VTK  9.3.20240416
vtkPointHandleRepresentation3D.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
18 #ifndef vtkPointHandleRepresentation3D_h
19 #define vtkPointHandleRepresentation3D_h
20 
21 #include "vtkCursor3D.h" // Needed for delegation to cursor3D
23 #include "vtkInteractionWidgetsModule.h" // For export macro
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkCursor3D;
27 class vtkProperty;
28 class vtkActor;
29 class vtkPolyDataMapper;
30 class vtkCellPicker;
31 
32 class VTKINTERACTIONWIDGETS_EXPORT vtkPointHandleRepresentation3D : public vtkHandleRepresentation
33 {
34 public:
39 
41 
45  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
49 
51 
58  void SetWorldPosition(double p[3]) override;
59  void SetDisplayPosition(double p[3]) override;
61 
65  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
66  int GetOutline() { return this->Cursor3D->GetOutline(); }
67  void OutlineOn() { this->Cursor3D->OutlineOn(); }
68  void OutlineOff() { this->Cursor3D->OutlineOff(); }
69 
73  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
74  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
75  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
76  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
77 
81  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
82  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
83  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
84  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
85 
89  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
90  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
91  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
92  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
93 
95 
107  vtkGetMacro(TranslationMode, vtkTypeBool);
108  vtkBooleanMacro(TranslationMode, vtkTypeBool);
110 
112 
115  void AllOn()
116  {
117  this->OutlineOn();
118  this->XShadowsOn();
119  this->YShadowsOn();
120  this->ZShadowsOn();
121  }
122  void AllOff()
123  {
124  this->OutlineOff();
125  this->XShadowsOff();
126  this->YShadowsOff();
127  this->ZShadowsOff();
128  }
130 
132 
137  vtkGetObjectMacro(Property, vtkProperty);
138  vtkGetObjectMacro(SelectedProperty, vtkProperty);
140 
142 
145  void SetInteractionColor(double, double, double);
146  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
147  void SetForegroundColor(double, double, double);
148  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
150 
152 
158  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
159  vtkGetMacro(HotSpotSize, double);
161 
165  void SetHandleSize(double size) override;
166 
168 
171  double* GetBounds() VTK_SIZEHINT(6) override;
172  void BuildRepresentation() override;
173  void StartWidgetInteraction(double eventPos[2]) override;
174  void WidgetInteraction(double eventPos[2]) override;
175  int ComputeInteractionState(int X, int Y, int modify = 0) override;
176  void PlaceWidget(double bounds[6]) override;
177  void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
178  unsigned long event, void* calldata) override;
179  void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
180  unsigned long event, void* calldata) override;
181  int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
182  unsigned long event, void* calldata, int modify = 0) override;
184 
186 
189  void ShallowCopy(vtkProp* prop) override;
190  void DeepCopy(vtkProp* prop) override;
191  void GetActors(vtkPropCollection*) override;
192  void ReleaseGraphicsResources(vtkWindow*) override;
193  int RenderOpaqueGeometry(vtkViewport* viewport) override;
194  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
195  vtkTypeBool HasTranslucentPolygonalGeometry() override;
197 
198  void Highlight(int highlight) override;
199 
201 
212  vtkSetMacro(SmoothMotion, vtkTypeBool);
213  vtkGetMacro(SmoothMotion, vtkTypeBool);
214  vtkBooleanMacro(SmoothMotion, vtkTypeBool);
216 
217  /*
218  * Register internal Pickers within PickingManager
219  */
220  void RegisterPickers() override;
221 
228  void SetVisibility(vtkTypeBool visible) override;
229 
230 protected:
233 
234  // the cursor3D
235  vtkActor* Actor;
237  vtkCursor3D* Cursor3D;
238 
239  // Do the picking
240  vtkCellPicker* CursorPicker;
241  double LastPickPosition[3];
242  double LastEventPosition[3];
243 
244  // Methods to manipulate the cursor
245  int ConstraintAxis;
246  void Translate(const double* p1, const double* p2) override;
247  void Scale(const double* p1, const double* p2, const double eventPos[2]);
248  void MoveFocus(const double* p1, const double* p2);
249  void SizeBounds();
250 
262  void MoveFocusRequest(
263  const double* p1, const double* p2, const double currPos[2], double center[3]);
264 
265  // Properties used to control the appearance of selected objects and
266  // the manipulator in general.
267  vtkProperty* Property;
268  vtkProperty* SelectedProperty;
269  void CreateDefaultProperties();
270 
271  // The size of the hot spot.
272  double HotSpotSize;
273  int DetermineConstraintAxis(int constraint, double* x, double* startPoint);
274  int WaitingForMotion;
275  int WaitCount;
276 
277  // Current handle sized (may reflect scaling)
278  double CurrentHandleSize;
279 
280  // Control how translation works
281  vtkTypeBool TranslationMode;
282 
283  vtkTypeBool SmoothMotion;
284 
285 private:
287  void operator=(const vtkPointHandleRepresentation3D&) = delete;
288 };
289 
290 VTK_ABI_NAMESPACE_END
291 #endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:151
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:91
generate a 3D cursor representation
Definition: vtkCursor3D.h:48
abstract class for representing widget handles
virtual void Translate(const double *p1, const double *p2)
Translates world position by vector p1p2 projected on the constraint axis if any.
a simple class to control print indentation
Definition: vtkIndent.h:108
represent the position of a point in 3D space
void AllOn()
Convenience methods to turn outline and shadows on and off.
void SetHandleSize(double size) override
Overload the superclasses SetHandleSize() method to update internal variables.
void AllOff()
Convenience methods to turn outline and shadows on and off.
void SetYShadows(int o)
Turn on/off the wireframe y-shadows.
void SetInteractionColor(double, double, double)
Set the widget color, and the color of interactive handles.
void SetForegroundColor(double, double, double)
Set the widget color, and the color of interactive handles.
void SetOutline(int o)
Turn on/off the wireframe bounding box.
double * GetBounds() override
Methods to make this class properly act like a vtkWidgetRepresentation.
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
void SetProperty(vtkProperty *)
Set/Get the handle properties when unselected and selected.
void SetZShadows(int o)
Turn on/off the wireframe z-shadows.
void SetXShadows(int o)
Turn on/off the wireframe x-shadows.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
static vtkPointHandleRepresentation3D * New()
Instantiate this class.
void SetTranslationMode(vtkTypeBool mode)
If translation mode is on, as the widget is moved the bounding box, shadows, and cursor are all trans...
void SetSelectedProperty(vtkProperty *)
Set/Get the handle properties when unselected and selected.
void SetDisplayPosition(double p[3]) override
Set the position of the point in world and display coordinates.
void SetForegroundColor(double c[3])
Set the widget color, and the color of interactive handles.
void SetWorldPosition(double p[3]) override
Set the position of the point in world and display coordinates.
map vtkPolyData to graphics primitives
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
represent surface properties of a geometric object
Definition: vtkProperty.h:167
platform-independent render window interaction including picking and frame rate control.
abstract specification for Viewports
Definition: vtkViewport.h:65
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ mode
Definition: vtkX3D.h:247
@ center
Definition: vtkX3D.h:230
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)