Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Link.cxx
index d7e5a820c7d0f8a9a83dd212ca0e3772ad843e1b..80158db62e164b4bd74905a98743692a0060afcc 100644 (file)
@@ -253,7 +253,8 @@ void SUPERVGUI_Link::paint(bool toErase) {
   if (toErase) {
     aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor());
   } else {
-    if (strcmp(myEngine->InPort()->Name(), "InVoid")==0)
+    if ((strcmp(myEngine->InPort()->Name(), "InVoid")==0) || 
+       (myEngine->InPort()->Kind() == SUPERV::DataStreamParameter ))
       aDataPen.setColor(CTRL_CLR);
     else
       aDataPen.setColor(DRAW_CLR);
@@ -279,7 +280,8 @@ void SUPERVGUI_Link::paint(QPainter* thePainter, bool toErase) {
   if (toErase) {
     aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor());
   } else {
-    if (strcmp(myEngine->InPort()->Name(), "InVoid")==0)
+    if ((strcmp(myEngine->InPort()->Name(), "InVoid")==0)|| 
+       (myEngine->InPort()->Kind() == SUPERV::DataStreamParameter ))
       aDataPen.setColor(CTRL_CLR);
     else
       aDataPen.setColor(DRAW_CLR);
@@ -395,12 +397,20 @@ void SUPERVGUI_Link::setVisible(bool theVisible) {
 bool SUPERVGUI_Link::isCreationComplete() {
   bool aIsBoth = myPortIn && myPortOut;
   if (myPortIn && myPortOut) {
+    // Check: is the same node?
     SUPERV_Port aInPort = myPortIn->getPort();
     QString aInNodeName(aInPort->Node()->Name());
     SUPERV_Port aOutPort = myPortOut->getPort();
     QString aOutNodeName(aOutPort->Node()->Name());
+
+    bool aCanCreate = true;
+    // Stream port can be connected only with stream port
+    if (myPortIn->getPort()->Kind() == SUPERV::DataStreamParameter)
+      aCanCreate = (myPortOut->getPort()->Kind() == SUPERV::DataStreamParameter);
+    else if (myPortOut->getPort()->Kind() == SUPERV::DataStreamParameter)
+      aCanCreate = (myPortIn->getPort()->Kind() == SUPERV::DataStreamParameter);
     
-    return (aInNodeName != aOutNodeName);
+    return aCanCreate && (aInNodeName != aOutNodeName);
   }
   else if (myPortInES && myPortOut) {
     SUPERV_Port aInPortES = myPortInES->getPort();
@@ -447,10 +457,16 @@ bool SUPERVGUI_Link::createEngine() {
   }
     
   // Create engine
-  if (!isESInputPort())
-    myEngine = myGraph->getMain()->getDataflow()->
-      Link(myPortOut->getPort(), myPortIn->getPort());
-  else
+  if (!isESInputPort()) {
+    if (myStartPort->getPort()->Kind() == SUPERV::DataStreamParameter) {
+      SUPERVGUI_StreamPortOut* aOut = dynamic_cast<SUPERVGUI_StreamPortOut*>(myPortOut);
+      SUPERVGUI_StreamPortIn* aIn = dynamic_cast<SUPERVGUI_StreamPortIn*>(myPortIn);
+      myEngine = myGraph->getMain()->getDataflow()->
+       StreamLink(aOut->getStreamPort(), aIn->getStreamPort());
+    } else
+      myEngine = myGraph->getMain()->getDataflow()->
+       Link(myPortOut->getPort(), myPortIn->getPort());
+  } else
     myEngine = myGraph->getMain()->getDataflow()->
       Link(myPortOut->getPort(), myPortInES->getPort());
 
@@ -556,6 +572,7 @@ void SUPERVGUI_Link::onMousePress(QMouseEvent * theEvent) {
     return;
   }
   if (theEvent->button() != Qt::LeftButton) {
+    SelectedLink = 0;
     myHltPnt = -1;
     return;
   }