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
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
generate a cylinder centered at origin
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:61
virtual void StartWidgetInteraction(double eventPos[2])
void SetSliderShapeToCylinder()
Specify whether to use a sphere or cylinder slider shape.
void SetSliderShapeToSphere()
Specify whether to use a sphere or cylinder slider shape.
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
virtual void SetTitleText(const char *)
Specify the label text for this widget.
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:33
provide the representation for a vtkSliderWidget with a 3D skin
virtual void WidgetInteraction(double newEventPos[2])
#define VTK_SIZEHINT(...)
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:76
abstract class defines the representation for a vtkSliderWidget
create hierarchies of vtkProp3Ds (transformable props)
Definition: vtkAssembly.h:69
map vtkPolyData to graphics primitives
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
virtual void Highlight(int vtkNotUsed(highlightOn))
virtual const char * GetTitleText()
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
create polygonal text
Definition: vtkVectorText.h:41