Cafu Engine
ModifyTerrain.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_MODIFY_TERRAIN_HPP_INCLUDED
8 #define CAFU_COMMAND_MODIFY_TERRAIN_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 
12 
13 class MapDocumentT;
14 class MapTerrainT;
15 
16 
18 {
19  public:
20 
21  /// Constructor to modify a terrain with given new height data.
22  /// The terrains current height data is overwritten with the passed new height data.
23  /// Note that the dimensions of the passed NewHeightData cannot be greater than the dimensions of the current height data.
24  /// @param MapDoc The map document in which the terrain is existent.
25  /// @param Terrain Pointer to the terrain object that is to be modified.
26  /// @param NewHeightData The height data with which the terrain is modified.
27  /// @param Position The position in the terrains current height data. Beginning at this position the height data is overwritten with the new data from NewHeightData.
28  /// @param SizeX X size of the new height data.
29  /// @param SizeY Y size of the new height data.
30  CommandModifyTerrainT(MapDocumentT& MapDoc, MapTerrainT* Terrain, const ArrayT<unsigned short>& NewHeightData, const wxPoint& Position, unsigned int SizeX, unsigned int SizeY);
31 
32  // CommandT implementation.
33  bool Do();
34  void Undo();
35  wxString GetName() const;
36 
37 
38  private:
39 
40  MapDocumentT& m_MapDoc; ///< The map document in which the terrain is existent.
41  MapTerrainT* m_Terrain; ///< The terrain object that is to be modified.
42  const ArrayT<unsigned short> m_NewHeightData; ///< The height data with which the terrain is modified.
43  ArrayT<unsigned short> m_PrevHeightData; ///< Backup of the terrains previous heigth data.
44  const wxPoint m_Offset; ///< The x/y offset in the terrains current height data.
45  const unsigned int m_SizeX; ///< SizeX X size of the new height data.
46  const unsigned int m_SizeY; ///< SizeY Y size of the new height data.
47 };
48 
49 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
bool Do()
This method executes the command.
Definition: ModifyTerrain.cpp:26
CommandModifyTerrainT(MapDocumentT &MapDoc, MapTerrainT *Terrain, const ArrayT< unsigned short > &NewHeightData, const wxPoint &Position, unsigned int SizeX, unsigned int SizeY)
Constructor to modify a terrain with given new height data.
Definition: ModifyTerrain.cpp:15
Definition: ModifyTerrain.hpp:17
The TerrainT class represents a terrain in a map.
Definition: MapTerrain.hpp:22
wxString GetName() const
Returns the name (a description) of the command.
Definition: ModifyTerrain.cpp:85
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
void Undo()
This method un-does the command.
Definition: ModifyTerrain.cpp:62