summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2015-01-23 20:39:50 +0000
committerapenner <penner@vaxxine.com>2015-01-23 20:39:50 +0000
commit4b34a53a8122919e53ce2e13627e2007fafec0db (patch)
tree79afc31ea2a1e3c53101b2496578f6d0a4ee503d /src
parentFix regression: pasted bitmaps should be embeded. (Bug #855440) (diff)
downloadinkscape-4b34a53a8122919e53ce2e13627e2007fafec0db.tar.gz
inkscape-4b34a53a8122919e53ce2e13627e2007fafec0db.zip
improved precision in placing grids and guides. (Bug 1373311)
Fixed bugs: - https://launchpad.net/bugs/1373311 (bzr r13868)
Diffstat (limited to 'src')
-rw-r--r--src/sp-guide.cpp22
-rw-r--r--src/ui/widget/registered-widget.cpp5
2 files changed, 22 insertions, 5 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index 3eecb2783..890c1f597 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -198,8 +198,15 @@ SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::P
SPRoot *root = doc->getRoot();
if( root->viewBox_set ) {
- newx = newx * root->viewBox.width() / root->width.computed;
- newy = newy * root->viewBox.height() / root->height.computed;
+ // check to see if scaling is uniform
+ if(Geom::are_near((root->viewBox.width() * root->height.computed) / (root->width.computed * root->viewBox.height()), 1.0, Geom::EPSILON)) {
+ double px2vbunit = (root->viewBox.width()/root->width.computed + root->viewBox.height()/root->height.computed)/2.0;
+ newx = newx * px2vbunit;
+ newy = newy * px2vbunit;
+ } else {
+ newx = newx * root->viewBox.width() / root->width.computed;
+ newy = newy * root->viewBox.height() / root->height.computed;
+ }
}
sp_repr_set_point(repr, "position", Geom::Point( newx, newy ));
@@ -341,8 +348,15 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit)
SPRoot *root = document->getRoot();
if( root->viewBox_set ) {
- newx = newx * root->viewBox.width() / root->width.computed;
- newy = newy * root->viewBox.height() / root->height.computed;
+ // check to see if scaling is uniform
+ if(Geom::are_near((root->viewBox.width() * root->height.computed) / (root->width.computed * root->viewBox.height()), 1.0, Geom::EPSILON)) {
+ double px2vbunit = (root->viewBox.width()/root->width.computed + root->viewBox.height()/root->height.computed)/2.0;
+ newx = newx * px2vbunit;
+ newy = newy * px2vbunit;
+ } else {
+ newx = newx * root->viewBox.width() / root->width.computed;
+ newy = newy * root->viewBox.height() / root->height.computed;
+ }
}
//XML Tree being used here directly while it shouldn't be.
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index bbf542987..298377af3 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -245,7 +245,10 @@ RegisteredScalarUnit::on_value_changed()
if (doc) {
SPRoot *root = doc->getRoot();
if (root->viewBox_set) {
- if (_user_units == RSU_x) {
+ // check to see if scaling is uniform
+ if(Geom::are_near((root->viewBox.width() * root->height.computed) / (root->width.computed * root->viewBox.height()), 1.0, Geom::EPSILON)) {
+ scale = (root->viewBox.width() / root->width.computed + root->viewBox.height() / root->height.computed)/2.0;
+ } else if (_user_units == RSU_x) {
scale = root->viewBox.width() / root->width.computed;
} else {
scale = root->viewBox.height() / root->height.computed;