]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Modifications for correct adding factory nodes into the dataflow. T3_0_0_a3
authormkr <mkr@opencascade.com>
Thu, 9 Jun 2005 12:46:32 +0000 (12:46 +0000)
committermkr <mkr@opencascade.com>
Thu, 9 Jun 2005 12:46:32 +0000 (12:46 +0000)
src/SUPERVGUI/SUPERVGUI.cxx
src/SUPERVGUI/SUPERVGUI.h
src/SUPERVGUI/SUPERVGUI_Service.cxx

index 3d4f78f45954e7a1d404d1b7912b1c91ff05f650..e97ccda262558a256b50a38be9aafcaf1adab194 100644 (file)
@@ -141,6 +141,8 @@ void SUPERVGUI::initialize( CAM_Application* app )
   //info    = new SUPERVGUI_Information();
   cursor  = application()->desktop()->cursor();
 
+  fillInterfaceNameMap();
+
   // ----- create actions --------------
   createSupervAction( 301, "IMPORT" );
   createSupervAction( 302, "EXPORT" );
@@ -890,3 +892,37 @@ bool SUPERVGUI::ActiveStudyChanged() {
   buffer[0] = (int)VIEW_GRAPHSUPERV;
 }*/
 
+void SUPERVGUI::fillInterfaceNameMap() {
+  //fill map: interface_name <-> component_name for all
+  //interfaces of all loaded components, it is necessary
+  //for correct adding factory nodes from AddComponent,
+  //SubComponent, MulComponent, etc. components.
+  myInterfaceNameMap.clear();
+
+  //get naming service
+  SALOME_NamingService* namingService = (( SalomeApp_Application* )application())->namingService();
+  //get module catalog
+  CORBA::Object_ptr obj  = namingService->Resolve("/Kernel/ModulCatalog");
+  SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
+  *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
+  if (!CORBA::is_nil(*aModuleCatalog)) {
+    //get component list
+    SALOME_ModuleCatalog::ListOfComponents_var aCompList = (*aModuleCatalog)->GetComponentList();
+    for (int ind1 = 0; ind1 < aCompList->length(); ind1++) {
+      //get component
+      SALOME_ModuleCatalog::Acomponent_ptr aComponent = (*aModuleCatalog)->GetComponent(aCompList[ind1]);
+      if ( aComponent != NULL ) {
+       //get interface list 
+       SALOME_ModuleCatalog::ListOfInterfaces_var anIntList = aComponent->GetInterfaceList();
+       for (int ind2 = 0; ind2 < anIntList->length(); ind2++) {
+         const char* anIntName = anIntList[ind2];
+         myInterfaceNameMap.insert(QString(anIntName), QString(aComponent->componentname()));
+       }
+      }
+    }
+  }
+}
+
+QMap<QString, QString> SUPERVGUI::getInterfaceNameMap() const {
+  return myInterfaceNameMap;
+}
index e484bcde42309b93a4ddc1a18097e27c07619c0a..f5bd8d9597b614b2e959e3f2b7327450b6c6f2da 100644 (file)
@@ -108,6 +108,8 @@ class SUPERVGUI: public SalomeApp_Module {
 
     virtual void windows( QMap<int, int>& ) const;
 
+    QMap<QString, QString> getInterfaceNameMap() const;
+
   signals:
     void KillMainThread(bool theValue);
 
@@ -139,6 +141,8 @@ class SUPERVGUI: public SalomeApp_Module {
     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
                             const int key = 0, const bool toggle = false );
 
+    void fillInterfaceNameMap();
+
     static int             factory;
     SUIT_Study*            study;
     SUPERV_Engine          engine;
@@ -148,6 +152,7 @@ class SUPERVGUI: public SalomeApp_Module {
 
     SUPERVGUI_Main*        main;  // active main    
     QPtrList<SUPERVGUI_Main> myGraphList;
+    QMap<QString, QString> myInterfaceNameMap;
 };
 
 #endif
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 );
-  }  
+  }
 }