Code

Node tool: snap while scaling a selection of nodes. Consider this as experimental...
[inkscape.git] / src / ui / tool / control-point-selection.h
index dde9ef218aefadb9bd467c70fbaa342a2a6aeaab..0e5acf6c5cc84e05151f5f8de19915117a02f20a 100644 (file)
@@ -1,5 +1,5 @@
 /** @file
- * Node selection - stores a set of nodes and applies transformations
+ * Control point selection - stores a set of control points and applies transformations
  * to them
  */
 /* Authors:
@@ -9,22 +9,23 @@
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
-#ifndef SEEN_UI_TOOL_NODE_SELECTION_H
-#define SEEN_UI_TOOL_NODE_SELECTION_H
+#ifndef SEEN_UI_TOOL_CONTROL_POINT_SELECTION_H
+#define SEEN_UI_TOOL_CONTROL_POINT_SELECTION_H
 
 #include <memory>
 #include <boost/optional.hpp>
-#include <boost/unordered_set.hpp>
 #include <sigc++/sigc++.h>
 #include <2geom/forward.h>
 #include <2geom/point.h>
 #include <2geom/rect.h>
-#include "display/display-forward.h"
 #include "util/accumulators.h"
+#include "util/unordered-containers.h"
 #include "ui/tool/commit-events.h"
 #include "ui/tool/manipulator.h"
+#include "snap-candidate.h"
 
 class SPDesktop;
+struct SPCanvasGroup;
 
 namespace Inkscape {
 namespace UI {
@@ -40,7 +41,7 @@ class ControlPointSelection : public Manipulator, public sigc::trackable {
 public:
     ControlPointSelection(SPDesktop *d, SPCanvasGroup *th_group);
     ~ControlPointSelection();
-    typedef boost::unordered_set< SelectableControlPoint * > set_type;
+    typedef INK_UNORDERED_SET<SelectableControlPoint *> set_type;
     typedef set_type Set; // convenience alias
 
     typedef set_type::iterator iterator;
@@ -75,7 +76,9 @@ public:
     void erase(iterator first, iterator last);
 
     // find
-    iterator find(const key_type &k) { return _points.find(k); }
+    iterator find(const key_type &k) {
+        return _points.find(k);
+    }
 
     // Sometimes it is very useful to keep a list of all selectable points.
     set_type const &allPoints() const { return _all_points; }
@@ -106,12 +109,16 @@ public:
     sigc::signal<void> signal_update;
     sigc::signal<void, SelectableControlPoint *, bool> signal_point_changed;
     sigc::signal<void, CommitEvent> signal_commit;
+
+    std::vector<Inkscape::SnapCandidatePoint> getOriginalPoints();
+    void setOriginalPoints();
+
 private:
     // The functions below are invoked from SelectableControlPoint.
     // Previously they were connected to handlers when selecting, but this
     // creates problems when dragging a point that was not selected.
-    void _pointGrabbed();
-    void _pointDragged(Geom::Point const &, Geom::Point &, GdkEventMotion *);
+    void _pointGrabbed(SelectableControlPoint *);
+    void _pointDragged(Geom::Point &, GdkEventMotion *);
     void _pointUngrabbed();
     bool _pointClicked(SelectableControlPoint *, GdkEventButton *);
     void _pointChanged(SelectableControlPoint *, bool);
@@ -129,11 +136,13 @@ private:
 
     set_type _points;
     set_type _all_points;
+    INK_UNORDERED_MAP<SelectableControlPoint *, Geom::Point> _original_positions;
+    INK_UNORDERED_MAP<SelectableControlPoint *, Geom::Matrix> _last_trans;
     boost::optional<double> _rot_radius;
     boost::optional<double> _mouseover_rot_radius;
     Geom::OptRect _bounds;
     TransformHandleSet *_handles;
-    SelectableControlPoint *_grabbed_point;
+    SelectableControlPoint *_grabbed_point, *_farthest_point;
     unsigned _dragging         : 1;
     unsigned _handles_visible  : 1;
     unsigned _one_node_handles : 1;
@@ -155,4 +164,4 @@ private:
   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 :