VTK
vtkImageCroppingRegionsWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageCroppingRegionsWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://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 =========================================================================*/
30 #ifndef vtkImageCroppingRegionsWidget_h
31 #define vtkImageCroppingRegionsWidget_h
32 
33 #include "vtkInteractionWidgetsModule.h" // For export macro
34 #include "vtk3DWidget.h"
35 
36 class vtkActor2D;
37 class vtkImageData;
38 class vtkLineSource;
39 class vtkVolumeMapper;
40 class vtkPolyData;
41 
42 class VTKINTERACTIONWIDGETS_EXPORT vtkImageCroppingRegionsWidget : public vtk3DWidget
43 {
44 public:
45 
47 
52  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
60  void PlaceWidget(double bounds[6]) override;
62 
66  void SetEnabled(int enabling) override;
67 
69 
72  vtkGetVector6Macro(PlanePositions, double);
73  virtual void SetPlanePositions(double pos[6])
74  {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
75  virtual void SetPlanePositions(float pos[6])
76  {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
77  virtual void SetPlanePositions(double xMin, double xMax,
78  double yMin, double yMax,
79  double zMin, double zMax);
81 
83 
86  virtual void SetCroppingRegionFlags(int flags);
87  vtkGetMacro(CroppingRegionFlags, int);
89 
94  enum
95  {
96  SLICE_ORIENTATION_YZ = 0,
97  SLICE_ORIENTATION_XZ = 1,
98  SLICE_ORIENTATION_XY = 2
99  };
100 
101  vtkGetMacro(SliceOrientation, int);
102  virtual void SetSliceOrientation(int orientation);
103  virtual void SetSliceOrientationToXY()
104  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY); };
105  virtual void SetSliceOrientationToYZ()
106  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ); };
107  virtual void SetSliceOrientationToXZ()
108  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ); };
109 
111 
114  virtual void SetSlice(int num);
115  vtkGetMacro(Slice, int);
117 
119 
122  virtual void SetLine1Color(double r, double g, double b);
123  virtual void SetLine1Color(double rgb[3])
124  { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
125  virtual double *GetLine1Color();
126  virtual void GetLine1Color(double rgb[3]);
128 
130 
133  virtual void SetLine2Color(double r, double g, double b);
134  virtual void SetLine2Color(double rgb[3])
135  { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
136  virtual double *GetLine2Color();
137  virtual void GetLine2Color(double rgb[3]);
139 
141 
144  virtual void SetLine3Color(double r, double g, double b);
145  virtual void SetLine3Color(double rgb[3])
146  { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
147  virtual double *GetLine3Color();
148  virtual void GetLine3Color(double rgb[3]);
150 
152 
155  virtual void SetLine4Color(double r, double g, double b);
156  virtual void SetLine4Color(double rgb[3])
157  { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
158  virtual double *GetLine4Color();
159  virtual void GetLine4Color(double rgb[3]);
161 
163 
167  virtual void SetVolumeMapper(vtkVolumeMapper *mapper);
168  vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
169  virtual void UpdateAccordingToInput();
171 
173 
176  void MoveHorizontalLine();
177  void MoveVerticalLine();
178  void MoveIntersectingLines();
179  void UpdateCursorIcon();
180  void OnButtonPress();
181  void OnButtonRelease();
182  void OnMouseMove();
184 
189  {
190  CroppingPlanesPositionChangedEvent = 10050
191  };
192 
193 protected:
194 
196  ~vtkImageCroppingRegionsWidget() override;
197 
199 
200  vtkLineSource *LineSources[4];
201  vtkActor2D *LineActors[4];
202  vtkPolyData* RegionPolyData[9];
203  vtkActor2D* RegionActors[9];
204 
205  double PlanePositions[6];
206 
208  int Slice;
209 
210  double GetSlicePosition();
211 
213 
215  int Moving;
216 
217  // Handles the events
218 
219  static void ProcessEvents(vtkObject* object,
220  unsigned long event,
221  void* clientdata,
222  void* calldata);
223 
224  void SetMouseCursor(int state);
225 
227  {
228  NoLine = 0,
236  MovingH2
237  };
238 
239  int ComputeWorldCoordinate(int x, int y, double* coord);
240 
241  void UpdateOpacity();
242  void UpdateGeometry();
243  void ConstrainPlanePositions(double positions[6]);
244 
245 private:
247  void operator=(const vtkImageCroppingRegionsWidget&) = delete;
248 };
249 
250 #endif
Abstract class for a volume mapper.
abstract base class for most VTK objects
Definition: vtkObject.h:59
virtual void SetLine2Color(double rgb[3])
Set/Get line 2 color.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
a actor that draws 2D data
Definition: vtkActor2D.h:45
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
virtual void SetLine4Color(double rgb[3])
Set/Get line 4 color.
virtual void SetPlanePositions(double pos[6])
Set/Get the plane positions that represent the cropped region.
WidgetEventIds
Events invoked by this widget.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
virtual void SetLine1Color(double rgb[3])
Set/Get line 1 color.
create a line defined by two end points
Definition: vtkLineSource.h:42
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void PlaceWidget()
This method is used to initially place the widget.
virtual void SetLine3Color(double rgb[3])
Set/Get line 3 color.
virtual void SetPlanePositions(float pos[6])
Set/Get the plane positions that represent the cropped region.