Some changes to gcode window toggles (#2704)

* Show gcode window automatically (#2572)

* Move the show gcode toggle to view menu, and remember if gcode window is shown last time

* fix an issue when merging main branch

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Noisyfox 2023-11-29 21:19:56 +08:00 committed by GitHub
parent b86b8ea810
commit 284c3e71eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 29 deletions

View file

@ -550,7 +550,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, f
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
if (!m_visible || !wxGetApp().show_gcode_window() || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
if (!wxGetApp().show_gcode_window() || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
return;
// window height
@ -675,8 +675,12 @@ void GCodeViewer::SequentialView::GCodeWindow::stop_mapping_file()
}
void GCodeViewer::SequentialView::render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type)
{
if (has_render_path)
marker.render(canvas_width, canvas_height, view_type);
if (has_render_path && m_show_marker) {
marker.set_world_position(current_position);
marker.set_world_offset(current_offset);
marker.render(canvas_width, canvas_height, view_type);
}
//float bottom = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size().get_height();
// BBS
@ -973,7 +977,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
m_settings_ids = gcode_result.settings_ids;
m_filament_diameters = gcode_result.filament_diameters;
m_filament_densities = gcode_result.filament_densities;
m_sequential_view.m_show_gcode_window = false;
m_sequential_view.m_show_marker = false;
//BBS: always load shell at preview
/*if (wxGetApp().is_editor())
@ -1254,15 +1258,9 @@ void GCodeViewer::render(int canvas_width, int canvas_height, int right_margin)
//BBS fixed bottom_margin for space to render horiz slider
int bottom_margin = SLIDER_BOTTOM_MARGIN * GCODE_VIEWER_SLIDER_SCALE;
m_sequential_view.m_show_gcode_window =
m_sequential_view.m_show_gcode_window ||
(m_sequential_view.current.last != m_sequential_view.endpoints.last && !m_no_render_path);
if (m_sequential_view.m_show_gcode_window) {
m_sequential_view.marker.set_world_position(m_sequential_view.current_position);
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
//BBS fixed buttom margin. m_moves_slider.pos_y
m_sequential_view.render(!m_no_render_path, legend_height, canvas_width, canvas_height - bottom_margin * m_scale, right_margin * m_scale, m_view_type);
}
m_sequential_view.m_show_marker = m_sequential_view.m_show_marker || (m_sequential_view.current.last != m_sequential_view.endpoints.last && !m_no_render_path);
// BBS fixed buttom margin. m_moves_slider.pos_y
m_sequential_view.render(!m_no_render_path, legend_height, canvas_width, canvas_height - bottom_margin * m_scale, right_margin * m_scale, m_view_type);
#if ENABLE_GCODE_VIEWER_STATISTICS
render_statistics();
#endif // ENABLE_GCODE_VIEWER_STATISTICS