VTK  9.3.1
vtkImageCroppingRegionsWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
21 #ifndef vtkImageCroppingRegionsWidget_h
22 #define vtkImageCroppingRegionsWidget_h
23 
24 #include "vtk3DWidget.h"
25 #include "vtkInteractionWidgetsModule.h" // For export macro
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkActor2D;
29 class vtkImageData;
30 class vtkLineSource;
31 class vtkVolumeMapper;
32 class vtkPolyData;
33 
34 class VTKINTERACTIONWIDGETS_EXPORT vtkImageCroppingRegionsWidget : public vtk3DWidget
35 {
36 public:
38 
43  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
47 
51  void PlaceWidget(double bounds[6]) override;
53 
57  void SetEnabled(int enabling) override;
58 
60 
63  vtkGetVector6Macro(PlanePositions, double);
64  virtual void SetPlanePositions(double pos[6])
65  {
66  this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);
67  }
68  virtual void SetPlanePositions(float pos[6])
69  {
70  this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);
71  }
72  virtual void SetPlanePositions(
73  double xMin, double xMax, double yMin, double yMax, double zMin, double zMax);
75 
77 
80  virtual void SetCroppingRegionFlags(int flags);
81  vtkGetMacro(CroppingRegionFlags, int);
83 
88  enum
89  {
90  SLICE_ORIENTATION_YZ = 0,
91  SLICE_ORIENTATION_XZ = 1,
92  SLICE_ORIENTATION_XY = 2
93  };
94 
95  vtkGetMacro(SliceOrientation, int);
96  virtual void SetSliceOrientation(int orientation);
97  virtual void SetSliceOrientationToXY()
98  {
99  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY);
100  }
101  virtual void SetSliceOrientationToYZ()
102  {
103  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ);
104  }
105  virtual void SetSliceOrientationToXZ()
106  {
107  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ);
108  }
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]) { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
124  virtual double* GetLine1Color();
125  virtual void GetLine1Color(double rgb[3]);
127 
129 
132  virtual void SetLine2Color(double r, double g, double b);
133  virtual void SetLine2Color(double rgb[3]) { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
134  virtual double* GetLine2Color();
135  virtual void GetLine2Color(double rgb[3]);
137 
139 
142  virtual void SetLine3Color(double r, double g, double b);
143  virtual void SetLine3Color(double rgb[3]) { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
144  virtual double* GetLine3Color();
145  virtual void GetLine3Color(double rgb[3]);
147 
149 
152  virtual void SetLine4Color(double r, double g, double b);
153  virtual void SetLine4Color(double rgb[3]) { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
154  virtual double* GetLine4Color();
155  virtual void GetLine4Color(double rgb[3]);
157 
159 
163  virtual void SetVolumeMapper(vtkVolumeMapper* mapper);
164  vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
165  virtual void UpdateAccordingToInput();
167 
169 
172  void MoveHorizontalLine();
173  void MoveVerticalLine();
174  void MoveIntersectingLines();
175  void UpdateCursorIcon();
176  void OnButtonPress();
177  void OnButtonRelease();
178  void OnMouseMove();
180 
185  {
186  CroppingPlanesPositionChangedEvent = 10050
187  };
188 
189 protected:
191  ~vtkImageCroppingRegionsWidget() override;
192 
194 
195  vtkLineSource* LineSources[4];
196  vtkActor2D* LineActors[4];
197  vtkPolyData* RegionPolyData[9];
198  vtkActor2D* RegionActors[9];
199 
200  double PlanePositions[6];
201 
203  int Slice;
204 
205  double GetSlicePosition();
206 
208 
210  int Moving;
211 
212  // Handles the events
213 
214  static void ProcessEvents(
215  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
216 
217  void SetMouseCursor(int state);
218 
220  {
221  NoLine = 0,
229  MovingH2
230  };
231 
232  int ComputeWorldCoordinate(int x, int y, double* coord);
233 
234  void UpdateOpacity();
235  void UpdateGeometry();
236  void ConstrainPlanePositions(double positions[6]);
237 
238 private:
240  void operator=(const vtkImageCroppingRegionsWidget&) = delete;
241 };
242 
243 VTK_ABI_NAMESPACE_END
244 #endif
Abstract class for a volume mapper.
abstract base class for most VTK objects
Definition: vtkObject.h:51
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:34
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:79
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:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
virtual void SetLine1Color(double rgb[3])
Set/Get line 1 color.
create a line defined by two end points
Definition: vtkLineSource.h:52
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:59
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.