diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-07-25 01:06:47 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-07-25 01:06:47 +0000 |
| commit | 4f3cc7cbb73a72e1ab10a587a3b81f8c8737fec3 (patch) | |
| tree | 75853d8eec5e85fb93a2a798b57f072e3c9eeb99 /src/sp-item.cpp | |
| parent | Replace direct use of Cairo contexts and surfaces in the rendering tree (diff) | |
| parent | Revert workarounds from 10501 - no longer necessary (diff) | |
| download | inkscape-4f3cc7cbb73a72e1ab10a587a3b81f8c8737fec3.tar.gz inkscape-4f3cc7cbb73a72e1ab10a587a3b81f8c8737fec3.zip | |
Merge from trunk
(bzr r10347.1.18)
Diffstat (limited to 'src/sp-item.cpp')
| -rw-r--r-- | src/sp-item.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 8e1a4d92c..946c94353 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -272,7 +272,7 @@ void SPItem::setCenter(Geom::Point object_centre) { // for getBounds() to work document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(i2d_affine()); + Geom::OptRect bbox = getBounds(i2dt_affine()); if (bbox) { transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; if (fabs(transform_center_x) < 1e-5) // rounding error @@ -297,7 +297,7 @@ Geom::Point SPItem::getCenter() const { // for getBounds() to work document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(i2d_affine()); + Geom::OptRect bbox = getBounds(i2dt_affine()); if (bbox) { return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y); } else { @@ -638,19 +638,19 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPObject *child; SPItem *item = SP_ITEM(object); // in the case of SP_OBJECT_WRITE_BUILD, the item should always be newly created, // so we need to add any children from the underlying object to the new repr if (flags & SP_OBJECT_WRITE_BUILD) { - Inkscape::XML::Node *crepr; - GSList *l; - l = NULL; - for (child = object->firstChild(); child != NULL; child = child->next ) { - if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; - crepr = child->updateRepr(xml_doc, NULL, flags); - if (crepr) l = g_slist_prepend (l, crepr); + GSList *l = NULL; + for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + if (crepr) { + l = g_slist_prepend (l, crepr); + } + } } while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@ -658,9 +658,10 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML l = g_slist_remove (l, l->data); } } else { - for (child = object->firstChild() ; child != NULL; child = child->next ) { - if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; - child->updateRepr(flags); + for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + child->updateRepr(flags); + } } } @@ -789,11 +790,11 @@ void SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transfor } // transform the expansions by the item's transform: - Geom::Affine i2d(i2d_affine ()); - dx0 *= i2d.expansionX(); - dx1 *= i2d.expansionX(); - dy0 *= i2d.expansionY(); - dy1 *= i2d.expansionY(); + Geom::Affine i2dt(i2dt_affine ()); + dx0 *= i2dt.expansionX(); + dx1 *= i2dt.expansionX(); + dy0 *= i2dt.expansionY(); + dy1 *= i2dt.expansionY(); // expand the bbox temp_bbox.x0 += dx0; @@ -889,13 +890,13 @@ void SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) { g_assert(bbox != NULL); - invoke_bbox( bbox, i2d_affine(), TRUE, type); + invoke_bbox( bbox, i2dt_affine(), TRUE, type); } Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) { Geom::OptRect rect = Geom::OptRect(); - invoke_bbox( rect, i2d_affine(), TRUE, type); + invoke_bbox( rect, i2dt_affine(), TRUE, type); return rect; } @@ -906,7 +907,7 @@ void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape * We don't know what shape we could be dealing with here, so we'll just * return the corners of the bounding box */ - Geom::OptRect bbox = item->getBounds(item->i2d_affine()); + Geom::OptRect bbox = item->getBounds(item->i2dt_affine()); if (bbox) { Geom::Point p1, p2; @@ -952,7 +953,7 @@ void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscap for (std::vector<Inkscape::SnapCandidatePoint>::const_iterator p_orig = p_clip_or_mask.begin(); p_orig != p_clip_or_mask.end(); p_orig++) { // All snappoints are in desktop coordinates, but the item's transformation is // in document coordinates. Hence the awkward construction below - Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * i2d_affine(); + Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * i2dt_affine(); p.push_back(Inkscape::SnapCandidatePoint(pt, (*p_orig).getSourceType(), (*p_orig).getTargetType())); } } @@ -1464,11 +1465,13 @@ Geom::Affine SPItem::i2doc_affine() const /** * Returns the transformation from item to desktop coords */ -Geom::Affine SPItem::i2d_affine() const +Geom::Affine SPItem::i2dt_affine() const { - Geom::Affine const ret( i2doc_affine() - * Geom::Scale(1, -1) - * Geom::Translate(0, document->getHeight()) ); +// Geom::Affine const ret( i2doc_affine() +// * Geom::Scale(1, -1) +// * Geom::Translate(0, document->getHeight()) ); + SPDesktop const *desktop = inkscape_active_desktop(); + Geom::Affine const ret( i2doc_affine() * desktop->doc2dt() ); return ret; } @@ -1476,10 +1479,10 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) { Geom::Affine dt2p; /* desktop to item parent transform */ if (parent) { - dt2p = static_cast<SPItem *>(parent)->i2d_affine().inverse(); + dt2p = static_cast<SPItem *>(parent)->i2dt_affine().inverse(); } else { - dt2p = ( Geom::Translate(0, -document->getHeight()) - * Geom::Scale(1, -1) ); + SPDesktop *dt = inkscape_active_desktop(); + dt2p = dt->dt2doc(); } Geom::Affine const i2p( i2dt * dt2p ); @@ -1493,7 +1496,7 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) Geom::Affine SPItem::dt2i_affine() const { /* fixme: Implement the right way (Lauris) */ - return i2d_affine().inverse(); + return i2dt_affine().inverse(); } /* Item views */ @@ -1571,9 +1574,6 @@ SPItem *sp_item_first_item_child(SPObject *obj) } void SPItem::convert_to_guides() { - SPDesktop *dt = inkscape_active_desktop(); - sp_desktop_namedview(dt); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); SPItem::BBoxType bbox_type = (prefs_bbox ==0)? @@ -1597,7 +1597,7 @@ void SPItem::convert_to_guides() { pts.push_back(std::make_pair(C, D)); pts.push_back(std::make_pair(D, A)); - sp_guide_pt_pairs_to_guides(dt, pts); + sp_guide_pt_pairs_to_guides(document, pts); } /* |
