From: Marko Luukkainen Date: Wed, 20 May 2020 13:47:51 +0000 (+0300) Subject: Use element transform when doing pick check X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F4245%2F1;p=simantics%2Fplatform.git Use element transform when doing pick check gitlab #537 Change-Id: I5fc0d21ce99daca3aa0db210f86382db74fba155 (cherry picked from commit 995f91f4eb4feac37fbee766fb2b16f8d919c5e3) --- 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; }