Salome HOME
Add functionality for Table view based on QCanvas.
authormkr <mkr@opencascade.com>
Fri, 10 Dec 2004 13:55:46 +0000 (13:55 +0000)
committermkr <mkr@opencascade.com>
Fri, 10 Dec 2004 13:55:46 +0000 (13:55 +0000)
19 files changed:
src/SUPERVGUI/Makefile.in
src/SUPERVGUI/SUPERVGUI_ArrayView.cxx [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_ArrayView.h [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_CanvasArray.h [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx
src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h
src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx
src/SUPERVGUI/SUPERVGUI_CanvasNode.h
src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx
src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h
src/SUPERVGUI/SUPERVGUI_CanvasView.cxx
src/SUPERVGUI/SUPERVGUI_Def.h
src/SUPERVGUI/SUPERVGUI_Main.cxx
src/SUPERVGUI/SUPERVGUI_Main.h
src/SUPERVGUI/SUPERVGUI_Service.cxx
src/SUPERVGUI/SUPERV_msg_en.po

index f905094f98d04c8fc2e72a507e720c015cc2c347..bd7bce6f246cc750ca99ffa087fbe042f959b84d 100644 (file)
@@ -67,10 +67,13 @@ LIB_SRC = SUPERVGUI.cxx              \
          SUPERVGUI_Label.cxx        \
           SUPERVGUI_CanvasView.cxx   \
           SUPERVGUI_Canvas.cxx       \
+         SUPERVGUI_CanvasArray.cxx  \
+         SUPERVGUI_ArrayView.cxx   \
           SUPERVGUI_CanvasNode.cxx   \
           SUPERVGUI_CanvasNodePrs.cxx   \
           SUPERVGUI_CanvasControlNode.cxx   \
           SUPERVGUI_CanvasControlNodePrs.cxx   \
+         SUPERVGUI_CanvasCellNodePrs.cxx   \
           SUPERVGUI_CanvasPort.cxx   \
           SUPERVGUI_CanvasLink.cxx \
          SUPERVGUI_ManagePortsDlg.cxx
@@ -93,7 +96,9 @@ LIB_MOC = SUPERVGUI.h              \
          SUPERVGUI_Link.h        \
          SUPERVGUI_Label.h       \
           SUPERVGUI_Canvas.h       \
+         SUPERVGUI_CanvasArray.h  \
           SUPERVGUI_CanvasView.h   \
+         SUPERVGUI_ArrayView.h   \
          SUPERVGUI_CanvasNode.h   \
          SUPERVGUI_CanvasControlNode.h   \
          SUPERVGUI_CanvasPort.h   \
diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx
new file mode 100644 (file)
index 0000000..e0518b1
--- /dev/null
@@ -0,0 +1,197 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  Copyright (C) 2003  OPEN CASCADE
+//
+//  File   : SUPERVGUI_ArrayView.cxx
+//  Author : 
+//  Module : SUPERV
+
+
+using namespace std;
+#include "SUPERVGUI_ArrayView.h"
+#include "SUPERVGUI_Main.h"
+#include "SUPERVGUI_CanvasCellNodePrs.h"
+
+#include <qcolordialog.h>
+
+#if QT_VERSION >= 0x030005
+QCursor PanCursor(Qt::SizeAllCursor);
+#else
+QCursor PanCursor(SizeAllCursor);
+#endif
+
+SUPERVGUI_ArrayView::SUPERVGUI_ArrayView(SUPERVGUI_CanvasArray* theArray, SUPERVGUI_Main* theMain):
+  QCanvasView(theArray, theMain),
+  myMain(theMain)
+{
+  setName("TableView");
+
+  myIsPanActivated = false;
+
+  myAddStudyItem = 0;
+  myCursor = cursor();
+
+  viewport()->setMouseTracking(true); //widget receives mouse move events 
+                                      //even if no buttons are pressed down
+
+  myPopup = new QPopupMenu(viewport());
+
+  if (myMain->isEditable()) {
+    myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode()));
+    myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile()));
+    myPopup->insertSeparator();
+  }
+
+  QPopupMenu* aViewPopup = new QPopupMenu(viewport());
+  aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas()));
+  aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow()));
+  aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showTable()));
+  aViewPopup->insertItem(tr("POP_TABLEVIEWCANVAS"), myMain, SLOT(showCanvasTable()));
+
+  myPopup->insertItem(tr("POP_VIEW"), aViewPopup);
+  myPopup->insertSeparator();
+
+  /*QPopupMenu* aZoomPopup = new QPopupMenu(viewport());
+  aZoomPopup->insertItem("200%", this, SLOT(zoomIn()));
+  aZoomPopup->insertItem("100%", this, SLOT(zoomReset()));
+  aZoomPopup->insertItem("50%", this, SLOT(zoomOut()));
+  aZoomPopup->insertSeparator();
+  aZoomPopup->insertItem("Fit All", this, SLOT(fitAll()));
+
+  myPopup->insertItem("Zoom", aZoomPopup);
+  myPopup->insertSeparator();*/
+
+  myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy()));
+  myPopup->insertItem(tr("MSG_CHANGE_INFO"), myMain, SLOT(changeInformation()));
+  myPopup->insertSeparator();
+
+  myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), myMain, SLOT(copy()));
+  myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), myMain, SLOT(filterNotification()));
+
+  myPopup->insertSeparator();
+  myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground()));
+  hide();
+}
+
+SUPERVGUI_ArrayView::~SUPERVGUI_ArrayView()
+{
+}
+
+void SUPERVGUI_ArrayView::ActivatePanning()
+{
+  cout<<" ===> SUPERVGUI_ArrayView::ActivatePanning()"<<endl;
+  myIsPanActivated = true;
+  viewport()->setMouseTracking(false);
+}
+
+void SUPERVGUI_ArrayView::ResetView()
+{
+  setContentsPos(0,0);
+  QWMatrix m;
+  setWorldMatrix(m);
+}
+
+void SUPERVGUI_ArrayView::addToStudy() 
+{
+  if (myMain->addStudy()) myMain->setAsFromStudy(true);
+}
+
+void SUPERVGUI_ArrayView::changeBackground()
+{
+  QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this );
+  if ( aColor.isValid() ) {
+    canvas()->setBackgroundColor(aColor);
+    setPaletteBackgroundColor(aColor.light(120));
+  }
+}
+
+void SUPERVGUI_ArrayView::contentsMousePressEvent(QMouseEvent* theEvent) {
+  myGlobalPoint = theEvent->globalPos();
+
+  cout<<" ===> myIsPanActivated = "<<myIsPanActivated<<endl;
+  if (((theEvent->button() == Qt::MidButton)
+       &&
+       (theEvent->state() == Qt::ControlButton)) || myIsPanActivated) {
+    myIsPanActivated = true;
+    viewport()->setMouseTracking(false); //widget only receives mouse move events when at least one 
+                                         //mouse button is pressed down while the mouse is being moved
+    myCursor = cursor();
+    setCursor(PanCursor);
+    return;
+  } 
+
+  QPoint thePoint = inverseWorldMatrix().map(theEvent->pos());
+  // compute collision rectangle
+  QRect aSel(thePoint.x()-MARGIN, thePoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
+
+  if (theEvent->button() == RightButton) {
+    QCanvasItemList l = canvas()->collisions(aSel);
+    for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
+      if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
+       SUPERVGUI_CanvasCellNodePrs* aNodePrs = (SUPERVGUI_CanvasCellNodePrs*) (*it);
+       QObject* anObj = aNodePrs->getObject(thePoint);
+       if (anObj->inherits("SUPERVGUI_CanvasCellNode")) {
+         myMain->showPopup(((SUPERVGUI_CanvasCellNode*)anObj)->getPopupMenu(viewport()), 
+                           theEvent);
+         return;
+       }
+      }
+    }
+
+    myPopup->setItemEnabled(myAddStudyItem, !myMain->isFromStudy());
+    myMain->showPopup(myPopup, theEvent);
+    return;
+  }
+}
+
+void SUPERVGUI_ArrayView::contentsMouseMoveEvent(QMouseEvent* theEvent) {
+  QPoint g = theEvent->globalPos();
+  if (myIsPanActivated) {
+    scrollBy(myGlobalPoint.x() - g.x(),
+            myGlobalPoint.y() - g.y());
+    myGlobalPoint = g;
+    return;
+  }
+
+  // QToolTip for title and label for SUPERVGUI_CanvasCellNode
+  SUPERVGUI_ToolTip* aTT = new SUPERVGUI_ToolTip(this);
+  QPoint aPoint1 = inverseWorldMatrix().map(theEvent->pos());
+  aTT->maybeTip(aPoint1);
+}
+
+void SUPERVGUI_ArrayView::contentsMouseReleaseEvent(QMouseEvent* theEvent) {
+  if (myIsPanActivated) {
+    myIsPanActivated = false;
+    viewport()->setMouseTracking(true);
+    setCursor(myCursor);
+  }
+}
+
+void SUPERVGUI_ToolTip::maybeTip(const QPoint& theP) {
+  // compute collision rectangle
+  QRect aSel(theP.x()-MARGIN, theP.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
+
+  QCanvasItemList l = ((SUPERVGUI_ArrayView*)parentWidget())->canvas()->collisions(aSel);
+  for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
+    if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
+      SUPERVGUI_CanvasCellNodePrs* aNodePrs = (SUPERVGUI_CanvasCellNodePrs*) (*it);
+      QObject* anObj = aNodePrs->getObject(theP);
+      if (anObj->inherits("SUPERVGUI_CanvasCellNode")) {
+       
+       QRect aTitleRect = aNodePrs->getTitleRect();
+       if (aTitleRect.contains(theP, true)) {
+         tip(aTitleRect, ((SUPERVGUI_CanvasCellNode*)anObj)->getEngine()->Name());
+         return;
+       }
+
+       QRect aLabelRect = aNodePrs->getLabelRect();
+       if (aLabelRect.contains(theP, true)) {
+         tip(aLabelRect, ((SUPERVGUI_CanvasCellNode*)anObj)->getLabelText());
+         return;
+       }
+      }
+    }
+  }
+}
diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.h b/src/SUPERVGUI/SUPERVGUI_ArrayView.h
new file mode 100644 (file)
index 0000000..e851d56
--- /dev/null
@@ -0,0 +1,67 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  Copyright (C) 2003  OPEN CASCADE
+//
+//  File   : SUPERVGUI_ArrayView.h
+//  Author : 
+//  Module : SUPERV
+
+#ifndef SUPERVGUI_ArrayView_H
+#define SUPERVGUI_ArrayView_H
+
+#include "SUPERVGUI_CanvasArray.h"
+#include <qpopupmenu.h>
+#include <qtooltip.h>
+
+//VRV: porting on Qt 3.0.5
+#if QT_VERSION >= 0x030005
+#include <qcursor.h> 
+#endif
+//VRV: porting on Qt 3.0.5
+
+class SUPERVGUI_Main;
+
+class SUPERVGUI_ArrayView: public QCanvasView {
+  Q_OBJECT
+
+  public:
+    SUPERVGUI_ArrayView(SUPERVGUI_CanvasArray* theArray, SUPERVGUI_Main* theMain);
+    virtual ~SUPERVGUI_ArrayView();
+
+    SUPERVGUI_Main* getMain() const { return myMain; }
+
+    void ActivatePanning();
+    void ResetView();
+
+  public slots:
+    void addToStudy();
+    void changeBackground();
+
+  private:
+    void contentsMousePressEvent(QMouseEvent* theEvent);
+    void contentsMouseMoveEvent(QMouseEvent* theEvent);
+    void contentsMouseReleaseEvent(QMouseEvent* theEvent);
+
+    SUPERVGUI_Main* myMain;
+    QPopupMenu*     myPopup;
+    int             myAddStudyItem;
+
+    QCursor         myCursor;
+
+    QPoint   myGlobalPoint;
+
+    bool myIsPanActivated;
+
+};
+
+class SUPERVGUI_ToolTip: public QToolTip {
+
+  public:
+    SUPERVGUI_ToolTip(QWidget* theWidget, QToolTipGroup* theGroup = 0):
+      QToolTip(theWidget, theGroup) {}
+    ~SUPERVGUI_ToolTip() { remove(parentWidget()); }
+    
+    virtual void maybeTip(const QPoint& theP);
+};
+
+#endif
diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx
new file mode 100644 (file)
index 0000000..cce72c3
--- /dev/null
@@ -0,0 +1,342 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  Copyright (C) 2003  OPEN CASCADE
+//
+//  File   : SUPERVGUI_CanvasArray.cxx
+//  Author : 
+//  Module : SUPERV
+
+using namespace std;
+#include "SUPERVGUI_CanvasArray.h"
+#include "SUPERVGUI_Main.h"
+#include "SUPERVGUI_BrowseNodeDlg.h"
+#include "QAD_Config.h"
+#include "SUPERVGUI_CanvasCellNodePrs.h"
+
+#include <qtooltip.h>
+//#include <qpointarray.h> 
+#define TEXT_MARGIN 5
+
+#define ADDNODES(NodesName,LevelHasDiffNT) \
+    ncols = nodes->NodesName.length(); \
+    for (int co=0; co<ncols; co++) {  \
+      SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[co]); \
+      if (!LevelHasDiffNT) x = 50 + co * (CELL_WIDTH  + CELL_SPACE); \
+      else x += (CELL_WIDTH  + CELL_SPACE); \
+      cell = getCellNode(aCNode); \
+      if (cell == NULL) { \
+        cout<<" ***>  cell is NULL => create a new one"<<endl; \
+        SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(this, myMain, aCNode); \
+        aNode->move(x, y); \
+        aNode->show(); \
+        aNode->sync(); \
+      } else { \
+        cout<<" ***>  cell is NOT NULL => not create"<<endl; \
+        cell->move(x, y); \
+        cell->show(); \
+      } \
+      update(); \
+    }
+
+
+
+#define ADDCONTROLNODES(NodesName,LevelHasDiffNT) \
+    ncols = nodes->NodesName.length(); \
+    if (!LevelHasDiffNT) x = 50; \
+    else x += (CELL_WIDTH  + CELL_SPACE); \
+    for (int co=0; co<ncols; co++) {  \
+      SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[co]); \
+      SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \
+      cell = getCellNode(aCNode); \
+      if (cell == NULL) { \
+        cout<<" ***>  cell control is NULL => create a new one"<<endl; \
+        SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(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); \
+        aNodeEnd->move(x, y); \
+        aNodeEnd->show(); \
+        aNodeEnd->sync(); \
+      } else { \
+        cout<<" ***>  cell control is NOT NULL => not create"<<endl; \
+        cell->move(x, y); \
+        cell->show(); \
+        y += (CELL_HEIGHT + CELL_SPACE); \
+        cell = getCellNode(aCNodeEnd); \
+        cell->move(x, y); \
+        cell->show(); \
+      } \
+      update(); \
+      x += (CELL_WIDTH + CELL_SPACE); \
+    }
+
+
+// ----------------------------------------------------------
+// SUPERVGUI_Array on QCanvas
+// ----------------------------------------------------------
+
+SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray(SUPERVGUI_Main* m):
+  QCanvas(),
+  myMain(m)
+{
+  Trace("SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray");
+  //resize(GRAPH_WIDTH, GRAPH_HEIGHT);
+  resize(800, 600);
+  setDoubleBuffering(true);
+
+  QColor aColor(MAIN_COLOR);
+  QString aRed   = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
+  QString aGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
+  QString aBlue  = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
+  if( (!aRed.isEmpty()) && (!aGreen.isEmpty()) && (!aBlue.isEmpty()) )
+    aColor = QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt());
+  setBackgroundColor(aColor);
+  myOldThreadNum = 0;
+}
+
+SUPERVGUI_CanvasArray::~SUPERVGUI_CanvasArray() {
+  Trace("SUPERVGUI_Array::~SUPERVGUI_CanvasArray");
+  //delete all cells which SUPERVGUI_CanvasArray contains
+  //destroy();
+  QObjectList* aCellList = queryList("SUPERVGUI_CanvasCellNode");
+  QObjectListIt aIt(*aCellList);
+  QObject* anObj;
+  while ((anObj = aIt.current()) != 0) {
+    ++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() {
+  MESSAGE("===> SUPERVGUI_CanvasArray::sync()");
+  if (SUPERV_isNull(myMain->getDataflow())) return;
+  
+  SUPERVGUI_CanvasCellNode* ihmNode;
+  QObjectList* ihmList = queryList("SUPERVGUI_CanvasCellNode");
+  QObjectListIt it(*ihmList);
+  while ((ihmNode=(SUPERVGUI_CanvasCellNode*)it.current()) != 0) {
+    ++it;
+    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() {
+  Trace("SUPERVGUI_Array::create");
+  SUPERV_Nodes nodes = myMain->getDataflow()->Nodes();
+  int aCount = 0;
+  aCount += nodes->CNodes.length();
+  aCount += nodes->FNodes.length();
+  aCount += nodes->INodes.length();
+  aCount += nodes->GNodes.length();
+  aCount += nodes->LNodes.length();
+  aCount += nodes->SNodes.length();
+  if (aCount == 0) return true;
+
+  SUPERVGUI_CanvasCellNode* cell;
+  QString         aLabel;
+  int             x, y;
+  int             nligs = myMain->getDataflow()->LevelMax();
+  int             ncols = myMain->getDataflow()->ThreadsMax();
+  
+  // there is no any calculations
+  if (ncols == 0) return false;
+  
+  QCanvasItemList anIL1 = this->allItems();
+  cout<<" ===> begin create() : CanvasArray has "<<anIL1.count()<<" items!"<<endl;
+
+  QPen pen(Qt::SolidLine);
+  pen.setWidth(1);
+  QBrush br(MAIN_TITLE);
+  
+  if (myOldThreadNum) { //some of threads allready exist on canvas array
+    cout<<" ===> second ... creation !"<<endl;
+    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++) {
+    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);
+    aThread->setPen(pen);
+    aThread->setBrush(br);
+    aThread->setZ(0);
+    aThread->show();
+    
+    QCanvasText* aText = new QCanvasText(aLabel, this);
+    QRect aBRect = aText->boundingRect();
+    aText->setX(aRect.x() + aRect.width()/2 - aBRect.width()/2);
+    aText->setY(aRect.y() + aRect.height()/2 - aBRect.height()/2);
+    aText->setZ(1);
+    aText->show();
+  }
+  
+  myOldThreadNum = ncols;
+  
+  QCanvasItemList anIL2 = this->allItems();
+  cout<<" ===> 1 create() : CanvasArray has "<<anIL2.count()<<" items!"<<endl;
+  
+  y = 60;
+  bool LevelHasDiffNT = false;
+  for (int li = 0; li <= nligs; li++) {
+    nodes = myMain->getDataflow()->LevelNodes(li);
+    int aSumNum = nodes->CNodes.length()+nodes->FNodes.length()+nodes->INodes.length()+
+                  nodes->GNodes.length()+nodes->LNodes.length()+nodes->SNodes.length();
+    if (nodes->CNodes.length() != 0 ) {
+      ADDNODES(CNodes,LevelHasDiffNT);
+      if (aSumNum > nodes->CNodes.length())
+       LevelHasDiffNT = true;
+    }
+    if (nodes->FNodes.length() != 0 ) {
+      ADDNODES(FNodes,LevelHasDiffNT);
+
+       QCanvasItemList anIL3 = this->allItems();
+       cout<<" ===> 2 create() : CanvasArray has "<<anIL3.count()<<" items!"<<endl;
+
+      if (aSumNum > nodes->FNodes.length())
+       LevelHasDiffNT = true;
+    }
+    if (nodes->INodes.length() != 0 ) {
+      ADDNODES(INodes,LevelHasDiffNT);
+      if (aSumNum > nodes->INodes.length())
+       LevelHasDiffNT = true;
+    }
+    if (nodes->GNodes.length() != 0 ) {
+      ADDNODES(GNodes,LevelHasDiffNT);
+      if (aSumNum > nodes->GNodes.length())
+       LevelHasDiffNT = true;
+    }
+    if (nodes->LNodes.length() != 0 ) {
+      ADDCONTROLNODES(LNodes,LevelHasDiffNT);
+      if (aSumNum > nodes->LNodes.length())
+       LevelHasDiffNT = true;
+    }
+    if (nodes->SNodes.length() != 0 ) {
+      ADDCONTROLNODES(SNodes,LevelHasDiffNT);
+      if (aSumNum > nodes->SNodes.length())
+       LevelHasDiffNT = true;
+    }
+    y += (CELL_HEIGHT + CELL_SPACE);
+
+    LevelHasDiffNT = false;
+  }
+  nodeX = 50;
+  nodeY = y + CELL_HEIGHT*2;
+
+  QCanvasItemList anIL4 = this->allItems();
+  cout<<" ===> end create() : CanvasArray has "<<anIL4.count()<<" items!"<<endl;
+
+  return true;
+
+}
+
+void SUPERVGUI_CanvasArray::destroy() {
+  Trace("SUPERVGUI_Array::destroy");
+  
+  QCanvasItemList anIL1 = this->allItems();
+  cout<<" ===> begin destroy() : CanvasArray has "<<anIL1.count()<<" items!"<<endl;
+  const QObjectList* anCL1 = this->children();
+  cout<<" ===> begin destroy() : CanvasArray has "<<anCL1->count()<<" children!"<<endl;
+
+  QObjectList* aCellList = queryList("SUPERVGUI_CanvasCellNode");
+  QObjectListIt aIt(*aCellList);
+  QObject* anObj;
+  while ((anObj = aIt.current()) != 0) {
+    ++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(); 
+  }
+
+  delete aTextList; 
+
+  QCanvasItemList anIL2 = this->allItems();
+  cout<<" ===> end destroy() : CanvasArray has "<<anIL2.count()<<" items!"<<endl; 
+}
+
+SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::getCellNode(SUPERV::CNode_ptr theNode) const
+{
+  return (SUPERVGUI_CanvasCellNode*) 
+    ((SUPERVGUI_CanvasArray*)this)->child(theNode->Name(), "SUPERVGUI_CanvasCellNode");
+}
+
+SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::addNode(SUPERV_CNode node) {
+  Trace("SUPERVGUI_CanvasArray::addNode");
+  SUPERVGUI_CanvasCellNode* n = new SUPERVGUI_CanvasCellNode(this, myMain, node);
+  n->move(nodeX, nodeY);
+  n->show();
+  update();
+  nodeX += NODE_DX;
+  nodeY += NODE_DY;
+  n->sync();
+  return(n);
+}
diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasArray.h b/src/SUPERVGUI/SUPERVGUI_CanvasArray.h
new file mode 100644 (file)
index 0000000..863b7c5
--- /dev/null
@@ -0,0 +1,47 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  Copyright (C) 2003  OPEN CASCADE
+//
+//  File   : SUPERVGUI_CanvasArray.h
+//  Author : 
+//  Module : SUPERV
+
+#ifndef SUPERVGUI_CanvasArray_H
+#define SUPERVGUI_CanvasArray_H
+
+using namespace std;
+#include "SUPERVGUI_Def.h"
+#include "SUPERVGUI_CanvasControlNode.h"
+
+#include <qpopupmenu.h>
+#include <qcanvas.h>
+
+class SUPERVGUI_Main;
+
+class SUPERVGUI_CanvasArray: public QCanvas {
+  Q_OBJECT
+    
+  public:
+    SUPERVGUI_CanvasArray(SUPERVGUI_Main* m);
+    virtual ~SUPERVGUI_CanvasArray();
+
+    void sync();
+    bool create();
+    void destroy();
+
+    SUPERVGUI_CanvasCellNode* getCellNode(SUPERV::CNode_ptr theNode) const;
+
+    SUPERVGUI_CanvasCellNode* addNode(SUPERV_CNode node);
+
+  private:
+    
+    SUPERVGUI_Main* myMain;
+
+    int             myOldThreadNum;
+
+    int             nodeX;
+    int             nodeY;
+
+};
+
+#endif
diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx
new file mode 100644 (file)
index 0000000..3aa3ec3
--- /dev/null
@@ -0,0 +1,236 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  Copyright (C) 2003  OPEN CASCADE
+//
+//  File   : SUPERVGUI_CanvasCellNodePrs.cxx
+//  Author : 
+//  Module : SUPERV
+
+#include "SUPERVGUI_CanvasCellNodePrs.h"
+#include "SUPERVGUI_Canvas.h"
+
+#define TEXT_MARGIN 5
+
+// ----------------------------------------------------------
+// Cell widget of the table on QCanvas
+// ----------------------------------------------------------
+SUPERVGUI_CanvasCellNodePrs::SUPERVGUI_CanvasCellNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasCellNode* theNode):
+  myTitleWidth(CELL_WIDTH_PART),
+  myLabelWidth(CELL_WIDTH_PART),
+  myStatusWidth(CELL_WIDTH_PART), 
+  SUPERVGUI_CanvasNodePrs(theCanvas, theNode, true)
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::SUPERVGUI_CanvasCellNodePrs");
+
+  //setZ(0);
+  myPortVisible = false;
+
+  QCanvasItemList anIL2 = canvas()->allItems();
+  cout<<" ===> 1 conatructor CellPrs : CanvasArray has "<<anIL2.count()<<" children!"<<endl;
+}
+
+void SUPERVGUI_CanvasCellNodePrs::moveBy(double dx, double dy) {
+  Trace("SUPERVGUI_CanvasCellNodePrs::moveBy");
+  int aX = (int) (x()+dx);
+  int aY = (int) (y()+dy);
+
+  int w = aX + width() + GRAPH_MARGIN;
+  int h = aY + height() + GRAPH_MARGIN;
+  if (canvas()->width() > w) w = canvas()->width();
+  if (canvas()->height() > h) h = canvas()->height();
+  if (canvas()->width() < w || canvas()->height() < h)
+    canvas()->resize(w, h);
+  QCanvasPolygonalItem::moveBy(dx, dy);
+}
+
+void SUPERVGUI_CanvasCellNodePrs::drawShape(QPainter& thePainter) {
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawShape  begin");
+  drawTitle(thePainter);
+  drawLabel(thePainter);
+  drawStatus(thePainter);
+  drawFrame(thePainter);
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawShape  end");
+}
+
+void drawCellText(QPainter& thePainter, const QString& theText, 
+                 const QRect& theRect, int theHAlign = Qt::AlignAuto)
+{
+  int flags = theHAlign | Qt::AlignVCenter;
+  QRect r(theRect.x() + TEXT_MARGIN, theRect.y(), 
+         theRect.width() - 2*TEXT_MARGIN, theRect.height());
+
+  QWMatrix aMat = thePainter.worldMatrix();
+  if (aMat.m11() != 1.0) { 
+    // for scaled picture only
+    QRect r1 = aMat.mapRect(r);
+    QFont saved = thePainter.font();
+    QFont f(saved);
+    if (f.pointSize() == -1) {
+      f.setPixelSize(f.pixelSize()*aMat.m11());
+    }
+    else {
+      f.setPointSize(f.pointSize()*aMat.m11());
+    }
+    thePainter.save();
+    QWMatrix m;
+    thePainter.setWorldMatrix(m);
+    thePainter.setFont(f);
+    thePainter.drawText(r1, flags, theText);
+    thePainter.setFont(saved);
+    thePainter.restore();
+  }
+  else {
+    thePainter.drawText(r, flags, theText);
+  }
+}
+
+void SUPERVGUI_CanvasCellNodePrs::drawTitle(QPainter& thePainter) {
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawTitle  begin");
+  QBrush saved = thePainter.brush();
+  if (getNode()->getEngine()->IsLoop() || getNode()->getEngine()->IsEndLoop()
+      ||
+      getNode()->getEngine()->IsSwitch() || getNode()->getEngine()->IsEndSwitch())
+    thePainter.setBrush(Qt::red.light());
+  else if (getNode()->getEngine()->IsGOTO())
+    thePainter.setBrush(Qt::green.light());
+  else {
+    QBrush br(MAIN_TITLE);
+    thePainter.setBrush(br);
+  }
+  drawTitleShape(thePainter);
+  thePainter.setBrush(saved);
+
+  drawCellText(thePainter, getNode()->getEngine()->Name(), getTitleRect(), Qt::AlignLeft);
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawTitle  end");
+}
+
+void SUPERVGUI_CanvasCellNodePrs::drawLabel(QPainter& thePainter) 
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawLabel  begin");
+  QRect r = getLabelRect();
+
+  QPen saved = thePainter.pen();
+  thePainter.setPen(NoPen);
+  thePainter.drawRect(r);
+  thePainter.setPen(saved);
+
+  drawCellText(thePainter, getNode()->getLabelText(), r, Qt::AlignLeft);
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawLabel  end");
+}
+
+void SUPERVGUI_CanvasCellNodePrs::drawStatus(QPainter& thePainter) 
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawStatus  begin");
+  QRect r = getStatusRect();
+
+  QBrush savedB = thePainter.brush();
+  thePainter.setBrush(getStatusColor());
+  drawStatusShape(thePainter);
+  thePainter.setBrush(savedB);
+
+  drawCellText(thePainter, getStatus(), r, Qt::AlignHCenter);
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawStatus  end");
+}
+
+QRect SUPERVGUI_CanvasCellNodePrs::getTitleRect() const
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::getTitleRect()!!!");
+  cout<<" xT = "<<(int)x()
+      <<" yT = "<<(int)y()
+      <<" wT = "<<getTitleWidth()
+      <<" hT = "<<getTitleHeight()<<endl;
+  return QRect((int)x(), (int)y(), getTitleWidth(), getTitleHeight());
+}
+
+QRect SUPERVGUI_CanvasCellNodePrs::getLabelRect() const
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::getLabelRect()!!!");
+  cout<<" xL = "<<((int)x())+getTitleWidth()
+      <<" yL = "<<(int)y()
+      <<" wL = "<<getLabelWidth()
+      <<" hL = "<<getLabelHeight()<<endl;
+  return QRect(((int)x())+getTitleWidth(), (int)y(), getLabelWidth(), getLabelHeight());
+}
+
+QRect SUPERVGUI_CanvasCellNodePrs::getStatusRect() const
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::getStatusRect()!!!");
+  cout<<" xS = "<<((int)x())+getTitleWidth()+getLabelWidth()
+      <<" yS = "<<(int)y()
+      <<" wS = "<<getStatusWidth()
+      <<" hS = "<<getStatusHeight()<<endl;
+  return QRect(((int)x())+getTitleWidth()+getLabelWidth(), (int)y(),
+              getStatusWidth(), getStatusHeight());
+}
+
+int SUPERVGUI_CanvasCellNodePrs::getTitleWidth() const {
+  return myTitleWidth;
+}
+
+int SUPERVGUI_CanvasCellNodePrs::getLabelWidth() const {
+  return myLabelWidth;
+}
+
+int SUPERVGUI_CanvasCellNodePrs::getStatusWidth() const {
+  return myStatusWidth;
+}
+
+int SUPERVGUI_CanvasCellNodePrs::width() const
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::width()  begin");
+  return myTitleWidth + myLabelWidth + myStatusWidth;
+}
+
+int SUPERVGUI_CanvasCellNodePrs::height() const
+{
+  MESSAGE("SUPERVGUI_CanvasCellNodePrs::height()  begin");
+  return getTitleHeight();
+}
+
+void SUPERVGUI_CanvasCellNodePrs::setState(SUPERV::GraphState theState)
+{
+  switch(theState) {
+  case SUPERV_Waiting:
+    setStatus("Waiting");
+    setStatusColor(QColor(35, 192, 255));
+    break;
+
+  case SUPERV_Running:
+  case SUPERV::ReadyState:
+    setStatus("Running");
+    setStatusColor(QColor(32,210,32));
+    break;
+
+  case SUPERV_Suspend:
+  case SUPERV::SuspendReadyState:
+    setStatus("Suspended");
+    setStatusColor(QColor(255,180, 0));
+    break;
+
+  case SUPERV_Done:
+    setStatus("Finished");
+    setStatusColor(QColor(255, 158, 255));
+    break;
+
+  case SUPERV_Error: 
+    setStatus("Aborted");
+    setStatusColor(Qt::red);
+    break;
+
+  case SUPERV_Kill:
+    setStatus("Killed");
+    setStatusColor(Qt::red);
+    break;
+
+  default:
+    setStatus("No Status");
+    setStatusColor(MAIN_BACK);
+    break;
+  }
+
+  cout<<"=================>>> setState from CELL!"<<endl;
+  canvas()->setChanged(getStatusRect());
+  cout<<"=================>>> before canvas()->update()!"<<endl;
+  canvas()->update();
+  cout<<"=================>>> after canvas()->update()!"<<endl;
+}
diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h
new file mode 100644 (file)
index 0000000..f835007
--- /dev/null
@@ -0,0 +1,52 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  Copyright (C) 2003  OPEN CASCADE
+//
+//  File   : SUPERVGUI_CanvasCellNodePrs.h
+//  Author : 
+//  Module : SUPERV
+
+#ifndef SUPERVGUI_CanvasCellNodePrs_H
+#define SUPERVGUI_CanvasCellNodePrs_H
+
+using namespace std;
+#include "SUPERVGUI_Def.h"
+#include "SUPERVGUI_CanvasNodePrs.h"
+#include "SUPERVGUI_CanvasControlNode.h"
+
+class SUPERVGUI_CanvasCellNodePrs: public SUPERVGUI_CanvasNodePrs {
+
+  public:
+    SUPERVGUI_CanvasCellNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasCellNode* theNode);
+    virtual ~SUPERVGUI_CanvasCellNodePrs() {}
+
+    virtual void moveBy(double dx, double dy);
+    virtual QRect getTitleRect() const;
+    virtual QRect getLabelRect() const;
+    virtual QRect getStatusRect() const;
+
+    int getTitleWidth() const;
+    int getLabelWidth() const;
+    int getStatusWidth() const;
+
+    virtual int width() const;
+    virtual int height() const;
+
+    virtual void setState(SUPERV::GraphState theState);
+
+  protected:
+    virtual void drawShape(QPainter& thePainter);
+
+    virtual void drawTitle(QPainter& thePainter);
+    virtual void drawLabel(QPainter& thePainter);
+    virtual void drawStatus(QPainter& thePainter);
+
+  private:
+    int myTitleWidth;
+    int myLabelWidth;
+    int myStatusWidth;
+    
+};
+
+#endif
index 374f14426cdbc6fa636f705182284888a57014cc..a47a1402a980eb135ff7604c31bb2012c50fba76 100644 (file)
@@ -9,6 +9,7 @@
 using namespace std;
 #include "SUPERVGUI_CanvasControlNode.h"
 #include "SUPERVGUI_CanvasControlNodePrs.h"
+#include "SUPERVGUI_CanvasCellNodePrs.h"
 #include "SUPERVGUI_Main.h"
 #include "SUPERVGUI.h"
 #include "SUPERVGUI_Canvas.h"
@@ -260,3 +261,109 @@ void SUPERVGUI_CanvasMacroNode::exportDataflow()
     }
   }
 }
+
+//=====================================================================
+// Cell node: node for table view
+//=====================================================================
+SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode(QObject* theParent, 
+                                                  SUPERVGUI_Main* theMain, 
+                                                  SUPERV_CNode theNode):
+  SUPERVGUI_CanvasNode(theParent, theMain, theNode, true)
+{
+  Trace("SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode");
+  
+  myIsControl = false;
+  myIsStart = false;
+
+  //check for control nodes
+  if (getEngine()->IsLoop() || getEngine()->IsSwitch()) {
+    myIsControl = true;  
+    myIsStart = true;
+  }
+  if (getEngine()->IsEndLoop() || getEngine()->IsEndSwitch())
+    myIsControl = true;
+}
+
+QPopupMenu* SUPERVGUI_CanvasCellNode::getPopupMenu(QWidget* theParent)
+{
+  QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent);
+  popup->setItemEnabled(myDeleteItem, false);
+  return popup;
+}
+
+void SUPERVGUI_CanvasCellNode::setPairCell(SUPERVGUI_CanvasCellNode* thePairCell) {
+  if (myIsControl) { //only for ControlNode
+    myPairCell = thePairCell;
+  }
+  else 
+    myPairCell = 0;
+}
+
+SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasCellNode::getPairCell() {
+  return myPairCell;
+}
+
+void SUPERVGUI_CanvasCellNode::sync() {
+  MESSAGE("===> SUPERVGUI_CanvasCellNode::sync() " << getEngine()->Name() << ", state " << getEngine()->State());
+
+  const bool isExecuting = getMain()->getDataflow()->IsExecuting();
+  //if getEngine() is a MacroNode then set it state to state of its subgraph
+  if ( getEngine()->IsMacro() && isExecuting ) {
+    // get SubGraph from MacroNode
+    SUPERV_Graph aMacro = SUPERV::Graph::_narrow(getEngine());
+    if (!SUPERV_isNull(aMacro)) {
+      SUPERV_Graph aGraph;
+      if (aMacro->IsStreamMacro())
+       aGraph = aMacro->StreamObjRef();
+      else
+       aGraph = aMacro->FlowObjRef();
+      if (!SUPERV_isNull(aGraph)) {
+       if (aGraph->State() != SUPERV::UndefinedState && aGraph->State() != SUPERV::NoState)
+         getPrs()->setState(aGraph->State());
+       else 
+         getPrs()->setState(getEngine()->State());
+      }
+    }
+  }
+  else {
+    getPrs()->setState(getEngine()->State());
+  }
+}
+
+/*bool SUPERVGUI_CanvasCellNode::setNodeName(QString aName)
+{
+  bool result = SUPERVGUI_CanvasNode::setNodeName(aName);
+  if (result && myPairCell) {
+    result = myPairCell->getEngine()->SetName((QString(tr("ENDNODE_PREFIX"))+aName).latin1());
+    if (result) {
+      setName(myPairCell->getEngine()->Name());
+      myPairCell->getPrs()->updateInfo();
+    } 
+    else {
+      QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_RENAMENODE" ) );
+    }
+    }
+  return result;
+}*/
+
+SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasCellNode::createPrs() const
+{
+  MESSAGE(" -> SUPERVGUI_CanvasCellNode::createPrs()");
+  SUPERVGUI_CanvasNodePrs* aPrs = 
+    new SUPERVGUI_CanvasCellNodePrs(getMain()->getCanvasArray(), 
+                                   (SUPERVGUI_CanvasCellNode*)this);
+  MESSAGE(" -> SUPERVGUI_CanvasCellNode::createPrs() 11");
+  return aPrs;
+}
+
+SUPERVGUI_CanvasCellEndNode::SUPERVGUI_CanvasCellEndNode( QObject* theParent, 
+                                                         SUPERVGUI_Main* theMain, 
+                                                         SUPERV_CNode theNode, 
+                                                         SUPERVGUI_CanvasCellNode* theStart):
+  SUPERVGUI_CanvasCellNode(theParent, theMain, theNode)
+{
+  //set start cell for end cell as pair 
+  myPairCell = theStart; 
+  //set end cell for start cell as pair
+  myPairCell->setPairCell(dynamic_cast<SUPERVGUI_CanvasCellNode*>(this));
+}
index 137836c00961a97adb469d4b0b5923d414da5caf..b7ebfac4cd61b333ee7142c1e0bdcf4cd6d36ff4 100644 (file)
@@ -117,4 +117,43 @@ class SUPERVGUI_CanvasGotoNode : public SUPERVGUI_CanvasNode {
     virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
 };
 
+class SUPERVGUI_CanvasCellNode : public SUPERVGUI_CanvasNode {
+  Q_OBJECT
+
+  public:
+    SUPERVGUI_CanvasCellNode(QObject* theParent, 
+                            SUPERVGUI_Main* theMain, 
+                            SUPERV_CNode theNode);
+    virtual ~SUPERVGUI_CanvasCellNode() {}
+
+    virtual QPopupMenu* getPopupMenu(QWidget* theParent);
+
+    void setPairCell(SUPERVGUI_CanvasCellNode* thePairCell);
+    SUPERVGUI_CanvasCellNode* getPairCell();
+
+     virtual void sync();
+     //virtual bool setNodeName(QString aName);
+
+  protected:
+    virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
+
+ protected:
+    SUPERVGUI_CanvasCellNode*  myPairCell;  //for ControlNodes
+
+ private:
+    bool        myIsControl;
+    bool        myIsStart;
+
+};
+
+class SUPERVGUI_CanvasCellEndNode: public SUPERVGUI_CanvasCellNode {
+  public:
+    SUPERVGUI_CanvasCellEndNode(QObject* theParent, 
+                               SUPERVGUI_Main* theMain, 
+                               SUPERV_CNode theNode, 
+                               SUPERVGUI_CanvasCellNode* theStart);
+    virtual ~SUPERVGUI_CanvasCellEndNode() {}
+};
+
 #endif
index d3d85eab11cd1230a41e2685d54da13a51b46f81..53fdbe38ad873b49c5342eec59cf419200cf0d16 100644 (file)
@@ -23,7 +23,7 @@ using namespace std;
 #include <qtooltip.h>
 */
 
-SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
+SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, bool theIsCell):
     QObject(theParent),
     myMain(theMain),
     myNode(theNode),
@@ -75,6 +75,9 @@ SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* t
   }
 
   isIgnore = false;
+
+  QCanvasItemList anIL2 = ((QCanvas*)parent())->allItems();
+  cout<<" ===> 1 conatructor CanvasNode : CanvasArray has "<<anIL2.count()<<" children!"<<endl;
 }
 
 SUPERVGUI_CanvasNode::~SUPERVGUI_CanvasNode()
@@ -150,7 +153,7 @@ QPopupMenu* SUPERVGUI_CanvasNode::getPopupMenu(QWidget* theParent)
     if (myMain->isEditable() && getNodeType() != SUPERV::EndLoopNode
                              && getNodeType() != SUPERV::EndSwitchNode) {
       popup->insertItem(tr("MSG_RENAME"), this, SLOT(rename()));
-      popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove()));
+      myDeleteItem = popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove()));
       popup->insertSeparator();
     }
     popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse()));
index 766ccc72d5759964f6e253b6dc094d9a74c594c7..14a8c3d7b2ce0574f46cbea3c71a127677b8bbbf 100644 (file)
@@ -23,7 +23,7 @@ class SUPERVGUI_CanvasNode : public QObject {
   Q_OBJECT
 
   public:
-    SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode);
+    SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, bool theIsCell=false);
     virtual ~SUPERVGUI_CanvasNode();
 
     // done to ignore port update when node is removed
@@ -104,6 +104,7 @@ class SUPERVGUI_CanvasNode : public QObject {
     SUPERVGUI_BrowseNodeDlg* myBrowseDlg;
 
     bool isIgnore;
+    int  myDeleteItem;
 
   protected slots:
     virtual void onDestroyed(QObject*);
index f7e87930119a9709bdb234ac25f2a1809e9060e6..d6d3abf07c4d7b44fe19e4624b1a406dc41cb3c5 100644 (file)
@@ -11,6 +11,7 @@ using namespace std;
 #include "SUPERVGUI_CanvasNode.h"
 #include "SUPERVGUI_CanvasPort.h"
 #include "SUPERVGUI_Canvas.h"
+#include "SUPERVGUI_CanvasCellNodePrs.h"
 
 //#define CHECKTIME
 
@@ -28,7 +29,8 @@ using namespace std;
 // Node presentation
 //=====================================================================
 SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, 
-                                                SUPERVGUI_CanvasNode* theNode):
+                                                SUPERVGUI_CanvasNode* theNode,
+                                                bool theCellPrs):
   QCanvasPolygonalItem(theCanvas),
   myNode(theNode)
 {
@@ -46,24 +48,41 @@ SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas,
 
   myLabelVisible = true;
   myPortVisible = true;
+  myCellPrs = theCellPrs;
 
   myColor = MAIN_BACK;
 
-  // create in/out connection points prs
-  myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true);
-  myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false);
+  if (!myCellPrs) {
+    // create in/out connection points prs
+    myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true);
+    myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false);
+  }
 
-  setZ(0);
-  setState(myNode->getEngine()->State());
-  updatePorts();
+  cout<<" ===> 0.2 conatructor NodePrs : CanvasArray has ......"<<endl;
+  //setZ(0);
+  
+  cout<<" ===> 0.3 conatructor NodePrs : CanvasArray has ......"<<endl;
+  if (!myCellPrs) {
+    cout<<" ===> 0.35 conatructor NodePrs : CanvasArray has ......"<<endl;
+    setZ(0);
+    setState(myNode->getEngine()->State());
+    updatePorts();
+  }
+  
+  cout<<" ===> 0.4 conatructor NodePrs : CanvasArray has ......"<<endl;
+
+  QCanvasItemList anIL2 = canvas()->allItems();
+  cout<<" ===> 1 conatructor NodePrs : CanvasArray has "<<anIL2.count()<<" children!"<<endl;
 }
 
 
 SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs() 
 {
-  Trace("SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs");
-  if (myPointIn) delete myPointIn;
-  if (myPointOut) delete myPointOut;
+  MESSAGE("SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs");
+  if (!myCellPrs) {
+    if (myPointIn) delete myPointIn;
+    if (myPointOut) delete myPointOut;
+  }
   hide();
 }
 
@@ -199,8 +218,10 @@ void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy)
     }
   }
 
-  myPointIn->moveBy(dx, dy);
-  myPointOut->moveBy(dx, dy);
+  if (!myCellPrs) {
+    myPointIn->moveBy(dx, dy);
+    myPointOut->moveBy(dx, dy);
+  }
 }
 
 void SUPERVGUI_CanvasNodePrs::setZ(double z)
@@ -257,7 +278,7 @@ void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b)
 
   myLabelVisible = b;
   updatePorts();
-  if (!isPortVisible()) updatePoints();
+  if (!isPortVisible() && !myCellPrs) updatePoints();
 
   if (aDisp) {
     show();
@@ -272,16 +293,20 @@ void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b)
 
   myPortVisible = b;
   if (b) {
-    myPointIn->hide();
-    myPointOut->hide();
+    if (!myCellPrs) {
+      myPointIn->hide();
+      myPointOut->hide();
+    }
 
     updateGates();
   }
   else {
-    updatePoints();
-
-    myPointIn->show();
-    myPointOut->show();
+    if (!myCellPrs) {
+      updatePoints();
+      
+      myPointIn->show();
+      myPointOut->show();
+    }
   }
 
   const QObjectList* list = myNode->children();
index de23786e818c106ef55dad93f9319e24d7383ff5..d8aa906e78e927607bda0b63cfb822d94d4401c0 100644 (file)
@@ -50,12 +50,18 @@ class SUPERVGUI_CanvasNode;
 class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem {
 
   public:
-    SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode);
+    SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode, bool theCellPrs=false);
     virtual ~SUPERVGUI_CanvasNodePrs();
 
     SUPERVGUI_CanvasNode* getNode() const { return myNode; }
     QObject* getObject(const QPoint& thePos) const;
 
+    QString getStatus() const { return myStatus; }
+    QColor getStatusColor() const { return myStatusColor; }
+
+    void setStatus(QString theStatus) { myStatus = theStatus; }
+    void setStatusColor(QColor theStatusColor) { myStatusColor = theStatusColor; }
+    
     virtual int width() const;
     virtual int height() const;
 
@@ -104,7 +110,7 @@ class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem {
 
   protected:
     void draw(QPainter& thePainter);
-    void drawShape(QPainter& thePainter);
+    virtual void drawShape(QPainter& thePainter);
 
     virtual void drawTitle(QPainter& thePainter);
     virtual void drawLabel(QPainter& thePainter);
@@ -116,6 +122,8 @@ class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem {
     virtual void drawTitleShape(QPainter& thePainter);
     virtual void drawStatusShape(QPainter& thePainter);
 
+    bool myPortVisible;
+
   private:
     SUPERVGUI_CanvasNode* myNode;
 
@@ -129,7 +137,7 @@ class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem {
     int myGateHeight;
 
     bool myLabelVisible;
-    bool myPortVisible;
+    bool myCellPrs;
     bool myMoving;
 
     QString myStatus;
index dd0e9814c77cc45d3e45b26980a556ee707a1526..ff8845230ce3a506af8931b5dfc69b7edf7b4bcc 100644 (file)
@@ -101,6 +101,7 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU
   aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas()));
   aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow()));
   aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showTable()));
+  aViewPopup->insertItem(tr("POP_TABLEVIEWCANVAS"), myMain, SLOT(showCanvasTable()));
   //  aViewPopup->insertItem("Previous Full View", myMain, SLOT(showFullGraph()));
   //  aViewPopup->insertItem(tr("POP_CANVASVIEW"), myMain, SLOT(showCanvas()));
 
index dac075dbda1855eccc3f61b9b9220c6e2503144a..99040dfadb6bac51eddaab51bae405a9dcc6207f 100644 (file)
@@ -52,6 +52,8 @@
 
 #define CELL_SPACE    5
 
+#define MARGIN 2
+
 // Noeuds
 // ------
 /*
@@ -218,7 +220,7 @@ NODE_Editing   "",          NODE_RED, NODE_GREEN, NODE_BLUE, true,  false,  true
 #define SUPERV_isNull(oc) (CORBA::is_nil(oc))
 
 
-enum GraphViewType { GRAPH, CONTROLFLOW, TABLE, CANVAS };
+enum GraphViewType { GRAPH, CONTROLFLOW, TABLE, CANVAS, CANVASTABLE };
 //enum NodeType { COMPUTE, SWITCH, LOOP, GOTO, LABEL };
 
 
index aa397a8c17f7bf91e69e0dd94b8967fc07afad61..2a1f8320e278b8bb3b0f68b1eedab68c10fcbe14 100644 (file)
@@ -201,6 +201,9 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
   graph->hide();
   array = new SUPERVGUI_Array(this);
 
+  myArray = new SUPERVGUI_CanvasArray(this);
+  myArrayView = new SUPERVGUI_ArrayView(myArray, this);
+
   myCanvas = new SUPERVGUI_Canvas(this);
   myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
   
@@ -213,6 +216,7 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
   layout->addWidget(graph);
   layout->addWidget(array);
   layout->addWidget(myCanvasView);
+  layout->addWidget(myArrayView);
 
   if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
     myCanvas->merge();
@@ -260,6 +264,7 @@ SUPERVGUI_Main::~SUPERVGUI_Main() {
   notification->_remove_ref();  // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
 
   delete myCanvas;
+  delete myArray;
 }
 
 void SUPERVGUI_Main::filterNotification() {
@@ -315,6 +320,10 @@ void SUPERVGUI_Main::execute(char *  theNodeName, SUPERV::GraphState theNodeStat
     SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
     if (aNode) aNode->sync();
   }
+  else if (myCurrentView == CANVASTABLE) {
+    SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
+    if (aNode) aNode->sync();
+  }
   else {
     SUPERVGUI_Node* aNodePrs; 
     SUPERVGUI_GraphNode* aGraphNodePrs;
@@ -346,6 +355,10 @@ void SUPERVGUI_Main::sync() {
     study->updateObjBrowser();
     if (myCurrentView == TABLE) {
       array->sync();
+    } else if (myCurrentView == CANVASTABLE) {
+      myArray->sync();
+      cout<<" --> after myArray->sync() ..."<<endl;
+      myArray->update();
     } else if (myCurrentView == GRAPH) {
       graph->sync();
     } else {
@@ -361,6 +374,10 @@ void SUPERVGUI_Main::showTable() {
   if (array->create()) {
     if (myCurrentView == GRAPH)
       graph->hide();
+    else if (myCurrentView == CANVASTABLE) {
+      myArrayView->hide();
+      myArray->destroy();
+    }
     else
       myCanvasView->hide();
     myCurrentView = TABLE;
@@ -368,12 +385,33 @@ void SUPERVGUI_Main::showTable() {
   sync();
 }
 
+void SUPERVGUI_Main::showCanvasTable() {
+  if (myCurrentView == CANVASTABLE) return;
+
+  if (myArray->create()) {
+    if (myCurrentView == GRAPH)
+      graph->hide();
+    else if (myCurrentView == TABLE)
+      array->destroy();
+    else
+      myCanvasView->hide();
+
+    myArrayView->show();
+    myCurrentView = CANVASTABLE;
+  }
+  sync();
+}
 
 void SUPERVGUI_Main::showFullGraph() {
   if (myCurrentView == TABLE) {
     array->destroy();
     graph->show();    
   }
+  else if (myCurrentView == CANVASTABLE) {
+    myArrayView->hide();
+    myArray->destroy();
+    graph->show();    
+  }
   else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
     myCanvasView->hide();
     graph->show();
@@ -394,6 +432,11 @@ void SUPERVGUI_Main::showContolFlow() {
     graph->hide();
     merge = true;
   }
+  else if (myCurrentView == CANVASTABLE) {
+    myArrayView->hide();
+    myArray->destroy();
+    merge = true;
+  }
   myCurrentView = CONTROLFLOW;
   myCanvas->setControlView();
   if (merge) {
@@ -410,6 +453,11 @@ void SUPERVGUI_Main::showCanvas() {
     array->destroy();
     merge = true;
   }
+  else if (myCurrentView == CANVASTABLE) {
+    myArrayView->hide();
+    myArray->destroy();
+    merge = true;
+  }
   else if (myCurrentView == GRAPH) {
     graph->hide();
     merge = true;
@@ -437,7 +485,11 @@ void SUPERVGUI_Main::insertFile() {
            array->destroy();
            array->create();
          }
-         else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
+         else if (myCurrentView == CANVASTABLE) {
+           myArray->destroy();
+           myArray->create();
+         }
+         else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
            myCanvas->merge();
          }
          sync();
@@ -749,6 +801,10 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
     array->destroy();
     array->create();
     break;
+  case CANVASTABLE:
+    myArray->destroy();
+    myArray->create();
+    break;  
   case CANVAS:
   case CONTROLFLOW: 
     {
@@ -779,6 +835,10 @@ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
     array->destroy();
     array->create();
     break;
+  case CANVASTABLE:
+    myArray->destroy();
+    myArray->create();
+    break;
   case CANVAS:
   case CONTROLFLOW: 
     {
@@ -821,6 +881,10 @@ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theE
     array->destroy();
     array->create();
     break;
+  case CANVASTABLE:
+    myArray->destroy();
+    myArray->create();
+    break;
   case CANVAS:
   case CONTROLFLOW: 
     {
@@ -859,6 +923,10 @@ void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
     array->destroy();
     array->create();
     break;
+  case CANVASTABLE:
+    myArray->destroy();
+    myArray->create();
+    break;
   case CANVAS:
   case CONTROLFLOW: 
     {
@@ -883,6 +951,16 @@ SUPERVGUI_Array* SUPERVGUI_Main::getArray() {
     return(array);
 }
 
+SUPERVGUI_CanvasArray*  SUPERVGUI_Main::getCanvasArray() {
+    Trace("SUPERVGUI_Main::getCanvasArray")
+    return(myArray);
+}
+
+SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
+    Trace("SUPERVGUI_Main::getArrayView")
+      return(myArrayView);
+}
+
 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
     Trace("SUPERVGUI_Main::getCanvas")
     return(myCanvas);
@@ -910,7 +988,8 @@ QAD_Study* SUPERVGUI_Main::getStudy() {
 
 bool SUPERVGUI_Main::isArrayShown() {
     Trace("SUPERVGUI_Main::isArrayShown")
-    return(myCurrentView == TABLE);
+      //return(myCurrentView == TABLE);
+    return(myCurrentView == CANVASTABLE);  
 }
 
 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
@@ -1197,6 +1276,8 @@ void SUPERVGUI_Main::ActivatePanning()
     array->ActivatePanning();
   } else if (myCanvasView->isVisible()) {
     myCanvasView->ActivatePanning();
+  } else if (myArrayView->isVisible()) {
+    myArrayView->ActivatePanning();
   }
 }
 
@@ -1209,6 +1290,8 @@ void SUPERVGUI_Main::ResetView()
     array->ResetView();
   } else if (myCanvasView->isVisible()) {
     myCanvasView->ResetView();
+  } else if (myArrayView->isVisible()) {
+    myArrayView->ResetView();
   }
 }
 
@@ -1307,6 +1390,8 @@ void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
   graph->setPaletteBackgroundColor(color);
   myCanvas->setBackgroundColor(color);
   myCanvasView->setPaletteBackgroundColor(color.light());
+  myArray->setBackgroundColor(color);
+  myArrayView->setPaletteBackgroundColor(color.light());
   
   SUPERVGraph_View::setPaletteBackgroundColor(color); 
 }
@@ -1347,6 +1432,7 @@ void SUPERVGUI_Main::startTimer() {
 void SUPERVGUI_Main::executionFinished() {
   getStudy()->updateObjBrowser();
   myCanvas->update();
+  myArray->update();
 }
 
 void SUPERVGUI_Main::checkExecution() {
index eae98b578684d77ae862b00337cd7c249dddf07e..1a3270c3ca15ba2937631351dc4dfbfc53e49de9 100644 (file)
@@ -36,6 +36,7 @@
 #include "SUPERVGUI_Port.h"
 #include "SUPERVGUI_Canvas.h"
 #include "SUPERVGUI_CanvasView.h"
+#include "SUPERVGUI_ArrayView.h"
 
 #include <qobject.h>
 #include <qapplication.h>
@@ -68,6 +69,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
 
     SUPERVGUI_Graph* getGraph();
     SUPERVGUI_Array* getArray();
+    SUPERVGUI_CanvasArray*  getCanvasArray();
+    SUPERVGUI_ArrayView* getArrayView();
     SUPERVGUI_Canvas* getCanvas();
     SUPERVGUI_CanvasView* getCanvasView();
     SUPERV_Graph getDataflow();
@@ -139,6 +142,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void changeInformation();
     void copy();
     void showTable();
+    void showCanvasTable();
     void showFullGraph();
     void showContolFlow();
     void showCanvas();
@@ -170,6 +174,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     
     GraphViewType   myCurrentView;
     SUPERVGUI_Array*   array;
+    SUPERVGUI_CanvasArray*  myArray;
+    SUPERVGUI_ArrayView*    myArrayView;
     SUPERVGUI_Canvas*       myCanvas;
     SUPERVGUI_CanvasView*   myCanvasView;
 
index 026c1ae9de37b37ca62386cb6f71af4769610ca0..6b148e5f833214ed401cf23036fc3a72fa63be8d 100644 (file)
@@ -683,7 +683,8 @@ void SUPERVGUI_Service::choose() {
 void SUPERVGUI_Service::showEvent(QShowEvent* theEvent) {
   SUPERVGUI_Main* aMain = Supervision.getMain();
   if (aMain && (!aMain->isArrayShown())) {
-    aMain->getGraph()->viewportToContents(0, 0, myX, myY);
+    aMain->getArrayView()->viewportToContents(0, 0, myX, myY);
+    //aMain->getGraph()->viewportToContents(0, 0, myX, myY);
   }
   QDialog::showEvent(theEvent);
 }
index cddb6b2949927d1fd597c83048e1f95923e1174b..cd82c037e677a2f38b1dcd681c32350d16e5f816 100644 (file)
@@ -534,6 +534,9 @@ msgstr "Control"
 msgid "POP_TABLEVIEW"
 msgstr "Table"
 
+msgid "POP_TABLEVIEWCANVAS"
+msgstr "Canvas Table"
+
 msgid "POP_CANVASVIEW"
 msgstr "Canvas"