Commit d730755e authored by Guillaume Seguin's avatar Guillaume Seguin

Show viz window upon double clicking the main window 3D viewer

parent 4f1a0175
...@@ -304,13 +304,8 @@ class GcodeViewPanel(wxGLPanel): ...@@ -304,13 +304,8 @@ class GcodeViewPanel(wxGLPanel):
glPopMatrix() glPopMatrix()
def double(self, event): def double(self, event):
p = event.GetPositionTuple() if self.parent.clickcb:
sz = self.GetClientSize() self.parent.clickcb(event)
v = map(lambda m, w, b: b * m / w, p, sz, self.bedsize)
v[1] = self.bedsize[1] - v[1]
v += [300]
print "Double-click at "+str(v)+" in "
print self
def move(self, event): def move(self, event):
"""react to mouse actions: """react to mouse actions:
...@@ -472,6 +467,7 @@ class GcodeViewMainWrapper(object): ...@@ -472,6 +467,7 @@ class GcodeViewMainWrapper(object):
def __init__(self, parent, build_dimensions, *args, **kwargs): def __init__(self, parent, build_dimensions, *args, **kwargs):
self.glpanel = GcodeViewPanel(parent, realparent = self) self.glpanel = GcodeViewPanel(parent, realparent = self)
self.glpanel.SetMinSize((150, 150)) self.glpanel.SetMinSize((150, 150))
self.clickcb = None
self.widget = self.glpanel self.widget = self.glpanel
self.refresh_timer = wx.CallLater(100, self.Refresh) self.refresh_timer = wx.CallLater(100, self.Refresh)
self.p = self # Hack for backwards compatibility with gviz API self.p = self # Hack for backwards compatibility with gviz API
......
...@@ -223,6 +223,7 @@ class VizPane(wx.BoxSizer): ...@@ -223,6 +223,7 @@ class VizPane(wx.BoxSizer):
try: try:
import printrun.gcview import printrun.gcview
root.gviz = printrun.gcview.GcodeViewMainWrapper(root.panel, root.build_dimensions_list) root.gviz = printrun.gcview.GcodeViewMainWrapper(root.panel, root.build_dimensions_list)
root.gviz.clickcb = root.showwin
except: except:
use2dview = True use2dview = True
print "3D view mode requested, but we failed to initialize it." print "3D view mode requested, but we failed to initialize it."
...@@ -235,6 +236,7 @@ class VizPane(wx.BoxSizer): ...@@ -235,6 +236,7 @@ class VizPane(wx.BoxSizer):
extrusion_width = root.settings.preview_extrusion_width) extrusion_width = root.settings.preview_extrusion_width)
root.gviz.SetToolTip(wx.ToolTip("Click to examine / edit\n layers of loaded file")) root.gviz.SetToolTip(wx.ToolTip("Click to examine / edit\n layers of loaded file"))
root.gviz.showall = 1 root.gviz.showall = 1
root.gviz.Bind(wx.EVT_LEFT_DOWN, root.showwin)
use3dview = root.settings.viz3d use3dview = root.settings.viz3d
if use3dview: if use3dview:
try: try:
...@@ -250,9 +252,8 @@ class VizPane(wx.BoxSizer): ...@@ -250,9 +252,8 @@ class VizPane(wx.BoxSizer):
build_dimensions = root.build_dimensions_list, build_dimensions = root.build_dimensions_list,
grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2), grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2),
extrusion_width = root.settings.preview_extrusion_width) extrusion_width = root.settings.preview_extrusion_width)
root.gwindow.Bind(wx.EVT_CLOSE, lambda x:root.gwindow.Hide()) root.gwindow.Bind(wx.EVT_CLOSE, lambda x: root.gwindow.Hide())
if not isinstance(root.gviz, NoViz): if not isinstance(root.gviz, NoViz):
root.gviz.Bind(wx.EVT_LEFT_DOWN, root.showwin)
self.Add(root.gviz.widget, 1, flag = wx.SHAPED) self.Add(root.gviz.widget, 1, flag = wx.SHAPED)
root.centersizer = wx.GridBagSizer() root.centersizer = wx.GridBagSizer()
self.Add(root.centersizer, 0, flag = wx.EXPAND) self.Add(root.centersizer, 0, flag = wx.EXPAND)
......
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