VTK  9.0.20201019
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 "vtk3DWidget.h"
37 #include "vtkInteractionWidgetsModule.h" // For export macro
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:
49 
54  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
58 
62  void PlaceWidget(double bounds[6]) override;
64 
68  void SetEnabled(int enabling) override;
69 
71 
74  vtkGetVector6Macro(PlanePositions, double);
75  virtual void SetPlanePositions(double pos[6])
76  {
77  this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);
78  }
79  virtual void SetPlanePositions(float pos[6])
80  {
81  this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);
82  }
83  virtual void SetPlanePositions(
84  double xMin, double xMax, double yMin, double yMax, double zMin, double zMax);
86 
88 
91  virtual void SetCroppingRegionFlags(int flags);
92  vtkGetMacro(CroppingRegionFlags, int);
94 
99  enum
100  {
101  SLICE_ORIENTATION_YZ = 0,
102  SLICE_ORIENTATION_XZ = 1,
103  SLICE_ORIENTATION_XY = 2
104  };
105 
106  vtkGetMacro(SliceOrientation, int);
107  virtual void SetSliceOrientation(int orientation);
108  virtual void SetSliceOrientationToXY()
109  {
110  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY);
111  }
112  virtual void SetSliceOrientationToYZ()
113  {
114  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ);
115  }
116  virtual void SetSliceOrientationToXZ()
117  {
118  this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ);
119  }
120 
122 
125  virtual void SetSlice(int num);
126  vtkGetMacro(Slice, int);
128 
130 
133  virtual void SetLine1Color(double r, double g, double b);
134  virtual void SetLine1Color(double rgb[3]) { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
135  virtual double* GetLine1Color();
136  virtual void GetLine1Color(double rgb[3]);
138 
140 
143  virtual void SetLine2Color(double r, double g, double b);
144  virtual void SetLine2Color(double rgb[3]) { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
145  virtual double* GetLine2Color();
146  virtual void GetLine2Color(double rgb[3]);
148 
150 
153  virtual void SetLine3Color(double r, double g, double b);
154  virtual void SetLine3Color(double rgb[3]) { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
155  virtual double* GetLine3Color();
156  virtual void GetLine3Color(double rgb[3]);
158 
160 
163  virtual void SetLine4Color(double r, double g, double b);
164  virtual void SetLine4Color(double rgb[3]) { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
165  virtual double* GetLine4Color();
166  virtual void GetLine4Color(double rgb[3]);
168 
170 
174  virtual void SetVolumeMapper(vtkVolumeMapper* mapper);
175  vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
176  virtual void UpdateAccordingToInput();
178 
180 
183  void MoveHorizontalLine();
184  void MoveVerticalLine();
185  void MoveIntersectingLines();
186  void UpdateCursorIcon();
187  void OnButtonPress();
188  void OnButtonRelease();
189  void OnMouseMove();
191 
196  {
197  CroppingPlanesPositionChangedEvent = 10050
198  };
199 
200 protected:
202  ~vtkImageCroppingRegionsWidget() override;
203 
205 
206  vtkLineSource* LineSources[4];
207  vtkActor2D* LineActors[4];
208  vtkPolyData* RegionPolyData[9];
209  vtkActor2D* RegionActors[9];
210 
211  double PlanePositions[6];
212 
214  int Slice;
215 
216  double GetSlicePosition();
217 
219 
221  int Moving;
222 
223  // Handles the events
224 
225  static void ProcessEvents(
226  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
227 
228  void SetMouseCursor(int state);
229 
231  {
232  NoLine = 0,
240  MovingH2
241  };
242 
243  int ComputeWorldCoordinate(int x, int y, double* coord);
244 
245  void UpdateOpacity();
246  void UpdateGeometry();
247  void ConstrainPlanePositions(double positions[6]);
248 
249 private:
251  void operator=(const vtkImageCroppingRegionsWidget&) = delete;
252 };
253 
254 #endif
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ
Definition: vtkImageCroppingRegionsWidget.h:102
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:44
vtkImageCroppingRegionsWidget::MovingV2
Definition: vtkImageCroppingRegionsWidget.h:238
vtkImageCroppingRegionsWidget
widget for cropping an image
Definition: vtkImageCroppingRegionsWidget.h:45
vtkImageCroppingRegionsWidget::WidgetEventIds
WidgetEventIds
Events invoked by this widget.
Definition: vtkImageCroppingRegionsWidget.h:195
vtkImageCroppingRegionsWidget::SetLine3Color
virtual void SetLine3Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:154
vtkImageCroppingRegionsWidget::SetLine4Color
virtual void SetLine4Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:164
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:233
vtkImageCroppingRegionsWidget::SetPlanePositions
virtual void SetPlanePositions(double pos[6])
Definition: vtkImageCroppingRegionsWidget.h:75
vtkImageCroppingRegionsWidget::MovingH2AndV2
Definition: vtkImageCroppingRegionsWidget.h:236
vtkImageCroppingRegionsWidget::SetLine2Color
virtual void SetLine2Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:144
vtkImageCroppingRegionsWidget::MovingH2AndV1
Definition: vtkImageCroppingRegionsWidget.h:234
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImageCroppingRegionsWidget::MouseCursorState
int MouseCursorState
Definition: vtkImageCroppingRegionsWidget.h:220
vtkImageCroppingRegionsWidget::SetLine1Color
virtual void SetLine1Color(double rgb[3])
Definition: vtkImageCroppingRegionsWidget.h:134
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:235
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:79
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ
Definition: vtkImageCroppingRegionsWidget.h:101
vtkImageCroppingRegionsWidget::Moving
int Moving
Definition: vtkImageCroppingRegionsWidget.h:221
vtkImageCroppingRegionsWidget::SetSliceOrientationToXY
virtual void SetSliceOrientationToXY()
Definition: vtkImageCroppingRegionsWidget.h:108
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:70
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:60
vtkImageCroppingRegionsWidget::VolumeMapper
vtkVolumeMapper * VolumeMapper
Definition: vtkImageCroppingRegionsWidget.h:204
vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY
Definition: vtkImageCroppingRegionsWidget.h:103
vtkImageCroppingRegionsWidget::SetSliceOrientationToXZ
virtual void SetSliceOrientationToXZ()
Definition: vtkImageCroppingRegionsWidget.h:116
vtkImageCroppingRegionsWidget::CroppingRegionFlags
int CroppingRegionFlags
Definition: vtkImageCroppingRegionsWidget.h:218
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:39
vtkX3D::orientation
Definition: vtkX3D.h:268
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:214
vtk3DWidget.h
vtkImageCroppingRegionsWidget::WidgetStates
WidgetStates
Definition: vtkImageCroppingRegionsWidget.h:230
vtkImageCroppingRegionsWidget::MovingV1
Definition: vtkImageCroppingRegionsWidget.h:237
vtkImageCroppingRegionsWidget::MovingH1
Definition: vtkImageCroppingRegionsWidget.h:239
vtkImageCroppingRegionsWidget::SliceOrientation
int SliceOrientation
Definition: vtkImageCroppingRegionsWidget.h:213
vtkImageCroppingRegionsWidget::SetPlanePositions
virtual void SetPlanePositions(float pos[6])
Definition: vtkImageCroppingRegionsWidget.h:79
vtkImageCroppingRegionsWidget::SetSliceOrientationToYZ
virtual void SetSliceOrientationToYZ()
Definition: vtkImageCroppingRegionsWidget.h:112