1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SUPERVGUI_GanvasNodePrs.cxx
23 // Author : Natalia KOPNOVA
26 #include "SUPERVGUI_CanvasNodePrs.h"
27 #include "SUPERVGUI_CanvasNode.h"
28 #include "SUPERVGUI_CanvasPort.h"
29 #include "SUPERVGUI_Canvas.h"
30 #include "SUPERVGUI_CanvasCellNodePrs.h"
31 #include "SUPERVGUI_Main.h"
33 #include "SUIT_ResourceMgr.h"
38 #include <sys/timeb.h>
41 //#define PORT_MARGIN 2
42 #undef PORT_HEIGHT // to avoid warning message
43 #define PORT_HEIGHT LABEL_HEIGHT
47 //=====================================================================
49 //=====================================================================
50 SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas,
51 SUPERVGUI_CanvasNode* theNode,
53 QCanvasPolygonalItem(theCanvas),
57 Trace("SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs");
58 myWidth = LABEL_WIDTH;
59 if (2*(PORT_WIDTH+PORT_MARGIN) > myWidth)
60 myWidth = 2*(PORT_WIDTH+PORT_MARGIN);
62 myTitleHeight = LABEL_HEIGHT;
63 myLabelHeight = LABEL_HEIGHT;
64 myStatusHeight = LABEL_HEIGHT;
65 myPortHeight = 2*PORT_MARGIN;
67 myGateHeight = PORT_HEIGHT + 2*PORT_MARGIN;
69 myLabelVisible = true;
71 myCellPrs = theCellPrs;
73 myColor = mgr->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK );
76 // create in/out connection points prs
77 myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true);
78 myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false);
81 setState(myNode->getEngine()->State());
87 SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs()
101 int SUPERVGUI_CanvasNodePrs::rtti() const
103 return SUPERVGUI_Canvas::Rtti_Node;
106 int SUPERVGUI_CanvasNodePrs::width() const
111 int SUPERVGUI_CanvasNodePrs::height() const
113 return getTitleHeight() + getLabelHeight() + getStatusHeight() +
114 getBodyHeight() + getGateHeight();
117 int SUPERVGUI_CanvasNodePrs::getTitleHeight() const
119 return myTitleHeight;
122 int SUPERVGUI_CanvasNodePrs::getLabelHeight() const
124 if (isLabelVisible())
125 return myLabelHeight;
129 int SUPERVGUI_CanvasNodePrs::getStatusHeight() const
131 return myStatusHeight;
134 int SUPERVGUI_CanvasNodePrs::getBodyHeight() const
137 return myPortHeight + myStreamHeight;
141 int SUPERVGUI_CanvasNodePrs::getPortHeight() const
148 int SUPERVGUI_CanvasNodePrs::getStreamHeight() const
151 return myStreamHeight;
155 int SUPERVGUI_CanvasNodePrs::getGateHeight() const
162 QPointArray SUPERVGUI_CanvasNodePrs::areaPoints() const
167 QPointArray aPnts(4);
168 aPnts[0] = QPoint((int)x(), (int)y());
169 aPnts[1] = aPnts[0] + QPoint(w, 0);
170 aPnts[2] = aPnts[1] + QPoint(0, h);
171 aPnts[3] = aPnts[0] + QPoint(0, h);
175 QObject* SUPERVGUI_CanvasNodePrs::getObject(const QPoint& thePos) const
177 QObject* anObj = myNode;
179 // check if it's a port
180 const QObjectList* list = myNode->children();
182 QObjectListIt it(*list);
183 SUPERVGUI_CanvasPort* aPort;
184 while (QObject* obj = it.current()) {
186 if (obj->inherits("SUPERVGUI_CanvasPort")) {
187 aPort = (SUPERVGUI_CanvasPort*) obj;
188 if (aPort->getPrs()->getPortRect().contains(thePos, true)) {
198 void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy)
200 int aX = (int) (x()+dx);
201 int aY = (int) (y()+dy);
202 int xx = aX - (int)x();
203 int yy = aY - (int)y();
205 int w = aX + width() + GRAPH_MARGIN;
206 int h = aY + height() + GRAPH_MARGIN;
207 if (canvas()->width() > w) w = canvas()->width();
208 if (canvas()->height() > h) h = canvas()->height();
209 if (canvas()->width() < w || canvas()->height() < h)
210 canvas()->resize(w, h);
212 // save new coordinates only if node is really moving...
214 myNode->getEngine()->Coords(aX, aY);
217 QCanvasPolygonalItem::moveBy(dx, dy);
219 // update port's rectangle
220 const QObjectList* list = myNode->children();
222 QObjectListIt it(*list);
223 SUPERVGUI_CanvasPort* aPort;
224 while (QObject* obj = it.current()) {
226 if (obj->inherits("SUPERVGUI_CanvasPort")) {
227 aPort = (SUPERVGUI_CanvasPort*) obj;
228 aPort->moveBy(xx, yy);
234 myPointIn->moveBy(dx, dy);
235 myPointOut->moveBy(dx, dy);
239 void SUPERVGUI_CanvasNodePrs::setZ(double z)
241 QCanvasItem::setZ(z);
244 const QObjectList* list = myNode->children();
246 QObjectListIt it(*list);
247 SUPERVGUI_CanvasPort* aPort;
248 while (QObject* obj = it.current()) {
250 if (obj->inherits("SUPERVGUI_CanvasPort")) {
251 aPort = (SUPERVGUI_CanvasPort*) obj;
252 aPort->getPrs()->setZ(z);
258 void SUPERVGUI_CanvasNodePrs::hideAll()
260 bool aDisp = isVisible();
263 setLabelVisible(false);
264 setPortVisible(false);
268 // canvas()->update();
272 void SUPERVGUI_CanvasNodePrs::showAll()
274 bool aDisp = isVisible();
277 setLabelVisible(true);
278 setPortVisible(true);
282 // canvas()->update();
286 void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b)
288 bool aDisp = isVisible();
293 if (!isPortVisible() && !myCellPrs) updatePoints();
301 void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b)
303 bool aDisp = isVisible();
324 const QObjectList* list = myNode->children();
326 QObjectListIt it(*list);
327 SUPERVGUI_CanvasPort* aPort;
328 while (QObject* obj = it.current()) {
330 if (obj->inherits("SUPERVGUI_CanvasPort")) {
331 aPort = (SUPERVGUI_CanvasPort*) obj;
332 aPort->getPrs()->setVisible(b);
343 void SUPERVGUI_CanvasNodePrs::setNodeColor(const QColor& theColor)
346 canvas()->setChanged(getRect());
350 void SUPERVGUI_CanvasNodePrs::updateInfo()
352 canvas()->setChanged(getTitleRect());
353 canvas()->setChanged(getLabelRect()); //node's comment is saved in engine (we can see it only
354 //with help of ChangeInformation dialog),
355 //node's label isn't change
359 void SUPERVGUI_CanvasNodePrs::updatePoints()
361 QPoint in = getInConnectionPoint();
362 myPointIn->setCoords(in.x(), in.y());
364 QPoint out = getOutConnectionPoint();
365 myPointOut->setCoords(out.x(), out.y());
368 void SUPERVGUI_CanvasNodePrs::updatePorts()
370 bool aDisp = isVisible();
373 QRect r = getBodyRect();
374 int w = (int)(r.width()/2) - PORT_MARGIN;
375 if (w < PORT_WIDTH) w = PORT_WIDTH;
377 int ix = r.x() + PORT_MARGIN;
378 int ih = r.y() + PORT_MARGIN;
380 int oh = r.y() + PORT_MARGIN;
382 const QObjectList* list = myNode->children();
384 QObjectListIt it(*list);
385 SUPERVGUI_CanvasPort* aPort;
386 while (QObject* obj = it.current()) {
388 if (obj->inherits("SUPERVGUI_CanvasPort")) {
389 aPort = (SUPERVGUI_CanvasPort*) obj;
390 if (!aPort->getEngine()->IsGate() && !aPort->isStream()) {
391 if (aPort->getEngine()->IsInput()) {
392 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
396 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
404 myPortHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
406 // update stream ports
407 int sy = r.y() + myPortHeight;
408 ih = sy + PORT_MARGIN;
409 oh = sy + PORT_MARGIN;
412 QObjectListIt it(*list);
413 SUPERVGUI_CanvasPort* aPort;
414 while (QObject* obj = it.current()) {
416 if (obj->inherits("SUPERVGUI_CanvasPort")) {
417 aPort = (SUPERVGUI_CanvasPort*) obj;
418 if (!aPort->getEngine()->IsGate() && aPort->isStream()) {
419 if (aPort->getEngine()->IsInput()) {
420 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
424 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
432 myStreamHeight = (ih>oh?ih:oh) - sy + PORT_MARGIN;
433 if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0;
435 // can update gates only after body height will be defined
444 void SUPERVGUI_CanvasNodePrs::updateGates()
446 bool aDisp = isVisible();
449 QRect r = getGateRect();
450 int w = (int)(r.width()/2) - PORT_MARGIN;
451 if (w < PORT_WIDTH) w = PORT_WIDTH;
453 int ix = r.x() + PORT_MARGIN;
454 int ih = r.y() + PORT_MARGIN;
456 int oh = r.y() + PORT_MARGIN;
458 const QObjectList* list = myNode->children();
460 QObjectListIt it(*list);
461 SUPERVGUI_CanvasPort* aPort;
462 while (QObject* obj = it.current()) {
464 if (obj->inherits("SUPERVGUI_CanvasPort")) {
465 aPort = (SUPERVGUI_CanvasPort*) obj;
466 if (aPort->getEngine()->IsGate()) {
467 if (aPort->getEngine()->IsInput()) {
468 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
472 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
480 myGateHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
485 QRect SUPERVGUI_CanvasNodePrs::getRect() const
487 return QRect((int)x(), (int)y(), width(), height());
490 QRect SUPERVGUI_CanvasNodePrs::getTitleRect() const
492 return QRect((int)x(), (int)y(), width(), getTitleHeight());
495 QRect SUPERVGUI_CanvasNodePrs::getLabelRect() const
497 return QRect((int)x(), ((int)y())+getTitleHeight(), width(), getLabelHeight());
500 QRect SUPERVGUI_CanvasNodePrs::getStatusRect() const
502 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(),
503 width(), getStatusHeight());
506 QRect SUPERVGUI_CanvasNodePrs::getBodyRect() const
508 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getStatusHeight(),
509 width(), getBodyHeight());
512 QRect SUPERVGUI_CanvasNodePrs::getGateRect() const
514 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+
515 getStatusHeight()+getBodyHeight(),
516 width(), getGateHeight());
519 QPoint SUPERVGUI_CanvasNodePrs::getInConnectionPoint() const
521 QRect r = getGateRect();
523 if (isPortVisible()) {
524 h = (int)((r.top()+r.bottom())/2);
527 h = (int)(y()+height()/2);
529 return QPoint(r.left()-POINT_SIZE, h);
532 QPoint SUPERVGUI_CanvasNodePrs::getOutConnectionPoint() const
534 QRect r = getGateRect();
536 if (isPortVisible()) {
537 h = (int)((r.top()+r.bottom())/2);
540 h = (int)y() + (int)(height()/2);
542 return QPoint(r.right()+POINT_SIZE, h);
545 void drawText(QPainter& thePainter, const QString& theText,
546 const QRect& theRect, int theHAlign = Qt::AlignAuto)
548 int flags = theHAlign | Qt::AlignVCenter;
549 QRect r(theRect.x() + TEXT_MARGIN, theRect.y(),
550 theRect.width() - 2*TEXT_MARGIN, theRect.height());
552 QWMatrix aMat = thePainter.worldMatrix();
553 if (aMat.m11() != 1.0) {
554 // for scaled picture only
555 QRect r1 = aMat.mapRect(r);
556 QFont saved = thePainter.font();
558 if (f.pointSize() == -1) {
559 f.setPixelSize((int)(f.pixelSize()*aMat.m11()));
562 f.setPointSize((int)(f.pointSize()*aMat.m11()));
566 thePainter.setWorldMatrix(m);
567 thePainter.setFont(f);
568 thePainter.drawText(r1, flags, theText);
569 thePainter.setFont(saved);
570 thePainter.restore();
573 thePainter.drawText(r, flags, theText);
577 void SUPERVGUI_CanvasNodePrs::draw(QPainter& thePainter)
579 thePainter.setPen(pen());
580 thePainter.setBrush(nodeColor());
581 if ( !CORBA::is_nil( myNode->getMain()->getDataflow()->Node( myNode->name() ) ) ) // mkr : IPAL11360
582 drawShape(thePainter);
585 void SUPERVGUI_CanvasNodePrs::drawShape(QPainter& thePainter)
587 drawTitle(thePainter);
588 if (isLabelVisible()) {
589 drawLabel(thePainter);
591 if (isPortVisible()) {
592 drawPort(thePainter);
593 drawGate(thePainter);
595 drawStatus(thePainter);
596 drawFrame(thePainter);
599 void SUPERVGUI_CanvasNodePrs::drawFrame(QPainter& thePainter)
601 /* it was a good idea, but...
602 drawed polyline is out of item boundaries :-(
603 QPointArray pnts = areaPoints();
607 thePainter.drawPolyline(pnts);
610 QBrush saved = thePainter.brush();
611 thePainter.setBrush(NoBrush);
612 thePainter.drawRect(getRect());
613 thePainter.setBrush(saved);
616 void SUPERVGUI_CanvasNodePrs::drawTitle(QPainter& thePainter)
618 QBrush saved = thePainter.brush();
619 QBrush br( myMgr->colorValue( "SUPERVGraph", "Title", DEF_MAIN_TITLE ) );
620 thePainter.setBrush(br);
621 drawTitleShape(thePainter);
622 thePainter.setBrush(saved);
624 drawText(thePainter, myNode->getEngine()->Name(), getTitleRect(), Qt::AlignHCenter);
627 void SUPERVGUI_CanvasNodePrs::drawTitleShape(QPainter& thePainter)
629 thePainter.drawRect(getTitleRect());
632 void SUPERVGUI_CanvasNodePrs::drawLabel(QPainter& thePainter)
634 QRect r = getLabelRect();
636 QPen saved = thePainter.pen();
637 thePainter.setPen(NoPen);
638 thePainter.drawRect(r);
639 thePainter.setPen(saved);
641 // drawText(thePainter, myNode->getEngine()->Comment(), r);
642 drawText(thePainter, myNode->getLabelText(), r);
645 void SUPERVGUI_CanvasNodePrs::drawStatus(QPainter& thePainter)
647 QRect r = getStatusRect();
649 r.setHeight(r.height()+1);
651 QBrush savedB = thePainter.brush();
652 thePainter.setBrush(myStatusColor);
653 drawStatusShape(thePainter);
654 thePainter.setBrush(savedB);
656 QRect r1(r.x(), r.y(), (int)r.width()/2, r.height());
657 drawText(thePainter, myStatus, r1, Qt::AlignHCenter);
659 QRect r2(r.x()+r.width()-r1.width(), r.y(), r1.width(), r.height());
660 drawText(thePainter, myTime, r2, Qt::AlignHCenter);
663 void SUPERVGUI_CanvasNodePrs::drawStatusShape(QPainter& thePainter)
665 QRect r = getStatusRect();
667 r.setHeight(r.height()+1);
668 thePainter.drawRect(r);
671 void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter)
673 QRect r = getBodyRect();
674 r.setHeight(r.height()+1);
676 thePainter.drawRect(r);
677 int x0 = (r.left() + r.right())/2;
678 thePainter.drawLine(x0, r.top(), x0, r.bottom());
679 if (getStreamHeight() > 0) {
680 int y0 = r.top() + getPortHeight();
681 thePainter.drawLine(r.left(), y0, r.right(), y0);
684 const QObjectList* list = myNode->children();
686 QObjectListIt it(*list);
687 SUPERVGUI_CanvasPort* aPort;
688 while (QObject* obj = it.current()) {
690 if (obj->inherits("SUPERVGUI_CanvasPort")) {
691 aPort = (SUPERVGUI_CanvasPort*) obj;
693 SUPERV_Port aPortEng = aPort->getEngine();
694 // if ( CORBA::is_nil( aPortEng ) )
695 // printf ( "---\n port engine IS NIL ---\n\n" );
697 if ( !CORBA::is_nil( aPortEng ) && !aPortEng->IsGate() ) {
698 aPort->getPrs()->draw(thePainter);
705 void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter)
707 QBrush saved = thePainter.brush();
708 thePainter.setBrush(green.light(170));
710 QRect r = getGateRect();
711 // r.setHeight(r.height()+1);
712 thePainter.drawRect(r);
713 //int x0 = (r.left() + r.right())/2;
714 // thePainter.drawLine(x0, r.top(), x0, r.bottom());
716 const QObjectList* list = myNode->children();
718 QObjectListIt it(*list);
719 SUPERVGUI_CanvasPort* aPort;
720 while (QObject* obj = it.current()) {
722 if (obj->inherits("SUPERVGUI_CanvasPort")) {
723 aPort = (SUPERVGUI_CanvasPort*) obj;
724 if (aPort->getEngine()->IsGate()) {
725 aPort->getPrs()->draw(thePainter);
731 thePainter.setBrush(saved);
734 void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState)
738 myStatus = "Waiting";
739 myStatusColor = QColor(35, 192, 255);
743 case SUPERV::ReadyState:
744 myStatus = "Running";
745 myStatusColor = QColor(32,210,32);
749 case SUPERV::SuspendReadyState:
750 myStatus = "Suspended";
751 myStatusColor = QColor(255,180, 0);
755 myStatus = "Finished";
756 myStatusColor = QColor(255, 158, 255);
760 myStatus = "Aborted";
769 case SUPERV::LoadingState:
770 myStatus = "Loading";
771 myStatusColor = QColor(56,255,56);
775 myStatus = "No Status";
776 myStatusColor = myMgr->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK );
781 // IPAL9273, 9369, 9731
782 if ( theState != SUPERV_Kill && myNode->getMain()->getDataflow()->State() != SUPERV_Kill )
783 sec = myNode->getEngine()->CpuUsed();
786 hms[0]=(char)(((s/10)%10)+48);
787 hms[1]=(char)((s%10)+48);
791 hms[3]=(char)((s/10)+48);
792 hms[4]=(char)((s%10)+48);
795 hms[6]=(char)((sec/10)+48);
796 hms[7]=(char)((sec%10)+48);
798 myTime = QString(hms);
800 canvas()->setChanged(getStatusRect());
805 //=====================================================================
807 //=====================================================================
808 SUPERVGUI_CanvasPortPrs::SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas,
809 SUPERVGUI_CanvasPort* thePort):
810 myCanvas(theCanvas), myPort(thePort)
814 myPoint = new SUPERVGUI_CanvasHookPrs(theCanvas, this, myPort->getEngine()->IsInput());
817 SUPERVGUI_CanvasPortPrs::~SUPERVGUI_CanvasPortPrs()
819 if (myPoint) delete myPoint;
822 void SUPERVGUI_CanvasPortPrs::setVisible(bool b)
824 if (myPoint) myPoint->setVisible(b);
826 myPort->updateLinks();
829 void SUPERVGUI_CanvasPortPrs::setPortRect(const QRect& theRect)
832 QPoint aPnt = getConnectionPoint();
834 // if (myPort->getEngine()->IsInput())
837 // dx = - POINT_SIZE;
838 // QPoint aPnt2(aPnt.x()+dx, aPnt.y());
841 // myLine->move(0, 0);
842 // myLine->setPoints(aPnt2.x(), aPnt2.y(), aPnt.x(), aPnt.y());
843 // if (myVisible) myLine->show();
846 myPoint->setCoords(aPnt.x(), aPnt.y());
847 // myPoint->move(aPnt.x(), aPnt.y());
848 if (myVisible) myPoint->show();
850 myPort->updateLinks();
853 void SUPERVGUI_CanvasPortPrs::moveBy(int dx, int dy)
855 myRect.moveBy(dx, dy);
856 if (myPoint) myPoint->moveBy(dx, dy);
857 // if (myLine) myLine->moveBy(dx, dy);
860 void SUPERVGUI_CanvasPortPrs::setZ(double z)
862 if (myPoint) myPoint->setZ(z);
863 // if (myLine) myLine->setZ(z);
866 void SUPERVGUI_CanvasPortPrs::update(bool theForce)
868 QString aNewText = getText();
869 if (theForce || myText.compare(aNewText) != 0) {
871 myCanvas->setChanged(myRect);
875 bool SUPERVGUI_CanvasPortPrs::isHilight() const
877 SUPERV_Port aPort = myPort->getEngine();
879 if (!aPort->IsGate()) {
880 if (aPort->IsInput()) {
881 if (aPort->HasInput() && !aPort->IsLinked())
884 else if (myPort->inherits("SUPERVGUI_CanvasPortOut")) {
885 SUPERVGUI_CanvasPortOut* aPortOut = (SUPERVGUI_CanvasPortOut*) myPort;
886 if (aPortOut->isInStudy())
893 bool SUPERVGUI_CanvasPortPrs::isAlert() const
896 SUPERV_Port aPort = myPort->getEngine();
897 if (!aPort->IsGate()) {
898 if (aPort->IsInput() && !aPort->HasInput() && !aPort->IsLinked())
904 QString SUPERVGUI_CanvasPortPrs::getText() const
906 SUPERV_Port aPort = myPort->getEngine();
908 if ( !CORBA::is_nil( aPort ) ) {
909 aText = aPort->Name();
910 if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream()) {
911 // mkr : modifications to avoid displaying long IOR's values on nodes' ports,
912 // display ports type from corresponding XML catalog instead.
913 QString aPortValue = aPort->ToString();
914 QString aPortType = aPort->Type();
915 if ( aPortType.compare("string") // not "string" type
917 aPortValue.find("IOR:") >= 0 ) // has IOR:... in value
918 aText = aText + "=" + aPortType;
920 aText = aText + "=" + aPortValue;
923 // printf( "--- return text of port : %s ---\n", aText.latin1() );
927 int SUPERVGUI_CanvasPortPrs::getAlignment() const
929 int a = Qt::AlignAuto;
930 SUPERV_Port aPort = myPort->getEngine();
931 /* Merge to Ecole_Ete
932 if (QString(aPort->Name()).compare(OUTVOID) == 0)
935 if (aPort->IsGate()) {
936 if (aPort->IsInput())
944 QPoint SUPERVGUI_CanvasPortPrs::getConnectionPoint() const
947 if (myPort->getEngine()->IsInput())
948 x = myRect.left() - PORT_MARGIN - POINT_SIZE;
950 x = myRect.right() + PORT_MARGIN + POINT_SIZE;
951 y = (int)(myRect.top() + myRect.bottom())/2;
955 void SUPERVGUI_CanvasPortPrs::draw(QPainter& thePainter)
958 QPen savedP = thePainter.pen();
959 QBrush savedB = thePainter.brush();
961 QPen aPen(savedP.color(), getLineWidth());
962 thePainter.setPen(aPen);
963 thePainter.setBrush(Qt::NoBrush);
964 thePainter.drawRect(myRect);
965 thePainter.setPen(savedP);
966 thePainter.setBrush(savedB);
968 QFont saved = thePainter.font();
970 f.setBold(isHilight());
971 thePainter.setFont(f);
973 QPen savedP = thePainter.pen();
974 if (myPort->isStream())
975 thePainter.setPen(QColor(128, 64, 0));// Qt::darkCyan);
976 else if (isHilight())
977 thePainter.setPen(Qt::blue);
979 thePainter.setPen(Qt::red.dark(120));
981 drawText(thePainter, myText, myRect, getAlignment());
983 thePainter.setPen(savedP);
984 thePainter.setFont(saved);
988 //=====================================================================
990 //=====================================================================
991 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
992 SUPERVGUI_CanvasNodePrs* theNode,
994 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
995 myNodePrs(theNode), myPortPrs(0), myIn(theIn), myLine(0)
1000 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
1001 SUPERVGUI_CanvasPortPrs* thePort,
1003 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
1004 myNodePrs(0), myPortPrs(thePort), myIn(theIn), myLine(0)
1009 void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas)
1011 myLine = new QCanvasLine(theCanvas);
1013 setBrush(Qt::black);
1014 myLine->setPen(QPen(Qt::black, 1));
1019 SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs()
1028 QObject* SUPERVGUI_CanvasHookPrs::getObject() const
1032 anObj = myNodePrs->getNode();
1033 else if ( myPortPrs )
1034 anObj = myPortPrs->getPort();
1038 void SUPERVGUI_CanvasHookPrs::setCoords(int x, int y)
1043 myLine->setPoints(x+(myIn?POINT_SIZE:-POINT_SIZE), y, x, y);
1047 void SUPERVGUI_CanvasHookPrs::setVisible(bool b)
1049 QCanvasEllipse::setVisible(b);
1050 if (myLine) myLine->setVisible(b);
1053 void SUPERVGUI_CanvasHookPrs::moveBy(double dx, double dy)
1055 QCanvasEllipse::moveBy(dx, dy);
1056 if (myLine) myLine->moveBy(dx, dy);
1059 void SUPERVGUI_CanvasHookPrs::setZ(double z)
1061 QCanvasEllipse::setZ(z);
1062 if (myLine) myLine->setZ(z);
1065 int SUPERVGUI_CanvasHookPrs::rtti() const
1067 return SUPERVGUI_Canvas::Rtti_Hook;