-package org.simantics.g3d.vtk.gizmo;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.List;\r
-\r
-import javax.vecmath.Point3d;\r
-\r
-import org.simantics.g3d.vtk.action.RotateAction;\r
-import org.simantics.g3d.vtk.shape.vtkShape;\r
-\r
-import vtk.vtkActor;\r
-import vtk.vtkProp;\r
-\r
-public class RotateAxisGizmo extends vtkGizmo{\r
- \r
- private List<vtkProp> parts = new ArrayList<vtkProp>();\r
- int type = -1;\r
-\r
- \r
- @Override\r
- public Collection<vtkProp> getGizmo() {\r
- for (vtkProp p : parts)\r
- p.Delete();\r
- parts.clear();\r
- double l = 100;\r
- double w = 3;\r
- switch (type) {\r
- case RotateAction.X:{\r
- vtkActor lineActorX = vtkShape.createLineActor(new Point3d(-l,0,0), new Point3d(l,0,0));\r
- lineActorX.GetProperty().SetColor(1, 0, 0);\r
- lineActorX.GetProperty().SetLineWidth(w);\r
- lineActorX.GetProperty().Delete();\r
- parts.add(lineActorX);\r
- break;\r
- }\r
- case RotateAction.Y: {\r
- vtkActor lineActorY = vtkShape.createLineActor(new Point3d(0,-l,0), new Point3d(0,l,0));\r
- lineActorY.GetProperty().SetColor(0, 1, 0);\r
- lineActorY.GetProperty().SetLineWidth(w);\r
- lineActorY.GetProperty().Delete();\r
- parts.add(lineActorY);\r
- break;\r
- }\r
- case RotateAction.Z: {\r
- vtkActor lineActorZ = vtkShape.createLineActor(new Point3d(0,0,-l), new Point3d(0,0,l));\r
- lineActorZ.GetProperty().SetColor(0, 0, 1);\r
- lineActorZ.GetProperty().SetLineWidth(w);\r
- lineActorZ.GetProperty().Delete();\r
- parts.add(lineActorZ);\r
- break;\r
- }\r
- default: {\r
- \r
- }\r
- }\r
- return parts;\r
- }\r
- \r
- public void setType(int type) {\r
- if (this.type == type)\r
- return;\r
- this.type = type;\r
- deattachActors();\r
- attachActors();\r
- }\r
- \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.gizmo;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.vecmath.Point3d;
+
+import org.simantics.g3d.vtk.awt.RotateAction;
+import org.simantics.g3d.vtk.shape.vtkShape;
+
+import vtk.vtkActor;
+import vtk.vtkProp;
+
+public class RotateAxisGizmo extends vtkGizmo{
+
+ private List<vtkProp> parts = new ArrayList<vtkProp>();
+ int type = -1;
+
+
+ @Override
+ public Collection<vtkProp> getGizmo() {
+ for (vtkProp p : parts)
+ p.Delete();
+ parts.clear();
+ double l = 100;
+ double w = 3;
+ switch (type) {
+ case RotateAction.X:{
+ vtkActor lineActorX = vtkShape.createLineActor(new Point3d(-l,0,0), new Point3d(l,0,0));
+ lineActorX.GetProperty().SetColor(1, 0, 0);
+ lineActorX.GetProperty().SetLineWidth(w);
+ lineActorX.GetProperty().Delete();
+ parts.add(lineActorX);
+ break;
+ }
+ case RotateAction.Y: {
+ vtkActor lineActorY = vtkShape.createLineActor(new Point3d(0,-l,0), new Point3d(0,l,0));
+ lineActorY.GetProperty().SetColor(0, 1, 0);
+ lineActorY.GetProperty().SetLineWidth(w);
+ lineActorY.GetProperty().Delete();
+ parts.add(lineActorY);
+ break;
+ }
+ case RotateAction.Z: {
+ vtkActor lineActorZ = vtkShape.createLineActor(new Point3d(0,0,-l), new Point3d(0,0,l));
+ lineActorZ.GetProperty().SetColor(0, 0, 1);
+ lineActorZ.GetProperty().SetLineWidth(w);
+ lineActorZ.GetProperty().Delete();
+ parts.add(lineActorZ);
+ break;
+ }
+ default: {
+
+ }
+ }
+ return parts;
+ }
+
+ public void setType(int type) {
+ if (this.type == type)
+ return;
+ this.type = type;
+ deattachActors();
+ attachActors();
+ }
+
+
+}