VTK  9.7.1
vtkImplicitPlaneRepresentation.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
32 #ifndef vtkImplicitPlaneRepresentation_h
33 #define vtkImplicitPlaneRepresentation_h
34 
36 #include "vtkInteractionWidgetsModule.h" // For export macro
37 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
38 
39 VTK_ABI_NAMESPACE_BEGIN
40 class vtkActor;
41 class vtkBox;
42 class vtkCellPicker;
43 class vtkConeSource;
44 class vtkCutter;
45 class vtkFeatureEdges;
46 class vtkImageData;
47 class vtkLineSource;
48 class vtkLookupTable;
49 class vtkOutlineFilter;
50 class vtkPlane;
51 class vtkPlaneSource;
52 class vtkPolyData;
54 class vtkPolyDataMapper;
55 class vtkProperty;
56 class vtkSphereSource;
57 class vtkTransform;
58 class vtkTubeFilter;
59 
60 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitPlaneRepresentation
62 {
63 public:
68 
70 
74  void PrintSelf(ostream& os, vtkIndent indent) override;
76 
78 
81  void SetOrigin(double x, double y, double z);
82  void SetOrigin(double x[3]);
83  double* GetOrigin() VTK_SIZEHINT(3);
84  void GetOrigin(double xyz[3]);
86 
88 
91  void SetNormal(double x, double y, double z);
92  void SetNormal(double n[3]);
93  void SetNormalToCamera();
94  double* GetNormal() VTK_SIZEHINT(3);
95  void GetNormal(double xyz[3]);
97 
99 
106  void SetNormalToXAxis(vtkTypeBool);
107  vtkGetMacro(NormalToXAxis, vtkTypeBool);
108  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
109  void SetNormalToYAxis(vtkTypeBool);
110  vtkGetMacro(NormalToYAxis, vtkTypeBool);
111  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
112  void SetNormalToZAxis(vtkTypeBool);
113  vtkGetMacro(NormalToZAxis, vtkTypeBool);
114  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
116 
118 
123  virtual void SetLockNormalToCamera(vtkTypeBool);
124  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
125  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
127 
129 
133  vtkSetMacro(Tubing, vtkTypeBool);
134  vtkGetMacro(Tubing, vtkTypeBool);
135  vtkBooleanMacro(Tubing, vtkTypeBool);
137 
139 
145  void SetDrawPlane(vtkTypeBool plane);
146  vtkGetMacro(DrawPlane, vtkTypeBool);
147  vtkBooleanMacro(DrawPlane, vtkTypeBool);
149 
151 
154  void SetDrawOutline(vtkTypeBool plane);
155  vtkGetMacro(DrawOutline, vtkTypeBool);
156  vtkBooleanMacro(DrawOutline, vtkTypeBool);
158 
160 
163  vtkSetMacro(ScaleEnabled, vtkTypeBool);
164  vtkGetMacro(ScaleEnabled, vtkTypeBool);
165  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
167 
172  void GetPolyData(vtkPolyData* pd);
173 
178  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
179 
188  void GetPlane(vtkPlane* plane);
189 
196  void SetPlane(vtkPlane* plane);
197 
202  void UpdatePlacement();
203 
205 
208  vtkGetObjectMacro(NormalProperty, vtkProperty);
209  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
211 
213 
217  vtkGetObjectMacro(PlaneProperty, vtkProperty);
218  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
220 
222 
226  vtkGetObjectMacro(EdgesProperty, vtkProperty);
228 
230 
235  void SetInteractionColor(double, double, double);
236  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
237  void SetHandleColor(double, double, double);
238  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
239  void SetForegroundColor(double, double, double);
240  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
242 
244 
247  void SetEdgeColor(vtkLookupTable*);
248  void SetEdgeColor(double, double, double);
249  void SetEdgeColor(double c[3]);
251 
253 
258  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
259  vtkGetMacro(BumpDistance, double);
261 
270  void BumpPlane(int dir, double factor);
271 
278  void PushPlane(double distance);
279 
281 
284  int ComputeInteractionState(int X, int Y, int modify = 0) override;
285  void PlaceWidget(double bounds[6]) override;
286  void BuildRepresentation() override;
287  void StartWidgetInteraction(double eventPos[2]) override;
288  void WidgetInteraction(double newEventPos[2]) override;
289  void EndWidgetInteraction(double newEventPos[2]) override;
291  unsigned long event, void* calldata) override;
293  unsigned long event, void* calldata) override;
295  unsigned long event, void* calldata, int modify = 0) override;
297  unsigned long event, void* calldata) override;
299 
301 
304  double* GetBounds() VTK_SIZEHINT(6) override;
305  void GetActors(vtkPropCollection* pc) override;
306  void ReleaseGraphicsResources(vtkWindow*) override;
307  int RenderOpaqueGeometry(vtkViewport*) override;
308  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
309  vtkTypeBool HasTranslucentPolygonalGeometry() override;
311 
312  // Manage the state of the widget
314  {
315  Outside = 0,
321  Scaling
322  };
323 
325 
334  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
336 
338 
342  virtual void SetRepresentationState(int);
343  vtkGetMacro(RepresentationState, int);
345 
346  // Get the underlying implicit plane object used by this rep
347  // that can be used as a cropping plane in vtkMapper.
348  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
349 
351 
355  virtual void SetCropPlaneToBoundingBox(bool);
356  vtkGetMacro(CropPlaneToBoundingBox, bool);
357  vtkBooleanMacro(CropPlaneToBoundingBox, bool);
359 
361 
365  vtkGetMacro(SnapToAxes, bool);
366  vtkSetMacro(SnapToAxes, bool);
368 
370 
376  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
377  virtual void SetAlwaysSnapToNearestAxis(bool snap)
378  {
379  this->AlwaysSnapToNearestAxis = snap;
380  this->SetNormal(this->GetNormal());
381  }
383 
384 protected:
386  ~vtkImplicitPlaneRepresentation() override;
387 
389 
390  // Keep track of event positions
391  double LastEventPosition[3];
392  double LastEventOrientation[4];
393  double StartEventOrientation[4];
394 
395  // Controlling ivars
399 
400  double SnappedEventOrientation[4];
403 
405 
406  // Locking normal to camera
408 
409  // Controlling the push operation
410  double BumpDistance;
411 
412  // The actual plane which is being manipulated
414 
415  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
416 
417  // The cut plane is produced with a vtkCutter
419  vtkPlaneSource* PlaneSource; // used when plane cropping disabled
424  void HighlightPlane(int highlight);
425 
426  // Optional tubes are represented by extracting boundary edges and tubing
431  vtkTypeBool Tubing; // control whether tubing is on
432 
433  // The + normal cone
437  void HighlightNormal(int highlight);
438 
439  // The normal line
443 
444  // The - normal cone
448 
449  // The origin positioning handle
453 
454  // Do the picking
456 
457  // Register internal Pickers within PickingManager
458  void RegisterPickers() override;
459 
460  // Transform the normal (used for rotation)
462 
463  // Methods to manipulate the plane
464  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
465  void Rotate3D(double* p1, double* p2);
466  void TranslateRepresentation(const vtkVector3d&) override;
467  void TranslateOrigin(double* p1, double* p2);
468  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
469  void Push(double* p1, double* p2);
470  void Scale(double* p1, double* p2, double X, double Y);
471  void SizeHandles();
472 
473  // Properties used to control the appearance of selected objects and
474  // the manipulator in general.
482  void CreateDefaultProperties() override;
483 
485 
486  // Support GetBounds() method
488 
489 private:
491  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
492 };
493 
494 VTK_ABI_NAMESPACE_END
495 #endif
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:61
virtual void EndWidgetInteraction(double newEventPos[2])
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.
virtual int ComputeInteractionState(int X, int Y, int modify=0)
virtual void CreateDefaultProperties()
Create and initialize properties with default values.
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])
virtual int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *callData, int modify=0)
map scalar values into colors via a lookup table
virtual void ComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
virtual void EndComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
void SetInteractionColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void StartComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
generate polygonal cone
Definition: vtkConeSource.h:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
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
platform-independent render window interaction including picking and frame rate control.
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
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.
a class defining the representation for a vtkImplicitPlaneWidget2
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
void SetHandleColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void TranslateRepresentation(const vtkVector3d &)
Translate the representation, to be implemented in derived class.
perform various plane computations
Definition: vtkPlane.h:31
void SetForegroundColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void WidgetInteraction(double newEventPos[2])
#define VTK_SIZEHINT(...)
create an array of quadrilaterals located in a plane
#define VTK_MARSHALEXCLUDE(reason)
define the API for widget / widget representation
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...
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
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
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
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL