From 121815791be2d24cb745663520b111ee914fbc09 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Thu, 1 Jul 2010 15:36:56 +0530 Subject: C++fied SPDocument added (bzr r9546.1.2) --- src/sp-guide.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index f5edf7d97..5bf7f664c 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -273,7 +273,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { std::list > pts; Geom::Point A(0, 0); - Geom::Point C(sp_document_width(doc), sp_document_height(doc)); + Geom::Point C(doc->getWidth(), doc->getHeight()); Geom::Point B(C[Geom::X], 0); Geom::Point D(0, C[Geom::Y]); -- cgit v1.2.3 From d25a9a072143eafa4a9823b84e977c4b85d45efe Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Fri, 2 Jul 2010 18:05:42 +0530 Subject: New Class SPDocumentUndo created which takes care of c++fying some non SPDocument based methods (bzr r9546.1.3) --- src/sp-guide.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 5bf7f664c..877e73979 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -284,7 +284,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { sp_guide_pt_pairs_to_guides(dt, pts); - sp_document_done (doc, SP_VERB_NONE, _("Guides Around Page")); + SPDocumentUndo::done (doc, SP_VERB_NONE, _("Guides Around Page")); } void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler) -- cgit v1.2.3 From 1aaf9a0ee3da28012bf43cfa61e2e5fa933edd2e Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 6 Jul 2010 12:52:32 +0530 Subject: C++ification of SPObject continued along with the onset of XML Privatisation. Users may checkout [grep -Ir XML Tree *] in the source code and all the places where the XML node/Tree is being used shall be reflected. (bzr r9546.1.5) --- src/sp-guide.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 877e73979..955d4fedc 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -358,7 +358,8 @@ void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { - sp_repr_set_point(SP_OBJECT(&guide)->repr, "position", point_on_line); + //XML Tree being used here directly while it shouldn't be. + sp_repr_set_point(SP_OBJECT(&guide)->getRepr(), "position", point_on_line); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) @@ -388,7 +389,8 @@ void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { - sp_repr_set_point(SP_OBJECT(&guide)->repr, "orientation", normal_to_line); + //XML Tree being used directly while it shouldn't be + sp_repr_set_point(SP_OBJECT(&guide)->getRepr(), "orientation", normal_to_line); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) @@ -457,8 +459,9 @@ void sp_guide_remove(SPGuide *guide) remove_last(att.item->constraints, SPGuideConstraint(guide, att.snappoint_ix)); } guide->attached_items.clear(); - - sp_repr_unparent(SP_OBJECT(guide)->repr); + + //XML Tree being used directly while it shouldn't be. + sp_repr_unparent(SP_OBJECT(guide)->getRepr()); } /* -- cgit v1.2.3 From 6cc35b45eab6422a6b6f67d621aa259a0a73786f Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Mon, 12 Jul 2010 22:06:46 +0530 Subject: SPObject c++ification finalized along with the beginning of XML Privatisation tweaks (bzr r9546.1.6) --- src/sp-guide.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 955d4fedc..e43c3056d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -158,8 +158,8 @@ static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "position"); + object->readAttr( "orientation"); + object->readAttr( "position"); } static void sp_guide_release(SPObject *object) -- cgit v1.2.3 From 7396564ea83c67c0e40a8b0aa453a13ddf21e0e0 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma public Date: Sat, 24 Jul 2010 20:58:27 +0530 Subject: Yet mor in c++ification (bzr r9546.1.11) --- src/sp-guide.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index e43c3056d..21b350486 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -242,7 +242,7 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) } SPGuide * -sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { +SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { SPDocument *doc=sp_desktop_document(desktop); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); @@ -253,7 +253,8 @@ sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &p sp_repr_set_point(repr, "position", pt1); sp_repr_set_point(repr, "orientation", n); - SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); + //SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); + desktop->namedview->appendChild(repr); Inkscape::GC::release(repr); SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr)); @@ -263,7 +264,7 @@ sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &p void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > &pts) { for (std::list >::iterator i = pts.begin(); i != pts.end(); ++i) { - sp_guide_create(dt, (*i).first, (*i).second); + SPGuide::createSPGuide(dt, (*i).first, (*i).second); } } @@ -287,27 +288,27 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { SPDocumentUndo::done (doc, SP_VERB_NONE, _("Guides Around Page")); } -void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler) +void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { - SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line); - sp_guideline_set_color(SP_GUIDELINE(item), guide->color); + SPCanvasItem *item = sp_guideline_new(group, this->point_on_line, this->normal_to_line); + sp_guideline_set_color(SP_GUIDELINE(item), this->color); - g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide); + g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); - guide->views = g_slist_prepend(guide->views, item); + this->views = g_slist_prepend(this->views, item); } -void sp_guide_hide(SPGuide *guide, SPCanvas *canvas) +void SPGuide::hideSPGuide(SPCanvas *canvas) { - g_assert(guide != NULL); - g_assert(SP_IS_GUIDE(guide)); + //g_assert(guide != NULL); + //g_assert(SP_IS_GUIDE(guide)); g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); - for (GSList *l = guide->views; l != NULL; l = l->next) { + for (GSList *l = this->views; l != NULL; l = l->next) { if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { sp_guideline_delete(SP_GUIDELINE(l->data)); - guide->views = g_slist_remove(guide->views, l->data); + this->views = g_slist_remove(this->views, l->data); return; } } @@ -315,14 +316,14 @@ void sp_guide_hide(SPGuide *guide, SPCanvas *canvas) g_assert_not_reached(); } -void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive) +void SPGuide::sensitize(SPCanvas *canvas, gboolean sensitive) { - g_assert(guide != NULL); - g_assert(SP_IS_GUIDE(guide)); + //g_assert(guide != NULL); + //g_assert(SP_IS_GUIDE(guide)); g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); - for (GSList *l = guide->views; l != NULL; l = l->next) { + for (GSList *l = this->views; l != NULL; l = l->next) { if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive); return; @@ -332,14 +333,14 @@ void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive) g_assert_not_reached(); } -Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt) +Geom::Point SPGuide::getPositionFrom(Geom::Point const &pt) const { - return -(pt - guide->point_on_line); + return -(pt - this->point_on_line); } -double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt) +double SPGuide::getDistanceFrom(Geom::Point const &pt) const { - return Geom::dot(pt - guide->point_on_line, guide->normal_to_line); + return Geom::dot(pt - this->point_on_line, this->normal_to_line); } /** -- cgit v1.2.3