From a8ef610e1960c0e0d61f417471e8d2c32b51db9a Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 28 Jan 2015 19:03:12 -0500 Subject: for snapping to grids and guides, reduce numerical error for the case of uniform scaling of viewbox (bzr r13881) --- src/sp-guide.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 890c1f597..08b055508 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -156,8 +156,15 @@ void SPGuide::set(unsigned int key, const gchar *value) { // If root viewBox set, interpret guides in terms of viewBox (90/96) SPRoot *root = document->getRoot(); if( root->viewBox_set ) { - newx = newx * root->width.computed / root->viewBox.width(); - newy = newy * root->height.computed / root->viewBox.height(); + if(Geom::are_near((root->width.computed * root->viewBox.height()) / (root->viewBox.width() * root->height.computed), 1.0, Geom::EPSILON)) { + // for uniform scaling, try to reduce numerical error + double vbunit2px = (root->width.computed / root->viewBox.width() + root->height.computed / root->viewBox.height())/2.0; + newx = newx * vbunit2px; + newy = newy * vbunit2px; + } else { + newx = newx * root->width.computed / root->viewBox.width(); + newy = newy * root->height.computed / root->viewBox.height(); + } } this->point_on_line = Geom::Point(newx, newy); } else if (success == 1) { -- cgit v1.2.3 From df7828a7a8ba0b7e6c2dd892ca5f0a62ef718bf0 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 24 Feb 2015 19:22:08 -0500 Subject: create SPObject factory (bzr r13939.1.1) --- src/sp-guide.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 08b055508..4e1c5913d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -47,16 +47,6 @@ using Inkscape::DocumentUndo; using std::vector; -#include "sp-factory.h" - -namespace { - SPObject* createGuide() { - return new SPGuide(); - } - - bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); -} - SPGuide::SPGuide() : SPObject() , label(NULL) -- cgit v1.2.3