summaryrefslogtreecommitdiffstats
path: root/src/snap.h
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2015-09-13 17:50:28 +0000
committerDiederik van Lierop <mail@diedenrezi.nl>2015-09-13 17:50:28 +0000
commit25900540fbb26b44933ce1ead2240893769cd60f (patch)
tree731a41270b51019617bf708b2ad6da26cb3cfe81 /src/snap.h
parentSecond round of extension executable bit cleanup. (diff)
downloadinkscape-25900540fbb26b44933ce1ead2240893769cd60f.tar.gz
inkscape-25900540fbb26b44933ce1ead2240893769cd60f.zip
Refactoring of the code that handles transformations and snapping in the selector tool and the node tool. Splitting large chunks of code into some small classes, and eliminating some wrapper methods which were all just too similar
(bzr r14363)
Diffstat (limited to '')
-rw-r--r--src/snap.h168
1 files changed, 20 insertions, 148 deletions
diff --git a/src/snap.h b/src/snap.h
index 944c49b3e..c4dd67b4c 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -21,6 +21,8 @@
#include "guide-snapper.h"
#include "object-snapper.h"
#include "snap-preferences.h"
+//#include "pure-transform.h"
+
// Guides
enum SPGuideDragType { // used both here and in desktop-events.cpp
@@ -32,6 +34,11 @@ enum SPGuideDragType { // used both here and in desktop-events.cpp
class SPGuide;
class SPNamedView;
+
+namespace Inkscape {
+ class PureTransform;
+}
+
typedef struct _GSList GSList;
/**
@@ -327,110 +334,6 @@ public:
*/
void guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const;
- /**
- * Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint freeSnapTranslate(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Geom::Point const &tr);
-
- /**
- * Apply a translation to a set of points and try to snap along a constraint.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param constraint The direction or line along which snapping must occur.
- * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint constrainedSnapTranslate(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Inkscape::Snapper::SnapConstraint const &constraint,
- Geom::Point const &tr);
-
- /**
- * Apply a scaling to a set of points and try to snap freely in 2 degrees-of-freedom.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param s Proposed scaling; the final scaling can only be calculated after snapping has occurred.
- * @param o Origin of the scaling.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint freeSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Geom::Scale const &s,
- Geom::Point const &o);
-
- /**
- * Apply a scaling to a set of points and snap such that the aspect ratio of the selection is preserved.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param s Proposed scaling; the final scaling can only be calculated after snapping has occurred.
- * @param o Origin of the scaling.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint constrainedSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Geom::Scale const &s,
- Geom::Point const &o);
-
- /**
- * Apply a stretch to a set of points and snap such that the direction of the stretch is preserved.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param s Proposed stretch; the final stretch can only be calculated after snapping has occurred.
- * @param o Origin of the stretching.
- * @param d Dimension in which to apply proposed stretch.
- * @param u true if the stretch should be uniform (i.e. to be applied equally in both dimensions).
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint constrainedSnapStretch(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Geom::Coord const &s,
- Geom::Point const &o,
- Geom::Dim2 d,
- bool uniform);
-
- /**
- * Apply a skew to a set of points and snap such that the direction of the skew is preserved.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param constraint The direction or line along which snapping must occur.
- * @param s Proposed skew; the final skew can only be calculated after snapping has occurred.
- * @param o Origin of the proposed skew.
- * @param d Dimension in which to apply proposed skew.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint constrainedSnapSkew(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Inkscape::Snapper::SnapConstraint const &constraint,
- Geom::Point const &s, // s[0] = skew factor, s[1] = scale factor
- Geom::Point const &o,
- Geom::Dim2 d);
-
- /**
- * Apply a rotation to a set of points and snap, without scaling.
- *
- * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
- * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param angle Proposed rotation (in radians); the final rotation can only be calculated after snapping has occurred.
- * @param o Origin of the rotation.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
- */
- Inkscape::SnappedPoint constrainedSnapRotate(std::vector<Inkscape::SnapCandidatePoint> const &p,
- Geom::Point const &pointer,
- Geom::Coord const &angle,
- Geom::Point const &o);
-
Inkscape::GuideSnapper guide; ///< guide snapper
Inkscape::ObjectSnapper object; ///< snapper to other objects
Inkscape::SnapPreferences snapprefs;
@@ -490,17 +393,6 @@ public:
*/
void displaySnapsource(Inkscape::SnapCandidatePoint const &p) const;
-protected:
- SPNamedView const *_named_view;
-
-private:
- std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method
- std::vector<SPItem*> _rotation_center_source_items; // to avoid snapping a rotation center to itself
- SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged
- SPDesktop const *_desktop;
- bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to
- std::vector<Inkscape::SnapCandidatePoint> *_unselected_nodes; ///< Nodes of the path that is currently being edited and which have not been selected and which will therefore be stationary. Only these nodes will be considered for snapping to. Of each unselected node both the position (Geom::Point) and the type (Inkscape::SnapTargetType) will be stored
-
/**
* Method for snapping sets of points while they are being transformed.
*
@@ -518,42 +410,22 @@ private:
*
* @param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
* @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
- * @param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation.
- * @param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined.
- * @param transformation_type Type of transformation to apply to points before trying to snap them.
- * @param transformation Description of the transformation; details depend on the type.
- * @param origin Origin of the transformation, if applicable.
- * @param dim Dimension to which the transformation applies, if applicable.
- * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling.
- * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
+ * @param transform Describes the type of transformation, it's parameters, and any additional constraints
*/
- Inkscape::SnappedPoint _snapTransformed(std::vector<Inkscape::SnapCandidatePoint> const &points,
+ void snapTransformed(std::vector<Inkscape::SnapCandidatePoint> const &points,
Geom::Point const &pointer,
- bool constrained,
- Inkscape::Snapper::SnapConstraint const &constraint,
- Transformation transformation_type,
- Geom::Point const &transformation,
- Geom::Point const &origin,
- Geom::Dim2 dim,
- bool uniform);
+ Inkscape::PureTransform &transform);
- /**
- * Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code.
- *
- * @param p The untransformed position of the point, paired with an identifier of the type of the snap source.
- * @param transformation_type Type of transformation to apply.
- * @param transformation Mathematical description of the transformation; details depend on the type.
- * @param origin Origin of the transformation, if applicable.
- * @param dim Dimension to which the transformation applies, if applicable.
- * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling.
- * @return The position of the point after transformation.
- */
- Geom::Point _transformPoint(Inkscape::SnapCandidatePoint const &p,
- Transformation const transformation_type,
- Geom::Point const &transformation,
- Geom::Point const &origin,
- Geom::Dim2 const dim,
- bool const uniform) const;
+protected:
+ SPNamedView const *_named_view;
+
+private:
+ std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method
+ std::vector<SPItem*> _rotation_center_source_items; // to avoid snapping a rotation center to itself
+ SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged
+ SPDesktop const *_desktop;
+ bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to
+ std::vector<Inkscape::SnapCandidatePoint> *_unselected_nodes; ///< Nodes of the path that is currently being edited and which have not been selected and which will therefore be stationary. Only these nodes will be considered for snapping to. Of each unselected node both the position (Geom::Point) and the type (Inkscape::SnapTargetType) will be stored
};