]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Use element transform when doing pick check 54/4254/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 20 May 2020 13:47:51 +0000 (16:47 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 20 May 2020 13:47:51 +0000 (16:47 +0300)
gitlab #537

Change-Id: I5fc0d21ce99daca3aa0db210f86382db74fba155

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;
         }