From 19117c36082531a00df461260f917d1207edde1f Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Wed, 11 Aug 2010 08:43:24 +0200 Subject: Clear pointers in the snapmanager if they're no longer needed. (bzr r9697) --- src/seltrans.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 764c222a8..7dbeb4173 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1039,6 +1039,7 @@ gboolean Inkscape::SelTrans::scaleRequest(Geom::Point &pt, guint state) geom_scale = Geom::Scale(sn.getTransformation()); pt = _calcAbsAffineGeom(geom_scale); } + m.unSetup(); } /* Status text */ @@ -1134,6 +1135,8 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, Geom // will have to calculate pt taking the stroke width into account pt = _calcAbsAffineGeom(geom_scale); } + + m.unSetup(); } // status text @@ -1226,6 +1229,8 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P } else { _desktop->snapindicator->remove_snaptarget(); } + + m.unSetup(); } // Update the handle position @@ -1299,6 +1304,7 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state) m.setup(_desktop, false, _items_const); // When rotating, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapRotate" for details Inkscape::SnappedPoint sn = m.constrainedSnapRotate(_snap_points, _point, radians, _origin); + m.unSetup(); if (sn.getSnapped()) { _desktop->snapindicator->set_new_snaptarget(sn); @@ -1309,6 +1315,7 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state) } else { _desktop->snapindicator->remove_snaptarget(); } + } @@ -1331,9 +1338,6 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state) // Move the item's transformation center gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) { - SnapManager &m = _desktop->namedview->snap_manager; - m.setup(_desktop); - // Center is being dragged for the first item in the selection only // Find out which item is first ... GSList *items = (GSList *) const_cast(_selection)->itemList(); @@ -1343,8 +1347,11 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) } // ... and store that item because later on we need to make sure that // this transformation center won't snap to itself + SnapManager &m = _desktop->namedview->snap_manager; + m.setup(_desktop); m.setRotationCenterSource(first); m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER); + m.unSetup(); if (state & GDK_CONTROL_MASK) { if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) { @@ -1439,6 +1446,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) } m.setup(_desktop, true, _items_const); dxy = m.multipleOfGridPitch(dxy, _point); + m.unSetup(); } else if (shift) { if (control) { // shift & control: constrained movement without snapping if (fabs(dxy[Geom::X]) > fabs(dxy[Geom::Y])) { @@ -1493,6 +1501,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) double elapsed = ((((double)endtime.tv_sec - starttime.tv_sec) * G_USEC_PER_SEC + (endtime.tv_usec - starttime.tv_usec))) / 1000.0; std::cout << "Time spent snapping: " << elapsed << std::endl; */ } + m.unSetup(); /* Pick one */ Inkscape::SnappedPoint best_snapped_point; -- cgit v1.2.3 From ae65480e4089a909a979962fce9265ab44d05b47 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 7 Oct 2010 22:38:37 +0200 Subject: Fix self-snapping when dragging the transformation center of a selection containing multiple items (as reported by LucaDC in LP #607107, comment #30) (bzr r9817) --- src/seltrans.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 7dbeb4173..9a1fdf4ad 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1338,18 +1338,15 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state) // Move the item's transformation center gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) { - // Center is being dragged for the first item in the selection only - // Find out which item is first ... - GSList *items = (GSList *) const_cast(_selection)->itemList(); - SPItem *first = NULL; - if (items) { - first = reinterpret_cast(g_slist_last(items)->data); // from the first item in selection - } - // ... and store that item because later on we need to make sure that - // this transformation center won't snap to itself SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); - m.setRotationCenterSource(first); + + // When dragging the transformation center while multiple items have been selected, then those + // items will share a single center. While dragging that single center, it should never snap to the + // centers of any of the selected objects. Therefore we will have to pass the list of selected items + // to the snapper, to avoid self-snapping of the rotation center + GSList *items = (GSList *) const_cast(_selection)->itemList(); + m.setRotationCenterSource(items); m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER); m.unSetup(); -- cgit v1.2.3 From cd2ff7c27f5809358e151eba391b8f9d85b1eea1 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 7 Nov 2010 21:16:45 +0100 Subject: Leave constrained angular snapping to the snap manager, instead of handling it locally (bzr r9880) --- src/seltrans.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 9a1fdf4ad..7ea2a86c0 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1656,6 +1656,7 @@ void Inkscape::SelTrans::_keepClosestPointOnly(std::vector Date: Tue, 16 Nov 2010 22:33:00 +0100 Subject: Fix display of snap source indicator for constrained snapping in the selector tool (bzr r9898) --- src/seltrans.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 7ea2a86c0..f96fce228 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -401,21 +401,6 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s g_warning("Checking number of snap sources failed; nothing serious, but please report to Diederik"); } - // Optionally, show the snap source - if (!(_state == STATE_ROTATE && x != 0.5 && y != 0.5)) { // but not when we're dragging a rotation handle, because that won't snap - // Now either _bbox_points or _snap_points has a single element, the other one has zero..... or both have zero elements - if ((_snap_points.size() + _bbox_points.size() + _bbox_points_for_translating.size()) > 1) { - g_warning("too many snap sources to display, please fix this"); - } else if (m.snapprefs.getSnapEnabledGlobally()) { - if (_bbox_points.size() == 1) { - _desktop->snapindicator->set_new_snapsource(_bbox_points.at(0)); - } else if (_bbox_points_for_translating.size() == 1) { - _desktop->snapindicator->set_new_snapsource(_bbox_points_for_translating.at(0)); - } else if (_snap_points.size() == 1){ - _desktop->snapindicator->set_new_snapsource(_snap_points.at(0)); - } - } - } } if ((x != -1) && (y != -1)) { -- cgit v1.2.3 From 144819c918dc761641c3cb5a490205fb73194ee3 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 17 Nov 2010 13:12:56 +1100 Subject: Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in all 1074 Vim modelines. The reason for this is that (a) setting the encoding isn't nice, and (b) Vim 7.3 (with modeline enabled) disallows it and pops up an error whenever you open any file with it ("invalid modeline"). Also corrected five deviant modestrings: * src/ui/widget/dock.cpp and src/ui/widget/dock.h: missing colon at the end * src/ui/dialog/tile.cpp: removed gratuitous second colon at the end * src/helper/units-test.h: removed gratuitous space before a colon * share/extensions/export_gimp_palette.py: missing textwidth=99 That's my geekiest commit yet. (bzr r9900) --- src/seltrans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index f96fce228..5a8e5d3db 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1655,4 +1655,4 @@ void Inkscape::SelTrans::_keepClosestPointOnly(std::vector Date: Wed, 17 Nov 2010 22:17:44 +0100 Subject: Shift should disable snapping when dragging the rotation center of an object (bzr r9903) --- src/seltrans.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 5a8e5d3db..cdfcee742 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1323,26 +1323,30 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state) // Move the item's transformation center gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) { - SnapManager &m = _desktop->namedview->snap_manager; - m.setup(_desktop); - // When dragging the transformation center while multiple items have been selected, then those // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center GSList *items = (GSList *) const_cast(_selection)->itemList(); + SnapManager &m = _desktop->namedview->snap_manager; + m.setup(_desktop); m.setRotationCenterSource(items); - m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER); - m.unSetup(); - if (state & GDK_CONTROL_MASK) { - if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) { - pt[Geom::Y] = _point[Geom::Y]; - } else { - pt[Geom::X] = _point[Geom::X]; + if (state & GDK_CONTROL_MASK) { // with Ctrl, constrain to axes + std::vector constraints; + constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(1, 0))); + constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(0, 1))); + Inkscape::SnappedPoint sp = m.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER), constraints, state & GDK_SHIFT_MASK); + pt = sp.getPoint(); + } + else { + if (!(state & GDK_SHIFT_MASK)) { // Shift disables snapping + m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER); } } + m.unSetup(); + // status text GString *xs = SP_PX_TO_METRIC_STRING(pt[Geom::X], _desktop->namedview->getDefaultMetric()); GString *ys = SP_PX_TO_METRIC_STRING(pt[Geom::Y], _desktop->namedview->getDefaultMetric()); -- cgit v1.2.3