VTK  9.3.0
vtkOrientationRepresentation.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
26#ifndef vtkOrientationRepresentation_h
27#define vtkOrientationRepresentation_h
28
29#include "vtkInteractionWidgetsModule.h" // For export macro
30#include "vtkNew.h" // For vtkNew
31#include "vtkSmartPointer.h" // For vtkSmartPointer
33
34#include <map>
35
36VTK_ABI_NAMESPACE_BEGIN
37class vtkActor;
38class vtkArrowSource;
39class vtkBox;
40class vtkCellPicker;
43class vtkProperty;
45class vtkTransform;
46
47class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationRepresentation : public vtkWidgetRepresentation
48{
49public:
54
56
60 void PrintSelf(ostream& os, vtkIndent indent) override;
62
64
69
71
75 virtual void SetOrientation(double values[3]);
76 virtual void SetOrientationX(double value);
77 virtual void SetOrientationY(double value);
78 virtual void SetOrientationZ(double value);
79 double* GetOrientation();
84
86
91 void SetProperty(int axis, bool selected, vtkProperty* property);
92 void SetPropertyX(bool selected, vtkProperty* property)
93 {
94 this->SetProperty(Axis::X_AXIS, selected, property);
95 }
96 void SetPropertyY(bool selected, vtkProperty* property)
97 {
98 this->SetProperty(Axis::Y_AXIS, selected, property);
99 }
100 void SetPropertyZ(bool selected, vtkProperty* property)
101 {
102 this->SetProperty(Axis::Z_AXIS, selected, property);
103 }
104 vtkProperty* GetProperty(int axis, bool selected);
105 vtkProperty* GetPropertyX(bool selected) { return this->GetProperty(Axis::X_AXIS, selected); }
106 vtkProperty* GetPropertyY(bool selected) { return this->GetProperty(Axis::Y_AXIS, selected); }
107 vtkProperty* GetPropertyZ(bool selected) { return this->GetProperty(Axis::Z_AXIS, selected); }
109
111
117 vtkSetClampMacro(TorusLength, double, MINIMUM_TORUS_LENGTH, MAXIMUM_TORUS_LENGTH);
118 vtkGetMacro(TorusLength, double);
120
122
129 vtkSetClampMacro(TorusThickness, double, MINIMUM_TORUS_THICKNESS, MAXIMUM_TORUS_THICKNESS);
130 vtkGetMacro(TorusThickness, double);
132
134
138 vtkSetMacro(ShowArrows, bool);
139 vtkGetMacro(ShowArrows, bool);
140 vtkBooleanMacro(ShowArrows, bool);
142
144
149 vtkSetClampMacro(ArrowDistance, double, MINIMUM_ARROW_DISTANCE, MAXIMUM_ARROW_DISTANCE);
150 vtkGetMacro(ArrowDistance, double);
152
154
162 vtkSetClampMacro(ArrowLength, double, MINIMUM_ARROW_LENGTH, MAXIMUM_ARROW_LENGTH);
163 vtkGetMacro(ArrowLength, double);
165
167
175 vtkSetMacro(ArrowTipLength, double);
176 vtkGetMacro(ArrowTipLength, double);
178
180
185 vtkSetClampMacro(ArrowTipRadius, double, MINIMUM_ARROW_TIP_RADIUS, MAXIMUM_ARROW_TIP_RADIUS);
186 vtkGetMacro(ArrowTipRadius, double);
188
190
195 vtkSetClampMacro(
196 ArrowShaftRadius, double, MINIMUM_ARROW_SHAFT_RADIUS, MAXIMUM_ARROW_SHAFT_RADIUS);
197 vtkGetMacro(ArrowShaftRadius, double);
199
201
204 void PlaceWidget(double bounds[6]) override;
205 void BuildRepresentation() override;
206 int ComputeInteractionState(int X, int Y, int modify = 0) override;
207 void StartWidgetInteraction(double e[2]) override;
208 void WidgetInteraction(double e[2]) override;
209 double* GetBounds() VTK_SIZEHINT(6) override;
211
213
216 void ReleaseGraphicsResources(vtkWindow*) override;
217 int RenderOpaqueGeometry(vtkViewport*) override;
218 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
219 vtkTypeBool HasTranslucentPolygonalGeometry() override;
221
231 void SetInteractionState(int state);
232
233 /*
234 * Register internal Pickers within PickingManager
235 */
236 void RegisterPickers() override;
237
243 void GetActors(vtkPropCollection*) override;
244
245 // Used to manage the state of the widget
246 enum
247 {
248 Outside = 0,
251 RotatingZ
252 };
253
254 // Used to select properties axis dependant
255 enum Axis : int
256 {
257 X_AXIS = 0,
259 Z_AXIS
260 };
261
262protected:
265
269
270private:
272 void operator=(const vtkOrientationRepresentation&) = delete;
273
277 void InitSources();
282 void InitTransforms();
283
288 void Rotate(const double p1[4], const double p2[4], const double baseVector[3]);
289
293 vtkSmartPointer<vtkPolyDataNormals> GetArrowsOutput(int axisIndex);
294
295 // Manage how the representation appears
296 double LastEventPosition[3] = { 0.0 };
297
298 // Support GetBounds() method
299 vtkNew<vtkBox> BoundingBox;
300
301 // Do the picking
302 vtkNew<vtkCellPicker> HandlePicker;
303 vtkSmartPointer<vtkProp> CurrentHandle;
304 vtkSmartPointer<vtkProp> LastHandle;
305
306 // Transform informations
307 vtkNew<vtkTransform> BaseTransform;
308 vtkNew<vtkTransform> OrientationTransform;
309
310 // Actors and geometry
311 vtkNew<vtkTransform> ArrowPosTransform;
312 vtkNew<vtkTransform> ArrowPosInvTransform;
313 vtkNew<vtkTransform> ArrowScaleTransform;
314 std::vector<vtkSmartPointer<vtkArrowSource>> ArrowSources;
315 std::vector<vtkSmartPointer<vtkSuperquadricSource>> TorusSources;
316 std::map<Axis, vtkNew<vtkActor>> TorusActors;
317 std::map<Axis, vtkNew<vtkActor>> ArrowsActors;
318 // Parameters used to control the appearance of selected objects and
319 // the manipulator in general.
320 std::map<Axis, vtkSmartPointer<vtkProperty>> Properties;
321 std::map<Axis, vtkSmartPointer<vtkProperty>> SelectedProperties;
322 // ... torus specific
323 double TorusLength = 7.5;
324 double TorusThickness = 0.005;
325 // ... arrow specific
326 bool ShowArrows = false;
327 double ArrowDistance = 0.0;
328 double ArrowLength = 0.05;
329 double ArrowTipLength = 1.0;
330 double ArrowTipRadius = 0.03;
331 double ArrowShaftRadius = 0.001;
332
333 // Minima/maxima to clamp values
334 static constexpr double MINIMUM_TORUS_THICKNESS = 0.001;
335 static constexpr double MAXIMUM_TORUS_THICKNESS = 0.1;
336 static constexpr double MINIMUM_TORUS_LENGTH = 0.01;
337 static constexpr double MAXIMUM_TORUS_LENGTH = 100.0;
338
339 static constexpr double MINIMUM_ARROW_DISTANCE = 0.0;
340 static constexpr double MAXIMUM_ARROW_DISTANCE = 0.5;
341 static constexpr double MINIMUM_ARROW_LENGTH = 0.01;
342 static constexpr double MAXIMUM_ARROW_LENGTH = 0.5;
343 static constexpr double MINIMUM_ARROW_TIP_RADIUS = 0.001;
344 static constexpr double MAXIMUM_ARROW_TIP_RADIUS = 0.5;
345 static constexpr double MINIMUM_ARROW_SHAFT_RADIUS = 0.001;
346 static constexpr double MAXIMUM_ARROW_SHAFT_RADIUS = 0.5;
347};
348
349VTK_ABI_NAMESPACE_END
350#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
Appends a cylinder to a cone to form an arrow.
implicit function for a bounding box
Definition vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:29
Allocate and hold a VTK object.
Definition vtkNew.h:51
a class defining the representation for the vtkOrientationWidget
virtual void SetOrientation(double values[3])
Set/Get the orientation values.
virtual void SetOrientationX(double value)
Set/Get the orientation values.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
vtkProperty * GetPropertyZ(bool selected)
Set/Get the properties values.
void SetPropertyX(bool selected, vtkProperty *property)
Set/Get the properties values.
static vtkOrientationRepresentation * New()
Instantiate the class.
vtkProperty * GetPropertyY(bool selected)
Set/Get the properties values.
~vtkOrientationRepresentation() override
void SetPropertyZ(bool selected, vtkProperty *property)
Set/Get the properties values.
double GetOrientationY()
Set/Get the orientation values.
virtual void SetOrientationZ(double value)
Set/Get the orientation values.
vtkProperty * GetProperty(int axis, bool selected)
Set/Get the properties values.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void SetOrientationY(double value)
Set/Get the orientation values.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetPropertyY(bool selected, vtkProperty *property)
Set/Get the properties values.
double GetOrientationZ()
Set/Get the orientation values.
vtkProperty * GetPropertyX(bool selected)
Set/Get the properties values.
double * GetOrientation()
Set/Get the orientation values.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
double GetOrientationX()
Set/Get the orientation values.
virtual void CreateDefaultProperties()
vtkTransform * GetTransform()
Get the orientation transform.
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetProperty(int axis, bool selected, vtkProperty *property)
Set/Get the properties values.
3D Widget for manipulating a vtkCamera
compute normals for polygonal mesh
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:57
Hold a reference to a vtkObjectBase instance.
create a polygonal superquadric centered at the origin
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)