2014-03-04 14:47:43 +01:00
|
|
|
#ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H
|
|
|
|
#define OPENCS_VIEW_WORLDSPACEWIDGET_H
|
|
|
|
|
2014-12-01 06:44:12 +11:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2015-11-12 15:05:17 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
2015-09-29 13:48:04 +02:00
|
|
|
#include "../../model/doc/document.hpp"
|
|
|
|
#include "../../model/world/tablemimedata.hpp"
|
2014-03-04 14:47:43 +01:00
|
|
|
|
2015-09-29 13:48:04 +02:00
|
|
|
#include "scenewidget.hpp"
|
2016-01-06 14:34:39 +01:00
|
|
|
#include "mask.hpp"
|
2014-03-06 10:01:23 +01:00
|
|
|
|
2015-12-12 14:49:16 +01:00
|
|
|
namespace CSMPrefs
|
|
|
|
{
|
|
|
|
class Setting;
|
|
|
|
}
|
|
|
|
|
2014-05-01 15:09:47 +02:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class UniversalId;
|
|
|
|
}
|
2014-11-01 18:57:39 +11:00
|
|
|
|
2014-07-08 12:39:12 +02:00
|
|
|
namespace CSVWidget
|
2014-03-06 10:01:23 +01:00
|
|
|
{
|
|
|
|
class SceneToolMode;
|
2014-11-28 09:14:02 +01:00
|
|
|
class SceneToolToggle2;
|
2014-03-06 10:01:23 +01:00
|
|
|
class SceneToolbar;
|
2014-09-06 16:11:06 +02:00
|
|
|
class SceneToolRun;
|
2014-03-06 10:01:23 +01:00
|
|
|
}
|
|
|
|
|
2014-03-04 14:47:43 +01:00
|
|
|
namespace CSVRender
|
|
|
|
{
|
2015-09-26 17:51:41 +02:00
|
|
|
class TagBase;
|
2015-10-25 15:16:22 +01:00
|
|
|
class CellArrow;
|
2016-03-01 15:48:34 +01:00
|
|
|
class EditMode;
|
2015-09-26 17:51:41 +02:00
|
|
|
|
2014-03-04 14:47:43 +01:00
|
|
|
class WorldspaceWidget : public SceneWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-11-28 09:14:02 +01:00
|
|
|
CSVWidget::SceneToolToggle2 *mSceneElements;
|
2014-09-06 16:11:06 +02:00
|
|
|
CSVWidget::SceneToolRun *mRun;
|
|
|
|
CSMDoc::Document& mDocument;
|
2014-11-11 15:58:22 +01:00
|
|
|
unsigned int mInteractionMask;
|
2015-09-27 14:38:12 +02:00
|
|
|
CSVWidget::SceneToolMode *mEditMode;
|
|
|
|
bool mLocked;
|
2015-10-01 12:46:01 +02:00
|
|
|
std::string mDragMode;
|
|
|
|
bool mDragging;
|
|
|
|
int mDragX;
|
|
|
|
int mDragY;
|
2015-10-01 13:42:21 +02:00
|
|
|
double mDragFactor;
|
|
|
|
double mDragWheelFactor;
|
|
|
|
double mDragShiftFactor;
|
2015-11-12 15:05:17 +01:00
|
|
|
QTimer mToolTipDelayTimer;
|
|
|
|
QPoint mToolTipPos;
|
|
|
|
bool mShowToolTips;
|
|
|
|
int mToolTipDelay;
|
2014-10-29 00:50:48 +11:00
|
|
|
|
2014-03-04 14:47:43 +01:00
|
|
|
public:
|
|
|
|
|
2014-09-11 11:27:56 +02:00
|
|
|
enum DropType
|
2014-05-03 14:00:30 +02:00
|
|
|
{
|
2014-09-11 11:27:56 +02:00
|
|
|
Type_CellsInterior,
|
|
|
|
Type_CellsExterior,
|
2014-09-13 18:54:29 +02:00
|
|
|
Type_Other,
|
|
|
|
Type_DebugProfile
|
2014-05-03 14:00:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum dropRequirments
|
|
|
|
{
|
|
|
|
canHandle,
|
|
|
|
needPaged,
|
|
|
|
needUnpaged,
|
|
|
|
ignored //either mixed cells, or not cells
|
|
|
|
};
|
2014-05-02 20:15:46 +02:00
|
|
|
|
2014-06-29 14:19:10 +02:00
|
|
|
WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0);
|
2014-10-29 00:50:48 +11:00
|
|
|
~WorldspaceWidget ();
|
2014-03-06 10:01:23 +01:00
|
|
|
|
2014-07-08 12:39:12 +02:00
|
|
|
CSVWidget::SceneToolMode *makeNavigationSelector (CSVWidget::SceneToolbar *parent);
|
2014-03-23 15:14:26 +01:00
|
|
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
2014-03-06 10:01:23 +01:00
|
|
|
/// is the responsibility of the calling function.
|
|
|
|
|
2014-07-31 14:05:27 +02:00
|
|
|
/// \attention The created tool is not added to the toolbar (via addTool). Doing
|
|
|
|
/// that is the responsibility of the calling function.
|
2014-11-28 09:14:02 +01:00
|
|
|
CSVWidget::SceneToolToggle2 *makeSceneVisibilitySelector (
|
2014-07-31 14:05:27 +02:00
|
|
|
CSVWidget::SceneToolbar *parent);
|
|
|
|
|
2014-09-06 16:11:06 +02:00
|
|
|
/// \attention The created tool is not added to the toolbar (via addTool). Doing
|
|
|
|
/// that is the responsibility of the calling function.
|
|
|
|
CSVWidget::SceneToolRun *makeRunTool (CSVWidget::SceneToolbar *parent);
|
|
|
|
|
2014-11-11 15:58:22 +01:00
|
|
|
/// \attention The created tool is not added to the toolbar (via addTool). Doing
|
|
|
|
/// that is the responsibility of the calling function.
|
|
|
|
CSVWidget::SceneToolMode *makeEditModeSelector (CSVWidget::SceneToolbar *parent);
|
|
|
|
|
2014-03-06 10:01:23 +01:00
|
|
|
void selectDefaultNavigationMode();
|
|
|
|
|
2016-04-03 16:32:07 -04:00
|
|
|
void centerOrbitCameraOnSelection();
|
|
|
|
|
2014-09-11 11:27:56 +02:00
|
|
|
static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
|
2014-05-02 20:15:46 +02:00
|
|
|
|
2014-09-11 13:04:20 +02:00
|
|
|
virtual dropRequirments getDropRequirements(DropType type) const;
|
2014-05-03 14:00:30 +02:00
|
|
|
|
2014-04-01 10:04:14 +02:00
|
|
|
virtual void useViewHint (const std::string& hint);
|
|
|
|
///< Default-implementation: ignored.
|
|
|
|
|
2014-09-11 13:04:20 +02:00
|
|
|
/// \return Drop handled?
|
|
|
|
virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
|
|
|
|
DropType type);
|
2014-05-03 14:00:30 +02:00
|
|
|
|
2014-11-09 11:29:45 +01:00
|
|
|
virtual unsigned int getVisibilityMask() const;
|
2014-07-31 14:05:27 +02:00
|
|
|
|
2014-11-11 15:58:22 +01:00
|
|
|
/// \note This function will implicitly add elements that are independent of the
|
|
|
|
/// selected edit mode.
|
|
|
|
virtual void setInteractionMask (unsigned int mask);
|
|
|
|
|
|
|
|
/// \note This function will only return those elements that are both visible and
|
|
|
|
/// marked for interaction.
|
|
|
|
unsigned int getInteractionMask() const;
|
2014-07-31 14:05:27 +02:00
|
|
|
|
2015-09-27 14:38:12 +02:00
|
|
|
virtual void setEditLock (bool locked);
|
|
|
|
|
2015-10-02 15:06:42 +02:00
|
|
|
CSMDoc::Document& getDocument();
|
|
|
|
|
2015-09-29 13:48:04 +02:00
|
|
|
/// \param elementMask Elements to be affected by the clear operation
|
|
|
|
virtual void clearSelection (int elementMask) = 0;
|
|
|
|
|
2016-01-19 14:25:20 +01:00
|
|
|
/// \param elementMask Elements to be affected by the select operation
|
|
|
|
virtual void selectAll (int elementMask) = 0;
|
|
|
|
|
2016-01-26 11:31:37 +01:00
|
|
|
// Select everything that references the same ID as at least one of the elements
|
|
|
|
// already selected
|
|
|
|
//
|
|
|
|
/// \param elementMask Elements to be affected by the select operation
|
|
|
|
virtual void selectAllWithSameParentId (int elementMask) = 0;
|
|
|
|
|
2016-01-10 08:56:15 +01:00
|
|
|
/// Return the next intersection point with scene elements matched by
|
|
|
|
/// \a interactionMask based on \a localPos and the camera vector.
|
|
|
|
/// If there is no such point, instead a point "in front" of \a localPos will be
|
|
|
|
/// returned.
|
|
|
|
///
|
|
|
|
/// \param ignoreHidden ignore elements specified in interactionMask that are
|
|
|
|
/// flagged as not visible.
|
|
|
|
osg::Vec3f getIntersectionPoint (const QPoint& localPos,
|
2016-01-15 15:46:10 +01:00
|
|
|
unsigned int interactionMask = Mask_Reference | Mask_Terrain,
|
2016-01-10 08:56:15 +01:00
|
|
|
bool ignoreHidden = false) const;
|
|
|
|
|
|
|
|
virtual std::string getCellId (const osg::Vec3f& point) const = 0;
|
|
|
|
|
2016-01-25 14:55:02 +01:00
|
|
|
virtual std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask)
|
|
|
|
const = 0;
|
|
|
|
|
2016-02-16 16:02:29 +01:00
|
|
|
virtual std::vector<osg::ref_ptr<TagBase> > getEdited (unsigned int elementMask)
|
|
|
|
const = 0;
|
|
|
|
|
2016-03-01 15:48:34 +01:00
|
|
|
virtual void setSubMode (int subMode, unsigned int elementMask) = 0;
|
|
|
|
|
2016-03-04 15:19:26 +01:00
|
|
|
/// Erase all overrides and restore the visual representation to its true state.
|
|
|
|
virtual void reset (unsigned int elementMask) = 0;
|
|
|
|
|
2016-03-05 10:56:54 +01:00
|
|
|
/// \note Drags will be automatically aborted when the aborting is triggered
|
|
|
|
/// (either explicitly or implicitly) from within this class. This function only
|
|
|
|
/// needs to be called, when the drag abort is triggered externally (e.g. from
|
|
|
|
/// an edit mode).
|
|
|
|
void abortDrag();
|
|
|
|
|
2014-05-01 15:09:47 +02:00
|
|
|
protected:
|
2014-07-31 14:05:27 +02:00
|
|
|
|
2016-01-15 15:49:10 +01:00
|
|
|
/// Visual elements in a scene
|
|
|
|
/// @note do not change the enumeration values, they are used in pre-existing button file names!
|
|
|
|
enum ButtonId
|
|
|
|
{
|
|
|
|
Button_Reference = 0x1,
|
|
|
|
Button_Pathgrid = 0x2,
|
|
|
|
Button_Water = 0x4,
|
|
|
|
Button_Fog = 0x8,
|
|
|
|
Button_Terrain = 0x10
|
|
|
|
};
|
|
|
|
|
2014-11-28 09:14:02 +01:00
|
|
|
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);
|
2014-07-31 14:05:27 +02:00
|
|
|
|
2014-11-11 15:58:22 +01:00
|
|
|
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
|
|
|
|
|
2014-10-09 05:56:44 +11:00
|
|
|
virtual void updateOverlay();
|
|
|
|
|
2014-10-29 10:43:55 +11:00
|
|
|
virtual void mouseMoveEvent (QMouseEvent *event);
|
|
|
|
virtual void mousePressEvent (QMouseEvent *event);
|
2014-10-29 00:50:48 +11:00
|
|
|
virtual void mouseReleaseEvent (QMouseEvent *event);
|
2014-10-29 10:43:55 +11:00
|
|
|
virtual void wheelEvent (QWheelEvent *event);
|
2014-11-03 21:24:47 +11:00
|
|
|
virtual void keyPressEvent (QKeyEvent *event);
|
2014-10-29 00:50:48 +11:00
|
|
|
|
2015-10-27 15:43:52 +01:00
|
|
|
virtual void handleMouseClick (osg::ref_ptr<TagBase> tag, const std::string& button,
|
|
|
|
bool shift);
|
2015-10-25 15:16:22 +01:00
|
|
|
|
2016-03-10 04:29:24 -05:00
|
|
|
/// \return Is \a key a button mapping setting? (ignored otherwise)
|
|
|
|
virtual bool storeMappingSetting (const CSMPrefs::Setting *setting);
|
|
|
|
|
|
|
|
virtual void settingChanged (const CSMPrefs::Setting *setting);
|
|
|
|
|
2016-03-01 15:48:34 +01:00
|
|
|
EditMode *getEditMode();
|
|
|
|
|
2014-05-01 15:09:47 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
|
2014-05-03 14:00:30 +02:00
|
|
|
void dropEvent(QDropEvent* event);
|
|
|
|
|
2014-05-01 15:09:47 +02:00
|
|
|
void dragMoveEvent(QDragMoveEvent *event);
|
|
|
|
|
2015-11-12 15:05:17 +01:00
|
|
|
osg::ref_ptr<TagBase> mousePick (const QPoint& localPos);
|
2015-09-26 17:51:41 +02:00
|
|
|
|
2014-09-06 16:11:06 +02:00
|
|
|
virtual std::string getStartupInstruction() = 0;
|
|
|
|
|
2014-03-06 10:01:23 +01:00
|
|
|
private slots:
|
|
|
|
|
2014-06-29 14:19:10 +02:00
|
|
|
virtual void referenceableDataChanged (const QModelIndex& topLeft,
|
2014-06-29 16:00:06 +02:00
|
|
|
const QModelIndex& bottomRight) = 0;
|
2014-06-29 14:19:10 +02:00
|
|
|
|
2014-06-29 16:00:06 +02:00
|
|
|
virtual void referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end) = 0;
|
2014-06-29 14:19:10 +02:00
|
|
|
|
2014-06-29 16:00:06 +02:00
|
|
|
virtual void referenceableAdded (const QModelIndex& index, int start, int end) = 0;
|
2014-06-29 14:19:10 +02:00
|
|
|
|
2014-06-29 16:00:06 +02:00
|
|
|
virtual void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) = 0;
|
2014-06-29 14:19:10 +02:00
|
|
|
|
2014-06-29 16:00:06 +02:00
|
|
|
virtual void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end) = 0;
|
2014-06-29 14:19:10 +02:00
|
|
|
|
2014-06-29 16:00:06 +02:00
|
|
|
virtual void referenceAdded (const QModelIndex& index, int start, int end) = 0;
|
2014-06-29 14:19:10 +02:00
|
|
|
|
2014-09-06 16:11:06 +02:00
|
|
|
virtual void runRequest (const std::string& profile);
|
|
|
|
|
2014-09-07 12:55:52 +02:00
|
|
|
void debugProfileDataChanged (const QModelIndex& topLeft,
|
|
|
|
const QModelIndex& bottomRight);
|
|
|
|
|
|
|
|
void debugProfileAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
|
|
|
|
2015-09-27 14:38:12 +02:00
|
|
|
void editModeChanged (const std::string& id);
|
2014-09-07 12:55:52 +02:00
|
|
|
|
2015-11-12 15:05:17 +01:00
|
|
|
void showToolTip();
|
|
|
|
|
2014-07-31 14:05:27 +02:00
|
|
|
protected slots:
|
|
|
|
|
2014-10-09 05:56:44 +11:00
|
|
|
void elementSelectionChanged();
|
2014-07-31 14:05:27 +02:00
|
|
|
|
2014-03-06 16:40:08 +01:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void closeRequest();
|
2014-10-31 21:50:57 +11:00
|
|
|
|
2014-05-03 14:00:30 +02:00
|
|
|
void dataDropped(const std::vector<CSMWorld::UniversalId>& data);
|
2014-11-03 08:10:28 +11:00
|
|
|
|
|
|
|
friend class MouseState;
|
2014-03-04 14:47:43 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-10-05 19:25:37 +11:00
|
|
|
#endif
|