VTK
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 =========================================================================*/
32 #ifndef __vtkImageCroppingRegionsWidget_h
33 #define __vtkImageCroppingRegionsWidget_h
34 
35 #include "vtk3DWidget.h"
36 
37 class vtkActor2D;
38 class vtkImageData;
39 class vtkLineSource;
40 class vtkVolumeMapper;
41 class vtkPolyData;
42 
44 {
45 public:
46 
48 
51  void PrintSelf(ostream& os, vtkIndent indent);
53 
55 
57  virtual void PlaceWidget(double bounds[6]);
59 
61  virtual void SetEnabled(int enabling);
62 
64 
65  vtkGetVector6Macro(PlanePositions, double);
66  virtual void SetPlanePositions(double pos[6])
67  {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
68  virtual void SetPlanePositions(float pos[6])
69  {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
70  virtual void SetPlanePositions(double xMin, double xMax,
71  double yMin, double yMax,
72  double zMin, double zMax);
74 
76 
77  virtual void SetCroppingRegionFlags(int flags);
78  vtkGetMacro(CroppingRegionFlags, int);
80 
82 
83  enum
84  {
85  SLICE_ORIENTATION_YZ = 0,
86  SLICE_ORIENTATION_XZ = 1,
87  SLICE_ORIENTATION_XY = 2
88  };
89  //ETX
90  vtkGetMacro(SliceOrientation, int);
91  virtual void SetSliceOrientation(int orientation);
92  virtual void SetSliceOrientationToXY()
93  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY); };
94  virtual void SetSliceOrientationToYZ()
95  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ); };
96  virtual void SetSliceOrientationToXZ()
97  { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ); };
99 
101 
102  virtual void SetSlice(int num);
103  vtkGetMacro(Slice, int);
105 
107 
108  virtual void SetLine1Color(double r, double g, double b);
109  virtual void SetLine1Color(double rgb[3])
110  { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
111  virtual double *GetLine1Color();
112  virtual void GetLine1Color(double rgb[3]);
114 
116 
117  virtual void SetLine2Color(double r, double g, double b);
118  virtual void SetLine2Color(double rgb[3])
119  { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
120  virtual double *GetLine2Color();
121  virtual void GetLine2Color(double rgb[3]);
123 
125 
126  virtual void SetLine3Color(double r, double g, double b);
127  virtual void SetLine3Color(double rgb[3])
128  { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
129  virtual double *GetLine3Color();
130  virtual void GetLine3Color(double rgb[3]);
132 
134 
135  virtual void SetLine4Color(double r, double g, double b);
136  virtual void SetLine4Color(double rgb[3])
137  { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
138  virtual double *GetLine4Color();
139  virtual void GetLine4Color(double rgb[3]);
141 
143 
145  virtual void SetVolumeMapper(vtkVolumeMapper *mapper);
146  vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
147  virtual void UpdateAccordingToInput();
149 
151 
152  void MoveHorizontalLine();
153  void MoveVerticalLine();
154  void MoveIntersectingLines();
155  void UpdateCursorIcon();
156  void OnButtonPress();
157  void OnButtonRelease();
158  void OnMouseMove();
160 
161  //BTX
163 
165  {
166  CroppingPlanesPositionChangedEvent = 10050
167  };
168  //ETX
170 
171 protected:
172 
175 
177 
178  vtkLineSource *LineSources[4];
179  vtkActor2D *LineActors[4];
180  vtkPolyData* RegionPolyData[9];
181  vtkActor2D* RegionActors[9];
182 
183  double PlanePositions[6];
184 
186  int Slice;
187 
188  double GetSlicePosition();
189 
191 
193  int Moving;
194 
195  // Handles the events
196 
197  static void ProcessEvents(vtkObject* object,
198  unsigned long event,
199  void* clientdata,
200  void* calldata);
201 
202  void SetMouseCursor(int state);
203 
204  //BTX
206  {
207  NoLine = 0,
215  MovingH2
216  };
217  //ETX
218 
219  int ComputeWorldCoordinate(int x, int y, double* coord);
220 
221  void UpdateOpacity();
222  void UpdateGeometry();
223  void ConstrainPlanePositions(double positions[6]);
224 
225 private:
227  void operator=(const vtkImageCroppingRegionsWidget&); //Not implemented
228 };
229 
230 #endif