VTK  9.1.0
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 =========================================================================*/
58 #ifndef vtkSliderRepresentation3D_h
59 #define vtkSliderRepresentation3D_h
60 
61 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
62 #include "vtkInteractionWidgetsModule.h" // For export macro
64 
65 class vtkActor;
66 class vtkPolyDataMapper;
67 class vtkSphereSource;
68 class vtkCellPicker;
69 class vtkProperty;
70 class vtkCylinderSource;
71 class vtkVectorText;
72 class vtkAssembly;
73 class vtkTransform;
75 class vtkMatrix4x4;
76 
77 class VTKINTERACTIONWIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
78 {
79 public:
84 
86 
90  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
94 
103  void SetPoint1InWorldCoordinates(double x, double y, double z);
105 
107 
116  void SetPoint2InWorldCoordinates(double x, double y, double z);
118 
120 
124  void SetTitleText(const char*) override;
125  const char* GetTitleText() override;
127 
129 
133  vtkSetClampMacro(SliderShape, int, SphereShape, CylinderShape);
134  vtkGetMacro(SliderShape, int);
135  void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
136  void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
138 
140 
145  vtkSetMacro(Rotation, double);
146  vtkGetMacro(Rotation, double);
148 
150 
154  vtkGetObjectMacro(SliderProperty, vtkProperty);
156 
158 
161  vtkGetObjectMacro(TubeProperty, vtkProperty);
162  vtkGetObjectMacro(CapProperty, vtkProperty);
164 
166 
170  vtkGetObjectMacro(SelectedProperty, vtkProperty);
172 
174 
177  void PlaceWidget(double bounds[6]) override;
178  void BuildRepresentation() override;
179  void StartWidgetInteraction(double eventPos[2]) override;
180  void WidgetInteraction(double newEventPos[2]) override;
181  void Highlight(int) override;
183 
185 
188  double* GetBounds() VTK_SIZEHINT(6) override;
189  void GetActors(vtkPropCollection*) override;
190  void ReleaseGraphicsResources(vtkWindow*) override;
191  int RenderOpaqueGeometry(vtkViewport*) override;
192  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
193  vtkTypeBool HasTranslucentPolygonalGeometry() override;
195 
199  vtkMTimeType GetMTime() override;
200 
201  /*
202  * Register internal Pickers within PickingManager
203  */
204  void RegisterPickers() override;
205 
206 protected:
209 
210  // Positioning the widget
211  vtkCoordinate* Point1Coordinate;
212  vtkCoordinate* Point2Coordinate;
213  double Length;
214 
215  // These are the slider end points taking into account the thickness
216  // of the slider
217  double SP1[3];
218  double SP2[3];
219 
220  // More ivars controlling the appearance of the widget
221  double Rotation;
222  int SliderShape;
223 
224  // Do the picking
225  vtkCellPicker* Picker;
226 
227  // Determine the parameter t along the slider
228  virtual double ComputePickPosition(double eventPos[2]);
229 
230  // The widget consists of several actors, all grouped
231  // together using an assembly. This makes it easier to
232  // perform the final transformation into
233  vtkAssembly* WidgetAssembly;
234 
235  // Cylinder used by other objects
236  vtkCylinderSource* CylinderSource;
238 
239  // The tube
240  vtkPolyDataMapper* TubeMapper;
241  vtkActor* TubeActor;
242  vtkProperty* TubeProperty;
243 
244  // The slider
245  vtkSphereSource* SliderSource;
246  vtkPolyDataMapper* SliderMapper;
247  vtkActor* SliderActor;
248  vtkProperty* SliderProperty;
249  vtkProperty* SelectedProperty;
250 
251  // The left cap
252  vtkPolyDataMapper* LeftCapMapper;
253  vtkActor* LeftCapActor;
254  vtkProperty* CapProperty;
255 
256  // The right cap
257  vtkPolyDataMapper* RightCapMapper;
258  vtkActor* RightCapActor;
259 
260  // The text. There is an extra transform used to rotate
261  // both the title and label
262  vtkVectorText* LabelText;
263  vtkPolyDataMapper* LabelMapper;
264  vtkActor* LabelActor;
265 
266  vtkVectorText* TitleText;
267  vtkPolyDataMapper* TitleMapper;
268  vtkActor* TitleActor;
269 
270  // Transform used during slider motion
271  vtkMatrix4x4* Matrix;
273 
274  // Manage the state of the widget
276  {
278  CylinderShape
279  };
280 
281 private:
283  void operator=(const vtkSliderRepresentation3D&) = delete;
284 };
285 
286 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
create hierarchies of vtkProp3Ds (transformable props)
Definition: vtkAssembly.h:109
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
generate a cylinder centered at origin
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
map vtkPolyData to graphics primitives
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:171
provide the representation for a vtkSliderWidget with a 3D skin
void BuildRepresentation() override
Methods to interface with the vtkSliderWidget.
void SetPoint2InWorldCoordinates(double x, double y, double z)
Position the second end point of the slider.
void Highlight(int) override
Methods to interface with the vtkSliderWidget.
vtkCoordinate * GetPoint2Coordinate()
Position the second end point of the slider.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkSliderWidget.
static vtkSliderRepresentation3D * New()
Instantiate the class.
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkSliderWidget.
vtkCoordinate * GetPoint1Coordinate()
Position the first end point of the slider.
double * GetBounds() override
Methods supporting the rendering process.
void SetSliderShapeToCylinder()
Specify whether to use a sphere or cylinder slider shape.
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkSliderWidget.
void SetTitleText(const char *) override
Specify the title text for this widget.
const char * GetTitleText() override
Specify the title text for this widget.
void SetPoint1InWorldCoordinates(double x, double y, double z)
Position the first end point of the slider.
void SetSliderShapeToSphere()
Specify whether to use a sphere or cylinder slider shape.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
abstract class defines the representation for a vtkSliderWidget
create a polygonal sphere centered at the origin
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
create polygonal text
abstract specification for Viewports
Definition: vtkViewport.h:47
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ Cylinder
Definition: vtkX3D.h:91
@ Transform
Definition: vtkX3D.h:47
int vtkTypeBool
Definition: vtkABI.h:69
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)