diff options
| author | Alvin Penner <penner@vaxxine.com> | 2015-02-12 16:17:54 +0000 |
|---|---|---|
| committer | apenner <penner@vaxxine.com> | 2015-02-12 16:17:54 +0000 |
| commit | b509a33d405dac5d1064f64644966d8304a21823 (patch) | |
| tree | 683a2b6600ef9dbc0c9e3ed15c096e6deb3d4493 /src | |
| parent | Bump Poppler dependency to 0.8.3 (diff) | |
| download | inkscape-b509a33d405dac5d1064f64644966d8304a21823.tar.gz inkscape-b509a33d405dac5d1064f64644966d8304a21823.zip | |
use up-to-date document units when intiallizing viewbox during a file load
(bzr r13918)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-root.cpp | 3 | ||||
| -rw-r--r-- | src/viewbox.cpp | 14 | ||||
| -rw-r--r-- | src/viewbox.h | 4 |
3 files changed, 9 insertions, 12 deletions
diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 85582e209..3a39a51c1 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -30,6 +30,7 @@ #include "svg/stringstream.h" #include "svg/svg.h" #include "xml/repr.h" +#include "util/units.h" #include "sp-factory.h" @@ -298,7 +299,7 @@ void SPRoot::update(SPCtx *ctx, guint flags) SPItemCtx rctx = *ictx; rctx.viewport = Geom::Rect::from_xywh( this->x.computed, this->y.computed, this->width.computed, this->height.computed ); - rctx = get_rctx( &rctx ); + rctx = get_rctx( &rctx, Inkscape::Util::Quantity::convert(1, this->document->getDisplayUnit(), "px") ); /* And invoke parent method */ SPGroup::update((SPCtx *) &rctx, flags); diff --git a/src/viewbox.cpp b/src/viewbox.cpp index 91f05668e..e1da23efa 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -14,9 +14,6 @@ #include <2geom/transforms.h> -#include "inkscape.h" -#include "document.h" -#include "util/units.h" #include "viewbox.h" #include "attributes.h" #include "enums.h" @@ -164,21 +161,20 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { } // Apply scaling from viewbox -void SPViewBox::apply_viewbox(const Geom::Rect& in) { +void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { /* Determine actual viewbox in viewport coordinates */ + // scale_none is the scale that would apply if the viewbox and page size are same size + // it is passed here because it is a double-precision variable, while 'in' is originally float double x = 0.0; double y = 0.0; double scale_x = in.width() / this->viewBox.width(); double scale_y = in.height() / this->viewBox.height(); double scale_uniform = 1.0; // used only if scaling is uniform - double scale_none = 1.0; // used only if viewbox and page size are same size if (Geom::are_near(scale_x / scale_y, 1.0, Geom::EPSILON)) { // scaling is already uniform, reduce numerical error scale_uniform = (scale_x + scale_y)/2.0; - if (SP_ACTIVE_DOCUMENT) - scale_none = Inkscape::Util::Quantity::convert(1, SP_ACTIVE_DOCUMENT->getDisplayUnit(), "px"); if (Geom::are_near(scale_uniform / scale_none, 1.0, Geom::EPSILON)) scale_uniform = scale_none; // objects are same size, reduce numerical error scale_x = scale_uniform; @@ -243,7 +239,7 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in) { this->c2p = q * this->c2p; } -SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx) { +SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx, double scale_none) { /* Create copy of item context */ SPItemCtx rctx = *ictx; @@ -254,7 +250,7 @@ SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx) { if (this->viewBox_set) { // Adjusts c2p for viewbox - apply_viewbox( rctx.viewport ); + apply_viewbox( rctx.viewport, scale_none ); } rctx.i2doc = this->c2p * rctx.i2doc; diff --git a/src/viewbox.h b/src/viewbox.h index 1898cd98f..c71abb610 100644 --- a/src/viewbox.h +++ b/src/viewbox.h @@ -41,9 +41,9 @@ public: void set_preserveAspectRatio(const gchar* value); /* Adjusts c2p for viewbox */ - void apply_viewbox(const Geom::Rect& in); + void apply_viewbox(const Geom::Rect& in, double scale_none = 1.0); - SPItemCtx get_rctx( const SPItemCtx* ictx); + SPItemCtx get_rctx( const SPItemCtx* ictx, double scale_none = 1.0); }; |
