OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
worldspacewidget.hpp
Go to the documentation of this file.
1 #ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H
2 #define OPENCS_VIEW_WORLDSPACEWIDGET_H
3 
4 #include <boost/shared_ptr.hpp>
5 
6 #include <QTimer>
7 #include <osg/Vec3>
8 
9 #include "../../model/doc/document.hpp"
10 #include "../../model/world/tablemimedata.hpp"
11 
12 #include "scenewidget.hpp"
13 #include "mask.hpp"
14 
15 namespace CSMPrefs
16 {
17  class Setting;
18 }
19 
20 namespace CSMWorld
21 {
22  class UniversalId;
23 }
24 
25 namespace CSVWidget
26 {
27  class SceneToolMode;
28  class SceneToolToggle2;
29  class SceneToolbar;
30  class SceneToolRun;
31 }
32 
33 namespace CSVRender
34 {
35  class TagBase;
36  class Cell;
37  class CellArrow;
38  class EditMode;
39 
41  {
42  bool hit;
43  osg::ref_ptr<TagBase> tag;
44  unsigned int index0, index1, index2; // indices of mesh vertices
45  osg::Vec3d worldPos;
46  };
47 
49  {
50  Q_OBJECT
51 
55  unsigned int mInteractionMask;
57  bool mLocked;
58  int mDragMode;
59  bool mDragging;
60  int mDragX;
61  int mDragY;
62  bool mSpeedMode;
63  double mDragFactor;
67  QPoint mToolTipPos;
70 
71  public:
72 
73  enum DropType
74  {
79  };
80 
82  {
86  ignored //either mixed cells, or not cells
87  };
88 
90  {
96  };
97 
98  WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0);
100 
104 
108  CSVWidget::SceneToolbar *parent);
109 
113 
117 
119 
121 
122  static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
123 
124  virtual dropRequirments getDropRequirements(DropType type) const;
125 
126  virtual void useViewHint (const std::string& hint);
128 
130  virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
131  DropType type);
132 
133  virtual unsigned int getVisibilityMask() const;
134 
137  virtual void setInteractionMask (unsigned int mask);
138 
141  unsigned int getInteractionMask() const;
142 
143  virtual void setEditLock (bool locked);
144 
146 
148  virtual void clearSelection (int elementMask) = 0;
149 
151  virtual void invertSelection (int elementMask) = 0;
152 
154  virtual void selectAll (int elementMask) = 0;
155 
156  // Select everything that references the same ID as at least one of the elements
157  // already selected
158  //
160  virtual void selectAllWithSameParentId (int elementMask) = 0;
161 
166  WorldspaceHitResult mousePick (const QPoint& localPos, unsigned int interactionMask) const;
167 
168  virtual std::string getCellId (const osg::Vec3f& point) const = 0;
169 
171  virtual Cell* getCell(const osg::Vec3d& point) const = 0;
172 
173  virtual std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask)
174  const = 0;
175 
176  virtual std::vector<osg::ref_ptr<TagBase> > getEdited (unsigned int elementMask)
177  const = 0;
178 
179  virtual void setSubMode (int subMode, unsigned int elementMask) = 0;
180 
182  virtual void reset (unsigned int elementMask) = 0;
183 
184  protected:
185 
188  enum ButtonId
189  {
193  Button_Fog = 0x8,
195  };
196 
198 
200 
201  virtual void updateOverlay();
202 
203  virtual void mouseMoveEvent (QMouseEvent *event);
204  virtual void wheelEvent (QWheelEvent *event);
205 
206  virtual void handleInteractionPress (const WorldspaceHitResult& hit, InteractionType type);
207 
208  virtual void settingChanged (const CSMPrefs::Setting *setting);
209 
211 
212  bool getSpeedMode();
213 
214  private:
215 
216  void dragEnterEvent(QDragEnterEvent *event);
217 
218  void dropEvent(QDropEvent* event);
219 
220  void dragMoveEvent(QDragMoveEvent *event);
221 
222  virtual std::string getStartupInstruction() = 0;
223 
224  void handleInteraction(InteractionType type, bool activate);
225 
226  public slots:
227 
232  void abortDrag();
233 
234  private slots:
235 
236  virtual void referenceableDataChanged (const QModelIndex& topLeft,
237  const QModelIndex& bottomRight) = 0;
238 
239  virtual void referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end) = 0;
240 
241  virtual void referenceableAdded (const QModelIndex& index, int start, int end) = 0;
242 
243  virtual void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) = 0;
244 
245  virtual void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end) = 0;
246 
247  virtual void referenceAdded (const QModelIndex& index, int start, int end) = 0;
248 
249  virtual void pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) = 0;
250 
251  virtual void pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end) = 0;
252 
253  virtual void pathgridAdded (const QModelIndex& parent, int start, int end) = 0;
254 
255 
256  virtual void runRequest (const std::string& profile);
257 
258  void debugProfileDataChanged (const QModelIndex& topLeft,
259  const QModelIndex& bottomRight);
260 
261  void debugProfileAboutToBeRemoved (const QModelIndex& parent, int start, int end);
262 
263  void editModeChanged (const std::string& id);
264 
265  void showToolTip();
266 
267  void primaryEdit(bool activate);
268 
269  void secondaryEdit(bool activate);
270 
271  void primarySelect(bool activate);
272 
273  void secondarySelect(bool activate);
274 
275  void speedMode(bool activate);
276 
277  protected slots:
278 
280 
281  signals:
282 
283  void closeRequest();
284 
285  void dataDropped(const std::vector<CSMWorld::UniversalId>& data);
286 
287  friend class MouseState;
288  };
289 }
290 
291 #endif
unsigned int getInteractionMask() const
Definition: worldspacewidget.cpp:334
osg::ref_ptr< TagBase > tag
Definition: worldspacewidget.hpp:43
virtual std::vector< osg::ref_ptr< TagBase > > getSelection(unsigned int elementMask) const =0
Extension of RenderWidget to support lighting mode selection & toolbar.
Definition: scenewidget.hpp:77
int mDragY
Definition: worldspacewidget.hpp:61
Definition: worldspacewidget.hpp:48
virtual void clearSelection(int elementMask)=0
ButtonId
Definition: worldspacewidget.hpp:188
static const struct @2 signals[]
virtual void pathgridAboutToBeRemoved(const QModelIndex &parent, int start, int end)=0
InteractionType
Definition: worldspacewidget.hpp:89
CSVWidget::SceneToolRun * makeRunTool(CSVWidget::SceneToolbar *parent)
Definition: worldspacewidget.cpp:219
virtual std::string getCellId(const osg::Vec3f &point) const =0
virtual void useViewHint(const std::string &hint)
Default-implementation: ignored.
Definition: worldspacewidget.cpp:140
unsigned int index0
Definition: worldspacewidget.hpp:44
CSMDoc::Document & mDocument
Definition: worldspacewidget.hpp:54
osg::Vec3d worldPos
Definition: worldspacewidget.hpp:45
virtual unsigned int getVisibilityMask() const
Definition: worldspacewidget.cpp:324
CSVWidget::SceneToolToggle2 * makeSceneVisibilitySelector(CSVWidget::SceneToolbar *parent)
Definition: worldspacewidget.cpp:204
virtual dropRequirments getDropRequirements(DropType type) const
Definition: worldspacewidget.cpp:298
virtual void referenceAboutToBeRemoved(const QModelIndex &parent, int start, int end)=0
virtual void setInteractionMask(unsigned int mask)
Definition: worldspacewidget.cpp:329
Mode selector tool.
Definition: scenetoolmode.hpp:18
virtual void referenceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)=0
virtual void referenceableAboutToBeRemoved(const QModelIndex &parent, int start, int end)=0
bool hit
Definition: worldspacewidget.hpp:42
Definition: worldspacewidget.hpp:191
virtual void selectAllWithSameParentId(int elementMask)=0
virtual std::string getStartupInstruction()=0
virtual void referenceAdded(const QModelIndex &index, int start, int end)=0
void dragEnterEvent(QDragEnterEvent *event)
Definition: worldspacewidget.cpp:452
virtual void setSubMode(int subMode, unsigned int elementMask)=0
Definition: worldspacewidget.hpp:84
int mDragX
Definition: worldspacewidget.hpp:60
CSVWidget::SceneToolRun * mRun
Definition: worldspacewidget.hpp:53
CSVWidget::SceneToolMode * mEditMode
Definition: worldspacewidget.hpp:56
Definition: worldspacewidget.hpp:85
void selectDefaultNavigationMode()
Definition: worldspacewidget.cpp:142
virtual bool handleDrop(const std::vector< CSMWorld::UniversalId > &data, DropType type)
Definition: worldspacewidget.cpp:306
Definition: worldspacewidget.hpp:76
friend class MouseState
Definition: worldspacewidget.hpp:287
bool mShowToolTips
Definition: worldspacewidget.hpp:68
static DropType getDropType(const std::vector< CSMWorld::UniversalId > &data)
Definition: worldspacewidget.cpp:270
unsigned int index1
Definition: worldspacewidget.hpp:44
virtual void setEditLock(bool locked)
Definition: worldspacewidget.cpp:339
virtual void handleInteractionPress(const WorldspaceHitResult &hit, InteractionType type)
Definition: worldspacewidget.cpp:673
virtual void referenceableDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)=0
CSVWidget::SceneToolMode * makeNavigationSelector(CSVWidget::SceneToolbar *parent)
Definition: worldspacewidget.cpp:160
void elementSelectionChanged()
Definition: worldspacewidget.cpp:585
Definition: worldspacewidget.hpp:40
Definition: worldspacewidget.hpp:193
void dragMoveEvent(QDragMoveEvent *event)
Definition: worldspacewidget.cpp:472
Definition: worldspacewidget.hpp:78
virtual void pathgridDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)=0
virtual void pathgridAdded(const QModelIndex &parent, int start, int end)=0
double mDragShiftFactor
Definition: worldspacewidget.hpp:65
WorldspaceHitResult mousePick(const QPoint &localPos, unsigned int interactionMask) const
Definition: worldspacewidget.cpp:364
virtual void addEditModeSelectorButtons(CSVWidget::SceneToolMode *tool)
Definition: worldspacewidget.cpp:352
virtual void referenceableAdded(const QModelIndex &index, int start, int end)=0
void editModeChanged(const std::string &id)
Definition: worldspacewidget.cpp:563
~WorldspaceWidget()
Definition: worldspacewidget.cpp:119
Definition: worldspacewidget.hpp:83
virtual void invertSelection(int elementMask)=0
void dropEvent(QDropEvent *event)
Definition: worldspacewidget.cpp:492
virtual Cell * getCell(const osg::Vec3d &point) const =0
void showToolTip()
Definition: worldspacewidget.cpp:570
Definition: worldspacewidget.hpp:86
QTimer mToolTipDelayTimer
Definition: worldspacewidget.hpp:66
virtual std::vector< osg::ref_ptr< TagBase > > getEdited(unsigned int elementMask) const =0
Definition: setting.hpp:22
CSVWidget::SceneToolToggle2 * mSceneElements
Definition: worldspacewidget.hpp:52
bool mDragging
Definition: worldspacewidget.hpp:59
virtual void runRequest(const std::string &profile)
Definition: worldspacewidget.cpp:511
unsigned int mInteractionMask
Definition: worldspacewidget.hpp:55
Definition: worldspacewidget.hpp:194
int mToolTipDelay
Definition: worldspacewidget.hpp:69
Definition: document.hpp:57
Definition: worldspacewidget.hpp:77
Multi-Toggle tool.
Definition: scenetooltoggle2.hpp:19
void centerOrbitCameraOnSelection()
Definition: worldspacewidget.cpp:147
virtual void selectAll(int elementMask)=0
EditMode * getEditMode()
Definition: worldspacewidget.cpp:687
Definition: worldspacewidget.hpp:192
Definition: scenetoolrun.hpp:15
Definition: worldspacewidget.hpp:190
bool mLocked
Definition: worldspacewidget.hpp:57
DropType
Definition: worldspacewidget.hpp:73
Definition: cell.hpp:42
Definition: worldspacewidget.hpp:75
unsigned int index2
Definition: worldspacewidget.hpp:44
dropRequirments
Definition: worldspacewidget.hpp:81
void secondarySelect(bool activate)
Definition: worldspacewidget.cpp:707
void dataDropped(const std::vector< CSMWorld::UniversalId > &data)
void debugProfileDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: worldspacewidget.cpp:516
void handleInteraction(InteractionType type, bool activate)
Definition: worldspacewidget.cpp:717
Definition: worldspacewidget.hpp:95
Definition: scenetoolbar.hpp:12
void primaryEdit(bool activate)
Definition: worldspacewidget.cpp:692
int mDragMode
Definition: worldspacewidget.hpp:58
void secondaryEdit(bool activate)
Definition: worldspacewidget.cpp:697
double mDragFactor
Definition: worldspacewidget.hpp:63
CSMDoc::Document & getDocument()
Definition: worldspacewidget.cpp:359
void primarySelect(bool activate)
Definition: worldspacewidget.cpp:702
void speedMode(bool activate)
Definition: worldspacewidget.cpp:712
QPoint mToolTipPos
Definition: worldspacewidget.hpp:67
void abortDrag()
Definition: worldspacewidget.cpp:440
bool mSpeedMode
Definition: worldspacewidget.hpp:62
void debugProfileAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: worldspacewidget.cpp:542
virtual void addVisibilitySelectorButtons(CSVWidget::SceneToolToggle2 *tool)
Definition: worldspacewidget.cpp:344
virtual void updateOverlay()
Definition: worldspacewidget.cpp:592
Definition: editmode.hpp:19
WorldspaceWidget(CSMDoc::Document &document, QWidget *parent=0)
Definition: worldspacewidget.cpp:35
virtual void mouseMoveEvent(QMouseEvent *event)
Definition: worldspacewidget.cpp:596
virtual void wheelEvent(QWheelEvent *event)
Definition: worldspacewidget.cpp:656
double mDragWheelFactor
Definition: worldspacewidget.hpp:64
virtual void settingChanged(const CSMPrefs::Setting *setting)
Definition: worldspacewidget.cpp:123
CSVWidget::SceneToolMode * makeEditModeSelector(CSVWidget::SceneToolbar *parent)
Definition: worldspacewidget.cpp:257
virtual void reset(unsigned int elementMask)=0
Erase all overrides and restore the visual representation to its true state.