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 =========================================================================*/
35 #ifndef vtkSliderRepresentation3D_h
36 #define vtkSliderRepresentation3D_h
37 
38 #include "vtkInteractionWidgetsModule.h" // For export macro
40 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
41 
42 class vtkActor;
43 class vtkPolyDataMapper;
44 class vtkSphereSource;
45 class vtkCellPicker;
46 class vtkProperty;
47 class vtkCylinderSource;
48 class vtkVectorText;
49 class vtkAssembly;
50 class vtkTransform;
52 class vtkMatrix4x4;
53 
54 
55 class VTKINTERACTIONWIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
56 {
57 public:
62 
64 
68  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
72 
80  vtkCoordinate *GetPoint1Coordinate();
81  void SetPoint1InWorldCoordinates(double x, double y, double z);
83 
85 
93  vtkCoordinate *GetPoint2Coordinate();
94  void SetPoint2InWorldCoordinates(double x, double y, double z);
96 
98 
102  void SetTitleText(const char*) override;
103  const char* GetTitleText() override;
105 
107 
111  vtkSetClampMacro(SliderShape,int,SphereShape,CylinderShape);
112  vtkGetMacro(SliderShape, int);
113  void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
114  void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
116 
118 
123  vtkSetMacro(Rotation,double);
124  vtkGetMacro(Rotation,double);
126 
128 
132  vtkGetObjectMacro(SliderProperty,vtkProperty);
134 
136 
139  vtkGetObjectMacro(TubeProperty,vtkProperty);
140  vtkGetObjectMacro(CapProperty,vtkProperty);
142 
144 
148  vtkGetObjectMacro(SelectedProperty,vtkProperty);
150 
152 
155  void PlaceWidget(double bounds[6]) override;
156  void BuildRepresentation() override;
157  void StartWidgetInteraction(double eventPos[2]) override;
158  void WidgetInteraction(double newEventPos[2]) override;
159  void Highlight(int) override;
161 
163 
166  double *GetBounds() VTK_SIZEHINT(6) override;
167  void GetActors(vtkPropCollection*) override;
168  void ReleaseGraphicsResources(vtkWindow*) override;
169  int RenderOpaqueGeometry(vtkViewport*) override;
170  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
171  vtkTypeBool HasTranslucentPolygonalGeometry() override;
173 
177  vtkMTimeType GetMTime() override;
178 
179  /*
180  * Register internal Pickers within PickingManager
181  */
182  void RegisterPickers() override;
183 
184 protected:
186  ~vtkSliderRepresentation3D() override;
187 
188  // Positioning the widget
189  vtkCoordinate *Point1Coordinate;
190  vtkCoordinate *Point2Coordinate;
191  double Length;
192 
193  // These are the slider end points taking into account the thickness
194  // of the slider
195  double SP1[3];
196  double SP2[3];
197 
198  // More ivars controlling the appearance of the widget
199  double Rotation;
200  int SliderShape;
201 
202  // Do the picking
203  vtkCellPicker *Picker;
204 
205  // Determine the parameter t along the slider
206  virtual double ComputePickPosition(double eventPos[2]);
207 
208  // The widget consists of several actors, all grouped
209  // together using an assembly. This makes it easier to
210  // perform the final transformation into
211  vtkAssembly *WidgetAssembly;
212 
213  // Cylinder used by other objects
214  vtkCylinderSource *CylinderSource;
216 
217  // The tube
218  vtkPolyDataMapper *TubeMapper;
219  vtkActor *TubeActor;
220  vtkProperty *TubeProperty;
221 
222  // The slider
223  vtkSphereSource *SliderSource;
224  vtkPolyDataMapper *SliderMapper;
225  vtkActor *SliderActor;
226  vtkProperty *SliderProperty;
227  vtkProperty *SelectedProperty;
228 
229  // The left cap
230  vtkPolyDataMapper *LeftCapMapper;
231  vtkActor *LeftCapActor;
232  vtkProperty *CapProperty;
233 
234  // The right cap
235  vtkPolyDataMapper *RightCapMapper;
236  vtkActor *RightCapActor;
237 
238  // The text. There is an extra transform used to rotate
239  // both the title and label
240  vtkVectorText *LabelText;
241  vtkPolyDataMapper *LabelMapper;
242  vtkActor *LabelActor;
243 
244  vtkVectorText *TitleText;
245  vtkPolyDataMapper *TitleMapper;
246  vtkActor *TitleActor;
247 
248  // Transform used during slider motion
249  vtkMatrix4x4 *Matrix;
251 
252  // Manage the state of the widget
255  CylinderShape
256  };
257 
258 
259 
260 private:
262  void operator=(const vtkSliderRepresentation3D&) = delete;
263 };
264 
265 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
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:55
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:253
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkVectorText
create polygonal text
Definition: vtkVectorText.h:47
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkSliderRepresentation3D::SetSliderShapeToSphere
void SetSliderShapeToSphere()
Definition: vtkSliderRepresentation3D.h:113
vtkSliderRepresentation::SetTitleText
virtual void SetTitleText(const char *)
Specify the label text for this widget.
Definition: vtkSliderRepresentation.h:133
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:254
ADIOS::Transform
Transform
Definition: ADIOSDefs.h:40
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkCoordinate
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
Definition: vtkCoordinate.h:81
vtkCylinderSource
generate a cylinder centered at origin
Definition: vtkCylinderSource.h:42
vtkTransformPolyDataFilter
transform points and associated normals and vectors for polygonal dataset
Definition: vtkTransformPolyDataFilter.h:51
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
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:134
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:66
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:114
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:41
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWidgetRepresentation::Highlight
virtual void Highlight(int vtkNotUsed(highlightOn))
Definition: vtkWidgetRepresentation.h:142
vtkSliderRepresentation
abstract class defines the representation for a vtkSliderWidget
Definition: vtkSliderRepresentation.h:42
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkAssembly
create hierarchies of vtkProp3Ds (transformable props)
Definition: vtkAssembly.h:75