VTK  9.3.0
vtkProp3D.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
24 #ifndef vtkProp3D_h
25 #define vtkProp3D_h
26 
27 #include "vtkNew.h" // for ivar
28 #include "vtkProp.h"
29 #include "vtkRenderingCoreModule.h" // For export macro
30 #include "vtkWeakPointer.h" // For vtkWeakPointer
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkLinearTransform;
34 class vtkMatrix4x4;
35 class vtkRenderer;
36 class vtkTransform;
37 
38 class VTKRENDERINGCORE_EXPORT vtkProp3D : public vtkProp
39 {
40 public:
41  vtkTypeMacro(vtkProp3D, vtkProp);
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
47  void ShallowCopy(vtkProp* prop) override;
48 
50 
53  virtual void SetPosition(double x, double y, double z)
54  {
55  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Position to (" << x << ","
56  << y << "," << z << ")");
57  if ((this->Position[0] != x) || (this->Position[1] != y) || (this->Position[2] != z))
58  {
59  this->Position[0] = x;
60  this->Position[1] = y;
61  this->Position[2] = z;
62  this->Modified();
63  this->IsIdentity = 0;
64  }
65  };
67 
68  virtual void SetPosition(double pos[3]) { this->SetPosition(pos[0], pos[1], pos[2]); }
69  vtkGetVectorMacro(Position, double, 3);
70  void AddPosition(double deltaPosition[3]);
71  void AddPosition(double deltaX, double deltaY, double deltaZ);
72 
74 
78  virtual void SetOrigin(double x, double y, double z)
79  {
80  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Origin to (" << x << ","
81  << y << "," << z << ")");
82  if ((this->Origin[0] != x) || (this->Origin[1] != y) || (this->Origin[2] != z))
83  {
84  this->Origin[0] = x;
85  this->Origin[1] = y;
86  this->Origin[2] = z;
87  this->Modified();
88  this->IsIdentity = 0;
89  }
90  };
91  virtual void SetOrigin(const double pos[3]) { this->SetOrigin(pos[0], pos[1], pos[2]); }
92  vtkGetVectorMacro(Origin, double, 3);
94 
96 
100  virtual void SetScale(double x, double y, double z)
101  {
102  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Scale to (" << x << ","
103  << y << "," << z << ")");
104  if (this->Scale[0] != x || this->Scale[1] != y || this->Scale[2] != z)
105  {
106  this->Scale[0] = x;
107  this->Scale[1] = y;
108  this->Scale[2] = z;
109  this->Modified();
110  this->IsIdentity = 0;
111  }
112  };
113  virtual void SetScale(double scale[3]) { this->SetScale(scale[0], scale[1], scale[2]); }
114  vtkGetVectorMacro(Scale, double, 3);
116 
120  void SetScale(double s) { this->SetScale(s, s, s); }
121 
123 
136  vtkGetObjectMacro(UserTransform, vtkLinearTransform);
138 
140 
146 
148 
153  virtual void GetMatrix(vtkMatrix4x4* result);
154  virtual void GetMatrix(double result[16]);
156 
158 
162  virtual void GetModelToWorldMatrix(vtkMatrix4x4* result);
164 
170 
176 
179  void GetBounds(double bounds[6]);
180  double* GetBounds() VTK_SIZEHINT(6) override = 0;
182 
186  double* GetCenter() VTK_SIZEHINT(3);
187 
191  double* GetXRange() VTK_SIZEHINT(2);
192 
196  double* GetYRange() VTK_SIZEHINT(2);
197 
201  double* GetZRange() VTK_SIZEHINT(2);
202 
206  double GetLength();
207 
215  void RotateX(double);
216 
224  void RotateY(double);
225 
233  void RotateZ(double);
234 
241  void RotateWXYZ(double w, double x, double y, double z);
242 
248  void SetOrientation(double x, double y, double z);
249 
255  void SetOrientation(double orientation[3]);
256 
258 
264  double* GetOrientation() VTK_SIZEHINT(3);
265  void GetOrientation(double orentation[3]);
267 
271  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
272 
279  void AddOrientation(double x, double y, double z);
280 
287  void AddOrientation(double orentation[3]);
288 
299  void PokeMatrix(vtkMatrix4x4* matrix) override;
300 
305  void InitPathTraversal() override;
306 
310  vtkMTimeType GetMTime() override;
311 
315  vtkMTimeType GetUserTransformMatrixMTime();
316 
318 
321  virtual void ComputeMatrix();
323 
325 
328  vtkMatrix4x4* GetMatrix() override
329  {
330  this->ComputeMatrix();
331  return this->Matrix;
332  }
334 
336 
339  vtkGetMacro(IsIdentity, vtkTypeBool);
341 
343 
352  {
353  WORLD = 0,
354  PHYSICAL = 1,
355  DEVICE = 2
356  };
357  void SetCoordinateSystemToWorld() { this->SetCoordinateSystem(WORLD); }
358  void SetCoordinateSystemToPhysical() { this->SetCoordinateSystem(PHYSICAL); }
359  void SetCoordinateSystemToDevice() { this->SetCoordinateSystem(DEVICE); }
361  vtkGetMacro(CoordinateSystem, CoordinateSystems);
364 
366 
373 
375 
379  vtkSetMacro(CoordinateSystemDevice, int);
380  vtkGetMacro(CoordinateSystemDevice, int);
382 
383 protected:
385  ~vtkProp3D() override;
386 
391  double Origin[3];
392  double Position[3];
393  double Orientation[3];
394  double Scale[3];
395  double Center[3];
397  double Bounds[6];
398  vtkProp3D* CachedProp3D; // support the PokeMatrix() method
400 
402  CoordinateSystems CoordinateSystem = WORLD;
405 
406 private:
407  vtkProp3D(const vtkProp3D&) = delete;
408  void operator=(const vtkProp3D&) = delete;
409 };
410 
411 VTK_ABI_NAMESPACE_END
412 #endif
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract superclass for linear transformations
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
const char * GetClassName() const
Return the class name as a string.
virtual void Modified()
Update the modification time for this object.
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:39
virtual void SetPosition(double x, double y, double z)
Set/Get/Add the position of the Prop3D in world coordinates.
Definition: vtkProp3D.h:53
virtual void GetMatrix(double result[16])
Return a reference to the Prop3D's 4x4 composite matrix.
vtkWeakPointer< vtkRenderer > CoordinateSystemRenderer
Definition: vtkProp3D.h:403
const char * GetCoordinateSystemAsString()
Specify the coordinate system that this prop is relative to.
void SetCoordinateSystem(CoordinateSystems val)
Specify the coordinate system that this prop is relative to.
vtkTimeStamp MatrixMTime
Definition: vtkProp3D.h:390
virtual void GetMatrix(vtkMatrix4x4 *result)
Return a reference to the Prop3D's 4x4 composite matrix.
void SetScale(double s)
Method to set the scale isotropically.
Definition: vtkProp3D.h:120
virtual void SetScale(double scale[3])
Set/Get the scale of the actor.
Definition: vtkProp3D.h:113
vtkNew< vtkMatrix4x4 > TempMatrix4x4
Definition: vtkProp3D.h:404
void AddPosition(double deltaX, double deltaY, double deltaZ)
vtkTypeBool IsIdentity
Definition: vtkProp3D.h:399
void AddPosition(double deltaPosition[3])
vtkMatrix4x4 * UserMatrix
Definition: vtkProp3D.h:388
virtual void SetPosition(double pos[3])
Definition: vtkProp3D.h:68
virtual void SetOrigin(double x, double y, double z)
Set/Get the origin of the Prop3D.
Definition: vtkProp3D.h:78
virtual void SetScale(double x, double y, double z)
Set/Get the scale of the actor.
Definition: vtkProp3D.h:100
~vtkProp3D() override
vtkTransform * Transform
Definition: vtkProp3D.h:396
virtual void GetModelToWorldMatrix(vtkMatrix4x4 *result)
Return a reference to the Prop3D's Model to World matrix.
void SetCoordinateSystemToWorld()
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:357
double * GetBounds() override=0
Return a reference to the Prop3D's composite transform.
void SetCoordinateSystemRenderer(vtkRenderer *ren)
Specify the Renderer that the prop3d is relative to when the coordinate system is set to PHYSICAL or ...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int CoordinateSystemDevice
Definition: vtkProp3D.h:401
void SetUserMatrix(vtkMatrix4x4 *matrix)
The UserMatrix can be used in place of UserTransform.
vtkMatrix4x4 * Matrix
Definition: vtkProp3D.h:389
void SetUserTransform(vtkLinearTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
void SetCoordinateSystemToDevice()
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:359
vtkProp3D * CachedProp3D
Definition: vtkProp3D.h:398
void SetCoordinateSystemToPhysical()
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:358
CoordinateSystems
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:352
void GetBounds(double bounds[6])
Return a reference to the Prop3D's composite transform.
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp3D.
vtkRenderer * GetCoordinateSystemRenderer()
Specify the Renderer that the prop3d is relative to when the coordinate system is set to PHYSICAL or ...
vtkMatrix4x4 * GetUserMatrix()
The UserMatrix can be used in place of UserTransform.
vtkLinearTransform * UserTransform
Definition: vtkProp3D.h:387
virtual void SetOrigin(const double pos[3])
Set/Get the origin of the Prop3D.
Definition: vtkProp3D.h:91
virtual void SetPropertiesFromModelToWorldMatrix(vtkMatrix4x4 *modelToWorld)
Set the position, scale, orientation from a provided model to world matrix.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
abstract specification for renderers
Definition: vtkRenderer.h:62
record modification and/or execution time
Definition: vtkTimeStamp.h:25
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
@ orientation
Definition: vtkX3D.h:262
@ scale
Definition: vtkX3D.h:229
int vtkTypeBool
Definition: vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_SIZEHINT(...)