Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2015-2018, LAAS-CNRS |
2 |
|
|
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) |
3 |
|
|
// |
4 |
|
|
// This file is part of gepetto-viewer. |
5 |
|
|
// gepetto-viewer is free software: you can redistribute it |
6 |
|
|
// and/or modify it under the terms of the GNU Lesser General Public |
7 |
|
|
// License as published by the Free Software Foundation, either version |
8 |
|
|
// 3 of the License, or (at your option) any later version. |
9 |
|
|
// |
10 |
|
|
// gepetto-viewer is distributed in the hope that it will be |
11 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
12 |
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 |
|
|
// General Lesser Public License for more details. You should have |
14 |
|
|
// received a copy of the GNU Lesser General Public License along with |
15 |
|
|
// gepetto-viewer. If not, see <http://www.gnu.org/licenses/>. |
16 |
|
|
|
17 |
|
|
#ifndef GEPETTO_GUI_OSGWIDGET_HH |
18 |
|
|
#define GEPETTO_GUI_OSGWIDGET_HH |
19 |
|
|
|
20 |
|
|
#include <gepetto/gui/fwd.hh> |
21 |
|
|
// This include must be include before any other Qt include for GLDEBUGPROC |
22 |
|
|
#include <gepetto/viewer/config-osg.h> |
23 |
|
|
|
24 |
|
|
#include <QLabel> |
25 |
|
|
#include <QString> |
26 |
|
|
#include <QThread> |
27 |
|
|
#include <QTimer> |
28 |
|
|
#include <osg/ref_ptr> |
29 |
|
|
#include <osgQt/GraphicsWindowQt> |
30 |
|
|
#include <osgViewer/ViewerBase> |
31 |
|
|
#include <osgViewer/ViewerEventHandlers> |
32 |
|
|
|
33 |
|
|
class QToolBar; |
34 |
|
|
class QProcess; |
35 |
|
|
class QTextBrowser; |
36 |
|
|
class QTemporaryDir; |
37 |
|
|
|
38 |
|
|
namespace gepetto { |
39 |
|
|
namespace gui { |
40 |
|
|
typedef viewer::WindowManagerPtr_t WindowManagerPtr_t; |
41 |
|
|
typedef viewer::WindowID WindowID; |
42 |
|
|
|
43 |
|
|
/// Widget that displays scenes. |
44 |
|
|
class OSGWidget : public QWidget { |
45 |
|
✗ |
Q_OBJECT |
46 |
|
|
public: |
47 |
|
|
OSGWidget(WindowsManagerPtr_t wm, const std::string& name, MainWindow* parent, |
48 |
|
|
Qt::WindowFlags f = 0, |
49 |
|
|
osgViewer::ViewerBase::ThreadingModel threadingModel = |
50 |
|
|
osgViewer::Viewer::ThreadPerContext); |
51 |
|
|
|
52 |
|
|
virtual ~OSGWidget(); |
53 |
|
|
|
54 |
|
|
WindowID windowID() const; |
55 |
|
|
|
56 |
|
|
WindowManagerPtr_t window() const; |
57 |
|
|
|
58 |
|
|
WindowsManagerPtr_t osg() const; |
59 |
|
|
|
60 |
|
|
public slots: |
61 |
|
|
/// Replace the camera at her home position. |
62 |
|
|
void onHome(); |
63 |
|
|
|
64 |
|
|
void addFloor(); |
65 |
|
|
|
66 |
|
|
void toggleCapture(bool active); |
67 |
|
|
|
68 |
|
|
void captureFrame(); |
69 |
|
|
void captureFrame(const std::string& filename); |
70 |
|
|
bool startCapture(const std::string& filename, const std::string& extension); |
71 |
|
|
bool stopCapture(); |
72 |
|
|
|
73 |
|
|
protected: |
74 |
|
|
virtual void paintEvent(QPaintEvent* event); |
75 |
|
|
|
76 |
|
|
bool isFixedSize() const; |
77 |
|
|
|
78 |
|
|
void setFixedSize(bool fixedSize); |
79 |
|
|
|
80 |
|
|
void setWindowDimension(const osgVector2& size); |
81 |
|
|
|
82 |
|
|
private slots: |
83 |
|
|
void readyReadProcessOutput(); |
84 |
|
|
void toggleFullscreenMode(bool fullscreenOn); |
85 |
|
|
|
86 |
|
|
private: |
87 |
|
|
void initToolBar(); |
88 |
|
|
void initGraphicsWindowsAndViewer(MainWindow* parent, |
89 |
|
|
const std::string& name); |
90 |
|
|
|
91 |
|
|
osg::ref_ptr<osgQt::GraphicsWindowQt> graphicsWindow_; |
92 |
|
|
WindowsManagerPtr_t wsm_; |
93 |
|
|
osg::ref_ptr<PickHandler> pickHandler_; |
94 |
|
|
WindowID wid_; |
95 |
|
|
WindowManagerPtr_t wm_; |
96 |
|
|
QTimer timer_; |
97 |
|
|
int nSuccessiveStaticFrames_; |
98 |
|
|
osgViewer::ViewerRefPtr viewer_; |
99 |
|
|
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCapture_; |
100 |
|
|
QTemporaryDir* tmpDirectory_; |
101 |
|
|
|
102 |
|
|
QToolBar* toolBar_; |
103 |
|
|
QAction* recordMovie_; |
104 |
|
|
|
105 |
|
|
// To record movies. |
106 |
|
|
QProcess* process_; |
107 |
|
|
QDialog* showPOutput_; |
108 |
|
|
QTextBrowser* pOutput_; |
109 |
|
|
|
110 |
|
|
QWidget *fullscreen_, *normal_; |
111 |
|
|
|
112 |
|
|
friend class PickHandler; |
113 |
|
|
}; |
114 |
|
|
} // namespace gui |
115 |
|
|
} // namespace gepetto |
116 |
|
|
|
117 |
|
|
#endif // GEPETTO_GUI_OSGWIDGET_HH |
118 |
|
|
|