Skip to content

Commit

Permalink
correct the zoom position by updating the view limits based on the sh…
Browse files Browse the repository at this point in the history
…ape of the window
  • Loading branch information
guillaumechauvat committed Dec 29, 2022
1 parent bff06b0 commit 9a4e6bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pymech/meshplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
# sets self.mesh_limits
self.setLimits(mesh)
# current limits
self.limits = self.mesh_limits
self.limits = self.mesh_limits.copy()

# and a status bar
# self.CreateStatusBar()
Expand Down Expand Up @@ -161,7 +161,7 @@ def OnInitGL(self):
gl.glClearColor(1, 1, 1, 1)

def updateLimits(self, width, height):
"""Reshape the OpenGL viewport based on the dimensions of the window."""
"""Update the view limits based on the dimensions of the window."""

xmin = self.limits[0]
xmax = self.limits[1]
Expand All @@ -180,6 +180,7 @@ def updateLimits(self, width, height):
dx = width / height * ly / 2
xmin = x0 - dx
xmax = x0 + dx
self.limits = [xmin, xmax, ymin, ymax]
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
Expand Down

0 comments on commit 9a4e6bf

Please sign in to comment.