2013-11-02 02:48:30 +01:00
|
|
|
#ifndef OPENCS_VIEW_SCENEWIDGET_H
|
|
|
|
#define OPENCS_VIEW_SCENEWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2015-03-19 23:27:14 +01:00
|
|
|
#include <QTimer>
|
2014-03-23 15:14:26 +01:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
class SceneManager;
|
|
|
|
}
|
|
|
|
|
2015-03-20 00:39:24 +01:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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:
|
|
|
|
SceneWidget(Resource::SceneManager* sceneManager, QWidget* parent = 0, Qt::WindowFlags f = 0);
|
|
|
|
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);
|
|
|
|
|
2015-03-28 20:15:17 +01:00
|
|
|
Resource::SceneManager* mSceneManager;
|
|
|
|
|
|
|
|
Lighting* mLighting;
|
|
|
|
|
|
|
|
osg::Vec4f mDefaultAmbient;
|
|
|
|
bool mHasDefaultAmbient;
|
|
|
|
LightingDay mLightingDay;
|
|
|
|
LightingNight mLightingNight;
|
|
|
|
LightingBright mLightingBright;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void selectLightingMode (const std::string& mode);
|
|
|
|
};
|
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
|