]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ShapePick.java
Use element transform when doing pick check
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / ShapePick.java
index a1d31acf0e03f9990ef11583fa8c1f4409eeb1b9..3766a751b6816dbc6a4d12be5f59a4fcd7160bb7 100644 (file)
@@ -39,6 +39,8 @@ public class ShapePick implements Pick {
             pickRect = s.getBounds2D();
 
         Shape es = ElementUtils.getElementShapeOrBounds(e);
+        // getElementShapeOrBounds returns shape or bounds in local coords!
+        es = ElementUtils.getTransform(e).createTransformedShape(es);
         PathIterator iter = es.getPathIterator(null);
         Collection<double[]> segments = new ArrayList<double[]>();
         PathUtils.toLineSegments(iter, segments);
@@ -55,7 +57,12 @@ public class ShapePick implements Pick {
                 for (double[] seg : segments) {
                     if (pickRect.intersectsLine(seg[0], seg[1], seg[2], seg[3]))
                         return true;
+                    if (pickRect.contains(seg[0], seg[1]))
+                       return true;
+                    if (pickRect.contains(seg[2], seg[3]))
+                       return true;
                 }
+                
                 return false;
         }