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"
16 #include "SUIT_ResourceMgr.h"
21 #include <sys/timeb.h>
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", "Background", 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 drawShape(thePainter);
567 void SUPERVGUI_CanvasNodePrs::drawShape(QPainter& thePainter)
569 drawTitle(thePainter);
570 if (isLabelVisible()) {
571 drawLabel(thePainter);
573 if (isPortVisible()) {
574 drawPort(thePainter);
575 drawGate(thePainter);
577 drawStatus(thePainter);
578 drawFrame(thePainter);
581 void SUPERVGUI_CanvasNodePrs::drawFrame(QPainter& thePainter)
583 /* it was a good idea, but...
584 drawed polyline is out of item boundaries :-(
585 QPointArray pnts = areaPoints();
589 thePainter.drawPolyline(pnts);
592 QBrush saved = thePainter.brush();
593 thePainter.setBrush(NoBrush);
594 thePainter.drawRect(getRect());
595 thePainter.setBrush(saved);
598 void SUPERVGUI_CanvasNodePrs::drawTitle(QPainter& thePainter)
600 QBrush saved = thePainter.brush();
601 QBrush br( myMgr->colorValue( "SUPERVGraph", "Title", DEF_MAIN_TITLE ) );
602 thePainter.setBrush(br);
603 drawTitleShape(thePainter);
604 thePainter.setBrush(saved);
606 drawText(thePainter, myNode->getEngine()->Name(), getTitleRect(), Qt::AlignHCenter);
609 void SUPERVGUI_CanvasNodePrs::drawTitleShape(QPainter& thePainter)
611 thePainter.drawRect(getTitleRect());
614 void SUPERVGUI_CanvasNodePrs::drawLabel(QPainter& thePainter)
616 QRect r = getLabelRect();
618 QPen saved = thePainter.pen();
619 thePainter.setPen(NoPen);
620 thePainter.drawRect(r);
621 thePainter.setPen(saved);
623 // drawText(thePainter, myNode->getEngine()->Comment(), r);
624 drawText(thePainter, myNode->getLabelText(), r);
627 void SUPERVGUI_CanvasNodePrs::drawStatus(QPainter& thePainter)
629 QRect r = getStatusRect();
631 r.setHeight(r.height()+1);
633 QBrush savedB = thePainter.brush();
634 thePainter.setBrush(myStatusColor);
635 drawStatusShape(thePainter);
636 thePainter.setBrush(savedB);
638 QRect r1(r.x(), r.y(), (int)r.width()/2, r.height());
639 drawText(thePainter, myStatus, r1, Qt::AlignHCenter);
641 QRect r2(r.x()+r.width()-r1.width(), r.y(), r1.width(), r.height());
642 drawText(thePainter, myTime, r2, Qt::AlignHCenter);
645 void SUPERVGUI_CanvasNodePrs::drawStatusShape(QPainter& thePainter)
647 QRect r = getStatusRect();
649 r.setHeight(r.height()+1);
650 thePainter.drawRect(r);
653 void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter)
655 QRect r = getBodyRect();
656 r.setHeight(r.height()+1);
658 thePainter.drawRect(r);
659 int x0 = (r.left() + r.right())/2;
660 thePainter.drawLine(x0, r.top(), x0, r.bottom());
661 if (getStreamHeight() > 0) {
662 int y0 = r.top() + getPortHeight();
663 thePainter.drawLine(r.left(), y0, r.right(), y0);
666 const QObjectList* list = myNode->children();
668 QObjectListIt it(*list);
669 SUPERVGUI_CanvasPort* aPort;
670 while (QObject* obj = it.current()) {
672 if (obj->inherits("SUPERVGUI_CanvasPort")) {
673 aPort = (SUPERVGUI_CanvasPort*) obj;
674 if (!aPort->getEngine()->IsGate()) {
675 aPort->getPrs()->draw(thePainter);
682 void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter)
684 QBrush saved = thePainter.brush();
685 thePainter.setBrush(green.light(170));
687 QRect r = getGateRect();
688 // r.setHeight(r.height()+1);
689 thePainter.drawRect(r);
690 //int x0 = (r.left() + r.right())/2;
691 // thePainter.drawLine(x0, r.top(), x0, r.bottom());
693 const QObjectList* list = myNode->children();
695 QObjectListIt it(*list);
696 SUPERVGUI_CanvasPort* aPort;
697 while (QObject* obj = it.current()) {
699 if (obj->inherits("SUPERVGUI_CanvasPort")) {
700 aPort = (SUPERVGUI_CanvasPort*) obj;
701 if (aPort->getEngine()->IsGate()) {
702 aPort->getPrs()->draw(thePainter);
708 thePainter.setBrush(saved);
711 void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState)
715 myStatus = "Waiting";
716 myStatusColor = QColor(35, 192, 255);
720 case SUPERV::ReadyState:
721 myStatus = "Running";
722 myStatusColor = QColor(32,210,32);
726 case SUPERV::SuspendReadyState:
727 myStatus = "Suspended";
728 myStatusColor = QColor(255,180, 0);
732 myStatus = "Finished";
733 myStatusColor = QColor(255, 158, 255);
737 myStatus = "Aborted";
746 case SUPERV::LoadingState:
747 myStatus = "Loading";
748 myStatusColor = QColor(56,255,56);
752 myStatus = "No Status";
753 myStatusColor = myMgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_BACK );
757 long sec = myNode->getEngine()->CpuUsed();
760 hms[0]=(char)(((s/10)%10)+48);
761 hms[1]=(char)((s%10)+48);
765 hms[3]=(char)((s/10)+48);
766 hms[4]=(char)((s%10)+48);
769 hms[6]=(char)((sec/10)+48);
770 hms[7]=(char)((sec%10)+48);
772 myTime = QString(hms);
774 canvas()->setChanged(getStatusRect());
779 //=====================================================================
781 //=====================================================================
782 SUPERVGUI_CanvasPortPrs::SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas,
783 SUPERVGUI_CanvasPort* thePort):
784 myCanvas(theCanvas), myPort(thePort)
788 myPoint = new SUPERVGUI_CanvasHookPrs(theCanvas, this, myPort->getEngine()->IsInput());
791 SUPERVGUI_CanvasPortPrs::~SUPERVGUI_CanvasPortPrs()
793 if (myPoint) delete myPoint;
796 void SUPERVGUI_CanvasPortPrs::setVisible(bool b)
798 if (myPoint) myPoint->setVisible(b);
800 myPort->updateLinks();
803 void SUPERVGUI_CanvasPortPrs::setPortRect(const QRect& theRect)
806 QPoint aPnt = getConnectionPoint();
808 // if (myPort->getEngine()->IsInput())
811 // dx = - POINT_SIZE;
812 // QPoint aPnt2(aPnt.x()+dx, aPnt.y());
815 // myLine->move(0, 0);
816 // myLine->setPoints(aPnt2.x(), aPnt2.y(), aPnt.x(), aPnt.y());
817 // if (myVisible) myLine->show();
820 myPoint->setCoords(aPnt.x(), aPnt.y());
821 // myPoint->move(aPnt.x(), aPnt.y());
822 if (myVisible) myPoint->show();
824 myPort->updateLinks();
827 void SUPERVGUI_CanvasPortPrs::moveBy(int dx, int dy)
829 myRect.moveBy(dx, dy);
830 if (myPoint) myPoint->moveBy(dx, dy);
831 // if (myLine) myLine->moveBy(dx, dy);
834 void SUPERVGUI_CanvasPortPrs::setZ(double z)
836 if (myPoint) myPoint->setZ(z);
837 // if (myLine) myLine->setZ(z);
840 void SUPERVGUI_CanvasPortPrs::update(bool theForce)
842 QString aNewText = getText();
843 if (theForce || myText.compare(aNewText) != 0) {
845 myCanvas->setChanged(myRect);
849 bool SUPERVGUI_CanvasPortPrs::isHilight() const
851 SUPERV_Port aPort = myPort->getEngine();
853 if (!aPort->IsGate()) {
854 if (aPort->IsInput()) {
855 if (aPort->HasInput() && !aPort->IsLinked())
858 else if (myPort->inherits("SUPERVGUI_CanvasPortOut")) {
859 SUPERVGUI_CanvasPortOut* aPortOut = (SUPERVGUI_CanvasPortOut*) myPort;
860 if (aPortOut->isInStudy())
867 bool SUPERVGUI_CanvasPortPrs::isAlert() const
870 SUPERV_Port aPort = myPort->getEngine();
871 if (!aPort->IsGate()) {
872 if (aPort->IsInput() && !aPort->HasInput() && !aPort->IsLinked())
878 QString SUPERVGUI_CanvasPortPrs::getText() const
880 SUPERV_Port aPort = myPort->getEngine();
881 QString aText = aPort->Name();
882 if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream())
883 aText = aText + "=" + aPort->ToString();
887 int SUPERVGUI_CanvasPortPrs::getAlignment() const
889 int a = Qt::AlignAuto;
890 SUPERV_Port aPort = myPort->getEngine();
891 /* Merge to Ecole_Ete
892 if (QString(aPort->Name()).compare(OUTVOID) == 0)
895 if (aPort->IsGate()) {
896 if (aPort->IsInput())
904 QPoint SUPERVGUI_CanvasPortPrs::getConnectionPoint() const
907 if (myPort->getEngine()->IsInput())
908 x = myRect.left() - PORT_MARGIN - POINT_SIZE;
910 x = myRect.right() + PORT_MARGIN + POINT_SIZE;
911 y = (int)(myRect.top() + myRect.bottom())/2;
915 void SUPERVGUI_CanvasPortPrs::draw(QPainter& thePainter)
918 QPen savedP = thePainter.pen();
919 QBrush savedB = thePainter.brush();
921 QPen aPen(savedP.color(), getLineWidth());
922 thePainter.setPen(aPen);
923 thePainter.setBrush(Qt::NoBrush);
924 thePainter.drawRect(myRect);
925 thePainter.setPen(savedP);
926 thePainter.setBrush(savedB);
928 QFont saved = thePainter.font();
930 f.setBold(isHilight());
931 thePainter.setFont(f);
933 QPen savedP = thePainter.pen();
934 if (myPort->isStream())
935 thePainter.setPen(QColor(128, 64, 0));// Qt::darkCyan);
936 else if (isHilight())
937 thePainter.setPen(Qt::blue);
939 thePainter.setPen(Qt::red.dark(120));
941 drawText(thePainter, myText, myRect, getAlignment());
943 thePainter.setPen(savedP);
944 thePainter.setFont(saved);
948 //=====================================================================
950 //=====================================================================
951 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
952 SUPERVGUI_CanvasNodePrs* theNode,
954 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
955 myNodePrs(theNode), myPortPrs(0), myIn(theIn), myLine(0)
960 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
961 SUPERVGUI_CanvasPortPrs* thePort,
963 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
964 myNodePrs(0), myPortPrs(thePort), myIn(theIn), myLine(0)
969 void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas)
971 myLine = new QCanvasLine(theCanvas);
974 myLine->setPen(QPen(Qt::black, 1));
979 SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs()
988 QObject* SUPERVGUI_CanvasHookPrs::getObject() const
992 anObj = myNodePrs->getNode();
993 else if ( myPortPrs )
994 anObj = myPortPrs->getPort();
998 void SUPERVGUI_CanvasHookPrs::setCoords(int x, int y)
1003 myLine->setPoints(x+(myIn?POINT_SIZE:-POINT_SIZE), y, x, y);
1007 void SUPERVGUI_CanvasHookPrs::setVisible(bool b)
1009 QCanvasEllipse::setVisible(b);
1010 if (myLine) myLine->setVisible(b);
1013 void SUPERVGUI_CanvasHookPrs::moveBy(double dx, double dy)
1015 QCanvasEllipse::moveBy(dx, dy);
1016 if (myLine) myLine->moveBy(dx, dy);
1019 void SUPERVGUI_CanvasHookPrs::setZ(double z)
1021 QCanvasEllipse::setZ(z);
1022 if (myLine) myLine->setZ(z);
1025 int SUPERVGUI_CanvasHookPrs::rtti() const
1027 return SUPERVGUI_Canvas::Rtti_Hook;