]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Correct Thread placing if any node was deleted
authormkr <mkr@opencascade.com>
Thu, 20 Jan 2005 10:14:15 +0000 (10:14 +0000)
committermkr <mkr@opencascade.com>
Thu, 20 Jan 2005 10:14:15 +0000 (10:14 +0000)
in Full view.

src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx
src/SUPERVGUI/SUPERVGUI_CanvasArray.h

index a95653493a454231bb495130ef33bbcfbc564fc9..7e18e792eac976573c43c2df0e400731b4456857 100644 (file)
@@ -14,7 +14,6 @@ using namespace std;
 #include "SUPERVGUI_CanvasCellNodePrs.h"
 
 #include <qtooltip.h>
-//#include <qpointarray.h> 
 #define TEXT_MARGIN 5
 
 #define ADDNODES(NodesName,LevelHasDiffNT) \
@@ -65,7 +64,7 @@ using namespace std;
         cell->show(); \
       } \
       update(); \
-      x += (CELL_WIDTH + CELL_SPACE); \
+      if (co < (ncols-1)) x += (CELL_WIDTH + CELL_SPACE); \
     }
 
 
@@ -89,7 +88,6 @@ SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray(SUPERVGUI_Main* m):
   if( (!aRed.isEmpty()) && (!aGreen.isEmpty()) && (!aBlue.isEmpty()) )
     aColor = QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt());
   setBackgroundColor(aColor);
-  myOldThreadNum = 0;
 }
 
 SUPERVGUI_CanvasArray::~SUPERVGUI_CanvasArray() {
@@ -103,18 +101,7 @@ SUPERVGUI_CanvasArray::~SUPERVGUI_CanvasArray() {
     ++aIt;
     delete anObj;
   }
-
   delete aCellList;
-
-  QObjectList* aCellEndList = queryList("SUPERVGUI_CanvasCellEndNode");
-  QObjectListIt aItEnd(*aCellEndList);
-  QObject* anObjEnd;
-  while ((anObjEnd = aItEnd.current()) != 0) {
-    ++aItEnd;
-    delete anObjEnd;
-  }
-
-  delete aCellEndList;
 }
 
 void SUPERVGUI_CanvasArray::sync() {
@@ -128,15 +115,6 @@ void SUPERVGUI_CanvasArray::sync() {
     ihmNode->sync();
   }
   delete ihmList;
-
-  SUPERVGUI_CanvasCellEndNode* ihmNodeEnd;
-  QObjectList* ihmListEnd = queryList("SUPERVGUI_CanvasCellEndNode");
-  QObjectListIt itEnd(*ihmListEnd);
-  while ((ihmNodeEnd=(SUPERVGUI_CanvasCellEndNode*)itEnd.current()) != 0) {
-    ++itEnd;
-    ihmNodeEnd->sync();
-  }
-  delete ihmListEnd;
 }
 
 bool SUPERVGUI_CanvasArray::create() {
@@ -159,34 +137,12 @@ bool SUPERVGUI_CanvasArray::create() {
   
   // there is no any calculations
   if (ncols == 0) return false;
-  
+
   QPen pen(Qt::SolidLine);
   pen.setWidth(1);
   QBrush br(MAIN_TITLE);
   
-  if (myOldThreadNum) { //some of threads allready exist on canvas array
-    QObjectList* aThreadList = queryList("QCanvasRectangle");
-    QObjectListIt aItThread(*aThreadList);
-    QCanvasRectangle* anObjThread;
-    while ((anObjThread = (QCanvasRectangle*)aItThread.current()) != 0) {
-      ++aItThread;
-      if (!anObjThread->isVisible())
-       anObjThread->show();
-    }
-    delete aThreadList;
-    
-    QObjectList* aTextList = queryList("QCanvasText");
-    QObjectListIt aItText(*aTextList);
-    QCanvasText* anObjText;
-    while ((anObjText = (QCanvasText*)aItText.current()) != 0) {
-      ++aItText;
-      if (!anObjText->isVisible())
-       anObjText->show();
-    }
-    delete aTextList;
-  }
-
-  for (int co = myOldThreadNum; co < ncols; co++) {
+  for (int co = 0; co < ncols; co++) {
     aLabel = QString("Thread %1").arg(co);
     QRect aRect = QRect(50 + co * (CELL_WIDTH  + CELL_SPACE), 20, CELL_WIDTH, CELL_HEIGHT);
     QCanvasRectangle* aThread = new QCanvasRectangle(aRect, this);
@@ -203,8 +159,6 @@ bool SUPERVGUI_CanvasArray::create() {
     aText->show();
   }
   
-  myOldThreadNum = ncols;
-  
   y = 60;
   bool LevelHasDiffNT = false;
   for (int li = 0; li <= nligs; li++) {
@@ -262,39 +216,18 @@ void SUPERVGUI_CanvasArray::destroy() {
     ++aIt;
     ((SUPERVGUI_CanvasCellNode*)anObj)->getPrs()->hide();
   }
-
   delete aCellList;
 
-  QObjectList* aCellEndList = queryList("SUPERVGUI_CanvasCellEndNode");
-  QObjectListIt aItEnd(*aCellEndList);
-  QObject* anObjEnd;
-  while ((anObjEnd = aItEnd.current()) != 0) {
-    ++aItEnd;
-    ((SUPERVGUI_CanvasCellEndNode*)anObjEnd)->getPrs()->hide();
-  }
-
-  delete aCellEndList;
-
-  QObjectList* aThreadList = queryList("QCanvasRectangle");
-  QObjectListIt aItThread(*aThreadList);
-  QCanvasRectangle* anObjThread;
-  while ((anObjThread = (QCanvasRectangle*)aItThread.current()) != 0) {
-    ++aItThread;
-    anObjThread->hide(); 
-  }
-
-  delete aThreadList;
-
-  QObjectList* aTextList = queryList("QCanvasText");
-  QObjectListIt aItText(*aTextList);
-  QCanvasText* anObjText;
-  while ((anObjText = (QCanvasText*)aItText.current()) != 0) {
-    ++aItText;
-    anObjText->hide(); 
+  // mkr : delete QCanvasRectangle and QCanvasText canvas items for each Thread.
+  // Threads will be recreate when create() function is called
+  QCanvasItemList aTextList = allItems();
+  for (QCanvasItemList::Iterator aItText = aTextList.begin(); aItText != aTextList.end(); ++aItText) {
+    SUPERVGUI_CanvasCellNodePrs* aPrs = dynamic_cast<SUPERVGUI_CanvasCellNodePrs*>(*aItText);
+    if (!aPrs) {
+      (*aItText)->hide();
+      delete *aItText;
+    }
   }
-
-  delete aTextList; 
-
 }
 
 SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::getCellNode(SUPERV::CNode_ptr theNode) const
index 863b7c53d1e2be3c782a3592f309a0a73e3217b6..fc8e3ce76b3e8b0770ad63dad9b7b8bfc98cb8d6 100644 (file)
@@ -37,8 +37,6 @@ class SUPERVGUI_CanvasArray: public QCanvas {
     
     SUPERVGUI_Main* myMain;
 
-    int             myOldThreadNum;
-
     int             nodeX;
     int             nodeY;