1 #ifndef OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
2 #define OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
3 
4 #include <string>
5 #include <memory>
6 
7 #include "worldspacewidget.hpp"
8 #include "cell.hpp"
9 
10 class QModelIndex;
11 
12 namespace CSMDoc
13 {
14     class Document;
15 }
16 
17 namespace CSMWorld
18 {
19     class IdTable;
20     class CellCoordinates;
21 }
22 
23 namespace CSVRender
24 {
25     class UnpagedWorldspaceWidget : public WorldspaceWidget
26     {
27             Q_OBJECT
28 
29             CSMDoc::Document& mDocument;
30             std::string mCellId;
31             CSMWorld::IdTable *mCellsModel;
32             CSMWorld::IdTable *mReferenceablesModel;
33             std::unique_ptr<Cell> mCell;
34 
35             void update();
36 
37         public:
38 
39             UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
40                                      QWidget *parent);
41 
42             dropRequirments getDropRequirements(DropType type) const override;
43 
44             /// \return Drop handled?
45             bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
46                 DropType type) override;
47 
48             /// \param elementMask Elements to be affected by the clear operation
49             void clearSelection (int elementMask) override;
50 
51             /// \param elementMask Elements to be affected by the select operation
52             void invertSelection (int elementMask) override;
53 
54             /// \param elementMask Elements to be affected by the select operation
55             void selectAll (int elementMask) override;
56 
57             // Select everything that references the same ID as at least one of the elements
58             // already selected
59             //
60             /// \param elementMask Elements to be affected by the select operation
61             void selectAllWithSameParentId (int elementMask) override;
62 
63             void selectInsideCube(const osg::Vec3d& pointA, const osg::Vec3d& pointB, DragMode dragMode) override;
64 
65             void selectWithinDistance(const osg::Vec3d& point, float distance, DragMode dragMode) override;
66 
67             std::string getCellId (const osg::Vec3f& point) const override;
68 
69             Cell* getCell(const osg::Vec3d& point) const override;
70 
71             Cell* getCell(const CSMWorld::CellCoordinates& coords) const override;
72 
73             std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask)
74                 const override;
75 
76             std::vector<osg::ref_ptr<TagBase> > getEdited (unsigned int elementMask)
77                 const override;
78 
79             void setSubMode (int subMode, unsigned int elementMask) override;
80 
81             /// Erase all overrides and restore the visual representation to its true state.
82             void reset (unsigned int elementMask) override;
83 
84         private:
85 
86             void referenceableDataChanged (const QModelIndex& topLeft,
87                 const QModelIndex& bottomRight) override;
88 
89             void referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end) override;
90 
91             void referenceableAdded (const QModelIndex& index, int start, int end) override;
92 
93             void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
94 
95             void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end) override;
96 
97             void referenceAdded (const QModelIndex& index, int start, int end) override;
98 
99             void pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
100 
101             void pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end) override;
102 
103             void pathgridAdded (const QModelIndex& parent, int start, int end) override;
104 
105             std::string getStartupInstruction()  override;
106 
107         protected:
108 
109             void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool) override;
110 
111         private slots:
112 
113             void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
114 
115             void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
116 
117             void assetTablesChanged ();
118 
119         signals:
120 
121             void cellChanged(const CSMWorld::UniversalId& id);
122     };
123 }
124 
125 #endif
126