Cafu Engine
MapDocumentT Class Reference

This class represents a CaWE "map" document. More...

#include "MapDocument.hpp"

Inheritance diagram for MapDocumentT:

Public Member Functions

 MapDocumentT (GameConfigT *GameConfig, wxProgressDialog *ProgressDialog, const wxString &FileName)
 The regular constructor for loading a cmap file from disk. More...
 
 ~MapDocumentT ()
 The destructor. More...
 
bool OnSaveDocument (const wxString &FileName, bool IsAutoSave, IntrusivePtrT< cf::GameSys::EntityT > RootEntity=NULL)
 Saves the document. Non-const, as it updates the m_FileName member. More...
 
bool SaveAs ()
 Calls OnSaveDocument(). More...
 
bool Save ()
 Calls OnSaveDocument(). More...
 
void SetChildFrame (ChildFrameT *ChildFrame)
 
ChildFrameTGetChildFrame () const
 
const wxString & GetFileName () const
 
MapDocAdapterTGetAdapter ()
 
cf::GameSys::WorldTGetScriptWorld ()
 
bool CompatSubmitCommand (CommandT *Command)
 For compatibility only. This method should be removed. More...
 
IntrusivePtrT
< MapEditor::CompMapEntityT
GetRootMapEntity () const
 Returns the root "map" entity of the map. More...
 
void GetAllElems (ArrayT< MapElementT * > &Elems) const
 Adds all elements in this map (entity representations and primitives) to the given array. More...
 
void Insert (IntrusivePtrT< cf::GameSys::EntityT > Entity, IntrusivePtrT< cf::GameSys::EntityT > Parent, unsigned long Pos=0xFFFFFFFF)
 Inserts the given entity into the map. More...
 
void Insert (MapPrimitiveT *Prim, IntrusivePtrT< MapEditor::CompMapEntityT > ParentEnt)
 Inserts the given primitive into the map, as a child of the given entity (the world or a custom entity). More...
 
void Remove (IntrusivePtrT< cf::GameSys::EntityT > Entity)
 Removes the given entity from the map. More...
 
void Remove (MapPrimitiveT *Prim)
 Removes the given primitive from the map. More...
 
ArrayT< MapElementT * > GetElementsIn (const BoundingBox3fT &Box, bool InsideOnly, bool CenterOnly) const
 
void GetUsedMaterials (ArrayT< EditorMaterialI * > &UsedMaterials) const
 Determines all materials that are currently being used in the world (in brushes, Bezier patches and terrains), and returns the whole list via the UsedMaterials reference parameter. More...
 
OrthoBspTreeTGetBspTree () const
 
GameConfigTGetGameConfig () const
 
cf::SceneGraph::LightMapManTGetLightMapMan ()
 
PlantDescrManTGetPlantDescrMan ()
 
const ArrayT< PtsPointT > & GetPointFilePoints () const
 
const ArrayT< wxColour > & GetPointFileColors () const
 
bool IsSnapEnabled () const
 Returns whether or not grid snap is enabled. Called by the tools and views to determine snap behavior. More...
 
int GetGridSpacing () const
 
bool Is2DGridEnabled () const
 
float SnapToGrid (float f, bool Toggle) const
 Returns the given number f snapped to the grid if the grid is active, rounded to the nearest integer otherwise. If Toggle is true, the grid activity is considered toggled. More...
 
Vector3fT SnapToGrid (const Vector3fT &Pos, bool Toggle, int AxisNoSnap) const
 Returns the given vector Pos snapped to the grid if the grid is active, rounded to the nearest integer otherwise. If Toggle is true, the grid activity is considered toggled. If AxisNoSnap is -1, all components of Pos are snapped to the grid. If AxisNoSnap is 0, 1 or 2, the corresponding component of Pos is returned unchanged. More...
 
bool GetAutoGroupEntities () const
 
const ArrayT< GroupT * > & GetGroups () const
 Methods for managing the groups. More...
 
ArrayT< GroupT * > & GetGroups ()
 
ArrayT< GroupT * > GetAbandonedGroups () const
 Returns only the groups that are empty (have no members). More...
 
- Public Member Functions inherited from SubjectT
void RegisterObserver (ObserverT *Obs)
 Registers the observer Obs for notification on updates of this class. More...
 
void UnregisterObserver (ObserverT *Obs)
 Unregisters the observer Obs from further notification on updates of this class. More...
 
void UpdateAllObservers (MapDocOtherDetailT OtherDetail)
 
void UpdateAllObservers_SelectionChanged (const ArrayT< MapElementT * > &OldSelection, const ArrayT< MapElementT * > &NewSelection)
 
void UpdateAllObservers_GroupsChanged ()
 
void UpdateAllObservers_Created (const ArrayT< IntrusivePtrT< cf::GameSys::EntityT > > &Entities)
 
void UpdateAllObservers_Created (const ArrayT< MapPrimitiveT * > &Primitives)
 
void UpdateAllObservers_Deleted (const ArrayT< IntrusivePtrT< cf::GameSys::EntityT > > &Entites)
 
void UpdateAllObservers_Deleted (const ArrayT< MapPrimitiveT * > &Primitives)
 
void UpdateAllObservers_Modified (const ArrayT< MapElementT * > &MapElements, MapElemModDetailE Detail)
 
void UpdateAllObservers_Modified (const ArrayT< MapElementT * > &MapElements, MapElemModDetailE Detail, const ArrayT< BoundingBox3fT > &OldBounds)
 
void UpdateAllObservers_EntChanged (const ArrayT< IntrusivePtrT< MapEditor::CompMapEntityT > > &Entities, EntityModDetailE Detail)
 
void UpdateAllObservers_EntChanged (const ArrayT< IntrusivePtrT< cf::GameSys::EntityT > > &Entities, EntityModDetailE Detail)
 
void UpdateAllObservers_EntChanged (IntrusivePtrT< cf::GameSys::EntityT > Entity, EntityModDetailE Detail)
 
void UpdateAllObservers_VarChanged (const cf::TypeSys::VarBaseT &Var)
 
void UpdateAllObservers_SubjectDies ()
 
virtual ~SubjectT ()
 The virtual destructor. More...
 

Static Public Member Functions

static MapDocumentTCreateNew (GameConfigT *GameConfig)
 A named constructor for creating a new, empty map. More...
 
static MapDocumentTImportHalfLife1Map (GameConfigT *GameConfig, wxProgressDialog *ProgressDialog, const wxString &FileName)
 A named constructor for importing a map in HL1 map file format. More...
 
static MapDocumentTImportHalfLife2Vmf (GameConfigT *GameConfig, wxProgressDialog *ProgressDialog, const wxString &FileName)
 A named constructor for importing a map in HL2 vmf file format. More...
 
static MapDocumentTImportDoom3Map (GameConfigT *GameConfig, wxProgressDialog *ProgressDialog, const wxString &FileName)
 A named constructor for importing a map in Doom3 map file format. More...
 
static void SaveEntities (std::ostream &OutFile, IntrusivePtrT< cf::GameSys::EntityT > RootEntity)
 

Static Public Attributes

static const unsigned int CMAP_FILE_VERSION = 14
 
void SetSelection (const ArrayT< MapElementT * > &NewSelection)
 Methods for managing the set of currently selected map elements. More...
 
const ArrayT< MapElementT * > & GetSelection () const
 
ArrayT< IntrusivePtrT
< cf::GameSys::EntityT > > 
GetSelectedEntities () const
 
const BoundingBox3fTGetMostRecentSelBB () const
 Returns the most recent bounding-box of the selection. That is, it returns the bounding-box of the current selection, or (if nothing is selected) the bounding-box of the previous selection. More...
 
IntrusivePtrT
< cf::GameSys::EntityT
GetPasteParent () const
 Returns a suitable parent entity into which new objects from the clipboard should be pasted. More...
 
void SetPasteParent (unsigned int ID)
 
static void Reduce (ArrayT< MapElementT * > &Elems)
 Reduces the given set of map elements by removing each element whose parent is in the set as well. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SubjectT
 SubjectT ()
 The constructor. It is protected so that only derived classes can create instances of this class. More...
 

Detailed Description

This class represents a CaWE "map" document.

Constructor & Destructor Documentation

MapDocumentT::MapDocumentT ( GameConfigT GameConfig,
wxProgressDialog *  ProgressDialog,
const wxString &  FileName 
)

The regular constructor for loading a cmap file from disk.

Parameters
GameConfigThe game configuration that will be used for the map.
ProgressDialogIf non-NULL, this dialog is used to show the progress while loading the map.
FileNameThe name of the file to load the map from.
MapDocumentT::~MapDocumentT ( )

The destructor.

Member Function Documentation

bool MapDocumentT::CompatSubmitCommand ( CommandT Command)

For compatibility only. This method should be removed.

MapDocumentT * MapDocumentT::CreateNew ( GameConfigT GameConfig)
static

A named constructor for creating a new, empty map.

Parameters
GameConfigThe game configuration that will be used for the map.
ArrayT< GroupT * > MapDocumentT::GetAbandonedGroups ( ) const

Returns only the groups that are empty (have no members).

void MapDocumentT::GetAllElems ( ArrayT< MapElementT * > &  Elems) const

Adds all elements in this map (entity representations and primitives) to the given array.

The MapEntRepresT instance of the world entity is always the first element that is added to the list.

const ArrayT<GroupT*>& MapDocumentT::GetGroups ( ) const
inline

Methods for managing the groups.

const BoundingBox3fT & MapDocumentT::GetMostRecentSelBB ( ) const

Returns the most recent bounding-box of the selection. That is, it returns the bounding-box of the current selection, or (if nothing is selected) the bounding-box of the previous selection.

IntrusivePtrT< cf::GameSys::EntityT > MapDocumentT::GetPasteParent ( ) const

Returns a suitable parent entity into which new objects from the clipboard should be pasted.

IntrusivePtrT< MapEditor::CompMapEntityT > MapDocumentT::GetRootMapEntity ( ) const

Returns the root "map" entity of the map.

void MapDocumentT::GetUsedMaterials ( ArrayT< EditorMaterialI * > &  UsedMaterials) const

Determines all materials that are currently being used in the world (in brushes, Bezier patches and terrains), and returns the whole list via the UsedMaterials reference parameter.

MapDocumentT * MapDocumentT::ImportDoom3Map ( GameConfigT GameConfig,
wxProgressDialog *  ProgressDialog,
const wxString &  FileName 
)
static

A named constructor for importing a map in Doom3 map file format.

Parameters
GameConfigThe game configuration that will be used for the map.
ProgressDialogIf non-NULL, this dialog is used to show the progress while loading the map.
FileNameThe name of the file to load the map from.
MapDocumentT * MapDocumentT::ImportHalfLife1Map ( GameConfigT GameConfig,
wxProgressDialog *  ProgressDialog,
const wxString &  FileName 
)
static

A named constructor for importing a map in HL1 map file format.

Parameters
GameConfigThe game configuration that will be used for the map.
ProgressDialogIf non-NULL, this dialog is used to show the progress while loading the map.
FileNameThe name of the file to load the map from.
MapDocumentT * MapDocumentT::ImportHalfLife2Vmf ( GameConfigT GameConfig,
wxProgressDialog *  ProgressDialog,
const wxString &  FileName 
)
static

A named constructor for importing a map in HL2 vmf file format.

Parameters
GameConfigThe game configuration that will be used for the map.
ProgressDialogIf non-NULL, this dialog is used to show the progress while loading the map.
FileNameThe name of the file to load the map from.
void MapDocumentT::Insert ( IntrusivePtrT< cf::GameSys::EntityT Entity,
IntrusivePtrT< cf::GameSys::EntityT Parent,
unsigned long  Pos = 0xFFFFFFFF 
)

Inserts the given entity into the map.

Callers should never attempt to insert an element into the world in a way other than calling this method, as it also inserts the element into the internal BSP tree that is used for rendering and culling.

void MapDocumentT::Insert ( MapPrimitiveT Prim,
IntrusivePtrT< MapEditor::CompMapEntityT ParentEnt 
)

Inserts the given primitive into the map, as a child of the given entity (the world or a custom entity).

Callers should never attempt to insert an element into the world in a way other than calling this method, as it also inserts the element into the internal BSP tree that is used for rendering and culling.

bool MapDocumentT::IsSnapEnabled ( ) const
inline

Returns whether or not grid snap is enabled. Called by the tools and views to determine snap behavior.

bool MapDocumentT::OnSaveDocument ( const wxString &  FileName,
bool  IsAutoSave,
IntrusivePtrT< cf::GameSys::EntityT RootEntity = NULL 
)

Saves the document. Non-const, as it updates the m_FileName member.

void MapDocumentT::Reduce ( ArrayT< MapElementT * > &  Elems)
static

Reduces the given set of map elements by removing each element whose parent is in the set as well.

This is an important helper method for operations such as delete, copy-to-clipboard, save-as-prefab, etc.

void MapDocumentT::Remove ( IntrusivePtrT< cf::GameSys::EntityT Entity)

Removes the given entity from the map.

The entity cannot be the root entity (the world).

void MapDocumentT::Remove ( MapPrimitiveT Prim)

Removes the given primitive from the map.

bool MapDocumentT::Save ( )
bool MapDocumentT::SaveAs ( )
void MapDocumentT::SetSelection ( const ArrayT< MapElementT * > &  NewSelection)

Methods for managing the set of currently selected map elements.

float MapDocumentT::SnapToGrid ( float  f,
bool  Toggle 
) const

Returns the given number f snapped to the grid if the grid is active, rounded to the nearest integer otherwise. If Toggle is true, the grid activity is considered toggled.

Vector3fT MapDocumentT::SnapToGrid ( const Vector3fT Pos,
bool  Toggle,
int  AxisNoSnap 
) const

Returns the given vector Pos snapped to the grid if the grid is active, rounded to the nearest integer otherwise. If Toggle is true, the grid activity is considered toggled. If AxisNoSnap is -1, all components of Pos are snapped to the grid. If AxisNoSnap is 0, 1 or 2, the corresponding component of Pos is returned unchanged.


The documentation for this class was generated from the following files: