Salome HOME
MPV: Merge V1_2d
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_GraphNode.cxx
index 3a1676f005dc2fdaa9423cd54bd306edd095fea7..af07998b7417e392ba885121a43ec4b789d81660 100644 (file)
@@ -54,16 +54,27 @@ SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* the
   myPOcount = 0;
   SUPERV_Ports       ports = myNode->Ports();
   int                n     = ports->length();
-
   for (int i=0; i<n; i++) {
     if (ports[i]->IsInput()) {
-      if (ports[i]->IsGate())
-       myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i]), 
-                                0, 0);
-      else {
-       myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i]), 
-                               myPIcount, 0);
-       myPIcount++;
+      if (getComputingNode()->IsEndSwitch()) {
+       if (ports[i]->IsGate())
+         myGatesLayout->addWidget(new SUPERVGUI_PortInESNode(myGatesBox, myMain, ports[i]), 
+                                 0, 0);
+       else {
+         myPortLayout->addWidget(new SUPERVGUI_PortInESNode(myValuesBox, myMain, ports[i]), 
+                                 myPIcount, 0);
+         myPIcount++;
+       }
+      } else {
+       if (ports[i]->IsGate())
+         myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i]), 
+                                  0, 0);
+       else {
+         myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i]), 
+                                 myPIcount, 0);
+         myPIcount++;
+       }
       }
     } else {
       if (ports[i]->IsGate())
@@ -76,6 +87,7 @@ SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* the
       }
     }
   }
+
 }
 
 
@@ -290,40 +302,45 @@ void SUPERVGUI_GraphNode::sync() {
  * If toCheckExisting = true the existing of links will be checked before creation
  */
 void SUPERVGUI_GraphNode::updateLinksPrs(bool toCheckExisting) {
+    
   SUPERVGUI_Graph* aGraph= myMain->getGraph();
-  SUPERVGUI_PortIn* pi;
-  QObjectList* ihmList = queryList("SUPERVGUI_PortIn");
-  QObjectListIt i(*ihmList);
-  while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) {
-    ++i;
-    if (pi->getPort()->IsLinked()) {
-      SUPERV_Link aLink = pi->getPort()->Link();
-      if (toCheckExisting) {
-       if (aGraph->isLinkPrsExists(aLink))
-         continue;
-      }
-      aGraph->createLinkPrs(aLink);
-    }
-  }
-  delete ihmList;
-
   //Find PortInESNode
   SUPERVGUI_PortInESNode* piES;
   QObjectList* ihmListES = queryList("SUPERVGUI_PortInESNode");
   QObjectListIt iES(*ihmListES);
-  while ((piES=(SUPERVGUI_PortInESNode*)iES.current()) != 0) {
-    ++iES;
-    if (piES->getPort()->IsLinked()) {
-      SUPERV_Links aLinks = piES->getPort()->Links();
-      for (int j=0; j<aLinks->length(); j++) {
+  if (iES.count()) {
+    while ((piES=(SUPERVGUI_PortInESNode*)iES.current()) != 0) {
+      ++iES;
+      if (piES->getPort()->IsLinked()) {
+       SUPERV_Links aLinks = piES->getPort()->Links();
+       for (int j=0; j<aLinks->length(); j++) {
+         if (toCheckExisting) {
+           if (aGraph->isLinkPrsExists(aLinks[j]))
+             continue;
+         }
+         aGraph->createLinkPrs(aLinks[j]);
+       }
+      }
+    }
+  }
+  else {
+    SUPERVGUI_PortIn* pi;
+    QObjectList* ihmList = queryList("SUPERVGUI_PortIn");
+    QObjectListIt i(*ihmList);
+    while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) {
+      ++i;
+      if (pi->getPort()->IsLinked()) {
+       SUPERV_Link aLink = pi->getPort()->Link();
        if (toCheckExisting) {
-         if (aGraph->isLinkPrsExists(aLinks[j]))
+         if (aGraph->isLinkPrsExists(aLink))
            continue;
        }
-       aGraph->createLinkPrs(aLinks[j]);
+       aGraph->createLinkPrs(aLink);
       }
     }
+    delete ihmList;
   }
+
   delete ihmListES;
 }
 
@@ -344,7 +361,9 @@ void SUPERVGUI_GraphNode::deletePort(SUPERVGUI_Port* thePort) {
   thePort->deleteLinks();
   
   thePort->getPort()->destroy();
+
   thePort->close(true);
+
   updatePorts();
   updateShape();
 }
@@ -435,6 +454,7 @@ void SUPERVGUI_GraphNode::updatePorts() {
   QObjectListIt aLI(*aShownPortsList);
   SUPERVGUI_Port* aVisPort;
 
+
   while ((aVisPort=(SUPERVGUI_Port*)aLI.current()) != 0) {  
     ++aLI;
     QString aNameVisible(aVisPort->getPort()->Name());