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 "QAD_Config.h"
22 #include "QAD_MessageBox.h"
25 #include <qcolordialog.h>
31 const char* imageZoomCursor[] = {
36 "................................",
37 "................................",
38 ".#######........................",
39 "..aaaaaaa.......................",
40 "................................",
41 ".............#####..............",
42 "...........##.aaaa##............",
43 "..........#.aa.....a#...........",
44 ".........#.a.........#..........",
45 ".........#a..........#a.........",
46 "........#.a...........#.........",
47 "........#a............#a........",
48 "........#a............#a........",
49 "........#a............#a........",
50 "........#a............#a........",
51 ".........#...........#.a........",
52 ".........#a..........#a.........",
53 ".........##.........#.a.........",
54 "........#####.....##.a..........",
55 ".......###aaa#####.aa...........",
56 "......###aa...aaaaa.......#.....",
57 ".....###aa................#a....",
58 "....###aa.................#a....",
59 "...###aa...............#######..",
60 "....#aa.................aa#aaaa.",
61 ".....a....................#a....",
62 "..........................#a....",
63 "...........................a....",
64 "................................",
65 "................................",
66 "................................",
67 "................................"};
69 QPixmap zoomPix(imageZoomCursor);
70 QCursor zoom2Cursor(zoomPix);
71 QCursor handCursor(Qt::PointingHandCursor);
73 #if QT_VERSION >= 0x030005
74 QCursor pan2Cursor(Qt::SizeAllCursor);
76 QCursor pan2Cursor(SizeAllCursor);
79 SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGUI_Main* theMain):
80 QCanvasView(theCanvas, theMain),
81 myMain(theMain), myCurrentItem(0), myHilighted(0), myLinkBuilder(0)
83 setName("CanvasView");
85 myIsPanBtnClicked = false;
86 myIsPanActivated = false;
87 myIsFitWRActivated = false;
88 myIsZoomActivated = false;
89 myIsLinkCreating = false;
95 myTimer = new QTimer(this);
96 connect(myTimer, SIGNAL(timeout()), this, SLOT(onTimeout()));
98 myPopup = new QPopupMenu(viewport());
100 const bool isEdit = myMain->isEditable();
102 myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode()));
104 // Paste Node functionality
105 SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
106 myPasteNodeItem = myPopup->insertItem(tr("ITM_PASTE_NODE"), aCB, SLOT(pasteNode()));
108 myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile()));
109 myPopup->insertSeparator();
112 QPopupMenu* aViewPopup = new QPopupMenu(viewport());
113 aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas()));
114 aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow()));
115 aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showCanvasTable()));
117 myPopup->insertItem(tr("POP_VIEW"), aViewPopup);
118 myPopup->insertSeparator();
120 QPopupMenu* aZoomPopup = new QPopupMenu(viewport());
121 aZoomPopup->insertItem("200%", this, SLOT(zoomIn()));
122 aZoomPopup->insertItem("100%", this, SLOT(zoomReset()));
123 aZoomPopup->insertItem("50%", this, SLOT(zoomOut()));
124 aZoomPopup->insertSeparator();
125 //mkr: "Fit within rectangle" functionality
126 aZoomPopup->insertItem(tr("POP_FITWITHINRECT"), this, SLOT(fitWithinRect()));
127 aZoomPopup->insertSeparator();
128 aZoomPopup->insertItem(tr("POP_FITALL"), this, SLOT(fitAll()));
131 myPopup->insertItem(tr("POP_ZOOM"), aZoomPopup);
132 myPopup->insertSeparator();
134 myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy()));
135 myPopup->insertItem(tr(isEdit ? "MSG_CHANGE_INFO" : "MSG_INFO"), myMain, SLOT(changeInformation()));
136 myPopup->insertSeparator();
138 myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), myMain, SLOT(copy()));
139 myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), myMain, SLOT(filterNotification()));
141 myPopup->insertSeparator();
142 myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground()));
144 viewport()->setMouseTracking(true);
146 //create sketching popup menu
147 mySketchPopup = new QPopupMenu(viewport());
148 mySketchPopup->setCheckable(true);
149 myDelPntItem = mySketchPopup->insertItem(tr("MSG_DEL_LAST_PNT"), this, SLOT(deletePoint()));
150 mySketchPopup->insertItem(tr("MSG_DEL_LINK"), this, SLOT(cancelSketch()));
151 myOrtoItem = mySketchPopup->insertItem(tr("MSG_ORTHO_LINE"), this, SLOT(setOrthoMode()));
155 SUPERVGUI_CanvasView::~SUPERVGUI_CanvasView()
159 void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
161 // MESSAGE("===> SUPERVGUI_CanvasView::contentsMousePressEvent(...) ");
162 myPoint = inverseWorldMatrix().map(theEvent->pos());
163 myGlobalPoint = theEvent->globalPos();
166 // compute collision rectangle
167 QRect aSel(myPoint.x()-MARGIN, myPoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
169 if (((theEvent->button() == Qt::MidButton) &&
170 (theEvent->state() == Qt::ControlButton)) ||
172 myIsPanActivated = true;
174 setCursor(pan2Cursor);
178 if (((theEvent->button() == Qt::LeftButton) &&
179 (theEvent->state() == Qt::ControlButton)) ||
181 myIsZoomActivated = true;
183 setCursor(zoom2Cursor);
187 if ( theEvent->button() == Qt::RightButton) {
188 if (myIsLinkCreating) {
189 myMain->showPopup(mySketchPopup, theEvent);
193 QCanvasItemList l = canvas()->collisions(aSel);
194 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
195 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
196 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
197 QObject* anObj = aNodePrs->getObject(myPoint);
198 if (anObj->inherits("SUPERVGUI_CanvasNode")) {
199 myMain->showPopup(((SUPERVGUI_CanvasNode*)anObj)->getPopupMenu(viewport()),
203 else if (anObj->inherits("SUPERVGUI_CanvasPort")) {
204 myMain->showPopup(((SUPERVGUI_CanvasPort*)anObj)->getPopupMenu(viewport()),
209 if (myMain->isEditable() && !myMain->getCanvas()->isControlView()) {
210 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
211 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
212 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
213 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
216 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
217 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
218 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
219 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
225 myPopup->setItemEnabled(myAddStudyItem, !myMain->isFromStudy());
226 // Paste Node functionality
227 SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
228 myPopup->setItemEnabled(myPasteNodeItem, aCB->isCopyNode() );
229 myMain->showPopup(myPopup, theEvent);
233 if (theEvent->button() == Qt::LeftButton) {
234 if (!myIsFitWRActivated) {//not moving items if fit within rectangle
235 //functionality is enable
236 QCanvasItemList l = canvas()->collisions(myPoint);
237 if (myIsLinkCreating) {
238 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
239 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
240 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
241 QObject* anObj = aNodePrs->getObject(myPoint);
242 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
243 endSketch((SUPERVGUI_CanvasPort*)anObj);
248 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
249 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
253 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) {
254 SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it);
255 QObject* anObj = aHookPrs->getObject();
256 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
257 endSketch((SUPERVGUI_CanvasPort*)anObj);
263 myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem));
265 mySketchPopup->setItemEnabled(myDelPntItem, true);
270 // if (myMain->isEditable()) { // allow to move nodes and link point on imported graph
271 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
272 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
274 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
275 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
278 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
279 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
280 if (aPrs->getIndex() > 0) {
282 aPrs->setMoving(true);
286 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
287 //mkr: for moving segment of link
288 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
289 if (aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->startPoint()
291 aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->endPoint()
293 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->startPoint()
295 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->endPoint()) {
299 aPrs->setMoving(true);
310 void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
315 QPoint p = inverseWorldMatrix().map(theEvent->pos());
316 QPoint g = theEvent->globalPos();
318 if (myTimer->isActive()) myTimer->stop();
320 if (myIsLinkCreating && myLinkBuilder) {
321 myLinkBuilder->setFloatPoint(p);
327 if (myCurrentItem->x() && myCurrentItem->y()) {
328 double cx = myCurrentItem->x() - myPoint.x();
329 double cy = myCurrentItem->y() - myPoint.y();
331 if (p.x()+cx < 0) p.setX(-(int)cx);
332 if (p.y()+cy < 0) p.setY(-(int)cy);
334 myCurrentItem->moveBy(p.x() - myPoint.x(),
335 p.y() - myPoint.y());
339 // scroll contents if mouse is outside
340 QRect r(contentsX(), contentsY(), visibleWidth(), visibleHeight());
341 if (!r.contains(theEvent->pos())) {
343 if (theEvent->pos().x() < r.left()) dx = theEvent->pos().x() - r.left();
344 if (theEvent->pos().x() > r.right()) dx = theEvent->pos().x() - r.right();
345 if (theEvent->pos().y() < r.top()) dy = theEvent->pos().y() - r.top();
346 if (theEvent->pos().y() > r.bottom()) dy = theEvent->pos().y() - r.bottom();
348 // start timer to scroll in silent mode
349 myDX = dx; myDY = dy;
356 if (myIsPanActivated) {
358 scrollBy(myGlobalPoint.x() - g.x(),
359 myGlobalPoint.y() - g.y());
365 if (myIsZoomActivated) {
367 double dx = g.x() - myGlobalPoint.x();
368 double s = 1. + fabs(dx)/10.;
369 if (dx < 0) s = 1./s;
371 QWMatrix m = worldMatrix();
380 //mkr: "Fit within rectangle" functionality
381 if (myIsFitWRActivated) {
382 int aLX, aTY; //left x and top y
383 if (myPoint.x() < p.x()) aLX = myPoint.x();
385 if (myPoint.y() < p.y()) aTY = myPoint.y();
387 QRect aRect(aLX, aTY, abs(myPoint.x()-p.x()), abs(myPoint.y()-p.y()));
388 QCanvasRectangle* aRect1 = new QCanvasRectangle(aRect, canvas());
390 //hide old selected rectangle
392 mySelectedRect->hide();
393 //draw new selected rectangle
394 QPen pen(Qt::SolidLine);
400 mySelectedRect = aRect1;
404 if (!myIsLinkCreating && myMain->isEditable() &&
405 !myMain->getCanvas()->isControlView()) {
406 // compute collision rectangle
407 QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
408 QCanvasItemList l = canvas()->collisions(aSel);
409 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
410 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
411 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
412 setHilighted(aPrs->getLink());
416 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
417 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
418 setHilighted(aPrs->getLink());
429 void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
431 // MESSAGE("===> SUPERVGUI_CanvasView::contentsMouseReleaseEvent(...) ");
432 if (myTimer->isActive()) myTimer->stop();
435 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
436 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(0);
437 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(false);
440 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
441 ((SUPERVGUI_CanvasPointPrs*)myCurrentItem)->setMoving(false);
446 if (myIsPanActivated) {
447 myIsPanActivated = false;
448 myIsPanBtnClicked = false;
452 if (myIsZoomActivated) {
453 myIsZoomActivated = false;
457 //mkr: "Fit within rectangle" functionality
458 if (myIsFitWRActivated) {
459 if (mySelectedRect) {
460 mySelectedRect->hide();
465 //myPoint is the start point for selecting rectangle now
466 QPoint anEndPoint = inverseWorldMatrix().map(theEvent->pos());
467 int aLX, aTY; //left x and top y
468 if (myPoint.x() < anEndPoint.x()) aLX = myPoint.x();
469 else aLX = anEndPoint.x();
470 if (myPoint.y() < anEndPoint.y()) aTY = myPoint.y();
471 else aTY = anEndPoint.y();
473 //calculate width and height for new view and new zoom factor
474 double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-anEndPoint.x())));
475 double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-anEndPoint.y())));
476 if (aXzoom > aYzoom) aXzoom = aYzoom;
479 m.scale(aXzoom, aXzoom);
481 setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom));
485 myIsFitWRActivated = false;
486 viewport()->setMouseTracking(true);
491 void SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
493 // MESSAGE("===> SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(...) ");
494 QPoint p = inverseWorldMatrix().map(theEvent->pos());
496 // compute collision rectangle
497 QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
499 if (theEvent->button() == Qt::LeftButton) {
500 QCanvasItemList l = canvas()->collisions(p);
501 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
502 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
503 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
504 SUPERVGUI_CanvasNode* aNode = aNodePrs->getNode();
505 if (aNode->getEngine()->IsMacro() && !myIsLinkCreating) {
506 myMain->openSubGraph(aNode->getEngine(), true);
514 void SUPERVGUI_CanvasView::onDestroyed(QObject* theObject)
516 if (theObject == myHilighted)
520 void SUPERVGUI_CanvasView::setHilighted(SUPERVGUI_CanvasLink* theLink)
522 if (theLink == myHilighted) return;
524 disconnect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
525 myHilighted->setHilighted(false);
529 myHilighted = theLink;
530 myHilighted->setHilighted(true);
531 connect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
535 void SUPERVGUI_CanvasView::onTimeout()
538 scrollBy(myDX, myDY);
541 inverseWorldMatrix().map((double)myDX, (double)myDY, &cx, &cy);
542 if (myCurrentItem->x()+cx < 0) cx = -myCurrentItem->x();
543 if (myCurrentItem->y()+cy < 0) cy = -myCurrentItem->y();
544 myCurrentItem->moveBy(cx, cy);
545 myPoint.setX(myPoint.x()+(int)cx);
546 myPoint.setY(myPoint.y()+(int)cy);
551 void SUPERVGUI_CanvasView::changeBackground()
553 QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this );
554 if ( aColor.isValid() ) {
555 canvas()->setBackgroundColor(aColor);
556 setPaletteBackgroundColor(aColor.light(120));
560 void SUPERVGUI_CanvasView::ActivatePanning()
562 myIsPanBtnClicked = true;
565 void SUPERVGUI_CanvasView::ResetView()
572 void SUPERVGUI_CanvasView::startSketch(SUPERVGUI_CanvasPort* thePort)
574 if (myIsLinkCreating) return;
576 myIsLinkCreating = true;
577 myLinkBuilder = new SUPERVGUI_CanvasLinkBuilder(canvas(), myMain, thePort);
578 mySketchPopup->setItemEnabled(myDelPntItem, false);
581 void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort)
583 // MESSAGE("===> SUPERVGUI_CanvasView::endSketch(" << thePort->name() << ")");
584 if (!myIsLinkCreating) return;
586 if (myLinkBuilder && myLinkBuilder->canCreateEngine(thePort)) {
587 bool input = thePort->getEngine()->IsInput();
588 SUPERV_Link aLinkEngine;
589 if (thePort->getEngine()->Kind() == SUPERV::DataStreamParameter) {
590 SUPERVGUI_CanvasStreamPortIn* aInPort = (SUPERVGUI_CanvasStreamPortIn*)
591 (input ? thePort : myLinkBuilder->getStartPort());
592 SUPERVGUI_CanvasStreamPortOut* aOutPort = (SUPERVGUI_CanvasStreamPortOut*)
593 (input ? myLinkBuilder->getStartPort() : thePort);
594 // aLinkEngine = myMain->getDataflow()->StreamLink(aOutPort->getStreamEngine(),
595 // aInPort->getStreamEngine());
596 if (myMain->getDataflow()->IsStreamGraph()) {
597 SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph();
598 if (!SUPERV_isNull(aSGraph))
599 aLinkEngine = aSGraph->StreamLink(aOutPort->getStreamEngine(),
600 aInPort->getStreamEngine());
604 SUPERVGUI_CanvasPort* aInPort = (input ? thePort : myLinkBuilder->getStartPort());
605 SUPERVGUI_CanvasPort* aOutPort = (input ? myLinkBuilder->getStartPort() : thePort);
606 aLinkEngine = myMain->getDataflow()->Link(aOutPort->getEngine(), aInPort->getEngine());
608 if (SUPERV_isNull(aLinkEngine))
611 // here, in fact, aLinkEngine may NOT be a newly created link. If a link already existed between the
612 // the 2 given ports - it will be return (NOT created again).
613 // this should be checked and new presentation should NOT be created for existing link.
614 // Solution 1: NOT to allow creation of a link if it already exists between the ports in
615 // myLinkBuilder->canCreateEngine()
616 // Solution 2: check here if aLinkEngine is "new" or "old"
617 // Implement 2nd solution, because canCreateEngine() checks for types of ports, etc.. - it's another thing
619 QObjectList* canvasLinks = canvas()->queryList("SUPERVGUI_CanvasLink");
620 SUPERVGUI_CanvasLink* canvasLink = 0;
621 QObjectListIt it(*canvasLinks);
622 bool prsAlreadyExists = false;
623 while ( (canvasLink=(SUPERVGUI_CanvasLink*)it.current()) ) {
625 SUPERV_Link existingLinkWithPrs = canvasLink->getEngine();
626 if ( !SUPERV_isNull( existingLinkWithPrs ) ) {
627 if ( existingLinkWithPrs->IsEqual( aLinkEngine ) ) {
628 prsAlreadyExists = true;
634 if ( prsAlreadyExists ) { // aLinkEngine is already bound with a SUPERVGUI_CanvasLink object
635 //return; // -> if return here, than the old CanvasLink is kept
637 // we want to delete old and create a new CanvasLink for this Link
640 // clear old corrdinates in Engine link
641 for ( int i = 1; i <= aLinkEngine->CoordsSize(); i++ )
642 aLinkEngine->RemoveCoord( i );
643 // now we are ready to set coords for a link and create a new CanvasLink presentation that will use them.
646 myLinkBuilder->setCoords(aLinkEngine.in());
648 delete myLinkBuilder;
651 SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(canvas(), myMain, aLinkEngine);
655 myIsLinkCreating = false;
657 // asv : 13.12.04 : introducing a check for ports' types compatibility (Bugs and Improvements p.1.16, PAL7380)
658 if ( !aLinkEngine->IsValid() ) {
659 const int id = QAD_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), tr( "MSG_INVALID_LINK" ),
660 tr( "Keep" ), tr( "Remove" ), 0, 1, 0 );
661 if ( id == 1 ) { // "Remove" was selected in Message Box
662 aLink->remove(); // the new link did not live long...
668 void SUPERVGUI_CanvasView::cancelSketch()
671 delete myLinkBuilder;
675 myIsLinkCreating = false;
678 void SUPERVGUI_CanvasView::deletePoint()
680 if (myIsLinkCreating && myLinkBuilder) {
681 myLinkBuilder->removeLastPoint();
683 mySketchPopup->setItemEnabled(myDelPntItem, myLinkBuilder->getPointCount());
687 void SUPERVGUI_CanvasView::setOrthoMode()
689 bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem);
690 mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho);
694 void SUPERVGUI_CanvasView::addToStudy()
696 if (myMain->addStudy()) myMain->setAsFromStudy(true);
699 void SUPERVGUI_CanvasView::zoomIn()
707 void SUPERVGUI_CanvasView::zoomReset()
715 void SUPERVGUI_CanvasView::zoomOut()
723 void SUPERVGUI_CanvasView::fitAll()
726 QCanvasItemList l = canvas()->allItems();
727 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
728 QRect r = (*it)->boundingRect();
729 if (w < r.right()) w = r.right();
730 if (h < r.bottom()) h = r.bottom();
732 w += GRAPH_MARGIN; h += GRAPH_MARGIN;
733 double s = ((double)visibleWidth())/((double)w);
734 double s1 = ((double)visibleHeight())/((double)h);
744 void SUPERVGUI_CanvasView::fitWithinRect()
746 //mkr: "Fit within rectangle" functionality
747 myIsFitWRActivated = true;
748 viewport()->setMouseTracking(false);
750 setCursor(handCursor);