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/connector-context.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index b0e192190..82be63de5 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -965,7 +965,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); // Update the hidden path - Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + Geom::Matrix i2d = (cc->clickeditem)->i2d_affine(); Geom::Matrix d2i = i2d.inverse(); SPPath *path = SP_PATH(cc->clickeditem); SPCurve *curve = path->original_curve ? path->original_curve : path->curve; @@ -1088,7 +1088,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cc->active_shape->avoidRef->updateConnectionPoint(cp); } @@ -1104,7 +1104,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con ConnectionPoint cp; cp.type = ConnPointUserDefined; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); @@ -1182,7 +1182,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) // Obtain original position ConnectionPoint const& cp = cc->connpthandles[cc->selected_handle]; SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - const Geom::Matrix& i2doc = sp_item_i2doc_affine(cc->active_shape); + const Geom::Matrix& i2doc = (cc->active_shape)->i2doc_affine(); sp_knot_set_position(cc->selected_handle, cp.pos * i2doc * desktop->doc2dt(), 0); cc->state = SP_CONNECTOR_CONTEXT_IDLE; desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, @@ -1204,7 +1204,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cc->active_shape->avoidRef->updateConnectionPoint(cp); } @@ -1235,7 +1235,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) ConnectionPoint cp; cp.type = ConnPointUserDefined; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); @@ -1431,7 +1431,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) /* Attach repr */ cc->newconn = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); - cc->newconn->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); bool connection = false; sp_object_setAttribute(cc->newconn, "inkscape:connector-type", @@ -1593,7 +1593,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) // Show the red path for dragging. cc->red_curve = SP_PATH(cc->clickeditem)->original_curve ? SP_PATH(cc->clickeditem)->original_curve->copy() : SP_PATH(cc->clickeditem)->curve->copy(); - Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + Geom::Matrix i2d = (cc->clickeditem)->i2d_affine(); cc->red_curve->transform(i2d); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); @@ -1752,7 +1752,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) g_assert( SP_IS_PATH(item) ); SPCurve *curve = SP_PATH(item)->original_curve ? SP_PATH(item)->original_curve : SP_PATH(item)->curve; - Geom::Matrix i2d = sp_item_i2d_affine(item); + Geom::Matrix i2d = item->i2d_affine(); if (cc->active_conn == item) { -- 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/connector-context.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 82be63de5..90b16fddd 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1064,7 +1064,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); cc_connector_rerouting_finish(cc, &p); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); cc->state = SP_CONNECTOR_CONTEXT_IDLE; return TRUE; break; @@ -1108,7 +1108,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) { @@ -1239,7 +1239,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) { @@ -1459,7 +1459,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) } // Process pending updates. cc->newconn->updateRepr(); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); if (connection) { // Adjust endpoints to shape edge. @@ -1693,7 +1693,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) // Ensure the item's connection_points map // has been updated - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); + SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); std::set seen; for ( ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end() ;) -- 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/connector-context.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 90b16fddd..ff19c7749 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1152,7 +1152,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) cc_connector_rerouting_finish(cc, NULL); - sp_document_undo(doc); + SPDocumentUndo::undo(doc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, @@ -1303,7 +1303,7 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p cc->clickeditem->setHidden(false); sp_conn_reroute_path_immediate(SP_PATH(cc->clickeditem)); cc->clickeditem->updateRepr(); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Reroute connector")); cc_set_active_conn(cc, cc->clickeditem); } @@ -1477,7 +1477,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) c->unref(); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); } @@ -1935,7 +1935,7 @@ void cc_selection_set_avoid(bool const set_avoid) char *event_desc = (set_avoid) ? _("Make connectors avoid selected objects") : _("Make connectors ignore selected objects"); - sp_document_done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); + SPDocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); } -- 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/connector-context.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index ff19c7749..a419af44a 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1286,15 +1286,15 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-start", shape_label, false); - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-start-point", cpid, false); } else { - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-end", shape_label, false); - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-end-point", cpid, false); } g_free(shape_label); @@ -1434,26 +1434,26 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); bool connection = false; - sp_object_setAttribute(cc->newconn, "inkscape:connector-type", + (cc->newconn)->setAttribute( "inkscape:connector-type", cc->isOrthogonal ? "orthogonal" : "polyline", false); - sp_object_setAttribute(cc->newconn, "inkscape:connector-curvature", + (cc->newconn)->setAttribute( "inkscape:connector-curvature", Glib::Ascii::dtostr(cc->curvature).c_str(), false); if (cc->shref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-start", + (cc->newconn)->setAttribute( "inkscape:connection-start", cc->shref, false); if (cc->scpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-start-point", + (cc->newconn)->setAttribute( "inkscape:connection-start-point", cc->scpid, false); connection = true; } if (cc->ehref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-end", + (cc->newconn)->setAttribute( "inkscape:connection-end", cc->ehref, false); if (cc->ecpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-end-point", + (cc->newconn)->setAttribute( "inkscape:connection-end-point", cc->ecpid, false); connection = true; } @@ -1917,7 +1917,7 @@ void cc_selection_set_avoid(bool const set_avoid) char const *value = (set_avoid) ? "true" : NULL; if (cc_item_is_shape(item)) { - sp_object_setAttribute(item, "inkscape:connector-avoid", + item->setAttribute("inkscape:connector-avoid", value, false); item->avoidRef->handleSettingChange(); changes++; -- cgit v1.2.3