Cafu Engine
AddPrim.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_ADD_PRIMITIVE_HPP_INCLUDED
8 #define CAFU_COMMAND_ADD_PRIMITIVE_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 #include "Templates/Pointer.hpp"
12 
13 
14 namespace MapEditor { class CompMapEntityT; }
15 class MapDocumentT;
16 class MapElementT;
17 class MapPrimitiveT;
18 class CommandSelectT;
19 
20 
21 /// This class implements a command for adding primitives into the map, as part of their specified parent entities.
22 /// It is quasi the counterpart to CommandDeleteT.
23 class CommandAddPrimT : public CommandT
24 {
25  public:
26 
27  /// The constructor for creating a command for adding a single primitive into the map.
28  /// @param MapDoc The map document into which the primitive is inserted.
29  /// @param AddPrim The primitive to add. NOTE: AddPrim->GetParent()==NULL is assumed, i.e. AddPrim has no prior parent!
30  /// @param Parent The parent entity that the primitive becomes a part of and which it is added to. Can be the world or a custom entity.
31  /// @param Name The name of this command for the undo history.
32  /// @param SetSel Whether the selection should be set to the newly added map primitive(s).
33  CommandAddPrimT(MapDocumentT& MapDoc, MapPrimitiveT* AddPrim, IntrusivePtrT<MapEditor::CompMapEntityT> Parent, wxString Name="new primitive", bool SetSel=true);
34 
35  /// The constructor for creating a command for adding multiple primitives into the map.
36  /// Analogous to the constructor for adding a single primitive above.
37  CommandAddPrimT(MapDocumentT& MapDoc, const ArrayT<MapPrimitiveT*>& AddPrims, IntrusivePtrT<MapEditor::CompMapEntityT> Parent, wxString Name="new primitives", bool SetSel=true);
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  MapDocumentT& m_MapDoc;
51  ArrayT<MapPrimitiveT*> m_AddPrims;
53  CommandSelectT* m_CommandSelect; ///< Subcommand for changing the selection.
54  wxString m_Name;
55 };
56 
57 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
This class adds no functionality of its own, but only exists for proper type separation.
Definition: MapPrimitive.hpp:21
Definition: Select.hpp:18
CommandAddPrimT(MapDocumentT &MapDoc, MapPrimitiveT *AddPrim, IntrusivePtrT< MapEditor::CompMapEntityT > Parent, wxString Name="new primitive", bool SetSel=true)
The constructor for creating a command for adding a single primitive into the map.
Definition: AddPrim.cpp:17
bool Do()
This method executes the command.
Definition: AddPrim.cpp:53
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
wxString GetName() const
Returns the name (a description) of the command.
Definition: AddPrim.cpp:94
~CommandAddPrimT()
The destructor.
Definition: AddPrim.cpp:43
This is the base class for all elements ("objects") that can exist in a map.
Definition: MapElement.hpp:57
void Undo()
This method un-does the command.
Definition: AddPrim.cpp:74
This class implements a command for adding primitives into the map, as part of their specified parent...
Definition: AddPrim.hpp:23