Salome HOME
Join modifications from branch BR_3_1_0deb
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasArray.cxx
index cf9404719e9f5a9ab41f3c3dc6622aa43a8138bf..19d07d227521aa716a8a2df355a4b9ed07116bfe 100644 (file)
@@ -7,6 +7,7 @@
 //  Module : SUPERV
 
 using namespace std;
+#include "SUPERVGUI.h"
 #include "SUPERVGUI_CanvasArray.h"
 #include "SUPERVGUI_Main.h"
 #include "SUPERVGUI_BrowseNodeDlg.h"
@@ -18,6 +19,8 @@ using namespace std;
 #include <qtooltip.h>
 #define TEXT_MARGIN 5
 
+#include <iostream.h> //for debug only
+
 #define ADDNODES(NodesName,LevelHasDiffNT) \
     ncols = nodes->NodesName.length(); \
     for (int co=0; co<ncols; co++) {  \
@@ -26,7 +29,7 @@ using namespace std;
       else x += (CELL_WIDTH  + CELL_SPACE); \
       cell = getCellNode(aCNode); \
       if (cell == NULL) { \
-        SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(this, myMain, aCNode); \
+        SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(myMgr, this, myMain, aCNode); \
         aNode->move(x, y); \
         aNode->show(); \
         aNode->sync(); \
@@ -48,12 +51,12 @@ using namespace std;
       SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \
       cell = getCellNode(aCNode); \
       if (cell == NULL) { \
-        SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(this, myMain, aCNode); \
+        SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode( myMgr, this, myMain, aCNode); \
         aNode->move(x, y); \
         aNode->show(); \
         aNode->sync(); \
         y += (CELL_HEIGHT + CELL_SPACE); \
-        SUPERVGUI_CanvasCellNode* aNodeEnd = new SUPERVGUI_CanvasCellEndNode(this, myMain, aCNodeEnd, aNode); \
+        SUPERVGUI_CanvasCellNode* aNodeEnd = new SUPERVGUI_CanvasCellEndNode( myMgr, this, myMain, aCNodeEnd, aNode); \
         aNodeEnd->move(x, y); \
         aNodeEnd->show(); \
         aNodeEnd->sync(); \
@@ -74,16 +77,27 @@ using namespace std;
 // SUPERVGUI_Array on QCanvas
 // ----------------------------------------------------------
 
-SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray(SUPERVGUI_Main* m):
+SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray(SUPERVGUI_Main* m, SUIT_ResourceMgr* mgr ):
   QCanvas(),
-  myMain(m)
+  myMain(m),
+  myMgr( mgr )
 {
   Trace("SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray");
   //resize(GRAPH_WIDTH, GRAPH_HEIGHT);
   resize(1000, 725);
   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" ) );
@@ -132,15 +146,23 @@ bool SUPERVGUI_CanvasArray::create() {
   SUPERVGUI_CanvasCellNode* cell;
   QString         aLabel;
   int             x, y;
   int             nligs = myMain->getDataflow()->LevelMax();
+  cout<<"-> myMain->getDataflow()->LevelMax() = "<<myMain->getDataflow()->LevelMax()<<endl;
   int             ncols = myMain->getDataflow()->ThreadsMax();
+  cout<<"-> myMain->getDataflow()->ThreadsMax() = "<<myMain->getDataflow()->ThreadsMax()<<endl;
   
   // there is no any calculations
   if (ncols == 0) return false;
 
   QPen pen(Qt::SolidLine);
   pen.setWidth(1);
-  QBrush br(MAIN_TITLE);
+
+  QBrush br( myMgr->colorValue( "SUPERVGraph", "Title", DEF_MAIN_TITLE ) );
+  
+  // variables to resize canvas in table view
+  int aMaxWidth = 0;
+  int aMaxHeight = 0;
   
   for (int co = 0; co < ncols; co++) {
     aLabel = QString("Thread %1").arg(co);
@@ -157,6 +179,8 @@ bool SUPERVGUI_CanvasArray::create() {
     aText->setY(aRect.y() + aRect.height()/2 - aBRect.height()/2);
     aText->setZ(1);
     aText->show();
+    
+    aMaxWidth = aRect.x() + aRect.width() + 50;
   }
   
   y = 60;
@@ -202,6 +226,13 @@ bool SUPERVGUI_CanvasArray::create() {
   nodeX = 50;
   nodeY = y + CELL_HEIGHT*2;
 
+  aMaxHeight = nodeY;
+  
+  // if aMaxWidth and aMaxHeight is greater than the current size 
+  // of the canvas, we resize canvas to these new width and height
+  if ( aMaxWidth > this->width() || aMaxHeight > this->height() )
+    this->resize( aMaxWidth > this->width() ? aMaxWidth : this->width(), 
+                 aMaxHeight > this->height() ? aMaxHeight : this->height() );
   return true;
 
 }
@@ -238,7 +269,7 @@ SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::getCellNode(SUPERV::CNode_ptr t
 
 SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::addNode(SUPERV_CNode node) {
   Trace("SUPERVGUI_CanvasArray::addNode");
-  SUPERVGUI_CanvasCellNode* n = new SUPERVGUI_CanvasCellNode(this, myMain, node);
+  SUPERVGUI_CanvasCellNode* n = new SUPERVGUI_CanvasCellNode( myMgr, this, myMain, node);
   n->move(nodeX, nodeY);
   n->show();
   update();