Java AWT component that encapsulate vtkGenericRenderWindowInteractor, vtkPlaneWidget, vtkBoxWidget and extends vtkPanel @see vtkPanel @author Kitware
| 23 | * @author Kitware |
| 24 | */ |
| 25 | public class vtkCanvas extends vtkPanel implements MouseListener, MouseMotionListener, MouseWheelListener, KeyListener { |
| 26 | private static final long serialVersionUID = 1L; |
| 27 | protected vtkGenericRenderWindowInteractor iren = new vtkGenericRenderWindowInteractor(); |
| 28 | protected Timer timer = new Timer(10, new DelayAction()); |
| 29 | protected int ctrlPressed = 0; |
| 30 | protected int shiftPressed = 0; |
| 31 | protected vtkPlaneWidget pw = new vtkPlaneWidget(); |
| 32 | protected vtkBoxWidget bw = new vtkBoxWidget(); |
| 33 | |
| 34 | public void Delete() { |
| 35 | iren = null; |
| 36 | pw = null; |
| 37 | bw = null; |
| 38 | super.Delete(); |
| 39 | } |
| 40 | |
| 41 | public vtkCanvas() { |
| 42 | super(); |
| 43 | Initialize(); |
| 44 | } |
| 45 | |
| 46 | public vtkCanvas(vtkRenderWindow renwin) { |
| 47 | super(renwin); |
| 48 | Initialize(); |
| 49 | } |
| 50 | |
| 51 | protected void Initialize() { |
| 52 | iren.SetRenderWindow(rw); |
| 53 | iren.TimerEventResetsTimerOff(); |
| 54 | iren.AddObserver("CreateTimerEvent", this, "StartTimer"); |
| 55 | iren.AddObserver("DestroyTimerEvent", this, "DestroyTimer"); |
| 56 | iren.SetSize(200, 200); |
| 57 | iren.ConfigureEvent(); |
| 58 | pw.AddObserver("EnableEvent", this, "BeginPlaneInteraction"); |
| 59 | bw.AddObserver("EnableEvent", this, "BeginBoxInteraction"); |
| 60 | pw.SetKeyPressActivationValue('l'); |
| 61 | bw.SetKeyPressActivationValue('b'); |
| 62 | pw.SetInteractor(iren); |
| 63 | bw.SetInteractor(iren); |
| 64 | |
| 65 | addComponentListener(new ComponentAdapter() { |
| 66 | public void componentResized(ComponentEvent event) { |
| 67 | // The Canvas is being resized, get the new size |
| 68 | int width = getWidth(); |
| 69 | int height = getHeight(); |
| 70 | setSize(width, height); |
| 71 | } |
| 72 | }); |
| 73 | |
| 74 | ren.SetBackground(0.0, 0.0, 0.0); |
| 75 | |
| 76 | // Setup same interactor style than vtkPanel |
| 77 | vtkInteractorStyleTrackballCamera style = new vtkInteractorStyleTrackballCamera(); |
| 78 | iren.SetInteractorStyle(style); |
| 79 | } |
| 80 | |
| 81 | public void StartTimer() { |
| 82 | if (timer.isRunning()) |
nothing calls this directly
no outgoing calls
no test coverage detected