Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkAnnotationROIRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: $RCSfile: vtkAnnotationROIRepresentation.h,v $
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or https://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
21 //
24 //
29 
32 
33 
34 #ifndef __vtkAnnotationROIRepresentation_h
35 #define __vtkAnnotationROIRepresentation_h
36 
37 // Annotations includes
38 #include "vtkSlicerAnnotationsModuleVTKWidgetsExport.h"
39 
40 // VTK includes
41 #include "vtkWidgetRepresentation.h"
42 
43 class vtkActor;
44 class vtkBox;
45 class vtkCellPicker;
46 class vtkDoubleArray;
47 class vtkLineSource;
48 class vtkMatrix4x4;
49 class vtkPlanes;
50 class vtkPointHandleRepresentation3D;
51 class vtkPoints;
52 class vtkPolyData;
53 class vtkPolyDataAlgorithm;
54 class vtkPolyDataMapper;
55 class vtkProperty;
56 class vtkSphereSource;
57 class vtkTransform;
58 
59 class VTK_SLICER_ANNOTATIONS_MODULE_VTKWIDGETS_EXPORT
61  : public vtkWidgetRepresentation
62 {
63 public:
66  static vtkAnnotationROIRepresentation *New();
67 
70  vtkTypeMacro(vtkAnnotationROIRepresentation,vtkWidgetRepresentation);
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
73  static const int NUMBER_HANDLES = 7;
74 
82  void GetPlanes(vtkPlanes *planes);
83 
89  vtkSetMacro(InsideOut,int);
90  vtkGetMacro(InsideOut,int);
91  vtkBooleanMacro(InsideOut,int);
92 
94  void SetWorldToLocalMatrix(vtkMatrix4x4 *worldToLocalMatrix);
95  vtkGetObjectMacro(WorldToLocalMatrix,vtkMatrix4x4);
96 
103  virtual void GetTransform(vtkTransform *t);
104 
110  virtual void SetTransform(vtkTransform* t);
111 
121  void GetPolyData(vtkPolyData *pd);
122 
127  //vtkGetObjectMacro(HandleProperty,vtkProperty);
128  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
129 
134  vtkGetObjectMacro(FaceProperty,vtkProperty);
135  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
136 
141  vtkGetObjectMacro(OutlineProperty,vtkProperty);
142  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
143 
147  void SetOutlineFaceWires(int);
148  vtkGetMacro(OutlineFaceWires,int);
149  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
150  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
151 
156  void SetOutlineCursorWires(int);
157  vtkGetMacro(OutlineCursorWires,int);
158  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
159  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
160 
164  void HandlesOn();
165  void HandlesOff();
166 
169  void PlaceWidget(double bounds[6]) override;
170  void BuildRepresentation() override;
171  int ComputeInteractionState(int X, int Y, int modify=0) override;
172  void StartWidgetInteraction(double e[2]) override;
173  void WidgetInteraction(double e[2]) override;
174  double *GetBounds() override;
175 
178  void ReleaseGraphicsResources(vtkWindow*) override;
179  int RenderOpaqueGeometry(vtkViewport*) override;
180  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
181  int HasTranslucentPolygonalGeometry() override;
182 
183  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
184 
193  virtual void SetInteractionState(int state);
194 
197  void GetCenter(double center[]);
198 
201  void GetExtents(double bounds[]);
202 
203  void GetActors(vtkPropCollection *actors) override;
204 
205 
206 protected:
208  ~vtkAnnotationROIRepresentation() override;
209 
211  double LastEventPosition[4];
212 
214  vtkActor *HexActor;
215  vtkPolyDataMapper *HexMapper;
216  vtkPolyData *HexPolyData;
217  vtkPoints *Points; //used by others as well
218  double N[6][3]; //the normals of the faces
219 
221  vtkActor *HexFace;
222  vtkPolyDataMapper *HexFaceMapper;
223  vtkPolyData *HexFacePolyData;
224 
226  vtkActor **Handle;
227  vtkPolyDataMapper **HandleMapper;
228  vtkSphereSource **HandleGeometry;
229  virtual void PositionHandles();
230  virtual int HighlightHandle(vtkProp *prop); //returns cell id
231  virtual void HighlightFace(int cellId);
232  void HighlightOutline(int highlight);
233  void ComputeNormals();
234  virtual void SizeHandles();
235 
237  vtkActor *HexOutline;
238  vtkPolyDataMapper *OutlineMapper;
239  vtkPolyData *OutlinePolyData;
240 
242  vtkCellPicker *HandlePicker;
243  //vtkCellPicker *HexPicker;
244  vtkActor *CurrentHandle;
246  vtkCellPicker *LastPicker;
247 
249  vtkTransform *Transform;
250 
252  vtkBox *BoundingBox;
253 
256  //vtkProperty *HandleProperty;
257  vtkProperty *HandleProperties[NUMBER_HANDLES];
259  vtkProperty *FaceProperty;
260  vtkProperty *SelectedFaceProperty;
261  vtkProperty *OutlineProperty;
263  virtual void CreateDefaultProperties();
264 
269  void GenerateOutline();
270 
272  virtual void Translate(double *p1, double *p2);
273  virtual void Scale(double *p1, double *p2, int X, int Y);
274  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
275  void MovePlusXFace(double *p1, double *p2);
276  void MoveMinusXFace(double *p1, double *p2);
277  void MovePlusYFace(double *p1, double *p2);
278  void MoveMinusYFace(double *p1, double *p2);
279  void MovePlusZFace(double *p1, double *p2);
280  void MoveMinusZFace(double *p1, double *p2);
281 
283  vtkPoints *PlanePoints;
284  vtkDoubleArray *PlaneNormals;
285  vtkMatrix4x4 *Matrix;
286 
287  vtkMatrix4x4 *WorldToLocalMatrix;
288 
289  //"dir" is the direction in which the face can be moved i.e. the axis passing
290  //through the center
291  void MoveFace(double *p1, double *p2, double *dir,
292  double *x1, double *x2, double *x3, double *x4,
293  double *x5);
294  //Helper method to obtain the direction in which the face is to be moved.
295  //Handles special cases where some of the scale factors are 0.
296  void GetDirection(const double Nx[3],const double Ny[3],
297  const double Nz[3], double dir[3]);
298 
299 
300 private:
302  void operator=(const vtkAnnotationROIRepresentation&) = delete;
303 };
304 
305 #endif
int InsideOut
Control the orientation of the normals.
vtkActor * HexActor
the hexahedron (6 faces)
vtkBox * BoundingBox
Support GetBounds() method.
vtkActor ** Handle
glyphs representing hot spots (e.g., handles)
vtkPoints * PlanePoints
Internal ivars for performance.
vtkCellPicker * HandlePicker
Do the picking.
vtkTransform * Transform
Transform the hexahedral points (used for rotations)
vtkActor * HexFace
A face of the hexahedron.