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 setState(myNode->getEngine()->State());
67 SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs()
81 int SUPERVGUI_CanvasNodePrs::rtti() const
83 return SUPERVGUI_Canvas::Rtti_Node;
86 int SUPERVGUI_CanvasNodePrs::width() const
91 int SUPERVGUI_CanvasNodePrs::height() const
93 return getTitleHeight() + getLabelHeight() + getStatusHeight() +
94 getBodyHeight() + getGateHeight();
97 int SUPERVGUI_CanvasNodePrs::getTitleHeight() const
102 int SUPERVGUI_CanvasNodePrs::getLabelHeight() const
104 if (isLabelVisible())
105 return myLabelHeight;
109 int SUPERVGUI_CanvasNodePrs::getStatusHeight() const
111 return myStatusHeight;
114 int SUPERVGUI_CanvasNodePrs::getBodyHeight() const
117 return myPortHeight + myStreamHeight;
121 int SUPERVGUI_CanvasNodePrs::getPortHeight() const
128 int SUPERVGUI_CanvasNodePrs::getStreamHeight() const
131 return myStreamHeight;
135 int SUPERVGUI_CanvasNodePrs::getGateHeight() const
142 QPointArray SUPERVGUI_CanvasNodePrs::areaPoints() const
147 QPointArray aPnts(4);
148 aPnts[0] = QPoint((int)x(), (int)y());
149 aPnts[1] = aPnts[0] + QPoint(w, 0);
150 aPnts[2] = aPnts[1] + QPoint(0, h);
151 aPnts[3] = aPnts[0] + QPoint(0, h);
155 QObject* SUPERVGUI_CanvasNodePrs::getObject(const QPoint& thePos) const
157 QObject* anObj = myNode;
159 // check if it's a port
160 const QObjectList* list = myNode->children();
162 QObjectListIt it(*list);
163 SUPERVGUI_CanvasPort* aPort;
164 while (QObject* obj = it.current()) {
166 if (obj->inherits("SUPERVGUI_CanvasPort")) {
167 aPort = (SUPERVGUI_CanvasPort*) obj;
168 if (aPort->getPrs()->getPortRect().contains(thePos, true)) {
178 void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy)
180 int aX = (int) (x()+dx);
181 int aY = (int) (y()+dy);
182 int xx = aX - (int)x();
183 int yy = aY - (int)y();
185 int w = aX + width() + GRAPH_MARGIN;
186 int h = aY + height() + GRAPH_MARGIN;
187 if (canvas()->width() > w) w = canvas()->width();
188 if (canvas()->height() > h) h = canvas()->height();
189 if (canvas()->width() < w || canvas()->height() < h)
190 canvas()->resize(w, h);
192 // save new coordinates only if node is really moving...
194 myNode->getEngine()->Coords(aX, aY);
197 QCanvasPolygonalItem::moveBy(dx, dy);
199 // update port's rectangle
200 const QObjectList* list = myNode->children();
202 QObjectListIt it(*list);
203 SUPERVGUI_CanvasPort* aPort;
204 while (QObject* obj = it.current()) {
206 if (obj->inherits("SUPERVGUI_CanvasPort")) {
207 aPort = (SUPERVGUI_CanvasPort*) obj;
208 aPort->moveBy(xx, yy);
214 myPointIn->moveBy(dx, dy);
215 myPointOut->moveBy(dx, dy);
219 void SUPERVGUI_CanvasNodePrs::setZ(double z)
221 QCanvasItem::setZ(z);
224 const QObjectList* list = myNode->children();
226 QObjectListIt it(*list);
227 SUPERVGUI_CanvasPort* aPort;
228 while (QObject* obj = it.current()) {
230 if (obj->inherits("SUPERVGUI_CanvasPort")) {
231 aPort = (SUPERVGUI_CanvasPort*) obj;
232 aPort->getPrs()->setZ(z);
238 void SUPERVGUI_CanvasNodePrs::hideAll()
240 bool aDisp = isVisible();
243 setLabelVisible(false);
244 setPortVisible(false);
248 // canvas()->update();
252 void SUPERVGUI_CanvasNodePrs::showAll()
254 bool aDisp = isVisible();
257 setLabelVisible(true);
258 setPortVisible(true);
262 // canvas()->update();
266 void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b)
268 bool aDisp = isVisible();
273 if (!isPortVisible() && !myCellPrs) updatePoints();
281 void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b)
283 bool aDisp = isVisible();
304 const QObjectList* list = myNode->children();
306 QObjectListIt it(*list);
307 SUPERVGUI_CanvasPort* aPort;
308 while (QObject* obj = it.current()) {
310 if (obj->inherits("SUPERVGUI_CanvasPort")) {
311 aPort = (SUPERVGUI_CanvasPort*) obj;
312 aPort->getPrs()->setVisible(b);
323 void SUPERVGUI_CanvasNodePrs::setNodeColor(const QColor& theColor)
326 canvas()->setChanged(getRect());
330 void SUPERVGUI_CanvasNodePrs::updateInfo()
332 canvas()->setChanged(getTitleRect());
333 canvas()->setChanged(getLabelRect()); //node's comment is saved in engine (we can see it only
334 //with help of ChangeInformation dialog),
335 //node's label isn't change
339 void SUPERVGUI_CanvasNodePrs::updatePoints()
341 QPoint in = getInConnectionPoint();
342 myPointIn->setCoords(in.x(), in.y());
344 QPoint out = getOutConnectionPoint();
345 myPointOut->setCoords(out.x(), out.y());
348 void SUPERVGUI_CanvasNodePrs::updatePorts()
350 bool aDisp = isVisible();
353 QRect r = getBodyRect();
354 int w = (int)(r.width()/2) - PORT_MARGIN;
355 if (w < PORT_WIDTH) w = PORT_WIDTH;
357 int ix = r.x() + PORT_MARGIN;
358 int ih = r.y() + PORT_MARGIN;
360 int oh = r.y() + PORT_MARGIN;
362 const QObjectList* list = myNode->children();
364 QObjectListIt it(*list);
365 SUPERVGUI_CanvasPort* aPort;
366 while (QObject* obj = it.current()) {
368 if (obj->inherits("SUPERVGUI_CanvasPort")) {
369 aPort = (SUPERVGUI_CanvasPort*) obj;
370 if (!aPort->getEngine()->IsGate() && !aPort->isStream()) {
371 if (aPort->getEngine()->IsInput()) {
372 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
376 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
384 myPortHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
386 // update stream ports
387 int sy = r.y() + myPortHeight;
388 ih = sy + PORT_MARGIN;
389 oh = sy + PORT_MARGIN;
392 QObjectListIt it(*list);
393 SUPERVGUI_CanvasPort* aPort;
394 while (QObject* obj = it.current()) {
396 if (obj->inherits("SUPERVGUI_CanvasPort")) {
397 aPort = (SUPERVGUI_CanvasPort*) obj;
398 if (!aPort->getEngine()->IsGate() && aPort->isStream()) {
399 if (aPort->getEngine()->IsInput()) {
400 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
404 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
412 myStreamHeight = (ih>oh?ih:oh) - sy + PORT_MARGIN;
413 if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0;
415 // can update gates only after body height will be defined
424 void SUPERVGUI_CanvasNodePrs::updateGates()
426 bool aDisp = isVisible();
429 QRect r = getGateRect();
430 int w = (int)(r.width()/2) - PORT_MARGIN;
431 if (w < PORT_WIDTH) w = PORT_WIDTH;
433 int ix = r.x() + PORT_MARGIN;
434 int ih = r.y() + PORT_MARGIN;
436 int oh = r.y() + PORT_MARGIN;
438 const QObjectList* list = myNode->children();
440 QObjectListIt it(*list);
441 SUPERVGUI_CanvasPort* aPort;
442 while (QObject* obj = it.current()) {
444 if (obj->inherits("SUPERVGUI_CanvasPort")) {
445 aPort = (SUPERVGUI_CanvasPort*) obj;
446 if (aPort->getEngine()->IsGate()) {
447 if (aPort->getEngine()->IsInput()) {
448 aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT));
452 aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT));
460 myGateHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN;
465 QRect SUPERVGUI_CanvasNodePrs::getRect() const
467 return QRect((int)x(), (int)y(), width(), height());
470 QRect SUPERVGUI_CanvasNodePrs::getTitleRect() const
472 return QRect((int)x(), (int)y(), width(), getTitleHeight());
475 QRect SUPERVGUI_CanvasNodePrs::getLabelRect() const
477 return QRect((int)x(), ((int)y())+getTitleHeight(), width(), getLabelHeight());
480 QRect SUPERVGUI_CanvasNodePrs::getStatusRect() const
482 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(),
483 width(), getStatusHeight());
486 QRect SUPERVGUI_CanvasNodePrs::getBodyRect() const
488 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getStatusHeight(),
489 width(), getBodyHeight());
492 QRect SUPERVGUI_CanvasNodePrs::getGateRect() const
494 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+
495 getStatusHeight()+getBodyHeight(),
496 width(), getGateHeight());
499 QPoint SUPERVGUI_CanvasNodePrs::getInConnectionPoint() const
501 QRect r = getGateRect();
503 if (isPortVisible()) {
504 h = (int)((r.top()+r.bottom())/2);
507 h = (int)(y()+height()/2);
509 return QPoint(r.left()-POINT_SIZE, h);
512 QPoint SUPERVGUI_CanvasNodePrs::getOutConnectionPoint() const
514 QRect r = getGateRect();
516 if (isPortVisible()) {
517 h = (int)((r.top()+r.bottom())/2);
520 h = (int)y() + (int)(height()/2);
522 return QPoint(r.right()+POINT_SIZE, h);
525 void drawText(QPainter& thePainter, const QString& theText,
526 const QRect& theRect, int theHAlign = Qt::AlignAuto)
528 int flags = theHAlign | Qt::AlignVCenter;
529 QRect r(theRect.x() + TEXT_MARGIN, theRect.y(),
530 theRect.width() - 2*TEXT_MARGIN, theRect.height());
532 QWMatrix aMat = thePainter.worldMatrix();
533 if (aMat.m11() != 1.0) {
534 // for scaled picture only
535 QRect r1 = aMat.mapRect(r);
536 QFont saved = thePainter.font();
538 if (f.pointSize() == -1) {
539 f.setPixelSize((int)(f.pixelSize()*aMat.m11()));
542 f.setPointSize((int)(f.pointSize()*aMat.m11()));
546 thePainter.setWorldMatrix(m);
547 thePainter.setFont(f);
548 thePainter.drawText(r1, flags, theText);
549 thePainter.setFont(saved);
550 thePainter.restore();
553 thePainter.drawText(r, flags, theText);
557 void SUPERVGUI_CanvasNodePrs::draw(QPainter& thePainter)
559 thePainter.setPen(pen());
560 thePainter.setBrush(nodeColor());
561 drawShape(thePainter);
564 void SUPERVGUI_CanvasNodePrs::drawShape(QPainter& thePainter)
566 drawTitle(thePainter);
567 if (isLabelVisible()) {
568 drawLabel(thePainter);
570 if (isPortVisible()) {
571 drawPort(thePainter);
572 drawGate(thePainter);
574 drawStatus(thePainter);
575 drawFrame(thePainter);
578 void SUPERVGUI_CanvasNodePrs::drawFrame(QPainter& thePainter)
580 /* it was a good idea, but...
581 drawed polyline is out of item boundaries :-(
582 QPointArray pnts = areaPoints();
586 thePainter.drawPolyline(pnts);
589 QBrush saved = thePainter.brush();
590 thePainter.setBrush(NoBrush);
591 thePainter.drawRect(getRect());
592 thePainter.setBrush(saved);
595 void SUPERVGUI_CanvasNodePrs::drawTitle(QPainter& thePainter)
597 QBrush saved = thePainter.brush();
598 QBrush br(MAIN_TITLE);
599 thePainter.setBrush(br);
600 drawTitleShape(thePainter);
601 thePainter.setBrush(saved);
603 drawText(thePainter, myNode->getEngine()->Name(), getTitleRect(), Qt::AlignHCenter);
606 void SUPERVGUI_CanvasNodePrs::drawTitleShape(QPainter& thePainter)
608 thePainter.drawRect(getTitleRect());
611 void SUPERVGUI_CanvasNodePrs::drawLabel(QPainter& thePainter)
613 QRect r = getLabelRect();
615 QPen saved = thePainter.pen();
616 thePainter.setPen(NoPen);
617 thePainter.drawRect(r);
618 thePainter.setPen(saved);
620 // drawText(thePainter, myNode->getEngine()->Comment(), r);
621 drawText(thePainter, myNode->getLabelText(), r);
624 void SUPERVGUI_CanvasNodePrs::drawStatus(QPainter& thePainter)
626 QRect r = getStatusRect();
628 r.setHeight(r.height()+1);
630 QBrush savedB = thePainter.brush();
631 thePainter.setBrush(myStatusColor);
632 drawStatusShape(thePainter);
633 thePainter.setBrush(savedB);
635 QRect r1(r.x(), r.y(), (int)r.width()/2, r.height());
636 drawText(thePainter, myStatus, r1, Qt::AlignHCenter);
638 QRect r2(r.x()+r.width()-r1.width(), r.y(), r1.width(), r.height());
639 drawText(thePainter, myTime, r2, Qt::AlignHCenter);
642 void SUPERVGUI_CanvasNodePrs::drawStatusShape(QPainter& thePainter)
644 QRect r = getStatusRect();
646 r.setHeight(r.height()+1);
647 thePainter.drawRect(r);
650 void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter)
652 QRect r = getBodyRect();
653 r.setHeight(r.height()+1);
655 thePainter.drawRect(r);
656 int x0 = (r.left() + r.right())/2;
657 thePainter.drawLine(x0, r.top(), x0, r.bottom());
658 if (getStreamHeight() > 0) {
659 int y0 = r.top() + getPortHeight();
660 thePainter.drawLine(r.left(), y0, r.right(), y0);
663 const QObjectList* list = myNode->children();
665 QObjectListIt it(*list);
666 SUPERVGUI_CanvasPort* aPort;
667 while (QObject* obj = it.current()) {
669 if (obj->inherits("SUPERVGUI_CanvasPort")) {
670 aPort = (SUPERVGUI_CanvasPort*) obj;
671 if (!aPort->getEngine()->IsGate()) {
672 aPort->getPrs()->draw(thePainter);
679 void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter)
681 QBrush saved = thePainter.brush();
682 thePainter.setBrush(green.light(170));
684 QRect r = getGateRect();
685 // r.setHeight(r.height()+1);
686 thePainter.drawRect(r);
687 //int x0 = (r.left() + r.right())/2;
688 // thePainter.drawLine(x0, r.top(), x0, r.bottom());
690 const QObjectList* list = myNode->children();
692 QObjectListIt it(*list);
693 SUPERVGUI_CanvasPort* aPort;
694 while (QObject* obj = it.current()) {
696 if (obj->inherits("SUPERVGUI_CanvasPort")) {
697 aPort = (SUPERVGUI_CanvasPort*) obj;
698 if (aPort->getEngine()->IsGate()) {
699 aPort->getPrs()->draw(thePainter);
705 thePainter.setBrush(saved);
708 void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState)
712 myStatus = "Waiting";
713 myStatusColor = QColor(35, 192, 255);
717 case SUPERV::ReadyState:
718 myStatus = "Running";
719 myStatusColor = QColor(32,210,32);
723 case SUPERV::SuspendReadyState:
724 myStatus = "Suspended";
725 myStatusColor = QColor(255,180, 0);
729 myStatus = "Finished";
730 myStatusColor = QColor(255, 158, 255);
734 myStatus = "Aborted";
743 case SUPERV::LoadingState:
744 myStatus = "Loading";
745 myStatusColor = QColor(56,255,56);
749 myStatus = "No Status";
750 myStatusColor = MAIN_BACK;
754 long sec = myNode->getEngine()->CpuUsed();
757 hms[0]=(char)(((s/10)%10)+48);
758 hms[1]=(char)((s%10)+48);
762 hms[3]=(char)((s/10)+48);
763 hms[4]=(char)((s%10)+48);
766 hms[6]=(char)((sec/10)+48);
767 hms[7]=(char)((sec%10)+48);
769 myTime = QString(hms);
771 canvas()->setChanged(getStatusRect());
776 //=====================================================================
778 //=====================================================================
779 SUPERVGUI_CanvasPortPrs::SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas,
780 SUPERVGUI_CanvasPort* thePort):
781 myCanvas(theCanvas), myPort(thePort)
785 myPoint = new SUPERVGUI_CanvasHookPrs(theCanvas, this, myPort->getEngine()->IsInput());
788 SUPERVGUI_CanvasPortPrs::~SUPERVGUI_CanvasPortPrs()
790 if (myPoint) delete myPoint;
793 void SUPERVGUI_CanvasPortPrs::setVisible(bool b)
795 if (myPoint) myPoint->setVisible(b);
797 myPort->updateLinks();
800 void SUPERVGUI_CanvasPortPrs::setPortRect(const QRect& theRect)
803 QPoint aPnt = getConnectionPoint();
805 // if (myPort->getEngine()->IsInput())
808 // dx = - POINT_SIZE;
809 // QPoint aPnt2(aPnt.x()+dx, aPnt.y());
812 // myLine->move(0, 0);
813 // myLine->setPoints(aPnt2.x(), aPnt2.y(), aPnt.x(), aPnt.y());
814 // if (myVisible) myLine->show();
817 myPoint->setCoords(aPnt.x(), aPnt.y());
818 // myPoint->move(aPnt.x(), aPnt.y());
819 if (myVisible) myPoint->show();
821 myPort->updateLinks();
824 void SUPERVGUI_CanvasPortPrs::moveBy(int dx, int dy)
826 myRect.moveBy(dx, dy);
827 if (myPoint) myPoint->moveBy(dx, dy);
828 // if (myLine) myLine->moveBy(dx, dy);
831 void SUPERVGUI_CanvasPortPrs::setZ(double z)
833 if (myPoint) myPoint->setZ(z);
834 // if (myLine) myLine->setZ(z);
837 void SUPERVGUI_CanvasPortPrs::update(bool theForce)
839 QString aNewText = getText();
840 if (theForce || myText.compare(aNewText) != 0) {
842 myCanvas->setChanged(myRect);
846 bool SUPERVGUI_CanvasPortPrs::isHilight() const
848 SUPERV_Port aPort = myPort->getEngine();
850 if (!aPort->IsGate()) {
851 if (aPort->IsInput()) {
852 if (aPort->HasInput() && !aPort->IsLinked())
855 else if (myPort->inherits("SUPERVGUI_CanvasPortOut")) {
856 SUPERVGUI_CanvasPortOut* aPortOut = (SUPERVGUI_CanvasPortOut*) myPort;
857 if (aPortOut->isInStudy())
864 bool SUPERVGUI_CanvasPortPrs::isAlert() const
867 SUPERV_Port aPort = myPort->getEngine();
868 if (!aPort->IsGate()) {
869 if (aPort->IsInput() && !aPort->HasInput() && !aPort->IsLinked())
875 QString SUPERVGUI_CanvasPortPrs::getText() const
877 SUPERV_Port aPort = myPort->getEngine();
878 QString aText = aPort->Name();
879 if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream())
880 aText = aText + "=" + aPort->ToString();
884 int SUPERVGUI_CanvasPortPrs::getAlignment() const
886 int a = Qt::AlignAuto;
887 SUPERV_Port aPort = myPort->getEngine();
888 /* Merge to Ecole_Ete
889 if (QString(aPort->Name()).compare(OUTVOID) == 0)
892 if (aPort->IsGate()) {
893 if (aPort->IsInput())
901 QPoint SUPERVGUI_CanvasPortPrs::getConnectionPoint() const
904 if (myPort->getEngine()->IsInput())
905 x = myRect.left() - PORT_MARGIN - POINT_SIZE;
907 x = myRect.right() + PORT_MARGIN + POINT_SIZE;
908 y = (int)(myRect.top() + myRect.bottom())/2;
912 void SUPERVGUI_CanvasPortPrs::draw(QPainter& thePainter)
915 QPen savedP = thePainter.pen();
916 QBrush savedB = thePainter.brush();
918 QPen aPen(savedP.color(), getLineWidth());
919 thePainter.setPen(aPen);
920 thePainter.setBrush(Qt::NoBrush);
921 thePainter.drawRect(myRect);
922 thePainter.setPen(savedP);
923 thePainter.setBrush(savedB);
925 QFont saved = thePainter.font();
927 f.setBold(isHilight());
928 thePainter.setFont(f);
930 QPen savedP = thePainter.pen();
931 if (myPort->isStream())
932 thePainter.setPen(QColor(128, 64, 0));// Qt::darkCyan);
933 else if (isHilight())
934 thePainter.setPen(Qt::blue);
936 thePainter.setPen(Qt::red.dark(120));
938 drawText(thePainter, myText, myRect, getAlignment());
940 thePainter.setPen(savedP);
941 thePainter.setFont(saved);
945 //=====================================================================
947 //=====================================================================
948 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
949 SUPERVGUI_CanvasNodePrs* theNode,
951 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
952 myNodePrs(theNode), myPortPrs(0), myIn(theIn), myLine(0)
957 SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas,
958 SUPERVGUI_CanvasPortPrs* thePort,
960 QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas),
961 myNodePrs(0), myPortPrs(thePort), myIn(theIn), myLine(0)
966 void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas)
968 myLine = new QCanvasLine(theCanvas);
971 myLine->setPen(QPen(Qt::black, 1));
976 SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs()
985 QObject* SUPERVGUI_CanvasHookPrs::getObject() const
989 anObj = myNodePrs->getNode();
990 else if ( myPortPrs )
991 anObj = myPortPrs->getPort();
995 void SUPERVGUI_CanvasHookPrs::setCoords(int x, int y)
1000 myLine->setPoints(x+(myIn?POINT_SIZE:-POINT_SIZE), y, x, y);
1004 void SUPERVGUI_CanvasHookPrs::setVisible(bool b)
1006 QCanvasEllipse::setVisible(b);
1007 if (myLine) myLine->setVisible(b);
1010 void SUPERVGUI_CanvasHookPrs::moveBy(double dx, double dy)
1012 QCanvasEllipse::moveBy(dx, dy);
1013 if (myLine) myLine->moveBy(dx, dy);
1016 void SUPERVGUI_CanvasHookPrs::setZ(double z)
1018 QCanvasEllipse::setZ(z);
1019 if (myLine) myLine->setZ(z);
1022 int SUPERVGUI_CanvasHookPrs::rtti() const
1024 return SUPERVGUI_Canvas::Rtti_Hook;