myCurrentItem(0),
myHilightedItem(0),
mySelectedItem(0),
- myMovingDone(false)
+ myMovingDone(false),
+ myCenter(0,0)
{
printf("Construct QxGraph_CanvasView\n");
setName("QxGraph_CanvasView");
QPixmap zoomPixmap (imageZoomCursor);
QCursor zoomCursor (zoomPixmap);
setCursor(zoomCursor);
+
+ // the center of the view before zooming
+ int aXVCenter = viewport()->width()/2;
+ int aYVCenter = viewport()->height()/2;
+ myCenter = viewportToContents(QPoint(aXVCenter,aYVCenter));
}
return;
}
scrollBy(myGlobalPoint.x() - aGlobalPoint.x(),
myGlobalPoint.y() - aGlobalPoint.y());
myGlobalPoint = aGlobalPoint;
+ myMovingDone = true;
return;
}
if ( myOperation == ZOOMVIEW )
{ // Zoom
+ QCanvasItemList aList = canvas()->allItems();
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it)
+ (*it)->hide();
+
+ int aXContCenter = myCenter.x();
+ int aYContCenter = myCenter.y();
+
QWMatrix m = worldMatrix();
double dx = aGlobalPoint.x() - myGlobalPoint.x();
double s = 1. + fabs(dx)*( (m.m11() < 1) ? m.m11() : 1. )/70.;
if (dx < 0) s = 1./s;
+ int aXContCenterScaled = aXContCenter*s;
+ int aYContCenterScaled = aYContCenter*s;
+
m.scale(s, s);
setWorldMatrix(m);
+ center(aXContCenterScaled,aYContCenterScaled);
+
+ myCenter.setX(aXContCenterScaled);
+ myCenter.setY(aYContCenterScaled);
+
// remember the canvas view's current transformation matrix in all canvas items
- QCanvasItemList aList = canvas()->allItems();
+ aList = canvas()->allItems();
for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
if ( anActItem ) anActItem->setTMatrix(m);
+ (*it)->show();
}
myGlobalPoint = aGlobalPoint;
+ myMovingDone = true;
+
return;
}
myOperation = NOTHING;
viewport()->setMouseTracking(true);
setCursor(myCursor);
+
+ emit viewOperationDone();
}
if ( myOperation == PANGLOBAL )
myOperation = NOTHING;
center( theEvent->x(), theEvent->y() );
setCursor(myCursor);
+
+ emit viewOperationDone();
}
if ( myOperation == WINDOWFIT )
viewport()->setMouseTracking(true);
setCursor(myCursor);
+
+ emit viewOperationDone();
}
if ( myOperation == ZOOMVIEW )
myOperation = NOTHING;
viewport()->setMouseTracking(true);
setCursor(myCursor);
+
+ emit viewOperationDone();
}
if ( theEvent->button() == RightButton )
canvas()->update();
//myOperation = NOTHING;
+
+ emit viewOperationDone();
}
void QxGraph_CanvasView::activateFitRect()
}
//myOperation = NOTHING;
+
+ emit viewOperationDone();
}
void QxGraph_CanvasView::onTimeout()