1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#ifndef CSV_RENDER_PATHGRID_H
#define CSV_RENDER_PATHGRID_H
#include <algorithm>
#include <string>
#include <vector>
#include <QString>
#include <osg/Vec3d>
#include <osg/ref_ptr>
#include "../../model/world/cellcoordinates.hpp"
#include "../../model/world/subcellcollection.hpp"
#include "tagbase.hpp"
#include <components/esm/refid.hpp>
namespace osg
{
class Vec3f;
class Geometry;
class Group;
class PositionAttitudeTransform;
}
namespace CSMWorld
{
class CommandMacro;
class Data;
struct Pathgrid;
}
namespace CSVRender
{
class Pathgrid;
struct WorldspaceHitResult;
class PathgridTag : public TagBase
{
public:
PathgridTag(Pathgrid* pathgrid);
Pathgrid* getPathgrid() const;
QString getToolTip(bool hideBasics, const WorldspaceHitResult& hit) const override;
private:
Pathgrid* mPathgrid;
};
class Pathgrid
{
public:
typedef std::vector<unsigned short> NodeList;
Pathgrid(CSMWorld::Data& data, osg::Group* parent, const std::string& pathgridId,
const CSMWorld::CellCoordinates& coordinates);
~Pathgrid();
const CSMWorld::CellCoordinates& getCoordinates() const;
const std::string& getId() const;
bool isSelected() const;
const NodeList& getSelected() const;
void selectAll();
void toggleSelected(unsigned short node); // Adds to end of vector
void invertSelected();
void clearSelected();
void moveSelected(const osg::Vec3d& offset);
void setDragOrigin(unsigned short node);
void setDragEndpoint(unsigned short node);
void setDragEndpoint(const osg::Vec3d& pos);
void resetIndicators();
void applyPoint(CSMWorld::CommandMacro& commands, const osg::Vec3d& worldPos);
void applyPosition(CSMWorld::CommandMacro& commands);
void applyEdge(CSMWorld::CommandMacro& commands, unsigned short node1, unsigned short node2);
void applyEdges(CSMWorld::CommandMacro& commands, unsigned short node);
void applyRemoveNodes(CSMWorld::CommandMacro& commands);
void applyRemoveEdges(CSMWorld::CommandMacro& commands);
osg::ref_ptr<PathgridTag> getTag() const;
void recreateGeometry();
void removeGeometry();
void update();
private:
CSMWorld::Data& mData;
CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& mPathgridCollection;
ESM::RefId mId;
CSMWorld::CellCoordinates mCoords;
bool mInterior;
NodeList mSelected;
osg::Vec3d mMoveOffset;
unsigned short mDragOrigin;
bool mChangeGeometry;
bool mRemoveGeometry;
bool mUseOffset;
osg::Group* mParent;
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
osg::ref_ptr<osg::Group> mPathgridGroup;
osg::ref_ptr<osg::Geometry> mPathgridGeometry;
osg::ref_ptr<osg::Geometry> mSelectedGeometry;
osg::ref_ptr<osg::Geometry> mDragGeometry;
osg::ref_ptr<PathgridTag> mTag;
void createGeometry();
void createSelectedGeometry();
void createSelectedGeometry(const CSMWorld::Pathgrid& source);
void removePathgridGeometry();
void removeSelectedGeometry();
void createDragGeometry(const osg::Vec3f& start, const osg::Vec3f& end, bool valid);
const CSMWorld::Pathgrid* getPathgridSource();
int edgeExists(const CSMWorld::Pathgrid& source, unsigned short node1, unsigned short node2);
void addEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
unsigned short node2);
void removeEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
unsigned short node2);
int clampToCell(int v);
};
}
#endif
|