hppmanipulationwidgetsplugin.hh 4.8 KB
Newer Older
Joseph Mirabel's avatar
Joseph Mirabel committed
1
2
#ifndef HPP_GUI_HPPMANIPULATIONWIDGETSPLUGIN_HH
#define HPP_GUI_HPPMANIPULATIONWIDGETSPLUGIN_HH
3

4
5
#include <QToolBar>

6
#include <gepetto/gui/plugin-interface.hh>
7
8
9
10
11
#include <hpp/corbaserver/manipulation/client.hh>
#undef __robot_hh__
#undef __problem_hh__
#include <hppwidgetsplugin/hppwidgetsplugin.hh>

12
13
class QListWidgetItem;

Joseph Mirabel's avatar
Joseph Mirabel committed
14
15
namespace hpp {
  namespace gui {
hdallard's avatar
hdallard committed
16
    /// HppManipulationWidgetsPlugin add functionalities to interact with hpp-manipulation-corba
Joseph Mirabel's avatar
Joseph Mirabel committed
17
18
19
20
    class HppManipulationWidgetsPlugin : public HppWidgetsPlugin
                                         // , public PluginInterface, public ModelInterface, public CorbaErrorInterface
    {
      Q_OBJECT
21
22
23
        Q_INTERFACES (gepetto::gui::PluginInterface
            gepetto::gui::ModelInterface
            gepetto::gui::CorbaInterface)
Joseph Mirabel's avatar
Joseph Mirabel committed
24

25
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
Joseph Mirabel's avatar
Joseph Mirabel committed
26
    Q_PLUGIN_METADATA (IID "hpp-gui.hppmanipulationwidgetsplugin")
27
#endif
Joseph Mirabel's avatar
Joseph Mirabel committed
28

Joseph Mirabel's avatar
Joseph Mirabel committed
29
30
31
32
33
34
35
36
37
      public:
        typedef hpp::corbaServer::manipulation::Client HppManipClient;

        explicit HppManipulationWidgetsPlugin ();

        virtual ~HppManipulationWidgetsPlugin ();

        // PluginInterface interface
      public:
hdallard's avatar
hdallard committed
38
        /// Initialize the plugin
Joseph Mirabel's avatar
Joseph Mirabel committed
39
        void init();
hdallard's avatar
hdallard committed
40
41

        /// Return the name of the plugin
Joseph Mirabel's avatar
Joseph Mirabel committed
42
43
44
45
        QString name() const;

        // ModelInterface interface
      public:
hdallard's avatar
hdallard committed
46
47
        /// Load a robot in the manipulation server.
        /// \param rd definition of the robot (Name, package path, URDF filename, suffix)
48
        void loadRobotModel (gepetto::gui::DialogLoadRobot::RobotDefinition rd);
hdallard's avatar
hdallard committed
49
50
51

        /// Load an environment in the manipulation server.
        /// \param ed definition of the environment (Name, package path, URDF filename, suffix)
52
        void loadEnvironmentModel (gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed);
hdallard's avatar
hdallard committed
53
54
55

        /// Get the name of a joint's body.
        /// \param jointName joint name
Joseph Mirabel's avatar
Joseph Mirabel committed
56
        std::string getBodyFromJoint (const std::string& jointName) const;
57

Joseph Mirabel's avatar
Joseph Mirabel committed
58
59
        // CorbaInterface
      public:
hdallard's avatar
hdallard committed
60
        /// Open a connection to a corba manipulation server.
Joseph Mirabel's avatar
Joseph Mirabel committed
61
        virtual void openConnection ();
hdallard's avatar
hdallard committed
62
63

        /// Close connection from corba manipulation server.
Joseph Mirabel's avatar
Joseph Mirabel committed
64
        virtual void closeConnection();
65

Joseph Mirabel's avatar
Joseph Mirabel committed
66
      public:
hdallard's avatar
hdallard committed
67
        /// Get the instance of corba manipulation client.
Joseph Mirabel's avatar
Joseph Mirabel committed
68
        HppManipClient* manipClient () const;
69

hdallard's avatar
hdallard committed
70
71
        /// Get the list of joints from corbaserver and update internal joint map.
        /// \param robotName name of the robot (unused)
Joseph Mirabel's avatar
Joseph Mirabel committed
72
        void updateRobotJoints (const QString robotName);
73

hdallard's avatar
hdallard committed
74
75
        /// Create the roadmap of a given joint.
        /// \param jointName name of the joint
Joseph Mirabel's avatar
Joseph Mirabel committed
76
        virtual Roadmap* createRoadmap (const std::string& jointName);
77

Joseph Mirabel's avatar
Joseph Mirabel committed
78
        public slots:
hdallard's avatar
hdallard committed
79
          /// Draw robot's contacts in the viewer.
80
          void drawRobotContacts ();
hdallard's avatar
hdallard committed
81
82

          /// Draw environment's contacts in the viewer.
83
          void drawEnvironmentContacts ();
hdallard's avatar
hdallard committed
84
85

          /// Draw handles frame in the viewer.
86
          void drawHandlesFrame ();
hdallard's avatar
hdallard committed
87
88

          /// Draw grippers frame in the viewer.
89
          void drawGrippersFrame ();
hdallard's avatar
hdallard committed
90
91

          /// Create the widget to select what to include in constraint's graph autobuild.
hdallard's avatar
hdallard committed
92
          void autoBuildGraph();
93

94
        private slots:
hdallard's avatar
hdallard committed
95
          /// Construct all the corba vars and create the graph.
96
          void buildGraph();
97
          void handleWorkerDone(int id);
98

99
100
101
      protected:
        virtual void loadConstraintWidget();

Joseph Mirabel's avatar
Joseph Mirabel committed
102
      private:
hdallard's avatar
hdallard committed
103
104
105
        // Type used to make one function to build datas needed for autoBuild
        typedef std::pair<hpp::Names_t, hpp::corbaserver::manipulation::Namess_t> NamesPair;
      typedef std::map<std::string, std::list<std::string> > MapNames;
hdallard's avatar
hdallard committed
106
107

        /// Convert a MapNames to a pair of corba types.
hdallard's avatar
hdallard committed
108
        NamesPair convertMap(MapNames& mapNames);
hdallard's avatar
hdallard committed
109
110

        /// Transform a list of QListWidgetItem to corba sequence of strings.
111
        hpp::Names_t_var convertToNames(const QList<QListWidgetItem *>& l);
112

113
114
      MapNames getObjects();
      void fillMap(MapNames& map, const QList<QListWidgetItem *>& l);
115
116
        void mergeShapes(MapNames& handles, MapNames& shapes);

117
118
119
120
121
122
123
124
125
      /// Draw the surface name describe by the points at index indexes[j] in points.
      /// The surface will be moved of epsilon along its normal so that it does not overlap
      /// others bodies.
      /// \param name surface name
      /// \param indexes table of indexes
      /// \param points table of points
      /// \param j index in table indexes
      /// \param epsilon offset
      void drawContactSurface(const std::string& name, hpp::intSeq_var& indexes,
126
			      hpp::floatSeqSeq_var& points, CORBA::ULong j, float epsilon = 0.0001f);
127

Joseph Mirabel's avatar
Joseph Mirabel committed
128
        HppManipClient* hpp_;
129

Joseph Mirabel's avatar
Joseph Mirabel committed
130
        QToolBar *toolBar_;
131
        QTabWidget *tw_;
132
        QDialog* graphBuilder_;
hdallard's avatar
hdallard committed
133

134
        int lastId_;
Joseph Mirabel's avatar
Joseph Mirabel committed
135
136
137
    };
  } // namespace gui
} // namespace hpp
138

Joseph Mirabel's avatar
Joseph Mirabel committed
139
#endif // HPP_GUI_HPPMANIPULATIONWIDGETSPLUGIN_HH