Code

Fix change in revision 9947 to be consistent with rest of the codebase.
[inkscape.git] / src / sp-offset.h
1 #ifndef __SP_OFFSET_H__
2 #define __SP_OFFSET_H__
4 /** \file
5  * SPOffset class.
6  *
7  * Authors:
8  *   Mitsuru Oka <oka326@parkcity.ne.jp>
9  *   Lauris Kaplinski <lauris@kaplinski.com>
10  * (of the sp-spiral.h upon which this file was created)
11  * Copyright (C) 1999-2002 Lauris Kaplinski
12  * Copyright (C) 2000-2001 Ximian, Inc.
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #include "sp-shape.h"
19 #include <sigc++/sigc++.h>
21 #define SP_TYPE_OFFSET            (sp_offset_get_type ())
22 #define SP_OFFSET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OFFSET, SPOffset))
23 #define SP_OFFSET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_OFFSET, SPOffsetClass))
24 #define SP_IS_OFFSET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OFFSET))
25 #define SP_IS_OFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_OFFSET))
27 class SPOffset;
28 class SPOffsetClass;
29 class SPUseReference;
31 /**
32  * SPOffset class.
33  *
34  * An offset is defined by curve and radius. The original curve is kept as
35  * a path in a sodipodi:original attribute. It's not possible to change
36  * the original curve.
37  *
38  * SPOffset is a derivative of SPShape, much like the SPSpiral or SPRect.
39  * The goal is to have a source shape (= originalPath), an offset (= radius)
40  * and compute the offset of the source by the radius. To get it to work,
41  * one needs to know what the source is and what the radius is, and how it's
42  * stored in the xml representation. The object itself is a "path" element,
43  * to get lots of shape functionality for free. The source is the easy part:
44  * it's stored in a "inkscape:original" attribute in the path. In case of
45  * "linked" offset, as they've been dubbed, there is an additional
46  * "inkscape:href" that contains the id of an element of the svg.
47  * When built, the object will attach a listener vector to that object and
48  * rebuild the "inkscape:original" whenever the href'd object changes. This
49  * is of course grossly inefficient, and also does not react to changes
50  * to the href'd during context stuff (like changing the shape of a star by
51  * dragging control points) unless the path of that object is changed during
52  * the context (seems to be the case for SPEllipse). The computation of the
53  * offset is done in sp_offset_set_shape(), a function that is called whenever
54  * a change occurs to the offset (change of source or change of radius).
55  * just like the sp-star and other, this path derivative can make control
56  * points, or more precisely one control point, that's enough to define the
57  * radius (look in object-edit).
58  */
59 struct SPOffset : public SPShape {
60     void *originalPath; ///< will be a livarot Path, just don't declare it here to please the gcc linker
61     char *original;     ///< SVG description of the source path
62     float rad;          ///< offset radius
64     /// for interactive setting of the radius
65     bool knotSet;
66     Geom::Point knot;
68     bool sourceDirty;
69     bool isUpdating;
71     gchar                *sourceHref;
72     SPUseReference       *sourceRef;
73     Inkscape::XML::Node  *sourceRepr; ///< the repr associated with that id
74     SPObject             *sourceObject;
76     sigc::connection _modified_connection;
77     sigc::connection _delete_connection;
78     sigc::connection _changed_connection;
79     sigc::connection _transformed_connection;
80 };
82 /// The SPOffset vtable.
83 struct SPOffsetClass
84 {
85   SPShapeClass parent_class;
86 };
89 /* Standard Gtk function */
90 GType sp_offset_get_type (void);
92 double sp_offset_distance_to_original (SPOffset * offset, Geom::Point px);
93 void sp_offset_top_point (SPOffset * offset, Geom::Point *px);
95 SPItem *sp_offset_get_source (SPOffset *offset);
97 #endif
99 /*
100   Local Variables:
101   mode:c++
102   c-file-style:"stroustrup"
103   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
104   indent-tabs-mode:nil
105   fill-column:99
106   End:
107 */
108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :