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 =========================================================================*/
33 #ifndef vtkImageCroppingRegionsWidget_h
34 #define vtkImageCroppingRegionsWidget_h
35 
36 #include "vtkInteractionWidgetsModule.h" // For export macro
37 #include "vtk3DWidget.h"
38 
39 class vtkActor2D;
40 class vtkImageData;
41 class vtkLineSource;
42 class vtkVolumeMapper;
43 class vtkPolyData;
44 
45 class VTKINTERACTIONWIDGETS_EXPORT vtkImageCroppingRegionsWidget : public vtk3DWidget
46 {
47 public:
48 
50 
55  void PrintSelf(ostream& os, vtkIndent indent);
57 
59 
63  virtual void PlaceWidget(double bounds[6]);
65 
69  virtual void SetEnabled(int enabling);
70 
72 
75  vtkGetVector6Macro(PlanePositions, double);
76  virtual void SetPlanePositions(double pos[6])
77  {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
78  virtual void SetPlanePositions(float pos[6])
79  {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
80  virtual void SetPlanePositions(double xMin, double xMax,
81  double yMin, double yMax,
82  double zMin, double zMax);
84 
86 
89  virtual void SetCroppingRegionFlags(int flags);
90  vtkGetMacro(CroppingRegionFlags, int);
92 
97  enum
98  {
99  SLICE_ORIENTATION_YZ = 0,
100  SLICE_ORIENTATION_XZ = 1,
101  SLICE_ORIENTATION_XY = 2
102  };
103 
104  vtkGetMacro(SliceOrientation, int);
105  virtual void SetSliceOrientation(int orientation);
106  virtual void SetSliceOrientationToXY()
107  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY); };
108  virtual void SetSliceOrientationToYZ()
109  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ); };
110  virtual void SetSliceOrientationToXZ()
111  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ); };
112 
114 
117  virtual void SetSlice(int num);
118  vtkGetMacro(Slice, int);
120 
122 
125  virtual void SetLine1Color(double r, double g, double b);
126  virtual void SetLine1Color(double rgb[3])
127  { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
128  virtual double *GetLine1Color();
129  virtual void GetLine1Color(double rgb[3]);
131 
133 
136  virtual void SetLine2Color(double r, double g, double b);
137  virtual void SetLine2Color(double rgb[3])
138  { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
139  virtual double *GetLine2Color();
140  virtual void GetLine2Color(double rgb[3]);
142 
144 
147  virtual void SetLine3Color(double r, double g, double b);
148  virtual void SetLine3Color(double rgb[3])
149  { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
150  virtual double *GetLine3Color();
151  virtual void GetLine3Color(double rgb[3]);
153 
155 
158  virtual void SetLine4Color(double r, double g, double b);
159  virtual void SetLine4Color(double rgb[3])
160  { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
161  virtual double *GetLine4Color();
162  virtual void GetLine4Color(double rgb[3]);
164 
166 
170  virtual void SetVolumeMapper(vtkVolumeMapper *mapper);
171  vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
172  virtual void UpdateAccordingToInput();
174 
176 
179  void MoveHorizontalLine();
180  void MoveVerticalLine();
181  void MoveIntersectingLines();
182  void UpdateCursorIcon();
183  void OnButtonPress();
184  void OnButtonRelease();
185  void OnMouseMove();
187 
192  {
193  CroppingPlanesPositionChangedEvent = 10050
194  };
195 
196 protected:
197 
200 
202 
203  vtkLineSource *LineSources[4];
204  vtkActor2D *LineActors[4];
205  vtkPolyData* RegionPolyData[9];
206  vtkActor2D* RegionActors[9];
207 
208  double PlanePositions[6];
209 
211  int Slice;
212 
213  double GetSlicePosition();
214 
216 
218  int Moving;
219 
220  // Handles the events
221 
222  static void ProcessEvents(vtkObject* object,
223  unsigned long event,
224  void* clientdata,
225  void* calldata);
226 
227  void SetMouseCursor(int state);
228 
230  {
231  NoLine = 0,
239  MovingH2
240  };
241 
242  int ComputeWorldCoordinate(int x, int y, double* coord);
243 
244  void UpdateOpacity();
245  void UpdateGeometry();
246  void ConstrainPlanePositions(double positions[6]);
247 
248 private:
250  void operator=(const vtkImageCroppingRegionsWidget&) VTK_DELETE_FUNCTION;
251 };
252 
253 #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
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...
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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.