ufe  4.2
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
transform3d.h
Go to the documentation of this file.
1 #line 1 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.10-windows/ufe/include/transform3d.h"
2 #ifndef _transform3d
3 #define _transform3d
4 // ===========================================================================
5 // Copyright 2020 Autodesk, Inc. All rights reserved.
6 //
7 // Use of this software is subject to the terms of the Autodesk license
8 // agreement provided at the time of installation or download, or which
9 // otherwise accompanies this software in either electronic or hard copy form.
10 // ===========================================================================
11 
12 #include "common/ufeExport.h"
13 #include "sceneItem.h"
14 #include "observer.h"
16 #include "types.h"
17 
18 #include <memory>
19 #include <array>
20 
21 UFE_NS_DEF {
22 
24 
31 {
32 public:
33 
34  // The None enumerant is deprecated, and may be removed in a future
35  // major version of UFE.
36  enum Type {NoHint, None = NoHint, Translate, Rotate, Scale, RotatePivot, ScalePivot};
37  EditTransform3dHint() = default;
39  EditTransform3dHint& operator=(const EditTransform3dHint&) = delete;
40  EditTransform3dHint(Type);
41  virtual ~EditTransform3dHint();
42 
43  inline Type type() const { return fType; }
44 
45 private:
46 
47  const Type fType{None};
48 };
49 
51 
53 {
54 public:
55  typedef std::shared_ptr<Transform3dRead> Ptr;
56 
64  static Ptr transform3dRead(const SceneItem::Ptr& item);
65 
68 
70  Transform3dRead(const Transform3dRead&) = default;
71 
73  virtual ~Transform3dRead();
74 
76  virtual const Path& path() const = 0;
77 
79  virtual SceneItem::Ptr sceneItem() const = 0;
80 
83  virtual Matrix4d matrix() const = 0;
84 
88  Matrix4d inclusiveMatrix() const;
89 
93  Matrix4d exclusiveMatrix() const;
94 
102  virtual Matrix4d segmentInclusiveMatrix() const = 0;
103 
111  virtual Matrix4d segmentExclusiveMatrix() const = 0;
112 };
113 
115 
154 {
155 public:
156  typedef std::shared_ptr<Transform3d> Ptr;
157 
165  static Ptr transform3d(const SceneItem::Ptr& item);
166 
176  static Ptr editTransform3d(
177  const SceneItem::Ptr& item,
179  );
180 
188  static bool addObserver(
189  const SceneItem::Ptr& item, const Observer::Ptr& obs);
190 
198  static bool removeObserver(
199  const SceneItem::Ptr& item, const Observer::Ptr& obs);
200 
201  typedef bool (*RemoveObserverItemType)(const SceneItem::Ptr& item, const Observer::Ptr& obs);
202 
212  static bool removeObserver(
213  const Path& path, const Observer::Ptr& obs);
214 
215  typedef bool (*RemoveObserverPathType)(const Path& path, const Observer::Ptr& obs);
216 
222  static std::size_t nbObservers(const SceneItem::Ptr& item);
223 
231  static bool hasObserver(
232  const SceneItem::Ptr& item, const Observer::Ptr& obs);
233 
236  static bool hasObservers(const Path& path);
237 
242  static bool hasObservers(Rtid runTimeId);
243 
247  static void notify(const Path& path);
248 
250  Transform3d();
252  Transform3d(const Transform3d&) = default;
254  virtual ~Transform3d() override;
255 
261  virtual TranslateUndoableCommand::Ptr translateCmd(
262  double x, double y, double z) = 0;
263 
265  return translateCmd(0, 0, 0); }
266 
272  virtual void translate(double x, double y, double z) {
273  auto cmd = translateCmd(x, y, z);
274  if (cmd) {
275  cmd->execute();
276  }
277  }
278 
281  virtual Vector3d translation() const = 0;
282 
289  virtual RotateUndoableCommand::Ptr rotateCmd(
290  double x, double y, double z) = 0;
291 
293  return rotateCmd(0, 0, 0); }
294 
300  virtual void rotate(double x, double y, double z) {
301  auto cmd = rotateCmd(x, y, z);
302  if (cmd) {
303  cmd->execute();
304  }
305  }
306 
310  virtual Vector3d rotation() const = 0;
311 
317  virtual ScaleUndoableCommand::Ptr scaleCmd(
318  double x, double y, double z) = 0;
319 
321  return scaleCmd(1, 1, 1); }
322 
328  virtual void scale(double x, double y, double z) {
329  auto cmd = scaleCmd(x, y, z);
330  if (cmd) {
331  cmd->execute();
332  }
333  }
334 
337  virtual Vector3d scale() const = 0;
338 
345  virtual TranslateUndoableCommand::Ptr rotatePivotCmd(
346  double x, double y, double z) = 0;
347 
349  return rotatePivotCmd(0, 0, 0); }
350 
356  virtual void rotatePivot(double x, double y, double z) {
357  auto cmd = rotatePivotCmd(x, y, z);
358  if (cmd) {
359  cmd->execute();
360  }
361  }
362 
365  virtual Vector3d rotatePivot() const = 0;
366 
373  virtual TranslateUndoableCommand::Ptr scalePivotCmd(
374  double x, double y, double z) = 0;
375 
377  return scalePivotCmd(0, 0, 0); }
378 
384  virtual void scalePivot(double x, double y, double z) {
385  auto cmd = scalePivotCmd(x, y, z);
386  if (cmd) {
387  cmd->execute();
388  }
389  }
390 
393  virtual Vector3d scalePivot() const = 0;
394 
405  double x, double y, double z) {
406  (void) x; (void) y; (void) z;
407  return nullptr;
408  }
409 
411  return translateRotatePivotCmd(0, 0, 0); }
412 
419  virtual void translateRotatePivot(double x, double y, double z) {
420  auto cmd = translateRotatePivotCmd(x, y, z);
421  if (cmd) {
422  cmd->execute();
423  }
424  }
425 
430  return Vector3d(0, 0, 0);
431  }
432 
443  double x, double y, double z) {
444  (void) x; (void) y; (void) z;
445  return nullptr;
446  }
447 
449  return translateScalePivotCmd(0, 0, 0); }
450 
456  virtual void translateScalePivot(double x, double y, double z) {
457  auto cmd = translateScalePivotCmd(x, y, z);
458  if (cmd) {
459  cmd->execute();
460  }
461  }
462 
466  virtual Vector3d scalePivotTranslation() const {
467  return Vector3d(0, 0, 0);
468  }
469 
479  double x, double y, double z) {
480  (void) x; (void) y; (void) z;
481  return nullptr;
482  }
483 
485  return rotateAxisCmd(0, 0, 0); }
486 
492  virtual void rotateAxis(double x, double y, double z) {
493  auto cmd = rotateAxisCmd(x, y, z);
494  if (cmd) {
495  cmd->execute();
496  }
497  }
498 
501  virtual Vector3d rotateAxis() const {
502  return Vector3d(0, 0, 0);
503  }
504 
513  double xy, double xz, double yz) {
514  (void) xy; (void) xz; (void) yz;
515  return nullptr;
516  }
517 
519  return shearCmd(0, 0, 0); }
520 
526  virtual void shear(double xy, double xz, double yz) {
527  auto cmd = shearCmd(xy, xz, yz);
528  if (cmd) {
529  cmd->execute();
530  }
531  }
532 
536  virtual Vector3d shear() const {
537  return Vector3d(0, 0, 0);
538  }
539 
544  virtual SetMatrix4dUndoableCommand::Ptr setMatrixCmd(const Matrix4d& m) = 0;
545 
550  virtual void setMatrix(const Matrix4d& m) {
551  auto cmd = setMatrixCmd(m);
552  if (cmd) {
553  cmd->execute();
554  }
555  }
556 };
557 
558 }
559 
560 #endif /* _transform3d */
std::shared_ptr< SetValue3UndoableCommand > Ptr
TranslateUndoableCommand::Ptr translateCmd()
Definition: transform3d.h:264
virtual void translate(double x, double y, double z)
Definition: transform3d.h:272
Abstract base class for 3D transform interface.
Definition: transform3d.h:153
TypedVectorN< double, 3 > Vector3d
Definition: types.h:104
std::shared_ptr< Observer > Ptr
Definition: observer.h:36
Definition of macros for symbol visibility.
std::shared_ptr< Transform3dRead > Ptr
Definition: transform3d.h:55
virtual void scalePivot(double x, double y, double z)
Definition: transform3d.h:384
virtual Vector3d scalePivotTranslation() const
Definition: transform3d.h:466
std::shared_ptr< Transform3d > Ptr
Definition: transform3d.h:156
ScaleUndoableCommand::Ptr scaleCmd()
Definition: transform3d.h:320
virtual void scale(double x, double y, double z)
Definition: transform3d.h:328
TranslateUndoableCommand::Ptr scalePivotCmd()
Definition: transform3d.h:376
Read-only abstract base class for 3D transform interface.
Definition: transform3d.h:52
virtual Vector3d rotatePivotTranslation() const
Definition: transform3d.h:429
RotateUndoableCommand::Ptr rotateAxisCmd()
Definition: transform3d.h:484
RotateUndoableCommand::Ptr rotateCmd()
Definition: transform3d.h:292
Hint class for Transform3d editTransform3d.
Definition: transform3d.h:30
std::shared_ptr< SetValueUndoableCommand > Ptr
Identify an object or 3D path in the scene.
Definition: path.h:37
virtual void setMatrix(const Matrix4d &m)
Definition: transform3d.h:550
ShearUndoableCommand::Ptr shearCmd()
Definition: transform3d.h:518
uint32_t Rtid
Definition: rtid.h:26
TranslateUndoableCommand::Ptr translateRotatePivotCmd()
Definition: transform3d.h:410
virtual RotateUndoableCommand::Ptr rotateAxisCmd(double x, double y, double z)
Definition: transform3d.h:478
virtual Vector3d shear() const
Definition: transform3d.h:536
virtual void translateRotatePivot(double x, double y, double z)
Definition: transform3d.h:419
#define UFE_NS_DEF
Definition: ufe.h:35
Typed square matrix template.
Definition: types.h:201
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:40
virtual void rotateAxis(double x, double y, double z)
Definition: transform3d.h:492
virtual TranslateUndoableCommand::Ptr translateRotatePivotCmd(double x, double y, double z)
Definition: transform3d.h:404
virtual const Path & path() const =0
Path path(const std::string &pathString)
virtual void translateScalePivot(double x, double y, double z)
Definition: transform3d.h:456
virtual void shear(double xy, double xz, double yz)
Definition: transform3d.h:526
virtual void rotatePivot(double x, double y, double z)
Definition: transform3d.h:356
virtual Vector3d rotateAxis() const
Definition: transform3d.h:501
virtual TranslateUndoableCommand::Ptr translateScalePivotCmd(double x, double y, double z)
Definition: transform3d.h:442
TranslateUndoableCommand::Ptr translateScalePivotCmd()
Definition: transform3d.h:448
virtual ShearUndoableCommand::Ptr shearCmd(double xy, double xz, double yz)
Definition: transform3d.h:512
#define UFE_SDK_DECL
Definition: ufeExport.h:36
virtual void rotate(double x, double y, double z)
Definition: transform3d.h:300
TranslateUndoableCommand::Ptr rotatePivotCmd()
Definition: transform3d.h:348