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