From 72cc39b9f0b340548f395c7f61ca9662b34aea09 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 11:04:37 +0200 Subject: Refactor SPItem bounding box methods: remove NRRect usage and make code using them more obvious. Fix filter region computation. (bzr r10582.1.1) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 72f92bd17..cf2474fe5 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1086,7 +1086,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); } else { SPItem *child = SP_ITEM(o); - Geom::OptRect box = child->getBboxDesktop(); + Geom::OptRect box = child->desktopVisualBounds(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s = g_slist_append(s, child); } -- cgit v1.2.3 From 24526cceccb4ed103a6324756476c64efb3fb5dd Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 16:58:22 +0200 Subject: Remove all NRRect use. (bzr r10582.1.5) --- src/document.cpp | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index cf2474fe5..d45041296 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -534,7 +534,7 @@ gdouble SPDocument::getWidth() const gdouble result = root->width.computed; if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { - result = root->viewBox.x1 - root->viewBox.x0; + result = root->viewBox.width(); } return result; } @@ -542,7 +542,7 @@ gdouble SPDocument::getWidth() const void SPDocument::setWidth(gdouble width, const SPUnit *unit) { if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + sp_units_get_pixels (width, *unit), root->viewBox.bottom())); } else { // set to width= gdouble old_computed = root->width.computed; root->width.computed = sp_units_get_pixels (width, *unit); @@ -557,16 +557,28 @@ void SPDocument::setWidth(gdouble width, const SPUnit *unit) } if (root->viewBox_set) - root->viewBox.x1 = root->viewBox.x0 + (root->width.computed / old_computed) * (root->viewBox.x1 - root->viewBox.x0); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); } root->updateRepr(); } +gdouble SPDocument::getHeight() const +{ + g_return_val_if_fail(this->priv != NULL, 0.0); + g_return_val_if_fail(this->root != NULL, 0.0); + + gdouble result = root->height.computed; + if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { + result = root->viewBox.height(); + } + return result; +} + void SPDocument::setHeight(gdouble height, const SPUnit *unit) { if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + sp_units_get_pixels (height, *unit))); } else { // set to height= gdouble old_computed = root->height.computed; root->height.computed = sp_units_get_pixels (height, *unit); @@ -581,24 +593,12 @@ void SPDocument::setHeight(gdouble height, const SPUnit *unit) } if (root->viewBox_set) - root->viewBox.y1 = root->viewBox.y0 + (root->height.computed / old_computed) * (root->viewBox.y1 - root->viewBox.y0); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); } root->updateRepr(); } -gdouble SPDocument::getHeight() const -{ - g_return_val_if_fail(this->priv != NULL, 0.0); - g_return_val_if_fail(this->root != NULL, 0.0); - - gdouble result = root->height.computed; - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { - result = root->viewBox.y1 - root->viewBox.y0; - } - return result; -} - Geom::Point SPDocument::getDimensions() const { return Geom::Point(getWidth(), getHeight()); @@ -941,15 +941,9 @@ void SPDocument::setupViewport(SPItemCtx *ctx) ctx->i2doc = Geom::identity(); // Set up viewport in case svg has it defined as percentages if (root->viewBox_set) { // if set, take from viewBox - ctx->vp.x0 = root->viewBox.x0; - ctx->vp.y0 = root->viewBox.y0; - ctx->vp.x1 = root->viewBox.x1; - ctx->vp.y1 = root->viewBox.y1; + ctx->viewport = root->viewBox; } else { // as a last resort, set size to A4 - ctx->vp.x0 = 0.0; - ctx->vp.y0 = 0.0; - ctx->vp.x1 = 210 * PX_PER_MM; - ctx->vp.y1 = 297 * PX_PER_MM; + ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * PX_PER_MM, 297 * PX_PER_MM); } ctx->i2vp = Geom::identity(); } -- cgit v1.2.3