VTK: Interaction/Widgets/vtkImageCroppingRegionsWidget.h Source File

| 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
41 static vtkImageCroppingRegionsWidget* New();
42 vtkTypeMacro(vtkImageCroppingRegionsWidget, vtk3DWidget);
43 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
50 using vtk3DWidget::PlaceWidget;
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
184 enum WidgetEventIds
185 {
186 CroppingPlanesPositionChangedEvent = 10050
187 };
188
189 protected:
190 vtkImageCroppingRegionsWidget();
191 ~vtkImageCroppingRegionsWidget() override;
192
193 vtkVolumeMapper* VolumeMapper;
194
195 vtkLineSource* LineSources[4];
196 vtkActor2D* LineActors[4];
197 vtkPolyData* RegionPolyData[9];
198 vtkActor2D* RegionActors[9];
199
200 double PlanePositions[6];
201
202 int SliceOrientation;
203 int Slice;
204
205 double GetSlicePosition();
206
207 int CroppingRegionFlags;
208
209 int MouseCursorState;
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
219 enum WidgetStates
220 {
221 NoLine = 0,
222 MovingH1AndV1,
223 MovingH2AndV1,
224 MovingH1AndV2,
225 MovingH2AndV2,
226 MovingV1,
227 MovingV2,
228 MovingH1,
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:
239 vtkImageCroppingRegionsWidget(const vtkImageCroppingRegionsWidget&) = delete;
240 void operator=(const vtkImageCroppingRegionsWidget&) = delete;
241 };
242
243 VTK_ABI_NAMESPACE_END
244 #endif
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:44
vtkImageCroppingRegionsWidget
widget for cropping an image
Definition: vtkImageCroppingRegionsWidget.h:35
vtkImageCroppingRegionsWidget::OnMouseMove
void OnMouseMove()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::ConstrainPlanePositions
void ConstrainPlanePositions(double positions[6])
vtkImageCroppingRegionsWidget::SetSlice
virtual void SetSlice(int num)
Set/Get the slice number.
vtkImageCroppingRegionsWidget::SliceOrientation
int SliceOrientation
Definition: vtkImageCroppingRegionsWidget.h:202
vtkImageCroppingRegionsWidget::SetPlanePositions
virtual void SetPlanePositions(float pos[6])
Set/Get the plane positions that represent the cropped region.
Definition: vtkImageCroppingRegionsWidget.h:68
vtkImageCroppingRegionsWidget::UpdateOpacity
void UpdateOpacity()
vtkImageCroppingRegionsWidget::SetCroppingRegionFlags
virtual void SetCroppingRegionFlags(int flags)
Set/Get the cropping region flags.
vtkImageCroppingRegionsWidget::OnButtonPress
void OnButtonPress()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::SetPlanePositions
virtual void SetPlanePositions(double pos[6])
Set/Get the plane positions that represent the cropped region.
Definition: vtkImageCroppingRegionsWidget.h:64
vtkImageCroppingRegionsWidget::Slice
int Slice
Definition: vtkImageCroppingRegionsWidget.h:203
vtkImageCroppingRegionsWidget::SetSliceOrientation
virtual void SetSliceOrientation(int orientation)
vtkImageCroppingRegionsWidget::WidgetEventIds
WidgetEventIds
Events invoked by this widget.
Definition: vtkImageCroppingRegionsWidget.h:185
vtkImageCroppingRegionsWidget::SetSliceOrientationToXZ
virtual void SetSliceOrientationToXZ()
Definition: vtkImageCroppingRegionsWidget.h:105
vtkImageCroppingRegionsWidget::MouseCursorState
int MouseCursorState
Definition: vtkImageCroppingRegionsWidget.h:209
vtkImageCroppingRegionsWidget::vtkImageCroppingRegionsWidget
vtkImageCroppingRegionsWidget()
vtkImageCroppingRegionsWidget::GetLine4Color
virtual double * GetLine4Color()
Set/Get line 4 color.
vtkImageCroppingRegionsWidget::GetLine1Color
virtual double * GetLine1Color()
Set/Get line 1 color.
vtkImageCroppingRegionsWidget::SetSliceOrientationToXY
virtual void SetSliceOrientationToXY()
Definition: vtkImageCroppingRegionsWidget.h:97
vtkImageCroppingRegionsWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard VTK methods.
vtkImageCroppingRegionsWidget::GetLine4Color
virtual void GetLine4Color(double rgb[3])
Set/Get line 4 color.
vtkImageCroppingRegionsWidget::SetPlanePositions
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.
vtkImageCroppingRegionsWidget::UpdateCursorIcon
void UpdateCursorIcon()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY
@ SLICE_ORIENTATION_XY
Definition: vtkImageCroppingRegionsWidget.h:92
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ
@ SLICE_ORIENTATION_XZ
Definition: vtkImageCroppingRegionsWidget.h:91
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ
@ SLICE_ORIENTATION_YZ
Definition: vtkImageCroppingRegionsWidget.h:90
vtkImageCroppingRegionsWidget::SetSliceOrientationToYZ
virtual void SetSliceOrientationToYZ()
Definition: vtkImageCroppingRegionsWidget.h:101
vtkImageCroppingRegionsWidget::VolumeMapper
vtkVolumeMapper * VolumeMapper
Definition: vtkImageCroppingRegionsWidget.h:193
vtkImageCroppingRegionsWidget::MoveVerticalLine
void MoveVerticalLine()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::MoveIntersectingLines
void MoveIntersectingLines()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::UpdateAccordingToInput
virtual void UpdateAccordingToInput()
Set/Get the input volume mapper Update the widget according to its mapper.
vtkImageCroppingRegionsWidget::GetLine2Color
virtual void GetLine2Color(double rgb[3])
Set/Get line 2 color.
vtkImageCroppingRegionsWidget::Moving
int Moving
Definition: vtkImageCroppingRegionsWidget.h:210
vtkImageCroppingRegionsWidget::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkImageCroppingRegionsWidget::SetLine4Color
virtual void SetLine4Color(double rgb[3])
Set/Get line 4 color.
Definition: vtkImageCroppingRegionsWidget.h:153
vtkImageCroppingRegionsWidget::CroppingRegionFlags
int CroppingRegionFlags
Definition: vtkImageCroppingRegionsWidget.h:207
vtkImageCroppingRegionsWidget::SetLine4Color
virtual void SetLine4Color(double r, double g, double b)
Set/Get line 4 color.
vtkImageCroppingRegionsWidget::SetLine2Color
virtual void SetLine2Color(double rgb[3])
Set/Get line 2 color.
Definition: vtkImageCroppingRegionsWidget.h:133
vtkImageCroppingRegionsWidget::SetMouseCursor
void SetMouseCursor(int state)
vtkImageCroppingRegionsWidget::ComputeWorldCoordinate
int ComputeWorldCoordinate(int x, int y, double *coord)
vtkImageCroppingRegionsWidget::GetLine2Color
virtual double * GetLine2Color()
Set/Get line 2 color.
vtkImageCroppingRegionsWidget::New
static vtkImageCroppingRegionsWidget * New()
Standard VTK methods.
vtkImageCroppingRegionsWidget::UpdateGeometry
void UpdateGeometry()
vtkImageCroppingRegionsWidget::SetLine1Color
virtual void SetLine1Color(double r, double g, double b)
Set/Get line 1 color.
vtkImageCroppingRegionsWidget::MoveHorizontalLine
void MoveHorizontalLine()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::SetVolumeMapper
virtual void SetVolumeMapper(vtkVolumeMapper *mapper)
Set/Get the input volume mapper Update the widget according to its mapper.
vtkImageCroppingRegionsWidget::GetLine3Color
virtual double * GetLine3Color()
Set/Get line 3 color.
vtkImageCroppingRegionsWidget::SetLine1Color
virtual void SetLine1Color(double rgb[3])
Set/Get line 1 color.
Definition: vtkImageCroppingRegionsWidget.h:123
vtkImageCroppingRegionsWidget::GetLine3Color
virtual void GetLine3Color(double rgb[3])
Set/Get line 3 color.
vtkImageCroppingRegionsWidget::GetSlicePosition
double GetSlicePosition()
vtkImageCroppingRegionsWidget::WidgetStates
WidgetStates
Definition: vtkImageCroppingRegionsWidget.h:220
vtkImageCroppingRegionsWidget::MovingH2AndV2
@ MovingH2AndV2
Definition: vtkImageCroppingRegionsWidget.h:225
vtkImageCroppingRegionsWidget::MovingH1AndV2
@ MovingH1AndV2
Definition: vtkImageCroppingRegionsWidget.h:224
vtkImageCroppingRegionsWidget::MovingH1AndV1
@ MovingH1AndV1
Definition: vtkImageCroppingRegionsWidget.h:222
vtkImageCroppingRegionsWidget::MovingH2AndV1
@ MovingH2AndV1
Definition: vtkImageCroppingRegionsWidget.h:223
vtkImageCroppingRegionsWidget::MovingV2
@ MovingV2
Definition: vtkImageCroppingRegionsWidget.h:227
vtkImageCroppingRegionsWidget::MovingH1
@ MovingH1
Definition: vtkImageCroppingRegionsWidget.h:228
vtkImageCroppingRegionsWidget::MovingV1
@ MovingV1
Definition: vtkImageCroppingRegionsWidget.h:226
vtkImageCroppingRegionsWidget::~vtkImageCroppingRegionsWidget
~vtkImageCroppingRegionsWidget() override
vtkImageCroppingRegionsWidget::SetLine3Color
virtual void SetLine3Color(double r, double g, double b)
Set/Get line 3 color.
vtkImageCroppingRegionsWidget::SetLine2Color
virtual void SetLine2Color(double r, double g, double b)
Set/Get line 2 color.
vtkImageCroppingRegionsWidget::OnButtonRelease
void OnButtonRelease()
Callbacks for user interaction.
vtkImageCroppingRegionsWidget::SetEnabled
void SetEnabled(int enabling) override
Enable/disable the widget.
vtkImageCroppingRegionsWidget::SetLine3Color
virtual void SetLine3Color(double rgb[3])
Set/Get line 3 color.
Definition: vtkImageCroppingRegionsWidget.h:143
vtkImageCroppingRegionsWidget::PlaceWidget
void PlaceWidget(double bounds[6]) override
Place/Adjust widget within bounds.
vtkImageCroppingRegionsWidget::GetLine1Color
virtual void GetLine1Color(double rgb[3])
Set/Get line 1 color.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:62
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:37
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:262
vtk3DWidget.h