Code

Split SPCanvasItem and SPCanvasGroup to individual .h files. Removed forward header.
[inkscape.git] / src / spray-context.cpp
index 40bfc041ecf560dd103f41b36e746319244abac3..6d19cbce429f662e0d6dfa55f82c133045340a11 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_SPRAY_CONTEXT_C__
-
 /*
  * Spray Tool
  *
@@ -12,6 +10,8 @@
  *   Vincent MONTAGNE
  *   Pierre BARBRY-BLOT
  *   Steren GIANNINI (steren.giannini@gmail.com)
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2009 authors
  *
@@ -27,7 +27,6 @@
 #include <numeric>
 
 #include "svg/svg.h"
-#include "display/canvas-bpath.h"
 
 #include <glib/gmem.h>
 #include "macros.h"
 #include "path-chemistry.h"
 #include "sp-gradient.h"
 #include "sp-stop.h"
-#include "sp-stop-fns.h"
 #include "sp-gradient-reference.h"
 #include "sp-linear-gradient.h"
 #include "sp-radial-gradient.h"
 #include "gradient-chemistry.h"
 #include "sp-text.h"
 #include "sp-flowtext.h"
+#include "display/sp-canvas.h"
 #include "display/canvas-bpath.h"
 #include "display/canvas-arena.h"
 #include "display/curve.h"
@@ -82,6 +81,8 @@
 #include "helper/action.h"
 
 #include <iostream>
+
+using Inkscape::DocumentUndo;
 using namespace std;
 
 
@@ -152,9 +153,9 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom
     Geom::Translate const s(c);
     Geom::Matrix affine = Geom::Matrix(s).inverse() * Geom::Matrix(rotation) * Geom::Matrix(s);
     // Rotate item.
-    sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine);
+    item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine);
     // Use each item's own transform writer, consistent with sp_selection_apply_affine()
-    sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+    item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
     // Restore the center position (it's changed because the bbox center changed)
     if (item->isCenterSet()) {
         item->setCenter(c);
@@ -166,8 +167,8 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom
 void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale  const &scale)
 {
     Geom::Translate const s(c);
-    sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s  );
-    sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+    item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s  );
+    item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
 }
 
 static void sp_spray_context_init(SPSprayContext *tc)
@@ -422,7 +423,7 @@ double get_move_standard_deviation(SPSprayContext *tc)
  * @param[in]   choice : 
 
  */
-void random_position( double &radius, double &angle, double &a, double &s, int choice)
+void random_position( double &radius, double &angle, double &a, double &s, int /*choice*/)
 {
     // angle is taken from an uniform distribution
     angle = g_random_double_range(0, M_PI*2.0);
@@ -480,14 +481,14 @@ bool sp_spray_recursive(SPDesktop *desktop,
     dr=dr*radius;
 
     if (mode == SPRAY_MODE_COPY) {
-        Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+        Geom::OptRect a = item->getBounds(item->i2doc_affine());
         if (a) {
             SPItem *item_copied;
             if(_fid<=population)
             {
                 // duplicate
                 SPDocument *doc = SP_OBJECT_DOCUMENT(item);
-                Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
+                Inkscape::XML::Document* xml_doc = doc->getReprDoc();
                 Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item);
                 Inkscape::XML::Node *parent = old_repr->parent();
                 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
@@ -528,11 +529,11 @@ bool sp_spray_recursive(SPDesktop *desktop,
             i++;
         }
         SPDocument *doc = SP_OBJECT_DOCUMENT(father);
-        Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
+        Inkscape::XML::Document* xml_doc = doc->getReprDoc();
         Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(father);
         Inkscape::XML::Node *parent = old_repr->parent();
 
-        Geom::OptRect a = father->getBounds(sp_item_i2doc_affine(father));
+        Geom::OptRect a = father->getBounds(father->i2doc_affine());
         if (a) {
             if (i==2) {
                 Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc);
@@ -563,19 +564,19 @@ bool sp_spray_recursive(SPDesktop *desktop,
                 selection->clear();
                 selection->add(item_copied);
                 selection->add(unionResult);
-                sp_selected_path_union(selection->desktop());
+                sp_selected_path_union_skip_undo(selection->desktop());
                 selection->add(father);
                 Inkscape::GC::release(copy2);
                 did = true;
             }
         }
     } else if (mode == SPRAY_MODE_CLONE) {
-        Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+        Geom::OptRect a = item->getBounds(item->i2doc_affine());
         if (a) {
             if(_fid<=population) {
                 SPItem *item_copied;
                 SPDocument *doc = SP_OBJECT_DOCUMENT(item);
-                Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
+                Inkscape::XML::Document* xml_doc = doc->getReprDoc();
                 Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item);
                 Inkscape::XML::Node *parent = old_repr->parent();
 
@@ -878,16 +879,16 @@ case GDK_SCROLL_LEFT:
             tc->has_dilated = false;
             switch (tc->mode) {
                 case SPRAY_MODE_COPY:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_SPRAY, _("Spray with copies"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_SPRAY, _("Spray with copies"));
                     break;
                 case SPRAY_MODE_CLONE:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
                     break;
                 case SPRAY_MODE_SINGLE_PATH:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
                     break;
             }
         }
@@ -1052,5 +1053,5 @@ break;
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :