OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scenewidget.hpp
Go to the documentation of this file.
1 #ifndef OPENCS_VIEW_SCENEWIDGET_H
2 #define OPENCS_VIEW_SCENEWIDGET_H
3 
4 #include <map>
5 #include <memory>
6 
7 #include <QWidget>
8 #include <QTimer>
9 
10 #include <osgViewer/View>
11 #include <osgViewer/CompositeViewer>
12 
13 #include <boost/shared_ptr.hpp>
14 
15 #include "lightingday.hpp"
16 #include "lightingnight.hpp"
17 #include "lightingbright.hpp"
18 
19 
20 namespace Resource
21 {
22  class ResourceSystem;
23 }
24 
25 namespace osg
26 {
27  class Group;
28  class Camera;
29 }
30 
31 namespace CSVWidget
32 {
33  class SceneToolMode;
34  class SceneToolbar;
35 }
36 
37 namespace CSMPrefs
38 {
39  class Setting;
40 }
41 
42 namespace CSVRender
43 {
44  class CameraController;
45  class FreeCameraController;
46  class OrbitCameraController;
47  class Lighting;
48 
49  class RenderWidget : public QWidget
50  {
51  Q_OBJECT
52 
53  public:
54  RenderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
55  virtual ~RenderWidget();
56 
58  void flagAsModified();
59 
60  void setVisibilityMask(int mask);
61 
62  osg::Camera *getCamera();
63 
64  protected:
65 
66  osg::ref_ptr<osgViewer::View> mView;
67  osg::ref_ptr<osg::Group> mRootNode;
68 
69  QTimer mTimer;
70 
71  protected slots:
72 
73  void toggleRenderStats();
74  };
75 
77  class SceneWidget : public RenderWidget
78  {
79  Q_OBJECT
80  public:
81  SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent = 0,
82  Qt::WindowFlags f = 0, bool retrieveInput = true);
83  virtual ~SceneWidget();
84 
88 
89  void setDefaultAmbient (const osg::Vec4f& colour);
91 
92  protected:
93  void setLighting (Lighting *lighting);
95 
96  void setAmbient(const osg::Vec4f& ambient);
97 
98  virtual void mouseMoveEvent (QMouseEvent *event);
99  virtual void wheelEvent (QWheelEvent *event);
100 
101  boost::shared_ptr<Resource::ResourceSystem> mResourceSystem;
102 
104 
105  osg::Vec4f mDefaultAmbient;
110 
112 
115 
119 
120  public slots:
121  void update(double dt);
122 
123  protected slots:
124 
125  virtual void settingChanged (const CSMPrefs::Setting *setting);
126 
127  void selectNavigationMode (const std::string& mode);
128 
129  private slots:
130 
131  void selectLightingMode (const std::string& mode);
132 
133  signals:
134 
135  void focusToolbarRequest();
136  };
137 
138 
139  // There are rendering glitches when using multiple Viewer instances, work around using CompositeViewer with multiple views
140  class CompositeViewer : public QObject, public osgViewer::CompositeViewer
141  {
142  Q_OBJECT
143  public:
144  CompositeViewer();
145 
146  static CompositeViewer& get();
147 
148  QTimer mTimer;
149 
150  private:
151  osg::Timer mFrameTimer;
153 
154  public slots:
155  void update();
156 
157  signals:
158  void simulationUpdated(double dt);
159  };
160 
161 }
162 
163 #endif
void selectNavigationMode(const std::string &mode)
Definition: scenewidget.cpp:368
Extension of RenderWidget to support lighting mode selection & toolbar.
Definition: scenewidget.hpp:77
static const struct @2 signals[]
CameraController * mCurrentCamControl
Definition: scenewidget.hpp:118
Definition: lightingnight.hpp:8
virtual void wheelEvent(QWheelEvent *event)
Definition: scenewidget.cpp:300
bool mHasDefaultAmbient
Definition: scenewidget.hpp:106
Mode selector tool.
Definition: scenetoolmode.hpp:18
double mSimulationTime
Definition: scenewidget.hpp:152
Definition: lighting.hpp:15
QTimer mTimer
Definition: scenewidget.hpp:69
osg::Timer mFrameTimer
Definition: scenewidget.hpp:151
void update()
Definition: scenewidget.cpp:155
boost::shared_ptr< Resource::ResourceSystem > mResourceSystem
Definition: scenewidget.hpp:101
bool mCamPositionSet
Tells update that camera isn't set.
Definition: scenewidget.hpp:114
LightingDay mLightingDay
Definition: scenewidget.hpp:107
RenderWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: scenewidget.cpp:32
int mPrevMouseX
Definition: scenewidget.hpp:111
void update(double dt)
Definition: scenewidget.cpp:305
Definition: cameracontroller.hpp:27
CompositeViewer()
Definition: scenewidget.cpp:122
FreeCameraController * mFreeCamControl
Definition: scenewidget.hpp:116
osg::Vec4f mDefaultAmbient
Definition: scenewidget.hpp:105
void toggleRenderStats()
Definition: scenewidget.cpp:110
void selectLightingMode(const std::string &mode)
Definition: scenewidget.cpp:246
OrbitCameraController * mOrbitCamControl
Definition: scenewidget.hpp:117
void setLighting(Lighting *lighting)
Definition: scenewidget.cpp:221
void simulationUpdated(double dt)
osg::ref_ptr< osgViewer::View > mView
Definition: scenewidget.hpp:66
Definition: lightingbright.hpp:14
CSVWidget::SceneToolMode * makeLightingSelector(CSVWidget::SceneToolbar *parent)
Definition: scenewidget.cpp:256
virtual void settingChanged(const CSMPrefs::Setting *setting)
Definition: scenewidget.cpp:318
Definition: cameracontroller.hpp:82
virtual void mouseMoveEvent(QMouseEvent *event)
Definition: scenewidget.cpp:292
int mPrevMouseY
Definition: scenewidget.hpp:111
Definition: setting.hpp:22
LightingNight mLightingNight
Definition: scenewidget.hpp:108
osg::ref_ptr< osg::Group > mRootNode
Definition: scenewidget.hpp:67
Definition: cameracontroller.hpp:139
Definition: scenewidget.hpp:49
QTimer mTimer
Definition: scenewidget.hpp:148
void setVisibilityMask(int mask)
Definition: scenewidget.cpp:100
void setAmbient(const osg::Vec4f &ambient)
Definition: scenewidget.cpp:235
void flagAsModified()
Initiates a request to redraw the view.
Definition: scenewidget.cpp:95
Definition: lightingday.hpp:8
void setDefaultAmbient(const osg::Vec4f &colour)
Definition: scenewidget.cpp:284
Definition: scenetoolbar.hpp:12
SceneWidget(boost::shared_ptr< Resource::ResourceSystem > resourceSystem, QWidget *parent=0, Qt::WindowFlags f=0, bool retrieveInput=true)
Definition: scenewidget.cpp:168
virtual ~RenderWidget()
Definition: scenewidget.cpp:90
virtual ~SceneWidget()
Definition: scenewidget.cpp:215
LightingBright mLightingBright
Definition: scenewidget.hpp:109
osg::Camera * getCamera()
Definition: scenewidget.cpp:105
Definition: scenewidget.hpp:140
Lighting * mLighting
Definition: scenewidget.hpp:103