2013-11-02 02:48:30 +01:00
|
|
|
#ifndef OPENCS_VIEW_SCENEWIDGET_H
|
|
|
|
#define OPENCS_VIEW_SCENEWIDGET_H
|
|
|
|
|
2016-03-10 04:29:24 -05:00
|
|
|
#include <map>
|
|
|
|
|
2013-11-02 02:48:30 +01:00
|
|
|
#include <QWidget>
|
2015-03-19 23:27:14 +01:00
|
|
|
#include <QTimer>
|
2014-03-23 15:14:26 +01:00
|
|
|
|
2015-07-18 03:52:38 +02:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2014-03-26 17:47:56 +01:00
|
|
|
#include "lightingday.hpp"
|
2014-03-26 17:59:42 +01:00
|
|
|
#include "lightingnight.hpp"
|
2014-03-26 18:29:15 +01:00
|
|
|
#include "lightingbright.hpp"
|
2014-03-26 17:47:56 +01:00
|
|
|
|
2015-03-23 15:55:57 +01:00
|
|
|
#include <osgViewer/View>
|
|
|
|
#include <osgViewer/CompositeViewer>
|
2014-03-23 15:14:26 +01:00
|
|
|
|
2015-03-28 20:15:17 +01:00
|
|
|
namespace Resource
|
|
|
|
{
|
2015-07-18 03:52:38 +02:00
|
|
|
class ResourceSystem;
|
2015-03-28 20:15:17 +01:00
|
|
|
}
|
|
|
|
|
2015-03-20 00:39:24 +01:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
2016-02-16 16:02:29 +01:00
|
|
|
class Camera;
|
2015-03-20 00:39:24 +01:00
|
|
|
}
|
|
|
|
|
2014-07-08 12:39:12 +02:00
|
|
|
namespace CSVWidget
|
2014-03-23 15:14:26 +01:00
|
|
|
{
|
|
|
|
class SceneToolMode;
|
|
|
|
class SceneToolbar;
|
2013-11-02 02:48:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:29:24 -05:00
|
|
|
namespace CSMPrefs
|
|
|
|
{
|
|
|
|
class Setting;
|
|
|
|
}
|
|
|
|
|
2013-11-02 02:48:30 +01:00
|
|
|
namespace CSVRender
|
|
|
|
{
|
2014-03-23 15:14:26 +01:00
|
|
|
class Lighting;
|
2014-02-27 15:23:14 +01:00
|
|
|
|
2015-03-28 20:15:17 +01:00
|
|
|
class RenderWidget : public QWidget
|
2013-11-02 02:48:30 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2015-03-19 23:27:14 +01:00
|
|
|
public:
|
2015-03-28 20:15:17 +01:00
|
|
|
RenderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
|
|
|
virtual ~RenderWidget();
|
2014-10-06 08:20:09 +11:00
|
|
|
|
2015-03-19 23:27:14 +01:00
|
|
|
void flagAsModified();
|
2014-10-05 19:25:37 +11:00
|
|
|
|
2015-03-26 00:27:39 +01:00
|
|
|
void setVisibilityMask(int mask);
|
|
|
|
|
2016-02-16 16:02:29 +01:00
|
|
|
osg::Camera *getCamera();
|
|
|
|
|
2015-03-19 23:27:14 +01:00
|
|
|
protected:
|
2014-10-28 06:01:19 +11:00
|
|
|
|
2015-03-23 15:55:57 +01:00
|
|
|
osg::ref_ptr<osgViewer::View> mView;
|
|
|
|
|
2015-03-20 00:39:24 +01:00
|
|
|
osg::Group* mRootNode;
|
|
|
|
|
2015-03-19 23:27:14 +01:00
|
|
|
QTimer mTimer;
|
2014-02-25 12:30:45 +01:00
|
|
|
};
|
2015-03-19 23:27:14 +01:00
|
|
|
|
2015-03-28 20:15:17 +01:00
|
|
|
// Extension of RenderWidget to support lighting mode selection & toolbar
|
|
|
|
class SceneWidget : public RenderWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-03-10 04:29:24 -05:00
|
|
|
SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent = 0,
|
|
|
|
Qt::WindowFlags f = 0, bool retrieveInput = true);
|
2015-03-28 20:15:17 +01:00
|
|
|
virtual ~SceneWidget();
|
|
|
|
|
|
|
|
CSVWidget::SceneToolMode *makeLightingSelector (CSVWidget::SceneToolbar *parent);
|
|
|
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
|
|
|
/// is the responsibility of the calling function.
|
|
|
|
|
|
|
|
void setDefaultAmbient (const osg::Vec4f& colour);
|
|
|
|
///< \note The actual ambient colour may differ based on lighting settings.
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void setLighting (Lighting *lighting);
|
|
|
|
///< \attention The ownership of \a lighting is not transferred to *this.
|
|
|
|
|
2015-03-28 21:26:16 +01:00
|
|
|
void setAmbient(const osg::Vec4f& ambient);
|
|
|
|
|
2016-03-10 04:29:24 -05:00
|
|
|
virtual void mousePressEvent (QMouseEvent *event);
|
|
|
|
virtual void mouseReleaseEvent (QMouseEvent *event);
|
|
|
|
|
|
|
|
/// \return Is \a key a button mapping setting? (ignored otherwise)
|
|
|
|
virtual bool storeMappingSetting (const CSMPrefs::Setting *setting);
|
|
|
|
|
|
|
|
std::string mapButton (QMouseEvent *event);
|
|
|
|
|
2015-07-18 03:52:38 +02:00
|
|
|
boost::shared_ptr<Resource::ResourceSystem> mResourceSystem;
|
2015-03-28 20:15:17 +01:00
|
|
|
|
|
|
|
Lighting* mLighting;
|
|
|
|
|
|
|
|
osg::Vec4f mDefaultAmbient;
|
|
|
|
bool mHasDefaultAmbient;
|
|
|
|
LightingDay mLightingDay;
|
|
|
|
LightingNight mLightingNight;
|
|
|
|
LightingBright mLightingBright;
|
|
|
|
|
2016-03-10 04:29:24 -05:00
|
|
|
std::map<std::pair<Qt::MouseButton, bool>, std::string> mButtonMapping;
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
|
|
|
|
virtual void settingChanged (const CSMPrefs::Setting *setting);
|
|
|
|
|
2016-03-10 16:56:14 -05:00
|
|
|
void selectNavigationMode (const std::string& mode);
|
|
|
|
|
2015-03-28 20:15:17 +01:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
void selectLightingMode (const std::string& mode);
|
2015-09-17 12:41:56 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void focusToolbarRequest();
|
2015-03-28 20:15:17 +01:00
|
|
|
};
|
2015-03-23 15:55:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
// There are rendering glitches when using multiple Viewer instances, work around using CompositeViewer with multiple views
|
|
|
|
class CompositeViewer : public QObject, public osgViewer::CompositeViewer
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
CompositeViewer();
|
|
|
|
|
|
|
|
static CompositeViewer& get();
|
|
|
|
|
|
|
|
QTimer mTimer;
|
|
|
|
|
2015-06-14 19:19:23 +02:00
|
|
|
private:
|
|
|
|
osg::Timer mFrameTimer;
|
|
|
|
double mSimulationTime;
|
|
|
|
|
2015-03-23 15:55:57 +01:00
|
|
|
public slots:
|
|
|
|
void update();
|
|
|
|
};
|
|
|
|
|
2013-11-02 02:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|