X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fdiagram%2Fhandler%2Fimpl%2FPickContextImpl.java;h=6a77af9b80e0cb0463abe78f5d8e0962f9b66c2a;hp=a891d62b70a360f7e750097f57cc2e0b26368ef5;hb=ceff53434e48f94c5d84ce12f3b1e21cabda457b;hpb=48135dcd03588783f9c1b688aaa53cdaacba6ef2 diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/impl/PickContextImpl.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/impl/PickContextImpl.java index a891d62b7..6a77af9b8 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/impl/PickContextImpl.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/impl/PickContextImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * Copyright (c) 2007, 2018 Association for Decentralized Information Management * in Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,7 @@ * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation + * Semantum Oy - gitlab #66 - parallel/spatial optimization *******************************************************************************/ package org.simantics.g2d.diagram.handler.impl; @@ -51,6 +52,8 @@ import org.slf4j.LoggerFactory; /** * @author Toni Kalajainen + * @author Jani Simomaa + * @author Tuukka Lehtonen */ public class PickContextImpl implements PickContext { @@ -62,6 +65,16 @@ public class PickContextImpl implements PickContext { private static final ThreadLocal perThreadElementBounds = ThreadLocal.withInitial(() -> new Rectangle2D.Double()); + private boolean useRTree; + + public PickContextImpl() { + this(false); + } + + public PickContextImpl(boolean useRTree) { + this.useRTree = useRTree; + } + @Override public void pick( IDiagram diagram, @@ -78,7 +91,7 @@ public class PickContextImpl implements PickContext { if (PERF) { long endTime = System.nanoTime(); - LOGGER.info("[picked " + result.size() + " elements @ " + request.pickArea + "] total pick time : " + ((endTime - startTime)*1e-6)); + LOGGER.info("[picked {} elements @ {}] total pick time {} ms", result.size(), request.pickArea, ((endTime - startTime)*1e-6)); } if (!result.isEmpty()) { @@ -171,11 +184,11 @@ public class PickContextImpl implements PickContext { return shape.getBounds2D(); } - private static List pickElements(IDiagram diagram, PickRequest request) { + private List pickElements(IDiagram diagram, PickRequest request) { ILayers layers = diagram.getHint(DiagramHints.KEY_LAYERS); // Get the scene graph nodes that intersect the pick-requests pick shape - INode spatialRoot = request.pickContext != null + INode spatialRoot = useRTree && request.pickContext != null ? request.pickContext.getSceneGraph().lookupNode(SceneGraphConstants.SPATIAL_ROOT_NODE_ID) : null;