VTK  9.3.20240329
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 
178  void OnMouseMove();
180 
185  {
186  CroppingPlanesPositionChangedEvent = 10050
187  };
188 
189 protected:
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 
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 
236  void ConstrainPlanePositions(double positions[6]);
237 
238 private:
240  void operator=(const vtkImageCroppingRegionsWidget&) = delete;
241 };
242 
243 VTK_ABI_NAMESPACE_END
244 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
virtual void PlaceWidget()
This method is used to initially place the widget.
a actor that draws 2D data
Definition: vtkActor2D.h:145
void OnMouseMove()
Callbacks for user interaction.
void ConstrainPlanePositions(double positions[6])
virtual void SetSlice(int num)
Set/Get the slice number.
virtual void SetPlanePositions(float pos[6])
Set/Get the plane positions that represent the cropped region.
virtual void SetCroppingRegionFlags(int flags)
Set/Get the cropping region flags.
void OnButtonPress()
Callbacks for user interaction.
virtual void SetPlanePositions(double pos[6])
Set/Get the plane positions that represent the cropped region.
virtual void SetSliceOrientation(int orientation)
WidgetEventIds
Events invoked by this widget.
virtual double * GetLine4Color()
Set/Get line 4 color.
virtual double * GetLine1Color()
Set/Get line 1 color.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard VTK methods.
virtual void GetLine4Color(double rgb[3])
Set/Get line 4 color.
virtual void SetPlanePositions(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
Set/Get the plane positions that represent the cropped region.
void UpdateCursorIcon()
Callbacks for user interaction.
void MoveVerticalLine()
Callbacks for user interaction.
void MoveIntersectingLines()
Callbacks for user interaction.
virtual void UpdateAccordingToInput()
Set/Get the input volume mapper Update the widget according to its mapper.
virtual void GetLine2Color(double rgb[3])
Set/Get line 2 color.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetLine4Color(double rgb[3])
Set/Get line 4 color.
virtual void SetLine4Color(double r, double g, double b)
Set/Get line 4 color.
virtual void SetLine2Color(double rgb[3])
Set/Get line 2 color.
void SetMouseCursor(int state)
int ComputeWorldCoordinate(int x, int y, double *coord)
virtual double * GetLine2Color()
Set/Get line 2 color.
static vtkImageCroppingRegionsWidget * New()
Standard VTK methods.
virtual void SetLine1Color(double r, double g, double b)
Set/Get line 1 color.
void MoveHorizontalLine()
Callbacks for user interaction.
virtual void SetVolumeMapper(vtkVolumeMapper *mapper)
Set/Get the input volume mapper Update the widget according to its mapper.
virtual double * GetLine3Color()
Set/Get line 3 color.
virtual void SetLine1Color(double rgb[3])
Set/Get line 1 color.
virtual void GetLine3Color(double rgb[3])
Set/Get line 3 color.
~vtkImageCroppingRegionsWidget() override
virtual void SetLine3Color(double r, double g, double b)
Set/Get line 3 color.
virtual void SetLine2Color(double r, double g, double b)
Set/Get line 2 color.
void OnButtonRelease()
Callbacks for user interaction.
void SetEnabled(int enabling) override
Enable/disable the widget.
virtual void SetLine3Color(double rgb[3])
Set/Get line 3 color.
void PlaceWidget(double bounds[6]) override
Place/Adjust widget within bounds.
virtual void GetLine1Color(double rgb[3])
Set/Get line 1 color.
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
a simple class to control print indentation
Definition: vtkIndent.h:108
create a line defined by two end points
abstract base class for most VTK objects
Definition: vtkObject.h:162
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:181
Abstract class for a volume mapper.
@ orientation
Definition: vtkX3D.h:262