summaryrefslogtreecommitdiffstats
path: root/src/sp-spiral.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-09-20 17:43:57 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-09-20 17:43:57 +0000
commit0a836d1870bb87d5be3e4d900718f903371c8e56 (patch)
tree7d218dc0e9d81e2f7d3eddcefad9640769dc89b3 /src/sp-spiral.cpp
parentCompact of SVG icons whith the help of ~suv and Martin Owens (diff)
parentMerge Google Summer of Code unit improvement. (diff)
downloadinkscape-0a836d1870bb87d5be3e4d900718f903371c8e56.tar.gz
inkscape-0a836d1870bb87d5be3e4d900718f903371c8e56.zip
Update to trunk
(bzr r11950.1.146)
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..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 {
@@ -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::display_name() {
+ 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.