OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pathgrid.hpp
Go to the documentation of this file.
1 #ifndef CSV_RENDER_PATHGRID_H
2 #define CSV_RENDER_PATHGRID_H
3 
4 #include <vector>
5 
6 #include <QString>
7 #include <osg/ref_ptr>
8 #include <osg/Vec3d>
9 
10 #include "../../model/world/cellcoordinates.hpp"
11 #include "../../model/world/idcollection.hpp"
12 #include "../../model/world/subcellcollection.hpp"
13 
14 #include "tagbase.hpp"
15 
16 namespace osg
17 {
18  class Geode;
19  class Geometry;
20  class Group;
21  class PositionAttitudeTransform;
22 }
23 
24 namespace CSMWorld
25 {
26  class CommandMacro;
27  class Data;
28  struct Pathgrid;
29 }
30 
31 namespace CSVRender
32 {
33  class Pathgrid;
34 
35  class PathgridTag : public TagBase
36  {
37  public:
38 
39  PathgridTag (Pathgrid* pathgrid);
40 
41  Pathgrid* getPathgrid () const;
42 
43  virtual QString getToolTip (bool hideBasics) const;
44 
45  private:
46 
48  };
49 
50  class Pathgrid
51  {
52  public:
53 
54  typedef std::vector<unsigned short> NodeList;
55 
56  Pathgrid(CSMWorld::Data& data, osg::Group* parent, const std::string& pathgridId,
57  const CSMWorld::CellCoordinates& coordinates);
58 
59  ~Pathgrid();
60 
62  const std::string& getId() const;
63 
64  bool isSelected() const;
65  const NodeList& getSelected() const;
66  void selectAll();
67  void toggleSelected(unsigned short node); // Adds to end of vector
68  void invertSelected();
69  void clearSelected();
70 
71  void moveSelected(const osg::Vec3d& offset);
72  void setDragOrigin(unsigned short node);
73  void setDragEndpoint(unsigned short node);
74  void setDragEndpoint(const osg::Vec3d& pos);
75 
76  void resetIndicators();
77 
78  void applyPoint(CSMWorld::CommandMacro& commands, const osg::Vec3d& worldPos);
79  void applyPosition(CSMWorld::CommandMacro& commands);
80  void applyEdge(CSMWorld::CommandMacro& commands, unsigned short node1, unsigned short node2);
81  void applyEdges(CSMWorld::CommandMacro& commands, unsigned short node);
84 
85  osg::ref_ptr<PathgridTag> getTag() const;
86 
87  void recreateGeometry();
88  void removeGeometry();
89 
90  void update();
91 
92  private:
93 
96  std::string mId;
98  bool mInterior;
99 
101  osg::Vec3d mMoveOffset;
102  unsigned short mDragOrigin;
103 
107 
108  osg::Group* mParent;
109  osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
110  osg::ref_ptr<osg::Geode> mPathgridGeode;
111  osg::ref_ptr<osg::Geometry> mPathgridGeometry;
112  osg::ref_ptr<osg::Geometry> mSelectedGeometry;
113  osg::ref_ptr<osg::Geometry> mDragGeometry;
114 
115  osg::ref_ptr<PathgridTag> mTag;
116 
117  void createGeometry();
118  void createSelectedGeometry();
119  void createSelectedGeometry(const CSMWorld::Pathgrid& source);
120  void removePathgridGeometry();
121  void removeSelectedGeometry();
122 
123  void createDragGeometry(const osg::Vec3f& start, const osg::Vec3f& end, bool valid);
124 
126 
127  int edgeExists(const CSMWorld::Pathgrid& source, unsigned short node1, unsigned short node2);
128  void addEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
129  unsigned short node2);
130  void removeEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
131  unsigned short node2);
132 
133  int clampToCell(int v);
134  };
135 }
136 
137 #endif
Pathgrid * getPathgrid() const
Definition: pathgrid.cpp:38
bool mInterior
Definition: pathgrid.hpp:98
void createDragGeometry(const osg::Vec3f &start, const osg::Vec3f &end, bool valid)
Definition: pathgrid.cpp:577
void applyPosition(CSMWorld::CommandMacro &commands)
Definition: pathgrid.cpp:290
void addEdge(CSMWorld::CommandMacro &commands, const CSMWorld::Pathgrid &source, unsigned short node1, unsigned short node2)
Definition: pathgrid.cpp:633
void applyRemoveNodes(CSMWorld::CommandMacro &commands)
Definition: pathgrid.cpp:355
std::vector< unsigned short > NodeList
Definition: pathgrid.hpp:54
CSMWorld::SubCellCollection< CSMWorld::Pathgrid > & mPathgridCollection
Definition: pathgrid.hpp:95
const std::string & getId() const
Definition: pathgrid.cpp:99
void resetIndicators()
Definition: pathgrid.cpp:216
void invertSelected()
Definition: pathgrid.cpp:147
void selectAll()
Definition: pathgrid.cpp:114
virtual QString getToolTip(bool hideBasics) const
Definition: pathgrid.cpp:43
bool mChangeGeometry
Definition: pathgrid.hpp:104
void removeSelectedGeometry()
Definition: pathgrid.cpp:568
std::string mId
Definition: pathgrid.hpp:96
osg::ref_ptr< osg::Geometry > mSelectedGeometry
Definition: pathgrid.hpp:112
PathgridTag(Pathgrid *pathgrid)
Definition: pathgrid.cpp:33
void recreateGeometry()
Definition: pathgrid.cpp:479
osg::ref_ptr< osg::PositionAttitudeTransform > mBaseNode
Definition: pathgrid.hpp:109
void createGeometry()
Definition: pathgrid.cpp:505
void moveSelected(const osg::Vec3d &offset)
Definition: pathgrid.cpp:175
Definition: pathgrid.hpp:35
int clampToCell(int v)
Definition: pathgrid.cpp:667
void clearSelected()
Definition: pathgrid.cpp:169
bool mUseOffset
Definition: pathgrid.hpp:106
void removeGeometry()
Definition: pathgrid.cpp:484
const CSMWorld::CellCoordinates & getCoordinates() const
Definition: pathgrid.cpp:94
void toggleSelected(unsigned short node)
Definition: pathgrid.cpp:132
void setDragOrigin(unsigned short node)
Definition: pathgrid.cpp:183
void removePathgridGeometry()
Definition: pathgrid.cpp:559
Definition: commandmacro.hpp:11
Definition: pathgrid.hpp:50
Definition: data.hpp:77
CSMWorld::Data & mData
Definition: pathgrid.hpp:94
Definition: tagbase.hpp:12
unsigned short mDragOrigin
Definition: pathgrid.hpp:102
osg::Vec3d mMoveOffset
Definition: pathgrid.hpp:101
void update()
Definition: pathgrid.cpp:489
Definition: cellcoordinates.hpp:12
Wrapper for Pathgrid record.
Definition: pathgrid.hpp:19
CSMWorld::CellCoordinates mCoords
Definition: pathgrid.hpp:97
void applyRemoveEdges(CSMWorld::CommandMacro &commands)
Definition: pathgrid.cpp:436
void applyPoint(CSMWorld::CommandMacro &commands, const osg::Vec3d &worldPos)
Definition: pathgrid.cpp:225
NodeList mSelected
Definition: pathgrid.hpp:100
~Pathgrid()
Definition: pathgrid.cpp:89
osg::ref_ptr< osg::Geometry > mDragGeometry
Definition: pathgrid.hpp:113
void removeEdge(CSMWorld::CommandMacro &commands, const CSMWorld::Pathgrid &source, unsigned short node1, unsigned short node2)
const NodeList & getSelected() const
Definition: pathgrid.cpp:109
void applyEdges(CSMWorld::CommandMacro &commands, unsigned short node)
Definition: pathgrid.cpp:343
Pathgrid(CSMWorld::Data &data, osg::Group *parent, const std::string &pathgridId, const CSMWorld::CellCoordinates &coordinates)
Definition: pathgrid.cpp:51
osg::ref_ptr< PathgridTag > mTag
Definition: pathgrid.hpp:115
Pathgrid * mPathgrid
Definition: pathgrid.hpp:47
osg::ref_ptr< PathgridTag > getTag() const
Definition: pathgrid.cpp:474
bool mRemoveGeometry
Definition: pathgrid.hpp:105
int edgeExists(const CSMWorld::Pathgrid &source, unsigned short node1, unsigned short node2)
Definition: pathgrid.cpp:622
osg::Group * mParent
Definition: pathgrid.hpp:108
void applyEdge(CSMWorld::CommandMacro &commands, unsigned short node1, unsigned short node2)
Definition: pathgrid.cpp:334
bool isSelected() const
Definition: pathgrid.cpp:104
const CSMWorld::Pathgrid * getPathgridSource()
Definition: pathgrid.cpp:611
void setDragEndpoint(unsigned short node)
Definition: pathgrid.cpp:188
osg::ref_ptr< osg::Geometry > mPathgridGeometry
Definition: pathgrid.hpp:111
osg::ref_ptr< osg::Geode > mPathgridGeode
Definition: pathgrid.hpp:110
void createSelectedGeometry()
Definition: pathgrid.cpp:538