Commit 4fa77f4b authored by Thomas Holder's avatar Thomas Holder Committed by Marc Jeanmougin

Fix "Object to Marker" coordinate/viewport offset

Move coordinates and refX/refY so that they are within the marker
viewport. SVG compliant renderers clip (overflow:hidden) markers at
their viewport rect (Inkscape doesn't do that, but web browsers do).

Regression of 1fa0c72b

Fixes #1376

(cherry-picked from 90b2bca7)
parent 1ce55def
Pipeline #184495618 passed with stages
in 115 minutes and 39 seconds
......@@ -2999,13 +2999,10 @@ void ObjectSet::toMarker(bool apply)
doc->ensureUpToDate();
Geom::OptRect r = visualBounds();
boost::optional<Geom::Point> c = center();
if ( !r || !c ) {
if (!r) {
return;
}
Geom::Point center = (*c) * doc->dt2doc();
std::vector<SPItem*> items_(items().begin(), items().end());
// bottommost object, after sorting
......@@ -3030,6 +3027,11 @@ void ObjectSet::toMarker(bool apply)
Geom::Rect bbox(r->min() * doc->dt2doc(), r->max() * doc->dt2doc());
// calculate the transform to be applied to objects to move them to 0,0
// (alternative would be to define viewBox or set overflow:visible)
Geom::Affine const move = Geom::Translate(-bbox.min());
Geom::Point const center = bbox.dimensions() * 0.5;
if (apply) {
// Delete objects so that their clones don't get alerted;
// the objects will be restored inside the marker element.
......@@ -3045,7 +3047,7 @@ void ObjectSet::toMarker(bool apply)
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *mark_id = generate_marker(repr_copies, bbox, doc, center, parent_transform);
gchar const *mark_id = generate_marker(repr_copies, bbox, doc, center, parent_transform * move);
(void)mark_id;
// restore compensation setting
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment