windows-manager.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_WINDOWSMANAGER_HH
18 #define GEPETTO_GUI_WINDOWSMANAGER_HH
19 
20 #include <gepetto/gui/fwd.hh>
22 
23 #include <QColor>
24 #include <QObject>
25 #include <QVector3D>
26 
27 namespace gepetto {
28  namespace gui {
29  class WindowsManager : public QObject, public viewer::WindowsManager
30  {
31  Q_OBJECT
32 
33  public:
35 
36  static WindowsManagerPtr_t create (BodyTreeWidget* bodyTree);
37 
38  WindowID createWindow(const std::string& windowName);
39  WindowID createWindow(const std::string& windowName,
40  OSGWidget* widget,
41  osgViewer::Viewer* viewer,
42  osg::GraphicsContext *gc);
43 
44  void insertNode (const std::string& nodeName, NodePtr_t node);
45  bool addToGroup(const std::string& nodeName, const std::string& groupName);
46  bool removeFromGroup (const std::string& nodeName, const std::string& groupName);
47  bool deleteNode (const std::string& nodeName, bool all);
48 
49  BodyTreeItems_t bodyTreeItems (const std::string& name) const;
50 
51  void captureFrame (const WindowID windowId, const std::string& filename);
52  bool startCapture (const WindowID windowId, const std::string& filename,
53  const std::string& extension);
54  bool stopCapture (const WindowID windowId);
55 
56  void refresh ();
57  void setRefreshIsSynchronous (bool synchonous);
58 
59  public slots:
60  WindowID createWindow(QString windowName);
61  void asyncRefresh ();
62 
63  protected:
64  WindowsManager (BodyTreeWidget* bodyTree);
65 
66  virtual void addNode (const std::string& nodeName, NodePtr_t node, GroupNodePtr_t parent);
67  virtual void addGroup(const std::string& groupName, GroupNodePtr_t group, GroupNodePtr_t parent);
68 
69  private:
70  typedef std::pair<BodyTreeItems_t, bool> BodyTreeItemsAndGroup_t;
71  typedef std::map<std::string, BodyTreeItemsAndGroup_t> BodyTreeItemMap_t;
72  BodyTreeWidget* bodyTree_;
73  BodyTreeItemMap_t nodeItemMap_;
74 
75  bool initParent (NodePtr_t node, GroupNodePtr_t parent, bool isGroup);
76  void addToGroup (const std::string& nodeName, const std::string& groupName,
77  const NodePtr_t& node, const BodyTreeItems_t& groups,
78  bool isGroup);
79  void deleteBodyItem(const std::string& nodeName);
80 
81  std::map<WindowID, OSGWidget*> widgets_;
82 
83  bool refreshIsSynchronous_;
84  viewer::Mutex configsAsyncMtx_;
85  NodeConfigurations_t configsAsync_;
86  };
87  } // namespace gui
88 } // namespace gepetto
89 
90 #endif // GEPETTO_GUI_WINDOWSMANAGER_HH
WindowID createWindow(const std::string &windowName)
std::vector< NodeConfiguration > NodeConfigurations_t
Definition: windows-manager.h:84
viewer::WindowsManager Parent_t
Definition: windows-manager.hh:34
bool deleteNode(const std::string &nodeName, bool all)
void insertNode(const std::string &nodeName, NodePtr_t node)
bool startCapture(const WindowID windowId, const std::string &filename, const std::string &extension)
Contains the list of all the bodies in the scene.
Definition: bodytreewidget.hh:31
bool addToGroup(const std::string &nodeName, const std::string &groupName)
BodyTreeItems_t bodyTreeItems(const std::string &name) const
viewer::WindowID WindowID
Definition: osgwidget.hh:41
void setRefreshIsSynchronous(bool synchonous)
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:47
Definition: action-search-bar.hh:27
WindowsManager()
Default constructor.
std::vector< BodyTreeItem * > BodyTreeItems_t
Definition: fwd.hh:42
viewer::GroupNodePtr_t GroupNodePtr_t
Definition: fwd.hh:50
static WindowsManagerPtr_t create()
bool removeFromGroup(const std::string &nodeName, const std::string &groupName)
Manage a set of windows that may share 3D objects.
Definition: windows-manager.h:48
void captureFrame(const WindowID windowId, const std::string &filename)
OpenThreads::Mutex Mutex
Definition: windows-manager.h:30
bool stopCapture(const WindowID windowId)
virtual void addGroup(const std::string &groupName, GroupNodePtr_t group, GroupNodePtr_t parent)
Definition: windows-manager.hh:29
Widget that displays scenes.
Definition: osgwidget.hh:44
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55
virtual void addNode(const std::string &nodeName, NodePtr_t node, GroupNodePtr_t parent)