gepetto-viewer  4.13.0
An user-friendly Graphical Interface
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 
21 
22 #include <QColor>
23 #include <QObject>
24 #include <QVector3D>
25 #include <gepetto/gui/fwd.hh>
26 
27 namespace gepetto {
28 namespace gui {
29 class WindowsManager : public QObject, public viewer::WindowsManager {
30  Q_OBJECT
31 
32  public:
34 
35  static WindowsManagerPtr_t create(BodyTreeWidget* bodyTree);
36 
37  WindowID createWindow(const std::string& windowName);
38  WindowID createWindow(const std::string& windowName, OSGWidget* widget,
39  osgViewer::Viewer* viewer, osg::GraphicsContext* gc);
40 
41  void insertNode(const std::string& nodeName, NodePtr_t node);
42  bool addToGroup(const std::string& nodeName, const std::string& groupName);
43  bool removeFromGroup(const std::string& nodeName,
44  const std::string& groupName);
45  bool deleteNode(const std::string& nodeName, bool all);
46 
47  BodyTreeItems_t bodyTreeItems(const std::string& name) const;
48 
49  void captureFrame(const WindowID windowId, const std::string& filename);
50  bool startCapture(const WindowID windowId, const std::string& filename,
51  const std::string& extension);
52  bool stopCapture(const WindowID windowId);
53 
54  void refresh();
55  void setRefreshIsSynchronous(bool synchonous);
56 
57  public slots:
58  WindowID createWindow(QString windowName);
59  void asyncRefresh();
60 
61  protected:
62  WindowsManager(BodyTreeWidget* bodyTree);
63 
64  virtual void addNode(const std::string& nodeName, NodePtr_t node,
65  GroupNodePtr_t parent);
66  virtual void addGroup(const std::string& groupName, GroupNodePtr_t group,
67  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:33
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:30
bool addToGroup(const std::string &nodeName, const std::string &groupName)
BodyTreeItems_t bodyTreeItems(const std::string &name) const
viewer::WindowID WindowID
Definition: osgwidget.hh:40
void setRefreshIsSynchronous(bool synchonous)
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:50
Definition: action-search-bar.hh:26
std::vector< BodyTreeItem * > BodyTreeItems_t
Definition: fwd.hh:45
WindowsManager()
Default constructor.
viewer::GroupNodePtr_t GroupNodePtr_t
Definition: fwd.hh:53
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:43
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:58
virtual void addNode(const std::string &nodeName, NodePtr_t node, GroupNodePtr_t parent)