Commit ff4aaf4f authored by Guillaume Seguin's avatar Guillaume Seguin

Store zoom factor and lock quaternion changes

parent 12da0a83
......@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from threading import Lock
import wx
from wx import glcanvas
......@@ -51,6 +53,10 @@ class wxGLPanel(wx.Panel):
self.sizer.Add(self.canvas, 1, wx.EXPAND)
self.SetSizerAndFit(self.sizer)
self.rot_lock = Lock()
self.basequat = [0, 0, 0, 1]
self.zoom_factor = 1.0
# bind events
self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent)
self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent)
......@@ -144,6 +150,7 @@ class wxGLPanel(wx.Panel):
glLoadIdentity()
if self.orthographic:
ratio = factor * float(min(self.width, self.height)) / self.dist
self.zoom_factor = 1.0
glScalef(ratio, ratio, 1)
def OnDraw(self, *args, **kwargs):
......@@ -197,6 +204,7 @@ class wxGLPanel(wx.Panel):
delta_y = to[1]
glTranslatef(delta_x, delta_y, 0)
glScalef(factor, factor, 1)
self.zoom_factor *= factor
if to:
glTranslatef(-delta_x, -delta_y, 0)
wx.CallAfter(self.Refresh)
......@@ -218,6 +226,7 @@ class wxGLPanel(wx.Panel):
p2x = float(p2[0]) / (sz[0] / 2) - 1
p2y = 1 - float(p2[1]) / (sz[1] / 2)
quat = trackball(p1x, p1y, p2x, p2y, self.dist / 250.0)
with self.rot_lock:
self.basequat = mulquat(self.basequat, quat)
self.initpos = p2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment