VTK  9.0.1
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 "vtk3DWidget.h"
34 #include "vtkInteractionWidgetsModule.h" // For export macro
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:
46 
51  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55 
59  void PlaceWidget(double bounds[6]) override;
61 
65  void SetEnabled(int enabling) override;
66 
68 
71  vtkGetVector6Macro(PlanePositions, double);
72  virtual void SetPlanePositions(double pos[6])
73  {
74  this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);
75  }
76  virtual void SetPlanePositions(float pos[6])
77  {
78  this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);
79  }
80  virtual void SetPlanePositions(
81  double xMin, double xMax, double yMin, double yMax, double zMin, double zMax);
83 
85 
88  virtual void SetCroppingRegionFlags(int flags);
89  vtkGetMacro(CroppingRegionFlags, int);
91 
96  enum
97  {
98  SLICE_ORIENTATION_YZ = 0,
99  SLICE_ORIENTATION_XZ = 1,
100  SLICE_ORIENTATION_XY = 2
101  };
102 
103  vtkGetMacro(SliceOrientation, int);
104  virtual void SetSliceOrientation(int orientation);
105  virtual void SetSliceOrientationToXY()
106  {
107  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY);
108  }
109  virtual void SetSliceOrientationToYZ()
110  {
111  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ);
112  }
113  virtual void SetSliceOrientationToXZ()
114  {
115  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ);
116  }
117 
119 
122  virtual void SetSlice(int num);
123  vtkGetMacro(Slice, int);
125 
127 
130  virtual void SetLine1Color(double r, double g, double b);
131  virtual void SetLine1Color(double rgb[3]) { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
132  virtual double* GetLine1Color();
133  virtual void GetLine1Color(double rgb[3]);
135 
137 
140  virtual void SetLine2Color(double r, double g, double b);
141  virtual void SetLine2Color(double rgb[3]) { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
142  virtual double* GetLine2Color();
143  virtual void GetLine2Color(double rgb[3]);
145 
147 
150  virtual void SetLine3Color(double r, double g, double b);
151  virtual void SetLine3Color(double rgb[3]) { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
152  virtual double* GetLine3Color();
153  virtual void GetLine3Color(double rgb[3]);
155 
157 
160  virtual void SetLine4Color(double r, double g, double b);
161  virtual void SetLine4Color(double rgb[3]) { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
162  virtual double* GetLine4Color();
163  virtual void GetLine4Color(double rgb[3]);
165 
167 
171  virtual void SetVolumeMapper(vtkVolumeMapper* mapper);
172  vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
173  virtual void UpdateAccordingToInput();
175 
177 
180  void MoveHorizontalLine();
181  void MoveVerticalLine();
182  void MoveIntersectingLines();
183  void UpdateCursorIcon();
184  void OnButtonPress();
185  void OnButtonRelease();
186  void OnMouseMove();
188 
193  {
194  CroppingPlanesPositionChangedEvent = 10050
195  };
196 
197 protected:
199  ~vtkImageCroppingRegionsWidget() override;
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(
223  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
224 
225  void SetMouseCursor(int state);
226 
228  {
229  NoLine = 0,
237  MovingH2
238  };
239 
240  int ComputeWorldCoordinate(int x, int y, double* coord);
241 
242  void UpdateOpacity();
243  void UpdateGeometry();
244  void ConstrainPlanePositions(double positions[6]);
245 
246 private:
248  void operator=(const vtkImageCroppingRegionsWidget&) = delete;
249 };
250 
251 #endif
Abstract class for a volume mapper.
abstract base class for most VTK objects
Definition: vtkObject.h:53
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:39
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:84
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:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
virtual void SetLine1Color(double rgb[3])
Set/Get line 1 color.
create a line defined by two end points
Definition: vtkLineSource.h:60
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.