Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Canvas.cxx
index dd99c802bcb7884279f39766e4b320789e807741..ddb63f95836d6498f538ec2a40a4d9c4fe678a79 100644 (file)
@@ -1,12 +1,29 @@
-//  SUPERV SUPERVGUI : GUI for Supervisor component
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-//  Copyright (C) 2003  OPEN CASCADE
+//  SUPERV SUPERVGUI : GUI for Supervisor component
 //
 //  File   : SUPERVGUI_Ganvas.cxx
 //  Author : Natalia KOPNOVA
 //  Module : SUPERV
 
-using namespace std;
+#include "SUPERVGUI.h"
 #include "SUPERVGUI_Def.h"
 #include "SUPERVGUI_Main.h"
 #include "SUPERVGUI_CanvasNode.h"
@@ -35,8 +52,10 @@ using namespace std;
        ihmList->removeRef(ihmNode); \
        ihmNode->merge(); \
         ihmNode = getNode(aCNodeEnd); \
-       ihmList->removeRef(ihmNode); \
-       ihmNode->merge(); \
+        if (ihmNode) { \
+         ihmList->removeRef(ihmNode); \
+         ihmNode->merge(); \
+        } \
       } \
     }
 
@@ -79,17 +98,27 @@ using namespace std;
 */
 
 
-SUPERVGUI_Canvas::SUPERVGUI_Canvas(SUPERVGUI_Main* m):
+SUPERVGUI_Canvas::SUPERVGUI_Canvas( SUPERVGUI_Main* m, SUIT_ResourceMgr* mgr ):
     QCanvas(),
     myMain(m)
 {
   Trace("SUPERVGUI_Canvas::SUPERVGUI_Canvas");
   myIsControlView = false;
   // resize(GRAPH_WIDTH, GRAPH_HEIGHT);
-  resize(800, 600);
+  resize(1050, 750);
   setDoubleBuffering(true);
 
-  QColor aColor(MAIN_COLOR);
+  // mkr : IPAL10825 -->
+  SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+  if ( !aSupMod ) {
+    MESSAGE("NULL Supervision module!");
+    return;
+  }
+  QColor aColor =  aSupMod->getIVFBackgroundColor();
+  if ( !aColor.isValid() )
+    aColor = mgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR );
+  // <--
+     
   //aColor = QColor(SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorRed" ), 
   //             SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorGreen" ), 
   //             SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorBlue" ) );
@@ -179,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();
@@ -201,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) {