VTK  9.3.1
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 
135  void SetUserTransform(vtkLinearTransform* transform);
136  vtkGetObjectMacro(UserTransform, vtkLinearTransform);
138 
140 
143  void SetUserMatrix(vtkMatrix4x4* matrix);
144  vtkMatrix4x4* GetUserMatrix();
146 
148 
153  virtual void GetMatrix(vtkMatrix4x4* result);
154  virtual void GetMatrix(double result[16]);
156 
158 
162  virtual void GetModelToWorldMatrix(vtkMatrix4x4* result);
164 
169  virtual void SetPropertiesFromModelToWorldMatrix(vtkMatrix4x4* modelToWorld);
170 
175 
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); }
360  void SetCoordinateSystem(CoordinateSystems val);
361  vtkGetMacro(CoordinateSystem, CoordinateSystems);
362  const char* GetCoordinateSystemAsString();
364 
366 
370  void SetCoordinateSystemRenderer(vtkRenderer* ren);
371  vtkRenderer* GetCoordinateSystemRenderer();
373 
375 
379  vtkSetMacro(CoordinateSystemDevice, int);
380  vtkGetMacro(CoordinateSystemDevice, int);
382 
383 protected:
384  vtkProp3D();
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
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
virtual vtkMatrix4x4 * GetMatrix()
Definition: vtkProp.h:155
CoordinateSystems
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:351
vtkTransform * Transform
Definition: vtkProp3D.h:396
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
virtual void ShallowCopy(vtkProp *prop)
Shallow copy of this vtkProp.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
void SetCoordinateSystemToWorld()
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:357
vtkMatrix4x4 * UserMatrix
Definition: vtkProp3D.h:388
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetScale(double s)
Method to set the scale isotropically.
Definition: vtkProp3D.h:120
abstract specification for renderers
Definition: vtkRenderer.h:61
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:38
vtkWeakPointer< vtkRenderer > CoordinateSystemRenderer
Definition: vtkProp3D.h:403
int vtkTypeBool
Definition: vtkABI.h:64
virtual double * GetBounds()
Get the bounds for this Prop as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
Definition: vtkProp.h:124
virtual void SetPosition(double x, double y, double z)
Set/Get/Add the position of the Prop3D in world coordinates.
Definition: vtkProp3D.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool IsIdentity
Definition: vtkProp3D.h:399
a simple class to control print indentation
Definition: vtkIndent.h:28
const char * GetClassName() const
Return the class name as a string.
virtual void Modified()
Update the modification time for this object.
virtual void SetOrigin(double x, double y, double z)
Set/Get the origin of the Prop3D.
Definition: vtkProp3D.h:78
virtual void SetOrigin(const double pos[3])
Set/Get the origin of the Prop3D.
Definition: vtkProp3D.h:91
virtual void SetPosition(double pos[3])
Definition: vtkProp3D.h:68
#define VTK_SIZEHINT(...)
void SetCoordinateSystemToPhysical()
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:358
vtkLinearTransform * UserTransform
Definition: vtkProp3D.h:387
vtkProp3D * CachedProp3D
Definition: vtkProp3D.h:398
int CoordinateSystemDevice
Definition: vtkProp3D.h:401
virtual void SetScale(double scale[3])
Set/Get the scale of the actor.
Definition: vtkProp3D.h:113
vtkTimeStamp MatrixMTime
Definition: vtkProp3D.h:390
void SetCoordinateSystemToDevice()
Specify the coordinate system that this prop is relative to.
Definition: vtkProp3D.h:359
vtkNew< vtkMatrix4x4 > TempMatrix4x4
Definition: vtkProp3D.h:404
vtkMatrix4x4 * Matrix
Definition: vtkProp3D.h:389
abstract superclass for linear transformations
virtual void SetScale(double x, double y, double z)
Set/Get the scale of the actor.
Definition: vtkProp3D.h:100