2121#include " hppwidgetsplugin/conversions.hh"
2222#include " hppwidgetsplugin/jointtreewidget.hh"
2323#include " hppmanipulationwidgetsplugin/linkwidget.hh"
24- #include " hppmanipulationwidgetsplugin/manipulationconstraintwidget.hh"
25- #include " hppwidgetsplugin/twojointsconstraint.hh"
26- #include " hppwidgetsplugin/listjointconstraint.hh"
2724
2825using CORBA::ULong;
2926
@@ -83,6 +80,7 @@ namespace hpp {
8380
8481 void HppManipulationWidgetsPlugin::loadRobotModel (gepetto::gui::DialogLoadRobot::RobotDefinition rd)
8582 {
83+ if (hpp_) return ;
8684 try {
8785 hpp::floatSeq_var q = client ()->robot ()->getCurrentConfig ();
8886 (void )q;
@@ -104,6 +102,7 @@ namespace hpp {
104102
105103 void HppManipulationWidgetsPlugin::loadEnvironmentModel (gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed)
106104 {
105+ if (hpp_) return ;
107106 try {
108107 hpp::floatSeq_var q = client ()->robot ()->getCurrentConfig ();
109108 (void )q;
@@ -132,7 +131,24 @@ namespace hpp {
132131 hpp_ = new HppManipClient (0 ,0 );
133132 QByteArray iiop = getHppIIOPurl ().toLatin1 ();
134133 QByteArray context = getHppContext ().toLatin1 ();
135- hpp_->connect (iiop.constData (), context.constData ());
134+ try {
135+ hpp_->connect (iiop.constData (), context.constData ());
136+ hpp::Names_t_var for_memory_deletion = hpp_->problem ()->getAvailable (" type" );
137+ } catch (const CORBA::Exception& e) {
138+ QString error (" Could not find the manipulation server. Is it running ?" );
139+ error += " \n " ;
140+ error += e._name ();
141+ error += " : " ;
142+ error += e._rep_id ();
143+ gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
144+ if (main != NULL )
145+ main->logError (error);
146+ else
147+ qDebug () << error;
148+
149+ if (hpp_) delete hpp_;
150+ hpp_ = NULL ;
151+ }
136152 }
137153
138154 void HppManipulationWidgetsPlugin::closeConnection ()
@@ -147,17 +163,6 @@ namespace hpp {
147163 return hpp_;
148164 }
149165
150- void HppManipulationWidgetsPlugin::updateRobotJoints (const QString robotName)
151- {
152- Q_UNUSED (robotName)
153- hpp::Names_t_var joints = client ()->robot ()->getAllJointNames ();
154- for (size_t i = 0 ; i < joints->length (); ++i) {
155- const char * jname = joints[(ULong) i];
156- hpp::Names_t_var lnames = client ()->robot ()->getLinkNames (jname);
157- jointMap_[jname] = JointElement (jname, " " , lnames, 0 , true );
158- }
159- }
160-
161166 Roadmap *HppManipulationWidgetsPlugin::createRoadmap (const std::string &jointName)
162167 {
163168 ManipulationRoadmap* r = new ManipulationRoadmap (this );
@@ -197,6 +202,7 @@ namespace hpp {
197202
198203 void HppManipulationWidgetsPlugin::drawRobotContacts ()
199204 {
205+ if (hpp_) return ;
200206 hpp::Names_t_var rcs = hpp_->problem ()->getRobotContactNames ();
201207 hpp::floatSeqSeq_var points;
202208 hpp::intSeq_var indexes;
@@ -220,6 +226,7 @@ namespace hpp {
220226
221227 void HppManipulationWidgetsPlugin::drawEnvironmentContacts ()
222228 {
229+ if (hpp_) return ;
223230 hpp::Names_t_var rcs = hpp_->problem ()->getEnvironmentContactNames ();
224231 hpp::floatSeqSeq_var points;
225232 hpp::intSeq_var indexes;
@@ -240,6 +247,7 @@ namespace hpp {
240247
241248 void HppManipulationWidgetsPlugin::drawHandlesFrame ()
242249 {
250+ if (hpp_) return ;
243251 gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
244252 hpp::Names_t_var rcs = hpp_->problem ()->getAvailable (" handle" );
245253 hpp::Transform__var t (new Transform_);
@@ -261,6 +269,7 @@ namespace hpp {
261269
262270 void HppManipulationWidgetsPlugin::drawGrippersFrame ()
263271 {
272+ if (hpp_) return ;
264273 gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
265274 hpp::Names_t_var rcs = hpp_->problem ()->getAvailable (" gripper" );
266275 hpp::Transform__var t (new Transform_);
@@ -335,6 +344,7 @@ namespace hpp {
335344
336345 HppManipulationWidgetsPlugin::MapNames HppManipulationWidgetsPlugin::getObjects ()
337346 {
347+ assert (hpp_ != NULL );
338348 HppManipulationWidgetsPlugin::MapNames map;
339349 hpp::Names_t_var handles = manipClient ()->problem ()->getAvailable (" handle" );
340350 hpp::Names_t_var surfaces = manipClient ()->problem ()->getAvailable (" robotcontact" );
@@ -406,6 +416,7 @@ namespace hpp {
406416
407417 void HppManipulationWidgetsPlugin::buildGraph ()
408418 {
419+ if (hpp_) return ;
409420 QListWidget* l = dynamic_cast <QListWidget*>(tw_->widget (0 ));
410421 HppManipulationWidgetsPlugin::MapNames handlesMap = getObjects ();
411422 HppManipulationWidgetsPlugin::MapNames shapesMap = getObjects ();
@@ -444,6 +455,7 @@ namespace hpp {
444455
445456 void HppManipulationWidgetsPlugin::autoBuildGraph ()
446457 {
458+ if (hpp_) return ;
447459 if (graphBuilder_ == NULL ) {
448460 graphBuilder_ = new QDialog (NULL , Qt::Dialog);
449461 tw_ = new QTabWidget (graphBuilder_);
@@ -511,22 +523,6 @@ namespace hpp {
511523 graphBuilder_->show ();
512524 }
513525
514- void HppManipulationWidgetsPlugin::loadConstraintWidget ()
515- {
516- gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
517- QDockWidget* dock = new QDockWidget (" &Constraint creator" , main);
518- dock->setObjectName (" hppmanipulationwidgetsplugin.constraintcreator" );
519- constraintWidget_ = new ManipulationConstraintWidget (this , dock);
520- dock->setWidget (constraintWidget_);
521- main->insertDockWidget (dock, Qt::RightDockWidgetArea, Qt::Vertical);
522- dock->toggleViewAction ()->setShortcut (gepetto::gui::DockKeyShortcutBase + Qt::Key_V);
523- dockWidgets_.append (dock);
524- constraintWidget_->addConstraint (new PositionConstraint (this ));
525- constraintWidget_->addConstraint (new OrientationConstraint (this ));
526- constraintWidget_->addConstraint (new TransformConstraint (this ));
527- constraintWidget_->addConstraint (new LockedJointConstraint (this ));
528- }
529-
530526#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
531527 Q_EXPORT_PLUGIN2 (hppmanipulationwidgetsplugin, HppManipulationWidgetsPlugin)
532528#endif
0 commit comments