1 #ifndef SEEN_SP_SHAPE_H
2 #define SEEN_SP_SHAPE_H
4 /*
5 * Base class for shapes, including <path> element
6 *
7 * Author:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * Abhishek Sharma
10 * Jon A. Cruz <jon@joncruz.org>
11 *
12 * Copyright (C) 1999-2002 Lauris Kaplinski
13 * Copyright (C) 2000-2001 Ximian, Inc.
14 * Copyright (C) 2008 Johan Engelen
15 *
16 * Released under GNU GPL, read the file 'COPYING' for more information
17 */
19 #include "display/display-forward.h"
20 #include "sp-lpe-item.h"
21 #include "sp-marker-loc.h"
22 #include <2geom/forward.h>
24 #include <sigc++/connection.h>
26 #define SP_TYPE_SHAPE (SPShape::getType ())
27 #define SP_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SHAPE, SPShape))
28 #define SP_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SHAPE, SPShapeClass))
29 #define SP_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SHAPE))
30 #define SP_IS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SHAPE))
32 #define SP_SHAPE_WRITE_PATH (1 << 2)
34 struct SPDesktop;
36 class SPShape : public SPLPEItem {
37 public:
38 SPCurve *curve;
40 SPObject *marker[SP_MARKER_LOC_QTY];
41 sigc::connection release_connect [SP_MARKER_LOC_QTY];
42 sigc::connection modified_connect [SP_MARKER_LOC_QTY];
44 static GType getType (void);
45 void setShape ();
46 SPCurve * getCurve ();
47 void setCurve (SPCurve *curve, unsigned int owner);
48 void setCurveInsync (SPCurve *curve, unsigned int owner);
49 int hasMarkers () const;
50 int numberOfMarkers (int type);
52 private:
53 static void sp_shape_init (SPShape *shape);
54 static void sp_shape_finalize (GObject *object);
56 static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
57 static void sp_shape_release (SPObject *object);
59 static void sp_shape_set(SPObject *object, unsigned key, gchar const *value);
60 static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags);
61 static void sp_shape_modified (SPObject *object, unsigned int flags);
62 static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
64 static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
65 static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
66 static void sp_shape_hide (SPItem *item, unsigned int key);
67 static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
69 static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai);
73 friend class SPShapeClass;
74 };
76 class SPShapeClass {
77 public:
78 SPLPEItemClass item_class;
80 /* Build bpath from extra shape attributes */
81 void (* set_shape) (SPShape *shape);
83 private:
84 static SPLPEItemClass *parent_class;
85 static void sp_shape_class_init (SPShapeClass *klass);
87 friend class SPShape;
88 };
90 void sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value);
92 Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2);
93 Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c);
94 Geom::Matrix sp_shape_marker_get_transform_at_end(Geom::Curve const & c);
96 #endif // SEEN_SP_SHAPE_H
98 /*
99 Local Variables:
100 mode:c++
101 c-file-style:"stroustrup"
102 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103 indent-tabs-mode:nil
104 fill-column:99
105 End:
106 */
107 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :