VTK
dox/Interaction/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 "vtkInteractionWidgetsModule.h" // For export macro
00030 #include "vtkWidgetRepresentation.h"
00031 
00032 class vtkTextProperty;
00033 class vtkActor2D;
00034 class vtkTextMapper;
00035 class vtkImageData;
00036 class vtkImageReslice;
00037 class vtkPlane;
00038 class vtkPlaneSource;
00039 class vtkResliceCursorPolyDataAlgorithm;
00040 class vtkResliceCursor;
00041 class vtkMatrix4x4;
00042 class vtkScalarsToColors;
00043 class vtkImageMapToColors;
00044 class vtkActor;
00045 class vtkImageActor;
00046 class vtkTexture;
00047 class vtkTextActor;
00048 class vtkImageAlgorithm;
00049 
00050 class VTKINTERACTIONWIDGETS_EXPORT vtkResliceCursorRepresentation : public vtkWidgetRepresentation
00051 {
00052 public:
00054 
00055   vtkTypeMacro(vtkResliceCursorRepresentation,vtkWidgetRepresentation);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00060 
00063   vtkSetClampMacro(Tolerance,int,1,100);
00064   vtkGetMacro(Tolerance,int);
00066 
00068 
00069   vtkSetMacro( ShowReslicedImage, int );
00070   vtkGetMacro( ShowReslicedImage, int );
00071   vtkBooleanMacro( ShowReslicedImage, int );
00073 
00075 
00077   vtkSetMacro(RestrictPlaneToVolume,int);
00078   vtkGetMacro(RestrictPlaneToVolume,int);
00079   vtkBooleanMacro(RestrictPlaneToVolume,int);
00081 
00083 
00086   vtkSetStringMacro(ThicknessLabelFormat);
00087   vtkGetStringMacro(ThicknessLabelFormat);
00089 
00090 //BTX -- used to communicate about the state of the representation
00091   enum { Outside=0, NearCenter, NearAxis1, NearAxis2,
00092          OnCenter, OnAxis1, OnAxis2};
00093   enum { None=0, PanAndRotate, RotateBothAxes,
00094          ResizeThickness, WindowLevelling };
00095 //ETX
00096 
00098   virtual char* GetThicknessLabelText();
00099 
00101 
00102   virtual double* GetThicknessLabelPosition();
00103   virtual void GetThicknessLabelPosition(double pos[3]);
00104   virtual void GetWorldThicknessLabelPosition(double pos[3]);
00106 
00108   virtual void BuildRepresentation();
00109 
00111 
00112   vtkGetObjectMacro( ResliceAxes, vtkMatrix4x4 );
00113   vtkGetObjectMacro( Reslice, vtkImageAlgorithm );
00115 
00117 
00118   vtkGetObjectMacro( ImageActor, vtkImageActor );
00120 
00122 
00127   virtual void SetLookupTable(vtkScalarsToColors*);
00128   vtkGetObjectMacro(LookupTable,vtkScalarsToColors);
00130 
00132 
00136   vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
00137   virtual void SetColorMap(vtkImageMapToColors *);
00139 
00141 
00145   void SetWindowLevel(double window, double level, int copy = 0);
00146   void GetWindowLevel(double wl[2]);
00147   double GetWindow(){return this->CurrentWindow;}
00148   double GetLevel(){return this->CurrentLevel;}
00150 
00151   virtual vtkResliceCursor * GetResliceCursor() = 0;
00152 
00154 
00156   vtkSetMacro(DisplayText,int);
00157   vtkGetMacro(DisplayText,int);
00158   vtkBooleanMacro(DisplayText,int);
00160 
00162 
00164   void SetTextProperty(vtkTextProperty* tprop);
00165   vtkTextProperty* GetTextProperty();
00167 
00169 
00171   vtkSetMacro( UseImageActor, int );
00172   vtkGetMacro( UseImageActor, int );
00173   vtkBooleanMacro( UseImageActor, int );
00175 
00177 
00179   void SetManipulationMode( int m );
00180   vtkGetMacro(ManipulationMode, int);
00182 
00184 
00186   void ActivateText(int);
00187   void ManageTextDisplay();
00189 
00191 
00193   virtual void InitializeReslicePlane();
00194   virtual void ResetCamera();
00196 
00198   virtual vtkResliceCursorPolyDataAlgorithm * GetCursorAlgorithm() = 0;
00199 
00201 
00203   vtkGetObjectMacro( PlaneSource, vtkPlaneSource );
00205 
00206 protected:
00207   vtkResliceCursorRepresentation();
00208   ~vtkResliceCursorRepresentation();
00209 
00211 
00213   virtual void CreateDefaultResliceAlgorithm();
00214   virtual void SetResliceParameters(
00215       double outputSpacingX, double outputSpacingY,
00216       int extentX, int extentY );
00218 
00220   virtual void WindowLevel( double x, double y );
00221 
00223   virtual void UpdateReslicePlane();
00224 
00226   virtual void ComputeReslicePlaneOrigin();
00227 
00228   // for negative window values.
00229   void InvertTable();
00230 
00231   // recompute origin to make the location of the reslice cursor consistent
00232   // with its physical location
00233   virtual void ComputeOrigin( vtkMatrix4x4 * );
00234 
00236   void GetVector1( double d[3] );
00237   void GetVector2( double d[3] );
00239 
00242   int ManipulationMode;
00243 
00244   // Keep track if modifier is set
00245   int Modifier;
00246 
00247   // Selection tolerance for the handles
00248   int Tolerance;
00249 
00250   // Format for printing the distance
00251   char *ThicknessLabelFormat;
00252 
00253   vtkImageAlgorithm       * Reslice;
00254   vtkPlaneSource          * PlaneSource;
00255   int                       RestrictPlaneToVolume;
00256   int                       ShowReslicedImage;
00257   vtkTextProperty         * ThicknessTextProperty;
00258   vtkTextMapper           * ThicknessTextMapper;
00259   vtkActor2D              * ThicknessTextActor;
00260   vtkMatrix4x4            * ResliceAxes;
00261   vtkMatrix4x4            * NewResliceAxes;
00262   vtkImageMapToColors     * ColorMap;
00263   vtkActor                * TexturePlaneActor;
00264   vtkTexture              * Texture;
00265   vtkScalarsToColors      * LookupTable;
00266   vtkImageActor           * ImageActor;
00267   vtkTextActor            * TextActor;
00268   double                    OriginalWindow;
00269   double                    OriginalLevel;
00270   double                    CurrentWindow;
00271   double                    CurrentLevel;
00272   double                    InitialWindow;
00273   double                    InitialLevel;
00274   double                    LastEventPosition[2];
00275   int                       UseImageActor;
00276   char                      TextBuff[128];
00277   int                       DisplayText;
00278 
00279   vtkScalarsToColors      * CreateDefaultLookupTable();
00280   void                      GenerateText();
00281 
00282 private:
00283   vtkResliceCursorRepresentation(const vtkResliceCursorRepresentation&);  //Not implemented
00284   void operator=(const vtkResliceCursorRepresentation&);  //Not implemented
00285 };
00286 
00287 #endif