VTK
dox/Widgets/vtkResliceCursorRepresentation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkResliceCursorRepresentation.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 =========================================================================*/
00026 #ifndef __vtkResliceCursorRepresentation_h
00027 #define __vtkResliceCursorRepresentation_h
00028 
00029 #include "vtkWidgetRepresentation.h"
00030 
00031 class vtkTextProperty;
00032 class vtkActor2D;
00033 class vtkTextMapper;
00034 class vtkImageData;
00035 class vtkImageReslice;
00036 class vtkPlane;
00037 class vtkPlaneSource;
00038 class vtkResliceCursorPolyDataAlgorithm;
00039 class vtkResliceCursor;
00040 class vtkMatrix4x4;
00041 class vtkScalarsToColors;
00042 class vtkImageMapToColors;
00043 class vtkActor;
00044 class vtkImageActor;
00045 class vtkTexture;
00046 class vtkTextActor;
00047 class vtkImageAlgorithm;
00048 
00049 class VTK_WIDGETS_EXPORT vtkResliceCursorRepresentation : public vtkWidgetRepresentation
00050 {
00051 public:
00053 
00054   vtkTypeMacro(vtkResliceCursorRepresentation,vtkWidgetRepresentation);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00062   vtkSetClampMacro(Tolerance,int,1,100);
00063   vtkGetMacro(Tolerance,int);
00065 
00067 
00068   vtkSetMacro( ShowReslicedImage, int );
00069   vtkGetMacro( ShowReslicedImage, int );
00070   vtkBooleanMacro( ShowReslicedImage, int );
00072 
00074 
00076   vtkSetMacro(RestrictPlaneToVolume,int);
00077   vtkGetMacro(RestrictPlaneToVolume,int);
00078   vtkBooleanMacro(RestrictPlaneToVolume,int);
00080 
00082 
00085   vtkSetStringMacro(ThicknessLabelFormat);
00086   vtkGetStringMacro(ThicknessLabelFormat);
00088 
00089 //BTX -- used to communicate about the state of the representation
00090   enum { Outside=0, NearCenter, NearAxis1, NearAxis2,
00091          OnCenter, OnAxis1, OnAxis2};
00092   enum { None=0, PanAndRotate, RotateBothAxes,
00093          ResizeThickness, WindowLevelling };
00094 //ETX
00095 
00097   virtual char* GetThicknessLabelText();
00098 
00100 
00101   virtual double* GetThicknessLabelPosition();
00102   virtual void GetThicknessLabelPosition(double pos[3]);
00103   virtual void GetWorldThicknessLabelPosition(double pos[3]);
00105 
00107   virtual void BuildRepresentation();
00108 
00110 
00111   vtkGetObjectMacro( ResliceAxes, vtkMatrix4x4 );
00112   vtkGetObjectMacro( Reslice, vtkImageAlgorithm );
00114 
00116 
00117   vtkGetObjectMacro( ImageActor, vtkImageActor );
00119 
00121 
00126   virtual void SetLookupTable(vtkScalarsToColors*);
00127   vtkGetObjectMacro(LookupTable,vtkScalarsToColors);
00129 
00131 
00135   vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
00136   virtual void SetColorMap(vtkImageMapToColors *);
00138 
00140 
00144   void SetWindowLevel(double window, double level, int copy = 0);
00145   void GetWindowLevel(double wl[2]);
00146   double GetWindow(){return this->CurrentWindow;}
00147   double GetLevel(){return this->CurrentLevel;}
00149 
00150   virtual vtkResliceCursor * GetResliceCursor() = 0;
00151 
00153 
00155   vtkSetMacro(DisplayText,int);
00156   vtkGetMacro(DisplayText,int);
00157   vtkBooleanMacro(DisplayText,int);
00159 
00161 
00163   void SetTextProperty(vtkTextProperty* tprop);
00164   vtkTextProperty* GetTextProperty();
00166 
00168 
00170   vtkSetMacro( UseImageActor, int );
00171   vtkGetMacro( UseImageActor, int );
00172   vtkBooleanMacro( UseImageActor, int );
00174 
00176 
00178   void SetManipulationMode( int m );
00179   vtkGetMacro(ManipulationMode, int);
00181 
00183 
00185   void ActivateText(int);
00186   void ManageTextDisplay();
00188 
00190 
00192   virtual void InitializeReslicePlane();
00193   virtual void ResetCamera();
00195 
00197   virtual vtkResliceCursorPolyDataAlgorithm * GetCursorAlgorithm() = 0;
00198 
00200 
00202   vtkGetObjectMacro( PlaneSource, vtkPlaneSource );
00204 
00205 protected:
00206   vtkResliceCursorRepresentation();
00207   ~vtkResliceCursorRepresentation();
00208 
00210 
00212   virtual void CreateDefaultResliceAlgorithm();
00213   virtual void SetResliceParameters(
00214       double outputSpacingX, double outputSpacingY,
00215       int extentX, int extentY );
00217 
00219   virtual void WindowLevel( double x, double y );
00220 
00222   virtual void UpdateReslicePlane();
00223 
00225   virtual void ComputeReslicePlaneOrigin();
00226 
00227   // for negative window values.
00228   void InvertTable();
00229 
00230   // recompute origin to make the location of the reslice cursor consistent
00231   // with its physical location
00232   virtual void ComputeOrigin( vtkMatrix4x4 * );
00233 
00235   void GetVector1( double d[3] );
00236   void GetVector2( double d[3] );
00238 
00241   int ManipulationMode;
00242 
00243   // Keep track if modifier is set
00244   int Modifier;
00245 
00246   // Selection tolerance for the handles
00247   int Tolerance;
00248 
00249   // Format for printing the distance
00250   char *ThicknessLabelFormat;
00251 
00252   vtkImageAlgorithm       * Reslice;
00253   vtkPlaneSource          * PlaneSource;
00254   int                       RestrictPlaneToVolume;
00255   int                       ShowReslicedImage;
00256   vtkTextProperty         * ThicknessTextProperty;
00257   vtkTextMapper           * ThicknessTextMapper;
00258   vtkActor2D              * ThicknessTextActor;
00259   vtkMatrix4x4            * ResliceAxes;
00260   vtkMatrix4x4            * NewResliceAxes;
00261   vtkImageMapToColors     * ColorMap;
00262   vtkActor                * TexturePlaneActor;
00263   vtkTexture              * Texture;
00264   vtkScalarsToColors      * LookupTable;
00265   vtkImageActor           * ImageActor;
00266   vtkTextActor            * TextActor;
00267   double                    OriginalWindow;
00268   double                    OriginalLevel;
00269   double                    CurrentWindow;
00270   double                    CurrentLevel;
00271   double                    InitialWindow;
00272   double                    InitialLevel;
00273   double                    LastEventPosition[2];
00274   int                       UseImageActor;
00275   char                      TextBuff[128];
00276   int                       DisplayText;
00277 
00278   vtkScalarsToColors      * CreateDefaultLookupTable();
00279   void                      GenerateText();
00280 
00281 private:
00282   vtkResliceCursorRepresentation(const vtkResliceCursorRepresentation&);  //Not implemented
00283   void operator=(const vtkResliceCursorRepresentation&);  //Not implemented
00284 };
00285 
00286 #endif