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