summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAbhishek Sharma Public <spyzerdotabhishek0at-signgmaildotcom>2010-07-14 18:10:35 +0000
committerAbhishek Sharma Public <spyzerdotabhishek0at-signgmaildotcom>2010-07-14 18:10:35 +0000
commitcde0571b44ec5b108907bda85971c49f3ceb1de8 (patch)
tree88f75682989d77787d297498b9bda9568a5e53f5 /src
parentSPObject c++ification finalized along with the beginning of XML Privatisation... (diff)
downloadinkscape-cde0571b44ec5b108907bda85971c49f3ceb1de8.tar.gz
inkscape-cde0571b44ec5b108907bda85971c49f3ceb1de8.zip
SPShape c++ified to the extent it was possible and more changes done for XML privatisation. Major changes yet to come.
(bzr r9546.1.7)
Diffstat (limited to 'src')
-rw-r--r--src/box3d-context.cpp36
-rw-r--r--src/box3d-side.cpp21
-rw-r--r--src/box3d-side.h2
-rw-r--r--src/conn-avoid-ref.cpp2
-rw-r--r--src/extension/internal/odf.cpp2
-rw-r--r--src/knotholder.cpp4
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/live_effects/lpe-knot.cpp2
-rw-r--r--src/live_effects/parameter/path.cpp2
-rw-r--r--src/lpe-tool-context.cpp4
-rw-r--r--src/path-chemistry.cpp2
-rw-r--r--src/sp-conn-end.cpp2
-rw-r--r--src/sp-ellipse.cpp10
-rw-r--r--src/sp-flowregion.cpp2
-rw-r--r--src/sp-item-group.cpp4
-rw-r--r--src/sp-line.cpp4
-rw-r--r--src/sp-offset.cpp16
-rw-r--r--src/sp-path.cpp10
-rw-r--r--src/sp-polygon.cpp4
-rw-r--r--src/sp-polyline.cpp2
-rw-r--r--src/sp-rect.cpp6
-rw-r--r--src/sp-shape.cpp192
-rw-r--r--src/sp-shape.h68
-rw-r--r--src/sp-spiral.cpp8
-rw-r--r--src/sp-star.cpp8
-rw-r--r--src/sp-use-reference.cpp2
-rw-r--r--src/spiral-context.cpp2
-rw-r--r--src/splivarot.cpp16
-rw-r--r--src/star-context.cpp2
-rw-r--r--src/ui/tool/path-manipulator.cpp2
30 files changed, 257 insertions, 182 deletions
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 354fa1234..e48f7e17d 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -573,7 +573,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
{
- SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
+ //SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
+ SPDesktop *desktop = bc.desktop;
if (!bc.item) {
@@ -582,7 +583,12 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
}
/* Create object */
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
+
+ /* Remove convoluted code. */
+ //Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
+
+ /*To be removed for directly accessing the XML Document*/
+ Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc;
Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
repr->setAttribute("sodipodi:type", "inkscape:box3d");
@@ -598,7 +604,8 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
repr->addChild(repr_side, NULL);
- Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
+ //Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
+ Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side));
guint desc = Box3D::int_to_face(i);
@@ -609,7 +616,28 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
/* Set style */
- box3d_side_apply_style(side);
+ /* Removed the faulty usage */
+ //box3d_side_apply_style(side);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ Glib::ustring descr = "/desktop/";
+ descr += box3d_side_axes_string(side);
+ descr += "/style";
+ Glib::ustring cur_style = prefs->getString(descr);
+
+ bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false);
+ if (use_current && !cur_style.empty()) {
+ // use last used style
+ side->setAttribute("style", cur_style.data());
+
+ } else {
+ // use default style
+ GString *pstring = g_string_new("");
+ g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side));
+ sp_desktop_apply_style_tool (desktop, side->getRepr(), pstring->str, false);
+ }
+
SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
}
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index be6d47db7..9059e9705 100644
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
@@ -117,7 +117,7 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
sp_repr_set_int(repr, "inkscape:box3dsidetype", side->dir1 ^ side->dir2 ^ side->front_or_rear);
}
- sp_shape_set_shape ((SPShape *) object);
+ ((SPShape *) object)->setShape ();
/* Duplicate the path */
SPCurve const *curve = ((SPShape *) object)->curve;
@@ -179,7 +179,7 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags)
if (flags & (SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- sp_shape_set_shape ((SPShape *) object);
+ ((SPShape *) object)->setShape ();
}
if (((SPObjectClass *) parent_class)->update)
@@ -251,19 +251,24 @@ box3d_side_set_shape (SPShape *shape)
/* Reset the shape'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
- sp_shape_set_curve_insync (shape, c, TRUE);
+ shape->setCurveInsync( c, TRUE);
if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
SPCurve *c_lpe = c->copy();
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
if (success) {
- sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+ shape->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
}
c->unref();
}
-void
+/* removed to be merged into box3d-context function sp_box3d_drag
+ * so as to remove the faulty mehcanism of accessing a parent's/base
+ * level class members from a derived subclass.
+ */
+
+/*void
box3d_side_apply_style (Box3DSide *side) {
Inkscape::XML::Node *repr_face = SP_OBJECT_REPR(SP_OBJECT(side));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -276,15 +281,15 @@ box3d_side_apply_style (Box3DSide *side) {
SPDesktop *desktop = inkscape_active_desktop();
bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false);
if (use_current && !cur_style.empty()) {
- /* use last used style */
+ // use last used style
repr_face->setAttribute("style", cur_style.data());
} else {
- /* use default style */
+ // use default style
GString *pstring = g_string_new("");
g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side));
sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false);
}
-}
+}*/
gchar *
box3d_side_axes_string(Box3DSide *side)
diff --git a/src/box3d-side.h b/src/box3d-side.h
index ba1431fab..6014ddaae 100644
--- a/src/box3d-side.h
+++ b/src/box3d-side.h
@@ -41,7 +41,7 @@ struct Box3DSideClass {
GType box3d_side_get_type (void);
void box3d_side_position_set (Box3DSide *side); // FIXME: Replace this by box3d_side_set_shape??
-void box3d_side_apply_style (Box3DSide *side);
+//void box3d_side_apply_style (Box3DSide *side);
gchar *box3d_side_axes_string(Box3DSide *side);
Persp3D *box3d_side_perspective(Box3DSide *side);
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index ed2aceb82..fd37fceed 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -484,7 +484,7 @@ static std::vector<Geom::Point> approxItemWithPoints(SPItem const *item, const G
}
else if (SP_IS_SHAPE(item))
{
- SPCurve* item_curve = sp_shape_get_curve(SP_SHAPE(item));
+ SPCurve* item_curve = SP_SHAPE(item)->getCurve();
// make sure it has an associated curve
if (item_curve)
{
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index aadb9ee17..bf8a70a14 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -2002,7 +2002,7 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
else if (SP_IS_SHAPE(item))
{
//g_message("### %s is a shape", nodeName.c_str());
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
}
else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
{
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index 6778e9ad8..23d610ad0 100644
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
@@ -122,7 +122,7 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state)
}
if (SP_IS_SHAPE(item)) {
- sp_shape_set_shape(SP_SHAPE(item));
+ SP_SHAPE(item)->setShape();
}
knot_holder->update_knots();
@@ -171,7 +171,7 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state)
}
if (SP_IS_SHAPE (item)) {
- sp_shape_set_shape(SP_SHAPE (item));
+ SP_SHAPE (item)->setShape();
}
this->update_knots();
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 6266fade0..2cc26e4e1 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -518,7 +518,7 @@ Effect::getHelperPaths(SPLPEItem *lpeitem)
// rather than copying PathVectors all over the place
if (show_orig_path) {
// add original path to helperpaths
- SPCurve* curve = sp_shape_get_curve (SP_SHAPE(lpeitem));
+ SPCurve* curve = SP_SHAPE(lpeitem)->getCurve ();
hp_vec.push_back(curve->get_pathvector());
}
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index a2476a098..d43213fe9 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -498,7 +498,7 @@ void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &p
if (SP_IS_PATH(lpeitem)) {
c = sp_path_get_curve_for_edit(SP_PATH(lpeitem));
} else {
- c = sp_shape_get_curve(SP_SHAPE(lpeitem));
+ c = SP_SHAPE(lpeitem)->getCurve();
}
if (c) {
Geom::PathVector subpaths = c->get_pathvector();
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index af4f84f59..bdbe126e2 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -366,7 +366,7 @@ PathParam::linked_modified(SPObject *linked_obj, guint /*flags*/)
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
- curve = sp_shape_get_curve(SP_SHAPE(linked_obj));
+ curve = SP_SHAPE(linked_obj)->getCurve();
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp
index 8eafa1711..1459cb460 100644
--- a/src/lpe-tool-context.cpp
+++ b/src/lpe-tool-context.cpp
@@ -472,7 +472,7 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select
for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
if (SP_IS_PATH(i->data)) {
path = SP_PATH(i->data);
- curve = sp_shape_get_curve(SP_SHAPE(path));
+ curve = SP_SHAPE(path)->getCurve();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(curve->get_pathvector());
canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), "");
if (!show)
@@ -514,7 +514,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc)
std::map<SPPath *, SPCanvasItem*>::iterator i;
for (i = lc->measuring_items->begin(); i != lc->measuring_items->end(); ++i) {
path = i->first;
- curve = sp_shape_get_curve(SP_SHAPE(path));
+ curve = SP_SHAPE(path)->getCurve();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector());
SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX));
SPUnit unit = sp_unit_get_by_id(unitid);
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 639c7fa00..12913fd85 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -534,7 +534,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
}
if (!curve)
diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp
index 3ad6954a2..07dd852f2 100644
--- a/src/sp-conn-end.cpp
+++ b/src/sp-conn-end.cpp
@@ -66,7 +66,7 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p
if (!SP_IS_SHAPE(item)) return false;
// make sure it has an associated curve
- SPCurve* item_curve = sp_shape_get_curve(SP_SHAPE(item));
+ SPCurve* item_curve = SP_SHAPE(item)->getCurve();
if (!item_curve) return false;
// apply transformations (up to common ancestor)
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index b5f0bdab6..7eb473d03 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -153,7 +153,7 @@ sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags)
ellipse->cy.update(em, ex, dy);
ellipse->rx.update(em, ex, dr);
ellipse->ry.update(em, ex, dr);
- sp_shape_set_shape((SPShape *) object);
+ ((SPShape *) object)->setShape();
}
if (((SPObjectClass *) ge_parent_class)->update)
@@ -190,7 +190,7 @@ static void sp_genericellipse_set_shape(SPShape *shape)
// unconditionally read the curve from d, if any, to preserve appearance
Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
SPCurve *cold = new SPCurve(pv);
- sp_shape_set_curve_insync (shape, cold, TRUE);
+ shape->setCurveInsync( cold, TRUE);
cold->unref();
}
return;
@@ -257,12 +257,12 @@ static void sp_genericellipse_set_shape(SPShape *shape)
/* Reset the shape'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
- sp_shape_set_curve_insync (shape, curve, TRUE);
+ shape->setCurveInsync( curve, TRUE);
if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
SPCurve *c_lpe = curve->copy();
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
if (success) {
- sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+ shape->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
}
@@ -855,7 +855,7 @@ static void
sp_arc_modified(SPObject *object, guint flags)
{
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- sp_shape_set_shape((SPShape *) object);
+ ((SPShape *) object)->setShape();
}
if (((SPObjectClass *) arc_parent_class)->modified)
diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp
index 29ee05f5e..cff7a5db7 100644
--- a/src/sp-flowregion.cpp
+++ b/src/sp-flowregion.cpp
@@ -520,7 +520,7 @@ static void GetDest(SPObject* child,Shape **computed)
tr_mat = SP_ITEM(u_child)->transform;
}
if ( SP_IS_SHAPE (u_child) ) {
- curve = sp_shape_get_curve (SP_SHAPE (u_child));
+ curve = SP_SHAPE (u_child)->getCurve ();
} else if ( SP_IS_TEXT (u_child) ) {
curve = SP_TEXT (u_child)->getNormalizedBpath ();
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 5b15ca326..56b9dbc21 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -858,12 +858,12 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
if (SP_IS_PATH(subitem)) {
c = sp_path_get_original_curve(SP_PATH(subitem));
} else {
- c = sp_shape_get_curve(SP_SHAPE(subitem));
+ c = SP_SHAPE(subitem)->getCurve();
}
// only run LPEs when the shape has a curve defined
if (c) {
sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
- sp_shape_set_curve(SP_SHAPE(subitem), c, TRUE);
+ SP_SHAPE(subitem)->setCurve(c, TRUE);
if (write) {
Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
diff --git a/src/sp-line.cpp b/src/sp-line.cpp
index 6d3d2aea7..b29e51b5a 100644
--- a/src/sp-line.cpp
+++ b/src/sp-line.cpp
@@ -158,7 +158,7 @@ SPLine::sp_line_update (SPObject *object, SPCtx *ctx, guint flags)
line->y1.update(em, ex, h);
line->y2.update(em, ex, h);
- sp_shape_set_shape ((SPShape *) object);
+ ((SPShape *) object)->setShape ();
}
if (((SPObjectClass *) SPLineClass::static_parent_class)->update)
@@ -244,7 +244,7 @@ SPLine::sp_line_set_shape (SPShape *shape)
c->moveto(line->x1.computed, line->y1.computed);
c->lineto(line->x2.computed, line->y2.computed);
- sp_shape_set_curve_insync (shape, c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update
+ shape->setCurveInsync (c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update
c->unref();
}
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index fdff5d7b6..449d7d44d 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -283,7 +283,7 @@ sp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
// Make sure the object has curve
- SPCurve *curve = sp_shape_get_curve (SP_SHAPE (offset));
+ SPCurve *curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL) {
sp_offset_set_shape (SP_SHAPE (offset));
}
@@ -410,7 +410,7 @@ sp_offset_update(SPObject *object, SPCtx *ctx, guint flags)
if (flags &
(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- sp_shape_set_shape ((SPShape *) object);
+ ((SPShape *) object)->setShape ();
}
offset->isUpdating=false;
@@ -465,7 +465,7 @@ sp_offset_set_shape(SPShape *shape)
Geom::PathVector pv = sp_svg_read_pathv(res_d);
SPCurve *c = new SPCurve(pv);
g_assert(c != NULL);
- sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE);
+ ((SPShape *) offset)->setCurveInsync (c, TRUE);
c->unref();
}
return;
@@ -714,7 +714,7 @@ sp_offset_set_shape(SPShape *shape)
Geom::PathVector pv = sp_svg_read_pathv(res_d);
SPCurve *c = new SPCurve(pv);
g_assert(c != NULL);
- sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE);
+ ((SPShape *) offset)->setCurveInsync (c, TRUE);
c->unref();
free (res_d);
@@ -954,11 +954,11 @@ sp_offset_top_point (SPOffset * offset, Geom::Point *px)
return;
}
- SPCurve *curve = sp_shape_get_curve (SP_SHAPE (offset));
+ SPCurve *curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL)
{
sp_offset_set_shape (SP_SHAPE (offset));
- curve = sp_shape_get_curve (SP_SHAPE (offset));
+ curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL)
return;
}
@@ -1082,7 +1082,7 @@ sp_offset_source_modified (SPObject */*iSource*/, guint /*flags*/, SPItem *item)
SPOffset *offset = SP_OFFSET(item);
offset->sourceDirty=true;
refresh_offset_source(offset);
- sp_shape_set_shape ((SPShape *) offset);
+ ((SPShape *) offset)->setShape ();
}
static void
@@ -1100,7 +1100,7 @@ refresh_offset_source(SPOffset* offset)
SPCurve *curve=NULL;
if (!SP_IS_SHAPE (item) && !SP_IS_TEXT (item)) return;
if (SP_IS_SHAPE (item)) {
- curve = sp_shape_get_curve (SP_SHAPE (item));
+ curve = SP_SHAPE (item)->getCurve ();
if (curve == NULL)
return;
}
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 5a0ff7c08..d98647b11 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -279,11 +279,11 @@ sp_path_set(SPObject *object, unsigned int key, gchar const *value)
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *curve = new SPCurve(pv);
if (curve) {
- sp_shape_set_curve((SPShape *) path, curve, TRUE);
+ ((SPShape *) path)->setCurve(curve, TRUE);
curve->unref();
}
} else {
- sp_shape_set_curve((SPShape *) path, NULL, TRUE);
+ ((SPShape *) path)->setCurve(NULL, TRUE);
}
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
@@ -425,7 +425,7 @@ g_message("sp_path_update_patheffect");
SPCurve *curve = path->original_curve->copy();
/* if a path does not have an lpeitem applied, then reset the curve to the original_curve.
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
- sp_shape_set_curve_insync(shape, curve, TRUE);
+ shape->setCurveInsync(curve, TRUE);
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
if (success && write) {
@@ -446,7 +446,7 @@ g_message("sp_path_update_patheffect writes 'd' attribute");
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *oldcurve = new SPCurve(pv);
if (oldcurve) {
- sp_shape_set_curve(shape, oldcurve, TRUE);
+ shape->setCurve(oldcurve, TRUE);
oldcurve->unref();
}
}
@@ -505,7 +505,7 @@ sp_path_get_curve_for_edit (SPPath *path)
sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) {
return sp_path_get_original_curve(path);
} else {
- return sp_shape_get_curve( (SPShape *) path );
+ return ((SPShape *) path)->getCurve();
}
}
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index b947e45ec..d5e10e10f 100644
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
@@ -116,7 +116,7 @@ static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::Do
SPShape *shape = SP_SHAPE(object);
// Tolerable workaround: we need to update the object's curve before we set points=
// because it's out of sync when e.g. some extension attrs of the polygon or star are changed in XML editor
- sp_shape_set_shape(shape);
+ shape->setShape();
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:polygon");
@@ -209,7 +209,7 @@ void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value)
* a single-point polygon in SPCurve. TODO: add a testcase with only one coordinate pair */
curve->closepath();
}
- sp_shape_set_curve(SP_SHAPE(polygon), curve, TRUE);
+ (SP_SHAPE(polygon))->setCurve(curve, TRUE);
curve->unref();
break;
}
diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp
index b5eb81a11..5bf40352d 100644
--- a/src/sp-polyline.cpp
+++ b/src/sp-polyline.cpp
@@ -141,7 +141,7 @@ SPPolyLine::sp_polyline_set (SPObject *object, unsigned int key, const gchar *va
}
}
- sp_shape_set_curve (SP_SHAPE (polyline), curve, TRUE);
+ (SP_SHAPE (polyline))->setCurve (curve, TRUE);
curve->unref();
break;
}
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 4e417f35b..5b75269dc 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -185,7 +185,7 @@ sp_rect_update(SPObject *object, SPCtx *ctx, guint flags)
rect->height.update(em, ex, h);
rect->rx.update(em, ex, w);
rect->ry.update(em, ex, h);
- sp_shape_set_shape((SPShape *) object);
+ ((SPShape *) object)->setShape();
flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
}
@@ -231,7 +231,7 @@ sp_rect_set_shape(SPShape *shape)
SPRect *rect = (SPRect *) shape;
if ((rect->height.computed < 1e-18) || (rect->width.computed < 1e-18)) {
- sp_shape_set_curve_insync(SP_SHAPE(rect), NULL, TRUE);
+ SP_SHAPE(rect)->setCurveInsync( NULL, TRUE);
return;
}
@@ -281,7 +281,7 @@ sp_rect_set_shape(SPShape *shape)
}
c->closepath();
- sp_shape_set_curve_insync(SP_SHAPE(rect), c, TRUE);
+ SP_SHAPE(rect)->setCurveInsync( c, TRUE);
c->unref();
}
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 8e8e22272..3b3e1108b 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -54,7 +54,7 @@
#define noSHAPE_VERBOSE
-static void sp_shape_class_init (SPShapeClass *klass);
+/*static void sp_shape_class_init (SPShapeClass *klass);
static void sp_shape_init (SPShape *shape);
static void sp_shape_finalize (GObject *object);
@@ -66,28 +66,30 @@ static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags);
static void sp_shape_modified (SPObject *object, unsigned int flags);
static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
+static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);*/
void sp_shape_print (SPItem * item, SPPrintContext * ctx);
-static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
+/*static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_shape_hide (SPItem *item, unsigned int key);
static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai);
-static SPLPEItemClass *parent_class;
+static SPLPEItemClass *parent_class;*/
+
+SPLPEItemClass * SPShapeClass::parent_class=0;
/**
* Registers the SPShape class with Gdk and returns its type number.
*/
GType
-sp_shape_get_type (void)
+SPShape::getType (void)
{
static GType type = 0;
if (!type) {
GTypeInfo info = {
sizeof (SPShapeClass),
NULL, NULL,
- (GClassInitFunc) sp_shape_class_init,
+ (GClassInitFunc) SPShapeClass::sp_shape_class_init,
NULL, NULL,
sizeof (SPShape),
16,
@@ -103,8 +105,8 @@ sp_shape_get_type (void)
* Initializes a SPShapeClass object. Establishes the function pointers to the class'
* member routines in the class vtable, and sets pointers to parent classes.
*/
-static void
-sp_shape_class_init (SPShapeClass *klass)
+void
+SPShapeClass::sp_shape_class_init (SPShapeClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass);
@@ -113,20 +115,20 @@ sp_shape_class_init (SPShapeClass *klass)
parent_class = (SPLPEItemClass *)g_type_class_peek_parent (klass);
- gobject_class->finalize = sp_shape_finalize;
+ gobject_class->finalize = SPShape::sp_shape_finalize;
- sp_object_class->build = sp_shape_build;
- sp_object_class->release = sp_shape_release;
- sp_object_class->set = sp_shape_set;
- sp_object_class->update = sp_shape_update;
- sp_object_class->modified = sp_shape_modified;
- sp_object_class->write = sp_shape_write;
+ sp_object_class->build = SPShape::sp_shape_build;
+ sp_object_class->release = SPShape::sp_shape_release;
+ sp_object_class->set = SPShape::sp_shape_set;
+ sp_object_class->update = SPShape::sp_shape_update;
+ sp_object_class->modified = SPShape::sp_shape_modified;
+ sp_object_class->write = SPShape::sp_shape_write;
- item_class->bbox = sp_shape_bbox;
+ item_class->bbox = SPShape::sp_shape_bbox;
item_class->print = sp_shape_print;
- item_class->show = sp_shape_show;
- item_class->hide = sp_shape_hide;
- item_class->snappoints = sp_shape_snappoints;
+ item_class->show = SPShape::sp_shape_show;
+ item_class->hide = SPShape::sp_shape_hide;
+ item_class->snappoints = SPShape::sp_shape_snappoints;
lpe_item_class->update_patheffect = NULL;
klass->set_shape = NULL;
@@ -135,8 +137,8 @@ sp_shape_class_init (SPShapeClass *klass)
/**
* Initializes an SPShape object.
*/
-static void
-sp_shape_init (SPShape *shape)
+void
+SPShape::sp_shape_init (SPShape *shape)
{
for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) {
new (&shape->release_connect[i]) sigc::connection();
@@ -146,8 +148,8 @@ sp_shape_init (SPShape *shape)
shape->curve = NULL;
}
-static void
-sp_shape_finalize (GObject *object)
+void
+SPShape::sp_shape_finalize (GObject *object)
{
SPShape *shape=(SPShape *)object;
@@ -158,8 +160,8 @@ sp_shape_finalize (GObject *object)
shape->modified_connect[i].~connection();
}
- if (((GObjectClass *) (parent_class))->finalize) {
- (* ((GObjectClass *) (parent_class))->finalize)(object);
+ if (((GObjectClass *) (SPShapeClass::parent_class))->finalize) {
+ (* ((GObjectClass *) (SPShapeClass::parent_class))->finalize)(object);
}
}
@@ -170,11 +172,11 @@ sp_shape_finalize (GObject *object)
*
* \see sp_object_build()
*/
-static void
-sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
+void
+SPShape::sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
- if (((SPObjectClass *) (parent_class))->build) {
- (*((SPObjectClass *) (parent_class))->build) (object, document, repr);
+ if (((SPObjectClass *) (SPShapeClass::parent_class))->build) {
+ (*((SPObjectClass *) (SPShapeClass::parent_class))->build) (object, document, repr);
}
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
@@ -192,8 +194,8 @@ sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
*
* \see sp_object_release()
*/
-static void
-sp_shape_release (SPObject *object)
+void
+SPShape::sp_shape_release (SPObject *object)
{
SPItem *item;
SPShape *shape;
@@ -217,26 +219,26 @@ sp_shape_release (SPObject *object)
shape->curve = shape->curve->unref();
}
- if (((SPObjectClass *) parent_class)->release) {
- ((SPObjectClass *) parent_class)->release (object);
+ if (((SPObjectClass *) SPShapeClass::parent_class)->release) {
+ ((SPObjectClass *) SPShapeClass::parent_class)->release (object);
}
}
-static void
-sp_shape_set(SPObject *object, unsigned int key, gchar const *value)
+void
+SPShape::sp_shape_set(SPObject *object, unsigned int key, gchar const *value)
{
- if (((SPObjectClass *) parent_class)->set) {
- ((SPObjectClass *) parent_class)->set(object, key, value);
+ if (((SPObjectClass *) SPShapeClass::parent_class)->set) {
+ ((SPObjectClass *) SPShapeClass::parent_class)->set(object, key, value);
}
}
-static Inkscape::XML::Node *
-sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
+Inkscape::XML::Node *
+SPShape::sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
{
- if (((SPObjectClass *)(parent_class))->write) {
- ((SPObjectClass *)(parent_class))->write(object, doc, repr, flags);
+ if (((SPObjectClass *)(SPShapeClass::parent_class))->write) {
+ ((SPObjectClass *)(SPShapeClass::parent_class))->write(object, doc, repr, flags);
}
return repr;
@@ -246,14 +248,14 @@ sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::No
* Updates the shape when its attributes have changed. Also establishes
* marker objects to match the style settings.
*/
-static void
-sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
+void
+SPShape::sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
{
SPItem *item = (SPItem *) object;
SPShape *shape = (SPShape *) object;
- if (((SPObjectClass *) (parent_class))->update) {
- (* ((SPObjectClass *) (parent_class))->update) (object, ctx, flags);
+ if (((SPObjectClass *) (SPShapeClass::parent_class))->update) {
+ (* ((SPObjectClass *) (SPShapeClass::parent_class))->update) (object, ctx, flags);
}
/* This stanza checks that an object's marker style agrees with
@@ -293,7 +295,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
}
}
- if (sp_shape_has_markers (shape)) {
+ if (shape->hasMarkers ()) {
/* Dimension marker views */
for (SPItemView *v = item->display; v != NULL; v = v->next) {
if (!v->arenaitem->key) {
@@ -303,7 +305,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
if (shape->marker[i]) {
sp_marker_show_dimension ((SPMarker *) shape->marker[i],
NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i,
- sp_shape_number_of_markers (shape, i));
+ shape->numberOfMarkers (i));
}
}
}
@@ -402,8 +404,8 @@ sp_shape_marker_get_transform_at_end(Geom::Curve const & c)
*
* @todo figure out what to do when both 'marker' and for instance 'marker-end' are set.
*/
-static void
-sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai)
+void
+SPShape::sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai)
{
SPStyle *style = ((SPObject *) shape)->style;
@@ -511,13 +513,13 @@ sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai)
/**
* Sets modified flag for all sub-item views.
*/
-static void
-sp_shape_modified (SPObject *object, unsigned int flags)
+void
+SPShape::sp_shape_modified (SPObject *object, unsigned int flags)
{
SPShape *shape = SP_SHAPE (object);
- if (((SPObjectClass *) (parent_class))->modified) {
- (* ((SPObjectClass *) (parent_class))->modified) (object, flags);
+ if (((SPObjectClass *) (SPShapeClass::parent_class))->modified) {
+ (* ((SPObjectClass *) (SPShapeClass::parent_class))->modified) (object, flags);
}
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
@@ -531,7 +533,7 @@ sp_shape_modified (SPObject *object, unsigned int flags)
* Calculates the bounding box for item, storing it into bbox.
* This also includes the bounding boxes of any markers included in the shape.
*/
-static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
+void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SPShape const *shape = SP_SHAPE (item);
if (shape->curve) {
@@ -585,7 +587,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
}
// Union with bboxes of the markers, if any
- if (sp_shape_has_markers (shape)) {
+ if (shape->hasMarkers ()) {
/** \todo make code prettier! */
Geom::PathVector const & pathv = shape->curve->get_pathvector();
// START marker
@@ -871,8 +873,8 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
/**
* Sets style, path, and paintbox. Updates marker views, including dimensions.
*/
-static NRArenaItem *
-sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/)
+NRArenaItem *
+SPShape::sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/)
{
SPObject *object = SP_OBJECT(item);
SPShape *shape = SP_SHAPE(item);
@@ -895,7 +897,7 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int
sp_shape_set_marker (object, i, object->style->marker[i].value);
}
- if (sp_shape_has_markers (shape)) {
+ if (shape->hasMarkers ()) {
/* provide key and dimension the marker views */
if (!arenaitem->key) {
@@ -906,7 +908,7 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int
if (shape->marker[i]) {
sp_marker_show_dimension ((SPMarker *) shape->marker[i],
NR_ARENA_ITEM_GET_KEY (arenaitem) + i,
- sp_shape_number_of_markers (shape, i));
+ shape->numberOfMarkers (i));
}
}
@@ -920,8 +922,8 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int
/**
* Hides/removes marker views from the shape.
*/
-static void
-sp_shape_hide (SPItem *item, unsigned int key)
+void
+SPShape::sp_shape_hide (SPItem *item, unsigned int key)
{
SPShape *shape;
SPItemView *v;
@@ -940,8 +942,8 @@ sp_shape_hide (SPItem *item, unsigned int key)
}
}
- if (((SPItemClass *) parent_class)->hide) {
- ((SPItemClass *) parent_class)->hide (item, key);
+ if (((SPItemClass *) SPShapeClass::parent_class)->hide) {
+ ((SPItemClass *) SPShapeClass::parent_class)->hide (item, key);
}
}
@@ -950,18 +952,18 @@ sp_shape_hide (SPItem *item, unsigned int key)
* \return TRUE if the shape has any markers, or FALSE if not.
*/
int
-sp_shape_has_markers (SPShape const *shape)
+SPShape::hasMarkers () const
{
/* Note, we're ignoring 'marker' settings, which technically should apply for
all three settings. This should be fixed later such that if 'marker' is
specified, then all three should appear. */
return (
- shape->curve &&
- (shape->marker[SP_MARKER_LOC] ||
- shape->marker[SP_MARKER_LOC_START] ||
- shape->marker[SP_MARKER_LOC_MID] ||
- shape->marker[SP_MARKER_LOC_END])
+ this->curve &&
+ (this->marker[SP_MARKER_LOC] ||
+ this->marker[SP_MARKER_LOC_START] ||
+ this->marker[SP_MARKER_LOC_MID] ||
+ this->marker[SP_MARKER_LOC_END])
);
}
@@ -972,9 +974,9 @@ sp_shape_has_markers (SPShape const *shape)
* \return Number of markers that the shape has of this type.
*/
int
-sp_shape_number_of_markers (SPShape *shape, int type)
+SPShape::numberOfMarkers (int type)
{
- Geom::PathVector const & pathv = shape->curve->get_pathvector();
+ Geom::PathVector const & pathv = this->curve->get_pathvector();
if (pathv.size() == 0) {
return 0;
}
@@ -982,7 +984,7 @@ sp_shape_number_of_markers (SPShape *shape, int type)
switch(type) {
case SP_MARKER_LOC:
{
- if ( shape->marker[SP_MARKER_LOC] ) {
+ if ( this->marker[SP_MARKER_LOC] ) {
guint n = 0;
for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
n += path_it->size_default() + 1;
@@ -994,11 +996,11 @@ sp_shape_number_of_markers (SPShape *shape, int type)
}
case SP_MARKER_LOC_START:
// there is only a start marker on the first path of a pathvector
- return shape->marker[SP_MARKER_LOC_START] ? 1 : 0;
+ return this->marker[SP_MARKER_LOC_START] ? 1 : 0;
case SP_MARKER_LOC_MID:
{
- if ( shape->marker[SP_MARKER_LOC_MID] ) {
+ if ( this->marker[SP_MARKER_LOC_MID] ) {
guint n = 0;
for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
n += path_it->size_default() + 1;
@@ -1012,7 +1014,7 @@ sp_shape_number_of_markers (SPShape *shape, int type)
case SP_MARKER_LOC_END:
{
// there is only an end marker on the last path of a pathvector
- return shape->marker[SP_MARKER_LOC_END] ? 1 : 0;
+ return this->marker[SP_MARKER_LOC_END] ? 1 : 0;
}
default:
@@ -1113,13 +1115,13 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value)
* Calls any registered handlers for the set_shape action
*/
void
-sp_shape_set_shape (SPShape *shape)
+SPShape::setShape ()
{
- g_return_if_fail (shape != NULL);
- g_return_if_fail (SP_IS_SHAPE (shape));
+ //g_return_if_fail (shape != NULL);
+ //g_return_if_fail (SP_IS_SHAPE (shape));
- if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape) {
- SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape (shape);
+ if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape) {
+ SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape (this);
}
}
@@ -1130,29 +1132,29 @@ sp_shape_set_shape (SPShape *shape)
* This routine also triggers a request to update the display.
*/
void
-sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner)
+SPShape::setCurve (SPCurve *curve, unsigned int owner)
{
- if (shape->curve) {
- shape->curve = shape->curve->unref();
+ if (this->curve) {
+ this->curve = this->curve->unref();
}
if (curve) {
if (owner) {
- shape->curve = curve->ref();
+ this->curve = curve->ref();
} else {
- shape->curve = curve->copy();
+ this->curve = curve->copy();
}
}
- SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ SP_OBJECT(this)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
/**
* Return duplicate of curve (if any exists) or NULL if there is no curve
*/
SPCurve *
-sp_shape_get_curve (SPShape *shape)
+SPShape::getCurve ()
{
- if (shape->curve) {
- return shape->curve->copy();
+ if (this->curve) {
+ return this->curve->copy();
}
return NULL;
}
@@ -1161,16 +1163,16 @@ sp_shape_get_curve (SPShape *shape)
* Same as sp_shape_set_curve but without updating the display
*/
void
-sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner)
+SPShape::setCurveInsync (SPCurve *curve, unsigned int owner)
{
- if (shape->curve) {
- shape->curve = shape->curve->unref();
+ if (this->curve) {
+ this->curve = this->curve->unref();
}
if (curve) {
if (owner) {
- shape->curve = curve->ref();
+ this->curve = curve->ref();
} else {
- shape->curve = curve->copy();
+ this->curve = curve->copy();
}
}
}
@@ -1178,7 +1180,7 @@ sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner)
/**
* Return all nodes in a path that are to be considered for snapping
*/
-static void sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
+void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
{
g_assert(item != NULL);
g_assert(SP_IS_SHAPE(item));
diff --git a/src/sp-shape.h b/src/sp-shape.h
index 4b1ded236..0a3b3e37f 100644
--- a/src/sp-shape.h
+++ b/src/sp-shape.h
@@ -21,7 +21,7 @@
#include <sigc++/connection.h>
-#define SP_TYPE_SHAPE (sp_shape_get_type ())
+#define SP_TYPE_SHAPE (SPShape::getType ())
#define SP_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SHAPE, SPShape))
#define SP_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SHAPE, SPShapeClass))
#define SP_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SHAPE))
@@ -31,38 +31,78 @@
struct SPDesktop;
-struct SPShape : public SPLPEItem {
- SPCurve *curve;
+//struct SPShape : public SPLPEItem {
+class SPShape : public SPLPEItem {
+ public:
+ SPCurve *curve;
- SPObject *marker[SP_MARKER_LOC_QTY];
- sigc::connection release_connect [SP_MARKER_LOC_QTY];
- sigc::connection modified_connect [SP_MARKER_LOC_QTY];
+ SPObject *marker[SP_MARKER_LOC_QTY];
+ sigc::connection release_connect [SP_MARKER_LOC_QTY];
+ sigc::connection modified_connect [SP_MARKER_LOC_QTY];
+
+ static GType getType (void);
+ void setShape ();
+ SPCurve * getCurve ();
+ void setCurve (SPCurve *curve, unsigned int owner);
+ void setCurveInsync (SPCurve *curve, unsigned int owner);
+ int hasMarkers () const;
+ int numberOfMarkers (int type);
+ private:
+ static void sp_shape_init (SPShape *shape);
+ static void sp_shape_finalize (GObject *object);
+
+ static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
+ static void sp_shape_release (SPObject *object);
+
+ static void sp_shape_set(SPObject *object, unsigned key, gchar const *value);
+ static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags);
+ static void sp_shape_modified (SPObject *object, unsigned int flags);
+ static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
+
+ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
+ static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
+ static void sp_shape_hide (SPItem *item, unsigned int key);
+ static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
+
+ static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai);
+
+
+
+ friend class SPShapeClass;
};
-struct SPShapeClass {
+//struct SPShapeClass {
+class SPShapeClass {
+ public:
SPLPEItemClass item_class;
/* Build bpath from extra shape attributes */
void (* set_shape) (SPShape *shape);
+
+ private:
+ static SPLPEItemClass *parent_class;
+ static void sp_shape_class_init (SPShapeClass *klass);
+
+ friend class SPShape;
};
-GType sp_shape_get_type (void);
+//GType sp_shape_get_type (void);
-void sp_shape_set_shape (SPShape *shape);
+//void sp_shape_set_shape (SPShape *shape);
/* Return duplicate of curve or NULL */
-SPCurve *sp_shape_get_curve (SPShape *shape);
+//SPCurve *sp_shape_get_curve (SPShape *shape);
// sets a curve, updates display
-void sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner);
+//void sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner);
// same as sp_shape_set_curve, but without updating display
-void sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner);
+//void sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner);
// markers API
void sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value);
-int sp_shape_has_markers (SPShape const *shape);
-int sp_shape_number_of_markers (SPShape* Shape, int type);
+//int sp_shape_has_markers (SPShape const *shape);
+//int sp_shape_number_of_markers (SPShape* Shape, int type);
Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2);
Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c);
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 3acc34d2a..499500c44 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -287,7 +287,7 @@ static void
sp_spiral_update (SPObject *object, SPCtx *ctx, guint flags)
{
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- sp_shape_set_shape ((SPShape *) object);
+ ((SPShape *) object)->setShape ();
}
if (((SPObjectClass *) parent_class)->update)
@@ -427,7 +427,7 @@ sp_spiral_set_shape (SPShape *shape)
// unconditionally read the curve from d, if any, to preserve appearance
Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
SPCurve *cold = new SPCurve(pv);
- sp_shape_set_curve_insync (shape, cold, TRUE);
+ shape->setCurveInsync( cold, TRUE);
cold->unref();
}
return;
@@ -470,12 +470,12 @@ sp_spiral_set_shape (SPShape *shape)
/* Reset the shape'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
- sp_shape_set_curve_insync (shape, c, TRUE);
+ shape->setCurveInsync( c, TRUE);
if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
SPCurve *c_lpe = c->copy();
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
if (success) {
- sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+ shape->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
}
diff --git a/src/sp-star.cpp b/src/sp-star.cpp
index 0d74cf780..b956019d4 100644
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
@@ -270,7 +270,7 @@ sp_star_update (SPObject *object, SPCtx *ctx, guint flags)
if (flags & (SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- sp_shape_set_shape ((SPShape *) object);
+ ((SPShape *) object)->setShape ();
}
if (((SPObjectClass *) parent_class)->update)
@@ -439,7 +439,7 @@ sp_star_set_shape (SPShape *shape)
// unconditionally read the curve from d, if any, to preserve appearance
Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
SPCurve *cold = new SPCurve(pv);
- sp_shape_set_curve_insync (shape, cold, TRUE);
+ shape->setCurveInsync( cold, TRUE);
cold->unref();
}
return;
@@ -509,12 +509,12 @@ sp_star_set_shape (SPShape *shape)
/* Reset the shape'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
- sp_shape_set_curve_insync (shape, c, TRUE);
+ shape->setCurveInsync( c, TRUE);
if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
SPCurve *c_lpe = c->copy();
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
if (success) {
- sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+ shape->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
}
diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp
index 914e416b3..a05dc0e93 100644
--- a/src/sp-use-reference.cpp
+++ b/src/sp-use-reference.cpp
@@ -222,7 +222,7 @@ void SPUsePath::refresh_source()
return;
}
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
if (curve == NULL)
return;
}
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index 3d1cd4b21..13407b80b 100644
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
@@ -474,7 +474,7 @@ sp_spiral_finish(SPSpiralContext *sc)
SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
- sp_shape_set_shape(SP_SHAPE(spiral));
+ SP_SHAPE(spiral)->setShape();
SP_OBJECT(spiral)->updateRepr(SP_OBJECT_WRITE_EXT);
sp_canvas_end_forced_full_redraws(desktop->canvas);
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index d9ac792b3..b2fe45e19 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -667,7 +667,7 @@ Geom::PathVector* item_outline(SPItem const *item)
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
} else if (SP_IS_TEXT(item)) {
curve = SP_TEXT(item)->getNormalizedBpath();
}
@@ -782,7 +782,7 @@ Geom::PathVector* item_outline(SPItem const *item)
if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether
ret_pathv = orig->MakePathVector();
- if (SP_IS_SHAPE(item) && sp_shape_has_markers (SP_SHAPE(item))) {
+ if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers ()) {
SPShape *shape = SP_SHAPE(item);
Geom::PathVector const & pathv = curve->get_pathvector();
@@ -891,7 +891,7 @@ sp_selected_path_outline(SPDesktop *desktop)
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
if (curve == NULL)
continue;
}
@@ -1075,7 +1075,7 @@ sp_selected_path_outline(SPDesktop *desktop)
if (clip_path)
repr->setAttribute("clip-path", clip_path);
- if (SP_IS_SHAPE(item) && sp_shape_has_markers (SP_SHAPE(item))) {
+ if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers ()) {
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g");
@@ -1308,7 +1308,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
}
if (SP_IS_SHAPE(item))
{
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
if (curve == NULL)
return;
}
@@ -1537,7 +1537,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
if (curve == NULL)
continue;
}
@@ -1779,7 +1779,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
if (!curve)
return false;
}
@@ -2112,7 +2112,7 @@ SPCurve* curve_for_item(SPItem *item)
if (SP_IS_PATH(item)) {
curve = sp_path_get_curve_for_edit(SP_PATH(item));
} else {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
}
}
else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 2761c573a..61646ceee 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -492,7 +492,7 @@ sp_star_finish (SPStarContext * sc)
SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
SPObject *object = SP_OBJECT(sc->item);
- sp_shape_set_shape(SP_SHAPE(sc->item));
+ (SP_SHAPE(sc->item))->setShape();
object->updateRepr(SP_OBJECT_WRITE_EXT);
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index ba82b810b..f102be1f7 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1250,7 +1250,7 @@ void PathManipulator::_setGeometry()
if (_path->getRepr()->attribute("inkscape:original-d"))
sp_path_set_original_curve(_path, _spcurve, false, false);
else
- sp_shape_set_curve(SP_SHAPE(_path), _spcurve, false);
+ SP_SHAPE(_path)->setCurve(_spcurve, false);
}
}