VTK  9.1.0
vtkImplicitCylinderRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImplicitCylinderRepresentation.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 =========================================================================*/
39 #ifndef vtkImplicitCylinderRepresentation_h
40 #define vtkImplicitCylinderRepresentation_h
41 
42 #include "vtkInteractionWidgetsModule.h" // For export macro
44 
45 class vtkActor;
46 class vtkPolyDataMapper;
47 class vtkCellPicker;
48 class vtkConeSource;
49 class vtkLineSource;
50 class vtkSphereSource;
51 class vtkTubeFilter;
52 class vtkCylinder;
53 class vtkProperty;
54 class vtkImageData;
55 class vtkOutlineFilter;
56 class vtkFeatureEdges;
57 class vtkPolyData;
59 class vtkTransform;
60 class vtkBox;
61 class vtkLookupTable;
62 
63 #define VTK_MAX_CYL_RESOLUTION 2048
64 
65 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation
67 {
68 public:
73 
75 
79  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
83 
87  void SetCenter(double x, double y, double z);
88  void SetCenter(double x[3]);
89  double* GetCenter() VTK_SIZEHINT(3);
90  void GetCenter(double xyz[3]);
92 
94 
98  void SetAxis(double x, double y, double z);
99  void SetAxis(double a[3]);
100  double* GetAxis() VTK_SIZEHINT(3);
101  void GetAxis(double a[3]);
103 
105 
109  void SetRadius(double r);
110  double GetRadius();
112 
114 
121  vtkSetClampMacro(MinRadius, double, 0.001, 0.25);
122  vtkGetMacro(MinRadius, double);
123  vtkSetClampMacro(MaxRadius, double, 0.25, VTK_FLOAT_MAX);
124  vtkGetMacro(MaxRadius, double);
126 
128 
135  void SetAlongXAxis(vtkTypeBool);
136  vtkGetMacro(AlongXAxis, vtkTypeBool);
137  vtkBooleanMacro(AlongXAxis, vtkTypeBool);
138  void SetAlongYAxis(vtkTypeBool);
139  vtkGetMacro(AlongYAxis, vtkTypeBool);
140  vtkBooleanMacro(AlongYAxis, vtkTypeBool);
141  void SetAlongZAxis(vtkTypeBool);
142  vtkGetMacro(AlongZAxis, vtkTypeBool);
143  vtkBooleanMacro(AlongZAxis, vtkTypeBool);
145 
147 
153  void SetDrawCylinder(vtkTypeBool drawCyl);
154  vtkGetMacro(DrawCylinder, vtkTypeBool);
155  vtkBooleanMacro(DrawCylinder, vtkTypeBool);
157 
159 
165  vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CYL_RESOLUTION);
166  vtkGetMacro(Resolution, int);
168 
170 
175  vtkSetMacro(Tubing, vtkTypeBool);
176  vtkGetMacro(Tubing, vtkTypeBool);
177  vtkBooleanMacro(Tubing, vtkTypeBool);
179 
181 
185  vtkSetMacro(OutlineTranslation, vtkTypeBool);
186  vtkGetMacro(OutlineTranslation, vtkTypeBool);
187  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
189 
191 
195  vtkSetMacro(OutsideBounds, vtkTypeBool);
196  vtkGetMacro(OutsideBounds, vtkTypeBool);
197  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
199 
201 
207  vtkSetVector6Macro(WidgetBounds, double);
208  vtkGetVector6Macro(WidgetBounds, double);
210 
212 
220  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
221  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
222  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
224 
226 
229  vtkSetMacro(ScaleEnabled, vtkTypeBool);
230  vtkGetMacro(ScaleEnabled, vtkTypeBool);
231  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
233 
240  void GetCylinder(vtkCylinder* cyl);
241 
246  void GetPolyData(vtkPolyData* pd);
247 
252  void UpdatePlacement(void);
253 
255 
258  vtkGetObjectMacro(AxisProperty, vtkProperty);
259  vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
261 
263 
267  vtkGetObjectMacro(CylinderProperty, vtkProperty);
268  vtkGetObjectMacro(SelectedCylinderProperty, vtkProperty);
270 
272 
275  vtkGetObjectMacro(OutlineProperty, vtkProperty);
276  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
278 
280 
284  vtkGetObjectMacro(EdgesProperty, vtkProperty);
287 
290  void SetEdgeColor(vtkLookupTable*);
291  void SetEdgeColor(double, double, double);
292  void SetEdgeColor(double c[3]);
294 
296 
299  int ComputeInteractionState(int X, int Y, int modify = 0) override;
300  void PlaceWidget(double bounds[6]) override;
301  void BuildRepresentation() override;
302  void StartWidgetInteraction(double eventPos[2]) override;
303  void WidgetInteraction(double newEventPos[2]) override;
304  void EndWidgetInteraction(double newEventPos[2]) override;
306 
308 
311  double* GetBounds() override;
312  void GetActors(vtkPropCollection* pc) override;
313  void ReleaseGraphicsResources(vtkWindow*) override;
314  int RenderOpaqueGeometry(vtkViewport*) override;
315  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
316  vtkTypeBool HasTranslucentPolygonalGeometry() override;
318 
320 
325  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
326  vtkGetMacro(BumpDistance, double);
328 
336  void BumpCylinder(int dir, double factor);
337 
344  void PushCylinder(double distance);
345 
346  // Manage the state of the widget
348  {
349  Outside = 0,
356  TranslatingCenter
357  };
358 
360 
369  vtkSetClampMacro(InteractionState, int, Outside, TranslatingCenter);
371 
373 
377  virtual void SetRepresentationState(int);
378  vtkGetMacro(RepresentationState, int);
380 
381  /*
382  * Register internal Pickers within PickingManager
383  */
384  void RegisterPickers() override;
385 
387 
391  vtkGetMacro(TranslationAxis, int);
392  vtkSetClampMacro(TranslationAxis, int, -1, 2);
394 
396 
399  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
400  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
401  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
402  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
404 
406 
409  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
411 
412 protected:
415 
417 
419 
420  // Keep track of event positions
421  double LastEventPosition[3];
422 
423  // Control the radius
424  double MinRadius;
425  double MaxRadius;
426 
427  // Controlling the push operation
428  double BumpDistance;
429 
430  // Controlling ivars
434 
435  // The actual cylinder which is being manipulated
437 
438  // The facet resolution for rendering purposes.
440 
441  // The bounding box is represented by a single voxel image data
446  void HighlightOutline(int highlight);
447  vtkTypeBool OutlineTranslation; // whether the outline can be moved
448  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
449  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
450  double WidgetBounds[6];
452 
453  // The cut cylinder is produced with a vtkCutter
458  void HighlightCylinder(int highlight);
459 
460  // Optional tubes are represented by extracting boundary edges and tubing
465  vtkTypeBool Tubing; // control whether tubing is on
466 
467  // The + normal cone (i.e., in positive direction along normal)
471  void HighlightNormal(int highlight);
472 
473  // The + normal line
477 
478  // The - normal cone
482 
483  // The - normal line
487 
488  // The center positioning handle
492 
493  // Do the picking
496 
497  // Transform the normal (used for rotation)
499 
500  // Methods to manipulate the cylinder
501  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
502  void TranslateCylinder(double* p1, double* p2);
503  void TranslateOutline(double* p1, double* p2);
504  void TranslateCenter(double* p1, double* p2);
505  void TranslateCenterOnAxis(double* p1, double* p2);
506  void ScaleRadius(double* p1, double* p2);
507  void AdjustRadius(double X, double Y, double* p1, double* p2);
508  void Scale(double* p1, double* p2, double X, double Y);
509  void SizeHandles();
510 
511  // Properties used to control the appearance of selected objects and
512  // the manipulator in general.
521 
522  // Intersect oriented infinite cylinder against bounding box
524 
525  // Support GetBounds() method
527 
528 private:
530  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
531 };
532 
533 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
implicit function for a bounding box
Definition: vtkBox.h:39
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
generate polygonal cone
Definition: vtkConeSource.h:39
implicit function for a cylinder
Definition: vtkCylinder.h:42
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
defining the representation for a vtkImplicitCylinderWidget
void HighlightOutline(int highlight)
void HighlightCylinder(int highlight)
void HighlightNormal(int highlight)
void TranslateCylinder(double *p1, double *p2)
void TranslateCenterOnAxis(double *p1, double *p2)
void ScaleRadius(double *p1, double *p2)
double * GetCenter()
Get the center of the cylinder.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void AdjustRadius(double X, double Y, double *p1, double *p2)
void TranslateOutline(double *p1, double *p2)
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetCenter(double x, double y, double z)
Get the center of the cylinder.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
void Rotate(double X, double Y, double *p1, double *p2, double *vpn)
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void Scale(double *p1, double *p2, double X, double Y)
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void TranslateCenter(double *p1, double *p2)
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void SetCenter(double x[3])
Get the center of the cylinder.
static vtkImplicitCylinderRepresentation * New()
Instantiate the class.
a simple class to control print indentation
Definition: vtkIndent.h:34
create a line defined by two end points
Definition: vtkLineSource.h:61
map scalar values into colors via a lookup table
create wireframe outline for an arbitrary data set or composite dataset
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
filter that generates tubes around lines
Definition: vtkTubeFilter.h:80
abstract specification for Viewports
Definition: vtkViewport.h:47
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
void GetBounds(T a, double bds[6])
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_MAX_CYL_RESOLUTION
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
#define VTK_SIZEHINT(...)