2 // File : SUPERVGUI_Array.cxx
3 // Created : 08 / 02 / 2002
4 // Author : Francis KLOSS
9 #include "SUPERVGUI_Def.h"
10 #include "SUPERVGUI_Array.h"
11 #include "SUPERVGUI_Main.h"
12 #include "SUPERVGUI_ComputeNode.h"
13 #include "SUPERVGUI_BrowseNodeDlg.h"
17 #define ADDNODES(NodesName) \
18 ncols = nodes->NodesName.length(); \
19 for (int co=0; co<ncols; co++) { \
20 SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[co]); \
21 x = 50 + co * (CELL_WIDTH + CELL_SPACE);\
22 SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \
23 ResizeGraph(aNode, x, y); \
24 addChild(aNode, x, y); \
29 #define ADDCONTROLNODES(NodesName) \
30 ncols = nodes->NodesName.length(); \
32 for (int co=0; co<ncols; co++) { \
33 SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[co]); \
34 SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \
35 ResizeGraph(aNode, x, y); \
36 addChild(aNode, x, y); \
37 x += (CELL_WIDTH + CELL_SPACE); \
38 SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \
39 SUPERVGUI_Node* aNodeEnd = new SUPERVGUI_Cell(viewport(), main, aCNodeEnd); \
40 ResizeGraph(aNodeEnd, x, y); \
41 addChild(aNodeEnd, x, y); \
42 x += (CELL_WIDTH + CELL_SPACE); \
48 SUPERVGUI_Array::SUPERVGUI_Array(SUPERVGUI_Main* m):
51 resizeContents(GRAPH_WIDTH, GRAPH_HEIGHT);
56 SUPERVGUI_Array::~SUPERVGUI_Array() {
57 Trace("SUPERVGUI_Array::~SUPERVGUI_Array")
60 bool SUPERVGUI_Array::create() {
61 Trace("SUPERVGUI_Array::create");
62 SUPERV_Nodes nodes = main->getDataflow()->Nodes();
64 aCount += nodes->CNodes.length();
65 aCount += nodes->FNodes.length();
66 aCount += nodes->INodes.length();
67 aCount += nodes->GNodes.length();
68 aCount += nodes->LNodes.length();
69 aCount += nodes->SNodes.length();
79 int nligs = main->getDataflow()->LevelMax();
80 int ncols = main->getDataflow()->ThreadsMax();
82 // there is no any calculations
83 if (ncols == 0) return false;
85 for (int co=0; co<ncols; co++) {
86 aLabel = QString("Thread %1").arg(co);
87 QLabel* aTitle = new QLabel(aLabel, viewport());
88 aTitle->setAlignment(QLabel::AlignCenter | QLabel::AlignVCenter);
89 aTitle->setLineWidth(1);
90 aTitle->setPaletteBackgroundColor(MAIN_TITLE);
91 aTitle->setMinimumSize(CELL_WIDTH, CELL_HEIGHT);
92 aTitle->setFrameStyle(QFrame::Panel | QFrame::Plain);
93 addChild(aTitle, 50 + co * (CELL_WIDTH + CELL_SPACE), 20);
95 for (int li=0; li<=nligs; li++) {
96 nodes = main->getDataflow()->LevelNodes(li);
97 y = 60 + li * (CELL_HEIGHT + CELL_SPACE);
102 ADDCONTROLNODES(LNodes);
103 ADDCONTROLNODES(SNodes);
106 nodeY = y + CELL_HEIGHT*2;
112 void SUPERVGUI_Array::destroy() {
113 Trace("SUPERVGUI_Array::destroy")
116 SUPERVGUI_Cell* cell;
117 QObjectList* ihmList = queryList("SUPERVGUI_Cell");
118 QObjectListIt i(*ihmList);
120 while ((cell=(SUPERVGUI_Cell*)i.current()) != 0) {
129 void SUPERVGUI_Array::sync() {
130 Trace("SUPERVGUI_Array::sync")
131 if (SUPERV_isNull(main->getDataflow())) return;
133 SUPERVGUI_Cell* cell;
134 QObjectList* ihmList = queryList("SUPERVGUI_Cell");
135 QObjectListIt i(*ihmList);
136 while ((cell=(SUPERVGUI_Cell*)i.current()) != 0) {
143 SUPERVGUI_Node* SUPERVGUI_Array::addNode(SUPERV_CNode node) {
144 Trace("SUPERVGUI_Array::Array")
145 SUPERVGUI_Node* n = new SUPERVGUI_ComputeNode(viewport(), main, node);
146 ResizeGraph(n, nodeX, nodeY);
147 addChild(n, nodeX, nodeY);
154 void SUPERVGUI_Array::contentsMousePressEvent(QMouseEvent* e) {
155 Trace("SUPERVGUI_Array::contentsMousePressEvent")
156 if (e->button() == RightButton) {
157 myPopup->exec(e->globalPos());
165 // ------------------------------------
166 // Cell widget of the table
167 // ------------------------------------
170 SUPERVGUI_Cell::SUPERVGUI_Cell(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n):
171 SUPERVGUI_Node(parent, m, n),
174 Trace("SUPERVGUI_Cell::SUPERVGUI_Cell");
176 setFrameStyle(QFrame::Panel | QFrame::Raised);
178 QHBoxLayout* aBox = new QHBoxLayout(this);
181 component = new SUPERVGUI_Label(this, CELL_WIDTH_PART, LABEL_HEIGHT, myNode->Comment(), QLabel::AlignLeft);
182 connect(component, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*)));
184 myTitle = new SUPERVGUI_Label(this, CELL_WIDTH_PART, LABEL_HEIGHT, name(), QLabel::AlignLeft);
185 connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*)));
186 myTitle->setMinimumSize(CELL_WIDTH_PART, LABEL_HEIGHT);
187 myTitle->setMaximumSize(CELL_WIDTH_PART, LABEL_HEIGHT);
189 // aBox->addWidget(service);
190 aBox->addWidget(myTitle);
191 aBox->addWidget(component);
193 myStatus->reparent(this, pos());
194 aBox->addWidget(myStatus);
196 // QToolTip::add(service, myNode->Name());
197 QToolTip::add(myTitle, myTitle->text());
199 myPopup->setItemEnabled(myDeleteItem, false);
203 SUPERVGUI_Cell::~SUPERVGUI_Cell() {
204 Trace("SUPERVGUI_Cell::~SUPERVGUI_Cell");
205 QToolTip::remove(myTitle);
206 if (guiNode != NULL) {
211 void SUPERVGUI_Cell::sync() {
212 Trace("SUPERVGUI_Cell::sync");
213 if (myMain == NULL) return;
214 myTitle->setText(myNode->Name());
215 component->setText(myNode->Comment());
217 if (guiNode != NULL) {
220 SUPERVGUI_PortIn* pi;
221 QObjectList* ihmList = guiNode->queryList("SUPERVGUI_PortIn");
222 QObjectListIt i(*ihmList);
223 while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) {
229 SUPERVGUI_PortOut* po;
230 ihmList = guiNode->queryList("SUPERVGUI_PortOut");
232 while ((po=(SUPERVGUI_PortOut*)i.current()) != 0) {
238 SUPERVGUI_Node::sync();
242 void SUPERVGUI_Cell::updateStudy()
244 Trace("SUPERVGUI_Cell::updateStudy")
247 SUPERVGUI_PortOut* po;
248 QObjectList* ihmList = guiNode->queryList("SUPERVGUI_PortOut");
249 QObjectListIt i(*ihmList);
250 while ((po=(SUPERVGUI_PortOut*)i.current()) != 0)
260 void SUPERVGUI_Cell::rename() {
261 SUPERVGUI_Node::rename();
262 myTitle->setText(myNode->Name());
263 // QToolTip::remove(myTitle);
264 //QToolTip::add(myTitle, myTitle->text());