gepetto-viewer  4.13.0
An user-friendly Graphical Interface
osgwidget.hh
Go to the documentation of this file.
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 
21 
22 #include <QLabel>
23 #include <QString>
24 #include <QThread>
25 #include <QTimer>
26 #include <gepetto/gui/fwd.hh>
27 #include <osg/ref_ptr>
28 #include <osgQt/GraphicsWindowQt>
29 #include <osgViewer/ViewerBase>
30 #include <osgViewer/ViewerEventHandlers>
31 
32 class QToolBar;
33 class QProcess;
34 class QTextBrowser;
35 class QTemporaryDir;
36 
37 namespace gepetto {
38 namespace gui {
41 
43 class OSGWidget : public QWidget {
44  Q_OBJECT
45  public:
46  OSGWidget(WindowsManagerPtr_t wm, const std::string& name, MainWindow* parent,
47  Qt::WindowFlags f = 0,
48  osgViewer::ViewerBase::ThreadingModel threadingModel =
49  osgViewer::Viewer::ThreadPerContext);
50 
51  virtual ~OSGWidget();
52 
53  WindowID windowID() const;
54 
55  WindowManagerPtr_t window() const;
56 
57  WindowsManagerPtr_t osg() const;
58 
59  public slots:
61  void onHome();
62 
63  void addFloor();
64 
65  void toggleCapture(bool active);
66 
67  void captureFrame();
68  void captureFrame(const std::string& filename);
69  bool startCapture(const std::string& filename, const std::string& extension);
70  bool stopCapture();
71 
72  protected:
73  virtual void paintEvent(QPaintEvent* event);
74 
75  bool isFixedSize() const;
76 
77  void setFixedSize(bool fixedSize);
78 
79  void setWindowDimension(const osgVector2& size);
80 
81  private slots:
82  void readyReadProcessOutput();
83  void toggleFullscreenMode(bool fullscreenOn);
84 
85  private:
86  void initToolBar();
87  void initGraphicsWindowsAndViewer(MainWindow* parent,
88  const std::string& name);
89 
90  osg::ref_ptr<osgQt::GraphicsWindowQt> graphicsWindow_;
92  osg::ref_ptr<PickHandler> pickHandler_;
93  WindowID wid_;
95  QTimer timer_;
96  int nSuccessiveStaticFrames_;
97  osgViewer::ViewerRefPtr viewer_;
98  osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCapture_;
99  QTemporaryDir* tmpDirectory_;
100 
101  QToolBar* toolBar_;
102  QAction* recordMovie_;
103 
104  // To record movies.
105  QProcess* process_;
106  QDialog* showPOutput_;
107  QTextBrowser* pOutput_;
108 
109  QWidget *fullscreen_, *normal_;
110 
111  friend class PickHandler;
112 };
113 } // namespace gui
114 } // namespace gepetto
115 
116 #endif // GEPETTO_GUI_OSGWIDGET_HH
WindowsManagerPtr_t osg() const
void onHome()
Replace the camera at her home position.
viewer::WindowManagerPtr_t WindowManagerPtr_t
Definition: osgwidget.hh:39
void setFixedSize(bool fixedSize)
Class.
Definition: mainwindow.hh:40
::osg::Vec2f osgVector2
Definition: config-osg.h:98
OSGWidget(WindowsManagerPtr_t wm, const std::string &name, MainWindow *parent, Qt::WindowFlags f=0, osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::Viewer::ThreadPerContext)
viewer::WindowID WindowID
Definition: osgwidget.hh:40
Definition: pick-handler.hh:35
Definition: action-search-bar.hh:26
WindowManagerPtr_t window() const
virtual void paintEvent(QPaintEvent *event)
std::string WindowID
Definition: fwd.h:17
bool startCapture(const std::string &filename, const std::string &extension)
bool isFixedSize() const
void toggleCapture(bool active)
void setWindowDimension(const osgVector2 &size)
Widget that displays scenes.
Definition: osgwidget.hh:43
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:58
WindowID windowID() const