1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "SceneDataPortItem.hxx"
20 #include "SceneTextItem.hxx"
21 #include "SceneNodeItem.hxx"
24 // #include "QtGuiContext.hxx"
25 // #include "Menus.hxx"
26 // #include <QGraphicsSceneHoverEvent>
32 #include "YacsTrace.hxx"
35 using namespace YACS::ENGINE;
36 using namespace YACS::HMI;
39 SceneDataPortItem::SceneDataPortItem(QGraphicsScene *scene, SceneItem *parent,
40 QString label, Subject *subject)
41 : SceneObserverItem(scene, parent, label, subject), ScenePortItem(label)
44 _height = _portHeight;
46 _brushColor = QColor(158, 227, 151);
47 _hiBrushColor = QColor(127, 227, 116);
48 _penColor = QColor( 15, 180, 0);
49 _hiPenColor = QColor( 11, 128, 0);
52 SceneDataPortItem::~SceneDataPortItem()
56 void SceneDataPortItem::paint(QPainter *painter,
57 const QStyleOptionGraphicsItem *option,
60 //DEBTRACE("ScenePortItem::paint");
62 painter->setPen(getPenColor());
63 painter->setBrush(getBrushColor());
64 painter->drawRoundRect(QRectF(0, 0, _width, _height), 33*_height/_width, 33);
68 void SceneDataPortItem::setText(QString label)
71 _text = new SceneTextItem(_scene,
75 _text->setPlainText(label);
78 void SceneDataPortItem::update(GuiEvent event, int type, Subject* son)
80 DEBTRACE("SceneDataPortItem::update "<< eventName(event)<<" "<<type<<" "<<son);
83 case YACS::HMI::RENAME:
84 _text->setPlainText(son->getName().c_str());
86 case YACS::HMI::REMOVE:
87 SceneObserverItem::update(event, type, son);
92 SceneNodeItem* SceneDataPortItem::getParent()
95 return dynamic_cast<SceneNodeItem*>(_parent);