diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-12-07 20:47:44 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-12-07 20:47:44 +0000 |
| commit | 075a88fc7edbec8682bcd672de325ec1bedf129f (patch) | |
| tree | 33d64f8ddc366a96e2c480b672224d44fc0e6355 /src/sp-ellipse.cpp | |
| parent | Update to trunk (diff) | |
| parent | Fix bug 1733422 - Bezier and pencil tool don't work form: from clipboard (diff) | |
| download | inkscape-075a88fc7edbec8682bcd672de325ec1bedf129f.tar.gz inkscape-075a88fc7edbec8682bcd672de325ec1bedf129f.zip | |
Mege trunk into powerpencilII
Diffstat (limited to 'src/sp-ellipse.cpp')
| -rw-r--r-- | src/sp-ellipse.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 166237c8e..c32e3012c 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -721,6 +721,65 @@ bool SPGenericEllipse::_isSlice() const return !(Geom::are_near(a.extent(), 0) || Geom::are_near(a.extent(), SP_2PI)); } +/** +Returns the ratio in which the vector from p0 to p1 is stretched by transform + */ +gdouble SPGenericEllipse::vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform) { + if (p0 == p1) { + return 0; + } + + return (Geom::distance(p0 * xform, p1 * xform) / Geom::distance(p0, p1)); +} + +void SPGenericEllipse::setVisibleRx(gdouble rx) { + if (rx == 0) { + this->rx.unset(); + } else { + this->rx = rx / SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed + 1, this->cy.computed), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); + } + + this->updateRepr(); +} + +void SPGenericEllipse::setVisibleRy(gdouble ry) { + if (ry == 0) { + this->ry.unset(); + } else { + this->ry = ry / SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed, this->cy.computed + 1), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); + } + + this->updateRepr(); +} + +gdouble SPGenericEllipse::getVisibleRx() const { + if (!this->rx._set) { + return 0; + } + + return this->rx.computed * SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed + 1, this->cy.computed), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); +} + +gdouble SPGenericEllipse::getVisibleRy() const { + if (!this->ry._set) { + return 0; + } + + return this->ry.computed * SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed, this->cy.computed + 1), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); +} + /* Local Variables: mode:c++ |
