diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-09-20 17:09:19 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-09-20 17:09:19 +0000 |
| commit | cf74f053a081f6f4b460da9cd72afaab23d54d13 (patch) | |
| tree | 427aa22ba3dcad9b55edb90522b5ab0208074e06 /src/sp-spiral.cpp | |
| parent | Using inkscape compact settings to save the icons.svg file (diff) | |
| parent | Merge from trunk. (diff) | |
| download | inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.tar.gz inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.zip | |
Merge Google Summer of Code unit improvement.
(bzr r12554)
Diffstat (limited to 'src/sp-spiral.cpp')
| -rw-r--r-- | src/sp-spiral.cpp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index ab7cc5c9d..e4bfb8c76 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -28,7 +28,6 @@ #include "sp-spiral.h" - #include "sp-factory.h" namespace { @@ -435,6 +434,58 @@ void SPSpiral::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape } /** + * Set spiral transform + */ +Geom::Affine SPSpiral::set_transform(Geom::Affine const &xform) +{ + // Only set transform with proportional scaling + if (!xform.withoutTranslation().isUniformScale()) { + return xform; + } + + /* Calculate spiral start in parent coords. */ + Geom::Point pos( Geom::Point(this->cx, this->cy) * xform ); + + /* This function takes care of translation and scaling, we return whatever parts we can't + handle. */ + Geom::Affine ret(Geom::Affine(xform).withoutTranslation()); + gdouble const s = hypot(ret[0], ret[1]); + if (s > 1e-9) { + ret[0] /= s; + ret[1] /= s; + ret[2] /= s; + ret[3] /= s; + } else { + ret[0] = 1.0; + ret[1] = 0.0; + ret[2] = 0.0; + ret[3] = 1.0; + } + + this->rad *= s; + + /* Find start in item coords */ + pos = pos * ret.inverse(); + this->cx = pos[Geom::X]; + this->cy = pos[Geom::Y]; + + this->set_shape(); + + // Adjust stroke width + this->adjust_stroke(s); + + // Adjust pattern fill + this->adjust_pattern(xform * ret.inverse()); + + // Adjust gradient fill + this->adjust_gradient(xform * ret.inverse()); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + + return ret; +} + +/** * Return one of the points on the spiral. * * \param t specifies how far along the spiral. |
