Skip to content

Commit

Permalink
Merge pull request #383 from sbriseid/goview_scroll_wheel_support
Browse files Browse the repository at this point in the history
Enabled support for using scrool wheel to zoom.
  • Loading branch information
sbriseid authored Nov 23, 2024
2 parents bf16f86 + e70cece commit 23917e0
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 23917e0

Please sign in to comment.