From: Hannu Niemistö Date: Wed, 16 Aug 2017 12:04:13 +0000 (+0300) Subject: Merge "(refs #7433) Fixed a bug in Left.equals" X-Git-Tag: v1.31.0~236 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=9c4f7c59dc673c6af8d3ac1d92566ff132d43826;hp=b3dad17f21c1ec92aadb72dce69830cad25e9af6 Merge "(refs #7433) Fixed a bug in Left.equals" --- 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); diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java index 5f375095f..dd09f9ebf 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@ -632,15 +632,20 @@ public class SCLScenegraph { double trX = -1 * content.getX(); double trY = -1 * content.getY(); - result.append(MAIN_SECTION, ""); - - result.append(SELECTION_SECTION, ""); + // NaNs + if(!Double.isFinite(trX)) trX = 0; + if(!Double.isFinite(trY)) trY = 0; + result.append(MAIN_SECTION, ""); + result.append(SELECTION_SECTION, ""); result.append(SELECTION_MASK_SECTION, ""); + + result.append(ALL_SECTIONS, ""); + KeyVisitor keyVisitor = new KeyVisitor(); sg.accept(keyVisitor); @@ -658,9 +663,7 @@ public class SCLScenegraph { } - result.append(SELECTION_SECTION, ""); - result.append(SELECTION_MASK_SECTION, ""); - result.append(MAIN_SECTION, ""); + result.append(ALL_SECTIONS, ""); StringBuilder res = new StringBuilder(); res.append(""); @@ -785,10 +788,13 @@ public class SCLScenegraph { parentBuilder2.append(SELECTION_SECTION, "\n"); parentBuilder2.append(SELECTION_MASK_SECTION, "\n"); Rectangle2D rect = n.getRect(); - parentBuilder2.append(SELECTION_MASK_SECTION,""); + // NaN + if(rect.getHeight() == rect.getHeight() && rect.getWidth() == rect.getWidth()) { + parentBuilder2.append(SELECTION_MASK_SECTION,""); + } parentBuilder2.append(SELECTION_MASK_SECTION,"\n"); } } else if (node instanceof SVGNode) {