app/path_curves.[ch] app/tools/gimpdrawtool.c app/tools/gimppathtool.[ch]

2001-04-11  Simon Budig  <simon@gimp.org>

        * app/path_curves.[ch]
        * app/tools/gimpdrawtool.c
        * app/tools/gimppathtool.[ch]
        * app/tools/path_tool.[ch]
        * app/tools/path_toolP.h

        At least now it looks as if it could do something sometimes...
This commit is contained in:
Simon Budig 2001-04-11 13:28:53 +00:00 committed by Simon Budig
parent 77094344d0
commit 5957eb4f4a
9 changed files with 124 additions and 87 deletions

View File

@ -1,3 +1,13 @@
2001-04-11 Simon Budig <simon@gimp.org>
* app/path_curves.[ch]
* app/tools/gimpdrawtool.c
* app/tools/gimppathtool.[ch]
* app/tools/path_tool.[ch]
* app/tools/path_toolP.h
At least now it looks as if it could do something sometimes...
2001-04-11 Michael Natterer <mitch@gimp.org>
* configure.in

View File

@ -93,7 +93,7 @@ path_curve_get_points (PathSegment *segment,
}
#ifdef PATH_TOOL_DEBUG
else
fprintf (stderr, "path_curve_get_point called without valid curve");
fprintf (stderr, "path_curve_get_points called without valid curve");
#endif
return 0;
}
@ -109,7 +109,7 @@ path_curve_get_point (PathSegment *segment,
if (CurveTypes[segment->type].get_point)
(* CurveTypes[segment->type].get_point) (segment, position, x, y);
else {
#if 0
#if 1
*x = segment->x + (segment->next->x - segment->x) * position;
*y = segment->y + (segment->next->y - segment->y) * position;
#else

View File

@ -20,7 +20,7 @@
#ifndef __PATH_CURVES_H__
#define __PATH_CURVES_H__
#undef PATH_TOOL_DEBUG
#define PATH_TOOL_DEBUG
#ifdef PATH_TOOL_DEBUG
#include <stdio.h>
#endif

View File

@ -256,7 +256,7 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
gdk_draw_arc (tool->gdisp->canvas->window,
draw_tool->gc, filled,
hx - size/2, hy - size/2,
size, size, 0, 360);
size, size, 0, 360*64);
}

View File

@ -191,13 +191,13 @@ gimp_path_tool_destroy (GtkObject *object)
GimpPathTool *path_tool = GIMP_PATH_TOOL (object);
#ifdef PATH_TOOL_DEBUG
fprintf (stderr, "tools_free_path_tool start\n");
fprintf (stderr, "gimp_path_tool_free start\n");
#endif PATH_TOOL_DEBUG
path_free_path (path_tool->cur_path);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
path_free_path (path_tool->cur_path);
}
static void
@ -240,16 +240,17 @@ gimp_path_tool_button_press (GimpTool *tool,
{
GimpPathTool *path_tool = GIMP_PATH_TOOL (tool);
gint grab_pointer=0;
gint x, y, halfwidth, dummy;
gdouble x, y;
gint halfwidth, dummy;
#ifdef PATH_TOOL_DEBUG
fprintf (stderr, "path_tool_button_press\n");
#endif PATH_TOOL_DEBUG
/* Transform window-coordinates to canvas-coordinates */
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0);
gdisplay_untransform_coords_f (gdisp, bevent->x, bevent->y, &x, &y, TRUE);
#ifdef PATH_TOOL_DEBUG
fprintf(stderr, "Clickcoordinates %d, %d\n",x,y);
fprintf(stderr, "Clickcoordinates %.2f, %.2f\n",x,y);
#endif PATH_TOOL_DEBUG
path_tool->click_x = x;
path_tool->click_y = y;
@ -259,6 +260,9 @@ gimp_path_tool_button_press (GimpTool *tool,
halfwidth -= x;
path_tool->click_halfwidth = halfwidth;
tool->gdisp = gdisp;
tool->state = ACTIVE;
if (!path_tool->cur_path->curves)
gimp_draw_tool_start (GIMP_DRAW_TOOL(path_tool), gdisp->canvas->window);
@ -303,7 +307,6 @@ gimp_path_tool_button_press (GimpTool *tool,
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
tool->state = ACTIVE;
}
@ -621,9 +624,9 @@ gimp_path_tool_motion_anchor (GimpPathTool *path_tool,
GDisplay *gdisp)
{
gdouble dx, dy, d;
gint x,y;
static gint dxsum = 0;
static gint dysum = 0;
gdouble x,y;
static gdouble dxsum = 0;
static gdouble dysum = 0;
/*
* Dont do anything, if the user clicked with pressed CONTROL-Key,
@ -639,7 +642,7 @@ gimp_path_tool_motion_anchor (GimpPathTool *path_tool,
dysum = 0;
}
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE);
dx = x - path_tool->click_x - dxsum;
dy = y - path_tool->click_y - dysum;
@ -687,9 +690,9 @@ gimp_path_tool_motion_handle (GimpPathTool *path_tool,
GDisplay *gdisp)
{
gdouble dx, dy;
gint x,y;
static gint dxsum = 0;
static gint dysum = 0;
gdouble x,y;
static gdouble dxsum = 0;
static gdouble dysum = 0;
/*
* Dont do anything, if the user clicked with pressed CONTROL-Key,
@ -706,7 +709,7 @@ gimp_path_tool_motion_handle (GimpPathTool *path_tool,
dysum = 0;
}
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE);
dx = x - path_tool->click_x - dxsum;
dy = y - path_tool->click_y - dysum;
@ -733,9 +736,9 @@ gimp_path_tool_motion_curve (GimpPathTool *path_tool,
GDisplay *gdisp)
{
gdouble dx, dy;
gint x,y;
static gint dxsum = 0;
static gint dysum = 0;
gdouble x,y;
static gdouble dxsum = 0;
static gdouble dysum = 0;
if (!(path_tool->state & PATH_TOOL_DRAG))
{
@ -744,7 +747,7 @@ gimp_path_tool_motion_curve (GimpPathTool *path_tool,
dysum = 0;
}
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE);
dx = x - path_tool->click_x - dxsum;
dy = y - path_tool->click_y - dysum;
@ -774,39 +777,37 @@ gimp_path_tool_cursor_update (GimpTool *tool,
{
GimpPathTool *path_tool = GIMP_PATH_TOOL (tool);
#if 0
gint x, y, halfwidth, dummy, cursor_location;
gint x, y, halfwidth, dummy, cursor_location;
#ifdef PATH_TOOL_DEBUG
/* fprintf (stderr, "path_tool_cursor_update\n");
*/
#endif PATH_TOOL_DEBUG
#idef PATH_TOOL_DEBUG
/* fprintf (stderr, "path_tool_cursor_update\n");
*/
#edif PATH_TOOL_DEBUG
path_tool = (PathTool *) tool->private;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
/* get halfwidth in image coord */
gdisplay_untransform_coords (gdisp, mevent->x + PATH_TOOL_HALFWIDTH, 0, &halfwidth, &dummy, TRUE, 0);
halfwidth -= x;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
/* get halfwidth in image coord */
gdisplay_untransform_coords (gdisp, mevent->x + PATH_TOOL_HALFWIDTH, 0, &halfwidth, &dummy, TRUE, 0);
halfwidth -= x;
cursor_location = path_tool_cursor_position (tool, x, y, halfwidth, NULL, NULL, NULL, NULL, NULL);
cursor_location = path_tool_cursor_position (tool, x, y, halfwidth, NULL, NULL, NULL, NULL, NULL);
switch (cursor_location) {
case ON_CANVAS:
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE1AP_CURSOR);
break;
case ON_ANCHOR:
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
break;
case ON_HANDLE:
gdisplay_install_tool_cursor (gdisp, GDK_CROSSHAIR);
break;
case ON_CURVE:
gdisplay_install_tool_cursor (gdisp, GDK_CROSSHAIR);
break;
default:
gdisplay_install_tool_cursor (gdisp, GDK_QUESTION_ARROW);
break;
}
switch (cursor_location) {
case ON_CANVAS:
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE1AP_CURSOR);
break;
case ON_ANCHOR:
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
break;
case ON_HANDLE:
gdisplay_install_tool_cursor (gdisp, GDK_CROSSHAIR);
break;
case ON_CURVE:
gdisplay_install_tool_cursor (gdisp, GDK_CROSSHAIR);
break;
default:
gdisplay_install_tool_cursor (gdisp, GDK_QUESTION_ARROW);
break;
}
/* New Syntax */
gdisplay_install_tool_cursor (gdisp,
@ -817,14 +818,41 @@ gimp_path_tool_cursor_update (GimpTool *tool,
}
/* This is a CurveTraverseFunc */
static void
gimp_path_tool_draw_helper (NPath *path,
PathCurve *curve,
PathSegment *segment,
gpointer tool)
{
GimpPathTool *path_tool;
GimpDrawTool *draw_tool;
gboolean draw = TRUE;
path_tool = GIMP_PATH_TOOL (tool);
draw_tool = GIMP_DRAW_TOOL (tool);
if (path_tool->draw & PATH_TOOL_REDRAW_ACTIVE)
draw = (segment->flags & SEGMENT_ACTIVE ||
(segment->next && segment->next->flags & SEGMENT_ACTIVE));
if (segment->flags & SEGMENT_ACTIVE)
gimp_draw_tool_draw_handle (draw_tool, segment->x, segment->y, PATH_TOOL_WIDTH, 2);
else
gimp_draw_tool_draw_handle (draw_tool, segment->x, segment->y, PATH_TOOL_WIDTH, 3);
if (segment->next)
path_curve_draw_segment (draw_tool, segment);
}
static void
gimp_path_tool_draw (GimpDrawTool *draw_tool)
{
GimpPathTool *path_tool;
GimpTool *tool;
path_tool = GIMP_PATH_TOOL (draw_tool);
tool = GIMP_TOOL (draw_tool);
path_traverse_path (path_tool->click_path, NULL, gimp_path_tool_draw_helper, NULL, draw_tool);
}

View File

@ -38,8 +38,8 @@ struct _GimpPathTool
GimpDrawTool parent_instance;
gint click_type; /* where did the user click? */
gint click_x; /* X-coordinate of the click */
gint click_y; /* Y-coordinate of the click */
gdouble click_x; /* X-coordinate of the click */
gdouble click_y; /* Y-coordinate of the click */
gint click_halfwidth;
guint click_modifier; /* what modifiers were pressed? */
NPath *click_path; /* On which Path/Curve/Segment */

View File

@ -41,6 +41,7 @@
#include "apptypes.h"
#include "path_curves.h"
#include "path_tool.h"
#include "gimppathtool.h"
/*
* Every new curve-type has to have a parameter between 0 and 1, and
@ -99,18 +100,18 @@ gdouble path_tool_on_curve (NPath *path,
/* Tools to manipulate paths, curves, segments */
PathCurve * path_add_curve (NPath *,
gint,
gint);
gdouble,
gdouble);
PathSegment * path_append_segment (NPath *,
PathCurve *,
SegmentType,
gint,
gint);
gdouble,
gdouble);
PathSegment * path_prepend_segment (NPath *,
PathCurve *,
SegmentType,
gint,
gint);
gdouble,
gdouble);
PathSegment * path_split_segment (PathSegment *,
gdouble);
void path_join_curves (PathSegment *,
@ -271,8 +272,8 @@ path_traverse_segment (NPath *path,
PathCurve *
path_add_curve (NPath * cur_path,
gint x,
gint y)
gdouble x,
gdouble y)
{
PathCurve * tmp = cur_path->curves;
PathCurve * new_curve = NULL;
@ -309,8 +310,8 @@ PathSegment *
path_append_segment (NPath * cur_path,
PathCurve * cur_curve,
SegmentType type,
gint x,
gint y)
gdouble x,
gdouble y)
{
PathSegment * tmp = cur_curve->segments;
PathSegment * new_segment = NULL;
@ -363,8 +364,8 @@ PathSegment *
path_prepend_segment (NPath * cur_path,
PathCurve * cur_curve,
SegmentType type,
gint x,
gint y)
gdouble x,
gdouble y)
{
PathSegment * tmp = cur_curve->segments;
PathSegment * new_segment = NULL;
@ -728,8 +729,8 @@ path_delete_segment (PathSegment *segment)
gint
path_tool_cursor_position (NPath *path,
gint x,
gint y,
gdouble x,
gdouble y,
gint halfwidth,
NPath **pathP,
PathCurve **curveP,
@ -1571,8 +1572,8 @@ typedef struct {
NPath *path;
PathCurve *curve;
PathSegment *segment;
gint testx;
gint testy;
gdouble testx;
gdouble testy;
gint distance;
gboolean found;
} Path_on_anchors_type;
@ -1605,8 +1606,8 @@ path_tool_on_anchors_helper (NPath *path,
gboolean
path_tool_on_anchors (NPath *path,
gint x,
gint y,
gdouble x,
gdouble y,
gint halfwidth,
NPath **ret_pathP,
PathCurve **ret_curveP,
@ -1645,8 +1646,8 @@ typedef struct {
NPath *path;
PathCurve *curve;
PathSegment *segment;
gint testx;
gint testy;
gdouble testx;
gdouble testy;
gint halfwidth;
gint handle_id;
gboolean found;
@ -1679,8 +1680,8 @@ path_tool_on_handles_helper (NPath *path,
gint
path_tool_on_handles (NPath *path,
gint x,
gint y,
gdouble x,
gdouble y,
gint halfwidth,
NPath **ret_pathP,
PathCurve **ret_curveP,
@ -1787,7 +1788,6 @@ path_set_flags_helper (NPath *path,
* is active, path_tool->single_active_segment points to it.
*/
#if 0
/* If SEGMENT_ACTIVE state has changed change the PathTool data
* accordingly.
*/
@ -1803,7 +1803,6 @@ path_set_flags_helper (NPath *path,
tmp_uint ^= GPOINTER_TO_UINT(segment);
tmp->path_tool->single_active_segment = GUINT_TO_POINTER(tmp_uint);
}
#endif
}
}

View File

@ -66,18 +66,18 @@ gdouble path_locate_point (NPath *,
/* Tools to manipulate paths, curves, segments */
PathCurve * path_add_curve (NPath *,
gint,
gint);
gdouble,
gdouble);
PathSegment * path_append_segment (NPath *,
PathCurve *,
SegmentType,
gint,
gint);
gdouble,
gdouble);
PathSegment * path_prepend_segment (NPath *,
PathCurve *,
SegmentType,
gint,
gint);
gdouble,
gdouble);
PathSegment * path_split_segment (PathSegment *,
gdouble);
void path_join_curves (PathSegment *,

View File

@ -67,7 +67,7 @@ struct _path_curve
{
PathSegment *segments; /* The segments of the curve */
PathSegment *cur_segment; /* the current segment */
NPath *parent; /* the parent Path */
NPath *parent; /* the parent Path */
PathCurve *next; /* Next Curve or NULL */
PathCurve *prev; /* Previous Curve or NULL */
};