1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "edit_selection.h"
|
|
|
|
#include "ellipse_select.h"
|
|
|
|
#include "gdisplay.h"
|
|
|
|
#include "gimage_mask.h"
|
|
|
|
#include "rect_select.h"
|
|
|
|
/* private header file for rect_select data structure */
|
|
|
|
#include "rect_selectP.h"
|
1999-04-13 01:55:06 +08:00
|
|
|
#include "selection_options.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
|
|
|
/* the ellipse selection tool options */
|
|
|
|
SelectionOptions * ellipse_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/*************************************/
|
|
|
|
/* Ellipsoidal selection apparatus */
|
|
|
|
|
|
|
|
void
|
1999-04-19 05:22:41 +08:00
|
|
|
ellipse_select (GimpImage *gimage,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int w,
|
|
|
|
int h,
|
|
|
|
int op,
|
|
|
|
int antialias,
|
|
|
|
int feather,
|
|
|
|
double feather_radius)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Channel * new_mask;
|
|
|
|
|
|
|
|
/* if applicable, replace the current selection */
|
1999-05-05 17:10:35 +08:00
|
|
|
if (op == SELECTION_REPLACE)
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage_mask_clear (gimage);
|
|
|
|
else
|
|
|
|
gimage_mask_undo (gimage);
|
|
|
|
|
|
|
|
/* if feathering for rect, make a new mask with the
|
|
|
|
* rectangle and feather that with the old mask
|
|
|
|
*/
|
|
|
|
if (feather)
|
|
|
|
{
|
1998-06-29 08:24:44 +08:00
|
|
|
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
channel_combine_ellipse (new_mask, ADD, x, y, w, h, antialias);
|
|
|
|
channel_feather (new_mask, gimage_get_mask (gimage),
|
1999-05-07 07:10:29 +08:00
|
|
|
feather_radius,
|
|
|
|
feather_radius,
|
|
|
|
op, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
channel_delete (new_mask);
|
|
|
|
}
|
1999-05-05 17:10:35 +08:00
|
|
|
else if (op == SELECTION_INTERSECT)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-06-29 08:24:44 +08:00
|
|
|
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
channel_combine_ellipse (new_mask, ADD, x, y, w, h, antialias);
|
|
|
|
channel_combine_mask (gimage_get_mask (gimage), new_mask, op, 0, 0);
|
|
|
|
channel_delete (new_mask);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
channel_combine_ellipse (gimage_get_mask (gimage), op, x, y, w, h, antialias);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-04-09 06:25:54 +08:00
|
|
|
ellipse_select_draw (Tool *tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GDisplay * gdisp;
|
|
|
|
EllipseSelect * ellipse_sel;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) tool->gdisp_ptr;
|
|
|
|
ellipse_sel = (EllipseSelect *) tool->private;
|
|
|
|
|
|
|
|
x1 = MINIMUM (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w);
|
|
|
|
y1 = MINIMUM (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h);
|
|
|
|
x2 = MAXIMUM (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w);
|
|
|
|
y2 = MAXIMUM (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h);
|
|
|
|
|
|
|
|
gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0);
|
|
|
|
gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0);
|
|
|
|
|
|
|
|
gdk_draw_arc (ellipse_sel->core->win,
|
|
|
|
ellipse_sel->core->gc, 0,
|
|
|
|
x1, y1, (x2 - x1), (y2 - y1), 0, 23040);
|
|
|
|
}
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static void
|
1999-04-13 01:55:06 +08:00
|
|
|
ellipse_select_options_reset (void)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-04-13 01:55:06 +08:00
|
|
|
selection_options_reset (ellipse_options);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
Tool *
|
1999-07-03 01:40:10 +08:00
|
|
|
tools_new_ellipse_select (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Tool *tool;
|
|
|
|
EllipseSelect *private;
|
|
|
|
|
|
|
|
/* The tool options */
|
|
|
|
if (!ellipse_options)
|
1999-04-13 01:55:06 +08:00
|
|
|
{
|
|
|
|
ellipse_options =
|
|
|
|
selection_options_new (ELLIPSE_SELECT, ellipse_select_options_reset);
|
|
|
|
tools_register (ELLIPSE_SELECT, (ToolOptions *) ellipse_options);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool = tools_new_tool (ELLIPSE_SELECT);
|
|
|
|
private = g_new (EllipseSelect, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
private->core = draw_core_new (ellipse_select_draw);
|
|
|
|
/* Make the selection static, not blinking */
|
|
|
|
private->x = private->y = 0;
|
|
|
|
private->w = private->h = 0;
|
|
|
|
|
|
|
|
tool->private = (void *) private;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->button_press_func = rect_select_button_press;
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->button_release_func = rect_select_button_release;
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->motion_func = rect_select_motion;
|
|
|
|
tool->cursor_update_func = rect_select_cursor_update;
|
|
|
|
tool->control_func = rect_select_control;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-04-09 06:25:54 +08:00
|
|
|
tools_free_ellipse_select (Tool *tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
EllipseSelect *ellipse_sel;
|
|
|
|
|
|
|
|
ellipse_sel = (EllipseSelect *) tool->private;
|
|
|
|
|
|
|
|
draw_core_free (ellipse_sel->core);
|
|
|
|
g_free (ellipse_sel);
|
|
|
|
}
|