VTK  9.7.1
vtkImplicitConeRepresentation.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
30 #ifndef vtkImplicitConeRepresentation_h
31 #define vtkImplicitConeRepresentation_h
32 
34 #include "vtkInteractionWidgetsModule.h" // For export macro
35 #include "vtkVector.h" // For vtkVector3d
36 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkActor;
40 class vtkPolyDataMapper;
41 class vtkConeSource;
42 class vtkLineSource;
43 class vtkSphereSource;
44 class vtkTubeFilter;
45 class vtkCone;
46 class vtkProperty;
47 class vtkImageData;
48 class vtkPolyData;
49 class vtkBox;
50 class vtkCellPicker;
51 
52 #define VTK_MAX_CONE_RESOLUTION 2048
53 
54 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitConeRepresentation
56 {
57 public:
58  // Manage the state of the widget
60  {
61  Outside = 0,
62  Moving, // Generic state set by the widget
68  TranslatingOrigin
69  };
70 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
76 
80  void SetOrigin(double x, double y, double z);
81  void SetOrigin(double x[3]);
82  double* GetOrigin() VTK_SIZEHINT(3);
83  void GetOrigin(double xyz[3]);
85 
87 
91  void SetAxis(double x, double y, double z);
92  void SetAxis(double a[3]);
93  double* GetAxis() VTK_SIZEHINT(3);
94  void GetAxis(double a[3]);
96 
98 
101  void SetAngle(double r);
102  double GetAngle();
104 
106 
114  void SetAlongXAxis(bool);
115  vtkGetMacro(AlongXAxis, bool);
116  vtkBooleanMacro(AlongXAxis, bool);
117  void SetAlongYAxis(bool);
118  vtkGetMacro(AlongYAxis, bool);
119  vtkBooleanMacro(AlongYAxis, bool);
120  void SetAlongZAxis(bool);
121  vtkGetMacro(AlongZAxis, bool);
122  vtkBooleanMacro(AlongZAxis, bool);
124 
126 
132  void SetDrawCone(bool draw);
133  vtkGetMacro(DrawCone, bool);
134  vtkBooleanMacro(DrawCone, bool);
136 
138 
145  vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CONE_RESOLUTION);
146  vtkGetMacro(Resolution, int);
148 
150 
156  vtkSetMacro(Tubing, bool);
157  vtkGetMacro(Tubing, bool);
158  vtkBooleanMacro(Tubing, bool);
160 
162 
166  vtkSetMacro(ScaleEnabled, bool);
167  vtkGetMacro(ScaleEnabled, bool);
168  vtkBooleanMacro(ScaleEnabled, bool);
170 
175  void GetPolyData(vtkPolyData* pd);
176 
181  void UpdatePlacement();
182 
184 
187  vtkGetObjectMacro(AxisProperty, vtkProperty);
188  vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
190 
192 
196  vtkGetObjectMacro(ConeProperty, vtkProperty);
197  vtkGetObjectMacro(SelectedConeProperty, vtkProperty);
199 
201 
205  vtkGetObjectMacro(EdgesProperty, vtkProperty);
207 
209 
214  void SetInteractionColor(double, double, double);
215  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
216  void SetHandleColor(double, double, double);
217  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
218  void SetForegroundColor(double, double, double);
219  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
221 
223 
226  int ComputeInteractionState(int X, int Y, int modify = 0) override;
227  void PlaceWidget(double bounds[6]) override;
228  void BuildRepresentation() override;
229  void StartWidgetInteraction(double eventPos[2]) override;
230  void WidgetInteraction(double newEventPos[2]) override;
231  void EndWidgetInteraction(double newEventPos[2]) override;
233 
235 
238  double* GetBounds() override;
239  void GetActors(vtkPropCollection* pc) override;
240  void ReleaseGraphicsResources(vtkWindow*) override;
241  int RenderOpaqueGeometry(vtkViewport*) override;
245 
247 
253  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
254  vtkGetMacro(BumpDistance, double);
256 
264  void BumpCone(int dir, double factor);
265 
272  void PushCone(double distance);
273 
283  vtkSetClampMacro(InteractionState, InteractionStateType, InteractionStateType::Outside,
284  InteractionStateType::TranslatingOrigin);
285 
287 
291  virtual void SetRepresentationState(InteractionStateType);
292  vtkGetMacro(RepresentationState, InteractionStateType);
294 
295  /*
296  * Register internal Pickers within PickingManager
297  */
298  void RegisterPickers() override;
299 
300  void GetCone(vtkCone* cone) const;
301 
302 protected:
304  ~vtkImplicitConeRepresentation() override;
305 
306  // The actual cone we're manipulating
308 
309  InteractionStateType RepresentationState = InteractionStateType::Outside;
310 
311  // Keep track of event positions
313 
314  // Controlling the push operation
315  double BumpDistance = 0.01;
316 
317  // Controlling ivars
318  bool AlongXAxis = false;
319  bool AlongYAxis = false;
320  bool AlongZAxis = false;
321 
322  // The facet resolution for rendering purposes.
323  int Resolution = 128;
324 
325  bool ScaleEnabled = true; // whether the widget can be scaled
326 
330  bool DrawCone = true;
331 
332  // Optional tubes are represented by extracting boundary edges and tubing
337  bool Tubing = true; // control whether tubing is on
338 
339  // The axis line
343 
344  // Axis line arrow
348 
349  // The origin positioning handle
353 
354  // Do the picking
357 
358  // Properties used to control the appearance of selected objects and
359  // the manipulator in general.
367 
368  // Support GetBounds() method
370 
371  void HighlightCone(bool highlight);
372  void HighlightOriginHandle(bool highlight);
373  void HighlightAxis(bool highlight);
374 
375  // Methods to manipulate the cone
376  void Rotate(
377  double X, double Y, const vtkVector3d& p1, const vtkVector3d& p2, const vtkVector3d& vpn);
378  void TranslateCone(const vtkVector3d& p1, const vtkVector3d& p2);
379  void TranslateRepresentation(const vtkVector3d& motion) override;
380  void TranslateOrigin(const vtkVector3d& p1, const vtkVector3d& p2);
381  void TranslateOriginOnAxis(const vtkVector3d& p1, const vtkVector3d& p2);
382  void ScaleAngle(const vtkVector3d& p1, const vtkVector3d& p2);
383  void AdjustAngle(double X, double Y, const vtkVector3d& p1, const vtkVector3d& p2);
384  void Scale(const vtkVector3d& p1, const vtkVector3d& p2, double X, double Y);
385  void SizeHandles();
386 
387  // Intersect oriented infinite cone against bounding box
388  void BuildCone();
389 
391  void operator=(const vtkImplicitConeRepresentation&) = delete;
392 };
393 
394 VTK_ABI_NAMESPACE_END
395 #endif
virtual void EndWidgetInteraction(double newEventPos[2])
implicit function for a cone
Definition: vtkCone.h:31
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.
vtkNew< vtkSphereSource > OriginHandleSource
virtual int ComputeInteractionState(int X, int Y, int modify=0)
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])
vtkNew< vtkPolyDataMapper > AxisArrowMapper
void SetInteractionColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
generate polygonal cone
Definition: vtkConeSource.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
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
filter that generates tubes around lines
Definition: vtkTubeFilter.h:75
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void TranslateRepresentation(const vtkVector3d &)
Translate the representation, to be implemented in derived class.
virtual void WidgetInteraction(double newEventPos[2])
void SetHandleColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
vtkNew< vtkPolyDataMapper > ConePDMapper
#define VTK_SIZEHINT(...)
create a line defined by two end points
Definition: vtkLineSource.h:53
map vtkPolyData to graphics primitives
Extends the vtkWidgetRepresentation to help positioning widget in space and how it should be displaye...
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkNew< vtkPolyDataMapper > AxisLineMapper
void SetForegroundColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
#define VTK_MARSHALAUTO
defining the representation for a vtkImplicitConeWidget
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:30
vtkNew< vtkPolyDataMapper > OriginHandleMapper
#define VTK_MAX_CONE_RESOLUTION