1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SUPERVGUI_CanvasView.cxx
8 // Author : Natalia KOPNOVA
13 #include "SUPERVGUI_CanvasView.h"
14 #include "SUPERVGUI_Main.h"
15 #include "SUPERVGUI_CanvasNode.h"
16 #include "SUPERVGUI_CanvasPort.h"
17 #include "SUPERVGUI_CanvasLink.h"
18 #include "SUPERVGUI_CanvasNodePrs.h"
19 #include "SUPERVGUI_Clipboard.h"
21 #include "SUIT_MessageBox.h"
24 #include <qcolordialog.h>
30 const char* imageZoomCursor[] = {
35 "................................",
36 "................................",
37 ".#######........................",
38 "..aaaaaaa.......................",
39 "................................",
40 ".............#####..............",
41 "...........##.aaaa##............",
42 "..........#.aa.....a#...........",
43 ".........#.a.........#..........",
44 ".........#a..........#a.........",
45 "........#.a...........#.........",
46 "........#a............#a........",
47 "........#a............#a........",
48 "........#a............#a........",
49 "........#a............#a........",
50 ".........#...........#.a........",
51 ".........#a..........#a.........",
52 ".........##.........#.a.........",
53 "........#####.....##.a..........",
54 ".......###aaa#####.aa...........",
55 "......###aa...aaaaa.......#.....",
56 ".....###aa................#a....",
57 "....###aa.................#a....",
58 "...###aa...............#######..",
59 "....#aa.................aa#aaaa.",
60 ".....a....................#a....",
61 "..........................#a....",
62 "...........................a....",
63 "................................",
64 "................................",
65 "................................",
66 "................................"};
68 QPixmap zoomPix(imageZoomCursor);
69 QCursor zoom2Cursor(zoomPix);
70 QCursor handCursor(Qt::PointingHandCursor);
72 #if QT_VERSION >= 0x030005
73 QCursor pan2Cursor(Qt::SizeAllCursor);
75 QCursor pan2Cursor(SizeAllCursor);
78 SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGUI_Main* theMain):
79 QCanvasView(theCanvas, theMain),
80 myMain(theMain), myCurrentItem(0), myHilighted(0), myLinkBuilder(0)
82 setName("CanvasView");
84 myIsPanBtnClicked = false;
85 myIsPanActivated = false;
86 myIsFitWRActivated = false;
87 myIsZoomActivated = false;
88 myIsLinkCreating = false;
94 myTimer = new QTimer(this);
95 connect(myTimer, SIGNAL(timeout()), this, SLOT(onTimeout()));
97 myPopup = new QPopupMenu(viewport());
99 const bool isEdit = myMain->isEditable();
101 myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode()));
103 // Paste Node functionality
104 SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
105 myPasteNodeItem = myPopup->insertItem(tr("ITM_PASTE_NODE"), aCB, SLOT(pasteNode()));
107 myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile()));
108 myPopup->insertSeparator();
111 QPopupMenu* aViewPopup = new QPopupMenu(viewport());
112 aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas()));
113 aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow()));
114 aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showCanvasTable()));
116 myPopup->insertItem(tr("POP_VIEW"), aViewPopup);
117 myPopup->insertSeparator();
119 QPopupMenu* aZoomPopup = new QPopupMenu(viewport());
120 aZoomPopup->insertItem("200%", this, SLOT(zoomIn()));
121 aZoomPopup->insertItem("100%", this, SLOT(zoomReset()));
122 aZoomPopup->insertItem("50%", this, SLOT(zoomOut()));
123 aZoomPopup->insertSeparator();
124 //mkr: "Fit within rectangle" functionality
125 aZoomPopup->insertItem(tr("POP_FITWITHINRECT"), this, SLOT(fitWithinRect()));
126 aZoomPopup->insertSeparator();
127 aZoomPopup->insertItem(tr("POP_FITALL"), this, SLOT(fitAll()));
130 myPopup->insertItem(tr("POP_ZOOM"), aZoomPopup);
131 myPopup->insertSeparator();
133 myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), myMain, SLOT(addDataflowToStudy()));
134 myPopup->insertItem(tr(isEdit ? "MSG_CHANGE_INFO" : "MSG_INFO"), myMain, SLOT(changeInformation()));
135 myPopup->insertSeparator();
137 myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), myMain, SLOT(copy()));
138 myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), myMain, SLOT(filterNotification()));
140 myPopup->insertSeparator();
141 myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground()));
143 viewport()->setMouseTracking(true);
145 //create sketching popup menu
146 mySketchPopup = new QPopupMenu(viewport());
147 mySketchPopup->setCheckable(true);
148 myDelPntItem = mySketchPopup->insertItem(tr("MSG_DEL_LAST_PNT"), this, SLOT(deletePoint()));
149 mySketchPopup->insertItem(tr("MSG_DEL_LINK"), this, SLOT(cancelSketch()));
150 myOrtoItem = mySketchPopup->insertItem(tr("MSG_ORTHO_LINE"), this, SLOT(setOrthoMode()));
153 // add "change dataflow parameters" popup item
154 myPopup->insertSeparator();
155 myDSParamsItem = myPopup->insertItem( tr( "MSG_SET_GRAPHPARAMS" ), myMain, SLOT( changeDSGraphParameters() ) );
159 SUPERVGUI_CanvasView::~SUPERVGUI_CanvasView()
163 void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
165 myPoint = inverseWorldMatrix().map(theEvent->pos());
166 myGlobalPoint = theEvent->globalPos();
169 // compute collision rectangle
170 QRect aSel(myPoint.x()-MARGIN, myPoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
172 if (((theEvent->button() == Qt::MidButton) &&
173 (theEvent->state() == Qt::ControlButton)) ||
175 myIsPanActivated = true;
177 setCursor(pan2Cursor);
181 if (((theEvent->button() == Qt::LeftButton) &&
182 (theEvent->state() == Qt::ControlButton)) ||
184 myIsZoomActivated = true;
186 setCursor(zoom2Cursor);
190 if ( theEvent->button() == Qt::RightButton) {
191 if (myIsLinkCreating) {
192 myMain->showPopup(mySketchPopup, theEvent);
196 QCanvasItemList l = canvas()->collisions(aSel);
197 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
198 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
199 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
200 QObject* anObj = aNodePrs->getObject(myPoint);
201 if (anObj->inherits("SUPERVGUI_CanvasNode")) {
202 myMain->showPopup(((SUPERVGUI_CanvasNode*)anObj)->getPopupMenu(viewport()),
206 else if (anObj->inherits("SUPERVGUI_CanvasPort")) {
207 myMain->showPopup(((SUPERVGUI_CanvasPort*)anObj)->getPopupMenu(viewport()),
212 if (myMain->isEditable() && !myMain->getCanvas()->isControlView()) {
213 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
214 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
215 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
216 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
219 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
220 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
221 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
222 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
228 myPopup->setItemEnabled(myAddStudyItem, !myMain->isDataflowInStudy());
229 // Paste Node functionality
230 SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
231 myPopup->setItemEnabled(myPasteNodeItem, aCB->isCopyNode() );
233 myPopup->setItemEnabled( myDSParamsItem, isHavingStreamPort()/*myMain->getDataflow()->IsStreamGraph()*/ );
235 myMain->showPopup(myPopup, theEvent);
239 if (theEvent->button() == Qt::LeftButton) {
240 if (!myIsFitWRActivated) {//not moving items if fit within rectangle
241 //functionality is enable
242 QCanvasItemList l = canvas()->collisions(myPoint);
243 if (myIsLinkCreating) {
244 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
245 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
246 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
247 QObject* anObj = aNodePrs->getObject(myPoint);
248 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
249 endSketch((SUPERVGUI_CanvasPort*)anObj);
254 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
255 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
259 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) {
260 SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it);
261 QObject* anObj = aHookPrs->getObject();
262 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
263 endSketch((SUPERVGUI_CanvasPort*)anObj);
269 myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem));
271 mySketchPopup->setItemEnabled(myDelPntItem, true);
276 // if (myMain->isEditable()) { // allow to move nodes and link point on imported graph
277 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
278 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
280 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
281 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
284 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
285 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
286 if (aPrs->getIndex() > 0) {
288 aPrs->setMoving(true);
292 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
293 //mkr: for moving segment of link
294 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
295 if (aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->startPoint()
297 aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->endPoint()
299 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->startPoint()
301 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->endPoint()) {
305 aPrs->setMoving(true);
316 void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
321 QPoint p = inverseWorldMatrix().map(theEvent->pos());
322 QPoint g = theEvent->globalPos();
324 if (myTimer->isActive()) myTimer->stop();
326 if (myIsLinkCreating && myLinkBuilder) {
327 myLinkBuilder->setFloatPoint(p);
333 if (myCurrentItem->x() && myCurrentItem->y()) {
334 double cx = myCurrentItem->x() - myPoint.x();
335 double cy = myCurrentItem->y() - myPoint.y();
337 if (p.x()+cx < 0) p.setX(-(int)cx);
338 if (p.y()+cy < 0) p.setY(-(int)cy);
340 myCurrentItem->moveBy(p.x() - myPoint.x(),
341 p.y() - myPoint.y());
345 // scroll contents if mouse is outside
346 QRect r(contentsX(), contentsY(), visibleWidth(), visibleHeight());
347 if (!r.contains(theEvent->pos())) {
349 if (theEvent->pos().x() < r.left()) dx = theEvent->pos().x() - r.left();
350 if (theEvent->pos().x() > r.right()) dx = theEvent->pos().x() - r.right();
351 if (theEvent->pos().y() < r.top()) dy = theEvent->pos().y() - r.top();
352 if (theEvent->pos().y() > r.bottom()) dy = theEvent->pos().y() - r.bottom();
354 // start timer to scroll in silent mode
355 myDX = dx; myDY = dy;
362 if (myIsPanActivated) {
364 scrollBy(myGlobalPoint.x() - g.x(),
365 myGlobalPoint.y() - g.y());
371 if (myIsZoomActivated) {
373 double dx = g.x() - myGlobalPoint.x();
374 double s = 1. + fabs(dx)/10.;
375 if (dx < 0) s = 1./s;
377 QWMatrix m = worldMatrix();
386 //mkr: "Fit within rectangle" functionality
387 if (myIsFitWRActivated) {
388 int aLX, aTY; //left x and top y
389 if (myPoint.x() < p.x()) aLX = myPoint.x();
391 if (myPoint.y() < p.y()) aTY = myPoint.y();
393 QRect aRect(aLX, aTY, abs(myPoint.x()-p.x()), abs(myPoint.y()-p.y()));
394 QCanvasRectangle* aRect1 = new QCanvasRectangle(aRect, canvas());
396 //hide old selected rectangle
398 mySelectedRect->hide();
399 //draw new selected rectangle
400 QPen pen(Qt::SolidLine);
406 mySelectedRect = aRect1;
410 if (!myIsLinkCreating && myMain->isEditable() &&
411 !myMain->getCanvas()->isControlView()) {
412 // compute collision rectangle
413 QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
414 QCanvasItemList l = canvas()->collisions(aSel);
415 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
416 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
417 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
418 setHilighted(aPrs->getLink());
422 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
423 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
424 setHilighted(aPrs->getLink());
435 void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
437 if (myTimer->isActive()) myTimer->stop();
440 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
441 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(0);
442 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(false);
445 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
446 ((SUPERVGUI_CanvasPointPrs*)myCurrentItem)->setMoving(false);
451 if (myIsPanActivated) {
452 myIsPanActivated = false;
453 myIsPanBtnClicked = false;
457 if (myIsZoomActivated) {
458 myIsZoomActivated = false;
462 //mkr: "Fit within rectangle" functionality
463 if (myIsFitWRActivated) {
464 if (mySelectedRect) {
465 mySelectedRect->hide();
470 //myPoint is the start point for selecting rectangle now
471 QPoint anEndPoint = inverseWorldMatrix().map(theEvent->pos());
472 int aLX, aTY; //left x and top y
473 if (myPoint.x() < anEndPoint.x()) aLX = myPoint.x();
474 else aLX = anEndPoint.x();
475 if (myPoint.y() < anEndPoint.y()) aTY = myPoint.y();
476 else aTY = anEndPoint.y();
478 //calculate width and height for new view and new zoom factor
479 double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-anEndPoint.x())));
480 double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-anEndPoint.y())));
481 if (aXzoom > aYzoom) aXzoom = aYzoom;
484 m.scale(aXzoom, aXzoom);
486 setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom));
490 myIsFitWRActivated = false;
491 viewport()->setMouseTracking(true);
496 void SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
498 QPoint p = inverseWorldMatrix().map(theEvent->pos());
500 // compute collision rectangle
501 //QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
503 if (theEvent->button() == Qt::LeftButton) {
504 QCanvasItemList l = canvas()->collisions(p);
505 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
506 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
507 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
508 SUPERVGUI_CanvasNode* aNode = aNodePrs->getNode();
509 if (aNode->getEngine()->IsMacro() && !myIsLinkCreating) {
510 myMain->openSubGraph(aNode->getEngine(), true);
518 void SUPERVGUI_CanvasView::onDestroyed(QObject* theObject)
520 if (theObject == myHilighted)
524 void SUPERVGUI_CanvasView::setHilighted(SUPERVGUI_CanvasLink* theLink)
526 if (theLink == myHilighted) return;
528 disconnect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
529 myHilighted->setHilighted(false);
533 myHilighted = theLink;
534 myHilighted->setHilighted(true);
535 connect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
539 void SUPERVGUI_CanvasView::onTimeout()
542 scrollBy(myDX, myDY);
545 inverseWorldMatrix().map((double)myDX, (double)myDY, &cx, &cy);
546 if (myCurrentItem->x()+cx < 0) cx = -myCurrentItem->x();
547 if (myCurrentItem->y()+cy < 0) cy = -myCurrentItem->y();
548 myCurrentItem->moveBy(cx, cy);
549 myPoint.setX(myPoint.x()+(int)cx);
550 myPoint.setY(myPoint.y()+(int)cy);
555 void SUPERVGUI_CanvasView::changeBackground()
557 QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this );
558 if ( aColor.isValid() ) {
559 // change background color for canvas view
560 canvas()->setBackgroundColor(aColor);
561 setPaletteBackgroundColor(aColor.light(120));
562 // change background color for array view
563 getMain()->getArrayView()->canvas()->setBackgroundColor(aColor);
564 getMain()->getArrayView()->setPaletteBackgroundColor(aColor.light(120));
568 void SUPERVGUI_CanvasView::ActivatePanning()
570 myIsPanBtnClicked = true;
573 void SUPERVGUI_CanvasView::ResetView()
580 void SUPERVGUI_CanvasView::startSketch(SUPERVGUI_CanvasPort* thePort)
582 if (myIsLinkCreating) return;
584 myIsLinkCreating = true;
585 myLinkBuilder = new SUPERVGUI_CanvasLinkBuilder(canvas(), myMain, thePort);
586 mySketchPopup->setItemEnabled(myDelPntItem, false);
589 void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort)
591 if (!myIsLinkCreating) return;
593 if (myLinkBuilder && myLinkBuilder->canCreateEngine(thePort)) {
594 bool input = thePort->getEngine()->IsInput();
595 SUPERV_Link aLinkEngine;
596 if (thePort->getEngine()->Kind() == SUPERV::DataStreamParameter) {
597 SUPERVGUI_CanvasStreamPortIn* aInPort = (SUPERVGUI_CanvasStreamPortIn*)
598 (input ? thePort : myLinkBuilder->getStartPort());
599 SUPERVGUI_CanvasStreamPortOut* aOutPort = (SUPERVGUI_CanvasStreamPortOut*)
600 (input ? myLinkBuilder->getStartPort() : thePort);
601 // aLinkEngine = myMain->getDataflow()->StreamLink(aOutPort->getStreamEngine(),
602 // aInPort->getStreamEngine());
603 if (myMain->getDataflow()->IsStreamGraph()) {
604 SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph();
605 if (!SUPERV_isNull(aSGraph))
606 aLinkEngine = aSGraph->StreamLink(aOutPort->getStreamEngine(),
607 aInPort->getStreamEngine());
611 SUPERVGUI_CanvasPort* aInPort = (input ? thePort : myLinkBuilder->getStartPort());
612 SUPERVGUI_CanvasPort* aOutPort = (input ? myLinkBuilder->getStartPort() : thePort);
613 aLinkEngine = myMain->getDataflow()->Link(aOutPort->getEngine(), aInPort->getEngine());
615 if (SUPERV_isNull(aLinkEngine))
618 // here, in fact, aLinkEngine may NOT be a newly created link. If a link already existed between the
619 // the 2 given ports - it will be return (NOT created again).
620 // this should be checked and new presentation should NOT be created for existing link.
621 // Solution 1: NOT to allow creation of a link if it already exists between the ports in
622 // myLinkBuilder->canCreateEngine()
623 // Solution 2: check here if aLinkEngine is "new" or "old"
624 // Implement 2nd solution, because canCreateEngine() checks for types of ports, etc.. - it's another thing
626 QObjectList* canvasLinks = canvas()->queryList("SUPERVGUI_CanvasLink");
627 SUPERVGUI_CanvasLink* canvasLink = 0;
628 QObjectListIt it(*canvasLinks);
629 bool prsAlreadyExists = false;
630 while ( (canvasLink=(SUPERVGUI_CanvasLink*)it.current()) ) {
632 SUPERV_Link existingLinkWithPrs = canvasLink->getEngine();
633 if ( !SUPERV_isNull( existingLinkWithPrs ) ) {
634 if ( existingLinkWithPrs->IsEqual( aLinkEngine ) ) {
635 prsAlreadyExists = true;
641 if ( prsAlreadyExists ) { // aLinkEngine is already bound with a SUPERVGUI_CanvasLink object
642 //return; // -> if return here, than the old CanvasLink is kept
644 // we want to delete old and create a new CanvasLink for this Link
647 // clear old corrdinates in Engine link
648 for ( int i = 1; i <= aLinkEngine->CoordsSize(); i++ )
649 aLinkEngine->RemoveCoord( i );
650 // now we are ready to set coords for a link and create a new CanvasLink presentation that will use them.
653 myLinkBuilder->setCoords(aLinkEngine.in());
655 delete myLinkBuilder;
658 SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(canvas(), myMain, aLinkEngine);
662 myIsLinkCreating = false;
664 // asv : 13.12.04 : introducing a check for ports' types compatibility (Bugs and Improvements p.1.16, PAL7380)
665 if ( !aLinkEngine->IsValid() ) {
666 const int id = SUIT_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), tr( "MSG_INVALID_LINK" ),
667 tr( "Keep" ), tr( "Remove" ), 0, 1, 0 );
668 if ( id == 1 ) { // "Remove" was selected in Message Box
669 aLink->remove(); // the new link did not live long...
675 void SUPERVGUI_CanvasView::cancelSketch()
678 delete myLinkBuilder;
682 myIsLinkCreating = false;
685 void SUPERVGUI_CanvasView::deletePoint()
687 if (myIsLinkCreating && myLinkBuilder) {
688 myLinkBuilder->removeLastPoint();
690 mySketchPopup->setItemEnabled(myDelPntItem, myLinkBuilder->getPointCount());
694 void SUPERVGUI_CanvasView::setOrthoMode()
696 bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem);
697 mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho);
700 void SUPERVGUI_CanvasView::zoomIn()
708 void SUPERVGUI_CanvasView::zoomReset()
716 void SUPERVGUI_CanvasView::zoomOut()
724 void SUPERVGUI_CanvasView::fitAll()
727 QCanvasItemList l = canvas()->allItems();
728 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
729 QRect r = (*it)->boundingRect();
730 if (w < r.right()) w = r.right();
731 if (h < r.bottom()) h = r.bottom();
733 w += GRAPH_MARGIN; h += GRAPH_MARGIN;
734 double s = ((double)visibleWidth())/((double)w);
735 double s1 = ((double)visibleHeight())/((double)h);
745 void SUPERVGUI_CanvasView::fitWithinRect()
747 //mkr: "Fit within rectangle" functionality
748 myIsFitWRActivated = true;
749 viewport()->setMouseTracking(false);
751 setCursor(handCursor);
754 bool SUPERVGUI_CanvasView::isHavingStreamPort() const
756 SUPERV::ListOfNodes* aNodesList = myMain->getDataflow()->Nodes();
759 for ( int i = 0 ; i < (int) aNodesList->CNodes.length() ; i++ ) {
760 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->CNodes)[i]->StreamPorts() );
761 if ((int) aStrPortsList.length() > 0) {
767 for ( int i = 0 ; i < (int) aNodesList->FNodes.length() ; i++ ) {
768 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->FNodes)[i]->StreamPorts() );
769 if ((int) aStrPortsList.length() > 0) {
775 for ( int i = 0 ; i < (int) aNodesList->INodes.length() ; i++ ) {
776 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->INodes)[i]->StreamPorts() );
777 if ((int) aStrPortsList.length() > 0) {
783 for ( int i = 0 ; i < (int) aNodesList->GNodes.length() ; i++ ) {
784 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->GNodes)[i]->StreamPorts() );
785 if ((int) aStrPortsList.length() > 0) {
791 for ( int i = 0 ; i < (int) aNodesList->LNodes.length() ; i++ ) {
792 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->LNodes)[i]->StreamPorts() );
793 if ((int) aStrPortsList.length() > 0) {
799 for ( int i = 0 ; i < (int) aNodesList->SNodes.length() ; i++ ) {
800 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->SNodes)[i]->StreamPorts() );
801 if ((int) aStrPortsList.length() > 0) {