Commit 7f336375 authored by Joseph Mirabel's avatar Joseph Mirabel

Better handling of CORBA connection

parent 6bd8c5c5
...@@ -80,6 +80,7 @@ namespace hpp { ...@@ -80,6 +80,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::loadRobotModel(gepetto::gui::DialogLoadRobot::RobotDefinition rd) void HppManipulationWidgetsPlugin::loadRobotModel(gepetto::gui::DialogLoadRobot::RobotDefinition rd)
{ {
if (hpp_) return;
try { try {
hpp::floatSeq_var q = client ()->robot ()->getCurrentConfig(); hpp::floatSeq_var q = client ()->robot ()->getCurrentConfig();
(void)q; (void)q;
...@@ -101,6 +102,7 @@ namespace hpp { ...@@ -101,6 +102,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::loadEnvironmentModel(gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed) void HppManipulationWidgetsPlugin::loadEnvironmentModel(gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed)
{ {
if (hpp_) return;
try { try {
hpp::floatSeq_var q = client ()->robot ()->getCurrentConfig(); hpp::floatSeq_var q = client ()->robot ()->getCurrentConfig();
(void)q; (void)q;
...@@ -131,12 +133,21 @@ namespace hpp { ...@@ -131,12 +133,21 @@ namespace hpp {
QByteArray context = getHppContext ().toLatin1(); QByteArray context = getHppContext ().toLatin1();
try { try {
hpp_->connect (iiop.constData (), context.constData ()); hpp_->connect (iiop.constData (), context.constData ());
} catch (const CosNaming::NamingContext::NotFound&) { hpp::Names_t_var for_memory_deletion = hpp_->problem()->getAvailable("type");
const char* msg = "Could not find the manipulation server. Is it running ?"; } catch (const CORBA::Exception& e) {
qDebug () << msg; QString error ("Could not find the manipulation server. Is it running ?");
error += "\n";
error += e._name();
error += " : ";
error += e._rep_id();
gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance(); gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance();
if (main != NULL) if (main != NULL)
main->logError(msg); main->logError(error);
else
qDebug () << error;
if (hpp_) delete hpp_;
hpp_ = NULL;
} }
} }
...@@ -191,6 +202,7 @@ namespace hpp { ...@@ -191,6 +202,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::drawRobotContacts() void HppManipulationWidgetsPlugin::drawRobotContacts()
{ {
if (hpp_) return;
hpp::Names_t_var rcs = hpp_->problem()->getRobotContactNames(); hpp::Names_t_var rcs = hpp_->problem()->getRobotContactNames();
hpp::floatSeqSeq_var points; hpp::floatSeqSeq_var points;
hpp::intSeq_var indexes; hpp::intSeq_var indexes;
...@@ -214,6 +226,7 @@ namespace hpp { ...@@ -214,6 +226,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::drawEnvironmentContacts() void HppManipulationWidgetsPlugin::drawEnvironmentContacts()
{ {
if (hpp_) return;
hpp::Names_t_var rcs = hpp_->problem()->getEnvironmentContactNames(); hpp::Names_t_var rcs = hpp_->problem()->getEnvironmentContactNames();
hpp::floatSeqSeq_var points; hpp::floatSeqSeq_var points;
hpp::intSeq_var indexes; hpp::intSeq_var indexes;
...@@ -234,6 +247,7 @@ namespace hpp { ...@@ -234,6 +247,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::drawHandlesFrame() void HppManipulationWidgetsPlugin::drawHandlesFrame()
{ {
if (hpp_) return;
gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance (); gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
hpp::Names_t_var rcs = hpp_->problem()->getAvailable("handle"); hpp::Names_t_var rcs = hpp_->problem()->getAvailable("handle");
hpp::Transform__var t (new Transform_); hpp::Transform__var t (new Transform_);
...@@ -255,6 +269,7 @@ namespace hpp { ...@@ -255,6 +269,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::drawGrippersFrame() void HppManipulationWidgetsPlugin::drawGrippersFrame()
{ {
if (hpp_) return;
gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance (); gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
hpp::Names_t_var rcs = hpp_->problem()->getAvailable("gripper"); hpp::Names_t_var rcs = hpp_->problem()->getAvailable("gripper");
hpp::Transform__var t (new Transform_); hpp::Transform__var t (new Transform_);
...@@ -329,6 +344,7 @@ namespace hpp { ...@@ -329,6 +344,7 @@ namespace hpp {
HppManipulationWidgetsPlugin::MapNames HppManipulationWidgetsPlugin::getObjects() HppManipulationWidgetsPlugin::MapNames HppManipulationWidgetsPlugin::getObjects()
{ {
assert (hpp_ != NULL);
HppManipulationWidgetsPlugin::MapNames map; HppManipulationWidgetsPlugin::MapNames map;
hpp::Names_t_var handles = manipClient()->problem()->getAvailable("handle"); hpp::Names_t_var handles = manipClient()->problem()->getAvailable("handle");
hpp::Names_t_var surfaces = manipClient()->problem()->getAvailable("robotcontact"); hpp::Names_t_var surfaces = manipClient()->problem()->getAvailable("robotcontact");
...@@ -400,6 +416,7 @@ namespace hpp { ...@@ -400,6 +416,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::buildGraph() void HppManipulationWidgetsPlugin::buildGraph()
{ {
if (hpp_) return;
QListWidget* l = dynamic_cast<QListWidget*>(tw_->widget(0)); QListWidget* l = dynamic_cast<QListWidget*>(tw_->widget(0));
HppManipulationWidgetsPlugin::MapNames handlesMap = getObjects(); HppManipulationWidgetsPlugin::MapNames handlesMap = getObjects();
HppManipulationWidgetsPlugin::MapNames shapesMap = getObjects(); HppManipulationWidgetsPlugin::MapNames shapesMap = getObjects();
...@@ -438,6 +455,7 @@ namespace hpp { ...@@ -438,6 +455,7 @@ namespace hpp {
void HppManipulationWidgetsPlugin::autoBuildGraph() void HppManipulationWidgetsPlugin::autoBuildGraph()
{ {
if (hpp_) return;
if (graphBuilder_ == NULL) { if (graphBuilder_ == NULL) {
graphBuilder_ = new QDialog(NULL, Qt::Dialog); graphBuilder_ = new QDialog(NULL, Qt::Dialog);
tw_ = new QTabWidget(graphBuilder_); tw_ = new QTabWidget(graphBuilder_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment