From: Marko Luukkainen Date: Wed, 20 May 2020 13:47:51 +0000 (+0300) Subject: Use element transform when doing pick check X-Git-Tag: v1.43.0~25 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F54%2F4254%2F1;p=simantics%2Fplatform.git Use element transform when doing pick check gitlab #537 Change-Id: I5fc0d21ce99daca3aa0db210f86382db74fba155 --- diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ShapePick.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ShapePick.java index a1d31acf0..3766a751b 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ShapePick.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ShapePick.java @@ -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 segments = new ArrayList(); 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; }