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