X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fgizmo%2FTranslateAxisGizmo.java;h=64b32d3ed9ced8c4291f73abff093927d43b83fb;hb=53d55c24c779745f188bdb18d32f71d20acb61b2;hp=0bd70cf279e3000913f98c1e50b7ea071dc459b3;hpb=289aaab900078ef56efc8779e4b15830e472149e;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateAxisGizmo.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateAxisGizmo.java index 0bd70cf2..64b32d3e 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateAxisGizmo.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateAxisGizmo.java @@ -1,119 +1,119 @@ -/******************************************************************************* - * 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.action.TranslateAction; -import org.simantics.g3d.vtk.shape.vtkShape; - -import vtk.vtkActor; -import vtk.vtkProp; - -public class TranslateAxisGizmo extends vtkGizmo{ - - private List parts = new ArrayList(); - int type = -1; - - - @Override - public Collection getGizmo() { - for (vtkProp p : parts) - p.Delete(); - parts.clear(); - double l = 100; - double w = 3; - switch (type) { - case TranslateAction.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 TranslateAction.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 TranslateAction.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; - } - case TranslateAction.XY: { - 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); - 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 TranslateAction.XZ: { - vtkActor lineActorX = vtkShape.createLineActor(new Point3d(-l,0,0), new Point3d(l,0,0)); - lineActorX.GetProperty().SetColor(1, 0, 0); - lineActorX.GetProperty().Delete(); - parts.add(lineActorX); - vtkActor lineActorZ = vtkShape.createLineActor(new Point3d(0,0,-l), new Point3d(0,0,l)); - lineActorZ.GetProperty().SetColor(0, 0, 1); - lineActorZ.GetProperty().Delete(); - parts.add(lineActorZ); - break; - } - case TranslateAction.YZ: { - 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); - 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; - if (getRenderer() != null) { - deattachActors(); - attachActors(); - } - } - - -} +/******************************************************************************* + * 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.TranslateAction; +import org.simantics.g3d.vtk.shape.vtkShape; + +import vtk.vtkActor; +import vtk.vtkProp; + +public class TranslateAxisGizmo extends vtkGizmo{ + + private List parts = new ArrayList(); + int type = -1; + + + @Override + public Collection getGizmo() { + for (vtkProp p : parts) + p.Delete(); + parts.clear(); + double l = 100; + double w = 3; + switch (type) { + case TranslateAction.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 TranslateAction.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 TranslateAction.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; + } + case TranslateAction.XY: { + 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); + 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 TranslateAction.XZ: { + vtkActor lineActorX = vtkShape.createLineActor(new Point3d(-l,0,0), new Point3d(l,0,0)); + lineActorX.GetProperty().SetColor(1, 0, 0); + lineActorX.GetProperty().Delete(); + parts.add(lineActorX); + vtkActor lineActorZ = vtkShape.createLineActor(new Point3d(0,0,-l), new Point3d(0,0,l)); + lineActorZ.GetProperty().SetColor(0, 0, 1); + lineActorZ.GetProperty().Delete(); + parts.add(lineActorZ); + break; + } + case TranslateAction.YZ: { + 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); + 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; + if (getView() != null) { + deattachActors(); + attachActors(); + } + } + + +}