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 <QtGui>
21 #include <QWidget>
22 #include <iostream>
23 
26 
27 namespace gepetto {
28  namespace gui {
29  const int DockKeyShortcutBase = Qt::CTRL + Qt::ALT;
30 
34  public:
36  : errorMsg_ ("Not initalized")
37  , isInit_ (false)
38  {}
39 
40  virtual ~PluginInterface () {}
41 
42  virtual QString name () const = 0;
43 
44  void doInit ()
45  {
46  try {
47  init ();
48  isInit_ = true;
49  } catch (const std::exception& e) {
50  errorMsg_ = QString (e.what ());
51  }
52  }
53 
54  bool isInit () const
55  {
56  return isInit_;
57  }
58 
59  const QString& errorMsg () const
60  {
61  return errorMsg_;
62  }
63 
64  protected:
65  virtual void init () = 0;
66 
67  private:
68  QString errorMsg_;
69  bool isInit_;
70  };
71 
75  public:
77 
78  virtual QAction* action (const std::string& jointName) const = 0;
79  };
80 
84  public:
85  virtual ~ModelInterface () {}
86 
87  virtual void loadRobotModel (DialogLoadRobot::RobotDefinition rd) = 0;
88 
89  virtual void loadEnvironmentModel (DialogLoadEnvironment::EnvironmentDefinition ed) = 0;
90 
91  virtual std::string getBodyFromJoint (const std::string& jointName) const = 0;
92  };
93 
97  public:
98  virtual ~ConnectionInterface () {}
99 
100  virtual void openConnection () = 0;
101 
102  virtual void closeConnection () = 0;
103  };
104  } // namespace gui
105 } // namespace gepetto
106 
107 Q_DECLARE_INTERFACE (gepetto::gui::PluginInterface, "gepetto-gui.plugins/0.0")
108 Q_DECLARE_INTERFACE (gepetto::gui::JointModifierInterface, "gepetto-gui.plugin.joint-modifier/0.0")
109 Q_DECLARE_INTERFACE (gepetto::gui::ModelInterface, "gepetto-gui.plugin.model/0.0")
110 Q_DECLARE_INTERFACE (gepetto::gui::ConnectionInterface, "gepetto-gui.plugin.connection/0.0")
111 
112 
113 
114 #endif // GEPETTO_GUI_PLUGININTERFACE_HH
virtual ~ModelInterface()
Definition: plugin-interface.hh:85
bool isInit() const
Definition: plugin-interface.hh:54
Definition: dialogloadrobot.hh:34
virtual QString name() const =0
Definition: plugin-interface.hh:33
void doInit()
Definition: plugin-interface.hh:44
Definition: plugin-interface.hh:74
const QString & errorMsg() const
Definition: plugin-interface.hh:59
Definition: action-search-bar.hh:27
virtual ~JointModifierInterface()
Definition: plugin-interface.hh:76
PluginInterface()
Definition: plugin-interface.hh:35
Definition: plugin-interface.hh:83
Definition: dialogloadenvironment.hh:37
virtual ~ConnectionInterface()
Definition: plugin-interface.hh:98
const int DockKeyShortcutBase
Definition: plugin-interface.hh:29
virtual ~PluginInterface()
Definition: plugin-interface.hh:40
Definition: plugin-interface.hh:96