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
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ
Definition: vtkImageCroppingRegionsWidget.h:99
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:49
vtkImageCroppingRegionsWidget::MovingV2
Definition: vtkImageCroppingRegionsWidget.h:237
vtkImageCroppingRegionsWidget
widget for cropping an image
Definition: vtkImageCroppingRegionsWidget.h:45
vtkImageCroppingRegionsWidget::WidgetEventIds
WidgetEventIds
Events invoked by this widget.
Definition: vtkImageCroppingRegionsWidget.h:191
vtkImageCroppingRegionsWidget::SetLine3Color
virtual void SetLine3Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:148
vtkImageCroppingRegionsWidget::SetLine4Color
virtual void SetLine4Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:159
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkImageCroppingRegionsWidget::MovingH1AndV1
Definition: vtkImageCroppingRegionsWidget.h:232
vtkImageCroppingRegionsWidget::SetPlanePositions
virtual void SetPlanePositions(double pos[6])
Definition: vtkImageCroppingRegionsWidget.h:76
vtkImageCroppingRegionsWidget::MovingH2AndV2
Definition: vtkImageCroppingRegionsWidget.h:235
vtkImageCroppingRegionsWidget::SetLine2Color
virtual void SetLine2Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:137
vtkImageCroppingRegionsWidget::MovingH2AndV1
Definition: vtkImageCroppingRegionsWidget.h:233
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY
Definition: vtkImageCroppingRegionsWidget.h:101
vtkImageCroppingRegionsWidget::MouseCursorState
int MouseCursorState
Definition: vtkImageCroppingRegionsWidget.h:217
vtkImageCroppingRegionsWidget::SetLine1Color
virtual void SetLine1Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:126
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkImageCroppingRegionsWidget::MovingH1AndV2
Definition: vtkImageCroppingRegionsWidget.h:234
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkImageCroppingRegionsWidget::Moving
int Moving
Definition: vtkImageCroppingRegionsWidget.h:218
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ
Definition: vtkImageCroppingRegionsWidget.h:100
vtkImageCroppingRegionsWidget::SetSliceOrientationToXY
virtual void SetSliceOrientationToXY()
Definition: vtkImageCroppingRegionsWidget.h:106
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:42
vtkImageCroppingRegionsWidget::VolumeMapper
vtkVolumeMapper * VolumeMapper
Definition: vtkImageCroppingRegionsWidget.h:201
vtkImageCroppingRegionsWidget::SetSliceOrientationToXZ
virtual void SetSliceOrientationToXZ()
Definition: vtkImageCroppingRegionsWidget.h:110
vtkImageCroppingRegionsWidget::CroppingRegionFlags
int CroppingRegionFlags
Definition: vtkImageCroppingRegionsWidget.h:215
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:45
vtkX3D::orientation
Definition: vtkX3D.h:262
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkImageCroppingRegionsWidget::Slice
int Slice
Definition: vtkImageCroppingRegionsWidget.h:211
vtk3DWidget.h
vtkImageCroppingRegionsWidget::WidgetStates
WidgetStates
Definition: vtkImageCroppingRegionsWidget.h:229
vtkImageCroppingRegionsWidget::MovingV1
Definition: vtkImageCroppingRegionsWidget.h:236
vtkImageCroppingRegionsWidget::MovingH1
Definition: vtkImageCroppingRegionsWidget.h:238
vtkImageCroppingRegionsWidget::SliceOrientation
int SliceOrientation
Definition: vtkImageCroppingRegionsWidget.h:210
vtkImageCroppingRegionsWidget::SetPlanePositions
virtual void SetPlanePositions(float pos[6])
Definition: vtkImageCroppingRegionsWidget.h:78
vtkImageCroppingRegionsWidget::SetSliceOrientationToYZ
virtual void SetSliceOrientationToYZ()
Definition: vtkImageCroppingRegionsWidget.h:108