1999-10-04 03:13:54 +08:00
|
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
|
*
|
|
|
|
|
* This file Copyright (C) 1999 Simon Budig
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __PATH_CURVES_H__
|
|
|
|
|
#define __PATH_CURVES_H__
|
|
|
|
|
|
2001-04-11 21:28:53 +08:00
|
|
|
|
#define PATH_TOOL_DEBUG
|
2001-04-07 22:55:39 +08:00
|
|
|
|
#ifdef PATH_TOOL_DEBUG
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define IMAGE_COORDS 1
|
|
|
|
|
#define AA_IMAGE_COORDS 2
|
|
|
|
|
#define SCREEN_COORDS 3
|
|
|
|
|
|
|
|
|
|
#define SEGMENT_ACTIVE 1
|
|
|
|
|
|
|
|
|
|
#define PATH_TOOL_DRAG 1
|
|
|
|
|
|
|
|
|
|
#define PATH_TOOL_REDRAW_ALL 1
|
|
|
|
|
#define PATH_TOOL_REDRAW_ACTIVE 2
|
|
|
|
|
#define PATH_TOOL_REDRAW_HANDLES 4
|
|
|
|
|
|
|
|
|
|
#define SUBDIVIDE 1000
|
|
|
|
|
|
|
|
|
|
typedef enum { SEGMENT_LINE=0, SEGMENT_BEZIER} SegmentType;
|
|
|
|
|
|
|
|
|
|
enum { ON_ANCHOR, ON_HANDLE, ON_CURVE, ON_CANVAS };
|
|
|
|
|
|
|
|
|
|
typedef struct _path_segment PathSegment;
|
|
|
|
|
typedef struct _path_curve PathCurve;
|
|
|
|
|
typedef struct _npath NPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct _path_segment
|
|
|
|
|
{
|
|
|
|
|
SegmentType type; /* What type of segment */
|
|
|
|
|
gdouble x, y; /* location of starting-point in image space */
|
|
|
|
|
gpointer data; /* Additional data, dependant of segment-type */
|
|
|
|
|
|
|
|
|
|
guint32 flags; /* Various Flags: Is the Segment active? */
|
|
|
|
|
|
|
|
|
|
PathCurve *parent; /* the parent Curve */
|
|
|
|
|
PathSegment *next; /* Next Segment or NULL */
|
|
|
|
|
PathSegment *prev; /* Previous Segment or NULL */
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct _path_curve
|
|
|
|
|
{
|
|
|
|
|
PathSegment *segments; /* The segments of the curve */
|
|
|
|
|
PathSegment *cur_segment; /* the current segment */
|
|
|
|
|
NPath *parent; /* the parent Path */
|
|
|
|
|
PathCurve *next; /* Next Curve or NULL */
|
|
|
|
|
PathCurve *prev; /* Previous Curve or NULL */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct _npath
|
|
|
|
|
{
|
|
|
|
|
PathCurve *curves; /* the curves */
|
|
|
|
|
PathCurve *cur_curve; /* the current curve */
|
|
|
|
|
GString *name; /* the name of the path */
|
|
|
|
|
guint32 state; /* is the path locked? */
|
|
|
|
|
/* GimpPathTool *path_tool; */ /* The parent Path Tool */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef void
|
|
|
|
|
(*PathTraverseFunc) (NPath *,
|
|
|
|
|
PathCurve *,
|
|
|
|
|
gpointer);
|
|
|
|
|
typedef void
|
|
|
|
|
(*CurveTraverseFunc) (NPath *,
|
|
|
|
|
PathCurve *,
|
|
|
|
|
PathSegment *,
|
|
|
|
|
gpointer);
|
|
|
|
|
typedef void
|
|
|
|
|
(*SegmentTraverseFunc) (NPath *,
|
|
|
|
|
PathCurve *,
|
|
|
|
|
PathSegment *,
|
|
|
|
|
gint,
|
|
|
|
|
gint,
|
|
|
|
|
gpointer);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This function is to get a set of npoints different coordinates for
|
|
|
|
|
* the range from start to end (each in the range from 0 to 1 and
|
|
|
|
|
* start < end).
|
|
|
|
|
* returns the number of created coords. Make sure that the points-
|
|
|
|
|
* Array is allocated.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef guint (*PathGetPointsFunc) (PathSegment *segment,
|
|
|
|
|
gdouble *points,
|
1999-10-04 03:13:54 +08:00
|
|
|
|
guint npoints,
|
|
|
|
|
gdouble start,
|
|
|
|
|
gdouble end);
|
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef void (*PathGetPointFunc) (PathSegment *segment,
|
1999-10-04 03:13:54 +08:00
|
|
|
|
gdouble position,
|
|
|
|
|
gdouble *x,
|
|
|
|
|
gdouble *y);
|
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef void (*PathDrawHandlesFunc) (GimpDrawTool *tool,
|
1999-10-04 03:13:54 +08:00
|
|
|
|
PathSegment *segment);
|
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef void (*PathDrawSegmentFunc) (GimpDrawTool *tool,
|
1999-10-04 03:13:54 +08:00
|
|
|
|
PathSegment *segment);
|
|
|
|
|
|
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef gdouble (*PathOnSegmentFunc) (PathSegment *segment,
|
1999-10-04 03:13:54 +08:00
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint halfwidth,
|
|
|
|
|
gint *distance);
|
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef void (*PathDragSegmentFunc) (PathSegment *segment,
|
1999-10-04 03:13:54 +08:00
|
|
|
|
gdouble position,
|
1999-10-08 18:22:39 +08:00
|
|
|
|
gdouble dx,
|
|
|
|
|
gdouble dy);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef gint (*PathOnHandlesFunc) (PathSegment *segment,
|
1999-10-08 18:22:39 +08:00
|
|
|
|
gdouble x,
|
|
|
|
|
gdouble y,
|
|
|
|
|
gdouble halfwidth);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef void (*PathDragHandleFunc) (PathSegment *segment,
|
1999-10-08 18:22:39 +08:00
|
|
|
|
gdouble dx,
|
|
|
|
|
gdouble dy,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gint handle_id);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef PathSegment * (*PathInsertAnchorFunc) (PathSegment *segment,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gdouble position);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
2001-04-07 22:55:39 +08:00
|
|
|
|
typedef void (*PathUpdateSegmentFunc) (PathSegment *segment);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
1999-10-08 18:22:39 +08:00
|
|
|
|
typedef void (*PathFlipSegmentFunc) (PathSegment *segment);
|
1999-10-07 07:24:22 +08:00
|
|
|
|
|
1999-10-08 18:22:39 +08:00
|
|
|
|
typedef void (*PathInitSegmentFunc) (PathSegment *segment);
|
1999-10-07 07:24:22 +08:00
|
|
|
|
|
1999-10-08 18:22:39 +08:00
|
|
|
|
typedef void (*PathCleanupSegmentFunc) (PathSegment *segment);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
typedef struct {
|
1999-10-07 07:24:22 +08:00
|
|
|
|
PathGetPointsFunc get_points;
|
|
|
|
|
PathGetPointFunc get_point;
|
|
|
|
|
PathDrawHandlesFunc draw_handles;
|
|
|
|
|
PathDrawSegmentFunc draw_segment;
|
|
|
|
|
PathOnSegmentFunc on_segment;
|
|
|
|
|
PathDragSegmentFunc drag_segment;
|
|
|
|
|
PathOnHandlesFunc on_handles;
|
|
|
|
|
PathDragHandleFunc drag_handle;
|
|
|
|
|
PathInsertAnchorFunc insert_anchor;
|
|
|
|
|
PathUpdateSegmentFunc update_segment;
|
|
|
|
|
PathFlipSegmentFunc flip_segment;
|
|
|
|
|
PathInitSegmentFunc init_segment;
|
|
|
|
|
PathCleanupSegmentFunc cleanup_segment;
|
1999-10-04 03:13:54 +08:00
|
|
|
|
} CurveDescription;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guint
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_get_points (PathSegment *segment,
|
|
|
|
|
gdouble *points,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
guint npoints,
|
|
|
|
|
gdouble start,
|
|
|
|
|
gdouble end);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_get_point (PathSegment *segment,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gdouble position,
|
|
|
|
|
gdouble *x,
|
|
|
|
|
gdouble *y);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_draw_handles (GimpDrawTool *tool,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
PathSegment *segment);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_draw_segment (GimpDrawTool *tool,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
PathSegment *segment);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gdouble
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_on_segment (PathSegment *segment,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint halfwidth,
|
|
|
|
|
gint *distance);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_drag_segment (PathSegment *segment,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gdouble position,
|
1999-10-08 18:22:39 +08:00
|
|
|
|
gdouble dx,
|
|
|
|
|
gdouble dy);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gint
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_on_handle (PathSegment *segment,
|
1999-10-08 18:22:39 +08:00
|
|
|
|
gdouble x,
|
|
|
|
|
gdouble y,
|
|
|
|
|
gdouble halfwidth);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_drag_handle (PathSegment *segment,
|
1999-10-08 18:22:39 +08:00
|
|
|
|
gdouble dx,
|
|
|
|
|
gdouble dy,
|
1999-10-07 07:24:22 +08:00
|
|
|
|
gint handle_id);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
PathSegment *
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_insert_anchor (PathSegment *segment,
|
|
|
|
|
gdouble position);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
2001-04-07 22:55:39 +08:00
|
|
|
|
path_curve_update_segment (PathSegment *segment);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
void
|
1999-10-08 18:22:39 +08:00
|
|
|
|
path_curve_flip_segment (PathSegment *segment);
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
1999-10-07 07:24:22 +08:00
|
|
|
|
void
|
1999-10-08 18:22:39 +08:00
|
|
|
|
path_curve_init_segment (PathSegment *segment);
|
1999-10-07 07:24:22 +08:00
|
|
|
|
|
|
|
|
|
void
|
1999-10-08 18:22:39 +08:00
|
|
|
|
path_curve_cleanup_segment (PathSegment *segment);
|
1999-10-07 07:24:22 +08:00
|
|
|
|
|
1999-10-04 03:13:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This is, what Soleil (Olofs little daughter) has to say to this:
|
|
|
|
|
|
|
|
|
|
fc fc g hgvfvv drrrrrrtcc jctfcz w sdzs d bx cv^[ ^[c^[f c
|
|
|
|
|
vffvcccccccccccccggfc fvx^[c^[x^[x^[x^[x^[x^[x^[ v xbvcbvcxv cxxc xxxx^[x
|
|
|
|
|
xz^[c^[x^[x^[x^[x^[x^[x^[xxxxxxcccccccxxxxxxxxxxxxxxxv<EFBFBD>"<EFBFBD>p'
|
|
|
|
|
hj^[[24~^[[4~^[[1~^[[4~^[[1~^[[4~ ^[[D^[[Bk^[[B,,,,,
|
|
|
|
|
,^[[2~^[[4~^[[6~^[[4~l^[[6~,l' .holg^[[B^[[B n,,klmj ^[[B^[[1~j ^[[P^[[B
|
|
|
|
|
^[[D^[[4~^[[6~nb ^[[A^[[C ^[[Akj^[[B ^[[A^[[C^[[A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...^[[1~^[[D^[[4~^[[2~^[[C^[[B,^[[A^[[2~^[[C^[[2~^[[A^[[3~^[[A^[[4~ ^[[2~
|
|
|
|
|
^[[2~p<EFBFBD>- ., <EFBFBD>^[[A<EFBFBD>pl., k,km ,
|
|
|
|
|
m,^[[5~^[[6~^[[2~^[[C^[[3~p^[[A^[[B<EFBFBD>^[[2~^[[B^[[6~^[[1~, .^[[D^[[4~^[[2~^[[Db
|
|
|
|
|
.l, .,.,m ^[[2~p<EFBFBD>l. ik
|
|
|
|
|
^[[20~kl9i^[[20~^[[20~^[[20~^[[21~^[[21~^[[21~^[[21~^[[21~^[[21~^[[20~m +
|
|
|
|
|
^[[A^[[5~^[[G^[[D ^[[5~^[[1+^[[C
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endif /* __PATH_CURVES_H__ */
|
|
|
|
|
|