VTK  9.3.0
vtkBoxRepresentation.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
27#ifndef vtkBoxRepresentation_h
28#define vtkBoxRepresentation_h
29
30#include "vtkInteractionWidgetsModule.h" // For export macro
32
33VTK_ABI_NAMESPACE_BEGIN
34class vtkActor;
36class vtkLineSource;
37class vtkSphereSource;
38class vtkCellPicker;
39class vtkProperty;
40class vtkPolyData;
41class vtkPoints;
44class vtkTransform;
45class vtkPlane;
46class vtkPlanes;
47class vtkBox;
48class vtkDoubleArray;
49class vtkMatrix4x4;
50
51class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
52{
53public:
58
60
64 void PrintSelf(ostream& os, vtkIndent indent) override;
66
75 void GetPlanes(vtkPlanes* planes);
76
77 // Get the underlying planes used by this rep
78 // this can be used as a cropping planes in vtkMapper
79 vtkPlane* GetUnderlyingPlane(int i) { return this->Planes[i]; }
80
82
88 vtkSetMacro(InsideOut, vtkTypeBool);
89 vtkGetMacro(InsideOut, vtkTypeBool);
90 vtkBooleanMacro(InsideOut, vtkTypeBool);
92
100 virtual void GetTransform(vtkTransform* t);
101
108 virtual void SetTransform(vtkTransform* t);
109
121
123
128 vtkGetObjectMacro(HandleProperty, vtkProperty);
129 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
131
133
138 vtkGetObjectMacro(FaceProperty, vtkProperty);
139 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
141
143
148 vtkGetObjectMacro(OutlineProperty, vtkProperty);
149 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
151
153
156 void SetForegroundColor(double _arg1, double _arg2, double _arg3);
157 void SetForegroundColor(const double _arg[3])
158 {
159 this->SetForegroundColor(_arg[0], _arg[1], _arg[2]);
160 }
162
164
168 void SetInteractionColor(double _arg1, double _arg2, double _arg3);
169 void SetInteractionColor(const double _arg[3])
170 {
171 this->SetInteractionColor(_arg[0], _arg[1], _arg[2]);
172 }
174
176
181 vtkGetMacro(OutlineFaceWires, int);
182 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
183 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
185
187
193 vtkGetMacro(OutlineCursorWires, int);
194 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
195 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
197
199
203 virtual void HandlesOn();
204 virtual void HandlesOff();
206
208
211 void PlaceWidget(double bounds[6]) override;
212 void BuildRepresentation() override;
213 int ComputeInteractionState(int X, int Y, int modify = 0) override;
214 void StartWidgetInteraction(double e[2]) override;
215 void WidgetInteraction(double e[2]) override;
216 double* GetBounds() VTK_SIZEHINT(6) override;
217 void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
218 unsigned long event, void* calldata) override;
219 void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
220 unsigned long event, void* calldata) override;
221 int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
222 unsigned long event, void* calldata, int modify = 0) override;
223 void EndComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
224 unsigned long event, void* calldata) override;
226
228
231 void ReleaseGraphicsResources(vtkWindow*) override;
232 int RenderOpaqueGeometry(vtkViewport*) override;
233 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
234 vtkTypeBool HasTranslucentPolygonalGeometry() override;
236
237 // Used to manage the state of the widget
238 enum
239 {
240 Outside = 0,
249 Scaling
250 };
251
261 void SetInteractionState(int state);
262
264
268 vtkGetMacro(TwoPlaneMode, bool);
269 void SetTwoPlaneMode(bool);
271
273
277 vtkGetMacro(SnapToAxes, bool);
278 vtkSetMacro(SnapToAxes, bool);
280
282
289
290 /*
291 * Register internal Pickers within PickingManager
292 */
293 void RegisterPickers() override;
294
296
300 vtkGetMacro(TranslationAxis, int);
301 vtkSetClampMacro(TranslationAxis, int, -1, 2);
303
305
308 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
309 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
310 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
311 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
313
315
318 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
320
327
328protected:
331
332 // Manage how the representation appears
333 double LastEventPosition[3];
334 double LastEventOrientation[4];
335 double StartEventOrientation[4];
336 double SnappedEventOrientations[3][4];
337 bool SnappedOrientation[3];
339
341
342 // Constraint axis translation
344
345 // the hexahedron (6 faces)
349 vtkPoints* Points; // used by others as well
350 double N[6][3]; // the normals of the faces
351
352 // A face of the hexahedron
356
357 // glyphs representing hot spots (e.g., handles)
361 virtual void PositionHandles();
362 int HighlightHandle(vtkProp* prop); // returns cell id
363 void HighlightFace(int cellId);
364 void HighlightOutline(int highlight);
365 virtual void ComputeNormals();
366 virtual void SizeHandles();
367
368 // wireframe outline
372
373 // Do the picking
379
380 // Transform the hexahedral points (used for rotations)
382
383 // Support GetBounds() method
385
386 // Properties used to control the appearance of selected objects and
387 // the manipulator in general.
395
396 // Control the orientation of the normals
401
402 // Helper methods
403 virtual void Translate(const double* p1, const double* p2);
404 virtual void Scale(const double* p1, const double* p2, int X, int Y);
405 virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
406 void MovePlusXFace(const double* p1, const double* p2);
407 void MoveMinusXFace(const double* p1, const double* p2);
408 void MovePlusYFace(const double* p1, const double* p2);
409 void MoveMinusYFace(const double* p1, const double* p2);
410 void MovePlusZFace(const double* p1, const double* p2);
411 void MoveMinusZFace(const double* p1, const double* p2);
412 void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
413
414 // Internal ivars for performance
418
419 // The actual planes which are being manipulated
420 vtkPlane* Planes[6];
421
422 //"dir" is the direction in which the face can be moved i.e. the axis passing
423 // through the center
424 void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
425 double* x3, double* x4, double* x5);
426 // Helper method to obtain the direction in which the face is to be moved.
427 // Handles special cases where some of the scale factors are 0.
428 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
429
430private:
432 void operator=(const vtkBoxRepresentation&) = delete;
433};
434
435VTK_ABI_NAMESPACE_END
436#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
a class defining the representation for the vtkBoxWidget2
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetForegroundColor(const double _arg[3])
Set the foreground color (the outline of the box).
virtual void PositionHandles()
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void MovePlusZFace(const double *p1, const double *p2)
void OutlineCursorWiresOff()
Control the representation of the outline.
void MoveMinusYFace(const double *p1, const double *p2)
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
void SetOutlineCursorWires(int)
Control the representation of the outline.
vtkPolyDataMapper * HexFaceMapper
void StepBackward()
For complex events should we snap orientations to be aligned with the x y z axes.
void GetActors(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp (i.e.,...
void MoveMinusXFace(const double *p1, const double *p2)
void MoveFace(const double *p1, const double *p2, const double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
virtual void HandlesOff()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
void HighlightFace(int cellId)
int HighlightHandle(vtkProp *prop)
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
void OutlineFaceWiresOn()
Control the representation of the outline.
vtkPolyDataMapper * OutlineMapper
vtkPlane * GetUnderlyingPlane(int i)
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void Translate(const double *p1, const double *p2)
void MovePlusYFace(const double *p1, const double *p2)
virtual void SizeHandles()
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void Rotate(int X, int Y, const double *p1, const double *p2, const double *vpn)
vtkSphereSource ** HandleGeometry
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
vtkDoubleArray * PlaneNormals
void SetTwoPlaneMode(bool)
In two plane mode only the X planes are shown this is useful for defining thick slabs.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkProperty * SelectedOutlineProperty
void OutlineCursorWiresOn()
Control the representation of the outline.
virtual void ComputeNormals()
void HighlightOutline(int highlight)
void SetInteractionColor(const double _arg[3])
Set the interaction color.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
void UpdatePose(const double *p1, const double *d1, const double *p2, const double *d2)
vtkProperty * SelectedHandleProperty
void MovePlusXFace(const double *p1, const double *p2)
vtkPolyDataMapper * HexMapper
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void StepForward()
For complex events should we snap orientations to be aligned with the x y z axes.
vtkPolyDataMapper ** HandleMapper
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkBoxWidget2) or other object.
virtual void HandlesOn()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
void SetOutlineFaceWires(int)
Control the representation of the outline.
~vtkBoxRepresentation() override
void OutlineFaceWiresOff()
Control the representation of the outline.
virtual void CreateDefaultProperties()
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void Scale(const double *p1, const double *p2, int X, int Y)
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
static vtkBoxRepresentation * New()
Instantiate the class.
void SetForegroundColor(double _arg1, double _arg2, double _arg3)
Set the foreground color (the outline of the box).
void MoveMinusZFace(const double *p1, const double *p2)
void SetInteractionColor(double _arg1, double _arg2, double _arg3)
Set the interaction color.
implicit function for a bounding box
Definition vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
perform various plane computations
Definition vtkPlane.h:26
implicit function for convex set of planes
Definition vtkPlanes.h:42
represent the position of a point in 3D space
represent and manipulate 3D points
Definition vtkPoints.h:29
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:80
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
platform-independent render window interaction including picking and frame rate control.
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)