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/flood-context.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 612ae1cfc..f8c2e14a0 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -485,10 +485,10 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { - sp_item_write_transform(SP_ITEM(reprobj), pathRepr, transform, NULL); + SP_ITEM(reprobj)->doWriteTransform(pathRepr, transform, NULL); // premultiply the item transform by the accumulated parent transform in the paste layer - Geom::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer()))); + Geom::Matrix local (SP_GROUP(desktop->currentLayer())->i2doc_affine()); if (!local.isIdentity()) { gchar const *t_str = pathRepr->attribute("transform"); Geom::Matrix item_t (Geom::identity()); @@ -774,7 +774,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even /* Create new arena */ NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); sp_document_ensure_up_to_date (document); @@ -807,7 +807,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(document)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = SP_ITEM(sp_document_root(document))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -850,7 +850,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even nr_pixblock_release(&B); // Hide items - sp_item_invoke_hide(SP_ITEM(sp_document_root(document)), dkey); + SP_ITEM(sp_document_root(document))->invoke_hide(dkey); nr_object_unref((NRObject *) arena); -- cgit v1.2.3 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/flood-context.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index f8c2e14a0..019cbbb02 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -776,7 +776,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even NRArena *arena = NRArena::create(); unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (document); + document->ensure_up_to_date (); SPItem *document_root = SP_ITEM(SP_DOCUMENT_ROOT(document)); Geom::OptRect bbox = document_root->getBounds(Geom::identity()); @@ -798,7 +798,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even unsigned int height = (int)ceil(screen.height() * zoom_scale * padding); Geom::Point origin(screen.min()[Geom::X], - sp_document_height(document) - screen.height() - screen.min()[Geom::Y]); + document->getHeight() - screen.height() - screen.min()[Geom::Y]); origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2)); origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2)); @@ -905,7 +905,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even } for (unsigned int i = 0; i < fill_points.size(); i++) { - Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, sp_document_height(document) + (fill_points[i][Geom::Y] / zoom_scale)) * affine; + Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, document->getHeight() + (fill_points[i][Geom::Y] / zoom_scale)) * affine; pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X])); pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[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/flood-context.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 019cbbb02..696efd3e3 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -1119,7 +1119,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even g_free(trace_px); - sp_document_done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); + SPDocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); } static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) @@ -1139,7 +1139,7 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); /* Set style */ sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ret = TRUE; } break; @@ -1278,7 +1278,7 @@ static void sp_flood_finish(SPFloodContext *rc) sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(rc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); rc->item = NULL; -- 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/flood-context.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 696efd3e3..5181809dc 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -417,7 +417,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto std::vector results = pte.traceGrayMap(gray_map); gray_map->destroy(gray_map); - Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->repr; + //XML Tree being used here directly while it shouldn't be...." + Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); long totalNodeCount = 0L; -- 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/flood-context.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 5181809dc..b9aaf902e 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -418,7 +418,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto gray_map->destroy(gray_map); //XML Tree being used here directly while it shouldn't be...." - Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); + //Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); long totalNodeCount = 0L; @@ -482,7 +482,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto g_free(str); } - layer_repr->addChild(pathRepr, NULL); + //layer_repr->addChild(pathRepr, NULL); + desktop->currentLayer()->addChild(pathRepr,NULL); SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { @@ -1137,9 +1138,10 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE); - Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); + //Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); /* Set style */ - sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); + //sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); + desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false); SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ret = TRUE; } -- cgit v1.2.3