]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Adjustments to picking and camera orientation on focus command 06/2906/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 27 May 2019 07:54:40 +0000 (10:54 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 27 May 2019 07:54:40 +0000 (10:54 +0300)
gitlab #5

Change-Id: If199287d5ef83f5d1ad410c8175cc4af67b1e50a

org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkCameraAndSelectorAction.java
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/InteractiveVtkPanel.java

index f4bd2a07380e435c442aec42ac925becca080efb..b4a387bc5390a7a27014626f7c0671f3b4c80254 100644 (file)
@@ -384,6 +384,11 @@ public class vtkCameraAndSelectorAction extends vtkAction implements ISelectionP
                public void focus(double x, double y, double z) {
                        Lock();
                        cam.SetFocalPoint(x, y, z);
+                       if (doNotRotate)
+                       cam.SetRoll(0);
+               cam.OrthogonalizeViewUp();
+               resetCameraClippingRange();
+               panel.UpdateLight();
                        UnLock();
                }
                
index 1f0a968cbbea4584e0e8d1e518d3421f8b7f4939..e6129b5d537d6879a30391019d854666f565cdca 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g3d.vtk.common;\r
-\r
-import java.awt.event.KeyEvent;\r
-import java.awt.event.MouseEvent;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.simantics.g3d.scenegraph.RenderListener;\r
-import org.simantics.g3d.vtk.action.vtkAction;\r
-\r
-import vtk.vtkAbstractPicker;\r
-import vtk.vtkAreaPicker;\r
-import vtk.vtkAssemblyNode;\r
-import vtk.vtkAssemblyPath;\r
-import vtk.vtkCellPicker;\r
-import vtk.vtkGenericRenderWindowInteractor;\r
-import vtk.vtkInteractorStyleTrackballCamera;\r
-import vtk.vtkObjectBase;\r
-import vtk.vtkPanel;\r
-import vtk.vtkPointPicker;\r
-import vtk.vtkProp;\r
-import vtk.vtkProp3DCollection;\r
-import vtk.vtkPropCollection;\r
-import vtk.vtkPropPicker;\r
-import vtk.vtkScenePicker;\r
-\r
-public class InteractiveVtkPanel extends vtkPanel {\r
-       \r
-       protected vtkGenericRenderWindowInteractor iren;\r
-    \r
-\r
-       public vtkGenericRenderWindowInteractor getRenderWindowInteractor() {\r
-        return this.iren;\r
-    }\r
-       private static final long serialVersionUID = 2815073937537950615L;\r
-       \r
-       \r
-       public InteractiveVtkPanel() {\r
-               super();\r
-               iren = new vtkGenericRenderWindowInteractor();\r
-               iren.SetRenderWindow(rw);\r
-        iren.TimerEventResetsTimerOff();\r
-        iren.SetSize(200, 200);\r
-        iren.ConfigureEvent();\r
-        vtkInteractorStyleTrackballCamera style = new vtkInteractorStyleTrackballCamera();\r
-        iren.SetInteractorStyle(style);\r
-        addDeletable(style);\r
-        addDeletable(iren);\r
-       }\r
-       \r
-       @Override\r
-       public void mouseClicked(MouseEvent e) {\r
-\r
-       }\r
-       \r
-       @Override\r
-       public void mouseMoved(MouseEvent e) {\r
-\r
-       }\r
-       \r
-       @Override\r
-       public void mouseEntered(MouseEvent e) {\r
-               super.mouseEntered(e);\r
-       }\r
-       \r
-       @Override\r
-       public void mouseExited(MouseEvent e) {\r
-       \r
-       }\r
-       \r
-       @Override\r
-       public void mousePressed(MouseEvent e) {\r
-               \r
-       }\r
-       \r
-       @Override\r
-       public void mouseDragged(MouseEvent e) {\r
-               \r
-       }\r
-       \r
-       @Override\r
-       public void mouseReleased(MouseEvent e) {\r
-       \r
-       }\r
-       \r
-       @Override\r
-       public void keyPressed(KeyEvent e) {\r
-\r
-       }\r
-       \r
-       @Override\r
-       public void keyTyped(KeyEvent e) {\r
-               \r
-       }\r
-       \r
-       public void setSize(int x, int y) {\r
-        if (windowset == 1) {\r
-            Lock();\r
-            rw.SetSize(x, y);\r
-            iren.SetSize(x, y);\r
-            iren.ConfigureEvent();\r
-            UnLock();\r
-        }\r
-    }\r
-\r
-       private vtkScenePicker scenePicker;\r
-       \r
-       int pickType = 4;\r
-       \r
-       public int getPickType() {\r
-               return pickType;\r
-       }\r
-       \r
-       public void setPickType(int pickType) {\r
-               this.pickType = pickType;\r
-       }\r
-       \r
-       public vtkProp[] pick(int x, int y) {\r
-               \r
-               \r
-//             vtkPicker picker = new vtkPicker();\r
-//             vtkAbstractPicker picker = new vtkAbstractPicker();\r
-//             picker.Pick(x, rw.GetSize()[1] - y, ren);\r
-//             // see page 60 of VTK user's guide\r
-//\r
-               if (pickType == 0) {\r
-       \r
-                       vtkPropPicker picker = new vtkPropPicker();\r
-                       Lock();\r
-                       picker.PickProp(x, rw.GetSize()[1] - y, ren);\r
-       \r
-                       UnLock();\r
-       \r
-                       vtkAssemblyPath apath = picker.GetPath();\r
-                       return processPick(picker, apath);\r
-                       \r
-               } else if (pickType == 1) {\r
-                       if (scenePicker == null) {\r
-                               scenePicker = new vtkScenePicker();\r
-                               scenePicker.SetRenderer(ren);\r
-                               scenePicker.EnableVertexPickingOn();\r
-                               \r
-                       }\r
-                       Lock();\r
-\r
-                       vtkAssemblyPath apath = ren.PickProp(x, rw.GetSize()[1] - y);\r
-                       //int vertexId = scenePicker.GetVertexId(new int[]{x, rw.GetSize()[1] - y});\r
-                       \r
-                       UnLock();\r
-                       \r
-                       if (apath != null) {\r
-                               apath.InitTraversal();\r
-//                             System.out.println("Pick, actors " + apath.GetNumberOfItems() );\r
-//                             for (int i = 0; i < apath.GetNumberOfItems(); i++) {\r
-//                                     vtkAssemblyNode node = apath.GetNextNode();\r
-//                                     vtkProp test = (vtkProp) node.GetViewProp();\r
-//                                     System.out.println(test.GetClassName());\r
-//                             }\r
-                               \r
-                               vtkAssemblyNode node = apath.GetLastNode();\r
-                               vtkProp test = (vtkProp) node.GetViewProp();\r
-                               apath.Delete();\r
-                               node.Delete();\r
-                               return new vtkProp[]{test};\r
-       \r
-                       }\r
-                       \r
-               } else if (pickType == 2) {\r
-                       vtkPointPicker picker = new vtkPointPicker();\r
-                       picker.SetTolerance(2.0/(double)rw.GetSize()[0]);\r
-                       Lock();\r
-                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);\r
-                       UnLock();\r
-                       \r
-                       vtkAssemblyPath apath = picker.GetPath();\r
-                       return processPick(picker, apath);\r
-               } else if (pickType == 3) {\r
-                       vtkAreaPicker picker = new vtkAreaPicker();\r
-                       Lock();\r
-                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);\r
-                       //picker.AreaPick(x-1, rw.GetSize()[1] - y-1,x+1,rw.GetSize()[1] - y+1, ren);\r
-                       UnLock();\r
-                       vtkAssemblyPath apath = picker.GetPath();\r
-                       return processPick(picker, apath);\r
-               } else if (pickType == 4) {\r
-                       vtkCellPicker picker = new vtkCellPicker();\r
-                       picker.SetTolerance(2.0/(double)rw.GetSize()[0]);\r
-                       Lock();\r
-                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);\r
-                       UnLock();       \r
-                       vtkAssemblyPath apath = picker.GetPath();\r
-                       return processPick(picker, apath);\r
-               }\r
-\r
-               return null;\r
-       }\r
-       \r
-       public vtkProp[] pick2(int x, int y) {\r
-               \r
-               \r
-//             vtkPicker picker = new vtkPicker();\r
-//             vtkAbstractPicker picker = new vtkAbstractPicker();\r
-//             picker.Pick(x, rw.GetSize()[1] - y, ren);\r
-//             // see page 60 of VTK user's guide\r
-//\r
-               if (pickType == 0) {\r
-       \r
-                       vtkPropPicker picker = new vtkPropPicker();\r
-                       Lock();\r
-                       picker.PickProp(x, rw.GetSize()[1] - y, ren);\r
-       \r
-                       UnLock();\r
-                       vtkPropCollection coll = picker.GetPickList();\r
-                       return processPick(picker, coll);\r
-                       \r
-               } else if (pickType == 1) {\r
-                       if (scenePicker == null) {\r
-                               scenePicker = new vtkScenePicker();\r
-                               scenePicker.SetRenderer(ren);\r
-                               scenePicker.EnableVertexPickingOn();\r
-                               \r
-                       }\r
-                       Lock();\r
-\r
-                       \r
-                       vtkAssemblyPath apath = ren.PickProp(x, rw.GetSize()[1] - y);\r
-                       \r
-                       UnLock();\r
-                       \r
-                       if (apath != null) {\r
-                               apath.InitTraversal();\r
-\r
-                               \r
-                               vtkAssemblyNode node = apath.GetLastNode();\r
-                               vtkProp test = (vtkProp) node.GetViewProp();\r
-                               apath.Delete();\r
-                               node.Delete();\r
-                               return new vtkProp[]{test};\r
-       \r
-                       }\r
-                       \r
-               } else if (pickType == 2) {\r
-                       vtkPointPicker picker = new vtkPointPicker();\r
-                       picker.SetTolerance(2.0/(double)rw.GetSize()[0]);\r
-                       Lock();\r
-                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);\r
-                       UnLock();\r
-                       vtkProp3DCollection coll = picker.GetProp3Ds();\r
-                       return processPick(picker, coll);\r
-               } else if (pickType == 3) {\r
-                       vtkAreaPicker picker = new vtkAreaPicker();\r
-                       Lock();\r
-                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);\r
-                       //picker.AreaPick(x-1, rw.GetSize()[1] - y-1,x+1,rw.GetSize()[1] - y+1, ren);\r
-                       UnLock();\r
-                       vtkProp3DCollection coll = picker.GetProp3Ds();\r
-                       return processPick(picker, coll);\r
-               } else if (pickType == 4) {\r
-                       vtkCellPicker picker = new vtkCellPicker();\r
-                       picker.SetTolerance(2.0/(double)rw.GetSize()[0]);\r
-                       Lock();\r
-                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);\r
-                       UnLock();       \r
-                       vtkProp3DCollection coll = picker.GetProp3Ds();\r
-                       return processPick(picker, coll);\r
-               }\r
-\r
-               return null;\r
-       }\r
-       \r
-       private vtkProp[] processPick(vtkAbstractPicker picker, vtkAssemblyPath apath) {\r
-//             double[] pickPos = picker.GetPickPosition();\r
-               picker.Delete();\r
-               if (apath != null) {\r
-                       apath.InitTraversal();\r
-                       vtkProp result[] = new vtkProp[apath.GetNumberOfItems()];\r
-                       for (int i = apath.GetNumberOfItems()-1; i >= 0; i--) {\r
-                               vtkAssemblyNode node = apath.GetNextNode();\r
-                               vtkProp test = (vtkProp) node.GetViewProp();\r
-//                             System.out.println("Picked: " + test.GetClassName() + " " + test.GetVTKId());\r
-                               result[i] = test;\r
-                               node.Delete();\r
-                       }\r
-                       apath.Delete();\r
-                       return result;\r
-\r
-               }\r
-               return null;\r
-       }\r
-       \r
-       private vtkProp[] processPick(vtkAbstractPicker picker, vtkPropCollection coll) {\r
-//             double[] pickPos = picker.GetPickPosition();\r
-               picker.Delete();\r
-               if (coll != null) {\r
-                       coll.InitTraversal();\r
-                       vtkProp result[] = new vtkProp[coll.GetNumberOfItems()];\r
-                       for (int i = coll.GetNumberOfItems()-1; i >= 0; i--) {\r
-                               vtkProp test = coll.GetNextProp();\r
-                               \r
-//                             System.out.println("Picked: " + test.GetClassName() + " " + test.GetVTKId());\r
-                               result[i] = test;\r
-                               \r
-                       }\r
-                       coll.Delete();\r
-                       return result;\r
-\r
-               }\r
-               return null;\r
-       }\r
-       \r
-       \r
-       private vtkAction defaultAction;\r
-       private vtkAction currentAction;\r
-       \r
-       public void setActiveAction(vtkAction action) {\r
-               if (action.equals(currentAction))\r
-                       return;\r
-               if (currentAction != null)\r
-                       currentAction.deattach();\r
-               currentAction = action;\r
-               if (action != null)\r
-                       action.attach();\r
-       }\r
-       \r
-       public void setDefaultAction(vtkAction defaultAction) {\r
-               this.defaultAction = defaultAction;\r
-       }\r
-       \r
-       public void useDefaultAction() {\r
-               setActiveAction(defaultAction);\r
-       }\r
-       \r
-       public vtkAction getDefaultAction() {\r
-               return defaultAction;\r
-       }\r
-       \r
-       \r
-       @Override\r
-       public synchronized void Render() {\r
-               //System.out.println("Render " + rendering);\r
-               if (rendering)\r
-                       return;\r
-               \r
-               firePreRender();\r
-               super.Render();\r
-               firePostRender();\r
-       }\r
-       \r
-       \r
-       public void addListener(RenderListener l) {\r
-               listeners.add(l);\r
-       }\r
-       \r
-       public void removeListener(RenderListener l) {\r
-               listeners.remove(l);\r
-       }\r
-       \r
-       private List<RenderListener> listeners = new ArrayList<RenderListener>();\r
-       \r
-       List<RenderListener> list = new ArrayList<RenderListener>();\r
-       \r
-       private void firePreRender() {\r
-               if (listeners.size() > 0) {\r
-                       list.addAll(listeners);\r
-                       for (RenderListener l : list)\r
-                               l.preRender();\r
-                       list.clear();\r
-               }\r
-       }\r
-       \r
-       private void firePostRender() {\r
-               if (listeners.size() > 0) {\r
-                       list.addAll(listeners);\r
-                       for (RenderListener l : list)\r
-                               l.postRender();\r
-                       list.clear();\r
-               }\r
-       }\r
-\r
-       \r
-       private List<vtkObjectBase> deletable = new ArrayList<vtkObjectBase>();\r
-       \r
-       public void addDeletable(vtkObjectBase o) {\r
-               deletable.add(o);\r
-       }\r
-       \r
-       public void removeDeletable (vtkObjectBase o) {\r
-               deletable.remove(o);\r
-       }\r
-       \r
-       @Override\r
-       public void Delete() {\r
-               for (vtkObjectBase o : deletable) {\r
-                       if (o.GetVTKId() != 0) {\r
-                               o.Delete();\r
-                       }\r
-               }\r
-               deletable.clear();\r
-               \r
-               super.Delete();\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g3d.vtk.common;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.simantics.g3d.scenegraph.RenderListener;
+import org.simantics.g3d.vtk.action.vtkAction;
+
+import vtk.vtkAbstractPicker;
+import vtk.vtkAreaPicker;
+import vtk.vtkAssemblyNode;
+import vtk.vtkAssemblyPath;
+import vtk.vtkCellPicker;
+import vtk.vtkGenericRenderWindowInteractor;
+import vtk.vtkInteractorStyleTrackballCamera;
+import vtk.vtkObjectBase;
+import vtk.vtkPanel;
+import vtk.vtkPointPicker;
+import vtk.vtkProp;
+import vtk.vtkProp3DCollection;
+import vtk.vtkPropCollection;
+import vtk.vtkPropPicker;
+import vtk.vtkScenePicker;
+
+public class InteractiveVtkPanel extends vtkPanel {
+       
+       protected vtkGenericRenderWindowInteractor iren;
+    
+
+       public vtkGenericRenderWindowInteractor getRenderWindowInteractor() {
+        return this.iren;
+    }
+       private static final long serialVersionUID = 2815073937537950615L;
+       
+       
+       public InteractiveVtkPanel() {
+               super();
+               iren = new vtkGenericRenderWindowInteractor();
+               iren.SetRenderWindow(rw);
+        iren.TimerEventResetsTimerOff();
+        iren.SetSize(200, 200);
+        iren.ConfigureEvent();
+        vtkInteractorStyleTrackballCamera style = new vtkInteractorStyleTrackballCamera();
+        iren.SetInteractorStyle(style);
+        addDeletable(style);
+        addDeletable(iren);
+       }
+       
+       @Override
+       public void mouseClicked(MouseEvent e) {
+
+       }
+       
+       @Override
+       public void mouseMoved(MouseEvent e) {
+
+       }
+       
+       @Override
+       public void mouseEntered(MouseEvent e) {
+               super.mouseEntered(e);
+       }
+       
+       @Override
+       public void mouseExited(MouseEvent e) {
+       
+       }
+       
+       @Override
+       public void mousePressed(MouseEvent e) {
+               
+       }
+       
+       @Override
+       public void mouseDragged(MouseEvent e) {
+               
+       }
+       
+       @Override
+       public void mouseReleased(MouseEvent e) {
+       
+       }
+       
+       @Override
+       public void keyPressed(KeyEvent e) {
+
+       }
+       
+       @Override
+       public void keyTyped(KeyEvent e) {
+               
+       }
+       
+       public void setSize(int x, int y) {
+        if (windowset == 1) {
+            Lock();
+            rw.SetSize(x, y);
+            iren.SetSize(x, y);
+            iren.ConfigureEvent();
+            UnLock();
+        }
+    }
+
+       private vtkScenePicker scenePicker;
+       
+       int pickType = 4;
+       
+       public int getPickType() {
+               return pickType;
+       }
+       
+       public void setPickType(int pickType) {
+               this.pickType = pickType;
+       }
+       
+       public vtkProp[] pick(int x, int y) {
+               
+               
+//             vtkPicker picker = new vtkPicker();
+//             vtkAbstractPicker picker = new vtkAbstractPicker();
+//             picker.Pick(x, rw.GetSize()[1] - y, ren);
+//             // see page 60 of VTK user's guide
+//
+               if (pickType == 0) {
+       
+                       vtkPropPicker picker = new vtkPropPicker();
+                       Lock();
+                       picker.PickProp(x, rw.GetSize()[1] - y, ren);
+       
+                       UnLock();
+       
+                       vtkAssemblyPath apath = picker.GetPath();
+                       return processPick(picker, apath);
+                       
+               } else if (pickType == 1) {
+                       if (scenePicker == null) {
+                               scenePicker = new vtkScenePicker();
+                               scenePicker.SetRenderer(ren);
+                               scenePicker.EnableVertexPickingOn();
+                               
+                       }
+                       Lock();
+
+                       vtkAssemblyPath apath = ren.PickProp(x, rw.GetSize()[1] - y);
+                       //int vertexId = scenePicker.GetVertexId(new int[]{x, rw.GetSize()[1] - y});
+                       
+                       UnLock();
+                       
+                       if (apath != null) {
+                               apath.InitTraversal();
+//                             System.out.println("Pick, actors " + apath.GetNumberOfItems() );
+//                             for (int i = 0; i < apath.GetNumberOfItems(); i++) {
+//                                     vtkAssemblyNode node = apath.GetNextNode();
+//                                     vtkProp test = (vtkProp) node.GetViewProp();
+//                                     System.out.println(test.GetClassName());
+//                             }
+                               
+                               vtkAssemblyNode node = apath.GetLastNode();
+                               vtkProp test = (vtkProp) node.GetViewProp();
+                               apath.Delete();
+                               node.Delete();
+                               return new vtkProp[]{test};
+       
+                       }
+                       
+               } else if (pickType == 2) {
+                       vtkPointPicker picker = new vtkPointPicker();
+                       //picker.SetTolerance(2.0/(double)rw.GetSize()[0]);
+                       picker.SetTolerance(0.00001);
+                       Lock();
+                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);
+                       UnLock();
+                       
+                       vtkAssemblyPath apath = picker.GetPath();
+                       return processPick(picker, apath);
+               } else if (pickType == 3) {
+                       vtkAreaPicker picker = new vtkAreaPicker();
+                       Lock();
+                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);
+                       //picker.AreaPick(x-1, rw.GetSize()[1] - y-1,x+1,rw.GetSize()[1] - y+1, ren);
+                       UnLock();
+                       vtkAssemblyPath apath = picker.GetPath();
+                       return processPick(picker, apath);
+               } else if (pickType == 4) {
+                       vtkCellPicker picker = new vtkCellPicker();
+                       //picker.SetTolerance(2.0/(double)rw.GetSize()[0]);
+                       picker.SetTolerance(0.00001);
+                       Lock();
+                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);
+                       UnLock();       
+                       vtkAssemblyPath apath = picker.GetPath();
+                       return processPick(picker, apath);
+               }
+
+               return null;
+       }
+       
+       public vtkProp[] pick2(int x, int y) {
+               
+               
+//             vtkPicker picker = new vtkPicker();
+//             vtkAbstractPicker picker = new vtkAbstractPicker();
+//             picker.Pick(x, rw.GetSize()[1] - y, ren);
+//             // see page 60 of VTK user's guide
+//
+               if (pickType == 0) {
+       
+                       vtkPropPicker picker = new vtkPropPicker();
+                       Lock();
+                       picker.PickProp(x, rw.GetSize()[1] - y, ren);
+       
+                       UnLock();
+                       vtkPropCollection coll = picker.GetPickList();
+                       return processPick(picker, coll);
+                       
+               } else if (pickType == 1) {
+                       if (scenePicker == null) {
+                               scenePicker = new vtkScenePicker();
+                               scenePicker.SetRenderer(ren);
+                               scenePicker.EnableVertexPickingOn();
+                               
+                       }
+                       Lock();
+
+                       
+                       vtkAssemblyPath apath = ren.PickProp(x, rw.GetSize()[1] - y);
+                       
+                       UnLock();
+                       
+                       if (apath != null) {
+                               apath.InitTraversal();
+
+                               
+                               vtkAssemblyNode node = apath.GetLastNode();
+                               vtkProp test = (vtkProp) node.GetViewProp();
+                               apath.Delete();
+                               node.Delete();
+                               return new vtkProp[]{test};
+       
+                       }
+                       
+               } else if (pickType == 2) {
+                       vtkPointPicker picker = new vtkPointPicker();
+                       picker.SetTolerance(2.0/(double)rw.GetSize()[0]);
+                       Lock();
+                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);
+                       UnLock();
+                       vtkProp3DCollection coll = picker.GetProp3Ds();
+                       return processPick(picker, coll);
+               } else if (pickType == 3) {
+                       vtkAreaPicker picker = new vtkAreaPicker();
+                       Lock();
+                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);
+                       //picker.AreaPick(x-1, rw.GetSize()[1] - y-1,x+1,rw.GetSize()[1] - y+1, ren);
+                       UnLock();
+                       vtkProp3DCollection coll = picker.GetProp3Ds();
+                       return processPick(picker, coll);
+               } else if (pickType == 4) {
+                       vtkCellPicker picker = new vtkCellPicker();
+                       picker.SetTolerance(2.0/(double)rw.GetSize()[0]);
+                       Lock();
+                       picker.Pick(new double[]{x, rw.GetSize()[1] - y,0}, ren);
+                       UnLock();       
+                       vtkProp3DCollection coll = picker.GetProp3Ds();
+                       return processPick(picker, coll);
+               }
+
+               return null;
+       }
+       
+       private vtkProp[] processPick(vtkAbstractPicker picker, vtkAssemblyPath apath) {
+//             double[] pickPos = picker.GetPickPosition();
+               picker.Delete();
+               if (apath != null) {
+                       apath.InitTraversal();
+                       vtkProp result[] = new vtkProp[apath.GetNumberOfItems()];
+                       for (int i = apath.GetNumberOfItems()-1; i >= 0; i--) {
+                               vtkAssemblyNode node = apath.GetNextNode();
+                               vtkProp test = (vtkProp) node.GetViewProp();
+//                             System.out.println("Picked: " + test.GetClassName() + " " + test.GetVTKId());
+                               result[i] = test;
+                               node.Delete();
+                       }
+                       apath.Delete();
+                       return result;
+
+               }
+               return null;
+       }
+       
+       private vtkProp[] processPick(vtkAbstractPicker picker, vtkPropCollection coll) {
+//             double[] pickPos = picker.GetPickPosition();
+               picker.Delete();
+               if (coll != null) {
+                       coll.InitTraversal();
+                       vtkProp result[] = new vtkProp[coll.GetNumberOfItems()];
+                       for (int i = coll.GetNumberOfItems()-1; i >= 0; i--) {
+                               vtkProp test = coll.GetNextProp();
+                               
+//                             System.out.println("Picked: " + test.GetClassName() + " " + test.GetVTKId());
+                               result[i] = test;
+                               
+                       }
+                       coll.Delete();
+                       return result;
+
+               }
+               return null;
+       }
+       
+       
+       private vtkAction defaultAction;
+       private vtkAction currentAction;
+       
+       public void setActiveAction(vtkAction action) {
+               if (action.equals(currentAction))
+                       return;
+               if (currentAction != null)
+                       currentAction.deattach();
+               currentAction = action;
+               if (action != null)
+                       action.attach();
+       }
+       
+       public void setDefaultAction(vtkAction defaultAction) {
+               this.defaultAction = defaultAction;
+       }
+       
+       public void useDefaultAction() {
+               setActiveAction(defaultAction);
+       }
+       
+       public vtkAction getDefaultAction() {
+               return defaultAction;
+       }
+       
+       
+       @Override
+       public synchronized void Render() {
+               //System.out.println("Render " + rendering);
+               if (rendering)
+                       return;
+               
+               firePreRender();
+               super.Render();
+               firePostRender();
+       }
+       
+       
+       public void addListener(RenderListener l) {
+               listeners.add(l);
+       }
+       
+       public void removeListener(RenderListener l) {
+               listeners.remove(l);
+       }
+       
+       private List<RenderListener> listeners = new ArrayList<RenderListener>();
+       
+       List<RenderListener> list = new ArrayList<RenderListener>();
+       
+       private void firePreRender() {
+               if (listeners.size() > 0) {
+                       list.addAll(listeners);
+                       for (RenderListener l : list)
+                               l.preRender();
+                       list.clear();
+               }
+       }
+       
+       private void firePostRender() {
+               if (listeners.size() > 0) {
+                       list.addAll(listeners);
+                       for (RenderListener l : list)
+                               l.postRender();
+                       list.clear();
+               }
+       }
+
+       
+       private List<vtkObjectBase> deletable = new ArrayList<vtkObjectBase>();
+       
+       public void addDeletable(vtkObjectBase o) {
+               deletable.add(o);
+       }
+       
+       public void removeDeletable (vtkObjectBase o) {
+               deletable.remove(o);
+       }
+       
+       @Override
+       public void Delete() {
+               for (vtkObjectBase o : deletable) {
+                       if (o.GetVTKId() != 0) {
+                               o.Delete();
+                       }
+               }
+               deletable.clear();
+               
+               super.Delete();
+       }
+}