Salome HOME
Allow to create links to/from "default" ports of switch node in LinkBuilder::canCreat...
authorasv <asv@opencascade.com>
Fri, 14 Jan 2005 11:49:54 +0000 (11:49 +0000)
committerasv <asv@opencascade.com>
Fri, 14 Jan 2005 11:49:54 +0000 (11:49 +0000)
src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx

index 5ae3abfdd7183e48084784b915b05155dd38615f..4855b18adae231260f802b0680c3b23c39977385 100644 (file)
@@ -326,7 +326,6 @@ SUPERVGUI_CanvasLinkBuilder::~SUPERVGUI_CanvasLinkBuilder()
 
 bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort)
 {
-  bool result = false;
   if (thePort && myPort) {
     SUPERVGUI_CanvasPort* aInPort;
     SUPERVGUI_CanvasPort* aOutPort;
@@ -345,17 +344,10 @@ bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort)
       aInPort = thePort;
     }
 
-    // control if node is different
+    // control if nodes are different, not the same node
     QString aInNode(aInPort->getEngine()->Node()->Name());
     QString aOutNode(aOutPort->getEngine()->Node()->Name());
-    if (aInNode.compare(aOutNode) == 0) 
-      return false;
-
-    // control if no port is "Default"
-    QString aInName(aInPort->getEngine()->Name());
-    QString aOutName(aOutPort->getEngine()->Name());
-    if (aInName.compare("Default") == 0 ||
-       aOutName.compare("Default") == 0)
+    if (aInNode.compare(aOutNode) == 0) // linking outport and inport of the same node
       return false;
 
     // control types of ports
@@ -376,18 +368,21 @@ bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort)
     if ( aInKind == SUPERV::GateParameter && aOutKind != SUPERV::GateParameter && aOutKind != SUPERV::InLineParameter )
        return false;
 
-    // control if port is already linked except for input port of end switch node
-    if (!(aInKind == SUPERV::EndSwitchParameter || 
-         aInPort->getEngine()->Node()->Kind() == SUPERV::EndSwitchNode)) {
-      // asv : 15.12.04 : PAL7374, p.2.2 "Bugs and Improvements": multiple links into Gate port 
-      //                  for InGate it's OK to accept more than 1 link
-      if ( aInPort->getEngine()->IsLinked() && aInKind != SUPERV::GateParameter ) 
-       return false;
-    }
-
-    result = true;
+    // asv : 15.12.04 : PAL7374, p.2.2 "Bugs and Improvements": multiple links into Gate port 
+    //                  for InGate it's OK to accept more than 1 link
+    // THESE NEEDS REVISION, ALSO DON'T ALLOW MANY LINKS TO "DEFAULT" PORT OF EndSwitch
+    //if ( aInPort->getEngine()->IsLinked() && aInKind != SUPERV::GateParameter ) 
+    
+    // control if port is already linked except for input inline ports of end switch node (check for EndSwitchParameter)
+    // and "Default" port of Switch node (check for aNode->isEndSwitch()).  "Default" port is linked by default, but we
+    // let it to be "re-linked" to another port. 
+    const bool isEndSwitch = ( aInKind == SUPERV::EndSwitchParameter || aInPort->getEngine()->Node()->IsEndSwitch() );
+    if ( !isEndSwitch && aInPort->getEngine()->IsLinked() ) 
+      return false;
+    
+    return true;
   }
-  return result;
+  return false;
 }
 
 void SUPERVGUI_CanvasLinkBuilder::setCoords(SUPERV::Link_ptr theLink)