1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SUPERVGUI_ComputeNode.cxx
8 // Author : Vitaly SMETANNIKOV
12 #include "SUPERVGUI_ComputeNode.h"
13 #include "SUPERVGUI_Main.h"
14 #include <qapplication.h>
18 SUPERVGUI_ComputeNode::SUPERVGUI_ComputeNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
19 :SUPERVGUI_GraphNode(theParent, theMain, theNode)
22 setFrameStyle(QFrame::Panel | QFrame::Raised);
24 QGridLayout* aGridLayout = new QGridLayout(this, 0, 2, 3, 1);
26 myTitle->setPaletteBackgroundColor(QColor(63, 213, 255));
27 myTitle->reparent(this, pos());
28 aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 1);
30 QString aComment(theNode->Comment());
32 QString aCommentVis = aComment;
33 if (getNodeType() == SUPERV::FactoryNode)
34 aCommentVis = QString(myNode->Service()->ServiceName) + QString(tr("COMMENT_FROM"))
35 + QString(getFactoryNode()->GetComponentName());
37 //aCommentVis = tr("COMMENT_PYTHON");
38 aCommentVis = tr("COMMENT_CNODE");
40 if (aComment.isNull() || aComment.isEmpty()) {
41 theNode->SetComment(aCommentVis.latin1());
44 myServiceBox = new QVBox(this, "service");
45 myComment = new SUPERVGUI_Label(myServiceBox, LABEL_WIDTH, LABEL_HEIGHT, aCommentVis, QLabel::AlignLeft);
46 connect(myComment, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*)));
47 QToolTip::add(myTitle, myTitle->text());
48 QToolTip::add(myComment, myComment->text());
49 aGridLayout->addMultiCellWidget(myServiceBox, 1, 1, 0, 1);
51 myStatus->reparent(this, pos());
52 myTime->reparent(this, pos());
53 aGridLayout->addWidget(myStatus, 2, 0);
54 aGridLayout->addWidget(myTime, 2, 1);
56 myPortsBox->reparent(this, pos());
58 aGridLayout->addMultiCellWidget(myPortsBox, 3, 3, 0, 1);
61 myShowPopup = new QPopupMenu(this);
62 myServiceItem = myShowPopup->insertItem(tr("POP_SHOWTITLES"), this, SLOT(switchService()));
63 myPortsItem = myShowPopup->insertItem(tr("POP_SHOWPORTS"), this, SLOT(switchPorts()));
65 myPopup->insertSeparator();
66 myPopup->insertItem(tr("POP_SHOW"), myShowPopup);
67 myShowPopup->setItemChecked(myServiceItem, true);
68 myShowPopup->setItemChecked(myPortsItem, true);
74 SUPERVGUI_ComputeNode::~SUPERVGUI_ComputeNode() {
75 QToolTip::remove(myTitle);
76 QToolTip::remove(myComment);
80 void SUPERVGUI_ComputeNode::sync()
82 Trace("SUPERVGUI_Node::sync");
83 setName(myNode->Name());
84 myTitle->setText(name());
86 //myComment->setText(myNode->Comment());
88 bool editing = myMain->getDataflow()->IsEditing();
89 myPopup->setItemEnabled(myKillItem, !editing);
90 if (myMain->isEditable()) {
91 myPopup->setItemEnabled(myRenameItem, editing);
92 myPopup->setItemEnabled(myDeleteItem, editing);
94 SUPERVGUI_GraphNode::sync();
100 * Hides services info and ports
102 void SUPERVGUI_ComputeNode::hideAll() {
103 myServiceBox->hide();
104 myShowPopup->setItemChecked(myServiceItem, false);
106 myShowPopup->setItemChecked(myPortsItem, false);
113 * Shows services info and ports
115 void SUPERVGUI_ComputeNode::showAll() {
116 myServiceBox->show();
117 myShowPopup->setItemChecked(myServiceItem, true);
119 myShowPopup->setItemChecked(myPortsItem, true);
126 * Switches visibility of Service names in the node
128 void SUPERVGUI_ComputeNode::switchService() {
129 bool aIsVisible = myServiceBox->isVisible();
130 if (aIsVisible) myServiceBox->hide();
131 else myServiceBox->show();
133 myShowPopup->setItemChecked(myServiceItem, !aIsVisible);
138 * Switches visibility of Ports in the node
140 void SUPERVGUI_ComputeNode::switchPorts() {
141 bool aIsVisible = myPortsBox->isVisible();
142 if (aIsVisible) myPortsBox->hide();
143 else myPortsBox->show();
145 myShowPopup->setItemChecked(myPortsItem, !aIsVisible);
148 void SUPERVGUI_ComputeNode::rename() {
149 SUPERVGUI_Node::rename();
150 // QToolTip::remove(myTitle);
151 QToolTip::add(myTitle, myTitle->text());
154 void SUPERVGUI_ComputeNode::updateShape() {
155 qApp->processEvents();