void ZoomableGerberView::updateViewSize() { QSize ns = getActualZoom()*initSize; if(ns.width()<width() && ns.height()<height()) { if(initSize.width()>initSize.height()) setActualZoom((double)viewport()->width()/(double)initSize.width()); else setActualZoom((double)viewport()->height()/(double)initSize.height()); ns = getActualZoom()*initSize; } mView->resize(ns); }
void ZoomableGerberView::wheelEvent(QWheelEvent * event) { mZoomCoeficient += event->delta()*0.001L; if(getActualZoom()>1000.0L) setActualZoom(1000.0L); if(getActualZoom()<0.001L) setActualZoom(0.001L); const QPoint cp = QCursor::pos(); QPoint p = mView->mapFromGlobal(cp); QPoint s = mapFromGlobal(cp); double xp = ensure0to1((double)p.x()/(double)mView->width()); double yp = ensure0to1((double)p.y()/(double)mView->height()); updateViewSize(); horizontalScrollBar()->setValue(mView->width()*xp-s.x()); verticalScrollBar()->setValue(mView->height()*yp-s.y()); event->accept(); }
int ZDvidDataSliceHelper::getActualScale() const { return zgeom::GetZoomScale(getActualZoom()); }