VTK  9.0.1
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 "vtkCoordinate.h" // For vtkViewportCoordinateMacro
33 #include "vtkInteractionWidgetsModule.h" // For export macro
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 class VTKINTERACTIONWIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
49 {
50 public:
55 
57 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
65 
73  vtkCoordinate* GetPoint1Coordinate();
74  void SetPoint1InWorldCoordinates(double x, double y, double z);
76 
78 
86  vtkCoordinate* GetPoint2Coordinate();
87  void SetPoint2InWorldCoordinates(double x, double y, double z);
89 
91 
95  void SetTitleText(const char*) override;
96  const char* GetTitleText() override;
98 
100 
104  vtkSetClampMacro(SliderShape, int, SphereShape, CylinderShape);
105  vtkGetMacro(SliderShape, int);
106  void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
107  void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
109 
111 
116  vtkSetMacro(Rotation, double);
117  vtkGetMacro(Rotation, double);
119 
121 
125  vtkGetObjectMacro(SliderProperty, vtkProperty);
127 
129 
132  vtkGetObjectMacro(TubeProperty, vtkProperty);
133  vtkGetObjectMacro(CapProperty, vtkProperty);
135 
137 
141  vtkGetObjectMacro(SelectedProperty, vtkProperty);
143 
145 
148  void PlaceWidget(double bounds[6]) override;
149  void BuildRepresentation() override;
150  void StartWidgetInteraction(double eventPos[2]) override;
151  void WidgetInteraction(double newEventPos[2]) override;
152  void Highlight(int) override;
154 
156 
159  double* GetBounds() VTK_SIZEHINT(6) override;
160  void GetActors(vtkPropCollection*) override;
161  void ReleaseGraphicsResources(vtkWindow*) override;
162  int RenderOpaqueGeometry(vtkViewport*) override;
163  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
164  vtkTypeBool HasTranslucentPolygonalGeometry() override;
166 
170  vtkMTimeType GetMTime() override;
171 
172  /*
173  * Register internal Pickers within PickingManager
174  */
175  void RegisterPickers() override;
176 
177 protected:
179  ~vtkSliderRepresentation3D() override;
180 
181  // Positioning the widget
182  vtkCoordinate* Point1Coordinate;
183  vtkCoordinate* Point2Coordinate;
184  double Length;
185 
186  // These are the slider end points taking into account the thickness
187  // of the slider
188  double SP1[3];
189  double SP2[3];
190 
191  // More ivars controlling the appearance of the widget
192  double Rotation;
193  int SliderShape;
194 
195  // Do the picking
196  vtkCellPicker* Picker;
197 
198  // Determine the parameter t along the slider
199  virtual double ComputePickPosition(double eventPos[2]);
200 
201  // The widget consists of several actors, all grouped
202  // together using an assembly. This makes it easier to
203  // perform the final transformation into
204  vtkAssembly* WidgetAssembly;
205 
206  // Cylinder used by other objects
207  vtkCylinderSource* CylinderSource;
209 
210  // The tube
211  vtkPolyDataMapper* TubeMapper;
212  vtkActor* TubeActor;
213  vtkProperty* TubeProperty;
214 
215  // The slider
216  vtkSphereSource* SliderSource;
217  vtkPolyDataMapper* SliderMapper;
218  vtkActor* SliderActor;
219  vtkProperty* SliderProperty;
220  vtkProperty* SelectedProperty;
221 
222  // The left cap
223  vtkPolyDataMapper* LeftCapMapper;
224  vtkActor* LeftCapActor;
225  vtkProperty* CapProperty;
226 
227  // The right cap
228  vtkPolyDataMapper* RightCapMapper;
229  vtkActor* RightCapActor;
230 
231  // The text. There is an extra transform used to rotate
232  // both the title and label
233  vtkVectorText* LabelText;
234  vtkPolyDataMapper* LabelMapper;
235  vtkActor* LabelActor;
236 
237  vtkVectorText* TitleText;
238  vtkPolyDataMapper* TitleMapper;
239  vtkActor* TitleActor;
240 
241  // Transform used during slider motion
242  vtkMatrix4x4* Matrix;
244 
245  // Manage the state of the widget
247  {
249  CylinderShape
250  };
251 
252 private:
254  void operator=(const vtkSliderRepresentation3D&) = delete;
255 };
256 
257 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:135
vtkSliderRepresentation3D
provide the representation for a vtkSliderWidget with a 3D skin
Definition: vtkSliderRepresentation3D.h:48
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:246
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
vtkX3D::Transform
@ Transform
Definition: vtkX3D.h:47
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkSliderRepresentation3D::SetSliderShapeToSphere
void SetSliderShapeToSphere()
Definition: vtkSliderRepresentation3D.h:106
vtkSliderRepresentation::SetTitleText
virtual void SetTitleText(const char *)
Specify the label text for this widget.
Definition: vtkSliderRepresentation.h:135
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:208
vtkX3D::Cylinder
@ Cylinder
Definition: vtkX3D.h:91
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkSliderRepresentation3D::SphereShape
@ SphereShape
Definition: vtkSliderRepresentation3D.h:248
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:76
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:134
vtkSliderRepresentation.h
vtkSliderRepresentation::GetTitleText
virtual const char * GetTitleText()
Definition: vtkSliderRepresentation.h:136
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
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:107
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWidgetRepresentation::Highlight
virtual void Highlight(int vtkNotUsed(highlightOn))
Definition: vtkWidgetRepresentation.h:140
vtkSliderRepresentation
abstract class defines the representation for a vtkSliderWidget
Definition: vtkSliderRepresentation.h:44
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
vtkAssembly
create hierarchies of vtkProp3Ds (transformable props)
Definition: vtkAssembly.h:69