diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-08-27 14:58:22 +0000 |
|---|---|---|
| committer | Krzysztof Kosinski <tweenk.pl@gmail.com> | 2011-08-27 14:58:22 +0000 |
| commit | 24526cceccb4ed103a6324756476c64efb3fb5dd (patch) | |
| tree | 24abb1d2b1bdb6156a83f2d393cbdc4747fda4ac /src/sp-symbol.cpp | |
| parent | Remove NRRect from paint servers and temporary calculations (diff) | |
| download | inkscape-24526cceccb4ed103a6324756476c64efb3fb5dd.tar.gz inkscape-24526cceccb4ed103a6324756476c64efb3fb5dd.zip | |
Remove all NRRect use.
(bzr r10582.1.5)
Diffstat (limited to 'src/sp-symbol.cpp')
| -rw-r--r-- | src/sp-symbol.cpp | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 0a1ebdb06..87cd210e4 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -131,10 +131,7 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; if ((width > 0) && (height > 0)) { /* Set viewbox */ - symbol->viewBox.x0 = x; - symbol->viewBox.y0 = y; - symbol->viewBox.x1 = x + width; - symbol->viewBox.y1 = y + height; + symbol->viewBox = Geom::Rect::from_xywh(x, y, width, height); symbol->viewBox_set = TRUE; } else { symbol->viewBox_set = FALSE; @@ -234,7 +231,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) /* Calculate child to parent transformation */ /* Apply parent <use> translation (set up as vewport) */ - symbol->c2p = Geom::Affine(Geom::Translate(rctx.vp.x0, rctx.vp.y0)); + symbol->c2p = Geom::Translate(rctx.viewport.min()); if (symbol->viewBox_set) { double x, y, width, height; @@ -242,16 +239,16 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) if (symbol->aspect_align == SP_ASPECT_NONE) { x = 0.0; y = 0.0; - width = rctx.vp.x1 - rctx.vp.x0; - height = rctx.vp.y1 - rctx.vp.y0; + width = rctx.viewport.width(); + height = rctx.viewport.height(); } else { double scalex, scaley, scale; /* Things are getting interesting */ - scalex = (rctx.vp.x1 - rctx.vp.x0) / (symbol->viewBox.x1 - symbol->viewBox.x0); - scaley = (rctx.vp.y1 - rctx.vp.y0) / (symbol->viewBox.y1 - symbol->viewBox.y0); + scalex = rctx.viewport.width() / symbol->viewBox.width(); + scaley = rctx.viewport.height() / symbol->viewBox.height(); scale = (symbol->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = (symbol->viewBox.x1 - symbol->viewBox.x0) * scale; - height = (symbol->viewBox.y1 - symbol->viewBox.y0) * scale; + width = symbol->viewBox.width() * scale; + height = symbol->viewBox.height() * scale; /* Now place viewbox to requested position */ switch (symbol->aspect_align) { case SP_ASPECT_XMIN_YMIN: @@ -259,36 +256,36 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) y = 0.0; break; case SP_ASPECT_XMID_YMIN: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); + x = 0.5 * (rctx.viewport.width() - width); y = 0.0; break; case SP_ASPECT_XMAX_YMIN: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); + x = 1.0 * (rctx.viewport.width() - width); y = 0.0; break; case SP_ASPECT_XMIN_YMID: x = 0.0; - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMID_YMID: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 0.5 * (rctx.viewport.width() - width); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMAX_YMID: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 1.0 * (rctx.viewport.width() - width); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMIN_YMAX: x = 0.0; - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + y = 1.0 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMID_YMAX: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 0.5 * (rctx.viewport.width() - width); + y = 1.0 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMAX_YMAX: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 1.0 * (rctx.viewport.width() - width); + y = 1.0 * (rctx.viewport.height() - height); break; default: x = 0.0; @@ -298,12 +295,12 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } /* Compose additional transformation from scale and position */ Geom::Affine q; - q[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0); + q[0] = width / symbol->viewBox.width(); q[1] = 0.0; q[2] = 0.0; - q[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0); - q[4] = -symbol->viewBox.x0 * q[0] + x; - q[5] = -symbol->viewBox.y0 * q[3] + y; + q[3] = height / symbol->viewBox.height(); + q[4] = -symbol->viewBox.left() * q[0] + x; + q[5] = -symbol->viewBox.top() * q[3] + y; /* Append viewbox transformation */ symbol->c2p = q * symbol->c2p; } @@ -313,10 +310,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) /* If viewBox is set initialize child viewport */ /* Otherwise <use> has set it up already */ if (symbol->viewBox_set) { - rctx.vp.x0 = symbol->viewBox.x0; - rctx.vp.y0 = symbol->viewBox.y0; - rctx.vp.x1 = symbol->viewBox.x1; - rctx.vp.y1 = symbol->viewBox.y1; + rctx.viewport = symbol->viewBox; rctx.i2vp = Geom::identity(); } |
