1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE
5 // File : SUPERVGUI_GanvasNodePrs.cxx
6 // Author : Natalia KOPNOVA
9 #include "SUPERVGUI_CanvasNodePrs.h"
10 #include "SUPERVGUI_CanvasNode.h"
11 #include "SUPERVGUI_CanvasPort.h"
12 #include "SUPERVGUI_Canvas.h"
13 #include "SUPERVGUI_CanvasCellNodePrs.h"
14 #include "SUPERVGUI_Main.h"
16 #include "SUIT_ResourceMgr.h"
21 #include <sys/timeb.h>
24 //#define PORT_MARGIN 2
25 #undef PORT_HEIGHT // to avoid warning message
26 #define PORT_HEIGHT LABEL_HEIGHT
30 //=====================================================================
32 //=====================================================================
33 SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas,
34 SUPERVGUI_CanvasNode* theNode,
36 QCanvasPolygonalItem(theCanvas),
40 Trace("SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs");
41 myWidth = LABEL_WIDTH;
42 if (2*(PORT_WIDTH+PORT_MARGIN) > myWidth)
43 myWidth = 2*(PORT_WIDTH+PORT_MARGIN);
45 myTitleHeight = LABEL_HEIGHT;
46 myLabelHeight = LABEL_HEIGHT;
47 myStatusHeight = LABEL_HEIGHT;
48 myPortHeight = 2*PORT_MARGIN;
50 myGateHeight = PORT_HEIGHT + 2*PORT_MARGIN;
52 myLabelVisible = true;
54 myCellPrs = theCellPrs;
56 myColor = mgr->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK );
59 // create in/out connection points prs
60 myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true);
61 myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false);
64 setState(myNode->getEngine()->State());
70 SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs()
84 int SUPERVGUI_CanvasNodePrs::rtti() const
86 return SUPERVGUI_Canvas::Rtti_Node;
89 int SUPERVGUI_CanvasNodePrs::width() const
94 int SUPERVGUI_CanvasNodePrs::height() const
96 return getTitleHeight() + getLabelHeight() + getStatusHeight() +
97 getBodyHeight() + getGateHeight();
100 int SUPERVGUI_CanvasNodePrs::getTitleHeight() const
102 return myTitleHeight;
105 int SUPERVGUI_CanvasNodePrs::getLabelHeight() const
107 if (isLabelVisible())
108 return myLabelHeight;
112 int SUPERVGUI_CanvasNodePrs::getStatusHeight() const
114 return myStatusHeight;
117 int SUPERVGUI_CanvasNodePrs::getBodyHeight() const
120 return myPortHeight + myStreamHeight;
124 int SUPERVGUI_CanvasNodePrs::getPortHeight() const
131 int SUPERVGUI_CanvasNodePrs::getStreamHeight() const
134 return myStreamHeight;
138 int SUPERVGUI_CanvasNodePrs::getGateHeight() const
145 QPointArray SUPERVGUI_CanvasNodePrs::areaPoints() const
150 QPointArray aPnts(4);
151 aPnts[0] = QPoint((int)x(), (int)y());
152 aPnts[1] = aPnts[0] + QPoint(w, 0);
153 aPnts[2] = aPnts[1] + QPoint(0, h);
154 aPnts[3] = aPnts[0] + QPoint(0, h);
158 QObject* SUPERVGUI_CanvasNodePrs::getObject(const QPoint& thePos) const
160 QObject* anObj = myNode;
162 // check if it's a port
163 const QObjectList* list = myNode->children();
165 QObjectListIt it(*list);
166 SUPERVGUI_CanvasPort* aPort;
167 while (QObject* obj = it.current()) {
169 if (obj->inherits("SUPERVGUI_CanvasPort")) {
170 aPort = (SUPERVGUI_CanvasPort*) obj;
171 if (aPort->getPrs()->getPortRect().contains(thePos, true)) {
181 void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy)
183 int aX = (int) (x()+dx);
184 int aY = (int) (y()+dy);
185 int xx = aX - (int)x();
186 int yy = aY - (int)y();
188 int w = aX + width() + GRAPH_MARGIN;
189 int h = aY + height() + GRAPH_MARGIN;
190 if (canvas()->width() > w) w = canvas()->width();
191 if (canvas()->height() > h) h = canvas()->height();
192 if (canvas()->width() < w || canvas()->height() < h)
193 canvas()->resize(w, h);
195 // save new coordinates only if node is really moving...
197 myNode->getEngine()->Coords(aX, aY);
200 QCanvasPolygonalItem::moveBy(dx, dy);
202 // update port's rectangle
203 const QObjectList* list = myNode->children();
205 QObjectListIt it(*list);
206 SUPERVGUI_CanvasPort* aPort;
207 while (QObject* obj = it.current()) {
209 if (obj->inherits("SUPERVGUI_CanvasPort")) {
210 aPort = (SUPERVGUI_CanvasPort*) obj;
211 aPort->moveBy(xx, yy);
217 myPointIn->moveBy(dx, dy);
218 myPointOut->moveBy(dx, dy);
222 void SUPERVGUI_CanvasNodePrs::setZ(double z)
224 QCanvasItem::setZ(z);
227 const QObjectList* list = myNode->children();
229 QObjectListIt it(*list);
230 SUPERVGUI_CanvasPort* aPort;
231 while (QObject* obj = it.current()) {
233 if (obj->inherits("SUPERVGUI_CanvasPort")) {
234 aPort = (SUPERVGUI_CanvasPort*) obj;
235 aPort->getPrs()->setZ(z);
241 void SUPERVGUI_CanvasNodePrs::hideAll()
243 bool aDisp = isVisible();
246 setLabelVisible(false);
247 setPortVisible(false);
251 // canvas()->update();
255 void SUPERVGUI_CanvasNodePrs::showAll()
257 bool aDisp = isVisible();
260 setLabelVisible(true);
261 setPortVisible(true);
265 // canvas()->update();
269 void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b)
271 bool aDisp = isVisible();
276 if (!isPortVisible() && !myCellPrs) updatePoints();
284 void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b)
286 bool aDisp = isVisible();
307 const QObjectList* list = myNode->children();
309 QObjectListIt it(*list);
310 SUPERVGUI_CanvasPort* aPort;
311 while (QObject* obj = it.current()) {
313 if (obj->inherits("SUPERVGUI_CanvasPort")) {
314 aPort = (SUPERVGUI_CanvasPort*) obj;
315 aPort->getPrs()->setVisible(b);
326 void SUPERVGUI_CanvasNodePrs::setNodeColor(const QColor& theColor)
329 canvas()->setChanged(getRect());
333 void SUPERVGUI_CanvasNodePrs::updateInfo()
335 canvas()->setChanged(getTitleRect());
336 canvas()->setChanged(getLabelRect()); //node's comment is saved in engine (we can see it only
337 //with help of ChangeInformation dialog),
338 //node's label isn't change
342 void SUPERVGUI_CanvasNodePrs::updatePoints()
344 QPoint in = getInConnectionPoint();
345 myPointIn->setCoords(in.x(), in.y());
347 QPoint out = getOutConnectionPoint();
348 myPointOut->setCoords(out.x(), out.y());
351 void SUPERVGUI_CanvasNodePrs::updatePorts()
353 bool aDisp = isVisible();
356 QRect r = getBodyRect();
357 int w = (int)(r.width()/2) - PORT_MARGIN;
358 if (w < PORT_WIDTH) w = PORT_WIDTH;
360 int ix = r.x() + PORT_MARGIN;
361 int ih = r.y() + PORT_MARGIN;
363 int oh = r.y() + PORT_MARGIN;
365 const QObjectList* list = myNode->children();
367 QObjectListIt it(*list);
368 SUPERVGUI_CanvasPort* aPort;
369 while (QObject* obj = it.current()) {
371 if (obj->inherits("SUPERVGUI_CanvasPort")) {
372 aPort = (SUPERVGUI_CanvasPort*) obj;
373 if (!aPort->getEngine()->IsGate() && !aPort->isStream()) {
374 if (aPort->getEngine()->IsInput()) {
375 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
379 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
387 myPortHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
389 // update stream ports
390 int sy = r.y() + myPortHeight;
391 ih = sy + PORT_MARGIN;
392 oh = sy + PORT_MARGIN;
395 QObjectListIt it(*list);
396 SUPERVGUI_CanvasPort* aPort;
397 while (QObject* obj = it.current()) {
399 if (obj->inherits("SUPERVGUI_CanvasPort")) {
400 aPort = (SUPERVGUI_CanvasPort*) obj;
401 if (!aPort->getEngine()->IsGate() && aPort->isStream()) {
402 if (aPort->getEngine()->IsInput()) {
403 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
407 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
415 myStreamHeight = (ih>oh?ih:oh) - sy + PORT_MARGIN;
416 if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0;
418 // can update gates only after body height will be defined
427 void SUPERVGUI_CanvasNodePrs::updateGates()
429 bool aDisp = isVisible();
432 QRect r = getGateRect();
433 int w = (int)(r.width()/2) - PORT_MARGIN;
434 if (w < PORT_WIDTH) w = PORT_WIDTH;
436 int ix = r.x() + PORT_MARGIN;
437 int ih = r.y() + PORT_MARGIN;
439 int oh = r.y() + PORT_MARGIN;
441 const QObjectList* list = myNode->children();
443 QObjectListIt it(*list);
444 SUPERVGUI_CanvasPort* aPort;
445 while (QObject* obj = it.current()) {
447 if (obj->inherits("SUPERVGUI_CanvasPort")) {
448 aPort = (SUPERVGUI_CanvasPort*) obj;
449 if (aPort->getEngine()->IsGate()) {
450 if (aPort->getEngine()->IsInput()) {
451 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
455 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
463 myGateHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
468 QRect SUPERVGUI_CanvasNodePrs::getRect() const
470 return QRect((int)x(), (int)y(), width(), height());
473 QRect SUPERVGUI_CanvasNodePrs::getTitleRect() const
475 return QRect((int)x(), (int)y(), width(), getTitleHeight());
478 QRect SUPERVGUI_CanvasNodePrs::getLabelRect() const
480 return QRect((int)x(), ((int)y())+getTitleHeight(), width(), getLabelHeight());
483 QRect SUPERVGUI_CanvasNodePrs::getStatusRect() const
485 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(),
486 width(), getStatusHeight());
489 QRect SUPERVGUI_CanvasNodePrs::getBodyRect() const
491 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getStatusHeight(),
492 width(), getBodyHeight());
495 QRect SUPERVGUI_CanvasNodePrs::getGateRect() const
497 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+
498 getStatusHeight()+getBodyHeight(),
499 width(), getGateHeight());
502 QPoint SUPERVGUI_CanvasNodePrs::getInConnectionPoint() const
504 QRect r = getGateRect();
506 if (isPortVisible()) {
507 h = (int)((r.top()+r.bottom())/2);
510 h = (int)(y()+height()/2);
512 return QPoint(r.left()-POINT_SIZE, h);
515 QPoint SUPERVGUI_CanvasNodePrs::getOutConnectionPoint() const
517 QRect r = getGateRect();
519 if (isPortVisible()) {
520 h = (int)((r.top()+r.bottom())/2);
523 h = (int)y() + (int)(height()/2);
525 return QPoint(r.right()+POINT_SIZE, h);
528 void drawText(QPainter& thePainter, const QString& theText,
529 const QRect& theRect, int theHAlign = Qt::AlignAuto)
531 int flags = theHAlign | Qt::AlignVCenter;
532 QRect r(theRect.x() + TEXT_MARGIN, theRect.y(),
533 theRect.width() - 2*TEXT_MARGIN, theRect.height());
535 QWMatrix aMat = thePainter.worldMatrix();
536 if (aMat.m11() != 1.0) {
537 // for scaled picture only
538 QRect r1 = aMat.mapRect(r);
539 QFont saved = thePainter.font();
541 if (f.pointSize() == -1) {
542 f.setPixelSize((int)(f.pixelSize()*aMat.m11()));
545 f.setPointSize((int)(f.pointSize()*aMat.m11()));
549 thePainter.setWorldMatrix(m);
550 thePainter.setFont(f);
551 thePainter.drawText(r1, flags, theText);
552 thePainter.setFont(saved);
553 thePainter.restore();
556 thePainter.drawText(r, flags, theText);
560 void SUPERVGUI_CanvasNodePrs::draw(QPainter& thePainter)
562 thePainter.setPen(pen());
563 thePainter.setBrush(nodeColor());
564 if ( !CORBA::is_nil( myNode->getMain()->getDataflow()->Node( myNode->name() ) ) ) // mkr : IPAL11360
565 drawShape(thePainter);
568 void SUPERVGUI_CanvasNodePrs::drawShape(QPainter& thePainter)
570 drawTitle(thePainter);
571 if (isLabelVisible()) {
572 drawLabel(thePainter);
574 if (isPortVisible()) {
575 drawPort(thePainter);
576 drawGate(thePainter);
578 drawStatus(thePainter);
579 drawFrame(thePainter);
582 void SUPERVGUI_CanvasNodePrs::drawFrame(QPainter& thePainter)
584 /* it was a good idea, but...
585 drawed polyline is out of item boundaries :-(
586 QPointArray pnts = areaPoints();
590 thePainter.drawPolyline(pnts);
593 QBrush saved = thePainter.brush();
594 thePainter.setBrush(NoBrush);
595 thePainter.drawRect(getRect());
596 thePainter.setBrush(saved);
599 void SUPERVGUI_CanvasNodePrs::drawTitle(QPainter& thePainter)
601 QBrush saved = thePainter.brush();
602 QBrush br( myMgr->colorValue( "SUPERVGraph", "Title", DEF_MAIN_TITLE ) );
603 thePainter.setBrush(br);
604 drawTitleShape(thePainter);
605 thePainter.setBrush(saved);
607 drawText(thePainter, myNode->getEngine()->Name(), getTitleRect(), Qt::AlignHCenter);
610 void SUPERVGUI_CanvasNodePrs::drawTitleShape(QPainter& thePainter)
612 thePainter.drawRect(getTitleRect());
615 void SUPERVGUI_CanvasNodePrs::drawLabel(QPainter& thePainter)
617 QRect r = getLabelRect();
619 QPen saved = thePainter.pen();
620 thePainter.setPen(NoPen);
621 thePainter.drawRect(r);
622 thePainter.setPen(saved);
624 // drawText(thePainter, myNode->getEngine()->Comment(), r);
625 drawText(thePainter, myNode->getLabelText(), r);
628 void SUPERVGUI_CanvasNodePrs::drawStatus(QPainter& thePainter)
630 QRect r = getStatusRect();
632 r.setHeight(r.height()+1);
634 QBrush savedB = thePainter.brush();
635 thePainter.setBrush(myStatusColor);
636 drawStatusShape(thePainter);
637 thePainter.setBrush(savedB);
639 QRect r1(r.x(), r.y(), (int)r.width()/2, r.height());
640 drawText(thePainter, myStatus, r1, Qt::AlignHCenter);
642 QRect r2(r.x()+r.width()-r1.width(), r.y(), r1.width(), r.height());
643 drawText(thePainter, myTime, r2, Qt::AlignHCenter);
646 void SUPERVGUI_CanvasNodePrs::drawStatusShape(QPainter& thePainter)
648 QRect r = getStatusRect();
650 r.setHeight(r.height()+1);
651 thePainter.drawRect(r);
654 void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter)
656 QRect r = getBodyRect();
657 r.setHeight(r.height()+1);
659 thePainter.drawRect(r);
660 int x0 = (r.left() + r.right())/2;
661 thePainter.drawLine(x0, r.top(), x0, r.bottom());
662 if (getStreamHeight() > 0) {
663 int y0 = r.top() + getPortHeight();
664 thePainter.drawLine(r.left(), y0, r.right(), y0);
667 const QObjectList* list = myNode->children();
669 QObjectListIt it(*list);
670 SUPERVGUI_CanvasPort* aPort;
671 while (QObject* obj = it.current()) {
673 if (obj->inherits("SUPERVGUI_CanvasPort")) {
674 aPort = (SUPERVGUI_CanvasPort*) obj;
676 SUPERV_Port aPortEng = aPort->getEngine();
677 // if ( CORBA::is_nil( aPortEng ) )
678 // printf ( "---\n port engine IS NIL ---\n\n" );
680 if ( !CORBA::is_nil( aPortEng ) && !aPortEng->IsGate() ) {
681 aPort->getPrs()->draw(thePainter);
688 void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter)
690 QBrush saved = thePainter.brush();
691 thePainter.setBrush(green.light(170));
693 QRect r = getGateRect();
694 // r.setHeight(r.height()+1);
695 thePainter.drawRect(r);
696 //int x0 = (r.left() + r.right())/2;
697 // thePainter.drawLine(x0, r.top(), x0, r.bottom());
699 const QObjectList* list = myNode->children();
701 QObjectListIt it(*list);
702 SUPERVGUI_CanvasPort* aPort;
703 while (QObject* obj = it.current()) {
705 if (obj->inherits("SUPERVGUI_CanvasPort")) {
706 aPort = (SUPERVGUI_CanvasPort*) obj;
707 if (aPort->getEngine()->IsGate()) {
708 aPort->getPrs()->draw(thePainter);
714 thePainter.setBrush(saved);
717 void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState)
721 myStatus = "Waiting";
722 myStatusColor = QColor(35, 192, 255);
726 case SUPERV::ReadyState:
727 myStatus = "Running";
728 myStatusColor = QColor(32,210,32);
732 case SUPERV::SuspendReadyState:
733 myStatus = "Suspended";
734 myStatusColor = QColor(255,180, 0);
738 myStatus = "Finished";
739 myStatusColor = QColor(255, 158, 255);
743 myStatus = "Aborted";
752 case SUPERV::LoadingState:
753 myStatus = "Loading";
754 myStatusColor = QColor(56,255,56);
758 myStatus = "No Status";
759 myStatusColor = myMgr->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK );
763 long sec = myNode->getEngine()->CpuUsed();
766 hms[0]=(char)(((s/10)%10)+48);
767 hms[1]=(char)((s%10)+48);
771 hms[3]=(char)((s/10)+48);
772 hms[4]=(char)((s%10)+48);
775 hms[6]=(char)((sec/10)+48);
776 hms[7]=(char)((sec%10)+48);
778 myTime = QString(hms);
780 canvas()->setChanged(getStatusRect());
785 //=====================================================================
787 //=====================================================================
788 SUPERVGUI_CanvasPortPrs::SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas,
789 SUPERVGUI_CanvasPort* thePort):
790 myCanvas(theCanvas), myPort(thePort)
794 myPoint = new SUPERVGUI_CanvasHookPrs(theCanvas, this, myPort->getEngine()->IsInput());
797 SUPERVGUI_CanvasPortPrs::~SUPERVGUI_CanvasPortPrs()
799 if (myPoint) delete myPoint;
802 void SUPERVGUI_CanvasPortPrs::setVisible(bool b)
804 if (myPoint) myPoint->setVisible(b);
806 myPort->updateLinks();
809 void SUPERVGUI_CanvasPortPrs::setPortRect(const QRect& theRect)
812 QPoint aPnt = getConnectionPoint();
814 // if (myPort->getEngine()->IsInput())
817 // dx = - POINT_SIZE;
818 // QPoint aPnt2(aPnt.x()+dx, aPnt.y());
821 // myLine->move(0, 0);
822 // myLine->setPoints(aPnt2.x(), aPnt2.y(), aPnt.x(), aPnt.y());
823 // if (myVisible) myLine->show();
826 myPoint->setCoords(aPnt.x(), aPnt.y());
827 // myPoint->move(aPnt.x(), aPnt.y());
828 if (myVisible) myPoint->show();
830 myPort->updateLinks();
833 void SUPERVGUI_CanvasPortPrs::moveBy(int dx, int dy)
835 myRect.moveBy(dx, dy);
836 if (myPoint) myPoint->moveBy(dx, dy);
837 // if (myLine) myLine->moveBy(dx, dy);
840 void SUPERVGUI_CanvasPortPrs::setZ(double z)
842 if (myPoint) myPoint->setZ(z);
843 // if (myLine) myLine->setZ(z);
846 void SUPERVGUI_CanvasPortPrs::update(bool theForce)
848 QString aNewText = getText();
849 if (theForce || myText.compare(aNewText) != 0) {
851 myCanvas->setChanged(myRect);
855 bool SUPERVGUI_CanvasPortPrs::isHilight() const
857 SUPERV_Port aPort = myPort->getEngine();
859 if (!aPort->IsGate()) {
860 if (aPort->IsInput()) {
861 if (aPort->HasInput() && !aPort->IsLinked())
864 else if (myPort->inherits("SUPERVGUI_CanvasPortOut")) {
865 SUPERVGUI_CanvasPortOut* aPortOut = (SUPERVGUI_CanvasPortOut*) myPort;
866 if (aPortOut->isInStudy())
873 bool SUPERVGUI_CanvasPortPrs::isAlert() const
876 SUPERV_Port aPort = myPort->getEngine();
877 if (!aPort->IsGate()) {
878 if (aPort->IsInput() && !aPort->HasInput() && !aPort->IsLinked())
884 QString SUPERVGUI_CanvasPortPrs::getText() const
886 SUPERV_Port aPort = myPort->getEngine();
888 if ( !CORBA::is_nil( aPort ) ) {
889 aText = aPort->Name();
890 if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream())
891 aText = aText + "=" + aPort->ToString();
893 // printf( "--- return text of port : %s ---\n", aText.latin1() );
897 int SUPERVGUI_CanvasPortPrs::getAlignment() const
899 int a = Qt::AlignAuto;
900 SUPERV_Port aPort = myPort->getEngine();
901 /* Merge to Ecole_Ete
902 if (QString(aPort->Name()).compare(OUTVOID) == 0)
905 if (aPort->IsGate()) {
906 if (aPort->IsInput())
914 QPoint SUPERVGUI_CanvasPortPrs::getConnectionPoint() const
917 if (myPort->getEngine()->IsInput())
918 x = myRect.left() - PORT_MARGIN - POINT_SIZE;
920 x = myRect.right() + PORT_MARGIN + POINT_SIZE;
921 y = (int)(myRect.top() + myRect.bottom())/2;
925 void SUPERVGUI_CanvasPortPrs::draw(QPainter& thePainter)
928 QPen savedP = thePainter.pen();
929 QBrush savedB = thePainter.brush();
931 QPen aPen(savedP.color(), getLineWidth());
932 thePainter.setPen(aPen);
933 thePainter.setBrush(Qt::NoBrush);
934 thePainter.drawRect(myRect);
935 thePainter.setPen(savedP);
936 thePainter.setBrush(savedB);
938 QFont saved = thePainter.font();
940 f.setBold(isHilight());
941 thePainter.setFont(f);
943 QPen savedP = thePainter.pen();
944 if (myPort->isStream())
945 thePainter.setPen(QColor(128, 64, 0));// Qt::darkCyan);
946 else if (isHilight())
947 thePainter.setPen(Qt::blue);
949 thePainter.setPen(Qt::red.dark(120));
951 drawText(thePainter, myText, myRect, getAlignment());
953 thePainter.setPen(savedP);
954 thePainter.setFont(saved);
958 //=====================================================================
960 //=====================================================================
961 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
962 SUPERVGUI_CanvasNodePrs* theNode,
964 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
965 myNodePrs(theNode), myPortPrs(0), myIn(theIn), myLine(0)
970 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
971 SUPERVGUI_CanvasPortPrs* thePort,
973 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
974 myNodePrs(0), myPortPrs(thePort), myIn(theIn), myLine(0)
979 void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas)
981 myLine = new QCanvasLine(theCanvas);
984 myLine->setPen(QPen(Qt::black, 1));
989 SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs()
998 QObject* SUPERVGUI_CanvasHookPrs::getObject() const
1002 anObj = myNodePrs->getNode();
1003 else if ( myPortPrs )
1004 anObj = myPortPrs->getPort();
1008 void SUPERVGUI_CanvasHookPrs::setCoords(int x, int y)
1013 myLine->setPoints(x+(myIn?POINT_SIZE:-POINT_SIZE), y, x, y);
1017 void SUPERVGUI_CanvasHookPrs::setVisible(bool b)
1019 QCanvasEllipse::setVisible(b);
1020 if (myLine) myLine->setVisible(b);
1023 void SUPERVGUI_CanvasHookPrs::moveBy(double dx, double dy)
1025 QCanvasEllipse::moveBy(dx, dy);
1026 if (myLine) myLine->moveBy(dx, dy);
1029 void SUPERVGUI_CanvasHookPrs::setZ(double z)
1031 QCanvasEllipse::setZ(z);
1032 if (myLine) myLine->setZ(z);
1035 int SUPERVGUI_CanvasHookPrs::rtti() const
1037 return SUPERVGUI_Canvas::Rtti_Hook;