From 8867de5daf309e4cdd3fce177b408618490be4f3 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 29 Jun 2010 23:35:42 +0530 Subject: This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp-item and marks the onset of document c++ification as well. Users can check performace increase with [/usr/bin/time -v inkscape_binary_with_commandline_options]. (bzr r9546.1.1) --- src/splivarot.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db9f72975..db5ceaa8e 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -451,11 +451,11 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb // adjust style properties that depend on a possible transform in the source object in order // to get a correct style attribute for the new path SPItem* item_source = SP_ITEM(source); - Geom::Matrix i2doc(sp_item_i2doc_affine(item_source)); - sp_item_adjust_stroke(item_source, i2doc.descrim()); - sp_item_adjust_pattern(item_source, i2doc); - sp_item_adjust_gradient(item_source, i2doc); - sp_item_adjust_livepatheffect(item_source, i2doc); + Geom::Matrix i2doc(item_source->i2doc_affine()); + item_source->adjust_stroke(i2doc.descrim()); + item_source->adjust_pattern(i2doc); + item_source->adjust_gradient(i2doc); + item_source->adjust_livepatheffect(i2doc); Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source); @@ -484,7 +484,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb // premultiply by the inverse of parent's repr SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent)); - Geom::Matrix local (sp_item_i2doc_affine(parent_item)); + Geom::Matrix local (parent_item->i2doc_affine()); gchar *transform = sp_svg_transform_write(local.inverse()); // now that we have the result, add it on the canvas @@ -620,7 +620,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate(xml_doc); g_repr->appendChild(m_repr); SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr); - sp_item_write_transform(marker_item, m_repr, tr); + marker_item->doWriteTransform(m_repr, tr); } } @@ -1089,7 +1089,7 @@ sp_selected_path_outline(SPDesktop *desktop) // restore title, description, id, transform repr->setAttribute("id", id); SPItem *newitem = (SPItem *) doc->getObjectByRepr(repr); - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); if (title) { newitem->setTitle(title); } @@ -1189,7 +1189,7 @@ sp_selected_path_outline(SPDesktop *desktop) repr->setAttribute("id", id); SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); if (title) { newitem->setTitle(title); } @@ -1321,7 +1321,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat Geom::Matrix const transform(item->transform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); style = g_strdup(SP_OBJECT(item)->repr->attribute("style")); @@ -1472,11 +1472,11 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat if ( updating ) { // on conserve l'original // we reapply the transform to the original (offset will feel it) - sp_item_write_transform(item, SP_OBJECT_REPR(item), transform); + item->doWriteTransform(SP_OBJECT_REPR(item), transform); } else { // delete original, apply the transform to the offset SP_OBJECT(item)->deleteObject(false); - sp_item_write_transform(nitem, repr, transform); + nitem->doWriteTransform(repr, transform); } // The object just created from a temporary repr is only a seed. @@ -1546,7 +1546,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) Geom::Matrix const transform(item->transform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); @@ -1719,7 +1719,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); // reapply the transform - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); repr->setAttribute("id", id); @@ -1788,7 +1788,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, } // correct virtual size by full transform (bug #166937) - size /= sp_item_i2doc_affine(item).descrim(); + size /= item->i2doc_affine().descrim(); // save the transform, to re-apply it after simplification Geom::Matrix const transform(item->transform); @@ -1798,7 +1798,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, this is necessary so that the item is transformed twice back and forth, allowing all compensations to cancel out regardless of the preferences */ - sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); gchar *mask = g_strdup(SP_OBJECT_REPR(item)->attribute("mask")); @@ -1878,7 +1878,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); // reapply the transform - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); // restore title & description if (title) { @@ -1943,7 +1943,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - Geom::OptRect itemBbox = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect itemBbox = item->getBounds(item->i2d_affine()); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { @@ -2088,7 +2088,7 @@ pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool t if (doTransformation) { if (transformFull) { - *dest *= extraPreAffine * sp_item_i2doc_affine(item) * extraPostAffine; + *dest *= extraPreAffine * item->i2doc_affine() * extraPostAffine; } else { *dest *= extraPreAffine * (Geom::Matrix)item->transform * extraPostAffine; } -- 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/splivarot.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db5ceaa8e..5073382e5 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -419,7 +419,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb { SP_OBJECT(l->data)->deleteObject(); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, description); selection->clear(); @@ -593,7 +593,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb if (desc) g_free(desc); if (verb != SP_VERB_NONE) { - sp_document_done(sp_desktop_document(desktop), verb, description); + SPDocumentUndo::done(sp_desktop_document(desktop), verb, description); } delete res; @@ -1216,7 +1216,7 @@ sp_selected_path_outline(SPDesktop *desktop) } if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, _("Convert stroke to path")); } else { // TRANSLATORS: "to outline" means "to convert stroke to path" @@ -1419,7 +1419,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat { // pas vraiment de points sur le resultat // donc il ne reste rien - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), (updating ? SP_VERB_SELECTION_LINKED_OFFSET : SP_VERB_SELECTION_DYNAMIC_OFFSET), (updating ? _("Create linked offset") @@ -1488,7 +1488,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat selection->set(nitem); } - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), (updating ? SP_VERB_SELECTION_LINKED_OFFSET : SP_VERB_SELECTION_DYNAMIC_OFFSET), (updating ? _("Create linked offset") @@ -1733,7 +1733,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } if (did) { - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), (expand ? SP_VERB_SELECTION_OFFSET : SP_VERB_SELECTION_INSET), (expand ? _("Outset path") : _("Inset path"))); } else { @@ -1993,7 +1993,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju breakableAngles, true); if (didSomething) - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_SIMPLIFY, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_SIMPLIFY, _("Simplify")); else desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No paths to simplify in the selection.")); -- 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/splivarot.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 5073382e5..d9ac792b3 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1323,7 +1323,8 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); - style = g_strdup(SP_OBJECT(item)->repr->attribute("style")); + //XML Tree being used directly here while it shouldn't be... + style = g_strdup(SP_OBJECT(item)->getRepr()->attribute("style")); // remember the position of the item gint pos = SP_OBJECT_REPR(item)->position(); @@ -1451,7 +1452,9 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat g_free(str); if ( updating ) { - char const *id = SP_OBJECT(item)->repr->attribute("id"); + + //XML Tree being used directly here while it shouldn't be + char const *id = SP_OBJECT(item)->getRepr()->attribute("id"); char const *uri = g_strdup_printf("#%s", id); repr->setAttribute("xlink:href", uri); g_free((void *) uri); -- cgit v1.2.3 From cde0571b44ec5b108907bda85971c49f3ceb1de8 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Wed, 14 Jul 2010 23:40:35 +0530 Subject: 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) --- src/splivarot.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/splivarot.cpp') 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)) -- cgit v1.2.3