OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cell.hpp
Go to the documentation of this file.
1 #ifndef OPENCS_VIEW_CELL_H
2 #define OPENCS_VIEW_CELL_H
3 
4 #include <string>
5 #include <map>
6 #include <memory>
7 #include <vector>
8 
9 #include <osg/ref_ptr>
10 
11 #include "../../model/world/cellcoordinates.hpp"
12 
13 class QModelIndex;
14 
15 namespace osg
16 {
17  class Group;
18  class Geometry;
19  class Geode;
20 }
21 
22 namespace CSMWorld
23 {
24  class Data;
25 }
26 
27 namespace Terrain
28 {
29  class TerrainGrid;
30 }
31 
32 namespace CSVRender
33 {
34  class CellWater;
35  class Pathgrid;
36  class TagBase;
37  class Object;
38 
39  class CellArrow;
40  class CellBorder;
41  class CellMarker;
42  class CellWater;
43 
44  class Cell
45  {
47  std::string mId;
48  osg::ref_ptr<osg::Group> mCellNode;
49  std::map<std::string, Object *> mObjects;
50  std::unique_ptr<Terrain::TerrainGrid> mTerrain;
52  std::unique_ptr<CellArrow> mCellArrows[4];
53  std::unique_ptr<CellMarker> mCellMarker;
54  std::unique_ptr<CellBorder> mCellBorder;
55  std::unique_ptr<CellWater> mCellWater;
56  std::unique_ptr<Pathgrid> mPathgrid;
57  bool mDeleted;
58  int mSubMode;
59  unsigned int mSubModeElementMask;
61 
65  bool removeObject (const std::string& id);
66 
67  // Remove object and return iterator to next object.
68  std::map<std::string, Object *>::iterator removeObject (
69  std::map<std::string, Object *>::iterator iter);
70 
74  bool addObjects (int start, int end);
75 
76  void updateLand();
77  void unloadLand();
78 
79  public:
80 
81  enum Selection
82  {
86  };
87 
88  public:
89 
92  Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id,
93  bool deleted = false);
94 
95  ~Cell();
96 
98  Pathgrid* getPathgrid() const;
99 
102  bool referenceableDataChanged (const QModelIndex& topLeft,
103  const QModelIndex& bottomRight);
104 
107  bool referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end);
108 
111  bool referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
112 
115  bool referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end);
116 
119  bool referenceAdded (const QModelIndex& parent, int start, int end);
120 
121  void pathgridModified();
122 
123  void pathgridRemoved();
124 
125  void landDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
126 
127  void landAboutToBeRemoved (const QModelIndex& parent, int start, int end);
128 
129  void landAdded (const QModelIndex& parent, int start, int end);
130 
131  void landTextureChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
132 
133  void landTextureAboutToBeRemoved (const QModelIndex& parent, int start, int end);
134 
135  void landTextureAdded (const QModelIndex& parent, int start, int end);
136 
137  void reloadAssets();
138 
139  void setSelection (int elementMask, Selection mode);
140 
141  // Select everything that references the same ID as at least one of the elements
142  // already selected
143  void selectAllWithSameParentId (int elementMask);
144 
145  void setCellArrows (int mask);
146 
148  void setCellMarker();
149 
152 
153  bool isDeleted() const;
154 
155  std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask) const;
156 
157  std::vector<osg::ref_ptr<TagBase> > getEdited (unsigned int elementMask) const;
158 
159  void setSubMode (int subMode, unsigned int elementMask);
160 
163  void reset (unsigned int elementMask);
164 
165  friend class CellNodeCallback;
166  };
167 }
168 
169 #endif
std::unique_ptr< Pathgrid > mPathgrid
Definition: cell.hpp:56
bool addObjects(int start, int end)
Definition: cell.cpp:77
bool referenceableAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:225
void landDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: cell.cpp:362
Definition: cell.hpp:85
Simple terrain implementation that loads cells in a grid, with no LOD. Only requested cells are loade...
Definition: terraingrid.hpp:14
void setCellArrows(int mask)
Definition: cell.cpp:476
void landAdded(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:373
bool referenceableDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: cell.cpp:212
std::string mId
Definition: cell.hpp:47
CSMWorld::CellCoordinates mCoordinates
Definition: cell.hpp:51
void pathgridModified()
Definition: cell.cpp:350
bool referenceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: cell.cpp:241
std::unique_ptr< CellWater > mCellWater
Definition: cell.hpp:55
std::unique_ptr< CellMarker > mCellMarker
Definition: cell.hpp:53
void updateLand()
Definition: cell.cpp:106
osg::ref_ptr< osg::Group > mCellNode
Definition: cell.hpp:48
Cell(CSMWorld::Data &data, osg::Group *rootNode, const std::string &id, bool deleted=false)
Definition: cell.cpp:165
void reloadAssets()
Definition: cell.cpp:394
std::unique_ptr< CellBorder > mCellBorder
Definition: cell.hpp:54
void landAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:367
bool removeObject(const std::string &id)
Definition: cell.cpp:57
void landTextureChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: cell.cpp:379
void selectAllWithSameParentId(int elementMask)
Definition: cell.cpp:454
std::vector< osg::ref_ptr< TagBase > > getEdited(unsigned int elementMask) const
Definition: cell.cpp:538
bool referenceAdded(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:339
unsigned int mSubModeElementMask
Definition: cell.hpp:59
void setSubMode(int subMode, unsigned int elementMask)
Definition: cell.cpp:551
bool mDeleted
Definition: cell.hpp:57
void setSelection(int elementMask, Selection mode)
Definition: cell.cpp:412
Definition: cell.hpp:83
Definition: cell.hpp:84
std::unique_ptr< Terrain::TerrainGrid > mTerrain
Definition: cell.hpp:50
Definition: pathgrid.hpp:50
Selection
Definition: cell.hpp:81
Definition: cell.cpp:44
void setCellMarker()
Set marker for this cell.
Definition: cell.cpp:494
Definition: data.hpp:80
CSMWorld::Data & mData
Definition: cell.hpp:46
bool isDeleted() const
Definition: cell.cpp:517
std::unique_ptr< CellArrow > mCellArrows[4]
Definition: cell.hpp:52
bool mLandDeleted
Definition: cell.hpp:60
bool mUpdateLand
Definition: cell.hpp:60
void landTextureAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:384
Definition: cellcoordinates.hpp:12
bool referenceAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:315
void unloadLand()
Definition: cell.cpp:156
int mSubMode
Definition: cell.hpp:58
Pathgrid * getPathgrid() const
Definition: cell.cpp:207
Definition: cell.hpp:44
std::vector< osg::ref_ptr< TagBase > > getSelection(unsigned int elementMask) const
Definition: cell.cpp:522
CSMWorld::CellCoordinates getCoordinates() const
Returns 0, 0 in case of an unpaged cell.
Definition: cell.cpp:512
void landTextureAdded(const QModelIndex &parent, int start, int end)
Definition: cell.cpp:389
void pathgridRemoved()
Definition: cell.cpp:356
~Cell()
Definition: cell.cpp:198
void reset(unsigned int elementMask)
Definition: cell.cpp:562
std::map< std::string, Object * > mObjects
Definition: cell.hpp:49