]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/SUPERVGUI/SUPERVGUI_Service.cxx
Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Service.cxx
index 2b13b08f9d0f466ae2a8f7347aa5b00664b542c5..749ed00aee12ec2e87b5c130f8b912147e3410c5 100644 (file)
@@ -127,16 +127,16 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns):
   //QHGroupBox* aAddBox = new QHGroupBox(tr("TIT_ADDNODE"), aCorbaPane); //!!
   //aAddBox->setInsideSpacing(20); //!!
 
-  QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!!
-  connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!!
-  aComputeCBtn->setDefault(false); 
+//NRI   QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!!
+//NRI   connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!!
+//NRI   aComputeCBtn->setDefault(false); 
 
   QPushButton* aComputeBtn = new QPushButton(tr("TIT_ADDFNODE"), aCorbaPane);
   connect(aComputeBtn, SIGNAL(clicked()), this, SLOT(addFactoryNode()));
   aComputeBtn->setDefault(true); 
 
   aBaseLayout->addWidget(aComputeBtn);
-  aBaseLayout->addWidget(aComputeCBtn); //!!
+  //NRI  aBaseLayout->addWidget(aComputeCBtn); //!!
 
   aBaseLayoutV->insertLayout(-1, aBaseLayout);
   myTabPane->addTab(aCorbaPane, tr("MODULES_PANE"));
@@ -213,6 +213,23 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns):
 }
 
 
+char* getDataStreamParameterName(int aType)
+{
+  switch(aType) {
+  case 1:
+    return "integer";
+  case 2:
+    return "float";
+  case 3:
+    return "double";
+  case 4:
+    return "string";
+  case 6:
+    return "boolean";
+  default:
+    return "unknown";
+  }
+}
 
 void SUPERVGUI_Service::initialise() {
   CORBA::Object_ptr obj  = naming->Resolve("/Kernel/ModulCatalog");
@@ -229,7 +246,7 @@ void SUPERVGUI_Service::initialise() {
   long nbComp = lComponents->length();
   for (int i=0; i<nbComp; i++) {
     SALOME_ModuleCatalog::Acomponent_ptr C = (*aModuleCatalog)->GetComponent((char *)lComponents[i]);
-    QListViewItem* myComponentItem = new QListViewItem(components, (char*)lComponents[i]);
+    QListViewItem* myComponentItem = new QListViewItem(components, (char*)C->componentusername());
     myComponentItem->setSelectable(false);
     QString aIconName = C->component_icone();
     if (!aIconName.isEmpty()) {
@@ -263,14 +280,34 @@ void SUPERVGUI_Service::initialise() {
        long nbPortsOut = Service->ServiceoutParameter.length();
        for (int m=0; m<nbPortsOut; m++) {
          SALOME_ModuleCatalog::ServicesParameter* PortOut = &(Service->ServiceoutParameter[m]);
-         QListViewItem* myPortOutItem = new QListViewItem(myServiceItem, (char*)PortOut->Parametername, (char*)PortOut->Parametertype, "Out");
+         QListViewItem* myPortOutItem = 
+           new QListViewItem(myServiceItem, (char*)PortOut->Parametername, (char*)PortOut->Parametertype, "Out");
+         myPortOutItem->setSelectable(false);
+       }
+
+       long nbStreamPortsOut = Service->ServiceoutDataStreamParameter.length();
+       for (int m=0; m<nbStreamPortsOut; m++) {
+         SALOME_ModuleCatalog::ServicesDataStreamParameter* PortOut = &(Service->ServiceoutDataStreamParameter[m]);
+         QListViewItem* myPortOutItem = 
+           new QListViewItem(myServiceItem, (char*)PortOut->Parametername, 
+                             getDataStreamParameterName(PortOut->Parametertype), "DataStream Out");
          myPortOutItem->setSelectable(false);
        }
        
        long nbPortsIn = Service->ServiceinParameter.length();
        for (int l=0; l<nbPortsIn; l++) {
          SALOME_ModuleCatalog::ServicesParameter* PortIn = &(Service->ServiceinParameter[l]);
-         QListViewItem* myPortInItem = new QListViewItem(myServiceItem, (char*)PortIn->Parametername, (char*)PortIn->Parametertype, "In");
+         QListViewItem* myPortInItem = 
+           new QListViewItem(myServiceItem, (char*)PortIn->Parametername, (char*)PortIn->Parametertype, "In");
+         myPortInItem->setSelectable(false);
+       }
+
+       long nbStreamPortsIn = Service->ServiceinDataStreamParameter.length();
+       for (int l=0; l<nbStreamPortsIn; l++) {
+         SALOME_ModuleCatalog::ServicesDataStreamParameter* PortIn = &(Service->ServiceinDataStreamParameter[l]);
+         QListViewItem* myPortInItem = 
+           new QListViewItem(myServiceItem, (char*)PortIn->Parametername, 
+                             getDataStreamParameterName(PortIn->Parametertype), "DataStream In");
          myPortInItem->setSelectable(false);
        }
       }
@@ -285,9 +322,10 @@ SUPERVGUI_Service::~SUPERVGUI_Service() {
 }
 
 void SUPERVGUI_Service::addComputeNode() {
+  QAD_Desktop* aDesktop = QAD_Application::getDesktop();
   SUPERVGUI_Main* aMain = Supervision.getMain();
   if (aMain==0) {
-    QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
+    QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
   } else {
     CORBA::Object_ptr obj  = naming->Resolve("/Kernel/ModulCatalog");
     SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
@@ -304,9 +342,9 @@ void SUPERVGUI_Service::addComputeNode() {
          const char* service   = item->text(0).latin1();
          const char* interface = item->parent()->text(0).latin1();
          const char* component = item->parent()->parent()->text(0).latin1();
-         SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
+         SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(aDesktop->getComponentName(component));
          if (myComponent==NULL) {
-           QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
+           QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
          } else {
            const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
            b  = true;
@@ -324,16 +362,17 @@ void SUPERVGUI_Service::addComputeNode() {
        }
       }
       if (!b) {
-       QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD"));
+       QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
       }
     }
   }
 }
 
 void SUPERVGUI_Service::addFactoryNode() {
+  QAD_Desktop* aDesktop = QAD_Application::getDesktop();
   SUPERVGUI_Main* aMain = Supervision.getMain();
   if (aMain==0) {
-    QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
+    QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
   } else {
     CORBA::Object_ptr obj  = naming->Resolve("/Kernel/ModulCatalog");
     SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
@@ -349,24 +388,49 @@ 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 = item->parent()->parent()->text(0).latin1();
+         const char* component = aDesktop->getComponentName(item->parent()->parent()->text(0).latin1());
          SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
          if (myComponent==NULL) {
-           QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
+           QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
          } else {
            const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
            b  = true;
            
-           SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService);
-           if (CORBA::is_nil(node)) {
-             QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));   
-             return;
+           MESSAGE ( " myService->TypeOfNode == " << myService->TypeOfNode ) 
+
+           if ( myService->TypeOfNode == 0 ) { // ComputeNode
+             SUPERV_CNode node = aMain->getDataflow()->CNode(*myService);
+             if (CORBA::is_nil(node)) {
+               QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));         
+               return;
+             }
+             node->Coords(myX, myY);
+             myX += NODE_DX;
+             myY += NODE_DY;
+             aMain->addComputeNode(SUPERV::CNode::_narrow(node));
+           } else { // Factory Node
+             SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService);
+             if (CORBA::is_nil(node)) {
+               QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));         
+               return;
+             }
+             node->Coords(myX, myY);
+             myX += NODE_DX;
+             myY += NODE_DY;
+             aMain->addComputeNode(SUPERV::CNode::_narrow(node));
+             
            }
-           node->Coords(myX, myY);
-           myX += NODE_DX;
-           myY += NODE_DY;
-           aMain->addComputeNode(SUPERV::CNode::_narrow(node));
-         }
+
+//         SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService);
+//         if (CORBA::is_nil(node)) {
+//           QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));   
+//           return;
+//         }
+//         node->Coords(myX, myY);
+//         myX += NODE_DX;
+//         myY += NODE_DY;
+//         aMain->addComputeNode(SUPERV::CNode::_narrow(node));
+         }
        }
       }
       if (!b) {