ufe  2.0
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/ufe-full-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  enum Type {None, Translate, Rotate, Scale, RotatePivot, ScalePivot};
35  EditTransform3dHint() = default;
37  EditTransform3dHint& operator=(const EditTransform3dHint&) = delete;
38  EditTransform3dHint(Type);
39  virtual ~EditTransform3dHint();
40 
41  inline Type type() const { return fType; }
42 
43 private:
44 
45  const Type fType{None};
46 };
47 
49 
88 {
89 public:
90  typedef std::shared_ptr<Transform3d> Ptr;
91 
99  static Ptr transform3d(const SceneItem::Ptr& item);
100 
110  static Ptr editTransform3d(
111  const SceneItem::Ptr& item,
113  );
114 
122  static bool addObserver(
123  const SceneItem::Ptr& item, const Observer::Ptr& obs);
131  static bool removeObserver(
132  const SceneItem::Ptr& item, const Observer::Ptr& obs);
133 
139  static std::size_t nbObservers(const SceneItem::Ptr& item);
140 
148  static bool hasObserver(
149  const SceneItem::Ptr& item, const Observer::Ptr& obs);
150 
153  static bool hasObservers(const Path& path);
154 
159  static bool hasObservers(Rtid runTimeId);
160 
164  static void notify(const Path& path);
165 
167  Transform3d();
169  Transform3d(const Transform3d&) = default;
171  virtual ~Transform3d();
172 
174  virtual const Path& path() const = 0;
175 
177  virtual SceneItem::Ptr sceneItem() const = 0;
178 
184  virtual TranslateUndoableCommand::Ptr translateCmd(
185  double x, double y, double z) = 0;
186 
188  return translateCmd(0, 0, 0); }
189 
195  virtual void translate(double x, double y, double z) {
196  auto cmd = translateCmd(x, y, z);
197  if (cmd) {
198  cmd->execute();
199  }
200  }
201 
204  virtual Vector3d translation() const = 0;
205 
212  virtual RotateUndoableCommand::Ptr rotateCmd(
213  double x, double y, double z) = 0;
214 
216  return rotateCmd(0, 0, 0); }
217 
223  virtual void rotate(double x, double y, double z) {
224  auto cmd = rotateCmd(x, y, z);
225  if (cmd) {
226  cmd->execute();
227  }
228  }
229 
233  virtual Vector3d rotation() const = 0;
234 
240  virtual ScaleUndoableCommand::Ptr scaleCmd(
241  double x, double y, double z) = 0;
242 
244  return scaleCmd(1, 1, 1); }
245 
251  virtual void scale(double x, double y, double z) {
252  auto cmd = scaleCmd(x, y, z);
253  if (cmd) {
254  cmd->execute();
255  }
256  }
257 
260  virtual Vector3d scale() const = 0;
261 
268  virtual TranslateUndoableCommand::Ptr rotatePivotCmd(
269  double x, double y, double z) = 0;
270 
272  return rotatePivotCmd(0, 0, 0); }
273 
279  virtual void rotatePivot(double x, double y, double z) {
280  auto cmd = rotatePivotCmd(x, y, z);
281  if (cmd) {
282  cmd->execute();
283  }
284  }
285 
288  virtual Vector3d rotatePivot() const = 0;
289 
296  virtual TranslateUndoableCommand::Ptr scalePivotCmd(
297  double x, double y, double z) = 0;
298 
300  return scalePivotCmd(0, 0, 0); }
301 
307  virtual void scalePivot(double x, double y, double z) {
308  auto cmd = scalePivotCmd(x, y, z);
309  if (cmd) {
310  cmd->execute();
311  }
312  }
313 
316  virtual Vector3d scalePivot() const = 0;
317 
328  double x, double y, double z) {
329  (void) x; (void) y; (void) z;
330  return nullptr;
331  }
332 
334  return translateRotatePivotCmd(0, 0, 0); }
335 
342  virtual void translateRotatePivot(double x, double y, double z) {
343  auto cmd = translateRotatePivotCmd(x, y, z);
344  if (cmd) {
345  cmd->execute();
346  }
347  }
348 
353  return Vector3d(0, 0, 0);
354  }
355 
366  double x, double y, double z) {
367  (void) x; (void) y; (void) z;
368  return nullptr;
369  }
370 
372  return translateScalePivotCmd(0, 0, 0); }
373 
379  virtual void translateScalePivot(double x, double y, double z) {
380  auto cmd = translateScalePivotCmd(x, y, z);
381  if (cmd) {
382  cmd->execute();
383  }
384  }
385 
389  virtual Vector3d scalePivotTranslation() const {
390  return Vector3d(0, 0, 0);
391  }
392 
402  double x, double y, double z) {
403  (void) x; (void) y; (void) z;
404  return nullptr;
405  }
406 
408  return rotateAxisCmd(0, 0, 0); }
409 
415  virtual void rotateAxis(double x, double y, double z) {
416  auto cmd = rotateAxisCmd(x, y, z);
417  if (cmd) {
418  cmd->execute();
419  }
420  }
421 
424  virtual Vector3d rotateAxis() const {
425  return Vector3d(0, 0, 0);
426  }
427 
436  double xy, double xz, double yz) {
437  (void) xy; (void) xz; (void) yz;
438  return nullptr;
439  }
440 
442  return shearCmd(0, 0, 0); }
443 
449  virtual void shear(double xy, double xz, double yz) {
450  auto cmd = shearCmd(xy, xz, yz);
451  if (cmd) {
452  cmd->execute();
453  }
454  }
455 
459  virtual Vector3d shear() const {
460  return Vector3d(0, 0, 0);
461  }
462 
467  virtual SetMatrix4dUndoableCommand::Ptr setMatrixCmd(const Matrix4d& m) = 0;
468 
473  virtual void setMatrix(const Matrix4d& m) {
474  auto cmd = setMatrixCmd(m);
475  if (cmd) {
476  cmd->execute();
477  }
478  }
479 
482  virtual Matrix4d matrix() const = 0;
483 
487  Matrix4d inclusiveMatrix() const;
488 
492  Matrix4d exclusiveMatrix() const;
493 
501  virtual Matrix4d segmentInclusiveMatrix() const = 0;
502 
510  virtual Matrix4d segmentExclusiveMatrix() const = 0;
511 };
512 
513 }
514 
515 #endif /* _transform3d */
std::shared_ptr< SetValue3UndoableCommand > Ptr
TypedVector3< double > Vector3d
Definition: types.h:56
TranslateUndoableCommand::Ptr translateCmd()
Definition: transform3d.h:187
virtual void translate(double x, double y, double z)
Definition: transform3d.h:195
Abstract base class for 3D transform interface.
Definition: transform3d.h:87
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:307
virtual Vector3d scalePivotTranslation() const
Definition: transform3d.h:389
std::shared_ptr< Transform3d > Ptr
Definition: transform3d.h:90
ScaleUndoableCommand::Ptr scaleCmd()
Definition: transform3d.h:243
virtual void scale(double x, double y, double z)
Definition: transform3d.h:251
TranslateUndoableCommand::Ptr scalePivotCmd()
Definition: transform3d.h:299
virtual Vector3d rotatePivotTranslation() const
Definition: transform3d.h:352
RotateUndoableCommand::Ptr rotateAxisCmd()
Definition: transform3d.h:407
RotateUndoableCommand::Ptr rotateCmd()
Definition: transform3d.h:215
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:473
ShearUndoableCommand::Ptr shearCmd()
Definition: transform3d.h:441
uint32_t Rtid
Definition: rtid.h:26
TranslateUndoableCommand::Ptr translateRotatePivotCmd()
Definition: transform3d.h:333
virtual RotateUndoableCommand::Ptr rotateAxisCmd(double x, double y, double z)
Definition: transform3d.h:401
virtual Vector3d shear() const
Definition: transform3d.h:459
virtual void translateRotatePivot(double x, double y, double z)
Definition: transform3d.h:342
#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:415
virtual TranslateUndoableCommand::Ptr translateRotatePivotCmd(double x, double y, double z)
Definition: transform3d.h:327
Path path(const std::string &pathString)
virtual void translateScalePivot(double x, double y, double z)
Definition: transform3d.h:379
virtual void shear(double xy, double xz, double yz)
Definition: transform3d.h:449
virtual void rotatePivot(double x, double y, double z)
Definition: transform3d.h:279
virtual Vector3d rotateAxis() const
Definition: transform3d.h:424
virtual TranslateUndoableCommand::Ptr translateScalePivotCmd(double x, double y, double z)
Definition: transform3d.h:365
TranslateUndoableCommand::Ptr translateScalePivotCmd()
Definition: transform3d.h:371
virtual ShearUndoableCommand::Ptr shearCmd(double xy, double xz, double yz)
Definition: transform3d.h:435
#define UFE_SDK_DECL
Definition: ufeExport.h:36
virtual void rotate(double x, double y, double z)
Definition: transform3d.h:223
TranslateUndoableCommand::Ptr rotatePivotCmd()
Definition: transform3d.h:271