mirror of https://github.com/GNOME/gimp.git
renamed transform_coords() to transform_coordinate(); same for the
2006-08-09 Sven Neumann <sven@gimp.org> * app/display/gimpdisplayshell-transform.[ch]: renamed transform_coords() to transform_coordinate(); same for the untransform variant. Added new functions transform_points() and transform_coords() that work on arrays. * app/display/gimpdisplayshell-autoscroll.c * app/display/gimpdisplayshell-callbacks.c: changed accordingly. * app/tools/gimpdrawtool.c (gimp_draw_tool_draw_lines) (gimp_draw_tool_draw_strokes): use the new transform functions.
This commit is contained in:
parent
99f44594bd
commit
1c33f14bcf
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2006-08-09 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-transform.[ch]: renamed
|
||||
transform_coords() to transform_coordinate(); same for the
|
||||
untransform variant. Added new functions transform_points() and
|
||||
transform_coords() that work on arrays.
|
||||
|
||||
* app/display/gimpdisplayshell-autoscroll.c
|
||||
* app/display/gimpdisplayshell-callbacks.c: changed accordingly.
|
||||
|
||||
* app/tools/gimpdrawtool.c (gimp_draw_tool_draw_lines)
|
||||
(gimp_draw_tool_draw_strokes): use the new transform functions.
|
||||
|
||||
2006-08-09 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimpiscissorstool.c (iscissors_draw_curve):
|
||||
|
|
|
@ -141,9 +141,9 @@ gimp_display_shell_autoscroll_timeout (gpointer data)
|
|||
AUTOSCROLL_DX * (gdouble) dx,
|
||||
AUTOSCROLL_DX * (gdouble) dy);
|
||||
|
||||
gimp_display_shell_untransform_coords (shell,
|
||||
&device_coords,
|
||||
&image_coords);
|
||||
gimp_display_shell_untransform_coordinate (shell,
|
||||
&device_coords,
|
||||
&image_coords);
|
||||
|
||||
if (gimp_tool_control_get_snap_to (active_tool->control))
|
||||
{
|
||||
|
|
|
@ -493,9 +493,9 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
time = gdk_event_get_time (event);
|
||||
|
||||
/* GimpCoords passed to tools are ALWAYS in image coordinates */
|
||||
gimp_display_shell_untransform_coords (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
gimp_display_shell_untransform_coordinate (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
|
||||
active_tool = tool_manager_get_active (gimp);
|
||||
|
||||
|
@ -935,9 +935,9 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
}
|
||||
|
||||
/* GimpCoords passed to tools are ALWAYS in image coordinates */
|
||||
gimp_display_shell_untransform_coords (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
gimp_display_shell_untransform_coordinate (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
|
||||
active_tool = tool_manager_get_active (gimp);
|
||||
|
||||
|
@ -995,9 +995,9 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
time = gdk_event_get_time (event);
|
||||
|
||||
/* GimpCoords passed to tools are ALWAYS in image coordinates */
|
||||
gimp_display_shell_untransform_coords (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
gimp_display_shell_untransform_coordinate (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
|
||||
if (active_tool &&
|
||||
gimp_tool_control_get_snap_to (active_tool->control))
|
||||
|
@ -1074,9 +1074,9 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
/* GimpCoords passed to tools are ALWAYS in
|
||||
* image coordinates
|
||||
*/
|
||||
gimp_display_shell_untransform_coords (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
gimp_display_shell_untransform_coordinate (shell,
|
||||
&display_coords,
|
||||
&image_coords);
|
||||
|
||||
if (gimp_tool_control_get_snap_to (active_tool->control))
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* gimp_display_shell_transform_coords:
|
||||
* gimp_display_shell_transform_coordinate:
|
||||
* @shell: a #GimpDisplayShell
|
||||
* @image_coords: image coordinates
|
||||
* @display_coords: returns the corresponding display coordinates
|
||||
|
@ -40,9 +40,9 @@
|
|||
* objects can be rendered at the correct points on the display.
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_transform_coords (GimpDisplayShell *shell,
|
||||
GimpCoords *image_coords,
|
||||
GimpCoords *display_coords)
|
||||
gimp_display_shell_transform_coordinate (GimpDisplayShell *shell,
|
||||
GimpCoords *image_coords,
|
||||
GimpCoords *display_coords)
|
||||
{
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
|
@ -64,18 +64,18 @@ gimp_display_shell_transform_coords (GimpDisplayShell *shell,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_untransform_coords:
|
||||
* gimp_display_shell_untransform_coordinate:
|
||||
* @shell: a #GimpDisplayShell
|
||||
* @display_coords: display coordinates
|
||||
* @image_coords: returns the corresonding image coordinates
|
||||
* @image_coords: returns the corresponding image coordinates
|
||||
*
|
||||
* Transforms from display coordinates to image coordinates, so that
|
||||
* points on the display can be mapped to points in the image.
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
|
||||
GimpCoords *display_coords,
|
||||
GimpCoords *image_coords)
|
||||
gimp_display_shell_untransform_coordinate (GimpDisplayShell *shell,
|
||||
GimpCoords *display_coords,
|
||||
GimpCoords *image_coords)
|
||||
{
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
|
@ -96,19 +96,6 @@ gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
|
|||
image_coords->y /= scaley;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_transform_xy:
|
||||
* @shell: a #GimpDisplayShell
|
||||
* @x: x coordinate of point in image coordinates
|
||||
* @y: y coordinate of point in image coordinate
|
||||
* @nx: returns the transformed x coordinate
|
||||
* @ny: returns the transformed y coordinate
|
||||
* @use_offsets: if %TRUE, the @x and @y coordinates are in the coordinate
|
||||
* system of the active drawable instead of the image
|
||||
*
|
||||
* Transforms from image coordinates to display coordinates, so that objects
|
||||
* can be rendered at the correct points on the display.
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_transform_xy (GimpDisplayShell *shell,
|
||||
gdouble x,
|
||||
|
@ -294,6 +281,110 @@ gimp_display_shell_untransform_xy_f (GimpDisplayShell *shell,
|
|||
*ny = (y + shell->offset_y) / scaley - offset_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_transform_points:
|
||||
* @shell: a #GimpDisplayShell
|
||||
* @points: array of x, y coordinate pairs
|
||||
* @coords: returns the corresponding display coordinates
|
||||
* @n_points: number of points
|
||||
* @use_offsets: if %TRUE, the @x and @y coordinates are in the coordinate
|
||||
* system of the active drawable instead of the image
|
||||
*
|
||||
* Transforms from image coordinates to display coordinates, so that
|
||||
* objects can be rendered at the correct points on the display.
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_transform_points (GimpDisplayShell *shell,
|
||||
const gdouble *points,
|
||||
GdkPoint *coords,
|
||||
gint n_points,
|
||||
gboolean use_offsets)
|
||||
{
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
gint offset_x = 0;
|
||||
gint offset_y = 0;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
/* transform from image coordinates to screen coordinates */
|
||||
scalex = SCALEFACTOR_X (shell);
|
||||
scaley = SCALEFACTOR_Y (shell);
|
||||
|
||||
if (use_offsets)
|
||||
gimp_item_offsets (GIMP_ITEM (gimp_image_active_drawable (shell->display->image)),
|
||||
&offset_x, &offset_y);
|
||||
|
||||
for (i = 0; i < n_points ; i++)
|
||||
{
|
||||
gdouble x = scalex * (points[i * 2] + offset_x) - shell->offset_x;
|
||||
gdouble y = scaley * (points[i * 2 + 1] + offset_y) - shell->offset_y;
|
||||
|
||||
/* The projected coordinates can easily overflow a gint in the
|
||||
case of big images at high zoom levels, so we clamp them here
|
||||
to avoid problems.
|
||||
*/
|
||||
x = CLAMP (x, G_MININT, G_MAXINT);
|
||||
y = CLAMP (y, G_MININT, G_MAXINT);
|
||||
|
||||
coords[i].x = PROJ_ROUND (x) + shell->disp_xoffset;
|
||||
coords[i].y = PROJ_ROUND (y) + shell->disp_yoffset;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_transform_coords:
|
||||
* @shell: a #GimpDisplayShell
|
||||
* @image_coords: array of image coordinates
|
||||
* @disp_coords: returns the corresponding display coordinates
|
||||
* @n_coords: number of coordinates
|
||||
* @use_offsets: if %TRUE, the @x and @y coordinates are in the coordinate
|
||||
* system of the active drawable instead of the image
|
||||
*
|
||||
* Transforms from image coordinates to display coordinates, so that
|
||||
* objects can be rendered at the correct points on the display.
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_transform_coords (GimpDisplayShell *shell,
|
||||
const GimpCoords *image_coords,
|
||||
GdkPoint *disp_coords,
|
||||
gint n_coords,
|
||||
gboolean use_offsets)
|
||||
{
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
gint offset_x = 0;
|
||||
gint offset_y = 0;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
/* transform from image coordinates to screen coordinates */
|
||||
scalex = SCALEFACTOR_X (shell);
|
||||
scaley = SCALEFACTOR_Y (shell);
|
||||
|
||||
if (use_offsets)
|
||||
gimp_item_offsets (GIMP_ITEM (gimp_image_active_drawable (shell->display->image)),
|
||||
&offset_x, &offset_y);
|
||||
|
||||
for (i = 0; i < n_coords ; i++)
|
||||
{
|
||||
gdouble x = scalex * (image_coords[i].x + offset_x) - shell->offset_x;
|
||||
gdouble y = scaley * (image_coords[i].y + offset_y) - shell->offset_y;
|
||||
|
||||
/* The projected coordinates can easily overflow a gint in the
|
||||
case of big images at high zoom levels, so we clamp them here
|
||||
to avoid problems.
|
||||
*/
|
||||
x = CLAMP (x, G_MININT, G_MAXINT);
|
||||
y = CLAMP (y, G_MININT, G_MAXINT);
|
||||
|
||||
disp_coords[i].x = PROJ_ROUND (x) + shell->disp_xoffset;
|
||||
disp_coords[i].y = PROJ_ROUND (y) + shell->disp_yoffset;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_untransform_viewport:
|
||||
* @shell: a #GimpDisplayShell
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
#define __GIMP_DISPLAY_SHELL_TRANSFORM_H__
|
||||
|
||||
|
||||
void gimp_display_shell_transform_coords (GimpDisplayShell *shell,
|
||||
GimpCoords *image_coords,
|
||||
GimpCoords *display_coords);
|
||||
void gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
|
||||
GimpCoords *display_coords,
|
||||
GimpCoords *image_coords);
|
||||
void gimp_display_shell_transform_coordinate (GimpDisplayShell *shell,
|
||||
GimpCoords *image_coords,
|
||||
GimpCoords *display_coords);
|
||||
void gimp_display_shell_untransform_coordinate (GimpDisplayShell *shell,
|
||||
GimpCoords *display_coords,
|
||||
GimpCoords *image_coords);
|
||||
|
||||
void gimp_display_shell_transform_xy (GimpDisplayShell *shell,
|
||||
gdouble x,
|
||||
|
@ -54,6 +54,17 @@ void gimp_display_shell_untransform_xy_f (GimpDisplayShell *shell,
|
|||
gdouble *ny,
|
||||
gboolean use_offsets);
|
||||
|
||||
void gimp_display_shell_transform_points (GimpDisplayShell *shell,
|
||||
const gdouble *points,
|
||||
GdkPoint *coords,
|
||||
gint n_points,
|
||||
gboolean use_offsets);
|
||||
void gimp_display_shell_transform_coords (GimpDisplayShell *shell,
|
||||
const GimpCoords *image_coords,
|
||||
GdkPoint *disp_coords,
|
||||
gint n_coords,
|
||||
gboolean use_offsets);
|
||||
|
||||
void gimp_display_shell_untransform_viewport (GimpDisplayShell *shell,
|
||||
gint *x,
|
||||
gint *y,
|
||||
|
|
|
@ -1134,7 +1134,6 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
|
|||
{
|
||||
GimpDisplayShell *shell;
|
||||
GdkPoint *coords;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
||||
|
||||
|
@ -1142,13 +1141,8 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
|
|||
|
||||
coords = g_new (GdkPoint, n_points);
|
||||
|
||||
for (i = 0; i < n_points ; i++)
|
||||
{
|
||||
gimp_display_shell_transform_xy (shell,
|
||||
points[i*2], points[i*2+1],
|
||||
&coords[i].x, &coords[i].y,
|
||||
use_offsets);
|
||||
}
|
||||
gimp_display_shell_transform_points (shell,
|
||||
points, coords, n_points, use_offsets);
|
||||
|
||||
if (filled)
|
||||
{
|
||||
|
@ -1175,7 +1169,6 @@ gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
|
|||
{
|
||||
GimpDisplayShell *shell;
|
||||
GdkPoint *coords;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
||||
|
||||
|
@ -1183,13 +1176,8 @@ gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
|
|||
|
||||
coords = g_new (GdkPoint, n_points);
|
||||
|
||||
for (i = 0; i < n_points ; i++)
|
||||
{
|
||||
gimp_display_shell_transform_xy (shell,
|
||||
points[i].x, points[i].y,
|
||||
&coords[i].x, &coords[i].y,
|
||||
use_offsets);
|
||||
}
|
||||
gimp_display_shell_transform_coords (shell,
|
||||
points, coords, n_points, use_offsets);
|
||||
|
||||
if (filled)
|
||||
{
|
||||
|
|
|
@ -495,7 +495,6 @@ iscissors_convert (GimpIscissorsTool *iscissors,
|
|||
guint n_points;
|
||||
GSList *list;
|
||||
ICurve *icurve;
|
||||
guint packed;
|
||||
gint i;
|
||||
gint index;
|
||||
|
||||
|
@ -517,7 +516,9 @@ iscissors_convert (GimpIscissorsTool *iscissors,
|
|||
|
||||
for (i = 0; i < n_points; i ++)
|
||||
{
|
||||
packed = GPOINTER_TO_INT (g_ptr_array_index (icurve->points, i));
|
||||
guint32 packed = GPOINTER_TO_INT (g_ptr_array_index (icurve->points,
|
||||
i));
|
||||
|
||||
points[i].x = packed & 0x0000ffff;
|
||||
points[i].y = packed >> 16;
|
||||
}
|
||||
|
@ -1780,7 +1781,7 @@ gradmap_tile_validate (TileManager *tm,
|
|||
else
|
||||
gradmap[j*COST_WIDTH + 1] = 255; /* reserved for weak gradient */
|
||||
|
||||
contin:
|
||||
contin:
|
||||
datah += srcPR.bytes;
|
||||
datav += srcPR.bytes;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue