X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fgenericgui%2FSceneDataPortItem.cxx;h=ab5150eda7ce2574df4e6e801edfcee5ad141d97;hb=884c24e399ddcf623cee5d6d7136a06255b6f3f0;hp=f987a25e2b26a1b6d0d74ca2ff96b99f3abe0b86;hpb=f4c10bf1781a76534bb1fa293aef541aef56148b;p=modules%2Fyacs.git diff --git a/src/genericgui/SceneDataPortItem.cxx b/src/genericgui/SceneDataPortItem.cxx index f987a25e2..ab5150eda 100644 --- a/src/genericgui/SceneDataPortItem.cxx +++ b/src/genericgui/SceneDataPortItem.cxx @@ -1,32 +1,31 @@ -// Copyright (C) 2006-2008 CEA/DEN, EDF R&D +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include "SceneDataPortItem.hxx" #include "SceneTextItem.hxx" #include "SceneNodeItem.hxx" +#include "SceneLinkItem.hxx" #include "Scene.hxx" -// #include "QtGuiContext.hxx" -// #include "Menus.hxx" -// #include -// #include +#include "QtGuiContext.hxx" -// #include +#include "Resource.hxx" //#define _DEVDEBUG_ #include "YacsTrace.hxx" @@ -40,28 +39,47 @@ SceneDataPortItem::SceneDataPortItem(QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject) : SceneObserverItem(scene, parent, label, subject), ScenePortItem(label) { - _width = _portWidth; - _height = _portHeight; setText(label); - _brushColor = QColor(158, 227, 151); - _hiBrushColor = QColor(127, 227, 116); - _penColor = QColor( 15, 180, 0); - _hiPenColor = QColor( 11, 128, 0); + _width = Resource::DataPort_Width; + _height = Resource::DataPort_Height; + switch (getSubject()->getType()) + { + case INPUTPORT: + case OUTPUTPORT: + _brushColor = Resource::DataPort_brush; + _hiBrushColor = Resource::DataPort_hiBrush; + _penColor = Resource::DataPort_pen; + _hiPenColor = Resource::DataPort_hiPen; + break; + case INPUTDATASTREAMPORT: + case OUTPUTDATASTREAMPORT: + _brushColor = Resource::DataStreamPort_brush; + _hiBrushColor = Resource::DataStreamPort_hiBrush; + _penColor = Resource::DataStreamPort_pen; + _hiPenColor = Resource::DataStreamPort_hiPen; + break; + } } SceneDataPortItem::~SceneDataPortItem() { + DEBTRACE("ScenePortItem::~SceneDataPortItem"); } void SceneDataPortItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - //DEBTRACE("ScenePortItem::paint"); + DEBTRACE("ScenePortItem::paint"); painter->save(); - painter->setPen(getPenColor()); + + QPen pen(getPenColor()); + pen.setWidth(Resource::Thickness); + painter->setPen(pen); painter->setBrush(getBrushColor()); - painter->drawRoundRect(QRectF(0, 0, _width, _height), 33*_height/_width, 33); + QRectF rect(0, 0, Resource::DataPort_Width, Resource::DataPort_Height); + painter->drawRoundedRect(rect, Resource::Radius, Resource::Radius); + painter->restore(); } @@ -70,18 +88,18 @@ void SceneDataPortItem::setText(QString label) if (!_text) _text = new SceneTextItem(_scene, this, - label); - else - _text->setPlainText(label); + label ); } void SceneDataPortItem::update(GuiEvent event, int type, Subject* son) { DEBTRACE("SceneDataPortItem::update "<< eventName(event)<<" "<setPlainText(son->getName().c_str()); + _text->setPlainTextTrunc(son->getName().c_str()); + QGraphicsItem::update(); break; case YACS::HMI::REMOVE: SceneObserverItem::update(event, type, son); @@ -97,3 +115,47 @@ SceneNodeItem* SceneDataPortItem::getParent() return 0; } +void SceneDataPortItem::updateChildItems() +{ + DEBTRACE("SceneDataPortItem::updateChildItems " << _label.toStdString()); + if(SubjectDataPort* sdp=dynamic_cast(_subject)) + { + std::list lsl=sdp->getListOfSubjectLink(); + for (std::list::const_iterator it = lsl.begin(); it != lsl.end(); ++it) + { + SceneLinkItem* item = dynamic_cast(QtGuiContext::getQtCurrent()->_mapOfSceneItem[*it]); + item->updateShape(); + } + } +} + +void SceneDataPortItem::updateLinks() +{ + DEBTRACE("SceneDataPortItem::updateLinks " << _label.toStdString()); + if(SubjectDataPort* sdp=dynamic_cast(_subject)) + { + std::list lsl=sdp->getListOfSubjectLink(); + for (std::list::const_iterator it = lsl.begin(); it != lsl.end(); ++it) + { + SceneLinkItem* item = dynamic_cast(QtGuiContext::getQtCurrent()->_mapOfSceneItem[*it]); + item->updateShape(); + } + } +} + +void SceneDataPortItem::shrinkExpandLink(bool se) +{ + if(SubjectDataPort* sdp=dynamic_cast(_subject)) + { + std::list lsl=sdp->getListOfSubjectLink(); + for (std::list::const_iterator it = lsl.begin(); it != lsl.end(); ++it) + { + SceneLinkItem* item = dynamic_cast(QtGuiContext::getQtCurrent()->_mapOfSceneItem[*it]); + if (se) { + item->show(); + } else { + item->hide(); + }; + } + } +}