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> |
21 |
|
|
#include <gepetto/viewer/windows-manager.h> |
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: |
34 |
|
|
typedef viewer::WindowsManager Parent_t; |
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 |