1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE
5 // File : SUPERVGUI_GanvasNodePrs.cxx
6 // Author : Natalia KOPNOVA
10 #include "SUPERVGUI_CanvasNodePrs.h"
11 #include "SUPERVGUI_CanvasNode.h"
12 #include "SUPERVGUI_CanvasPort.h"
13 #include "SUPERVGUI_Canvas.h"
14 #include "SUPERVGUI_CanvasCellNodePrs.h"
19 #include <sys/timeb.h>
23 #undef PORT_HEIGHT // to avoid warning message
24 #define PORT_HEIGHT LABEL_HEIGHT
28 //=====================================================================
30 //=====================================================================
31 SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas,
32 SUPERVGUI_CanvasNode* theNode,
34 QCanvasPolygonalItem(theCanvas),
37 Trace("SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs");
38 myWidth = LABEL_WIDTH;
39 if (2*(PORT_WIDTH+PORT_MARGIN) > myWidth)
40 myWidth = 2*(PORT_WIDTH+PORT_MARGIN);
42 myTitleHeight = LABEL_HEIGHT;
43 myLabelHeight = LABEL_HEIGHT;
44 myStatusHeight = LABEL_HEIGHT;
45 myPortHeight = 2*PORT_MARGIN;
47 myGateHeight = PORT_HEIGHT + 2*PORT_MARGIN;
49 myLabelVisible = true;
51 myCellPrs = theCellPrs;
56 // create in/out connection points prs
57 myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true);
58 myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false);
61 cout<<" ===> 0.2 conatructor NodePrs : CanvasArray has ......"<<endl;
64 cout<<" ===> 0.3 conatructor NodePrs : CanvasArray has ......"<<endl;
66 cout<<" ===> 0.35 conatructor NodePrs : CanvasArray has ......"<<endl;
68 setState(myNode->getEngine()->State());
72 cout<<" ===> 0.4 conatructor NodePrs : CanvasArray has ......"<<endl;
74 QCanvasItemList anIL2 = canvas()->allItems();
75 cout<<" ===> 1 conatructor NodePrs : CanvasArray has "<<anIL2.count()<<" children!"<<endl;
79 SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs()
81 MESSAGE("SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs");
83 if (myPointIn) delete myPointIn;
84 if (myPointOut) delete myPointOut;
89 int SUPERVGUI_CanvasNodePrs::rtti() const
91 return SUPERVGUI_Canvas::Rtti_Node;
94 int SUPERVGUI_CanvasNodePrs::width() const
99 int SUPERVGUI_CanvasNodePrs::height() const
101 return getTitleHeight() + getLabelHeight() + getStatusHeight() +
102 getBodyHeight() + getGateHeight();
105 int SUPERVGUI_CanvasNodePrs::getTitleHeight() const
107 return myTitleHeight;
110 int SUPERVGUI_CanvasNodePrs::getLabelHeight() const
112 if (isLabelVisible())
113 return myLabelHeight;
117 int SUPERVGUI_CanvasNodePrs::getStatusHeight() const
119 return myStatusHeight;
122 int SUPERVGUI_CanvasNodePrs::getBodyHeight() const
125 return myPortHeight + myStreamHeight;
129 int SUPERVGUI_CanvasNodePrs::getPortHeight() const
136 int SUPERVGUI_CanvasNodePrs::getStreamHeight() const
139 return myStreamHeight;
143 int SUPERVGUI_CanvasNodePrs::getGateHeight() const
150 QPointArray SUPERVGUI_CanvasNodePrs::areaPoints() const
155 QPointArray aPnts(4);
156 aPnts[0] = QPoint((int)x(), (int)y());
157 aPnts[1] = aPnts[0] + QPoint(w, 0);
158 aPnts[2] = aPnts[1] + QPoint(0, h);
159 aPnts[3] = aPnts[0] + QPoint(0, h);
163 QObject* SUPERVGUI_CanvasNodePrs::getObject(const QPoint& thePos) const
165 QObject* anObj = myNode;
167 // check if it's a port
168 const QObjectList* list = myNode->children();
170 QObjectListIt it(*list);
171 SUPERVGUI_CanvasPort* aPort;
172 while (QObject* obj = it.current()) {
174 if (obj->inherits("SUPERVGUI_CanvasPort")) {
175 aPort = (SUPERVGUI_CanvasPort*) obj;
176 if (aPort->getPrs()->getPortRect().contains(thePos, true)) {
186 void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy)
188 int aX = (int) (x()+dx);
189 int aY = (int) (y()+dy);
190 int xx = aX - (int)x();
191 int yy = aY - (int)y();
193 int w = aX + width() + GRAPH_MARGIN;
194 int h = aY + height() + GRAPH_MARGIN;
195 if (canvas()->width() > w) w = canvas()->width();
196 if (canvas()->height() > h) h = canvas()->height();
197 if (canvas()->width() < w || canvas()->height() < h)
198 canvas()->resize(w, h);
200 // save new coordinates only if node is really moving...
202 myNode->getEngine()->Coords(aX, aY);
205 QCanvasPolygonalItem::moveBy(dx, dy);
207 // update port's rectangle
208 const QObjectList* list = myNode->children();
210 QObjectListIt it(*list);
211 SUPERVGUI_CanvasPort* aPort;
212 while (QObject* obj = it.current()) {
214 if (obj->inherits("SUPERVGUI_CanvasPort")) {
215 aPort = (SUPERVGUI_CanvasPort*) obj;
216 aPort->moveBy(xx, yy);
222 myPointIn->moveBy(dx, dy);
223 myPointOut->moveBy(dx, dy);
227 void SUPERVGUI_CanvasNodePrs::setZ(double z)
229 QCanvasItem::setZ(z);
232 const QObjectList* list = myNode->children();
234 QObjectListIt it(*list);
235 SUPERVGUI_CanvasPort* aPort;
236 while (QObject* obj = it.current()) {
238 if (obj->inherits("SUPERVGUI_CanvasPort")) {
239 aPort = (SUPERVGUI_CanvasPort*) obj;
240 aPort->getPrs()->setZ(z);
246 void SUPERVGUI_CanvasNodePrs::hideAll()
248 bool aDisp = isVisible();
251 setLabelVisible(false);
252 setPortVisible(false);
256 // canvas()->update();
260 void SUPERVGUI_CanvasNodePrs::showAll()
262 bool aDisp = isVisible();
265 setLabelVisible(true);
266 setPortVisible(true);
270 // canvas()->update();
274 void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b)
276 bool aDisp = isVisible();
281 if (!isPortVisible() && !myCellPrs) updatePoints();
289 void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b)
291 bool aDisp = isVisible();
312 const QObjectList* list = myNode->children();
314 QObjectListIt it(*list);
315 SUPERVGUI_CanvasPort* aPort;
316 while (QObject* obj = it.current()) {
318 if (obj->inherits("SUPERVGUI_CanvasPort")) {
319 aPort = (SUPERVGUI_CanvasPort*) obj;
320 aPort->getPrs()->setVisible(b);
331 void SUPERVGUI_CanvasNodePrs::setNodeColor(const QColor& theColor)
334 canvas()->setChanged(getRect());
338 void SUPERVGUI_CanvasNodePrs::updateInfo()
340 canvas()->setChanged(getTitleRect());
341 canvas()->setChanged(getLabelRect()); //node's comment is saved in engine (we can see it only
342 //with help of ChangeInformation dialog),
343 //node's label isn't change
347 void SUPERVGUI_CanvasNodePrs::updatePoints()
349 QPoint in = getInConnectionPoint();
350 myPointIn->setCoords(in.x(), in.y());
352 QPoint out = getOutConnectionPoint();
353 myPointOut->setCoords(out.x(), out.y());
356 void SUPERVGUI_CanvasNodePrs::updatePorts()
358 bool aDisp = isVisible();
361 QRect r = getBodyRect();
362 int w = (int)(r.width()/2) - PORT_MARGIN;
363 if (w < PORT_WIDTH) w = PORT_WIDTH;
365 int ix = r.x() + PORT_MARGIN;
366 int ih = r.y() + PORT_MARGIN;
368 int oh = r.y() + PORT_MARGIN;
370 const QObjectList* list = myNode->children();
372 QObjectListIt it(*list);
373 SUPERVGUI_CanvasPort* aPort;
374 while (QObject* obj = it.current()) {
376 if (obj->inherits("SUPERVGUI_CanvasPort")) {
377 aPort = (SUPERVGUI_CanvasPort*) obj;
378 if (!aPort->getEngine()->IsGate() && !aPort->isStream()) {
379 if (aPort->getEngine()->IsInput()) {
380 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
384 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
392 myPortHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
394 // update stream ports
395 int sy = r.y() + myPortHeight;
396 ih = sy + PORT_MARGIN;
397 oh = sy + PORT_MARGIN;
400 QObjectListIt it(*list);
401 SUPERVGUI_CanvasPort* aPort;
402 while (QObject* obj = it.current()) {
404 if (obj->inherits("SUPERVGUI_CanvasPort")) {
405 aPort = (SUPERVGUI_CanvasPort*) obj;
406 if (!aPort->getEngine()->IsGate() && aPort->isStream()) {
407 if (aPort->getEngine()->IsInput()) {
408 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
412 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
420 myStreamHeight = (ih>oh?ih:oh) - sy + PORT_MARGIN;
421 if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0;
423 // can update gates only after body height will be defined
432 void SUPERVGUI_CanvasNodePrs::updateGates()
434 bool aDisp = isVisible();
437 QRect r = getGateRect();
438 int w = (int)(r.width()/2) - PORT_MARGIN;
439 if (w < PORT_WIDTH) w = PORT_WIDTH;
441 int ix = r.x() + PORT_MARGIN;
442 int ih = r.y() + PORT_MARGIN;
444 int oh = r.y() + PORT_MARGIN;
446 const QObjectList* list = myNode->children();
448 QObjectListIt it(*list);
449 SUPERVGUI_CanvasPort* aPort;
450 while (QObject* obj = it.current()) {
452 if (obj->inherits("SUPERVGUI_CanvasPort")) {
453 aPort = (SUPERVGUI_CanvasPort*) obj;
454 if (aPort->getEngine()->IsGate()) {
455 if (aPort->getEngine()->IsInput()) {
456 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
460 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
468 myGateHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
473 QRect SUPERVGUI_CanvasNodePrs::getRect() const
475 return QRect((int)x(), (int)y(), width(), height());
478 QRect SUPERVGUI_CanvasNodePrs::getTitleRect() const
480 return QRect((int)x(), (int)y(), width(), getTitleHeight());
483 QRect SUPERVGUI_CanvasNodePrs::getLabelRect() const
485 return QRect((int)x(), ((int)y())+getTitleHeight(), width(), getLabelHeight());
488 QRect SUPERVGUI_CanvasNodePrs::getStatusRect() const
490 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(),
491 width(), getStatusHeight());
494 QRect SUPERVGUI_CanvasNodePrs::getBodyRect() const
496 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getStatusHeight(),
497 width(), getBodyHeight());
500 QRect SUPERVGUI_CanvasNodePrs::getGateRect() const
502 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+
503 getStatusHeight()+getBodyHeight(),
504 width(), getGateHeight());
507 QPoint SUPERVGUI_CanvasNodePrs::getInConnectionPoint() const
509 QRect r = getGateRect();
511 if (isPortVisible()) {
512 h = (int)((r.top()+r.bottom())/2);
515 h = (int)(y()+height()/2);
517 return QPoint(r.left()-POINT_SIZE, h);
520 QPoint SUPERVGUI_CanvasNodePrs::getOutConnectionPoint() const
522 QRect r = getGateRect();
524 if (isPortVisible()) {
525 h = (int)((r.top()+r.bottom())/2);
528 h = (int)y() + (int)(height()/2);
530 return QPoint(r.right()+POINT_SIZE, h);
533 void drawText(QPainter& thePainter, const QString& theText,
534 const QRect& theRect, int theHAlign = Qt::AlignAuto)
536 int flags = theHAlign | Qt::AlignVCenter;
537 QRect r(theRect.x() + TEXT_MARGIN, theRect.y(),
538 theRect.width() - 2*TEXT_MARGIN, theRect.height());
540 QWMatrix aMat = thePainter.worldMatrix();
541 if (aMat.m11() != 1.0) {
542 // for scaled picture only
543 QRect r1 = aMat.mapRect(r);
544 QFont saved = thePainter.font();
546 if (f.pointSize() == -1) {
547 f.setPixelSize(f.pixelSize()*aMat.m11());
550 f.setPointSize(f.pointSize()*aMat.m11());
554 thePainter.setWorldMatrix(m);
555 thePainter.setFont(f);
556 thePainter.drawText(r1, flags, theText);
557 thePainter.setFont(saved);
558 thePainter.restore();
561 thePainter.drawText(r, flags, theText);
565 void SUPERVGUI_CanvasNodePrs::draw(QPainter& thePainter)
567 thePainter.setPen(pen());
568 thePainter.setBrush(nodeColor());
569 drawShape(thePainter);
572 void SUPERVGUI_CanvasNodePrs::drawShape(QPainter& thePainter)
574 drawTitle(thePainter);
575 if (isLabelVisible()) {
576 drawLabel(thePainter);
578 if (isPortVisible()) {
579 drawPort(thePainter);
580 drawGate(thePainter);
582 drawStatus(thePainter);
583 drawFrame(thePainter);
586 void SUPERVGUI_CanvasNodePrs::drawFrame(QPainter& thePainter)
588 /* it was a good idea, but...
589 drawed polyline is out of item boundaries :-(
590 QPointArray pnts = areaPoints();
594 thePainter.drawPolyline(pnts);
597 QBrush saved = thePainter.brush();
598 thePainter.setBrush(NoBrush);
599 thePainter.drawRect(getRect());
600 thePainter.setBrush(saved);
603 void SUPERVGUI_CanvasNodePrs::drawTitle(QPainter& thePainter)
605 QBrush saved = thePainter.brush();
606 QBrush br(MAIN_TITLE);
607 thePainter.setBrush(br);
608 drawTitleShape(thePainter);
609 thePainter.setBrush(saved);
611 drawText(thePainter, myNode->getEngine()->Name(), getTitleRect(), Qt::AlignHCenter);
614 void SUPERVGUI_CanvasNodePrs::drawTitleShape(QPainter& thePainter)
616 thePainter.drawRect(getTitleRect());
619 void SUPERVGUI_CanvasNodePrs::drawLabel(QPainter& thePainter)
621 QRect r = getLabelRect();
623 QPen saved = thePainter.pen();
624 thePainter.setPen(NoPen);
625 thePainter.drawRect(r);
626 thePainter.setPen(saved);
628 // drawText(thePainter, myNode->getEngine()->Comment(), r);
629 drawText(thePainter, myNode->getLabelText(), r);
632 void SUPERVGUI_CanvasNodePrs::drawStatus(QPainter& thePainter)
634 QRect r = getStatusRect();
636 r.setHeight(r.height()+1);
638 QBrush savedB = thePainter.brush();
639 thePainter.setBrush(myStatusColor);
640 drawStatusShape(thePainter);
641 thePainter.setBrush(savedB);
643 QRect r1(r.x(), r.y(), (int)r.width()/2, r.height());
644 drawText(thePainter, myStatus, r1, Qt::AlignHCenter);
646 QRect r2(r.x()+r.width()-r1.width(), r.y(), r1.width(), r.height());
647 drawText(thePainter, myTime, r2, Qt::AlignHCenter);
650 void SUPERVGUI_CanvasNodePrs::drawStatusShape(QPainter& thePainter)
652 QRect r = getStatusRect();
654 r.setHeight(r.height()+1);
655 thePainter.drawRect(r);
658 void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter)
660 QRect r = getBodyRect();
661 r.setHeight(r.height()+1);
663 thePainter.drawRect(r);
664 int x0 = (r.left() + r.right())/2;
665 thePainter.drawLine(x0, r.top(), x0, r.bottom());
666 if (getStreamHeight() > 0) {
667 int y0 = r.top() + getPortHeight();
668 thePainter.drawLine(r.left(), y0, r.right(), y0);
671 const QObjectList* list = myNode->children();
673 QObjectListIt it(*list);
674 SUPERVGUI_CanvasPort* aPort;
675 while (QObject* obj = it.current()) {
677 if (obj->inherits("SUPERVGUI_CanvasPort")) {
678 aPort = (SUPERVGUI_CanvasPort*) obj;
679 if (!aPort->getEngine()->IsGate()) {
680 aPort->getPrs()->draw(thePainter);
687 void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter)
689 QBrush saved = thePainter.brush();
690 thePainter.setBrush(green.light(170));
692 QRect r = getGateRect();
693 // r.setHeight(r.height()+1);
694 thePainter.drawRect(r);
695 int x0 = (r.left() + r.right())/2;
696 // thePainter.drawLine(x0, r.top(), x0, r.bottom());
698 const QObjectList* list = myNode->children();
700 QObjectListIt it(*list);
701 SUPERVGUI_CanvasPort* aPort;
702 while (QObject* obj = it.current()) {
704 if (obj->inherits("SUPERVGUI_CanvasPort")) {
705 aPort = (SUPERVGUI_CanvasPort*) obj;
706 if (aPort->getEngine()->IsGate()) {
707 aPort->getPrs()->draw(thePainter);
713 thePainter.setBrush(saved);
716 void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState)
720 myStatus = "Waiting";
721 myStatusColor = QColor(35, 192, 255);
725 case SUPERV::ReadyState:
726 myStatus = "Running";
727 myStatusColor = QColor(32,210,32);
731 case SUPERV::SuspendReadyState:
732 myStatus = "Suspended";
733 myStatusColor = QColor(255,180, 0);
737 myStatus = "Finished";
738 myStatusColor = QColor(255, 158, 255);
742 myStatus = "Aborted";
751 case SUPERV::LoadingState:
752 myStatus = "Loading";
753 myStatusColor = QColor(56,255,56);
757 myStatus = "No Status";
758 myStatusColor = MAIN_BACK;
762 long sec = myNode->getEngine()->CpuUsed();
765 hms[0]=(char)(((s/10)%10)+48);
766 hms[1]=(char)((s%10)+48);
770 hms[3]=(char)((s/10)+48);
771 hms[4]=(char)((s%10)+48);
774 hms[6]=(char)((sec/10)+48);
775 hms[7]=(char)((sec%10)+48);
777 myTime = QString(hms);
779 canvas()->setChanged(getStatusRect());
784 //=====================================================================
786 //=====================================================================
787 SUPERVGUI_CanvasPortPrs::SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas,
788 SUPERVGUI_CanvasPort* thePort):
789 myCanvas(theCanvas), myPort(thePort)
793 myPoint = new SUPERVGUI_CanvasHookPrs(theCanvas, this, myPort->getEngine()->IsInput());
796 SUPERVGUI_CanvasPortPrs::~SUPERVGUI_CanvasPortPrs()
798 if (myPoint) delete myPoint;
801 void SUPERVGUI_CanvasPortPrs::setVisible(bool b)
803 if (myPoint) myPoint->setVisible(b);
805 myPort->updateLinks();
808 void SUPERVGUI_CanvasPortPrs::setPortRect(const QRect& theRect)
811 QPoint aPnt = getConnectionPoint();
813 // if (myPort->getEngine()->IsInput())
816 // dx = - POINT_SIZE;
817 // QPoint aPnt2(aPnt.x()+dx, aPnt.y());
820 // myLine->move(0, 0);
821 // myLine->setPoints(aPnt2.x(), aPnt2.y(), aPnt.x(), aPnt.y());
822 // if (myVisible) myLine->show();
825 myPoint->setCoords(aPnt.x(), aPnt.y());
826 // myPoint->move(aPnt.x(), aPnt.y());
827 if (myVisible) myPoint->show();
829 myPort->updateLinks();
832 void SUPERVGUI_CanvasPortPrs::moveBy(int dx, int dy)
834 myRect.moveBy(dx, dy);
835 if (myPoint) myPoint->moveBy(dx, dy);
836 // if (myLine) myLine->moveBy(dx, dy);
839 void SUPERVGUI_CanvasPortPrs::setZ(double z)
841 if (myPoint) myPoint->setZ(z);
842 // if (myLine) myLine->setZ(z);
845 void SUPERVGUI_CanvasPortPrs::update(bool theForce)
847 QString aNewText = getText();
848 if (theForce || myText.compare(aNewText) != 0) {
850 myCanvas->setChanged(myRect);
854 bool SUPERVGUI_CanvasPortPrs::isHilight() const
856 SUPERV_Port aPort = myPort->getEngine();
858 if (!aPort->IsGate()) {
859 if (aPort->IsInput()) {
860 if (aPort->HasInput() && !aPort->IsLinked())
863 else if (myPort->inherits("SUPERVGUI_CanvasPortOut")) {
864 SUPERVGUI_CanvasPortOut* aPortOut = (SUPERVGUI_CanvasPortOut*) myPort;
865 if (aPortOut->isInStudy())
872 bool SUPERVGUI_CanvasPortPrs::isAlert() const
875 SUPERV_Port aPort = myPort->getEngine();
876 if (!aPort->IsGate()) {
877 if (aPort->IsInput() && !aPort->HasInput() && !aPort->IsLinked())
883 QString SUPERVGUI_CanvasPortPrs::getText() const
885 SUPERV_Port aPort = myPort->getEngine();
886 QString aText = aPort->Name();
887 if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream())
888 aText = aText + "=" + aPort->ToString();
892 int SUPERVGUI_CanvasPortPrs::getAlignment() const
894 int a = Qt::AlignAuto;
895 SUPERV_Port aPort = myPort->getEngine();
896 /* Merge to Ecole_Ete
897 if (QString(aPort->Name()).compare(OUTVOID) == 0)
900 if (aPort->IsGate()) {
901 if (aPort->IsInput())
909 QPoint SUPERVGUI_CanvasPortPrs::getConnectionPoint() const
912 if (myPort->getEngine()->IsInput())
913 x = myRect.left() - PORT_MARGIN - POINT_SIZE;
915 x = myRect.right() + PORT_MARGIN + POINT_SIZE;
916 y = (int)(myRect.top() + myRect.bottom())/2;
920 void SUPERVGUI_CanvasPortPrs::draw(QPainter& thePainter)
923 QPen savedP = thePainter.pen();
924 QBrush savedB = thePainter.brush();
926 QPen aPen(savedP.color(), getLineWidth());
927 thePainter.setPen(aPen);
928 thePainter.setBrush(Qt::NoBrush);
929 thePainter.drawRect(myRect);
930 thePainter.setPen(savedP);
931 thePainter.setBrush(savedB);
933 QFont saved = thePainter.font();
935 f.setBold(isHilight());
936 thePainter.setFont(f);
938 QPen savedP = thePainter.pen();
939 if (myPort->isStream())
940 thePainter.setPen(QColor(128, 64, 0));// Qt::darkCyan);
941 else if (isHilight())
942 thePainter.setPen(Qt::blue);
944 thePainter.setPen(Qt::red.dark(120));
946 drawText(thePainter, myText, myRect, getAlignment());
948 thePainter.setPen(savedP);
949 thePainter.setFont(saved);
953 //=====================================================================
955 //=====================================================================
956 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
957 SUPERVGUI_CanvasNodePrs* theNode,
959 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
960 myNodePrs(theNode), myPortPrs(0), myIn(theIn), myLine(0)
965 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
966 SUPERVGUI_CanvasPortPrs* thePort,
968 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
969 myNodePrs(0), myPortPrs(thePort), myIn(theIn), myLine(0)
974 void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas)
976 myLine = new QCanvasLine(theCanvas);
979 myLine->setPen(QPen(Qt::black, 1));
984 SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs()
993 QObject* SUPERVGUI_CanvasHookPrs::getObject() const
997 anObj = myNodePrs->getNode();
999 anObj = myPortPrs->getPort();
1003 void SUPERVGUI_CanvasHookPrs::setCoords(int x, int y)
1008 myLine->setPoints(x+(myIn?POINT_SIZE:-POINT_SIZE), y, x, y);
1012 void SUPERVGUI_CanvasHookPrs::setVisible(bool b)
1014 QCanvasEllipse::setVisible(b);
1015 if (myLine) myLine->setVisible(b);
1018 void SUPERVGUI_CanvasHookPrs::moveBy(double dx, double dy)
1020 QCanvasEllipse::moveBy(dx, dy);
1021 if (myLine) myLine->moveBy(dx, dy);
1024 void SUPERVGUI_CanvasHookPrs::setZ(double z)
1026 QCanvasEllipse::setZ(z);
1027 if (myLine) myLine->setZ(z);
1030 int SUPERVGUI_CanvasHookPrs::rtti() const
1032 return SUPERVGUI_Canvas::Rtti_Hook;