Cafu Engine
ChangeTerrainRes.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_CHANGE_TERRAIN_RES_HPP_INCLUDED
8 #define CAFU_COMMAND_CHANGE_TERRAIN_RES_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 
12 #include "Templates/Array.hpp"
13 
14 
15 class MapDocumentT;
16 class MapTerrainT;
17 
18 
20 {
21  public:
22 
23  /// Constructor to change a terrain resolution.
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 NewResolution The resolution this terrain is changed to.
27  CommandChangeTerrainResT(MapDocumentT& MapDoc, MapTerrainT* Terrain, unsigned int NewResolution);
28 
29  // CommandT implementation.
30  bool Do();
31  void Undo();
32  wxString GetName() const;
33 
34 
35  private:
36 
37  MapDocumentT& m_MapDoc;
38  MapTerrainT* m_Terrain;
39  ArrayT<unsigned short> m_NewHeightData;
40  const ArrayT<unsigned short> m_PrevHeightData;
41  const unsigned int m_NewResolution;
42  const unsigned int m_PrevResolution;
43 
44  // Calculates the value of position x/y in the previous height data array as a bilinear interpolated value.
45  unsigned short BilinearInterpolation(float x, float y);
46 };
47 
48 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
The TerrainT class represents a terrain in a map.
Definition: MapTerrain.hpp:22
Definition: ChangeTerrainRes.hpp:19
bool Do()
This method executes the command.
Definition: ChangeTerrainRes.cpp:59
void Undo()
This method un-does the command.
Definition: ChangeTerrainRes.cpp:83
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
CommandChangeTerrainResT(MapDocumentT &MapDoc, MapTerrainT *Terrain, unsigned int NewResolution)
Constructor to change a terrain resolution.
Definition: ChangeTerrainRes.cpp:39
wxString GetName() const
Returns the name (a description) of the command.
Definition: ChangeTerrainRes.cpp:105