VTK  9.1.0
vtkBoxRepresentation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkBoxRepresentation.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=========================================================================*/
45#ifndef vtkBoxRepresentation_h
46#define vtkBoxRepresentation_h
47
48#include "vtkInteractionWidgetsModule.h" // For export macro
50
51class vtkActor;
53class vtkLineSource;
54class vtkSphereSource;
55class vtkCellPicker;
56class vtkProperty;
57class vtkPolyData;
58class vtkPoints;
61class vtkTransform;
62class vtkPlane;
63class vtkPlanes;
64class vtkBox;
65class vtkDoubleArray;
66class vtkMatrix4x4;
67
68class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
69{
70public:
75
77
81 void PrintSelf(ostream& os, vtkIndent indent) override;
83
92 void GetPlanes(vtkPlanes* planes);
93
94 // Get the underlying planes used by this rep
95 // this can be used as a cropping planes in vtkMapper
96 vtkPlane* GetUnderlyingPlane(int i) { return this->Planes[i]; }
97
99
105 vtkSetMacro(InsideOut, vtkTypeBool);
106 vtkGetMacro(InsideOut, vtkTypeBool);
107 vtkBooleanMacro(InsideOut, vtkTypeBool);
109
117 virtual void GetTransform(vtkTransform* t);
118
125 virtual void SetTransform(vtkTransform* t);
126
138
140
145 vtkGetObjectMacro(HandleProperty, vtkProperty);
146 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
148
150
155 vtkGetObjectMacro(FaceProperty, vtkProperty);
156 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
158
160
165 vtkGetObjectMacro(OutlineProperty, vtkProperty);
166 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
168
170
175 vtkGetMacro(OutlineFaceWires, int);
176 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
177 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
179
181
187 vtkGetMacro(OutlineCursorWires, int);
188 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
189 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
191
193
197 virtual void HandlesOn();
198 virtual void HandlesOff();
200
202
205 void PlaceWidget(double bounds[6]) override;
206 void BuildRepresentation() override;
207 int ComputeInteractionState(int X, int Y, int modify = 0) override;
208 void StartWidgetInteraction(double e[2]) override;
209 void WidgetInteraction(double e[2]) override;
210 double* GetBounds() VTK_SIZEHINT(6) override;
211 void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
212 unsigned long event, void* calldata) override;
213 void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
214 unsigned long event, void* calldata) override;
215 int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
216 unsigned long event, void* calldata, int modify = 0) override;
217 void EndComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
218 unsigned long event, void* calldata) override;
220
222
225 void ReleaseGraphicsResources(vtkWindow*) override;
226 int RenderOpaqueGeometry(vtkViewport*) override;
227 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
228 vtkTypeBool HasTranslucentPolygonalGeometry() override;
230
231 // Used to manage the state of the widget
232 enum
233 {
234 Outside = 0,
243 Scaling
244 };
245
255 void SetInteractionState(int state);
256
258
262 vtkGetMacro(TwoPlaneMode, bool);
263 void SetTwoPlaneMode(bool);
265
267
271 vtkGetMacro(SnapToAxes, bool);
272 vtkSetMacro(SnapToAxes, bool);
274
276
283
284 /*
285 * Register internal Pickers within PickingManager
286 */
287 void RegisterPickers() override;
288
290
294 vtkGetMacro(TranslationAxis, int);
295 vtkSetClampMacro(TranslationAxis, int, -1, 2);
297
299
302 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
303 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
304 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
305 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
307
309
312 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
314
315protected:
318
319 // Manage how the representation appears
320 double LastEventPosition[3];
321 double LastEventOrientation[4];
322 double StartEventOrientation[4];
323 double SnappedEventOrientations[3][4];
324 bool SnappedOrientation[3];
326
328
329 // Constraint axis translation
331
332 // the hexahedron (6 faces)
336 vtkPoints* Points; // used by others as well
337 double N[6][3]; // the normals of the faces
338
339 // A face of the hexahedron
343
344 // glyphs representing hot spots (e.g., handles)
348 virtual void PositionHandles();
349 int HighlightHandle(vtkProp* prop); // returns cell id
350 void HighlightFace(int cellId);
351 void HighlightOutline(int highlight);
352 virtual void ComputeNormals();
353 virtual void SizeHandles();
354
355 // wireframe outline
359
360 // Do the picking
366
367 // Transform the hexahedral points (used for rotations)
369
370 // Support GetBounds() method
372
373 // Properties used to control the appearance of selected objects and
374 // the manipulator in general.
382
383 // Control the orientation of the normals
388
389 // Helper methods
390 virtual void Translate(const double* p1, const double* p2);
391 virtual void Scale(const double* p1, const double* p2, int X, int Y);
392 virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
393 void MovePlusXFace(const double* p1, const double* p2);
394 void MoveMinusXFace(const double* p1, const double* p2);
395 void MovePlusYFace(const double* p1, const double* p2);
396 void MoveMinusYFace(const double* p1, const double* p2);
397 void MovePlusZFace(const double* p1, const double* p2);
398 void MoveMinusZFace(const double* p1, const double* p2);
399 void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
400
401 // Internal ivars for performance
405
406 // The actual planes which are being manipulated
407 vtkPlane* Planes[6];
408
409 //"dir" is the direction in which the face can be moved i.e. the axis passing
410 // through the center
411 void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
412 double* x3, double* x4, double* x5);
413 // Helper method to obtain the direction in which the face is to be moved.
414 // Handles special cases where some of the scale factors are 0.
415 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
416
417private:
419 void operator=(const vtkBoxRepresentation&) = delete;
420};
421
422#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
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.
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 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 ContrainedAxis.
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()
vtkProperty * SelectedFaceProperty
void HighlightOutline(int highlight)
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
vtkCellPicker * HandlePicker
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 MoveMinusZFace(const double *p1, const double *p2)
implicit function for a bounding box
Definition: vtkBox.h:48
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:43
create a line defined by two end points
Definition: vtkLineSource.h:70
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:45
perform various plane computations
Definition: vtkPlane.h:43
implicit function for convex set of planes
Definition: vtkPlanes.h:59
represent the position of a point in 3D space
represent and manipulate 3D points
Definition: vtkPoints.h:43
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:95
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:71
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
Definition: vtkTransform.h:64
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)