From ab34f2a146e164816331582bf89385cfc9d09818 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Thu, 31 Oct 2019 15:52:35 +0200 Subject: [PATCH] Fixed two problems in connecting picking Tolerance was incorrectly subtracted instead of added in RouteLine picking. RouteGraphConnectionClass did not take selection stroke width into account when doing coarse picking based on bounding box. gitlab #396 Change-Id: I6dabe7297eb553f0894c4299c393bb5369b45866 --- .../src/org/simantics/diagram/connection/RouteLine.java | 4 ++-- .../g2d/elementclass/RouteGraphConnectionClass.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteLine.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteLine.java index 8a73ead7a..91a53d854 100644 --- a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteLine.java +++ b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteLine.java @@ -97,10 +97,10 @@ public class RouteLine implements RouteNode, Serializable { public boolean isNear(double x2, double y2, double tolerance) { return isHorizontal ? Math.abs(y2-position) <= tolerance - && points.get(0).x <= x2 - tolerance + && points.get(0).x - tolerance <= x2 && x2 <= points.get(points.size()-1).x + tolerance : Math.abs(x2-position) <= tolerance - && points.get(0).y <= y2 - tolerance + && points.get(0).y - tolerance <= y2 && y2 <= points.get(points.size()-1).y + tolerance; } diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/RouteGraphConnectionClass.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/RouteGraphConnectionClass.java index bf4577b51..5aa435920 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/RouteGraphConnectionClass.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/RouteGraphConnectionClass.java @@ -198,11 +198,11 @@ public class RouteGraphConnectionClass { @Override public Rectangle2D getBounds(IElement e, Rectangle2D size) { - RouteGraph rg = getRouteGraph(e); - if (rg != null) { + RouteGraphNode rgn = e.getHint(KEY_RG_NODE); + if (rgn != null) { if (size == null) size = new Rectangle2D.Double(); - rg.getBounds(size); + size.setRect(rgn.getBoundsInLocal()); } return size; } -- 2.43.2