summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7af0b61)
raw | patch | inline | side by side (parent: 7af0b61)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Wed, 13 Jun 2007 20:39:53 +0000 (20:39 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Wed, 13 Jun 2007 20:39:53 +0000 (20:39 +0000) |
src/seltrans.cpp | patch | blob | history | |
src/sp-rect.cpp | patch | blob | history |
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 9c874c242cb666d8d2b07f18c92deb0e7b1846bd..56138c51eb9ee1632a52b1ae1cb0a5fe534325c1 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -310,6 +310,8 @@ void Inkscape::SelTrans::grab(NR::Point const &p, gdouble x, gdouble y, bool sho
_opposite = _opposite_for_bboxpoints;
}
+ // The lines below are usefull for debugging any snapping issues, as they'll spit out all points that are considered for snapping
+
/*std::cout << "Number of snap points: " << _snap_points.size() << std::endl;
for (std::vector<NR::Point>::const_iterator i = _snap_points.begin(); i != _snap_points.end(); i++)
{
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 6823f21229dca2aa254e9c291881538aeabe6593..0aaa834f251a3b98bc4a1a7eed0de5d785cc6cab 100644 (file)
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
static NR::Matrix sp_rect_set_transform(SPItem *item, NR::Matrix const &xform);
static void sp_rect_set_shape(SPShape *shape);
+static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p);
static SPShapeClass *parent_class;
item_class->description = sp_rect_description;
item_class->set_transform = sp_rect_set_transform;
+ item_class->snappoints = sp_rect_snappoints; //override the default sp_shape_snappoints; see sp_rect_snappoints for details
shape_class->set_shape = sp_rect_set_shape;
}
SP_ITEM(rect)->transform);
}
+/**
+ * Sets the snappoint p to the unrounded corners of the rectangle
+ */
+static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p)
+{
+ /* This method overrides sp_shape_snappoints, which is the default for any shape. The default method
+ returns all eight points along the path of a rounded rectangle, but not the real corners. Snapping
+ the startpoint and endpoint of each rounded corner is not very usefull and really confusing. Instead
+ we could snap either the real corners, or not snap at all. Bulia Byak opted to snap the real corners,
+ but it should be noted that this might be confusing in some cases with relatively large radii. With
+ small radii though the user will easily understand which point is snapping. */
+
+ g_assert(item != NULL);
+ g_assert(SP_IS_RECT(item));
+
+ SPRect *rect = SP_RECT(item);
+
+ NR::Matrix const i2d (sp_item_i2d_affine (item));
+
+ *p = NR::Point(rect->x.computed, rect->y.computed) * i2d;
+ *p = NR::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d;
+ *p = NR::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d;
+ *p = NR::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d;
+}
+
/*
Local Variables:
mode:c++