diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index ff985e3595..0f031ca839 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -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 diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index a91e7b938e..d0bfdc544f 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -650,7 +650,6 @@ public: std::string comment; }; bool m_is_dark = false; - bool m_visible{ true }; uint64_t m_selected_line_id{ 0 }; size_t m_last_lines_size{ 0 }; std::string m_filename; @@ -674,8 +673,6 @@ public: m_filename.shrink_to_fit(); } - void toggle_visibility() { m_visible = !m_visible; } - //BBS: GUI refactor: add canvas size //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; @@ -701,7 +698,7 @@ public: GCodeWindow gcode_window; std::vector gcode_ids; 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); }; @@ -883,8 +880,6 @@ public: void export_toolpaths_to_obj(const char* filename) const; - void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); } - std::vector& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; } size_t get_extruders_count() { return m_extruders_count; } void push_combo_style(); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index bc74bd4441..8bbab3a2bf 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3196,7 +3196,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) //case 'B': //case 'b': { zoom_to_bed(); break; } 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': { // if ((evt.GetModifiers() & shiftMask) != 0) { diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8e6c4f64a2..9a29714f28 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -988,6 +988,12 @@ static void generic_exception_handle() //#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 GUI_App::split_str(std::string src, std::string separator) { std::string::size_type pos; @@ -1165,7 +1171,7 @@ void GUI_App::post_init() if (app_config->get("stealth_mode") == "false") 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) { //updating networking int ret = updating_bambu_networking(); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 7acf5e8f26..7a0631c05f 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -324,7 +324,7 @@ private: // SoftFever 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;}; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 23ae74c7f5..6e5328da9c 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -2508,6 +2508,15 @@ void MainFrame::init_menubar_as_editor() else 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(); 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, diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 6704a03550..64bf3c273f 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -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__ 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_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 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_show_splash_screen, 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(item_stealth_mode, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));