VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkImageCroppingRegionsWidget.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00032 #ifndef __vtkImageCroppingRegionsWidget_h 00033 #define __vtkImageCroppingRegionsWidget_h 00034 00035 #include "vtkInteractionWidgetsModule.h" // For export macro 00036 #include "vtk3DWidget.h" 00037 00038 class vtkActor2D; 00039 class vtkImageData; 00040 class vtkLineSource; 00041 class vtkVolumeMapper; 00042 class vtkPolyData; 00043 00044 class VTKINTERACTIONWIDGETS_EXPORT vtkImageCroppingRegionsWidget : public vtk3DWidget 00045 { 00046 public: 00047 00049 00050 static vtkImageCroppingRegionsWidget *New(); 00051 vtkTypeMacro(vtkImageCroppingRegionsWidget, vtk3DWidget); 00052 void PrintSelf(ostream& os, vtkIndent indent); 00054 00056 00057 using vtk3DWidget::PlaceWidget; 00058 virtual void PlaceWidget(double bounds[6]); 00060 00062 virtual void SetEnabled(int enabling); 00063 00065 00066 vtkGetVector6Macro(PlanePositions, double); 00067 virtual void SetPlanePositions(double pos[6]) 00068 {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);} 00069 virtual void SetPlanePositions(float pos[6]) 00070 {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);} 00071 virtual void SetPlanePositions(double xMin, double xMax, 00072 double yMin, double yMax, 00073 double zMin, double zMax); 00075 00077 00078 virtual void SetCroppingRegionFlags(int flags); 00079 vtkGetMacro(CroppingRegionFlags, int); 00081 00083 00084 enum 00085 { 00086 SLICE_ORIENTATION_YZ = 0, 00087 SLICE_ORIENTATION_XZ = 1, 00088 SLICE_ORIENTATION_XY = 2 00089 }; 00090 //ETX 00091 vtkGetMacro(SliceOrientation, int); 00092 virtual void SetSliceOrientation(int orientation); 00093 virtual void SetSliceOrientationToXY() 00094 { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY); }; 00095 virtual void SetSliceOrientationToYZ() 00096 { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ); }; 00097 virtual void SetSliceOrientationToXZ() 00098 { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ); }; 00100 00102 00103 virtual void SetSlice(int num); 00104 vtkGetMacro(Slice, int); 00106 00108 00109 virtual void SetLine1Color(double r, double g, double b); 00110 virtual void SetLine1Color(double rgb[3]) 00111 { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); } 00112 virtual double *GetLine1Color(); 00113 virtual void GetLine1Color(double rgb[3]); 00115 00117 00118 virtual void SetLine2Color(double r, double g, double b); 00119 virtual void SetLine2Color(double rgb[3]) 00120 { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); } 00121 virtual double *GetLine2Color(); 00122 virtual void GetLine2Color(double rgb[3]); 00124 00126 00127 virtual void SetLine3Color(double r, double g, double b); 00128 virtual void SetLine3Color(double rgb[3]) 00129 { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); } 00130 virtual double *GetLine3Color(); 00131 virtual void GetLine3Color(double rgb[3]); 00133 00135 00136 virtual void SetLine4Color(double r, double g, double b); 00137 virtual void SetLine4Color(double rgb[3]) 00138 { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); } 00139 virtual double *GetLine4Color(); 00140 virtual void GetLine4Color(double rgb[3]); 00142 00144 00146 virtual void SetVolumeMapper(vtkVolumeMapper *mapper); 00147 vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper); 00148 virtual void UpdateAccordingToInput(); 00150 00152 00153 void MoveHorizontalLine(); 00154 void MoveVerticalLine(); 00155 void MoveIntersectingLines(); 00156 void UpdateCursorIcon(); 00157 void OnButtonPress(); 00158 void OnButtonRelease(); 00159 void OnMouseMove(); 00161 00162 //BTX 00164 00165 enum WidgetEventIds 00166 { 00167 CroppingPlanesPositionChangedEvent = 10050 00168 }; 00169 //ETX 00171 00172 protected: 00173 00174 vtkImageCroppingRegionsWidget(); 00175 ~vtkImageCroppingRegionsWidget(); 00176 00177 vtkVolumeMapper *VolumeMapper; 00178 00179 vtkLineSource *LineSources[4]; 00180 vtkActor2D *LineActors[4]; 00181 vtkPolyData* RegionPolyData[9]; 00182 vtkActor2D* RegionActors[9]; 00183 00184 double PlanePositions[6]; 00185 00186 int SliceOrientation; 00187 int Slice; 00188 00189 double GetSlicePosition(); 00190 00191 int CroppingRegionFlags; 00192 00193 int MouseCursorState; 00194 int Moving; 00195 00196 // Handles the events 00197 00198 static void ProcessEvents(vtkObject* object, 00199 unsigned long event, 00200 void* clientdata, 00201 void* calldata); 00202 00203 void SetMouseCursor(int state); 00204 00205 //BTX 00206 enum WidgetStates 00207 { 00208 NoLine = 0, 00209 MovingH1AndV1, 00210 MovingH2AndV1, 00211 MovingH1AndV2, 00212 MovingH2AndV2, 00213 MovingV1, 00214 MovingV2, 00215 MovingH1, 00216 MovingH2 00217 }; 00218 //ETX 00219 00220 int ComputeWorldCoordinate(int x, int y, double* coord); 00221 00222 void UpdateOpacity(); 00223 void UpdateGeometry(); 00224 void ConstrainPlanePositions(double positions[6]); 00225 00226 private: 00227 vtkImageCroppingRegionsWidget(const vtkImageCroppingRegionsWidget&); //Not implemented 00228 void operator=(const vtkImageCroppingRegionsWidget&); //Not implemented 00229 }; 00230 00231 #endif