gepetto-viewer  4.13.0
An user-friendly Graphical Interface
plugin-interface.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_PLUGININTERFACE_HH
18 #define GEPETTO_GUI_PLUGININTERFACE_HH
19 
20 #include <QWidget>
21 #include <QtGui>
24 #include <iostream>
25 
26 namespace gepetto {
27 namespace gui {
28 const int DockKeyShortcutBase = Qt::CTRL + Qt::ALT;
29 
33  public:
34  PluginInterface() : errorMsg_("Not initalized"), isInit_(false) {}
35 
36  virtual ~PluginInterface() {}
37 
38  virtual QString name() const = 0;
39 
40  void doInit() {
41  try {
42  init();
43  isInit_ = true;
44  } catch (const std::exception& e) {
45  errorMsg_ = QString(e.what());
46  }
47  }
48 
49  bool isInit() const { return isInit_; }
50 
51  const QString& errorMsg() const { return errorMsg_; }
52 
53  protected:
54  virtual void init() = 0;
55 
56  private:
57  QString errorMsg_;
58  bool isInit_;
59 };
60 
64  public:
66 
67  virtual QAction* action(const std::string& jointName) const = 0;
68 };
69 
73  public:
74  virtual ~ModelInterface() {}
75 
76  virtual void loadRobotModel(DialogLoadRobot::RobotDefinition rd) = 0;
77 
78  virtual void loadEnvironmentModel(
80 
81  virtual std::string getBodyFromJoint(const std::string& jointName) const = 0;
82 };
83 
87  public:
88  virtual ~ConnectionInterface() {}
89 
90  virtual void openConnection() = 0;
91 
92  virtual void closeConnection() = 0;
93 };
94 } // namespace gui
95 } // namespace gepetto
96 
97 Q_DECLARE_INTERFACE(gepetto::gui::PluginInterface, "gepetto-gui.plugins/0.0")
98 Q_DECLARE_INTERFACE(gepetto::gui::JointModifierInterface,
99  "gepetto-gui.plugin.joint-modifier/0.0")
100 Q_DECLARE_INTERFACE(gepetto::gui::ModelInterface,
101  "gepetto-gui.plugin.model/0.0")
102 Q_DECLARE_INTERFACE(gepetto::gui::ConnectionInterface,
103  "gepetto-gui.plugin.connection/0.0")
104 
105 #endif // GEPETTO_GUI_PLUGININTERFACE_HH
virtual ~ModelInterface()
Definition: plugin-interface.hh:74
bool isInit() const
Definition: plugin-interface.hh:49
Definition: dialogloadrobot.hh:33
virtual QString name() const =0
Definition: plugin-interface.hh:32
void doInit()
Definition: plugin-interface.hh:40
Definition: plugin-interface.hh:63
const QString & errorMsg() const
Definition: plugin-interface.hh:51
Definition: action-search-bar.hh:26
virtual ~JointModifierInterface()
Definition: plugin-interface.hh:65
PluginInterface()
Definition: plugin-interface.hh:34
Definition: plugin-interface.hh:72
Definition: dialogloadenvironment.hh:36
virtual ~ConnectionInterface()
Definition: plugin-interface.hh:88
const int DockKeyShortcutBase
Definition: plugin-interface.hh:28
virtual ~PluginInterface()
Definition: plugin-interface.hh:36
Definition: plugin-interface.hh:86