VTK  9.7.1
vtkSliderRepresentation3D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkSliderRepresentation3D_h
21 #define vtkSliderRepresentation3D_h
22 
23 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
24 #include "vtkInteractionWidgetsModule.h" // For export macro
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkActor;
29 class vtkPolyDataMapper;
30 class vtkSphereSource;
31 class vtkCellPicker;
32 class vtkProperty;
33 class vtkCylinderSource;
34 class vtkVectorText;
35 class vtkAssembly;
36 class vtkTransform;
37 class vtkTransformFilter;
38 class vtkMatrix4x4;
39 
40 class VTKINTERACTIONWIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
41 {
42 public:
47 
49 
53  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
57 
65  vtkCoordinate* GetPoint1Coordinate();
66  void SetPoint1InWorldCoordinates(double x, double y, double z);
68 
70 
78  vtkCoordinate* GetPoint2Coordinate();
79  void SetPoint2InWorldCoordinates(double x, double y, double z);
81 
83 
87  void SetTitleText(const char*) override;
88  const char* GetTitleText() override;
90 
92 
96  vtkSetClampMacro(SliderShape, int, SphereShape, CylinderShape);
97  vtkGetMacro(SliderShape, int);
98  void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
99  void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
101 
103 
108  vtkSetMacro(Rotation, double);
109  vtkGetMacro(Rotation, double);
111 
113 
117  vtkGetObjectMacro(SliderProperty, vtkProperty);
119 
121 
124  vtkGetObjectMacro(TubeProperty, vtkProperty);
125  vtkGetObjectMacro(CapProperty, vtkProperty);
127 
129 
133  vtkGetObjectMacro(SelectedProperty, vtkProperty);
135 
137 
140  void PlaceWidget(double bounds[6]) override;
141  void BuildRepresentation() override;
142  void StartWidgetInteraction(double eventPos[2]) override;
143  void WidgetInteraction(double newEventPos[2]) override;
144  void Highlight(int) override;
146 
148 
151  double* GetBounds() VTK_SIZEHINT(6) override;
152  void GetActors(vtkPropCollection* propCollection) override;
153  void ReleaseGraphicsResources(vtkWindow* window) override;
154  int RenderOpaqueGeometry(vtkViewport* viewport) override;
155  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
156  vtkTypeBool HasTranslucentPolygonalGeometry() override;
158 
162  vtkMTimeType GetMTime() override;
163 
164  /*
165  * Register internal Pickers within PickingManager
166  */
167  void RegisterPickers() override;
168 
169 protected:
171  ~vtkSliderRepresentation3D() override;
172 
173  // Positioning the widget
174  vtkCoordinate* Point1Coordinate;
175  vtkCoordinate* Point2Coordinate;
176  double Length;
177 
178  // These are the slider end points taking into account the thickness
179  // of the slider
180  double SP1[3];
181  double SP2[3];
182 
183  // More ivars controlling the appearance of the widget
184  double Rotation;
185  int SliderShape;
186 
187  // Do the picking
188  vtkCellPicker* Picker;
189 
190  // Determine the parameter t along the slider
191  virtual double ComputePickPosition(double eventPos[2]);
192 
193  // The widget consists of several actors, all grouped
194  // together using an assembly. This makes it easier to
195  // perform the final transformation into
196  vtkAssembly* WidgetAssembly;
197 
198  // Cylinder used by other objects
199  vtkCylinderSource* CylinderSource;
201 
202  // The tube
203  vtkPolyDataMapper* TubeMapper;
204  vtkActor* TubeActor;
205  vtkProperty* TubeProperty;
206 
207  // The slider
208  vtkSphereSource* SliderSource;
209  vtkPolyDataMapper* SliderMapper;
210  vtkActor* SliderActor;
211  vtkProperty* SliderProperty;
212  vtkProperty* SelectedProperty;
213 
214  // The left cap
215  vtkPolyDataMapper* LeftCapMapper;
216  vtkActor* LeftCapActor;
217  vtkProperty* CapProperty;
218 
219  // The right cap
220  vtkPolyDataMapper* RightCapMapper;
221  vtkActor* RightCapActor;
222 
223  // The text. There is an extra transform used to rotate
224  // both the title and label
225  vtkVectorText* LabelText;
226  vtkPolyDataMapper* LabelMapper;
227  vtkActor* LabelActor;
228 
229  vtkVectorText* TitleText;
230  vtkPolyDataMapper* TitleMapper;
231  vtkActor* TitleActor;
232 
233  // Transform used during slider motion
234  vtkMatrix4x4* Matrix;
236 
237  // Manage the state of the widget
239  {
241  CylinderShape
242  };
243 
244 private:
246  void operator=(const vtkSliderRepresentation3D&) = delete;
247 };
248 
249 VTK_ABI_NAMESPACE_END
250 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
virtual void PlaceWidget(double bounds[6])
The following is a suggested API for widget representations.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
generate a polygonal cylinder centered at the origin
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
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.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
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:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:28
provide the representation for a vtkSliderWidget with a 3D skin
virtual void WidgetInteraction(double newEventPos[2])
virtual void Highlight(int highlightOn)
#define VTK_SIZEHINT(...)
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:69
abstract class defines the representation for a vtkSliderWidget
create hierarchies of vtkProp3Ds (transformable props)
Definition: vtkAssembly.h:61
map vtkPolyData to graphics primitives
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
transform points and associated normals and vectors
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:36