Cafu Engine
Transform.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_COMMAND_TRANSFORM_HPP_INCLUDED
8 #define CAFU_COMMAND_TRANSFORM_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 #include "Math3D/Matrix.hpp"
12 #include "Math3D/Vector3.hpp"
13 
14 
15 class MapDocumentT;
16 class MapElementT;
17 class TrafoMementoT;
18 
19 
20 /// Command to transform an object or a list of objects using a delta and a transform mode.
22 {
23  public:
24 
25  /// This enum describes the kind of transformation that is to be applied by a CommandTransformT.
27  {
28  MODE_TRANSLATE,
29  MODE_ROTATE,
30  MODE_SCALE,
31  MODE_MATRIX
32  };
33 
34 
35  /// The constructor to transform an array of map elements using a delta and a transform mode.
36  CommandTransformT(MapDocumentT& MapDoc, const ArrayT<MapElementT*>& TransElems, TransModeT Mode, const Vector3fT& RefPoint, const Vector3fT& Amount, bool LockTexCoords);
37  CommandTransformT(MapDocumentT& MapDoc, const ArrayT<MapElementT*>& TransElems, const MatrixT& Matrix, bool LockTexCoords);
38 
39  /// The destructor.
41 
42  // Implementation of the CommandT interface.
43  bool Do();
44  void Undo();
45  wxString GetName() const;
46 
47 
48  private:
49 
50  void Init();
51 
52  MapDocumentT& m_MapDoc; ///< The map document that is (whose elements are) modified.
53  const ArrayT<MapElementT*> m_TransElems; ///< The map elements (of m_MapDoc) that are to be transformed.
54  ArrayT<TrafoMementoT*> m_OldStates; ///< The old states of the map elements, for the Undo() operation.
55  const TransModeT m_Mode; ///< The kind of transformation to apply to the m_TransElems.
56  const Vector3fT m_RefPoint; ///< Ignored for translations, the reference point for scales and rotations.
57  const Vector3fT m_Amount; ///< The delta for translations, the scale factors for scales, the angles for rotations.
58  const MatrixT m_Matrix; ///< The matrix for generic matrix transformations.
59  const bool m_LockTexCoords; ///< Transform the texture-space along with the geometry?
60 };
61 
62 #endif
TransModeT
This enum describes the kind of transformation that is to be applied by a CommandTransformT.
Definition: Transform.hpp:26
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
wxString GetName() const
Returns the name (a description) of the command.
Definition: Transform.cpp:111
An instance of this class encapsulates the transform-related state of a MapElementT.
Definition: MapElement.hpp:39
void Undo()
This method un-does the command.
Definition: Transform.cpp:91
bool Do()
This method executes the command.
Definition: Transform.cpp:63
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
Command to transform an object or a list of objects using a delta and a transform mode...
Definition: Transform.hpp:21
~CommandTransformT()
The destructor.
Definition: Transform.cpp:54
This is the base class for all elements ("objects") that can exist in a map.
Definition: MapElement.hpp:57
CommandTransformT(MapDocumentT &MapDoc, const ArrayT< MapElementT * > &TransElems, TransModeT Mode, const Vector3fT &RefPoint, const Vector3fT &Amount, bool LockTexCoords)
The constructor to transform an array of map elements using a delta and a transform mode...
Definition: Transform.cpp:13