ufe  3.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.9-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 
90 {
91 public:
92  typedef std::shared_ptr<Transform3d> Ptr;
93 
101  static Ptr transform3d(const SceneItem::Ptr& item);
102 
112  static Ptr editTransform3d(
113  const SceneItem::Ptr& item,
115  );
116 
124  static bool addObserver(
125  const SceneItem::Ptr& item, const Observer::Ptr& obs);
126 
134  static bool removeObserver(
135  const SceneItem::Ptr& item, const Observer::Ptr& obs);
136 
137  typedef bool (*RemoveObserverItemType)(const SceneItem::Ptr& item, const Observer::Ptr& obs);
138 
148  static bool removeObserver(
149  const Path& path, const Observer::Ptr& obs);
150 
151  typedef bool (*RemoveObserverPathType)(const Path& path, const Observer::Ptr& obs);
152 
158  static std::size_t nbObservers(const SceneItem::Ptr& item);
159 
167  static bool hasObserver(
168  const SceneItem::Ptr& item, const Observer::Ptr& obs);
169 
172  static bool hasObservers(const Path& path);
173 
178  static bool hasObservers(Rtid runTimeId);
179 
183  static void notify(const Path& path);
184 
186  Transform3d();
188  Transform3d(const Transform3d&) = default;
190  virtual ~Transform3d();
191 
193  virtual const Path& path() const = 0;
194 
196  virtual SceneItem::Ptr sceneItem() const = 0;
197 
203  virtual TranslateUndoableCommand::Ptr translateCmd(
204  double x, double y, double z) = 0;
205 
207  return translateCmd(0, 0, 0); }
208 
214  virtual void translate(double x, double y, double z) {
215  auto cmd = translateCmd(x, y, z);
216  if (cmd) {
217  cmd->execute();
218  }
219  }
220 
223  virtual Vector3d translation() const = 0;
224 
231  virtual RotateUndoableCommand::Ptr rotateCmd(
232  double x, double y, double z) = 0;
233 
235  return rotateCmd(0, 0, 0); }
236 
242  virtual void rotate(double x, double y, double z) {
243  auto cmd = rotateCmd(x, y, z);
244  if (cmd) {
245  cmd->execute();
246  }
247  }
248 
252  virtual Vector3d rotation() const = 0;
253 
259  virtual ScaleUndoableCommand::Ptr scaleCmd(
260  double x, double y, double z) = 0;
261 
263  return scaleCmd(1, 1, 1); }
264 
270  virtual void scale(double x, double y, double z) {
271  auto cmd = scaleCmd(x, y, z);
272  if (cmd) {
273  cmd->execute();
274  }
275  }
276 
279  virtual Vector3d scale() const = 0;
280 
287  virtual TranslateUndoableCommand::Ptr rotatePivotCmd(
288  double x, double y, double z) = 0;
289 
291  return rotatePivotCmd(0, 0, 0); }
292 
298  virtual void rotatePivot(double x, double y, double z) {
299  auto cmd = rotatePivotCmd(x, y, z);
300  if (cmd) {
301  cmd->execute();
302  }
303  }
304 
307  virtual Vector3d rotatePivot() const = 0;
308 
315  virtual TranslateUndoableCommand::Ptr scalePivotCmd(
316  double x, double y, double z) = 0;
317 
319  return scalePivotCmd(0, 0, 0); }
320 
326  virtual void scalePivot(double x, double y, double z) {
327  auto cmd = scalePivotCmd(x, y, z);
328  if (cmd) {
329  cmd->execute();
330  }
331  }
332 
335  virtual Vector3d scalePivot() const = 0;
336 
347  double x, double y, double z) {
348  (void) x; (void) y; (void) z;
349  return nullptr;
350  }
351 
353  return translateRotatePivotCmd(0, 0, 0); }
354 
361  virtual void translateRotatePivot(double x, double y, double z) {
362  auto cmd = translateRotatePivotCmd(x, y, z);
363  if (cmd) {
364  cmd->execute();
365  }
366  }
367 
372  return Vector3d(0, 0, 0);
373  }
374 
385  double x, double y, double z) {
386  (void) x; (void) y; (void) z;
387  return nullptr;
388  }
389 
391  return translateScalePivotCmd(0, 0, 0); }
392 
398  virtual void translateScalePivot(double x, double y, double z) {
399  auto cmd = translateScalePivotCmd(x, y, z);
400  if (cmd) {
401  cmd->execute();
402  }
403  }
404 
408  virtual Vector3d scalePivotTranslation() const {
409  return Vector3d(0, 0, 0);
410  }
411 
421  double x, double y, double z) {
422  (void) x; (void) y; (void) z;
423  return nullptr;
424  }
425 
427  return rotateAxisCmd(0, 0, 0); }
428 
434  virtual void rotateAxis(double x, double y, double z) {
435  auto cmd = rotateAxisCmd(x, y, z);
436  if (cmd) {
437  cmd->execute();
438  }
439  }
440 
443  virtual Vector3d rotateAxis() const {
444  return Vector3d(0, 0, 0);
445  }
446 
455  double xy, double xz, double yz) {
456  (void) xy; (void) xz; (void) yz;
457  return nullptr;
458  }
459 
461  return shearCmd(0, 0, 0); }
462 
468  virtual void shear(double xy, double xz, double yz) {
469  auto cmd = shearCmd(xy, xz, yz);
470  if (cmd) {
471  cmd->execute();
472  }
473  }
474 
478  virtual Vector3d shear() const {
479  return Vector3d(0, 0, 0);
480  }
481 
486  virtual SetMatrix4dUndoableCommand::Ptr setMatrixCmd(const Matrix4d& m) = 0;
487 
492  virtual void setMatrix(const Matrix4d& m) {
493  auto cmd = setMatrixCmd(m);
494  if (cmd) {
495  cmd->execute();
496  }
497  }
498 
501  virtual Matrix4d matrix() const = 0;
502 
506  Matrix4d inclusiveMatrix() const;
507 
511  Matrix4d exclusiveMatrix() const;
512 
520  virtual Matrix4d segmentInclusiveMatrix() const = 0;
521 
529  virtual Matrix4d segmentExclusiveMatrix() const = 0;
530 };
531 
532 }
533 
534 #endif /* _transform3d */
std::shared_ptr< SetValue3UndoableCommand > Ptr
TypedVector3< double > Vector3d
Definition: types.h:56
TranslateUndoableCommand::Ptr translateCmd()
Definition: transform3d.h:206
virtual void translate(double x, double y, double z)
Definition: transform3d.h:214
Abstract base class for 3D transform interface.
Definition: transform3d.h:89
std::shared_ptr< Observer > Ptr
Definition: observer.h:36
Definition of macros for symbol visibility.
virtual void scalePivot(double x, double y, double z)
Definition: transform3d.h:326
virtual Vector3d scalePivotTranslation() const
Definition: transform3d.h:408
std::shared_ptr< Transform3d > Ptr
Definition: transform3d.h:92
ScaleUndoableCommand::Ptr scaleCmd()
Definition: transform3d.h:262
virtual void scale(double x, double y, double z)
Definition: transform3d.h:270
TranslateUndoableCommand::Ptr scalePivotCmd()
Definition: transform3d.h:318
virtual Vector3d rotatePivotTranslation() const
Definition: transform3d.h:371
RotateUndoableCommand::Ptr rotateAxisCmd()
Definition: transform3d.h:426
RotateUndoableCommand::Ptr rotateCmd()
Definition: transform3d.h:234
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:492
ShearUndoableCommand::Ptr shearCmd()
Definition: transform3d.h:460
uint32_t Rtid
Definition: rtid.h:26
TranslateUndoableCommand::Ptr translateRotatePivotCmd()
Definition: transform3d.h:352
virtual RotateUndoableCommand::Ptr rotateAxisCmd(double x, double y, double z)
Definition: transform3d.h:420
virtual Vector3d shear() const
Definition: transform3d.h:478
virtual void translateRotatePivot(double x, double y, double z)
Definition: transform3d.h:361
#define UFE_NS_DEF
Definition: ufe.h:35
Matrix class for 3D transforms.
Definition: types.h:119
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:40
virtual void rotateAxis(double x, double y, double z)
Definition: transform3d.h:434
virtual TranslateUndoableCommand::Ptr translateRotatePivotCmd(double x, double y, double z)
Definition: transform3d.h:346
Path path(const std::string &pathString)
virtual void translateScalePivot(double x, double y, double z)
Definition: transform3d.h:398
virtual void shear(double xy, double xz, double yz)
Definition: transform3d.h:468
virtual void rotatePivot(double x, double y, double z)
Definition: transform3d.h:298
virtual Vector3d rotateAxis() const
Definition: transform3d.h:443
virtual TranslateUndoableCommand::Ptr translateScalePivotCmd(double x, double y, double z)
Definition: transform3d.h:384
TranslateUndoableCommand::Ptr translateScalePivotCmd()
Definition: transform3d.h:390
virtual ShearUndoableCommand::Ptr shearCmd(double xy, double xz, double yz)
Definition: transform3d.h:454
#define UFE_SDK_DECL
Definition: ufeExport.h:36
virtual void rotate(double x, double y, double z)
Definition: transform3d.h:242
TranslateUndoableCommand::Ptr rotatePivotCmd()
Definition: transform3d.h:290