Code

Eliminate more of SP_ACTIVE_DESKTOP
authorcilix42 <cilix42@users.sourceforge.net>
Fri, 15 Aug 2008 19:53:10 +0000 (19:53 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Fri, 15 Aug 2008 19:53:10 +0000 (19:53 +0000)
src/dyna-draw-context.cpp
src/eraser-context.cpp
src/flood-context.cpp
src/splivarot.cpp
src/splivarot.h
src/tweak-context.cpp
src/verbs.cpp

index c56ba7a4c197092d932ae979f8108b648530d833..e29865ff6c79029021891b101c3ba1361680ba3f 100644 (file)
@@ -990,7 +990,7 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize)
 
         if (unionize) {
             sp_desktop_selection(desktop)->add(dc->repr);
-            sp_selected_path_union_skip_undo();
+            sp_selected_path_union_skip_undo(desktop);
         } else {
             if (dc->keep_selected) {
                 sp_desktop_selection(desktop)->set(dc->repr);
@@ -1093,7 +1093,9 @@ static double square(double const x)
 static void
 fit_and_split(SPDynaDrawContext *dc, gboolean release)
 {
-    double const tolerance_sq = square( NR::expansion(SP_EVENT_CONTEXT(dc)->desktop->w2d()) * TOLERANCE_CALLIGRAPHIC );
+    SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop;
+
+    double const tolerance_sq = square( NR::expansion(desktop->w2d()) * TOLERANCE_CALLIGRAPHIC );
 
 #ifdef DYNA_DRAW_VERBOSE
     g_print("[F&S:R=%c]", release?'T':'F');
@@ -1186,24 +1188,24 @@ fit_and_split(SPDynaDrawContext *dc, gboolean release)
         if (!release) {
             g_assert(!dc->currentcurve->is_empty());
 
-            SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(SP_EVENT_CONTEXT(dc)->desktop),
+            SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop),
                                                    SP_TYPE_CANVAS_BPATH,
                                                    NULL);
             SPCurve *curve = dc->currentcurve->copy();
             sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
             curve->unref();
 
-            guint32 fillColor = sp_desktop_get_color_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", true);
-            //guint32 strokeColor = sp_desktop_get_color_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", false);
-            double opacity = sp_desktop_get_master_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic");
-            double fillOpacity = sp_desktop_get_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", true);
-            //double strokeOpacity = sp_desktop_get_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", false);
+            guint32 fillColor = sp_desktop_get_color_tool (desktop, "tools.calligraphic", true);
+            //guint32 strokeColor = sp_desktop_get_color_tool (desktop, "tools.calligraphic", false);
+            double opacity = sp_desktop_get_master_opacity_tool (desktop, "tools.calligraphic");
+            double fillOpacity = sp_desktop_get_opacity_tool (desktop, "tools.calligraphic", true);
+            //double strokeOpacity = sp_desktop_get_opacity_tool (desktop, "tools.calligraphic", false);
             sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), ((fillColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*fillOpacity)), SP_WIND_RULE_EVENODD);
             //on second thougtht don't do stroke yet because we don't have stoke-width yet and because stoke appears between segments while drawing
             //sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), ((strokeColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*strokeOpacity)), 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
             sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
             /* fixme: Cannot we cascade it to root more clearly? */
-            g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), SP_EVENT_CONTEXT(dc)->desktop);
+            g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), desktop);
 
             dc->segments = g_slist_prepend(dc->segments, cbp);
         }
index bec3326d62ab1f2876ce404685238bb3dee22fb0..ccbb877905e91a6e140555c69990cc534b91e246 100644 (file)
@@ -771,7 +771,7 @@ set_to_accumulated(SPEraserContext *dc)
 
                                 selection->set(item);
                                 selection->add(dup);
-                                sp_selected_path_diff_skip_undo();
+                                sp_selected_path_diff_skip_undo(desktop);
                                 workDone = true; // TODO set this only if something was cut.
                                 if ( !selection->isEmpty() ) {
                                     // If the item was not completely erased, track the new remainder.
index a9ca7073f906669c637a05a654d6c6a1e548bd2f..1057fd4be928fc634229036b1eb41a7f02a55d89 100644 (file)
@@ -530,7 +530,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
             if (union_with_selection) {
                 desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.",sp_nodes_in_path(SP_PATH(reprobj))), sp_nodes_in_path(SP_PATH(reprobj)));
                 selection->add(reprobj);
-                sp_selected_path_union_skip_undo();
+                sp_selected_path_union_skip_undo(desktop);
             } else {
                 desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.",sp_nodes_in_path(SP_PATH(reprobj))), sp_nodes_in_path(SP_PATH(reprobj)));
                 selection->set(reprobj);
index e66bc6a689581a95f436b44f5e56683f1eabfc0d..77675000f5415da6d1ff7f3ff04b7c5d46fbcbb4 100644 (file)
@@ -33,7 +33,6 @@
 #include "text-editing.h"
 #include "sp-item-group.h"
 #include "style.h"
-#include "inkscape.h"
 #include "document.h"
 #include "message-stack.h"
 #include "selection.h"
 
 bool   Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who);
 
-void sp_selected_path_boolop(bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description="");
-void sp_selected_path_do_offset(bool expand, double prefOffset);
-void sp_selected_path_create_offset_object(int expand, bool updating);
+void sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description="");
+void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset);
+void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating);
 
 void
-sp_selected_path_union()
+sp_selected_path_union(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_union, SP_VERB_SELECTION_UNION, _("Union"));
+    sp_selected_path_boolop(desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union"));
 }
 
 void
-sp_selected_path_union_skip_undo()
+sp_selected_path_union_skip_undo(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_union, SP_VERB_NONE, _("Union"));
+    sp_selected_path_boolop(desktop, bool_op_union, SP_VERB_NONE, _("Union"));
 }
 
 void
-sp_selected_path_intersect()
+sp_selected_path_intersect(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection"));
+    sp_selected_path_boolop(desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection"));
 }
 
 void
-sp_selected_path_diff()
+sp_selected_path_diff(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference"));
+    sp_selected_path_boolop(desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference"));
 }
 
 void
-sp_selected_path_diff_skip_undo()
+sp_selected_path_diff_skip_undo(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_diff, SP_VERB_NONE, _("Difference"));
+    sp_selected_path_boolop(desktop, bool_op_diff, SP_VERB_NONE, _("Difference"));
 }
 
 void
-sp_selected_path_symdiff()
+sp_selected_path_symdiff(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion"));
+    sp_selected_path_boolop(desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion"));
 }
 void
-sp_selected_path_cut()
+sp_selected_path_cut(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_cut, SP_VERB_SELECTION_CUT, _("Division"));
+    sp_selected_path_boolop(desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division"));
 }
 void
-sp_selected_path_slice()
+sp_selected_path_slice(SPDesktop *desktop)
 {
-    sp_selected_path_boolop(bool_op_slice, SP_VERB_SELECTION_SLICE,  _("Cut path"));
+    sp_selected_path_boolop(desktop, bool_op_slice, SP_VERB_SELECTION_SLICE,  _("Cut path"));
 }
 
 
 // boolean operations
 // take the source paths from the file, do the operation, delete the originals and add the results
 void
-sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustring description)
+sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
     
     GSList *il = (GSList *) selection->itemList();
@@ -625,10 +622,8 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix
 }
 
 void
-sp_selected_path_outline()
+sp_selected_path_outline(SPDesktop *desktop)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     if (selection->isEmpty()) {
@@ -937,78 +932,75 @@ sp_selected_path_outline()
 
 
 void
-sp_selected_path_offset()
+sp_selected_path_offset(SPDesktop *desktop)
 {
     double prefOffset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", 1.0);
 
-    sp_selected_path_do_offset(true, prefOffset);
+    sp_selected_path_do_offset(desktop, true, prefOffset);
 }
 void
-sp_selected_path_inset()
+sp_selected_path_inset(SPDesktop *desktop)
 {
     double prefOffset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", 1.0);
 
-    sp_selected_path_do_offset(false, prefOffset);
+    sp_selected_path_do_offset(desktop, false, prefOffset);
 }
 
 void
-sp_selected_path_offset_screen(double pixels)
+sp_selected_path_offset_screen(SPDesktop *desktop, double pixels)
 {
-    sp_selected_path_do_offset(true,  pixels / SP_ACTIVE_DESKTOP->current_zoom());
+    sp_selected_path_do_offset(desktop, true,  pixels / desktop->current_zoom());
 }
 
 void
-sp_selected_path_inset_screen(double pixels)
+sp_selected_path_inset_screen(SPDesktop *desktop, double pixels)
 {
-    sp_selected_path_do_offset(false,  pixels / SP_ACTIVE_DESKTOP->current_zoom());
+    sp_selected_path_do_offset(desktop, false,  pixels / desktop->current_zoom());
 }
 
 
-void sp_selected_path_create_offset_object_zero()
+void sp_selected_path_create_offset_object_zero(SPDesktop *desktop)
 {
-    sp_selected_path_create_offset_object(0, false);
+    sp_selected_path_create_offset_object(desktop, 0, false);
 }
 
-void sp_selected_path_create_offset()
+void sp_selected_path_create_offset(SPDesktop *desktop)
 {
-    sp_selected_path_create_offset_object(1, false);
+    sp_selected_path_create_offset_object(desktop, 1, false);
 }
-void sp_selected_path_create_inset()
+void sp_selected_path_create_inset(SPDesktop *desktop)
 {
-    sp_selected_path_create_offset_object(-1, false);
+    sp_selected_path_create_offset_object(desktop, -1, false);
 }
 
-void sp_selected_path_create_updating_offset_object_zero()
+void sp_selected_path_create_updating_offset_object_zero(SPDesktop *desktop)
 {
-    sp_selected_path_create_offset_object(0, true);
+    sp_selected_path_create_offset_object(desktop, 0, true);
 }
 
-void sp_selected_path_create_updating_offset()
+void sp_selected_path_create_updating_offset(SPDesktop *desktop)
 {
-    sp_selected_path_create_offset_object(1, true);
+    sp_selected_path_create_offset_object(desktop, 1, true);
 }
-void sp_selected_path_create_updating_inset()
+void sp_selected_path_create_updating_inset(SPDesktop *desktop)
 {
-    sp_selected_path_create_offset_object(-1, true);
+    sp_selected_path_create_offset_object(desktop, -1, true);
 }
 
 void
-sp_selected_path_create_offset_object(int expand, bool updating)
+sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating)
 {
     Inkscape::Selection *selection;
     Inkscape::XML::Node *repr;
     SPItem *item;
     SPCurve *curve;
     gchar *style, *str;
-    SPDesktop *desktop;
     float o_width, o_miter;
     JoinType o_join;
     ButtType o_butt;
 
     curve = NULL;
 
-    desktop = SP_ACTIVE_DESKTOP;
-
     selection = sp_desktop_selection(desktop);
 
     item = selection->singleItem();
@@ -1224,10 +1216,8 @@ sp_selected_path_create_offset_object(int expand, bool updating)
 
 
 void
-sp_selected_path_do_offset(bool expand, double prefOffset)
+sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     if (selection->isEmpty()) {
@@ -1669,11 +1659,9 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
 }
 
 void
-sp_selected_path_simplify_selection(float threshold, bool justCoalesce,
-                       float angleLimit, bool breakableAngles)
+sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool justCoalesce,
+                                    float angleLimit, bool breakableAngles)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     if (selection->isEmpty()) {
@@ -1704,7 +1692,7 @@ static double previousTime      = 0.0;
 static gdouble simplifyMultiply = 1.0;
 
 void
-sp_selected_path_simplify(void)
+sp_selected_path_simplify(SPDesktop *desktop)
 {
     gdouble simplifyThreshold =
         prefs_get_double_attribute("options.simplifythreshold", "value", 0.003);
@@ -1735,8 +1723,8 @@ sp_selected_path_simplify(void)
     //g_print("%g\n", simplify_threshold);
 
     //Make the actual call
-    sp_selected_path_simplify_selection(simplifyThreshold,
-                      simplifyJustCoalesce, 0.0, false);
+    sp_selected_path_simplify_selection(desktop, simplifyThreshold,
+                                        simplifyJustCoalesce, 0.0, false);
 }
 
 
index ad4d9c6e0907372891547d803082333fad4fb5fe..755beaa800d412c7880e31e2e5e9d6eb159a7bb3 100644 (file)
@@ -16,36 +16,36 @@ struct SPItem;
 // boolean operations
 // work on the current selection
 // selection has 2 contain exactly 2 items
-void sp_selected_path_union ();
-void sp_selected_path_union_skip_undo ();
-void sp_selected_path_intersect ();
-void sp_selected_path_diff ();
-void sp_selected_path_diff_skip_undo ();
-void sp_selected_path_symdiff ();
-void sp_selected_path_cut ();
-void sp_selected_path_slice ();
+void sp_selected_path_union (SPDesktop *desktop);
+void sp_selected_path_union_skip_undo (SPDesktop *desktop);
+void sp_selected_path_intersect (SPDesktop *desktop);
+void sp_selected_path_diff (SPDesktop *desktop);
+void sp_selected_path_diff_skip_undo (SPDesktop *desktop);
+void sp_selected_path_symdiff (SPDesktop *desktop);
+void sp_selected_path_cut (SPDesktop *desktop);
+void sp_selected_path_slice (SPDesktop *desktop);
 
 // offset/inset of a curve
 // takes the fill-rule in consideration
 // offset amount is the stroke-width of the curve
-void sp_selected_path_offset ();
-void sp_selected_path_offset_screen (double pixels);
-void sp_selected_path_inset ();
-void sp_selected_path_inset_screen (double pixels);
-void sp_selected_path_create_offset ();
-void sp_selected_path_create_inset ();
-void sp_selected_path_create_updating_offset ();
-void sp_selected_path_create_updating_inset ();
+void sp_selected_path_offset (SPDesktop *desktop);
+void sp_selected_path_offset_screen (SPDesktop *desktop, double pixels);
+void sp_selected_path_inset (SPDesktop *desktop);
+void sp_selected_path_inset_screen (SPDesktop *desktop, double pixels);
+void sp_selected_path_create_offset (SPDesktop *desktop);
+void sp_selected_path_create_inset (SPDesktop *desktop);
+void sp_selected_path_create_updating_offset (SPDesktop *desktop);
+void sp_selected_path_create_updating_inset (SPDesktop *desktop);
 
-void sp_selected_path_create_offset_object_zero ();
-void sp_selected_path_create_updating_offset_object_zero ();
+void sp_selected_path_create_offset_object_zero (SPDesktop *desktop);
+void sp_selected_path_create_updating_offset_object_zero (SPDesktop *desktop);
 
 // outline of a curve
 // uses the stroke-width
-void sp_selected_path_outline ();
+void sp_selected_path_outline (SPDesktop *desktop);
 
 // simplifies a path (removes small segments and the like)
-void sp_selected_path_simplify ();
+void sp_selected_path_simplify (SPDesktop *desktop);
 
 Path *Path_for_item(SPItem *item, bool doTransformation, bool transformFull = true);
 Geom::PathVector* pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull, Geom::Matrix extraPreAffine, Geom::Matrix extraPostAffine);
index 86d7e6da2c467158ae51a2d22a3169e4cb627d4c..9c69811282d67fc31662199de0d7fdb29388426d 100644 (file)
@@ -444,7 +444,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
             double th_max = (0.6 - 0.59*sqrt(fidelity)) / NR::expansion(i2doc);
             double threshold = MAX(th_max, th_max*force);
             res->ConvertEvenLines(threshold);
-            res->Simplify(threshold / (SP_ACTIVE_DESKTOP->current_zoom()));
+            res->Simplify(threshold / (selection->desktop()->current_zoom()));
 
             if (newrepr) { // converting to path, need to replace the repr
                 bool is_selected = selection->includes(item);
index cacb0fa077d03a33651367e7333861c5af2acbbf..5947ac2cf817f70c8acd8ba455c8975dd225fc43 100644 (file)
@@ -1031,57 +1031,57 @@ SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/)
             break;
 
         case SP_VERB_SELECTION_UNION:
-            sp_selected_path_union();
+            sp_selected_path_union(dt);
             break;
         case SP_VERB_SELECTION_INTERSECT:
-            sp_selected_path_intersect();
+            sp_selected_path_intersect(dt);
             break;
         case SP_VERB_SELECTION_DIFF:
-            sp_selected_path_diff();
+            sp_selected_path_diff(dt);
             break;
         case SP_VERB_SELECTION_SYMDIFF:
-            sp_selected_path_symdiff();
+            sp_selected_path_symdiff(dt);
             break;
 
         case SP_VERB_SELECTION_CUT:
-            sp_selected_path_cut();
+            sp_selected_path_cut(dt);
             break;
         case SP_VERB_SELECTION_SLICE:
-            sp_selected_path_slice();
+            sp_selected_path_slice(dt);
             break;
 
         case SP_VERB_SELECTION_OFFSET:
-            sp_selected_path_offset();
+            sp_selected_path_offset(dt);
             break;
         case SP_VERB_SELECTION_OFFSET_SCREEN:
-            sp_selected_path_offset_screen(1);
+            sp_selected_path_offset_screen(dt, 1);
             break;
         case SP_VERB_SELECTION_OFFSET_SCREEN_10:
-            sp_selected_path_offset_screen(10);
+            sp_selected_path_offset_screen(dt, 10);
             break;
         case SP_VERB_SELECTION_INSET:
-            sp_selected_path_inset();
+            sp_selected_path_inset(dt);
             break;
         case SP_VERB_SELECTION_INSET_SCREEN:
-            sp_selected_path_inset_screen(1);
+            sp_selected_path_inset_screen(dt, 1);
             break;
         case SP_VERB_SELECTION_INSET_SCREEN_10:
-            sp_selected_path_inset_screen(10);
+            sp_selected_path_inset_screen(dt, 10);
             break;
         case SP_VERB_SELECTION_DYNAMIC_OFFSET:
-            sp_selected_path_create_offset_object_zero();
+            sp_selected_path_create_offset_object_zero(dt);
             tools_switch_current(TOOLS_NODES);
             break;
         case SP_VERB_SELECTION_LINKED_OFFSET:
-            sp_selected_path_create_updating_offset_object_zero();
+            sp_selected_path_create_updating_offset_object_zero(dt);
             tools_switch_current(TOOLS_NODES);
             break;
 
         case SP_VERB_SELECTION_OUTLINE:
-            sp_selected_path_outline();
+            sp_selected_path_outline(dt);
             break;
         case SP_VERB_SELECTION_SIMPLIFY:
-            sp_selected_path_simplify();
+            sp_selected_path_simplify(dt);
             break;
         case SP_VERB_SELECTION_REVERSE:
             sp_selected_path_reverse(dt);