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