Skip to content

Commit

Permalink
Enabled support for using scrool wheel to zoom.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sverre Briseid authored and Sverre Briseid committed Nov 23, 2024
1 parent bf16f86 commit e70cece
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions viewlib/include/GoTools/viewlib/gvView.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ public slots:
/// zoom and rotate the camera.
virtual void mouseMoveEvent(QMouseEvent* e);

virtual void wheelEvent(QWheelEvent* e);

virtual bool get3Dpoint(int mousex, int mousey, Vector3D &objpt);

void drawOverlay();
Expand Down
18 changes: 18 additions & 0 deletions viewlib/src/gvView.C
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,24 @@ void gvView::mouseMoveEvent(QMouseEvent* e)
updateGL();
}


//===========================================================================
void gvView::wheelEvent(QWheelEvent* e)
//===========================================================================
{
// Zoom the scene with scroll wheel
double dist = 0.0;
camera_.getDistance(dist);

// Get the delta of the wheel, and adjust the zoom factor
int delta = -e->angleDelta().y(); // y() is typically used for vertical scrolling
double zoomFactor = 1.0 - 0.001 * delta; // Adjust the zoom speed to your preference

camera_.setDistance(dist * zoomFactor);

updateGL();
}

//===========================================================================
void gvView::focusOnBox()
//===========================================================================
Expand Down

0 comments on commit e70cece

Please sign in to comment.