~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/nodepath.h

  • Committer: Ted Gould
  • Date: 2008-11-21 05:24:08 UTC
  • Revision ID: ted@canonical.com-20081121052408-tilucis2pjrrpzxx
MergeĀ fromĀ fe-moved

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
class Radial{
52
52
 public:
53
53
/**  Radius */
54
 
        double r;
 
54
    double r;
55
55
/**  Amplitude */
56
 
        double a;
57
 
        Radial() {}
58
 
        //      Radial(Geom::Point const &p); // Convert a point to radial coordinates
59
 
        Radial(Radial &p) : r(p.r),a(p.a) {}
60
 
        //      operator Geom::Point() const;
 
56
    double a;
 
57
    Radial() {}
 
58
    //  Radial(Geom::Point const &p); // Convert a point to radial coordinates
 
59
    Radial(Radial &p) : r(p.r),a(p.a) {}
 
60
    //  operator Geom::Point() const;
61
61
 
62
62
/**
63
63
 * Construct Radial from Geom::Point.
64
64
 */
65
65
Radial(Geom::Point const &p)
66
66
{
67
 
        r = Geom::L2(p);
68
 
        if (r > 0) {
69
 
                a = Geom::atan2 (p);
70
 
        } else {
71
 
                a = HUGE_VAL; //undefined
72
 
        }
 
67
    r = Geom::L2(p);
 
68
    if (r > 0) {
 
69
        a = Geom::atan2 (p);
 
70
    } else {
 
71
        a = HUGE_VAL; //undefined
 
72
    }
73
73
}
74
74
 
75
75
/**
77
77
 */
78
78
operator Geom::Point() const
79
79
{
80
 
        if (a == HUGE_VAL) {
81
 
                return Geom::Point(0,0);
82
 
        } else {
83
 
                return r*Geom::Point(cos(a), sin(a));
84
 
        }
 
80
    if (a == HUGE_VAL) {
 
81
        return Geom::Point(0,0);
 
82
    } else {
 
83
        return r*Geom::Point(cos(a), sin(a));
 
84
    }
85
85
}
86
86
 
87
87
};
118
118
class SubPath {
119
119
 public:
120
120
/**  The parent of this subpath */
121
 
        Path * nodepath;
 
121
    Path * nodepath;
122
122
/**  Is this path closed (no endpoints) or not?*/
123
 
        gboolean closed;
 
123
    gboolean closed;
124
124
/**  The nodes in this subpath. */
125
 
        GList * nodes;
 
125
    GList * nodes;
126
126
/**  The first node of the subpath (does not imply open/closed)*/
127
 
        Node * first;
 
127
    Node * first;
128
128
/**  The last node of the subpath */
129
 
        Node * last;
 
129
    Node * last;
130
130
};
131
131
 
132
132
 
140
140
 */
141
141
typedef enum {
142
142
/**  A normal node */
143
 
        NODE_NONE,
 
143
    NODE_NONE,
144
144
/**  This node non-continuously joins two segments.*/
145
 
        NODE_CUSP,
 
145
    NODE_CUSP,
146
146
/**  This node continuously joins two segments. */
147
 
        NODE_SMOOTH,
 
147
    NODE_SMOOTH,
148
148
/**  This node has automatic handles. */
149
 
        NODE_AUTO,
 
149
    NODE_AUTO,
150
150
/**  This node is symmetric. */
151
 
        NODE_SYMM
 
151
    NODE_SYMM
152
152
} NodeType;
153
153
 
154
154
 
160
160
class NodeSide{
161
161
 public:
162
162
/**  Pointer to the next node, */
163
 
        Node * other;
 
163
    Node * other;
164
164
/**  Position */
165
 
        Geom::Point pos;
 
165
    Geom::Point pos;
166
166
/**  Origin (while dragging) in radial notation */
167
 
        Radial origin_radial;
 
167
    Radial origin_radial;
168
168
/**  Origin (while dragging) in x/y notation */
169
 
        Geom::Point origin;
 
169
    Geom::Point origin;
170
170
/**  Knots are Inkscape's way of providing draggable points.  This
171
171
 *  Knot is the point on the curve representing the control point in a
172
172
 *  bezier curve.*/
173
 
        SPKnot * knot;
 
173
    SPKnot * knot;
174
174
/**  What kind of rendering? */
175
 
        SPCanvasItem * line;
 
175
    SPCanvasItem * line;
176
176
};
177
177
 
178
178
/**
181
181
class Node {
182
182
 public:
183
183
/**  The parent subpath of this node */
184
 
        SubPath * subpath;
 
184
    SubPath * subpath;
185
185
/**  Type is selected from NodeType.*/
186
 
        guint type : 4;
 
186
    guint type : 4;
187
187
/**  Code refers to which ArtCode is used to represent the segment
188
188
 *  (which segment?).*/
189
 
        guint code : 4;
 
189
    guint code : 4;
190
190
/**  Boolean.  Am I currently selected or not? */
191
 
        guint selected : 1;
192
 
/**  */
193
 
        Geom::Point pos;
194
 
/**  */
195
 
        Geom::Point origin;
 
191
    guint selected : 1;
 
192
/**  */
 
193
    Geom::Point pos;
 
194
/**  */
 
195
    Geom::Point origin;
196
196
/**  Knots are Inkscape's way of providing draggable points.  This
197
197
 *  Knot is the point on the curve representing the endpoint.*/
198
 
        SPKnot * knot;
 
198
    SPKnot * knot;
199
199
/**  The NodeSide in the 'next' direction */
200
 
        NodeSide n;
 
200
    NodeSide n;
201
201
/**  The NodeSide in the 'previous' direction */
202
 
        NodeSide p;
 
202
    NodeSide p;
203
203
 
204
 
        /** The pointer to the nodeside which we are dragging out with Shift */
205
 
        NodeSide *dragging_out;
 
204
    /** The pointer to the nodeside which we are dragging out with Shift */
 
205
    NodeSide *dragging_out;
206
206
  
207
207
  /** Boolean.  Am I being dragged? */
208
208
  guint is_dragging : 1;
221
221
 */
222
222
class Path {
223
223
 public:
 
224
    /** Constructor should private, people should create new nodepaths using sp_nodepath_new
 
225
     *  But for some reason I cannot make sp_nodepath_new a friend :-(
 
226
     */
 
227
    Path() {};
 
228
    /** Destructor */
 
229
    ~Path();
 
230
 
224
231
/**  Pointer to the current desktop, for reporting purposes */
225
 
        SPDesktop * desktop;
 
232
    SPDesktop * desktop;
226
233
/**  The parent path of this nodepath */
227
 
        SPObject * object;
 
234
    SPObject * object;
228
235
/**  The parent livepatheffect of this nodepath, if applicable */
229
236
    SPItem * item;
230
237
/**  The context which created this nodepath.  Important if this nodepath is deleted */
231
 
        ShapeEditor *shape_editor;
 
238
    ShapeEditor *shape_editor;
232
239
/**  The subpaths which comprise this NodePath */
233
 
        GList * subpaths;
 
240
    GList * subpaths;
234
241
/**  A list of nodes which are currently selected */
235
 
        GList * selected;
 
242
    GList * selected;
236
243
/**  Transforms (userspace <---> virtual space?   someone please describe )
237
 
         njh: I'd be guessing that these are item <-> desktop transforms.*/
238
 
        Geom::Matrix i2d, d2i;
 
244
     njh: I'd be guessing that these are item <-> desktop transforms.*/
 
245
    Geom::Matrix i2d, d2i;
239
246
/**  The DOM node which describes this NodePath */
240
247
    Inkscape::XML::Node *repr;
241
248
    gchar *repr_key;
242
249
    gchar *repr_nodetypes_key;
243
 
        //STL compliant method to get the selected nodes
244
 
        void selection(std::list<Node *> &l);
 
250
    //STL compliant method to get the selected nodes
 
251
    void selection(std::list<Node *> &l);
245
252
 
246
 
        guint numSelected() {return (selected? g_list_length(selected) : 0);}
247
 
        Geom::Point& singleSelectedCoords() {return (((Node *) selected->data)->pos);}
 
253
    guint numSelected() {return (selected? g_list_length(selected) : 0);}
 
254
    Geom::Point& singleSelectedCoords() {return (((Node *) selected->data)->pos);}
248
255
 
249
256
    /// draw a "sketch" of the path by using these variables
250
257
    SPCanvasItem *helper_path;
254
261
    gdouble helperpath_width;
255
262
 
256
263
    // the helperpaths provided by all LPEs (and their paramaters) of the current item
257
 
    HelperPathList* helper_path_vec;
 
264
    HelperPathList helper_path_vec;
258
265
 
259
266
      /// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop
260
 
        unsigned int local_change;
 
267
    unsigned int local_change;
261
268
 
262
 
        /// true if we're showing selected nodes' handles
263
 
        bool show_handles;
 
269
    /// true if we're showing selected nodes' handles
 
270
    bool show_handles;
264
271
 
265
272
    /// true if the path cannot contain curves, just straight lines
266
273
    bool straight_path;
267
274
 
268
 
        /// active_node points to the node that is currently mouseovered (= NULL if
269
 
        /// there isn't any); we also consider the node mouseovered if it is covered
270
 
        /// by one of its handles and the latter is mouseovered
271
 
        static Node *active_node;
 
275
    /// active_node points to the node that is currently mouseovered (= NULL if
 
276
    /// there isn't any); we also consider the node mouseovered if it is covered
 
277
    /// by one of its handles and the latter is mouseovered
 
278
    static Node *active_node;
272
279
};
273
280
 
274
281
}  // namespace NodePath
282
289
 
283
290
// Do function documentation in nodepath.cpp
284
291
Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPObject *object, bool show_handles, const char * repr_key = NULL, SPItem *item = NULL);
285
 
void sp_nodepath_destroy (Inkscape::NodePath::Path * nodepath);
286
292
void sp_nodepath_deselect (Inkscape::NodePath::Path *nodepath);
287
293
void sp_nodepath_select_all (Inkscape::NodePath::Path *nodepath, bool invert);
288
294
void sp_nodepath_select_all_from_subpath(Inkscape::NodePath::Path *nodepath, bool invert);