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 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 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; return;
// window height // 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) 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) if (has_render_path && m_show_marker) {
marker.render(canvas_width, canvas_height, view_type); 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(); //float bottom = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size().get_height();
// BBS // BBS
@ -973,7 +977,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
m_settings_ids = gcode_result.settings_ids; m_settings_ids = gcode_result.settings_ids;
m_filament_diameters = gcode_result.filament_diameters; m_filament_diameters = gcode_result.filament_diameters;
m_filament_densities = gcode_result.filament_densities; 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 //BBS: always load shell at preview
/*if (wxGetApp().is_editor()) /*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 //BBS fixed bottom_margin for space to render horiz slider
int bottom_margin = SLIDER_BOTTOM_MARGIN * GCODE_VIEWER_SLIDER_SCALE; int bottom_margin = SLIDER_BOTTOM_MARGIN * GCODE_VIEWER_SLIDER_SCALE;
m_sequential_view.m_show_gcode_window = 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);
m_sequential_view.m_show_gcode_window || // BBS fixed buttom margin. m_moves_slider.pos_y
(m_sequential_view.current.last != m_sequential_view.endpoints.last && !m_no_render_path); 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 (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);
}
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
render_statistics(); render_statistics();
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS

View file

@ -650,7 +650,6 @@ public:
std::string comment; std::string comment;
}; };
bool m_is_dark = false; bool m_is_dark = false;
bool m_visible{ true };
uint64_t m_selected_line_id{ 0 }; uint64_t m_selected_line_id{ 0 };
size_t m_last_lines_size{ 0 }; size_t m_last_lines_size{ 0 };
std::string m_filename; std::string m_filename;
@ -674,8 +673,6 @@ public:
m_filename.shrink_to_fit(); m_filename.shrink_to_fit();
} }
void toggle_visibility() { m_visible = !m_visible; }
//BBS: GUI refactor: add canvas size //BBS: GUI refactor: add canvas size
//void render(float top, float bottom, uint64_t curr_line_id) const; //void render(float top, float bottom, uint64_t curr_line_id) const;
void render(float top, float bottom, float right, uint64_t curr_line_id) const; void render(float top, float bottom, float right, uint64_t curr_line_id) const;
@ -701,7 +698,7 @@ public:
GCodeWindow gcode_window; GCodeWindow gcode_window;
std::vector<unsigned int> gcode_ids; std::vector<unsigned int> gcode_ids;
float m_scale = 1.0; float m_scale = 1.0;
bool m_show_gcode_window = false; bool m_show_marker = false;
void render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type); void render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type);
}; };
@ -883,8 +880,6 @@ public:
void export_toolpaths_to_obj(const char* filename) const; void export_toolpaths_to_obj(const char* filename) const;
void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); }
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; } std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
size_t get_extruders_count() { return m_extruders_count; } size_t get_extruders_count() { return m_extruders_count; }
void push_combo_style(); void push_combo_style();

View file

@ -3196,7 +3196,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
//case 'B': //case 'B':
//case 'b': { zoom_to_bed(); break; } //case 'b': { zoom_to_bed(); break; }
case 'C': case 'C':
case 'c': { m_gcode_viewer.toggle_gcode_window_visibility(); m_dirty = true; request_extra_frame(); break; } case 'c': { wxGetApp().toggle_show_gcode_window(); m_dirty = true; request_extra_frame(); break; }
//case 'G': //case 'G':
//case 'g': { //case 'g': {
// if ((evt.GetModifiers() & shiftMask) != 0) { // if ((evt.GetModifiers() & shiftMask) != 0) {

View file

@ -988,6 +988,12 @@ static void generic_exception_handle()
//#endif //#endif
} }
void GUI_App::toggle_show_gcode_window()
{
m_show_gcode_window = !m_show_gcode_window;
app_config->set_bool("show_gcode_window", m_show_gcode_window);
}
std::vector<std::string> GUI_App::split_str(std::string src, std::string separator) std::vector<std::string> GUI_App::split_str(std::string src, std::string separator)
{ {
std::string::size_type pos; std::string::size_type pos;
@ -1165,7 +1171,7 @@ void GUI_App::post_init()
if (app_config->get("stealth_mode") == "false") if (app_config->get("stealth_mode") == "false")
hms_query = new HMSQuery(); hms_query = new HMSQuery();
m_show_gcode_window = app_config->get("show_gcode_window") == "true"; m_show_gcode_window = app_config->get_bool("show_gcode_window");
if (m_networking_need_update) { if (m_networking_need_update) {
//updating networking //updating networking
int ret = updating_bambu_networking(); int ret = updating_bambu_networking();

View file

@ -324,7 +324,7 @@ private:
// SoftFever // SoftFever
bool show_gcode_window() const { return m_show_gcode_window; } bool show_gcode_window() const { return m_show_gcode_window; }
void set_show_gcode_window(bool val) { m_show_gcode_window = val; } void toggle_show_gcode_window();
wxString get_inf_dialog_contect () {return m_info_dialog_content;}; wxString get_inf_dialog_contect () {return m_info_dialog_content;};

View file

@ -2508,6 +2508,15 @@ void MainFrame::init_menubar_as_editor()
else else
viewMenu->Check(wxID_CAMERA_ORTHOGONAL + camera_id_base, true); viewMenu->Check(wxID_CAMERA_ORTHOGONAL + camera_id_base, true);
viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &G-code Window") + "\tC", _L("Show g-code window in Previce scene"),
[this](wxCommandEvent &) {
wxGetApp().toggle_show_gcode_window();
m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT));
},
this, [this]() { return m_plater->is_preview_shown(); },
[this]() { return wxGetApp().show_gcode_window(); }, this);
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &Labels") + "\t" + ctrl + "E", _L("Show object labels in 3D scene"), append_menu_check_item(viewMenu, wxID_ANY, _L("Show &Labels") + "\t" + ctrl + "E", _L("Show object labels in 3D scene"),
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT)); }, this, [this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT)); }, this,

View file

@ -681,11 +681,6 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
} }
} }
if (param == "show_gcode_window") {
bool pbool = app_config->get("show_gcode_window") == "true" ? true : false;
wxGetApp().set_show_gcode_window(pbool);
}
#endif // __WXMSW__ #endif // __WXMSW__
if (param == "developer_mode") if (param == "developer_mode")
@ -987,7 +982,6 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_show_splash_screen = create_item_checkbox(_L("Show splash screen"), page, _L("Show the splash screen during startup."), 50, "show_splash_screen"); auto item_show_splash_screen = create_item_checkbox(_L("Show splash screen"), page, _L("Show the splash screen during startup."), 50, "show_splash_screen");
auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints"); auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints");
auto item_gcode_window = create_item_checkbox(_L("Show g-code window"), page, _L("If enabled, g-code window will be displayed."), 50, "show_gcode_window");
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets")); auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset"); auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset");
@ -1048,7 +1042,6 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_use_free_camera_settings, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_use_free_camera_settings, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_show_splash_screen, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_show_splash_screen, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_gcode_window, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20)); sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));