10 #ifndef vtkConeRepresentation_h
11 #define vtkConeRepresentation_h
13 #include "smtk/extension/vtk/widgets/vtkSMTKWidgetsExtModule.h"
15 #include "vtkVector.h"
16 #include "vtkWidgetRepresentation.h"
21 class vtkPolyDataMapper;
24 class vtkGlyph3DMapper;
26 class vtkSphereSource;
31 class vtkOutlineFilter;
32 class vtkFeatureEdges;
34 class vtkPolyDataAlgorithm;
39 #define VTK_MAX_CONE_RESOLUTION 2048
67 void PrintSelf(ostream& os, vtkIndent indent)
override;
77 bool SetEndpoint(
bool isBottom,
double x,
double y,
double z);
78 bool SetEndpoint(
bool isBottom,
const vtkVector3d& pt);
79 vtkVector3d GetEndpoint(
bool isBottom)
const;
81 bool SetBottomEndpoint(
double x,
double y,
double z) {
return this->SetEndpoint(
true, x, y, z); }
82 bool SetBottomEndpoint(
const vtkVector3d& pt) {
return this->SetEndpoint(
true, pt); }
83 vtkVector3d GetBottomEndpoint()
const {
return this->GetEndpoint(
true); }
84 void SetBottomPoint(
double x,
double y,
double z) { this->SetEndpoint(
true, x, y, z); }
85 void SetBottomPoint(
double* x) VTK_SIZEHINT(3) { this->SetEndpoint(
true, x[0], x[1], x[2]); }
86 double* GetBottomPoint() VTK_SIZEHINT(3);
88 bool SetTopEndpoint(
double x,
double y,
double z) {
return this->SetEndpoint(
false, x, y, z); }
89 bool SetTopEndpoint(
const vtkVector3d& pt) {
return this->SetEndpoint(
false, pt); }
90 vtkVector3d GetTopEndpoint()
const {
return this->GetEndpoint(
false); }
91 void SetTopPoint(
double x,
double y,
double z) { this->SetEndpoint(
false, x, y, z); }
92 void SetTopPoint(
double* x) VTK_SIZEHINT(3) { this->SetEndpoint(
false, x[0], x[1], x[2]); }
93 double* GetTopPoint() VTK_SIZEHINT(3);
103 bool SetRadius(
bool isBottom,
double r);
104 double GetRadius(
bool isBottom) const;
106 bool SetBottomRadius(
double r) {
return this->SetRadius(
true, r); }
107 double GetBottomRadius()
const {
return this->GetRadius(
true); }
109 bool SetTopRadius(
double r) {
return this->SetRadius(
false, r); }
110 double GetTopRadius()
const {
return this->GetRadius(
false); }
120 bool SetCylindrical(
int);
121 vtkGetMacro(Cylindrical,
int);
122 vtkBooleanMacro(Cylindrical,
int);
133 void SetAlongXAxis(vtkTypeBool);
134 vtkGetMacro(AlongXAxis, vtkTypeBool);
135 vtkBooleanMacro(AlongXAxis, vtkTypeBool);
136 void SetAlongYAxis(vtkTypeBool);
137 vtkGetMacro(AlongYAxis, vtkTypeBool);
138 vtkBooleanMacro(AlongYAxis, vtkTypeBool);
139 void SetAlongZAxis(vtkTypeBool);
140 vtkGetMacro(AlongZAxis, vtkTypeBool);
141 vtkBooleanMacro(AlongZAxis, vtkTypeBool);
151 void SetDrawCone(vtkTypeBool drawCyl);
152 vtkGetMacro(DrawCone, vtkTypeBool);
153 vtkBooleanMacro(DrawCone, vtkTypeBool);
163 vtkSetClampMacro(Resolution,
int, 8, VTK_MAX_CONE_RESOLUTION);
164 vtkGetMacro(Resolution,
int);
177 vtkSetClampMacro(Tolerance,
double, 0.0, VTK_DOUBLE_MAX);
178 vtkGetMacro(Tolerance,
double);
187 vtkSetMacro(Tubing, vtkTypeBool);
188 vtkGetMacro(Tubing, vtkTypeBool);
189 vtkBooleanMacro(Tubing, vtkTypeBool);
196 vtkSetMacro(ScaleEnabled, vtkTypeBool);
197 vtkGetMacro(ScaleEnabled, vtkTypeBool);
198 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
214 void UpdatePlacement();
220 vtkGetObjectMacro(HandleProperty, vtkProperty);
221 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
229 vtkGetObjectMacro(ConeProperty, vtkProperty);
230 vtkGetObjectMacro(SelectedConeProperty, vtkProperty);
238 vtkGetObjectMacro(EdgeProperty, vtkProperty);
245 int ComputeInteractionState(
int X,
int Y,
int modify = 0)
override;
246 void PlaceWidget(
double bounds[6])
override;
247 void BuildRepresentation()
override;
248 void StartWidgetInteraction(
double eventPos[2])
override;
249 void WidgetInteraction(
double newEventPos[2])
override;
250 void EndWidgetInteraction(
double newEventPos[2])
override;
257 double* GetBounds()
override;
258 void GetActors(vtkPropCollection* pc)
override;
259 void ReleaseGraphicsResources(vtkWindow*)
override;
260 int RenderOpaqueGeometry(vtkViewport*)
override;
261 int RenderTranslucentPolygonalGeometry(vtkViewport*)
override;
262 vtkTypeBool HasTranslucentPolygonalGeometry()
override;
271 vtkSetClampMacro(BumpDistance,
double, 0.000001, 1);
272 vtkGetMacro(BumpDistance,
double);
282 void BumpCone(
int dir,
double factor);
290 void PushCone(
double distance);
293 enum _InteractionState
299 AdjustingBottomRadius,
309 static std::string InteractionStateToString(
int);
321 vtkSetClampMacro(InteractionState,
int, Outside, TranslatingCenter);
329 virtual void SetRepresentationState(
int);
330 vtkGetMacro(RepresentationState,
int);
336 void RegisterPickers()
override;
339 void SwapTopAndBottom();
359 void HighlightElement(ElementType elem,
int highlight);
361 void HighlightCone(
int highlight);
362 void HighlightAxis(
int highlight);
363 void HighlightCap(
bool isBottom,
int highlight);
364 void HighlightCurve(
bool isBottom,
int highlight);
365 void HighlightHandle(
bool isBottom,
int highlight);
368 void Rotate(
double X,
double Y,
double* p1,
double* p2,
double* vpn);
369 void TranslateCone(
double* p1,
double* p2);
370 void PushCap(
bool isBottom,
double* p1,
double* p2);
371 void AdjustBottomRadius(
double X,
double Y,
double* p1,
double* p2);
372 void AdjustTopRadius(
double X,
double Y,
double* p1,
double* p2);
373 void TranslateCenter(
double* p1,
double* p2);
374 void TranslateCenterOnAxis(
double* p1,
double* p2);
375 void TranslateHandle(
bool isBottom,
double* p1,
double* p2);
376 void Scale(
double* p1,
double* p2,
double X,
double Y);
379 void CreateDefaultProperties();
383 vtkNew<vtkActor> Actor;
384 vtkNew<vtkPolyDataMapper> Mapper;
388 std::array<Element, NumberOfElements> Elements;
390 int RepresentationState;
392 double LastEventPosition[3];
394 double BumpDistance{ 0.01 };
396 vtkTypeBool AlongXAxis{ 0 };
397 vtkTypeBool AlongYAxis{ 0 };
398 vtkTypeBool AlongZAxis{ 0 };
400 vtkNew<vtkConeFrustum> Cone;
402 int Resolution{ 128 };
403 double Tolerance{ 1e-8 };
404 vtkTypeBool ScaleEnabled{ 1 };
405 vtkTypeBool DrawCone{ 1 };
406 vtkNew<vtkTubeFilter> AxisTuber;
407 vtkTypeBool Tubing{ 1 };
408 int Cylindrical{ 0 };
411 vtkNew<vtkSphereSource> Sphere;
414 vtkNew<vtkCellPicker> Picker;
415 vtkNew<vtkCellPicker> CylPicker;
419 vtkNew<vtkProperty> HandleProperty;
420 vtkNew<vtkProperty> SelectedHandleProperty;
421 vtkNew<vtkProperty> ConeProperty;
422 vtkNew<vtkProperty> SelectedConeProperty;
423 vtkNew<vtkProperty> EdgeProperty;
424 vtkNew<vtkProperty> SelectedEdgeProperty;
427 vtkNew<vtkBox> BoundingBox;
430 vtkNew<vtkGlyph3DMapper> BottomHandleMapper;
431 vtkNew<vtkGlyph3DMapper> TopHandleMapper;
433 vtkNew<vtkTransform> Transform;