diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2015-01-06 12:37:55 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2015-01-06 12:37:55 +0000 |
| commit | 5420b476f4668b03f4ce169494792c78b3a3235d (patch) | |
| tree | eb9e294469079afe8ace1c2809e0b41815d75b49 /src/document.cpp | |
| parent | UI/i18n. Fixing inconsistencies in the Fillet/Chamfer LPE dialogs. (diff) | |
| download | inkscape-5420b476f4668b03f4ce169494792c78b3a3235d.tar.gz inkscape-5420b476f4668b03f4ce169494792c78b3a3235d.zip | |
Add getDocumentScale() to return "real-world" to "user-unit" scale factor.
Use it to correct text postion after removing from path.
(bzr r13843)
Diffstat (limited to 'src/document.cpp')
| -rw-r--r-- | src/document.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/document.cpp b/src/document.cpp index 4b074c2fa..2caefb4ed 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -604,12 +604,32 @@ Inkscape::Util::Unit const* SPDocument::getDisplayUnit() const /// guaranteed not to return nullptr // returns 'px' units as default, like legacy Inkscape +// THIS SHOULD NOT BE USED... INSTEAD USE DOCUMENT SCALE Inkscape::Util::Unit const& SPDocument::getSVGUnit() const { SPNamedView const* nv = sp_document_namedview(this, NULL); return nv ? nv->getSVGUnit() : *unit_table.getUnit("px"); } +/// Returns document scale as defined by width/height and viewBox (real world to user-units). +Geom::Scale SPDocument::getDocumentScale() const +{ + Geom::Scale scale; + if( root->viewBox_set ) { + double scale_x = 1.0; + double scale_y = 1.0; + if( root->viewBox.width() > 0.0 ) { + scale_x = root->width.computed / root->viewBox.width(); + } + if( root->viewBox.height() > 0.0 ) { + scale_y = root->height.computed / root->viewBox.height(); + } + scale = Geom::Scale(scale_x, scale_y); + } + // std::cout << "SPDocument::getDocumentScale():\n" << scale << std::endl; + return scale; +} + // Avoid calling root->updateRepr() twice by combining setting width and height. // (As done on every delete as clipboard calls this via fitToRect(). Also called in page-sizer.cpp) void SPDocument::setWidthAndHeight(const Inkscape::Util::Quantity &width, const Inkscape::Util::Quantity &height, bool changeSize) |
