summaryrefslogtreecommitdiffstats
path: root/src/sp-spiral.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-09-24 22:17:24 +0000
committerMarkus Engel <markus.engel@tum.de>2013-09-24 22:17:24 +0000
commitbcca22a25ae98f70c36fff6292f0a8fe4e578d89 (patch)
treea18d382d32f471b7119b9b7b2782cec04d6da43f /src/sp-spiral.cpp
parentRefactored SPUse. (diff)
parentFix my email address through codebase (diff)
downloadinkscape-bcca22a25ae98f70c36fff6292f0a8fe4e578d89.tar.gz
inkscape-bcca22a25ae98f70c36fff6292f0a8fe4e578d89.zip
Merged from trunk (r12588).
(bzr r11608.1.129)
Diffstat (limited to 'src/sp-spiral.cpp')
-rw-r--r--src/sp-spiral.cpp63
1 files changed, 58 insertions, 5 deletions
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 8d2954c6e..0c5ef253f 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -28,7 +28,6 @@
#include "sp-spiral.h"
-
#include "sp-factory.h"
namespace {
@@ -227,12 +226,14 @@ void SPSpiral::update_patheffect(bool write) {
shape->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
-gchar* SPSpiral::description() {
- SPSpiral* item = this;
+const char* SPSpiral::displayName() {
+ return _("Spiral");
+}
- // TRANSLATORS: since turn count isn't an integer, please adjust the
+gchar* SPSpiral::description() {
+ // TRANSLATORS: since turn count isn't an integer, please adjust the
// string as needed to deal with an localized plural forms.
- return g_strdup_printf (_("<b>Spiral</b> with %3f turns"), SP_SPIRAL(item)->revo);
+ return g_strdup_printf (_("with %3f turns"), SP_SPIRAL(this)->revo);
}
/**
@@ -433,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.