gepetto-viewer  4.12.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 
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 class QTemporaryDir;
38 
39 namespace gepetto {
40  namespace gui {
43 
45  class OSGWidget : public QWidget
46  {
47  Q_OBJECT
48  public:
50  const std::string & name,
51  MainWindow* parent,
52  Qt::WindowFlags f = 0,
53  osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::Viewer::ThreadPerContext );
54 
55  virtual ~OSGWidget();
56 
57  WindowID windowID () const;
58 
59  WindowManagerPtr_t window () const;
60 
61  WindowsManagerPtr_t osg () const;
62 
63  public slots:
65  void onHome();
66 
67  void addFloor();
68 
69  void toggleCapture (bool active);
70 
71  void captureFrame ();
72  void captureFrame (const std::string& filename);
73  bool startCapture (const std::string& filename, const std::string& extension);
74  bool stopCapture ();
75 
76  protected:
77  virtual void paintEvent(QPaintEvent* event);
78 
79  bool isFixedSize () const;
80 
81  void setFixedSize (bool fixedSize);
82 
83  void setWindowDimension (const osgVector2& size);
84 
85  private slots:
86  void readyReadProcessOutput ();
87  void toggleFullscreenMode (bool fullscreenOn);
88 
89  private:
90  void initToolBar ();
91  void initGraphicsWindowsAndViewer (MainWindow* parent, const std::string& name);
92 
93  osg::ref_ptr<osgQt::GraphicsWindowQt> graphicsWindow_;
95  osg::ref_ptr<PickHandler> pickHandler_;
96  WindowID wid_;
97  WindowManagerPtr_t wm_;
98  QTimer timer_;
99  int nSuccessiveStaticFrames_;
100  osgViewer::ViewerRefPtr viewer_;
101  osg::ref_ptr <osgViewer::ScreenCaptureHandler> screenCapture_;
102  QTemporaryDir* tmpDirectory_;
103 
104  QToolBar* toolBar_;
105  QAction* recordMovie_;
106 
107  // To record movies.
108  QProcess* process_;
109  QDialog* showPOutput_;
110  QTextBrowser* pOutput_;
111 
112  QWidget* fullscreen_, *normal_;
113 
114  friend class PickHandler;
115  };
116  } // namespace gui
117 } // namespace gepetto
118 
119 #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:41
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:42
Definition: pick-handler.hh:38
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:45
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55
WindowID windowID() const