diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 5d9644457d..7612af0e90 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1147,7 +1147,6 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) else if (delta_pos[X] != 0.0f || delta_pos[Y] != 0.0f || delta_pos[Z] != 0.0f) type = EMoveType::Travel; -#if ENABLE_GCODE_VIEWER_AS_STATE if (type == EMoveType::Extrude && (m_width == 0.0f || m_height == 0.0f)) { if (m_extrusion_role != erCustom) { m_width = 0.5f; @@ -1155,10 +1154,6 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) } type = EMoveType::Travel; } -#else - if (type == EMoveType::Extrude && (m_width == 0.0f || m_height == 0.0f || !is_valid_extrusion_role(m_extrusion_role))) - type = EMoveType::Travel; -#endif // ENABLE_GCODE_VIEWER_AS_STATE return type; }; diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 526300e55a..101c320db8 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -244,10 +244,8 @@ namespace Slic3r { { unsigned int id; std::vector moves; -#if ENABLE_GCODE_VIEWER_AS_STATE Pointfs bed_shape; std::vector extruder_colors; -#endif // ENABLE_GCODE_VIEWER_AS_STATE PrintEstimatedTimeStatistics time_statistics; #if ENABLE_GCODE_VIEWER_STATISTICS @@ -256,19 +254,15 @@ namespace Slic3r { { time = 0; moves = std::vector(); -#if ENABLE_GCODE_VIEWER_AS_STATE bed_shape = Pointfs(); extruder_colors = std::vector(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE } #else void reset() { moves = std::vector(); -#if ENABLE_GCODE_VIEWER_AS_STATE bed_shape = Pointfs(); extruder_colors = std::vector(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE } #endif // ENABLE_GCODE_VIEWER_STATISTICS }; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 569a73bab1..c14e2df52f 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -58,7 +58,6 @@ #define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1) #define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER) #define ENABLE_GCODE_VIEWER_SHADERS_EDITOR (0 && ENABLE_GCODE_VIEWER) -#define ENABLE_GCODE_VIEWER_AS_STATE (1 && ENABLE_GCODE_VIEWER) #define ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR (1 && ENABLE_GCODE_VIEWER) #define ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG (1 && ENABLE_GCODE_VIEWER) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 4faa0486ff..e746635ee2 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -7,9 +7,7 @@ #include "libslic3r/Model.hpp" #include "libslic3r/Utils.hpp" #include "GUI_App.hpp" -#if ENABLE_GCODE_VIEWER_AS_STATE #include "MainFrame.hpp" -#endif // ENABLE_GCODE_VIEWER_AS_STATE #include "Plater.hpp" #include "PresetBundle.hpp" #include "Camera.hpp" @@ -314,13 +312,9 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& reset(); load_toolpaths(gcode_result); -#if ENABLE_GCODE_VIEWER_AS_STATE if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) -#endif // ENABLE_GCODE_VIEWER_AS_STATE load_shells(print, initialized); - -#if ENABLE_GCODE_VIEWER_AS_STATE - if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) { + else { Pointfs bed_shape; if (!gcode_result.bed_shape.empty()) // bed shape detected in the gcode @@ -337,7 +331,6 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& } wxGetApp().plater()->set_bed_shape(bed_shape, "", "", true); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE m_time_statistics = gcode_result.time_statistics; } @@ -351,12 +344,10 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std: if (m_vertices_count == 0) return; -#if ENABLE_GCODE_VIEWER_AS_STATE if (m_view_type == EViewType::Tool && !gcode_result.extruder_colors.empty()) // update tool colors from config stored in the gcode m_tool_colors = decode_colors(gcode_result.extruder_colors); else -#endif // ENABLE_GCODE_VIEWER_AS_STATE // update tool colors m_tool_colors = decode_colors(str_tool_colors); @@ -841,17 +832,13 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) for (size_t i = 0; i < m_vertices_count; ++i) { const GCodeProcessor::MoveVertex& move = gcode_result.moves[i]; -#if ENABLE_GCODE_VIEWER_AS_STATE if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) // for the gcode viewer we need all moves to correctly size the printbed m_paths_bounding_box.merge(move.position.cast()); else { -#endif // ENABLE_GCODE_VIEWER_AS_STATE if (move.type == EMoveType::Extrude && move.width != 0.0f && move.height != 0.0f) m_paths_bounding_box.merge(move.position.cast()); -#if ENABLE_GCODE_VIEWER_AS_STATE } -#endif // ENABLE_GCODE_VIEWER_AS_STATE } // add origin diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index dc8b21ce8d..2a744d72d7 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1913,12 +1913,12 @@ void GLCanvas3D::zoom_to_selection() _zoom_to_box(m_selection.get_bounding_box()); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void GLCanvas3D::zoom_to_gcode() { _zoom_to_box(m_gcode_viewer.get_paths_bounding_box(), 1.05); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER void GLCanvas3D::select_view(const std::string& direction) { @@ -2696,9 +2696,7 @@ static void load_gcode_retractions(const GCodePreviewData::Retraction& retractio void GLCanvas3D::load_gcode_preview(const GCodeProcessor::Result& gcode_result) { m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized); -#if ENABLE_GCODE_VIEWER_AS_STATE if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) -#endif // ENABLE_GCODE_VIEWER_AS_STATE _show_warning_texture_if_needed(WarningTexture::ToolpathOutside); } @@ -4280,17 +4278,15 @@ void GLCanvas3D::update_ui_from_settings() } #endif // ENABLE_RETINA_GL -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER if (wxGetApp().mainframe != nullptr && wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) wxGetApp().plater()->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1"); #else bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1"; wxGetApp().plater()->get_collapse_toolbar().set_enabled(enable_collapse); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER } - - GLCanvas3D::WipeTowerInfo GLCanvas3D::get_wipe_tower_info() const { WipeTowerInfo wti; @@ -5385,22 +5381,16 @@ static BoundingBoxf3 print_volume(const DynamicPrintConfig& config) void GLCanvas3D::_render_background() const { #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STATE bool use_error_color = false; if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) { use_error_color = m_dynamic_background_enabled; -#else - bool use_error_color = m_dynamic_background_enabled; -#endif // ENABLE_GCODE_VIEWER_AS_STATE if (!m_volumes.empty()) use_error_color &= _is_any_volume_outside(); else { BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3(); use_error_color &= (test_volume.radius() > 0.0) ? !test_volume.contains(m_gcode_viewer.get_paths_bounding_box()) : false; } -#if ENABLE_GCODE_VIEWER_AS_STATE } -#endif // ENABLE_GCODE_VIEWER_AS_STATE #endif // ENABLE_GCODE_VIEWER glsafe(::glPushMatrix()); @@ -7119,20 +7109,13 @@ void GLCanvas3D::_show_warning_texture_if_needed(WarningTexture::Warning warning bool show = false; if (!m_volumes.empty()) show = _is_any_volume_outside(); - else - { -#if ENABLE_GCODE_VIEWER_AS_STATE - if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) - { + else { + if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) { BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3(); const BoundingBoxf3& paths_volume = m_gcode_viewer.get_paths_bounding_box(); if (test_volume.radius() > 0.0 && paths_volume.radius() > 0.0) show = !test_volume.contains(paths_volume); } -#else - BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3(); - show = (test_volume.radius() > 0.0) ? !test_volume.contains(m_gcode_viewer.get_bounding_box()) : false; -#endif // ENABLE_GCODE_VIEWER_AS_STATE } _set_warning_texture(warning, show); #else diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 0b5a357fdb..15bb3e6f06 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -625,9 +625,9 @@ public: void zoom_to_bed(); void zoom_to_volumes(); void zoom_to_selection(); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void zoom_to_gcode(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER void select_view(const std::string& direction); void update_volumes_colors_by_extruder(); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 2fb60bf374..433e026f6c 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -754,7 +754,7 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const dialog.GetPaths(input_files); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const { input_file.Clear(); @@ -766,7 +766,7 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const if (dialog.ShowModal() == wxID_OK) input_file = dialog.GetPath(); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER bool GUI_App::switch_language() { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index ad874bd1ef..aa94475319 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -156,9 +156,9 @@ public: void keyboard_shortcuts(); void load_project(wxWindow *parent, wxString& input_file) const; void import_model(wxWindow *parent, wxArrayString& input_files) const; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void load_gcode(wxWindow* parent, wxString& input_file) const; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER static bool catch_error(std::function cb, const std::string& err); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 556f5de8cd..98c02322ee 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -13,9 +13,9 @@ #include "PresetBundle.hpp" #include "DoubleSlider.hpp" #include "Plater.hpp" -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER #include "MainFrame.hpp" -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER #include #include @@ -1196,11 +1196,11 @@ void Preview::update_double_slider_from_canvas(wxKeyEvent & event) void Preview::load_print_as_fff(bool keep_z_range) { -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER if (wxGetApp().mainframe == nullptr) // avoid proessing while mainframe is being constructed return; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER if (m_loaded || m_process->current_printer_technology() != ptFFF) return; @@ -1225,11 +1225,11 @@ void Preview::load_print_as_fff(bool keep_z_range) } } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer && !has_layers) #else if (! has_layers) -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER { #if ENABLE_GCODE_VIEWER hide_layers_slider(); @@ -1265,11 +1265,7 @@ void Preview::load_print_as_fff(bool keep_z_range) #if ENABLE_GCODE_VIEWER GCodeViewer::EViewType gcode_view_type = m_canvas->get_gcode_view_preview_type(); -#if ENABLE_GCODE_VIEWER_AS_STATE bool gcode_preview_data_valid = !m_gcode_result->moves.empty(); -#else - bool gcode_preview_data_valid = print->is_step_done(psGCodeExport); -#endif // ENABLE_GCODE_VIEWER_AS_STATE #else bool gcode_preview_data_valid = print->is_step_done(psGCodeExport) && ! m_gcode_preview_data->empty(); #endif // ENABLE_GCODE_VIEWER diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 778ce2134f..f017900f46 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -111,7 +111,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S // initialize tabpanel and menubar init_tabpanel(); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER init_editor_menubar(); init_gcodeviewer_menubar(); @@ -129,7 +129,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S #endif // _WIN32 #else init_menubar(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // set default tooltip timer in msec // SetAutoPop supposedly accepts long integers but some bug doesn't allow for larger values @@ -243,9 +243,9 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S update_ui_from_settings(); // FIXME (?) if (m_plater != nullptr) { -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER m_plater->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1"); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER m_plater->show_action_buttons(true); } } @@ -291,7 +291,7 @@ void MainFrame::update_layout() Layout(); }; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER ESettingsLayout layout = (m_mode == EMode::GCodeViewer) ? ESettingsLayout::GCodeViewer : (wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old : wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New : @@ -300,7 +300,7 @@ void MainFrame::update_layout() ESettingsLayout layout = wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old : wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New : wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER if (m_layout == layout) return; @@ -356,14 +356,14 @@ void MainFrame::update_layout() m_plater->Show(); break; } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER case ESettingsLayout::GCodeViewer: { m_main_sizer->Add(m_plater, 1, wxEXPAND); m_plater->Show(); break; } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER } //#ifdef __APPLE__ @@ -398,7 +398,7 @@ void MainFrame::shutdown() } #endif // _WIN32 -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER if (m_plater != nullptr) { m_plater->stop_jobs(); @@ -423,7 +423,7 @@ void MainFrame::shutdown() // Cleanup of canvases' volumes needs to be done here or a crash may happen on some Linux Debian flavours // see: https://github.com/prusa3d/PrusaSlicer/issues/3964 if (m_plater) m_plater->reset_canvas_volumes(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // Weird things happen as the Paint messages are floating around the windows being destructed. // Avoid the Paint messages by hiding the main window. @@ -436,11 +436,11 @@ void MainFrame::shutdown() m_settings_dialog.Close(); if (m_plater != nullptr) { -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER // restore sidebar if it was hidden when switching to gcode viewer mode if (m_restore_from_gcode_viewer.collapsed_sidebar) m_plater->collapse_sidebar(false); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // Stop the background thread (Windows and Linux). // Disconnect from a 3DConnextion driver (OSX). m_plater->get_mouse3d_controller().shutdown(); @@ -781,7 +781,7 @@ void MainFrame::on_sys_color_changed() msw_rescale_menu(menu_bar->GetMenu(id)); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER #ifdef _MSC_VER // \xA0 is a non-breaking space. It is entered here to spoil the automatic accelerators, // as the simple numeric accelerators spoil all numeric data entry. @@ -855,7 +855,7 @@ static void add_common_view_menu_items(wxMenu* view_menu, MainFrame* mainFrame, void MainFrame::init_editor_menubar() #else void MainFrame::init_menubar() -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER { #ifdef __APPLE__ wxMenuBar::SetAutoWindowMenu(false); @@ -1015,7 +1015,7 @@ void MainFrame::init_menubar() append_menu_item(fileMenu, wxID_ANY, _L("&Repair STL file") + dots, _L("Automatically repair an STL file"), [this](wxCommandEvent&) { repair_stl(); }, "wrench", nullptr, [this]() { return true; }, this); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER fileMenu->AppendSeparator(); append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview"), _L("Switch to G-code preview mode"), [this](wxCommandEvent&) { @@ -1023,13 +1023,13 @@ void MainFrame::init_menubar() set_mode(EMode::GCodeViewer); }, "", nullptr, [this]() { return m_plater != nullptr && m_plater->printer_technology() != ptSLA; }, this); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER fileMenu->AppendSeparator(); append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME), [this](wxCommandEvent&) { Close(false); }); } -#if !ENABLE_GCODE_VIEWER_AS_STATE +#if !ENABLE_GCODE_VIEWER #ifdef _MSC_VER // \xA0 is a non-breaking space. It is entered here to spoil the automatic accelerators, // as the simple numeric accelerators spoil all numeric data entry. @@ -1039,7 +1039,7 @@ void MainFrame::init_menubar() wxString sep = " - "; wxString sep_space = ""; #endif -#endif // !ENABLE_GCODE_VIEWER_AS_STATE +#endif // !ENABLE_GCODE_VIEWER // Edit menu wxMenu* editMenu = nullptr; @@ -1123,7 +1123,7 @@ void MainFrame::init_menubar() [this](){return can_change_view(); }, this); } -#if !ENABLE_GCODE_VIEWER_AS_STATE +#if !ENABLE_GCODE_VIEWER #if _WIN32 // This is needed on Windows to fake the CTRL+# of the window menu when using the numpad wxAcceleratorEntry entries[6]; @@ -1136,7 +1136,7 @@ void MainFrame::init_menubar() wxAcceleratorTable accel(6, entries); SetAcceleratorTable(accel); #endif // _WIN32 -#endif // !ENABLE_GCODE_VIEWER_AS_STATE +#endif // !ENABLE_GCODE_VIEWER windowMenu->AppendSeparator(); append_menu_item(windowMenu, wxID_ANY, _L("Print &Host Upload Queue") + "\tCtrl+J", _L("Display the Print Host Upload Queue window"), @@ -1148,7 +1148,7 @@ void MainFrame::init_menubar() wxMenu* viewMenu = nullptr; if (m_plater) { viewMenu = new wxMenu(); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER add_common_view_menu_items(viewMenu, this, std::bind(&MainFrame::can_change_view, this)); #else // The camera control accelerators are captured by GLCanvas3D::on_char(). @@ -1169,7 +1169,7 @@ void MainFrame::init_menubar() "", nullptr, [this](){return can_change_view(); }, this); append_menu_item(viewMenu, wxID_ANY, _L("Right") + sep + "&6", _L("Right View"), [this](wxCommandEvent&) { select_view("right"); }, "", nullptr, [this](){return can_change_view(); }, this); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER viewMenu->AppendSeparator(); #if ENABLE_SLOPE_RENDERING wxMenu* options_menu = new wxMenu(); @@ -1191,7 +1191,7 @@ void MainFrame::init_menubar() } // Help menu -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER auto helpMenu = generate_help_menu(); #else auto helpMenu = new wxMenu(); @@ -1228,12 +1228,12 @@ void MainFrame::init_menubar() [this](wxCommandEvent&) { wxGetApp().gcode_thumbnails_debug(); }); #endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // menubar // assign menubar to frame after appending items, otherwise special items // will not be handled correctly -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER m_editor_menubar = new wxMenuBar(); m_editor_menubar->Append(fileMenu, _L("&File")); if (editMenu) m_editor_menubar->Append(editMenu, _L("&Edit")); @@ -1253,16 +1253,16 @@ void MainFrame::init_menubar() wxGetApp().add_config_menu(menubar); menubar->Append(helpMenu, _(L("&Help"))); SetMenuBar(menubar); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER #ifdef __APPLE__ // This fixes a bug on Mac OS where the quit command doesn't emit window close events // wx bug: https://trac.wxwidgets.org/ticket/18328 -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER wxMenu* apple_menu = m_editor_menubar->OSXGetAppleMenu(); #else wxMenu *apple_menu = menubar->OSXGetAppleMenu(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER if (apple_menu != nullptr) { apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent &) { Close(); @@ -1271,14 +1271,14 @@ void MainFrame::init_menubar() #endif if (plater()->printer_technology() == ptSLA) -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER update_editor_menubar(); #else update_menubar(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void MainFrame::init_gcodeviewer_menubar() { wxMenu* fileMenu = new wxMenu; @@ -1412,13 +1412,13 @@ void MainFrame::set_mode(EMode mode) } } } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void MainFrame::update_editor_menubar() #else void MainFrame::update_menubar() -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER { const bool is_fff = plater()->printer_technology() == ptFFF; diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 8a3e4376b4..8961ad7172 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -68,7 +68,7 @@ class MainFrame : public DPIFrame wxString m_qs_last_input_file = wxEmptyString; wxString m_qs_last_output_file = wxEmptyString; wxString m_last_config = wxEmptyString; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER wxMenuBar* m_editor_menubar{ nullptr }; wxMenuBar* m_gcodeviewer_menubar{ nullptr }; @@ -79,7 +79,7 @@ class MainFrame : public DPIFrame }; RestoreFromGCodeViewer m_restore_from_gcode_viewer; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER #if 0 wxMenuItem* m_menu_item_repeat { nullptr }; // doesn't used now @@ -134,14 +134,14 @@ class MainFrame : public DPIFrame Old, New, Dlg, -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER GCodeViewer -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER }; ESettingsLayout m_layout{ ESettingsLayout::Unknown }; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER public: enum class EMode : unsigned char { @@ -151,7 +151,7 @@ public: private: EMode m_mode{ EMode::Editor }; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER protected: virtual void on_dpi_changed(const wxRect &suggested_rect); @@ -173,7 +173,7 @@ public: void init_tabpanel(); void create_preset_tabs(); void add_created_tab(Tab* panel); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void init_editor_menubar(); void update_editor_menubar(); void init_gcodeviewer_menubar(); @@ -183,7 +183,7 @@ public: #else void init_menubar(); void update_menubar(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER void update_ui_from_settings(); bool is_loaded() const { return m_loaded; } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 43cf27e30f..b87b3cce36 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -33,13 +33,11 @@ #include "libslic3r/Format/STL.hpp" #include "libslic3r/Format/AMF.hpp" #include "libslic3r/Format/3mf.hpp" -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER #include "libslic3r/GCode/GCodeProcessor.hpp" #else -#if !ENABLE_GCODE_VIEWER #include "libslic3r/GCode/PreviewData.hpp" -#endif // !ENABLE_GCODE_VIEWER -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER #include "libslic3r/GCode/ThumbnailData.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/SLA/Hollowing.hpp" @@ -2767,10 +2765,8 @@ void Plater::priv::reset() #if ENABLE_GCODE_VIEWER reset_gcode_toolpaths(); -#endif // ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STATE gcode_result.reset(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // Stop and reset the Print content. this->background_process.reset(); @@ -4633,7 +4629,7 @@ void Plater::extract_config_from_project() load_files(input_paths, false, true); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void Plater::load_gcode() { // Ask user for a gcode file name. @@ -4669,7 +4665,7 @@ void Plater::load_gcode(const wxString& filename) p->preview->reload_print(false); p->preview->get_canvas3d()->zoom_to_gcode(); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER std::vector Plater::load_files(const std::vector& input_files, bool load_model, bool load_config, bool imperial_units /*= false*/) { return p->load_files(input_files, load_model, load_config, imperial_units); } @@ -5443,7 +5439,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config) void Plater::set_bed_shape() const { -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER set_bed_shape(p->config->option("bed_shape")->values, p->config->option("bed_custom_texture")->value, p->config->option("bed_custom_model")->value); @@ -5451,15 +5447,15 @@ void Plater::set_bed_shape() const p->set_bed_shape(p->config->option("bed_shape")->values, p->config->option("bed_custom_texture")->value, p->config->option("bed_custom_model")->value); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void Plater::set_bed_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom) const { p->set_bed_shape(shape, custom_texture, custom_model, force_as_custom); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER void Plater::force_filament_colors_update() { @@ -5634,11 +5630,11 @@ void Plater::set_printer_technology(PrinterTechnology printer_technology) p->label_btn_send = printer_technology == ptFFF ? L("Send G-code") : L("Send to printer"); if (wxGetApp().mainframe != nullptr) -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER wxGetApp().mainframe->update_editor_menubar(); #else wxGetApp().mainframe->update_menubar(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER p->update_main_toolbar_tooltips(); @@ -5790,24 +5786,24 @@ bool Plater::init_view_toolbar() return p->init_view_toolbar(); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void Plater::enable_view_toolbar(bool enable) { p->view_toolbar.set_enabled(enable); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER bool Plater::init_collapse_toolbar() { return p->init_collapse_toolbar(); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void Plater::enable_collapse_toolbar(bool enable) { p->collapse_toolbar.set_enabled(enable); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER const Camera& Plater::get_camera() const { @@ -5936,9 +5932,9 @@ bool Plater::can_undo() const { return p->undo_redo_stack().has_undo_snapshot(); bool Plater::can_redo() const { return p->undo_redo_stack().has_redo_snapshot(); } bool Plater::can_reload_from_disk() const { return p->can_reload_from_disk(); } const UndoRedo::Stack& Plater::undo_redo_stack_main() const { return p->undo_redo_stack_main(); } -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void Plater::clear_undo_redo_stack_main() { p->undo_redo_stack_main().clear(); } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER void Plater::enter_gizmos_stack() { p->enter_gizmos_stack(); } void Plater::leave_gizmos_stack() { p->leave_gizmos_stack(); } bool Plater::inside_snapshot_capture() { return p->inside_snapshot_capture(); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 59d595bbe4..8142a7c359 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -173,10 +173,10 @@ public: void add_model(bool imperial_units = false); void import_sl1_archive(); void extract_config_from_project(); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void load_gcode(); void load_gcode(const wxString& filename); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER std::vector load_files(const std::vector& input_files, bool load_model = true, bool load_config = true, bool imperial_units = false); // To be called when providing a list of files to the GUI slic3r on command line. @@ -256,9 +256,9 @@ public: bool search_string_getter(int idx, const char** label, const char** tooltip); // For the memory statistics. const Slic3r::UndoRedo::Stack& undo_redo_stack_main() const; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void clear_undo_redo_stack_main(); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // Enter / leave the Gizmos specific Undo / Redo stack. To be used by the SLA support point editing gizmo. void enter_gizmos_stack(); void leave_gizmos_stack(); @@ -322,13 +322,13 @@ public: void sys_color_changed(); bool init_view_toolbar(); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void enable_view_toolbar(bool enable); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER bool init_collapse_toolbar(); -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void enable_collapse_toolbar(bool enable); -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER const Camera& get_camera() const; Camera& get_camera(); @@ -352,19 +352,16 @@ public: void update_preview_moves_slider(); void reset_gcode_toolpaths(); -#endif // ENABLE_GCODE_VIEWER - -#if ENABLE_GCODE_VIEWER_AS_STATE void reset_last_loaded_gcode() { m_last_loaded_gcode = ""; } -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER const Mouse3DController& get_mouse3d_controller() const; Mouse3DController& get_mouse3d_controller(); void set_bed_shape() const; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER void set_bed_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false) const; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER // ROII wrapper for suppressing the Undo / Redo snapshot to be taken. class SuppressSnapshots @@ -415,9 +412,9 @@ private: bool m_tracking_popup_menu = false; wxString m_tracking_popup_menu_error_message; -#if ENABLE_GCODE_VIEWER_AS_STATE +#if ENABLE_GCODE_VIEWER wxString m_last_loaded_gcode; -#endif // ENABLE_GCODE_VIEWER_AS_STATE +#endif // ENABLE_GCODE_VIEWER void suppress_snapshots(); void allow_snapshots();