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 "vtk3DWidget.h" 00036 00037 class vtkActor2D; 00038 class vtkImageData; 00039 class vtkLineSource; 00040 class vtkVolumeMapper; 00041 class vtkPolyData; 00042 00043 class VTK_WIDGETS_EXPORT vtkImageCroppingRegionsWidget : public vtk3DWidget 00044 { 00045 public: 00046 00048 00049 static vtkImageCroppingRegionsWidget *New(); 00050 vtkTypeMacro(vtkImageCroppingRegionsWidget, vtk3DWidget); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00053 00055 00056 using vtk3DWidget::PlaceWidget; 00057 virtual void PlaceWidget(double bounds[6]); 00059 00061 virtual void SetEnabled(int enabling); 00062 00064 00065 vtkGetVector6Macro(PlanePositions, double); 00066 virtual void SetPlanePositions(double pos[6]) 00067 {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);} 00068 virtual void SetPlanePositions(float pos[6]) 00069 {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);} 00070 virtual void SetPlanePositions(double xMin, double xMax, 00071 double yMin, double yMax, 00072 double zMin, double zMax); 00074 00076 00077 virtual void SetCroppingRegionFlags(int flags); 00078 vtkGetMacro(CroppingRegionFlags, int); 00080 00082 00083 enum 00084 { 00085 SLICE_ORIENTATION_YZ = 0, 00086 SLICE_ORIENTATION_XZ = 1, 00087 SLICE_ORIENTATION_XY = 2 00088 }; 00089 //ETX 00090 vtkGetMacro(SliceOrientation, int); 00091 virtual void SetSliceOrientation(int orientation); 00092 virtual void SetSliceOrientationToXY() 00093 { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY); }; 00094 virtual void SetSliceOrientationToYZ() 00095 { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ); }; 00096 virtual void SetSliceOrientationToXZ() 00097 { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ); }; 00099 00101 00102 virtual void SetSlice(int num); 00103 vtkGetMacro(Slice, int); 00105 00107 00108 virtual void SetLine1Color(double r, double g, double b); 00109 virtual void SetLine1Color(double rgb[3]) 00110 { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); } 00111 virtual double *GetLine1Color(); 00112 virtual void GetLine1Color(double rgb[3]); 00114 00116 00117 virtual void SetLine2Color(double r, double g, double b); 00118 virtual void SetLine2Color(double rgb[3]) 00119 { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); } 00120 virtual double *GetLine2Color(); 00121 virtual void GetLine2Color(double rgb[3]); 00123 00125 00126 virtual void SetLine3Color(double r, double g, double b); 00127 virtual void SetLine3Color(double rgb[3]) 00128 { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); } 00129 virtual double *GetLine3Color(); 00130 virtual void GetLine3Color(double rgb[3]); 00132 00134 00135 virtual void SetLine4Color(double r, double g, double b); 00136 virtual void SetLine4Color(double rgb[3]) 00137 { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); } 00138 virtual double *GetLine4Color(); 00139 virtual void GetLine4Color(double rgb[3]); 00141 00143 00145 virtual void SetVolumeMapper(vtkVolumeMapper *mapper); 00146 vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper); 00147 virtual void UpdateAccordingToInput(); 00149 00151 00152 void MoveHorizontalLine(); 00153 void MoveVerticalLine(); 00154 void MoveIntersectingLines(); 00155 void UpdateCursorIcon(); 00156 void OnButtonPress(); 00157 void OnButtonRelease(); 00158 void OnMouseMove(); 00160 00161 //BTX 00163 00164 enum WidgetEventIds 00165 { 00166 CroppingPlanesPositionChangedEvent = 10050 00167 }; 00168 //ETX 00170 00171 protected: 00172 00173 vtkImageCroppingRegionsWidget(); 00174 ~vtkImageCroppingRegionsWidget(); 00175 00176 vtkVolumeMapper *VolumeMapper; 00177 00178 vtkLineSource *LineSources[4]; 00179 vtkActor2D *LineActors[4]; 00180 vtkPolyData* RegionPolyData[9]; 00181 vtkActor2D* RegionActors[9]; 00182 00183 double PlanePositions[6]; 00184 00185 int SliceOrientation; 00186 int Slice; 00187 00188 double GetSlicePosition(); 00189 00190 int CroppingRegionFlags; 00191 00192 int MouseCursorState; 00193 int Moving; 00194 00195 // Handles the events 00196 00197 static void ProcessEvents(vtkObject* object, 00198 unsigned long event, 00199 void* clientdata, 00200 void* calldata); 00201 00202 void SetMouseCursor(int state); 00203 00204 //BTX 00205 enum WidgetStates 00206 { 00207 NoLine = 0, 00208 MovingH1AndV1, 00209 MovingH2AndV1, 00210 MovingH1AndV2, 00211 MovingH2AndV2, 00212 MovingV1, 00213 MovingV2, 00214 MovingH1, 00215 MovingH2 00216 }; 00217 //ETX 00218 00219 int ComputeWorldCoordinate(int x, int y, double* coord); 00220 00221 void UpdateOpacity(); 00222 void UpdateGeometry(); 00223 void ConstrainPlanePositions(double positions[6]); 00224 00225 private: 00226 vtkImageCroppingRegionsWidget(const vtkImageCroppingRegionsWidget&); //Not implemented 00227 void operator=(const vtkImageCroppingRegionsWidget&); //Not implemented 00228 }; 00229 00230 #endif