Code

remove many unnecessary to_2geom and from_2geom calls
[inkscape.git] / src / eraser-context.cpp
index 6cfd915ef2ccac2f7716f260478e8f8ac7dcdae7..559ce28667e7ba224aaf630fd69d367caa3b74ae 100644 (file)
@@ -163,11 +163,11 @@ sp_eraser_context_setup(SPEventContext *ec)
     if (((SPEventContextClass *) eraser_parent_class)->setup)
         ((SPEventContextClass *) eraser_parent_class)->setup(ec);
 
-    erc->accumulated = new SPCurve(32);
-    erc->currentcurve = new SPCurve(4);
+    erc->accumulated = new SPCurve();
+    erc->currentcurve = new SPCurve();
 
-    erc->cal1 = new SPCurve(32);
-    erc->cal2 = new SPCurve(32);
+    erc->cal1 = new SPCurve();
+    erc->cal2 = new SPCurve();
 
     erc->currentshape = sp_canvas_item_new(sp_desktop_sketch(ec->desktop), SP_TYPE_CANVAS_BPATH, NULL);
     sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(erc->currentshape), ERC_RED_RGBA, SP_WIND_RULE_EVENODD);
@@ -557,7 +557,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context,
         if (dc->dragging && event->button.button == 1 && !event_context->space_panning) {
             dc->dragging = FALSE;
 
-            NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
+            boost::optional<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
 
             sp_eraser_apply(dc, motion_dt);
 
@@ -730,7 +730,7 @@ set_to_accumulated(SPEraserContext *dc)
             item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
             item->updateRepr();
         }
-        Geom::PathVector pathv = dc->accumulated->get_pathvector() * to_2geom(sp_desktop_dt2root_affine(desktop));
+        Geom::PathVector pathv = dc->accumulated->get_pathvector() * sp_desktop_dt2root_affine(desktop);
         gchar *str = sp_svg_write_path(pathv);
         g_assert( str != NULL );
         dc->repr->setAttribute("d", str);
@@ -743,7 +743,7 @@ set_to_accumulated(SPEraserContext *dc)
             Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
 
             SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr));
-            NR::Maybe<NR::Rect> eraserBbox = acid->getBounds(NR::identity());
+            boost::optional<NR::Rect> eraserBbox = acid->getBounds(NR::identity());
             NR::Rect bounds = (*eraserBbox) * desktop->doc2dt();
             std::vector<SPItem*> remainingItems;
             GSList* toWorkOn = 0;
@@ -765,7 +765,7 @@ set_to_accumulated(SPEraserContext *dc)
                     for (GSList *i = toWorkOn ; i ; i = i->next ) {
                         SPItem *item = SP_ITEM(i->data);
                         if ( eraserMode ) {
-                            NR::Maybe<NR::Rect> bbox = item->getBounds(NR::identity());
+                            boost::optional<NR::Rect> bbox = item->getBounds(NR::identity());
                             if (bbox && bbox->intersects(*eraserBbox)) {
                                 Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc);
                                 dc->repr->parent()->appendChild(dup);
@@ -888,11 +888,11 @@ accumulate_eraser(SPEraserContext *dc)
 
         dc->accumulated->append(dc->cal1, FALSE);
 
-        add_cap(dc->accumulated, (*dc_cal1_lastseg)[2], (*dc_cal1_lastseg)[3], (*rev_cal2_firstseg)[3], (*rev_cal2_firstseg)[1], dc->cap_rounding);
+        add_cap(dc->accumulated, (*dc_cal1_lastseg)[2], (*dc_cal1_lastseg)[3], (*rev_cal2_firstseg)[0], (*rev_cal2_firstseg)[1], dc->cap_rounding);
 
         dc->accumulated->append(rev_cal2, TRUE);
 
-        add_cap(dc->accumulated, (*rev_cal2_lastseg)[2], (*rev_cal2_lastseg)[3], (*dc_cal1_firstseg)[3], (*dc_cal1_firstseg)[1], dc->cap_rounding);
+        add_cap(dc->accumulated, (*rev_cal2_lastseg)[2], (*rev_cal2_lastseg)[3], (*dc_cal1_firstseg)[0], (*dc_cal1_firstseg)[1], dc->cap_rounding);
 
         dc->accumulated->closepath();
 
@@ -931,7 +931,7 @@ fit_and_split(SPEraserContext *dc, gboolean release)
 #endif
 
         /* Current eraser */
-        if ( dc->cal1->get_length() == 0 || dc->cal2->get_length() == 0 ) {
+        if ( dc->cal1->is_empty() || dc->cal2->is_empty() ) {
             /* dc->npoints > 0 */
             /* g_print("erasers(1|2) reset\n"); */
             dc->cal1->reset();