]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java
Refactoring small features to common classes
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / editor / Plant3DEditor.java
index 9d0c3b820a289e912a3be846b5c55fa748ab0897..618e08533f33b97cae6c583eddac57d5b802c7b9 100644 (file)
@@ -31,11 +31,13 @@ import org.simantics.g3d.vtk.action.RemoveAction;
 import org.simantics.g3d.vtk.action.RotateAction;
 import org.simantics.g3d.vtk.action.TranslateAction;
 import org.simantics.g3d.vtk.action.vtkCameraAndSelectorAction;
+import org.simantics.g3d.vtk.common.ContextMenuListener;
 import org.simantics.g3d.vtk.common.HoverHighlighter;
 import org.simantics.g3d.vtk.common.InteractiveVtkPanel;
 import org.simantics.g3d.vtk.common.NodeSelectionProvider2;
 import org.simantics.g3d.vtk.common.SelectionHighlighter;
 import org.simantics.g3d.vtk.shape.vtkShape;
+import org.simantics.g3d.vtk.utils.AxesDisplay;
 import org.simantics.g3d.vtk.utils.vtkPanelUtil;
 import org.simantics.objmap.graph.IMapping;
 import org.simantics.objmap.graph.Mappings;
@@ -128,21 +130,8 @@ public class Plant3DEditor extends ResourceEditorPart {
                
                component.syncPopulate();
                
-               panel.addMouseListener(new java.awt.event.MouseAdapter() {
-                       @Override
-                       public void mouseClicked(final java.awt.event.MouseEvent e) {
-                               if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
-                                       Display.getDefault().asyncExec(new Runnable() {
-                                               public void run() {
-                                                       contextMenu.setLocation(e.getXOnScreen(), e.getYOnScreen());
-                                                       contextMenu.setVisible(true);
-                                               }
-                                       });
-                               }
-                       }
-               });
+               new ContextMenuListener(panel, contextMenu);
                
-
                cameraAction = new vtkCameraAndSelectorAction(panel);   
                panel.setDefaultAction(cameraAction);
                panel.useDefaultAction();
@@ -310,8 +299,6 @@ public class Plant3DEditor extends ResourceEditorPart {
                        vtkSequencePass seq = new vtkSequencePass();
                        seq.SetPasses(passes);
                        
-               
-                       
                        vtkCameraPass cameraPass = new vtkCameraPass();
                        cameraPass.SetDelegatePass(seq);
                        
@@ -335,34 +322,8 @@ public class Plant3DEditor extends ResourceEditorPart {
            ren1.AddActor(grid);
            panel.addDeletable(grid);
            
-           {
-                   vtkAxesActor axes = new vtkAxesActor();
-                   axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0,0,0);
-                   axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0,0,0);
-                   axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0,0,0);
-                   axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetShadow(0);
-                   axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetShadow(0);
-                   axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetShadow(0);
-                   axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().ItalicOff();
-                   axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().ItalicOff();
-                   axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().ItalicOff();
-                   axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().Delete();
-                   axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().Delete();
-                   axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().Delete();
-                   axes.GetXAxisCaptionActor2D().Delete();
-                   axes.GetYAxisCaptionActor2D().Delete();
-                   axes.GetZAxisCaptionActor2D().Delete();
-                   vtkOrientationMarkerWidget widget = new vtkOrientationMarkerWidget();
-                   widget.SetOutlineColor(0.9300, 0.5700, 0.1300 );
-                   widget.SetOrientationMarker(axes);
-                   widget.SetInteractor(panel.getRenderWindowInteractor());
-                   //widget.SetViewport(0.8, 0.0, 1.0, 0.2); // bottom right
-                   //widget.SetViewport(0.0, 0.0, 0.4, 0.4);
-                   widget.SetViewport(0.0, 0.0, 0.2, 0.2);  // bottom left
-                   widget.SetEnabled(1);
-                   widget.InteractiveOff();
-           }
-
+           AxesDisplay axesDisplay = new AxesDisplay(panel);
+           axesDisplay.show();
                
        }