Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
 

ZoomIn and ZoomOut to cursor position?

ZoomIn and ZoomOut to cursor position?
codex 2012/10/23 13:39
Hello,
this code work for zoomin and zoomout to center point

void Viewer3D::wheelEvent(QWheelEvent *event)
{
     int numDegrees = event->delta() / 8;
     int numSteps = numDegrees / 15;
     //
     myView->SetZoom(1 + numSteps * 0.1);
}

How make zoom to the mouse cursor position, like in AutoCAD?
Hans 2012/10/23 18:12
Use StartZoomAtPoint(X,Y) where X and Y are event->X() and event->Y() and then use ZoomAtPoint(X1,Y1, X2, Y1) where X1...Y1 are your Zooming-Factor.
codex 2012/10/23 18:24
thanks Hans, I found solution

void Viewer3D::wheelEvent(QWheelEvent *event)
{
     QPoint p = event->pos();
     myView->StartZoomAtPoint( p.x(), p.y() );
     double delta = (double)( event->delta() ) / ( 15 * 8 );
     int x = p.x();
     int y = p.y();
     int x1 = (int)( p.x() + width()*delta/100 );
     int y1 = (int)( p.y() + height()*delta/100 );
     myView->ZoomAtPoint( x, y, x1, y1 );
}
 
 
Latest news
  • Open CASCADE Technology 6.8.0 is available for download!
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map