~openmw/openmw/openmw-packaging2

« back to all changes in this revision

Viewing changes to apps/opencs/view/render/pathgrid.hpp

  • Committer: Scott Howard
  • Date: 2016-09-15 20:56:29 UTC
  • Revision ID: showard@debian.org-20160915205629-3tvfxe47zrb41a91
Cron update. Git hash: 37278b5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
47
            Pathgrid* mPathgrid;
 
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
 
 
61
            const CSMWorld::CellCoordinates& getCoordinates() const;
 
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);
 
82
            void applyRemoveNodes(CSMWorld::CommandMacro& commands);
 
83
            void applyRemoveEdges(CSMWorld::CommandMacro& commands);
 
84
 
 
85
            osg::ref_ptr<PathgridTag> getTag() const;
 
86
 
 
87
            void recreateGeometry();
 
88
            void removeGeometry();
 
89
 
 
90
            void update();
 
91
 
 
92
        private:
 
93
 
 
94
            CSMWorld::Data& mData;
 
95
            CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& mPathgridCollection;
 
96
            std::string mId;
 
97
            CSMWorld::CellCoordinates mCoords;
 
98
            bool mInterior;
 
99
 
 
100
            NodeList mSelected;
 
101
            osg::Vec3d mMoveOffset;
 
102
            unsigned short mDragOrigin;
 
103
 
 
104
            bool mChangeGeometry;
 
105
            bool mRemoveGeometry;
 
106
            bool mUseOffset;
 
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
 
 
125
            const CSMWorld::Pathgrid* getPathgridSource();
 
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