VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Interaction/Widgets/vtkImageCroppingRegionsWidget.h
Go to the documentation of this file.
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 =========================================================================*/
00035 #ifndef vtkImageCroppingRegionsWidget_h
00036 #define vtkImageCroppingRegionsWidget_h
00037 
00038 #include "vtkInteractionWidgetsModule.h" // For export macro
00039 #include "vtk3DWidget.h"
00040 
00041 class vtkActor2D;
00042 class vtkImageData;
00043 class vtkLineSource;
00044 class vtkVolumeMapper;
00045 class vtkPolyData;
00046 
00047 class VTKINTERACTIONWIDGETS_EXPORT vtkImageCroppingRegionsWidget : public vtk3DWidget
00048 {
00049 public:
00050 
00052 
00053   static vtkImageCroppingRegionsWidget *New();
00054   vtkTypeMacro(vtkImageCroppingRegionsWidget, vtk3DWidget);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00060   using vtk3DWidget::PlaceWidget;
00061   virtual void PlaceWidget(double bounds[6]);
00063 
00065   virtual void SetEnabled(int enabling);
00066 
00068 
00069   vtkGetVector6Macro(PlanePositions, double);
00070   virtual void SetPlanePositions(double pos[6])
00071     {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
00072   virtual void SetPlanePositions(float pos[6])
00073     {this->SetPlanePositions(pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);}
00074   virtual void SetPlanePositions(double xMin, double xMax,
00075                                  double yMin, double yMax,
00076                                  double zMin, double zMax);
00078 
00080 
00081   virtual void SetCroppingRegionFlags(int flags);
00082   vtkGetMacro(CroppingRegionFlags, int);
00084 
00086 
00087   enum
00088   {
00089     SLICE_ORIENTATION_YZ = 0,
00090     SLICE_ORIENTATION_XZ = 1,
00091     SLICE_ORIENTATION_XY = 2
00092   };
00093   //ETX
00094   vtkGetMacro(SliceOrientation, int);
00095   virtual void SetSliceOrientation(int orientation);
00096   virtual void SetSliceOrientationToXY()
00097     { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XY); };
00098   virtual void SetSliceOrientationToYZ()
00099     { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_YZ); };
00100   virtual void SetSliceOrientationToXZ()
00101     { this->SetSliceOrientation(vtkImageCroppingRegionsWidget::SLICE_ORIENTATION_XZ); };
00103 
00105 
00106   virtual void SetSlice(int num);
00107   vtkGetMacro(Slice, int);
00109 
00111 
00112   virtual void SetLine1Color(double r, double g, double b);
00113   virtual void SetLine1Color(double rgb[3])
00114     { this->SetLine1Color(rgb[0], rgb[1], rgb[2]); }
00115   virtual double *GetLine1Color();
00116   virtual void GetLine1Color(double rgb[3]);
00118 
00120 
00121   virtual void SetLine2Color(double r, double g, double b);
00122   virtual void SetLine2Color(double rgb[3])
00123     { this->SetLine2Color(rgb[0], rgb[1], rgb[2]); }
00124   virtual double *GetLine2Color();
00125   virtual void GetLine2Color(double rgb[3]);
00127 
00129 
00130   virtual void SetLine3Color(double r, double g, double b);
00131   virtual void SetLine3Color(double rgb[3])
00132     { this->SetLine3Color(rgb[0], rgb[1], rgb[2]); }
00133   virtual double *GetLine3Color();
00134   virtual void GetLine3Color(double rgb[3]);
00136 
00138 
00139   virtual void SetLine4Color(double r, double g, double b);
00140   virtual void SetLine4Color(double rgb[3])
00141     { this->SetLine4Color(rgb[0], rgb[1], rgb[2]); }
00142   virtual double *GetLine4Color();
00143   virtual void GetLine4Color(double rgb[3]);
00145 
00147 
00149   virtual void SetVolumeMapper(vtkVolumeMapper *mapper);
00150   vtkGetObjectMacro(VolumeMapper, vtkVolumeMapper);
00151   virtual void UpdateAccordingToInput();
00153 
00155 
00156   void MoveHorizontalLine();
00157   void MoveVerticalLine();
00158   void MoveIntersectingLines();
00159   void UpdateCursorIcon();
00160   void OnButtonPress();
00161   void OnButtonRelease();
00162   void OnMouseMove();
00164 
00165   //BTX
00167 
00168   enum WidgetEventIds
00169     {
00170     CroppingPlanesPositionChangedEvent = 10050
00171     };
00172   //ETX
00174 
00175 protected:
00176 
00177   vtkImageCroppingRegionsWidget();
00178   ~vtkImageCroppingRegionsWidget();
00179 
00180   vtkVolumeMapper *VolumeMapper;
00181 
00182   vtkLineSource *LineSources[4];
00183   vtkActor2D *LineActors[4];
00184   vtkPolyData* RegionPolyData[9];
00185   vtkActor2D* RegionActors[9];
00186 
00187   double PlanePositions[6];
00188 
00189   int SliceOrientation;
00190   int Slice;
00191 
00192   double GetSlicePosition();
00193 
00194   int CroppingRegionFlags;
00195 
00196   int MouseCursorState;
00197   int Moving;
00198 
00199   // Handles the events
00200 
00201   static void ProcessEvents(vtkObject* object,
00202                             unsigned long event,
00203                             void* clientdata,
00204                             void* calldata);
00205 
00206   void SetMouseCursor(int state);
00207 
00208   //BTX
00209   enum WidgetStates
00210   {
00211     NoLine = 0,
00212     MovingH1AndV1,
00213     MovingH2AndV1,
00214     MovingH1AndV2,
00215     MovingH2AndV2,
00216     MovingV1,
00217     MovingV2,
00218     MovingH1,
00219     MovingH2
00220   };
00221   //ETX
00222 
00223   int ComputeWorldCoordinate(int x, int y, double* coord);
00224 
00225   void UpdateOpacity();
00226   void UpdateGeometry();
00227   void ConstrainPlanePositions(double positions[6]);
00228 
00229 private:
00230   vtkImageCroppingRegionsWidget(const vtkImageCroppingRegionsWidget&);  //Not implemented
00231   void operator=(const vtkImageCroppingRegionsWidget&);  //Not implemented
00232 };
00233 
00234 #endif