/*******************************************************************************
- * 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
*
* 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;
/**
* @author Toni Kalajainen
+ * @author Jani Simomaa
+ * @author Tuukka Lehtonen
*/
public class PickContextImpl implements PickContext {
private static final ThreadLocal<Rectangle2D> 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,
return shape.getBounds2D();
}
- private static List<IElement> pickElements(IDiagram diagram, PickRequest request) {
+ private List<IElement> 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;