Salome HOME
Modifications for correct adding factory nodes into the dataflow.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Service.cxx
index 788cd8eeaa3df87339ac569b84ccb750f8bb7aa9..9732c589fc9db5298ebd10b57c0d06b3578e35fd 100644 (file)
@@ -452,32 +452,36 @@ void SUPERVGUI_Service::addFactoryNode() {
        if (item->isSelected()) {
          const char* service   = item->text(0).latin1();
          const char* interface = item->parent()->text(0).latin1();
-         const char* component = anApp->moduleName(item->parent()->parent()->text(0).latin1());
-         SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
-         if (myComponent==NULL) {
-           QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
-         } 
-         else {
-           const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
-           SUPERV_CNode aNode;
-           if ( myService->TypeOfNode == 0 ) { // ComputeNode
-             aNode = aMain->getDataflow()->CNode(*myService);
-             if (CORBA::is_nil( aNode ) ) {
-               QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));          
-               return;
-             }
+         //const char* component = anApp->moduleName(item->parent()->parent()->text(0).latin1());
+         if ( aSupMod->getInterfaceNameMap().contains(item->parent()->text(0)) ) {
+           const char* component = aSupMod->getInterfaceNameMap().find(item->parent()->text(0)).data();
+
+           SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
+           if (myComponent==NULL) {
+             QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
            } 
-           else { // Factory Node
-             aNode = aMain->getDataflow()->FNode(component, interface, *myService);
-             if ( CORBA::is_nil( aNode ) ) {
-               QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));          
-               return;
+           else {
+             const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
+             SUPERV_CNode aNode;
+             if ( myService->TypeOfNode == 0 ) { // ComputeNode
+               aNode = aMain->getDataflow()->CNode(*myService);
+               if (CORBA::is_nil( aNode ) ) {
+                 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));        
+                 return;
+               }
+             } 
+             else { // Factory Node
+               aNode = aMain->getDataflow()->FNode(component, interface, *myService);
+               if ( CORBA::is_nil( aNode ) ) {
+                 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));        
+                 return;
+               }
              }
+             SUPERV::INode_var aDummyEndNode;
+             addNode( aNode, aDummyEndNode, myX, myY );
+             b = true;
            }
-           SUPERV::INode_var aDummyEndNode;
-           addNode( aNode, aDummyEndNode, myX, myY );
-           b = true;
-         }
+         }
        }
       }
       if ( !b ) {
@@ -994,7 +998,7 @@ void SUPERVGUI_Service::addNode( SUPERV::CNode_var theNode, SUPERV::INode_var th
   SUPERVGUI_Main* aMain = aSupMod->getMain();
 
   if ( !CORBA::is_nil( theNode ) && aMain ) {
-
+    
     aMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> PAL7960
 
     int cx, cy;   //to appear a new node in the top-left corner of the current viewport
@@ -1020,6 +1024,6 @@ void SUPERVGUI_Service::addNode( SUPERV::CNode_var theNode, SUPERV::INode_var th
       aMain->addControlNode( theNode, SUPERV::CNode::_narrow( theEndNode ), true );
     else
       aMain->addComputeNode( theNode );
-  }  
+  }
 }