From 2a93bc46600afb468a36d9743333724cf571ee85 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Wed, 16 Aug 2017 12:47:37 +0300 Subject: [PATCH] ElementPainter produces infinite bounds for transformed selections refs #7435 Change-Id: Iec1e107799b9f4137cf045b56dd8dd2f250aea3e --- .../simantics/g2d/diagram/participant/ElementPainter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java index ec6e8cba0..d35bfadb0 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java @@ -91,6 +91,7 @@ import org.simantics.scenegraph.g2d.nodes.SingleElementNode; import org.simantics.scenegraph.g2d.nodes.UnboundedNode; import org.simantics.scenegraph.g2d.nodes.spatial.RTreeNode; import org.simantics.scenegraph.utils.ColorUtil; +import org.simantics.scenegraph.utils.GeometryUtils; import org.simantics.scenegraph.utils.NodeUtil; import org.simantics.utils.datastructures.collections.CollectionUtils; import org.simantics.utils.datastructures.hints.HintListenerAdapter; @@ -1014,8 +1015,11 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos Shape shape = ElementUtils.getElementShapeOrBounds(e); Rectangle2D bounds = shape.getBounds2D(); //System.out.println("selection bounds: "+bounds); - final double marginX = 1 / selectionTransform.getScaleX(); - final double marginY = 1 / selectionTransform.getScaleY(); + + Point2D scale = GeometryUtils.getScale2D(selectionTransform); + final double marginX = Math.abs(scale.getX()) > 1e-10 ? 1 / scale.getX() : 1; + final double marginY = Math.abs(scale.getY()) > 1e-10 ? 1 / scale.getY() : 1; + bounds.setFrame(bounds.getMinX() - marginX, bounds.getMinY() - marginY, bounds.getWidth() + 2*marginX, bounds.getHeight() + 2*marginY); List ss = e.getElementClass().getItemsByClass(SelectionSpecification.class); -- 2.47.1