VTK
vtkSliderRepresentation3D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSliderRepresentation3D.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
29 #ifndef vtkSliderRepresentation3D_h
30 #define vtkSliderRepresentation3D_h
31 
32 #include "vtkInteractionWidgetsModule.h" // For export macro
34 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
35 
36 class vtkActor;
37 class vtkPolyDataMapper;
38 class vtkSphereSource;
39 class vtkCellPicker;
40 class vtkProperty;
41 class vtkCylinderSource;
42 class vtkVectorText;
43 class vtkAssembly;
44 class vtkTransform;
46 class vtkMatrix4x4;
47 
48 
49 class VTKINTERACTIONWIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
50 {
51 public:
56 
58 
62  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66 
74  vtkCoordinate *GetPoint1Coordinate();
75  void SetPoint1InWorldCoordinates(double x, double y, double z);
77 
79 
87  vtkCoordinate *GetPoint2Coordinate();
88  void SetPoint2InWorldCoordinates(double x, double y, double z);
90 
92 
96  void SetTitleText(const char*) override;
97  const char* GetTitleText() override;
99 
101 
105  vtkSetClampMacro(SliderShape,int,SphereShape,CylinderShape);
106  vtkGetMacro(SliderShape, int);
107  void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
108  void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
110 
112 
117  vtkSetMacro(Rotation,double);
118  vtkGetMacro(Rotation,double);
120 
122 
126  vtkGetObjectMacro(SliderProperty,vtkProperty);
128 
130 
133  vtkGetObjectMacro(TubeProperty,vtkProperty);
134  vtkGetObjectMacro(CapProperty,vtkProperty);
136 
138 
142  vtkGetObjectMacro(SelectedProperty,vtkProperty);
144 
146 
149  void PlaceWidget(double bounds[6]) override;
150  void BuildRepresentation() override;
151  void StartWidgetInteraction(double eventPos[2]) override;
152  void WidgetInteraction(double newEventPos[2]) override;
153  void Highlight(int) override;
155 
157 
160  double *GetBounds() VTK_SIZEHINT(6) override;
161  void GetActors(vtkPropCollection*) override;
162  void ReleaseGraphicsResources(vtkWindow*) override;
163  int RenderOpaqueGeometry(vtkViewport*) override;
164  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
165  int HasTranslucentPolygonalGeometry() override;
167 
171  vtkMTimeType GetMTime() override;
172 
173  /*
174  * Register internal Pickers within PickingManager
175  */
176  void RegisterPickers() override;
177 
178 protected:
180  ~vtkSliderRepresentation3D() override;
181 
182  // Positioning the widget
183  vtkCoordinate *Point1Coordinate;
184  vtkCoordinate *Point2Coordinate;
185  double Length;
186 
187  // These are the slider end points taking into account the thickness
188  // of the slider
189  double SP1[3];
190  double SP2[3];
191 
192  // More ivars controlling the appearance of the widget
193  double Rotation;
194  int SliderShape;
195 
196  // Do the picking
197  vtkCellPicker *Picker;
198 
199  // Determine the parameter t along the slider
200  virtual double ComputePickPosition(double eventPos[2]);
201 
202  // The widget consists of several actors, all grouped
203  // together using an assembly. This makes it easier to
204  // perform the final transformation into
205  vtkAssembly *WidgetAssembly;
206 
207  // Cylinder used by other objects
208  vtkCylinderSource *CylinderSource;
210 
211  // The tube
212  vtkPolyDataMapper *TubeMapper;
213  vtkActor *TubeActor;
214  vtkProperty *TubeProperty;
215 
216  // The slider
217  vtkSphereSource *SliderSource;
218  vtkPolyDataMapper *SliderMapper;
219  vtkActor *SliderActor;
220  vtkProperty *SliderProperty;
221  vtkProperty *SelectedProperty;
222 
223  // The left cap
224  vtkPolyDataMapper *LeftCapMapper;
225  vtkActor *LeftCapActor;
226  vtkProperty *CapProperty;
227 
228  // The right cap
229  vtkPolyDataMapper *RightCapMapper;
230  vtkActor *RightCapActor;
231 
232  // The text. There is an extra transform used to rotate
233  // both the title and label
234  vtkVectorText *LabelText;
235  vtkPolyDataMapper *LabelMapper;
236  vtkActor *LabelActor;
237 
238  vtkVectorText *TitleText;
239  vtkPolyDataMapper *TitleMapper;
240  vtkActor *TitleActor;
241 
242  // Transform used during slider motion
243  vtkMatrix4x4 *Matrix;
245 
246  // Manage the state of the widget
249  CylinderShape
250  };
251 
252 
253 
254 private:
256  void operator=(const vtkSliderRepresentation3D&) = delete;
257 };
258 
259 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkSliderRepresentation3D
provide the representation for a vtkSliderWidget with a 3D skin
Definition: vtkSliderRepresentation3D.h:49
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkSliderRepresentation3D::_SliderShape
_SliderShape
Definition: vtkSliderRepresentation3D.h:247
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkVectorText
create polygonal text
Definition: vtkVectorText.h:41
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkSliderRepresentation3D::SetSliderShapeToSphere
void SetSliderShapeToSphere()
Definition: vtkSliderRepresentation3D.h:107
vtkSliderRepresentation::SetTitleText
virtual void SetTitleText(const char *)
Specify the label text for this widget.
Definition: vtkSliderRepresentation.h:127
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:137
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:215
vtkX3D::Cylinder
Definition: vtkX3D.h:85
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkSliderRepresentation3D::SphereShape
Definition: vtkSliderRepresentation3D.h:248
ADIOS::Transform
Transform
Definition: ADIOSDefs.h:40
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkCoordinate
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
Definition: vtkCoordinate.h:75
vtkCylinderSource
generate a cylinder centered at origin
Definition: vtkCylinderSource.h:36
vtkTransformPolyDataFilter
transform points and associated normals and vectors for polygonal dataset
Definition: vtkTransformPolyDataFilter.h:45
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkCoordinate.h
vtkWidgetRepresentation::PlaceWidget
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
Definition: vtkWidgetRepresentation.h:135
vtkSliderRepresentation.h
vtkSliderRepresentation::GetTitleText
virtual const char * GetTitleText()
Definition: vtkSliderRepresentation.h:128
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkSliderRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSliderRepresentation3D::SetSliderShapeToCylinder
void SetSliderShapeToCylinder()
Definition: vtkSliderRepresentation3D.h:108
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkWidgetRepresentation::Highlight
virtual void Highlight(int vtkNotUsed(highlightOn))
Definition: vtkWidgetRepresentation.h:142
vtkSliderRepresentation
abstract class defines the representation for a vtkSliderWidget
Definition: vtkSliderRepresentation.h:36
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkAssembly
create hierarchies of vtkProp3Ds (transformable props)
Definition: vtkAssembly.h:69