2 // File : SUPERVGUI_ComputeNode.cxx
3 // Created : 09 / 01 / 2003
4 // Author : Vitaly SMETANNIKOV
7 // Copyright : Open CASCADE
10 #include "SUPERVGUI_ComputeNode.h"
11 #include "SUPERVGUI_Main.h"
12 #include <qapplication.h>
16 SUPERVGUI_ComputeNode::SUPERVGUI_ComputeNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
17 :SUPERVGUI_GraphNode(theParent, theMain, theNode)
20 setFrameStyle(QFrame::Panel | QFrame::Raised);
22 QGridLayout* aGridLayout = new QGridLayout(this, 0, 2, 3, 1);
24 myTitle->setPaletteBackgroundColor(QColor(63, 213, 255));
25 myTitle->reparent(this, pos());
26 aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 1);
28 QString aComment(theNode->Comment());
29 if (aComment.isNull() || aComment.isEmpty()) {
30 if (getNodeType() == SUPERV::FactoryNode)
31 aComment = QString(myNode->Service()->ServiceName) + QString(tr("COMMENT_FROM"))
32 + QString(getFactoryNode()->GetComponentName());
34 //aComment = tr("COMMENT_PYTHON");
35 aComment = tr("COMMENT_CNODE");
36 theNode->SetComment(aComment.latin1());
39 myServiceBox = new QVBox(this, "service");
40 myComment = new SUPERVGUI_Label(myServiceBox, LABEL_WIDTH, LABEL_HEIGHT, aComment, QLabel::AlignLeft);
41 connect(myComment, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*)));
42 QToolTip::add(myComment, myComment->text());
43 aGridLayout->addMultiCellWidget(myServiceBox, 1, 1, 0, 1);
45 myStatus->reparent(this, pos());
46 myTime->reparent(this, pos());
47 aGridLayout->addWidget(myStatus, 2, 0);
48 aGridLayout->addWidget(myTime, 2, 1);
50 myPortsBox->reparent(this, pos());
52 aGridLayout->addMultiCellWidget(myPortsBox, 3, 3, 0, 1);
55 myShowPopup = new QPopupMenu(this);
56 myServiceItem = myShowPopup->insertItem(tr("POP_SHOWTITLES"), this, SLOT(switchService()));
57 myPortsItem = myShowPopup->insertItem(tr("POP_SHOWPORTS"), this, SLOT(switchPorts()));
59 myPopup->insertSeparator();
60 myPopup->insertItem(tr("POP_SHOW"), myShowPopup);
61 myShowPopup->setItemChecked(myServiceItem, true);
62 myShowPopup->setItemChecked(myPortsItem, true);
68 SUPERVGUI_ComputeNode::~SUPERVGUI_ComputeNode() {
69 QToolTip::remove(myComment);
73 void SUPERVGUI_ComputeNode::sync()
75 Trace("SUPERVGUI_Node::sync");
76 setName(myNode->Name());
77 myTitle->setText(name());
79 myComment->setText(myNode->Comment());
81 bool editing = myMain->getDataflow()->IsEditing();
82 myPopup->setItemEnabled(myKillItem, !editing);
83 if (myMain->isEditable()) {
84 myPopup->setItemEnabled(myRenameItem, editing);
85 myPopup->setItemEnabled(myDeleteItem, editing);
87 SUPERVGUI_GraphNode::sync();
93 * Hides services info and ports
95 void SUPERVGUI_ComputeNode::hideAll() {
97 myShowPopup->setItemChecked(myServiceItem, false);
99 myShowPopup->setItemChecked(myPortsItem, false);
106 * Shows services info and ports
108 void SUPERVGUI_ComputeNode::showAll() {
109 myServiceBox->show();
110 myShowPopup->setItemChecked(myServiceItem, true);
112 myShowPopup->setItemChecked(myPortsItem, true);
119 * Switches visibility of Service names in the node
121 void SUPERVGUI_ComputeNode::switchService() {
122 bool aIsVisible = myServiceBox->isVisible();
123 if (aIsVisible) myServiceBox->hide();
124 else myServiceBox->show();
126 myShowPopup->setItemChecked(myServiceItem, !aIsVisible);
131 * Switches visibility of Ports in the node
133 void SUPERVGUI_ComputeNode::switchPorts() {
134 bool aIsVisible = myPortsBox->isVisible();
135 if (aIsVisible) myPortsBox->hide();
136 else myPortsBox->show();
138 myShowPopup->setItemChecked(myPortsItem, !aIsVisible);
142 void SUPERVGUI_ComputeNode::updateShape() {
143 qApp->processEvents();