summaryrefslogtreecommitdiffstats
path: root/src/sp-guide.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:16:36 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:16:36 +0000
commit913372144fbee834867176885a5526d70243e4e0 (patch)
treea28957014d44a50067932243cc919f522efac898 /src/sp-guide.cpp
parentupdate to trunk (diff)
parentLatvian translation update (diff)
downloadinkscape-913372144fbee834867176885a5526d70243e4e0.tar.gz
inkscape-913372144fbee834867176885a5526d70243e4e0.zip
update to trunk
(bzr r13682.1.23)
Diffstat (limited to 'src/sp-guide.cpp')
-rw-r--r--src/sp-guide.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index 3eecb2783..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)
@@ -156,8 +146,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) {
@@ -198,8 +195,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 +345,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.