1 package org.simantics.g3d.vtk.swt;
3 import java.util.ArrayList;
6 import javax.vecmath.Point3d;
8 import org.simantics.g3d.shape.Color4d;
9 import org.simantics.g3d.vtk.common.VtkView;
10 import org.simantics.g3d.vtk.shape.vtkShape;
15 public class ConstraintDetector extends org.simantics.g3d.tools.ConstraintDetector {
17 VtkView renderingPart;
19 private List<vtkProp> parts = new ArrayList<vtkProp>();
21 public ConstraintDetector(VtkView renderingPart) {
22 this.renderingPart = renderingPart;
26 protected void addConstrainLineHighlight(Point3d p1, Point3d p2, Color4d color) {
29 vtkActor lineActorX = vtkShape.createLineActor(p1, p2);
30 lineActorX.GetProperty().SetColor(color.x, color.y, color.z);
31 lineActorX.GetProperty().SetLineWidth(w);
32 lineActorX.GetProperty().Delete();
33 parts.add(lineActorX);
35 renderingPart.getRenderer().AddActor(lineActorX);
36 renderingPart.unlock();
40 protected void addConstrainPlaneHighlight(Point3d p1, Point3d p2, int axis) {
42 Point3d p12 = new Point3d();
43 Color4d color = xColor;
45 case ConstraintDetector.X:
51 case ConstraintDetector.Y:
57 case ConstraintDetector.Z:
64 vtkActor lineActorX = vtkShape.createLineActor(p1, p12, p2);
65 lineActorX.GetProperty().SetColor(color.x, color.y, color.z);
66 lineActorX.GetProperty().SetLineWidth(w);
67 lineActorX.GetProperty().Delete();
68 parts.add(lineActorX);
70 renderingPart.getRenderer().AddActor(lineActorX);
71 renderingPart.unlock();
75 public void clearConstraintHighlights() {
77 if (parts.size() == 0)
80 for (vtkProp p : parts) {
81 renderingPart.getRenderer().RemoveActor(p);
85 renderingPart.unlock();