Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Canvas.cxx
index b3070b1b8bc698baaf33a007e0257b6903da2748..ddb63f95836d6498f538ec2a40a4d9c4fe678a79 100644 (file)
        ihmList->removeRef(ihmNode); \
        ihmNode->merge(); \
         ihmNode = getNode(aCNodeEnd); \
-       ihmList->removeRef(ihmNode); \
-       ihmNode->merge(); \
+        if (ihmNode) { \
+         ihmList->removeRef(ihmNode); \
+         ihmNode->merge(); \
+        } \
       } \
     }
 
@@ -206,7 +208,7 @@ void SUPERVGUI_Canvas::sync() {
  */
 void SUPERVGUI_Canvas::merge() {
   if (SUPERV_isNull(myMain->getDataflow())) return;
-      
+
   SUPERVGUI_CanvasNode* ihmNode;
   QObjectList* ihmList = queryList("SUPERVGUI_CanvasNode");
   SUPERV_Nodes nodes = myMain->getDataflow()->Nodes();
@@ -228,6 +230,43 @@ void SUPERVGUI_Canvas::merge() {
 
   UPDATECONTROLNODES(LNodes);    
   UPDATECONTROLNODES(SNodes);
+  /*
+  n = nodes->LNodes.length();
+  for (int i=0; i<n; i++) {
+    SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->LNodes[i]);
+    SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->LNodes[i]->Coupled());
+    ihmNode = getNode(aCNode);
+    SUPERVGUI_CanvasNode* ihmNodeEnd = getNode(aCNodeEnd);
+    if (ihmNode == NULL) {
+      myMain->addControlNode(aCNode, aCNodeEnd, false);
+    } else {
+      if (ihmNodeEnd) {
+        ihmNode->move(aCNode->X(), aCNode->Y());
+        ihmList->removeRef(ihmNode);
+        ihmNode->merge();
+        ihmNode = getNode(aCNodeEnd);
+        ihmList->removeRef(ihmNode);
+        ihmNode->merge();
+      }
+    }
+  }
+  n = nodes->SNodes.length();
+  for (int i=0; i<n; i++) {
+    SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->SNodes[i]);
+    SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->SNodes[i]->Coupled());
+    ihmNode = getNode(aCNode);
+    if (ihmNode == NULL) {
+      myMain->addControlNode(aCNode, aCNodeEnd, false);
+    } else {
+      ihmNode->move(aCNode->X(), aCNode->Y());
+      ihmList->removeRef(ihmNode);
+      ihmNode->merge();
+      ihmNode = getNode(aCNodeEnd);
+      ihmList->removeRef(ihmNode);
+      ihmNode->merge();
+    }
+  }
+  //*/
 
   QObjectListIt it(*ihmList);
   while ((ihmNode=(SUPERVGUI_CanvasNode*)it.current()) != 0) {