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()
161 SUPERVGUI_Clipboard::setNullClipboard();
164 void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
166 myPoint = inverseWorldMatrix().map(theEvent->pos());
167 myGlobalPoint = theEvent->globalPos();
170 // compute collision rectangle
171 QRect aSel(myPoint.x()-MARGIN, myPoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
173 if (((theEvent->button() == Qt::MidButton) &&
174 (theEvent->state() == Qt::ControlButton)) ||
176 myIsPanActivated = true;
178 setCursor(pan2Cursor);
182 if (((theEvent->button() == Qt::LeftButton) &&
183 (theEvent->state() == Qt::ControlButton)) ||
185 myIsZoomActivated = true;
187 setCursor(zoom2Cursor);
191 if ( theEvent->button() == Qt::RightButton) {
192 if (myIsLinkCreating) {
193 myMain->showPopup(mySketchPopup, theEvent);
197 QCanvasItemList l = canvas()->collisions(aSel);
198 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
199 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
200 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
201 QObject* anObj = aNodePrs->getObject(myPoint);
202 if (anObj->inherits("SUPERVGUI_CanvasNode")) {
203 myMain->showPopup(((SUPERVGUI_CanvasNode*)anObj)->getPopupMenu(viewport()),
207 else if (anObj->inherits("SUPERVGUI_CanvasPort")) {
208 myMain->showPopup(((SUPERVGUI_CanvasPort*)anObj)->getPopupMenu(viewport()),
213 if (myMain->isEditable() && !myMain->getCanvas()->isControlView()) {
214 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
215 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
216 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
217 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
220 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
221 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
222 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
223 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
229 myPopup->setItemEnabled(myAddStudyItem, !myMain->isDataflowInStudy());
230 // Paste Node functionality
231 SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
232 myPopup->setItemEnabled(myPasteNodeItem, aCB->isCopyNode() );
234 myPopup->setItemEnabled( myDSParamsItem, isHavingStreamPort()/*myMain->getDataflow()->IsStreamGraph()*/ );
236 myMain->showPopup(myPopup, theEvent);
240 if (theEvent->button() == Qt::LeftButton) {
241 if (!myIsFitWRActivated) {//not moving items if fit within rectangle
242 //functionality is enable
243 QCanvasItemList l = canvas()->collisions(myPoint);
244 if (myIsLinkCreating) {
245 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
246 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
247 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
248 QObject* anObj = aNodePrs->getObject(myPoint);
249 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
250 endSketch((SUPERVGUI_CanvasPort*)anObj);
255 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
256 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
260 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) {
261 SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it);
262 QObject* anObj = aHookPrs->getObject();
263 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
264 endSketch((SUPERVGUI_CanvasPort*)anObj);
270 myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem));
272 mySketchPopup->setItemEnabled(myDelPntItem, true);
277 // if (myMain->isEditable()) { // allow to move nodes and link point on imported graph
278 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
279 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
281 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
282 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
285 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
286 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
287 if (aPrs->getIndex() > 0) {
289 aPrs->setMoving(true);
293 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
294 //mkr: for moving segment of link
295 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
296 if (aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->startPoint()
298 aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->endPoint()
300 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->startPoint()
302 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->endPoint()) {
306 aPrs->setMoving(true);
317 void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
322 QPoint p = inverseWorldMatrix().map(theEvent->pos());
323 QPoint g = theEvent->globalPos();
325 if (myTimer->isActive()) myTimer->stop();
327 if (myIsLinkCreating && myLinkBuilder) {
328 myLinkBuilder->setFloatPoint(p);
334 if (myCurrentItem->x() && myCurrentItem->y()) {
335 double cx = myCurrentItem->x() - myPoint.x();
336 double cy = myCurrentItem->y() - myPoint.y();
338 if (p.x()+cx < 0) p.setX(-(int)cx);
339 if (p.y()+cy < 0) p.setY(-(int)cy);
341 myCurrentItem->moveBy(p.x() - myPoint.x(),
342 p.y() - myPoint.y());
346 // scroll contents if mouse is outside
347 QRect r(contentsX(), contentsY(), visibleWidth(), visibleHeight());
348 if (!r.contains(theEvent->pos())) {
350 if (theEvent->pos().x() < r.left()) dx = theEvent->pos().x() - r.left();
351 if (theEvent->pos().x() > r.right()) dx = theEvent->pos().x() - r.right();
352 if (theEvent->pos().y() < r.top()) dy = theEvent->pos().y() - r.top();
353 if (theEvent->pos().y() > r.bottom()) dy = theEvent->pos().y() - r.bottom();
355 // start timer to scroll in silent mode
356 myDX = dx; myDY = dy;
363 if (myIsPanActivated) {
365 scrollBy(myGlobalPoint.x() - g.x(),
366 myGlobalPoint.y() - g.y());
372 if (myIsZoomActivated) {
374 double dx = g.x() - myGlobalPoint.x();
375 double s = 1. + fabs(dx)/10.;
376 if (dx < 0) s = 1./s;
378 QWMatrix m = worldMatrix();
387 //mkr: "Fit within rectangle" functionality
388 if (myIsFitWRActivated) {
389 int aLX, aTY; //left x and top y
390 if (myPoint.x() < p.x()) aLX = myPoint.x();
392 if (myPoint.y() < p.y()) aTY = myPoint.y();
394 QRect aRect(aLX, aTY, abs(myPoint.x()-p.x()), abs(myPoint.y()-p.y()));
395 QCanvasRectangle* aRect1 = new QCanvasRectangle(aRect, canvas());
397 //hide old selected rectangle
399 mySelectedRect->hide();
400 //draw new selected rectangle
401 QPen pen(Qt::SolidLine);
407 mySelectedRect = aRect1;
411 if (!myIsLinkCreating && myMain->isEditable() &&
412 !myMain->getCanvas()->isControlView()) {
413 // compute collision rectangle
414 QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
415 QCanvasItemList l = canvas()->collisions(aSel);
416 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
417 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
418 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
419 setHilighted(aPrs->getLink());
423 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
424 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
425 setHilighted(aPrs->getLink());
436 void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
438 if (myTimer->isActive()) myTimer->stop();
441 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
442 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(0);
443 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(false);
446 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
447 ((SUPERVGUI_CanvasPointPrs*)myCurrentItem)->setMoving(false);
452 if (myIsPanActivated) {
453 myIsPanActivated = false;
454 myIsPanBtnClicked = false;
458 if (myIsZoomActivated) {
459 myIsZoomActivated = false;
463 //mkr: "Fit within rectangle" functionality
464 if (myIsFitWRActivated) {
465 if (mySelectedRect) {
466 mySelectedRect->hide();
471 //myPoint is the start point for selecting rectangle now
472 QPoint anEndPoint = inverseWorldMatrix().map(theEvent->pos());
473 int aLX, aTY; //left x and top y
474 if (myPoint.x() < anEndPoint.x()) aLX = myPoint.x();
475 else aLX = anEndPoint.x();
476 if (myPoint.y() < anEndPoint.y()) aTY = myPoint.y();
477 else aTY = anEndPoint.y();
479 //calculate width and height for new view and new zoom factor
480 double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-anEndPoint.x())));
481 double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-anEndPoint.y())));
482 if (aXzoom > aYzoom) aXzoom = aYzoom;
485 m.scale(aXzoom, aXzoom);
487 setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom));
491 myIsFitWRActivated = false;
492 viewport()->setMouseTracking(true);
497 void SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
499 QPoint p = inverseWorldMatrix().map(theEvent->pos());
501 // compute collision rectangle
502 //QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
504 if (theEvent->button() == Qt::LeftButton) {
505 QCanvasItemList l = canvas()->collisions(p);
506 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
507 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
508 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
509 SUPERVGUI_CanvasNode* aNode = aNodePrs->getNode();
510 if (aNode->getEngine()->IsMacro() && !myIsLinkCreating) {
511 myMain->openSubGraph(aNode->getEngine(), true);
519 void SUPERVGUI_CanvasView::onDestroyed(QObject* theObject)
521 if (theObject == myHilighted)
525 void SUPERVGUI_CanvasView::setHilighted(SUPERVGUI_CanvasLink* theLink)
527 if (theLink == myHilighted) return;
529 disconnect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
530 myHilighted->setHilighted(false);
534 myHilighted = theLink;
535 myHilighted->setHilighted(true);
536 connect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
540 void SUPERVGUI_CanvasView::onTimeout()
543 scrollBy(myDX, myDY);
546 inverseWorldMatrix().map((double)myDX, (double)myDY, &cx, &cy);
547 if (myCurrentItem->x()+cx < 0) cx = -myCurrentItem->x();
548 if (myCurrentItem->y()+cy < 0) cy = -myCurrentItem->y();
549 myCurrentItem->moveBy(cx, cy);
550 myPoint.setX(myPoint.x()+(int)cx);
551 myPoint.setY(myPoint.y()+(int)cy);
556 void SUPERVGUI_CanvasView::changeBackground()
558 QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this );
559 if ( aColor.isValid() ) {
560 // change background color for canvas view
561 canvas()->setBackgroundColor(aColor);
562 setPaletteBackgroundColor(aColor.light(120));
563 // change background color for array view
564 getMain()->getArrayView()->canvas()->setBackgroundColor(aColor);
565 getMain()->getArrayView()->setPaletteBackgroundColor(aColor.light(120));
569 void SUPERVGUI_CanvasView::ActivatePanning()
571 myIsPanBtnClicked = true;
574 void SUPERVGUI_CanvasView::ResetView()
581 void SUPERVGUI_CanvasView::startSketch(SUPERVGUI_CanvasPort* thePort)
583 if (myIsLinkCreating) return;
585 myIsLinkCreating = true;
586 myLinkBuilder = new SUPERVGUI_CanvasLinkBuilder(canvas(), myMain, thePort);
587 mySketchPopup->setItemEnabled(myDelPntItem, false);
590 void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort)
592 if (!myIsLinkCreating) return;
594 if (myLinkBuilder && myLinkBuilder->canCreateEngine(thePort)) {
595 bool input = thePort->getEngine()->IsInput();
596 SUPERV_Link aLinkEngine;
597 if (thePort->getEngine()->Kind() == SUPERV::DataStreamParameter) {
598 SUPERVGUI_CanvasStreamPortIn* aInPort = (SUPERVGUI_CanvasStreamPortIn*)
599 (input ? thePort : myLinkBuilder->getStartPort());
600 SUPERVGUI_CanvasStreamPortOut* aOutPort = (SUPERVGUI_CanvasStreamPortOut*)
601 (input ? myLinkBuilder->getStartPort() : thePort);
602 // aLinkEngine = myMain->getDataflow()->StreamLink(aOutPort->getStreamEngine(),
603 // aInPort->getStreamEngine());
604 if (myMain->getDataflow()->IsStreamGraph()) {
605 SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph();
606 if (!SUPERV_isNull(aSGraph))
607 aLinkEngine = aSGraph->StreamLink(aOutPort->getStreamEngine(),
608 aInPort->getStreamEngine());
612 SUPERVGUI_CanvasPort* aInPort = (input ? thePort : myLinkBuilder->getStartPort());
613 SUPERVGUI_CanvasPort* aOutPort = (input ? myLinkBuilder->getStartPort() : thePort);
614 aLinkEngine = myMain->getDataflow()->Link(aOutPort->getEngine(), aInPort->getEngine());
616 if (SUPERV_isNull(aLinkEngine))
619 // here, in fact, aLinkEngine may NOT be a newly created link. If a link already existed between the
620 // the 2 given ports - it will be return (NOT created again).
621 // this should be checked and new presentation should NOT be created for existing link.
622 // Solution 1: NOT to allow creation of a link if it already exists between the ports in
623 // myLinkBuilder->canCreateEngine()
624 // Solution 2: check here if aLinkEngine is "new" or "old"
625 // Implement 2nd solution, because canCreateEngine() checks for types of ports, etc.. - it's another thing
627 QObjectList* canvasLinks = canvas()->queryList("SUPERVGUI_CanvasLink");
628 SUPERVGUI_CanvasLink* canvasLink = 0;
629 QObjectListIt it(*canvasLinks);
630 bool prsAlreadyExists = false;
631 while ( (canvasLink=(SUPERVGUI_CanvasLink*)it.current()) ) {
633 SUPERV_Link existingLinkWithPrs = canvasLink->getEngine();
634 if ( !SUPERV_isNull( existingLinkWithPrs ) ) {
635 if ( existingLinkWithPrs->IsEqual( aLinkEngine ) ) {
636 prsAlreadyExists = true;
642 if ( prsAlreadyExists ) { // aLinkEngine is already bound with a SUPERVGUI_CanvasLink object
643 //return; // -> if return here, than the old CanvasLink is kept
645 // we want to delete old and create a new CanvasLink for this Link
648 // clear old corrdinates in Engine link
649 for ( int i = 1; i <= aLinkEngine->CoordsSize(); i++ )
650 aLinkEngine->RemoveCoord( i );
651 // now we are ready to set coords for a link and create a new CanvasLink presentation that will use them.
654 myLinkBuilder->setCoords(aLinkEngine.in());
656 delete myLinkBuilder;
659 SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(canvas(), myMain, aLinkEngine);
663 myIsLinkCreating = false;
665 // asv : 13.12.04 : introducing a check for ports' types compatibility (Bugs and Improvements p.1.16, PAL7380)
666 if ( !aLinkEngine->IsValid() ) {
667 const int id = SUIT_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), tr( "MSG_INVALID_LINK" ),
668 tr( "Keep" ), tr( "Remove" ), 0, 1, 0 );
669 if ( id == 1 ) { // "Remove" was selected in Message Box
670 aLink->remove(); // the new link did not live long...
676 void SUPERVGUI_CanvasView::cancelSketch()
679 delete myLinkBuilder;
683 myIsLinkCreating = false;
686 void SUPERVGUI_CanvasView::deletePoint()
688 if (myIsLinkCreating && myLinkBuilder) {
689 myLinkBuilder->removeLastPoint();
691 mySketchPopup->setItemEnabled(myDelPntItem, myLinkBuilder->getPointCount());
695 void SUPERVGUI_CanvasView::setOrthoMode()
697 bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem);
698 mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho);
701 void SUPERVGUI_CanvasView::zoomIn()
709 void SUPERVGUI_CanvasView::zoomReset()
717 void SUPERVGUI_CanvasView::zoomOut()
725 void SUPERVGUI_CanvasView::fitAll()
728 QCanvasItemList l = canvas()->allItems();
729 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
730 QRect r = (*it)->boundingRect();
731 if (w < r.right()) w = r.right();
732 if (h < r.bottom()) h = r.bottom();
734 w += GRAPH_MARGIN; h += GRAPH_MARGIN;
735 double s = ((double)visibleWidth())/((double)w);
736 double s1 = ((double)visibleHeight())/((double)h);
746 void SUPERVGUI_CanvasView::fitWithinRect()
748 //mkr: "Fit within rectangle" functionality
749 myIsFitWRActivated = true;
750 viewport()->setMouseTracking(false);
752 setCursor(handCursor);
755 bool SUPERVGUI_CanvasView::isHavingStreamPort() const
757 SUPERV::ListOfNodes* aNodesList = myMain->getDataflow()->Nodes();
760 for ( int i = 0 ; i < (int) aNodesList->CNodes.length() ; i++ ) {
761 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->CNodes)[i]->StreamPorts() );
762 if ((int) aStrPortsList.length() > 0) {
768 for ( int i = 0 ; i < (int) aNodesList->FNodes.length() ; i++ ) {
769 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->FNodes)[i]->StreamPorts() );
770 if ((int) aStrPortsList.length() > 0) {
776 for ( int i = 0 ; i < (int) aNodesList->INodes.length() ; i++ ) {
777 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->INodes)[i]->StreamPorts() );
778 if ((int) aStrPortsList.length() > 0) {
784 for ( int i = 0 ; i < (int) aNodesList->GNodes.length() ; i++ ) {
785 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->GNodes)[i]->StreamPorts() );
786 if ((int) aStrPortsList.length() > 0) {
792 for ( int i = 0 ; i < (int) aNodesList->LNodes.length() ; i++ ) {
793 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->LNodes)[i]->StreamPorts() );
794 if ((int) aStrPortsList.length() > 0) {
800 for ( int i = 0 ; i < (int) aNodesList->SNodes.length() ; i++ ) {
801 SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->SNodes)[i]->StreamPorts() );
802 if ((int) aStrPortsList.length() > 0) {