Commit 69702567 authored by Guillaume Seguin's avatar Guillaume Seguin

Add C keybinding to gcview to only show current layer

parent 5301e434
......@@ -210,6 +210,7 @@ class GcodeViewPanel(wxGLPanel):
kzi = [wx.WXK_PAGEDOWN, 388, 316, 61] # Zoom In Keys
kzo = [wx.WXK_PAGEUP, 390, 314, 45] # Zoom Out Keys
kfit = [70] # Fit to print keys
kshowcurrent = [67] # Show only current layer keys
kreset = [82] # Reset keys
key = event.GetKeyCode()
if key in kup:
......@@ -223,6 +224,10 @@ class GcodeViewPanel(wxGLPanel):
self.zoom(1 / step, (x, y))
if key in kfit:
self.fit()
if key in kshowcurrent:
if not self.parent.model or not self.parent.model.loaded:
return
self.parent.model.only_current = not self.parent.model.only_current
if key in kreset:
self.reset_mview(0.9)
self.basequat = [0, 0, 0, 1]
......
......@@ -289,6 +289,7 @@ class GcodeModel(Model):
self.max_layers = len(self.layer_stops) - 1
self.num_layers_to_draw = self.max_layers
self.printed_until = -1
self.only_current = False
self.initialized = False
self.loaded = True
......@@ -365,6 +366,7 @@ class GcodeModel(Model):
# Draw printed stuff until end or end_prev_layer
cur_end = min(self.printed_until, end)
if not self.only_current:
if 0 <= end_prev_layer <= cur_end:
glDrawArrays(GL_LINES, start, end_prev_layer)
elif cur_end >= 0:
......@@ -375,6 +377,7 @@ class GcodeModel(Model):
# Draw nonprinted stuff until end_prev_layer
start = max(cur_end, 0)
if end_prev_layer >= start:
if not self.only_current:
glDrawArrays(GL_LINES, start, end_prev_layer - start)
cur_end = end_prev_layer
......@@ -405,7 +408,7 @@ class GcodeModel(Model):
# Draw non printed stuff until end (if not ending at a given layer)
start = max(self.printed_until, 0)
end = end - start
if end_prev_layer < 0 and end > 0:
if end_prev_layer < 0 and end > 0 and not self.only_current:
glDrawArrays(GL_LINES, start, end)
self.vertex_buffer.unbind()
......
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