Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = this; while ( parent_text && !SP_IS_TEXT(parent_text) ) { parent_text = parent_text->parent; } if (parent_text == NULL) { return bbox; } // get the bbox of our portion of the layout bbox = SP_TEXT(parent_text)->layout.bounds(transform, sp_text_get_length_upto(parent_text, this), sp_text_get_length_upto(this, NULL) - 1); // Add stroke width // FIXME this code is incorrect if (bbox && type == SPItem::VISUAL_BBOX && !this->style->stroke.isNone()) { double scale = transform.descrim(); bbox->expandBy(0.5 * this->style->stroke_width.computed * scale); } return bbox; }
Geom::OptRect SPFlowtext::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox = this->layout.bounds(transform); // Add stroke width // FIXME this code is incorrect if (bbox && type == SPItem::VISUAL_BBOX && !this->style->stroke.isNone()) { double scale = transform.descrim(); bbox->expandBy(0.5 * this->style->stroke_width.computed * scale); } return bbox; }
Geom::Affine SPLine::set_transform(Geom::Affine const &transform) { Geom::Point points[2]; points[0] = Geom::Point(this->x1.computed, this->y1.computed); points[1] = Geom::Point(this->x2.computed, this->y2.computed); points[0] *= transform; points[1] *= transform; this->x1.computed = points[0][Geom::X]; this->y1.computed = points[0][Geom::Y]; this->x2.computed = points[1][Geom::X]; this->y2.computed = points[1][Geom::Y]; this->adjust_stroke(transform.descrim()); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); return Geom::identity(); }
/** * Writes the given transform into the repr for the given item. */ static Geom::Affine sp_path_set_transform(SPItem *item, Geom::Affine const &xform) { if (!SP_IS_PATH(item)) { return Geom::identity(); } SPPath *path = SP_PATH(item); if (!path->_curve) { // 0 nodes, nothing to transform return Geom::identity(); } // Transform the original-d path if this is a valid LPE item, other else the (ordinary) path if (path->_curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(item))) { if (sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(item), Inkscape::LivePathEffect::CLONE_ORIGINAL)) { // if path has the CLONE_ORIGINAL LPE applied, don't write the transform to the pathdata, but write it 'unoptimized' return xform; } else { path->_curve_before_lpe->transform(xform); } } else { path->_curve->transform(xform); } // Adjust stroke item->adjust_stroke(xform.descrim()); // Adjust pattern fill item->adjust_pattern(xform); // Adjust gradient fill item->adjust_gradient(xform); // Adjust LPE item->adjust_livepatheffect(xform); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); // nothing remains - we've written all of the transform, so return identity return Geom::identity(); }
Geom::Affine SPLine::setTransform(SPItem *item, Geom::Affine const &xform) { SPLine *line = SP_LINE(item); Geom::Point points[2]; points[0] = Geom::Point(line->x1.computed, line->y1.computed); points[1] = Geom::Point(line->x2.computed, line->y2.computed); points[0] *= xform; points[1] *= xform; line->x1.computed = points[0][Geom::X]; line->y1.computed = points[0][Geom::Y]; line->x2.computed = points[1][Geom::X]; line->y2.computed = points[1][Geom::Y]; item->adjust_stroke(xform.descrim()); SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); return Geom::identity(); }
Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) { if ((this->_optimizeScaledText && !xform.withoutTranslation().isNonzeroUniformScale()) || (!this->_optimizeScaledText && !xform.isNonzeroUniformScale())) { this->_optimizeScaledText = false; return xform; } this->_optimizeScaledText = false; SPText *text = reinterpret_cast<SPText *>(this); double const ex = xform.descrim(); if (ex == 0) { return xform; } Geom::Affine ret(xform); ret[0] /= ex; ret[1] /= ex; ret[2] /= ex; ret[3] /= ex; // Adjust font size text->_adjustFontsizeRecursive (this, ex); // Adjust stroke width this->adjust_stroke_width_recursive (ex); // 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_TEXT_LAYOUT_MODIFIED_FLAG); return ret; }