VTK
dox/Widgets/vtkSliderRepresentation3D.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkSliderRepresentation3D.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 =========================================================================*/
00034 #ifndef __vtkSliderRepresentation3D_h
00035 #define __vtkSliderRepresentation3D_h
00036 
00037 #include "vtkSliderRepresentation.h"
00038 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
00039 
00040 class vtkActor;
00041 class vtkPolyDataMapper;
00042 class vtkSphereSource;
00043 class vtkCellPicker;
00044 class vtkProperty;
00045 class vtkCylinderSource;
00046 class vtkVectorText;
00047 class vtkAssembly;
00048 class vtkTransform;
00049 class vtkTransformPolyDataFilter;
00050 class vtkMatrix4x4;
00051 
00052 
00053 class VTK_WIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
00054 {
00055 public:
00057   static vtkSliderRepresentation3D *New();
00058 
00060 
00061   vtkTypeMacro(vtkSliderRepresentation3D,vtkSliderRepresentation);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00064 
00066 
00072   vtkCoordinate *GetPoint1Coordinate();
00073   void SetPoint1InWorldCoordinates(double x, double y, double z);
00075 
00077 
00083   vtkCoordinate *GetPoint2Coordinate();
00084   void SetPoint2InWorldCoordinates(double x, double y, double z);
00086 
00088 
00090   virtual void SetTitleText(const char*);
00091   virtual const char* GetTitleText();
00093 
00095 
00097   vtkSetClampMacro(SliderShape,int,SphereShape,CylinderShape);
00098   vtkGetMacro(SliderShape, int);
00099   void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
00100   void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
00102   
00104 
00107   vtkSetMacro(Rotation,double);
00108   vtkGetMacro(Rotation,double);
00110 
00112 
00114   vtkGetObjectMacro(SliderProperty,vtkProperty);
00116   
00118 
00119   vtkGetObjectMacro(TubeProperty,vtkProperty);
00120   vtkGetObjectMacro(CapProperty,vtkProperty);
00122   
00124 
00126   vtkGetObjectMacro(SelectedProperty,vtkProperty);
00128   
00130 
00131   virtual void PlaceWidget(double bounds[6]);
00132   virtual void BuildRepresentation();
00133   virtual void StartWidgetInteraction(double eventPos[2]);
00134   virtual void WidgetInteraction(double newEventPos[2]);
00135   virtual void Highlight(int);
00137 
00139 
00140   virtual double *GetBounds();
00141   virtual void GetActors(vtkPropCollection*);
00142   virtual void ReleaseGraphicsResources(vtkWindow*);
00143   virtual int RenderOpaqueGeometry(vtkViewport*);
00144   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00145   virtual int HasTranslucentPolygonalGeometry();
00147   
00149   virtual unsigned long GetMTime();
00150 
00151 protected:
00152   vtkSliderRepresentation3D();
00153   ~vtkSliderRepresentation3D();
00154 
00155   // Positioning the widget
00156   vtkCoordinate *Point1Coordinate;
00157   vtkCoordinate *Point2Coordinate;
00158   double        Length;
00159 
00160   // These are the slider end points taking into account the thickness
00161   // of the slider
00162   double        SP1[3];
00163   double        SP2[3];
00164   
00165   // More ivars controlling the appearance of the widget
00166   double Rotation;
00167   int    SliderShape;
00168 
00169   // Do the picking
00170   vtkCellPicker *Picker;
00171 
00172   // Determine the parameter t along the slider
00173   virtual double ComputePickPosition(double eventPos[2]);
00174 
00175   // The widget consists of several actors, all grouped
00176   // together using an assembly. This makes it easier to
00177   // perform the final transformation into 
00178   vtkAssembly *WidgetAssembly;
00179 
00180   // Cylinder used by other objects
00181   vtkCylinderSource          *CylinderSource;
00182   vtkTransformPolyDataFilter *Cylinder;
00183 
00184   // The tube
00185   vtkPolyDataMapper *TubeMapper;
00186   vtkActor          *TubeActor;
00187   vtkProperty       *TubeProperty;
00188   
00189   // The slider
00190   vtkSphereSource   *SliderSource;
00191   vtkPolyDataMapper *SliderMapper;
00192   vtkActor          *SliderActor;
00193   vtkProperty       *SliderProperty;
00194   vtkProperty       *SelectedProperty;
00195   
00196   // The left cap
00197   vtkPolyDataMapper *LeftCapMapper;
00198   vtkActor          *LeftCapActor;
00199   vtkProperty       *CapProperty;
00200 
00201   // The right cap
00202   vtkPolyDataMapper *RightCapMapper;
00203   vtkActor          *RightCapActor;
00204   
00205   // The text. There is an extra transform used to rotate
00206   // both the title and label
00207   vtkVectorText     *LabelText;
00208   vtkPolyDataMapper *LabelMapper;
00209   vtkActor          *LabelActor;
00210   
00211   vtkVectorText     *TitleText;
00212   vtkPolyDataMapper *TitleMapper;
00213   vtkActor          *TitleActor;
00214 
00215   // Transform used during slider motion 
00216   vtkMatrix4x4 *Matrix;
00217   vtkTransform *Transform;
00218 
00219 //BTX - manage the state of the widget
00220   enum _SliderShape {    
00221     SphereShape,
00222     CylinderShape
00223   };
00224 
00225 //ETX
00226 
00227 
00228 private:
00229   vtkSliderRepresentation3D(const vtkSliderRepresentation3D&);  //Not implemented
00230   void operator=(const vtkSliderRepresentation3D&);  //Not implemented
00231 };
00232 
00233 #endif