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"), myMain, SLOT(addDataflowToStudy()));
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 myPoint = inverseWorldMatrix().map(theEvent->pos());
162 myGlobalPoint = theEvent->globalPos();
165 // compute collision rectangle
166 QRect aSel(myPoint.x()-MARGIN, myPoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
168 if (((theEvent->button() == Qt::MidButton) &&
169 (theEvent->state() == Qt::ControlButton)) ||
171 myIsPanActivated = true;
173 setCursor(pan2Cursor);
177 if (((theEvent->button() == Qt::LeftButton) &&
178 (theEvent->state() == Qt::ControlButton)) ||
180 myIsZoomActivated = true;
182 setCursor(zoom2Cursor);
186 if ( theEvent->button() == Qt::RightButton) {
187 if (myIsLinkCreating) {
188 myMain->showPopup(mySketchPopup, theEvent);
192 QCanvasItemList l = canvas()->collisions(aSel);
193 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
194 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
195 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
196 QObject* anObj = aNodePrs->getObject(myPoint);
197 if (anObj->inherits("SUPERVGUI_CanvasNode")) {
198 myMain->showPopup(((SUPERVGUI_CanvasNode*)anObj)->getPopupMenu(viewport()),
202 else if (anObj->inherits("SUPERVGUI_CanvasPort")) {
203 myMain->showPopup(((SUPERVGUI_CanvasPort*)anObj)->getPopupMenu(viewport()),
208 if (myMain->isEditable() && !myMain->getCanvas()->isControlView()) {
209 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
210 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
211 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
212 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
215 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
216 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
217 aPrs->getLink()->setSelectedObject(aPrs, myPoint);
218 myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent);
224 myPopup->setItemEnabled(myAddStudyItem, !myMain->isDataflowInStudy());
225 // Paste Node functionality
226 SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
227 myPopup->setItemEnabled(myPasteNodeItem, aCB->isCopyNode() );
228 myMain->showPopup(myPopup, theEvent);
232 if (theEvent->button() == Qt::LeftButton) {
233 if (!myIsFitWRActivated) {//not moving items if fit within rectangle
234 //functionality is enable
235 QCanvasItemList l = canvas()->collisions(myPoint);
236 if (myIsLinkCreating) {
237 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
238 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
239 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
240 QObject* anObj = aNodePrs->getObject(myPoint);
241 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
242 endSketch((SUPERVGUI_CanvasPort*)anObj);
247 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
248 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
252 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) {
253 SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it);
254 QObject* anObj = aHookPrs->getObject();
255 if (anObj->inherits("SUPERVGUI_CanvasPort")) {
256 endSketch((SUPERVGUI_CanvasPort*)anObj);
262 myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem));
264 mySketchPopup->setItemEnabled(myDelPntItem, true);
269 // if (myMain->isEditable()) { // allow to move nodes and link point on imported graph
270 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
271 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
273 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2);
274 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true);
277 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
278 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
279 if (aPrs->getIndex() > 0) {
281 aPrs->setMoving(true);
285 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
286 //mkr: for moving segment of link
287 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
288 if (aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->startPoint()
290 aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->endPoint()
292 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->startPoint()
294 aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->endPoint()) {
298 aPrs->setMoving(true);
309 void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
314 QPoint p = inverseWorldMatrix().map(theEvent->pos());
315 QPoint g = theEvent->globalPos();
317 if (myTimer->isActive()) myTimer->stop();
319 if (myIsLinkCreating && myLinkBuilder) {
320 myLinkBuilder->setFloatPoint(p);
326 if (myCurrentItem->x() && myCurrentItem->y()) {
327 double cx = myCurrentItem->x() - myPoint.x();
328 double cy = myCurrentItem->y() - myPoint.y();
330 if (p.x()+cx < 0) p.setX(-(int)cx);
331 if (p.y()+cy < 0) p.setY(-(int)cy);
333 myCurrentItem->moveBy(p.x() - myPoint.x(),
334 p.y() - myPoint.y());
338 // scroll contents if mouse is outside
339 QRect r(contentsX(), contentsY(), visibleWidth(), visibleHeight());
340 if (!r.contains(theEvent->pos())) {
342 if (theEvent->pos().x() < r.left()) dx = theEvent->pos().x() - r.left();
343 if (theEvent->pos().x() > r.right()) dx = theEvent->pos().x() - r.right();
344 if (theEvent->pos().y() < r.top()) dy = theEvent->pos().y() - r.top();
345 if (theEvent->pos().y() > r.bottom()) dy = theEvent->pos().y() - r.bottom();
347 // start timer to scroll in silent mode
348 myDX = dx; myDY = dy;
355 if (myIsPanActivated) {
357 scrollBy(myGlobalPoint.x() - g.x(),
358 myGlobalPoint.y() - g.y());
364 if (myIsZoomActivated) {
366 double dx = g.x() - myGlobalPoint.x();
367 double s = 1. + fabs(dx)/10.;
368 if (dx < 0) s = 1./s;
370 QWMatrix m = worldMatrix();
379 //mkr: "Fit within rectangle" functionality
380 if (myIsFitWRActivated) {
381 int aLX, aTY; //left x and top y
382 if (myPoint.x() < p.x()) aLX = myPoint.x();
384 if (myPoint.y() < p.y()) aTY = myPoint.y();
386 QRect aRect(aLX, aTY, abs(myPoint.x()-p.x()), abs(myPoint.y()-p.y()));
387 QCanvasRectangle* aRect1 = new QCanvasRectangle(aRect, canvas());
389 //hide old selected rectangle
391 mySelectedRect->hide();
392 //draw new selected rectangle
393 QPen pen(Qt::SolidLine);
399 mySelectedRect = aRect1;
403 if (!myIsLinkCreating && myMain->isEditable() &&
404 !myMain->getCanvas()->isControlView()) {
405 // compute collision rectangle
406 QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
407 QCanvasItemList l = canvas()->collisions(aSel);
408 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
409 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
410 SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
411 setHilighted(aPrs->getLink());
415 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
416 SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
417 setHilighted(aPrs->getLink());
428 void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
430 if (myTimer->isActive()) myTimer->stop();
433 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
434 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(0);
435 ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(false);
438 if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
439 ((SUPERVGUI_CanvasPointPrs*)myCurrentItem)->setMoving(false);
444 if (myIsPanActivated) {
445 myIsPanActivated = false;
446 myIsPanBtnClicked = false;
450 if (myIsZoomActivated) {
451 myIsZoomActivated = false;
455 //mkr: "Fit within rectangle" functionality
456 if (myIsFitWRActivated) {
457 if (mySelectedRect) {
458 mySelectedRect->hide();
463 //myPoint is the start point for selecting rectangle now
464 QPoint anEndPoint = inverseWorldMatrix().map(theEvent->pos());
465 int aLX, aTY; //left x and top y
466 if (myPoint.x() < anEndPoint.x()) aLX = myPoint.x();
467 else aLX = anEndPoint.x();
468 if (myPoint.y() < anEndPoint.y()) aTY = myPoint.y();
469 else aTY = anEndPoint.y();
471 //calculate width and height for new view and new zoom factor
472 double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-anEndPoint.x())));
473 double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-anEndPoint.y())));
474 if (aXzoom > aYzoom) aXzoom = aYzoom;
477 m.scale(aXzoom, aXzoom);
479 setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom));
483 myIsFitWRActivated = false;
484 viewport()->setMouseTracking(true);
489 void SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
491 QPoint p = inverseWorldMatrix().map(theEvent->pos());
493 // compute collision rectangle
494 //QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
496 if (theEvent->button() == Qt::LeftButton) {
497 QCanvasItemList l = canvas()->collisions(p);
498 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
499 if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
500 SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
501 SUPERVGUI_CanvasNode* aNode = aNodePrs->getNode();
502 if (aNode->getEngine()->IsMacro() && !myIsLinkCreating) {
503 myMain->openSubGraph(aNode->getEngine(), true);
511 void SUPERVGUI_CanvasView::onDestroyed(QObject* theObject)
513 if (theObject == myHilighted)
517 void SUPERVGUI_CanvasView::setHilighted(SUPERVGUI_CanvasLink* theLink)
519 if (theLink == myHilighted) return;
521 disconnect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
522 myHilighted->setHilighted(false);
526 myHilighted = theLink;
527 myHilighted->setHilighted(true);
528 connect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
532 void SUPERVGUI_CanvasView::onTimeout()
535 scrollBy(myDX, myDY);
538 inverseWorldMatrix().map((double)myDX, (double)myDY, &cx, &cy);
539 if (myCurrentItem->x()+cx < 0) cx = -myCurrentItem->x();
540 if (myCurrentItem->y()+cy < 0) cy = -myCurrentItem->y();
541 myCurrentItem->moveBy(cx, cy);
542 myPoint.setX(myPoint.x()+(int)cx);
543 myPoint.setY(myPoint.y()+(int)cy);
548 void SUPERVGUI_CanvasView::changeBackground()
550 QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this );
551 if ( aColor.isValid() ) {
552 canvas()->setBackgroundColor(aColor);
553 setPaletteBackgroundColor(aColor.light(120));
557 void SUPERVGUI_CanvasView::ActivatePanning()
559 myIsPanBtnClicked = true;
562 void SUPERVGUI_CanvasView::ResetView()
569 void SUPERVGUI_CanvasView::startSketch(SUPERVGUI_CanvasPort* thePort)
571 if (myIsLinkCreating) return;
573 myIsLinkCreating = true;
574 myLinkBuilder = new SUPERVGUI_CanvasLinkBuilder(canvas(), myMain, thePort);
575 mySketchPopup->setItemEnabled(myDelPntItem, false);
578 void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort)
580 if (!myIsLinkCreating) return;
582 if (myLinkBuilder && myLinkBuilder->canCreateEngine(thePort)) {
583 bool input = thePort->getEngine()->IsInput();
584 SUPERV_Link aLinkEngine;
585 if (thePort->getEngine()->Kind() == SUPERV::DataStreamParameter) {
586 SUPERVGUI_CanvasStreamPortIn* aInPort = (SUPERVGUI_CanvasStreamPortIn*)
587 (input ? thePort : myLinkBuilder->getStartPort());
588 SUPERVGUI_CanvasStreamPortOut* aOutPort = (SUPERVGUI_CanvasStreamPortOut*)
589 (input ? myLinkBuilder->getStartPort() : thePort);
590 // aLinkEngine = myMain->getDataflow()->StreamLink(aOutPort->getStreamEngine(),
591 // aInPort->getStreamEngine());
592 if (myMain->getDataflow()->IsStreamGraph()) {
593 SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph();
594 if (!SUPERV_isNull(aSGraph))
595 aLinkEngine = aSGraph->StreamLink(aOutPort->getStreamEngine(),
596 aInPort->getStreamEngine());
600 SUPERVGUI_CanvasPort* aInPort = (input ? thePort : myLinkBuilder->getStartPort());
601 SUPERVGUI_CanvasPort* aOutPort = (input ? myLinkBuilder->getStartPort() : thePort);
602 aLinkEngine = myMain->getDataflow()->Link(aOutPort->getEngine(), aInPort->getEngine());
604 if (SUPERV_isNull(aLinkEngine))
607 // here, in fact, aLinkEngine may NOT be a newly created link. If a link already existed between the
608 // the 2 given ports - it will be return (NOT created again).
609 // this should be checked and new presentation should NOT be created for existing link.
610 // Solution 1: NOT to allow creation of a link if it already exists between the ports in
611 // myLinkBuilder->canCreateEngine()
612 // Solution 2: check here if aLinkEngine is "new" or "old"
613 // Implement 2nd solution, because canCreateEngine() checks for types of ports, etc.. - it's another thing
615 QObjectList* canvasLinks = canvas()->queryList("SUPERVGUI_CanvasLink");
616 SUPERVGUI_CanvasLink* canvasLink = 0;
617 QObjectListIt it(*canvasLinks);
618 bool prsAlreadyExists = false;
619 while ( (canvasLink=(SUPERVGUI_CanvasLink*)it.current()) ) {
621 SUPERV_Link existingLinkWithPrs = canvasLink->getEngine();
622 if ( !SUPERV_isNull( existingLinkWithPrs ) ) {
623 if ( existingLinkWithPrs->IsEqual( aLinkEngine ) ) {
624 prsAlreadyExists = true;
630 if ( prsAlreadyExists ) { // aLinkEngine is already bound with a SUPERVGUI_CanvasLink object
631 //return; // -> if return here, than the old CanvasLink is kept
633 // we want to delete old and create a new CanvasLink for this Link
636 // clear old corrdinates in Engine link
637 for ( int i = 1; i <= aLinkEngine->CoordsSize(); i++ )
638 aLinkEngine->RemoveCoord( i );
639 // now we are ready to set coords for a link and create a new CanvasLink presentation that will use them.
642 myLinkBuilder->setCoords(aLinkEngine.in());
644 delete myLinkBuilder;
647 SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(canvas(), myMain, aLinkEngine);
651 myIsLinkCreating = false;
653 // asv : 13.12.04 : introducing a check for ports' types compatibility (Bugs and Improvements p.1.16, PAL7380)
654 if ( !aLinkEngine->IsValid() ) {
655 const int id = QAD_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), tr( "MSG_INVALID_LINK" ),
656 tr( "Keep" ), tr( "Remove" ), 0, 1, 0 );
657 if ( id == 1 ) { // "Remove" was selected in Message Box
658 aLink->remove(); // the new link did not live long...
664 void SUPERVGUI_CanvasView::cancelSketch()
667 delete myLinkBuilder;
671 myIsLinkCreating = false;
674 void SUPERVGUI_CanvasView::deletePoint()
676 if (myIsLinkCreating && myLinkBuilder) {
677 myLinkBuilder->removeLastPoint();
679 mySketchPopup->setItemEnabled(myDelPntItem, myLinkBuilder->getPointCount());
683 void SUPERVGUI_CanvasView::setOrthoMode()
685 bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem);
686 mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho);
689 void SUPERVGUI_CanvasView::zoomIn()
697 void SUPERVGUI_CanvasView::zoomReset()
705 void SUPERVGUI_CanvasView::zoomOut()
713 void SUPERVGUI_CanvasView::fitAll()
716 QCanvasItemList l = canvas()->allItems();
717 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
718 QRect r = (*it)->boundingRect();
719 if (w < r.right()) w = r.right();
720 if (h < r.bottom()) h = r.bottom();
722 w += GRAPH_MARGIN; h += GRAPH_MARGIN;
723 double s = ((double)visibleWidth())/((double)w);
724 double s1 = ((double)visibleHeight())/((double)h);
734 void SUPERVGUI_CanvasView::fitWithinRect()
736 //mkr: "Fit within rectangle" functionality
737 myIsFitWRActivated = true;
738 viewport()->setMouseTracking(false);
740 setCursor(handCursor);