|
Slicer 4.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkAnnotationROIRepresentation.h,v $ 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 =========================================================================*/ 00021 // 00024 // 00029 00032 00033 00034 #ifndef __vtkAnnotationROIRepresentation_h 00035 #define __vtkAnnotationROIRepresentation_h 00036 00037 // Annotations includes 00038 #include "vtkSlicerAnnotationsModuleVTKWidgetsExport.h" 00039 00040 // VTK includes 00041 #include "vtkWidgetRepresentation.h" 00042 00043 class vtkActor; 00044 class vtkBox; 00045 class vtkCellPicker; 00046 class vtkDoubleArray; 00047 class vtkLineSource; 00048 class vtkMatrix4x4; 00049 class vtkPlanes; 00050 class vtkPointHandleRepresentation3D; 00051 class vtkPoints; 00052 class vtkPolyData; 00053 class vtkPolyDataAlgorithm; 00054 class vtkPolyDataMapper; 00055 class vtkProperty; 00056 class vtkSphereSource; 00057 class vtkTransform; 00058 00059 class VTK_SLICER_ANNOTATIONS_MODULE_VTKWIDGETS_EXPORT 00060 vtkAnnotationROIRepresentation 00061 : public vtkWidgetRepresentation 00062 { 00063 public: 00066 static vtkAnnotationROIRepresentation *New(); 00067 00070 vtkTypeRevisionMacro(vtkAnnotationROIRepresentation,vtkWidgetRepresentation); 00071 void PrintSelf(ostream& os, vtkIndent indent); 00072 00073 static const int NUMBER_HANDLES = 7; 00074 00082 void GetPlanes(vtkPlanes *planes); 00083 00089 vtkSetMacro(InsideOut,int); 00090 vtkGetMacro(InsideOut,int); 00091 vtkBooleanMacro(InsideOut,int); 00092 00094 void SetWorldToLocalMatrix(vtkMatrix4x4 *worldToLocalMatrix); 00095 vtkGetObjectMacro(WorldToLocalMatrix,vtkMatrix4x4); 00096 00103 virtual void GetTransform(vtkTransform *t); 00104 00110 virtual void SetTransform(vtkTransform* t); 00111 00121 void GetPolyData(vtkPolyData *pd); 00122 00127 //vtkGetObjectMacro(HandleProperty,vtkProperty); 00128 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty); 00129 00134 vtkGetObjectMacro(FaceProperty,vtkProperty); 00135 vtkGetObjectMacro(SelectedFaceProperty,vtkProperty); 00136 00141 vtkGetObjectMacro(OutlineProperty,vtkProperty); 00142 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty); 00143 00147 void SetOutlineFaceWires(int); 00148 vtkGetMacro(OutlineFaceWires,int); 00149 void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);} 00150 void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);} 00151 00156 void SetOutlineCursorWires(int); 00157 vtkGetMacro(OutlineCursorWires,int); 00158 void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);} 00159 void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);} 00160 00164 void HandlesOn(); 00165 void HandlesOff(); 00166 00169 virtual void PlaceWidget(double bounds[6]); 00170 virtual void BuildRepresentation(); 00171 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00172 virtual void StartWidgetInteraction(double e[2]); 00173 virtual void WidgetInteraction(double e[2]); 00174 virtual double *GetBounds(); 00175 00178 virtual void ReleaseGraphicsResources(vtkWindow*); 00179 virtual int RenderOpaqueGeometry(vtkViewport*); 00180 virtual int RenderTranslucentPolygonalGeometry(vtkViewport*); 00181 virtual int HasTranslucentPolygonalGeometry(); 00182 00183 enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling}; 00184 00193 virtual void SetInteractionState(int state); 00194 00197 void GetCenter(double center[]); 00198 00201 void GetExtents(double bounds[]); 00202 00203 virtual void GetActors(vtkPropCollection *actors); 00204 00205 00206 protected: 00207 vtkAnnotationROIRepresentation(); 00208 ~vtkAnnotationROIRepresentation(); 00209 00211 double LastEventPosition[4]; 00212 00214 vtkActor *HexActor; 00215 vtkPolyDataMapper *HexMapper; 00216 vtkPolyData *HexPolyData; 00217 vtkPoints *Points; //used by others as well 00218 double N[6][3]; //the normals of the faces 00219 00221 vtkActor *HexFace; 00222 vtkPolyDataMapper *HexFaceMapper; 00223 vtkPolyData *HexFacePolyData; 00224 00226 vtkActor **Handle; 00227 vtkPolyDataMapper **HandleMapper; 00228 vtkSphereSource **HandleGeometry; 00229 virtual void PositionHandles(); 00230 virtual int HighlightHandle(vtkProp *prop); //returns cell id 00231 virtual void HighlightFace(int cellId); 00232 void HighlightOutline(int highlight); 00233 void ComputeNormals(); 00234 virtual void SizeHandles(); 00235 00237 vtkActor *HexOutline; 00238 vtkPolyDataMapper *OutlineMapper; 00239 vtkPolyData *OutlinePolyData; 00240 00242 vtkCellPicker *HandlePicker; 00243 //vtkCellPicker *HexPicker; 00244 vtkActor *CurrentHandle; 00245 int CurrentHexFace; 00246 vtkCellPicker *LastPicker; 00247 00249 vtkTransform *Transform; 00250 00252 vtkBox *BoundingBox; 00253 00256 //vtkProperty *HandleProperty; 00257 vtkProperty *HandleProperties[NUMBER_HANDLES]; 00258 vtkProperty *SelectedHandleProperty; 00259 vtkProperty *FaceProperty; 00260 vtkProperty *SelectedFaceProperty; 00261 vtkProperty *OutlineProperty; 00262 vtkProperty *SelectedOutlineProperty; 00263 virtual void CreateDefaultProperties(); 00264 00266 int InsideOut; 00267 int OutlineFaceWires; 00268 int OutlineCursorWires; 00269 void GenerateOutline(); 00270 00272 virtual void Translate(double *p1, double *p2); 00273 virtual void Scale(double *p1, double *p2, int X, int Y); 00274 virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn); 00275 void MovePlusXFace(double *p1, double *p2); 00276 void MoveMinusXFace(double *p1, double *p2); 00277 void MovePlusYFace(double *p1, double *p2); 00278 void MoveMinusYFace(double *p1, double *p2); 00279 void MovePlusZFace(double *p1, double *p2); 00280 void MoveMinusZFace(double *p1, double *p2); 00281 00283 vtkPoints *PlanePoints; 00284 vtkDoubleArray *PlaneNormals; 00285 vtkMatrix4x4 *Matrix; 00286 00287 vtkMatrix4x4 *WorldToLocalMatrix; 00288 00289 //"dir" is the direction in which the face can be moved i.e. the axis passing 00290 //through the center 00291 void MoveFace(double *p1, double *p2, double *dir, 00292 double *x1, double *x2, double *x3, double *x4, 00293 double *x5); 00294 //Helper method to obtain the direction in which the face is to be moved. 00295 //Handles special cases where some of the scale factors are 0. 00296 void GetDirection(const double Nx[3],const double Ny[3], 00297 const double Nz[3], double dir[3]); 00298 00299 00300 private: 00301 vtkAnnotationROIRepresentation(const vtkAnnotationROIRepresentation&); //Not implemented 00302 void operator=(const vtkAnnotationROIRepresentation&); //Not implemented 00303 }; 00304 00305 #endif
1.7.4