diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-07-27 14:40:29 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-07-27 14:40:29 +0000 |
| commit | 63203fb881bfce667a14b2bbb3ec2ee40a9adf77 (patch) | |
| tree | 86f322f2330dd9bd2f6719ffd7fd828bc67e4356 /src/object | |
| parent | Crashfix for connectors avoid selected items (diff) | |
| download | inkscape-63203fb881bfce667a14b2bbb3ec2ee40a9adf77.tar.gz inkscape-63203fb881bfce667a14b2bbb3ec2ee40a9adf77.zip | |
Make doc2dt a document property
Closes #340
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/box3d.cpp | 5 | ||||
| -rw-r--r-- | src/object/persp3d.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-guide.cpp | 10 | ||||
| -rw-r--r-- | src/object/sp-item.cpp | 22 |
4 files changed, 18 insertions, 23 deletions
diff --git a/src/object/box3d.cpp b/src/object/box3d.cpp index 483e5e7ae..f4b1665e5 100644 --- a/src/object/box3d.cpp +++ b/src/object/box3d.cpp @@ -649,7 +649,10 @@ box3d_XY_axes_are_swapped (SPBox3D *box) { static inline void box3d_aux_set_z_orders (int z_orders[6], int a, int b, int c, int d, int e, int f) { - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + // TODO add function argument: SPDocument *doc = box->document + auto doc = SP_ACTIVE_DOCUMENT; + + if (doc->is_yaxisdown()) { std::swap(a, f); std::swap(b, e); std::swap(c, d); diff --git a/src/object/persp3d.cpp b/src/object/persp3d.cpp index 3646f2df1..f772b2649 100644 --- a/src/object/persp3d.cpp +++ b/src/object/persp3d.cpp @@ -96,7 +96,7 @@ static Proj::Pt2 legacy_transform_forward(Proj::Pt2 pt, SPDocument const *doc) { } // <inkscape:perspective> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (doc->is_yaxisdown()) { pt[1] *= -1; if (pt[2]) { pt[1] += doc->getHeight().value("px"); @@ -111,7 +111,7 @@ static Proj::Pt2 legacy_transform_forward(Proj::Pt2 pt, SPDocument const *doc) { */ static Proj::Pt2 legacy_transform_backward(Proj::Pt2 pt, SPDocument const *doc) { // <inkscape:perspective> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (doc->is_yaxisdown()) { pt[1] *= -1; if (pt[2]) { pt[1] += doc->getHeight().value("px"); diff --git a/src/object/sp-guide.cpp b/src/object/sp-guide.cpp index 853511d42..6230e10eb 100644 --- a/src/object/sp-guide.cpp +++ b/src/object/sp-guide.cpp @@ -130,7 +130,7 @@ void SPGuide::set(SPAttributeEnum key, const gchar *value) { Geom::Point direction(newx, newy); // <sodipodi:guide> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (document->is_yaxisdown()) { direction[Geom::Y] *= -1.0; } @@ -181,7 +181,7 @@ void SPGuide::set(SPAttributeEnum key, const gchar *value) { } // <sodipodi:guide> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (document->is_yaxisdown()) { this->point_on_line[Geom::Y] = document->getHeight().value("px") - this->point_on_line[Geom::Y]; } } else { @@ -215,7 +215,7 @@ SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::P SPRoot *root = doc->getRoot(); // <sodipodi:guide> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (doc->is_yaxisdown()) { newy = doc->getHeight().value("px") - newy; n[Geom::Y] *= -1.0; } @@ -388,7 +388,7 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) double newy = point_on_line.y(); // <sodipodi:guide> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (document->is_yaxisdown()) { newy = document->getHeight().value("px") - newy; } @@ -441,7 +441,7 @@ void SPGuide::set_normal(Geom::Point const normal_to_line, bool const commit) auto normal = normal_to_line; // <sodipodi:guide> stores inverted y-axis coordinates - if (!SP_ACTIVE_DESKTOP || SP_ACTIVE_DESKTOP->is_yaxisdown()) { + if (document->is_yaxisdown()) { normal[Geom::Y] *= -1.0; } diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index 98ce76f2e..dfc482267 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -502,9 +502,7 @@ void SPItem::set(SPAttributeEnum key, gchar const* value) { case SP_ATTR_TRANSFORM_CENTER_Y: if (value) { item->transform_center_y = g_strtod(value, nullptr); - if (SP_ACTIVE_DESKTOP) { - item->transform_center_y *= -SP_ACTIVE_DESKTOP->yaxisdir(); - } + item->transform_center_y *= -document->yaxisdir(); } else { item->transform_center_y = 0; } @@ -745,9 +743,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X repr->setAttribute ("inkscape:transform-center-x", nullptr); if (item->transform_center_y != 0) { auto y = item->transform_center_y; - if (SP_ACTIVE_DESKTOP) { - y *= -SP_ACTIVE_DESKTOP->yaxisdir(); - } + y *= -document->yaxisdir(); sp_repr_set_svg_double (repr, "inkscape:transform-center-y", y); } else repr->setAttribute ("inkscape:transform-center-y", nullptr); @@ -918,8 +914,8 @@ Geom::OptRect SPItem::desktopGeometricBounds() const Geom::OptRect SPItem::desktopVisualBounds() const { Geom::OptRect ret = documentVisualBounds(); - if (ret && SP_ACTIVE_DESKTOP) { - *ret *= SP_ACTIVE_DESKTOP->doc2dt(); + if (ret) { + *ret *= document->doc2dt(); } return ret; } @@ -1590,10 +1586,7 @@ Geom::Affine SPItem::i2doc_affine() const Geom::Affine SPItem::i2dt_affine() const { Geom::Affine ret(i2doc_affine()); - SPDesktop const *desktop = SP_ACTIVE_DESKTOP; - if ( desktop ) { - ret *= desktop->doc2dt(); - } + ret *= document->doc2dt(); return ret; } @@ -1603,9 +1596,8 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) Geom::Affine dt2p; /* desktop to item parent transform */ if (parent) { dt2p = static_cast<SPItem *>(parent)->i2dt_affine().inverse(); - } else if (SP_ACTIVE_DESKTOP) { - SPDesktop *dt = SP_ACTIVE_DESKTOP; - dt2p = dt->dt2doc(); + } else { + dt2p = document->dt2doc(); } Geom::Affine const i2p( i2dt * dt2p ); |
