diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-09-20 17:43:57 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-09-20 17:43:57 +0000 |
| commit | 0a836d1870bb87d5be3e4d900718f903371c8e56 (patch) | |
| tree | 7d218dc0e9d81e2f7d3eddcefad9640769dc89b3 /src/sp-star.cpp | |
| parent | Compact of SVG icons whith the help of ~suv and Martin Owens (diff) | |
| parent | Merge Google Summer of Code unit improvement. (diff) | |
| download | inkscape-0a836d1870bb87d5be3e4d900718f903371c8e56.tar.gz inkscape-0a836d1870bb87d5be3e4d900718f903371c8e56.zip | |
Update to trunk
(bzr r11950.1.146)
Diffstat (limited to 'src/sp-star.cpp')
| -rw-r--r-- | src/sp-star.cpp | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 4a3a8cbe3..bc3155caf 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -251,19 +251,18 @@ void SPStar::update_patheffect(bool write) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +const char* SPStar::display_name() { + if (this->flatsided == false) + return _("Star"); + return _("Polygon"); +} + gchar* SPStar::description() { // while there will never be less than 3 vertices, we still need to // make calls to ngettext because the pluralization may be different // for various numbers >=3. The singular form is used as the index. - if (this->flatsided == false) { - return g_strdup_printf (ngettext("<b>Star</b> with %d vertex", - "<b>Star</b> with %d vertices", - this->sides), this->sides); - } else { - return g_strdup_printf (ngettext("<b>Polygon</b> with %d vertex", - "<b>Polygon</b> with %d vertices", - this->sides), this->sides); - } + return g_strdup_printf (ngettext(_("with %d vertex"), _("with %d vertices"), + this->sides), this->sides); } /** @@ -515,6 +514,55 @@ void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape:: } } +Geom::Affine SPStar::set_transform(Geom::Affine const &xform) +{ + // Only set transform with proportional scaling + if (!xform.withoutTranslation().isUniformScale()) { + return xform; + } + + /* Calculate star start in parent coords. */ + Geom::Point pos( this->center * 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->r[0] *= s; + this->r[1] *= s; + + /* Find start in item coords */ + pos = pos * ret.inverse(); + this->center = pos; + + 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; +} + /** * sp_star_get_xy: Get X-Y value as item coordinate system * @star: star item |
