From 88457bf4124310bdaca8d37e5b16e122b415e348 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 10 Sep 2020 08:49:50 +0200 Subject: [PATCH] Tech ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION set as default --- src/PrusaSlicer.cpp | 33 ++-- src/libslic3r/AppConfig.cpp | 4 +- src/libslic3r/AppConfig.hpp | 12 +- src/libslic3r/Technologies.hpp | 1 - src/slic3r/GUI/GCodeViewer.cpp | 8 - src/slic3r/GUI/GLCanvas3D.cpp | 16 -- src/slic3r/GUI/GUI_App.cpp | 40 ++--- src/slic3r/GUI/GUI_App.hpp | 16 +- src/slic3r/GUI/GUI_Preview.cpp | 4 - src/slic3r/GUI/GUI_Preview.hpp | 10 +- src/slic3r/GUI/KBShortcutsDialog.cpp | 8 - src/slic3r/GUI/MainFrame.cpp | 233 ++------------------------- src/slic3r/GUI/MainFrame.hpp | 35 +--- src/slic3r/GUI/Plater.cpp | 50 +----- 14 files changed, 77 insertions(+), 393 deletions(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index 7972d49b7..05e84b941 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -140,7 +140,7 @@ int CLI::run(int argc, char **argv) m_print_config.apply(config); } -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER // are we starting as gcodeviewer ? for (auto it = m_actions.begin(); it != m_actions.end(); ++it) { if (*it == "gcodeviewer") { @@ -150,12 +150,12 @@ int CLI::run(int argc, char **argv) break; } } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // Read input file(s) if any. -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (!start_as_gcodeviewer) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER for (const std::string& file : m_input_files) { if (!boost::filesystem::exists(file)) { boost::nowide::cerr << "No such file: " << file << std::endl; @@ -188,9 +188,9 @@ int CLI::run(int argc, char **argv) } m_models.push_back(model); } -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // Apply command line options to a more specific DynamicPrintConfig which provides normalize() // (command line options override --load files) @@ -549,11 +549,11 @@ int CLI::run(int argc, char **argv) << " (" << print.total_extruded_volume()/1000 << "cm3)" << std::endl; */ } -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if !ENABLE_GCODE_VIEWER } else if (opt_key == "gcodeviewer") { start_gui = true; start_as_gcodeviewer = true; -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // !ENABLE_GCODE_VIEWER } else { boost::nowide::cerr << "error: option not supported yet: " << opt_key << std::endl; return 1; @@ -563,11 +563,11 @@ int CLI::run(int argc, char **argv) if (start_gui) { #ifdef SLIC3R_GUI // #ifdef USE_WX -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER GUI::GUI_App* gui = new GUI::GUI_App(start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor); #else GUI::GUI_App *gui = new GUI::GUI_App(); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1"; if (Slic3r::instance_check(argc, argv, gui_single_instance_setting)) { @@ -577,22 +577,21 @@ int CLI::run(int argc, char **argv) // gui->autosave = m_config.opt_string("autosave"); GUI::GUI_App::SetInstance(gui); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER gui->CallAfter([gui, this, &load_configs, start_as_gcodeviewer] { #else gui->CallAfter([gui, this, &load_configs] { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - +#endif // ENABLE_GCODE_VIEWER if (!gui->initialized()) { return; } -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (start_as_gcodeviewer) { if (!m_input_files.empty()) gui->plater()->load_gcode(wxString::FromUTF8(m_input_files[0])); } else { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER_AS #if 0 // Load the cummulative config over the currently active profiles. //FIXME if multiple configs are loaded, only the last one will have an effect. @@ -611,9 +610,9 @@ int CLI::run(int argc, char **argv) gui->plater()->load_files(m_input_files, true, true); if (!m_extra_config.empty()) gui->mainframe->load_config(m_extra_config); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER }); int result = wxEntry(argc, argv); return result; diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index db3bd78dd..2d96e0b50 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -179,10 +179,10 @@ std::string AppConfig::load() void AppConfig::save() { -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (!m_save_enabled) return; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // The config is first written to a file with a PID suffix and then moved // to avoid race conditions with multiple instances of Slic3r diff --git a/src/libslic3r/AppConfig.hpp b/src/libslic3r/AppConfig.hpp index 3f4ce2008..f22a6314a 100644 --- a/src/libslic3r/AppConfig.hpp +++ b/src/libslic3r/AppConfig.hpp @@ -18,9 +18,9 @@ public: AppConfig() : m_dirty(false), m_orig_version(Semver::invalid()), -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER m_save_enabled(true), -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER m_legacy_datadir(false) { this->reset(); @@ -160,9 +160,9 @@ public: bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const { return get_3dmouse_device_numeric_value(name, "swap_yz", swap); } -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER void enable_save(bool enable) { m_save_enabled = enable; } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER static const std::string SECTION_FILAMENTS; static const std::string SECTION_MATERIALS; @@ -190,10 +190,10 @@ private: bool m_dirty; // Original version found in the ini file before it was overwritten Semver m_orig_version; -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER // Whether or not calls to save() should take effect bool m_save_enabled; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // Whether the existing version is before system profiles & configuration updating bool m_legacy_datadir; }; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 2dbad472f..a0484b259 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -59,6 +59,5 @@ #define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER) #define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER) #define ENABLE_GCODE_VIEWER_TASKBAR_ICON (0 && ENABLE_GCODE_VIEWER) -#define ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION (1 && ENABLE_GCODE_VIEWER) #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 2b9bf8ca4..5984afaa4 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -339,11 +339,7 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& reset(); load_toolpaths(gcode_result); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_editor()) -#else - if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION load_shells(print, initialized); else { Pointfs bed_shape; @@ -879,11 +875,7 @@ 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_STANDALONE_APPLICATION if (wxGetApp().is_gcode_viewer()) -#else - if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION // for the gcode viewer we need all moves to correctly size the printbed m_paths_bounding_box.merge(move.position.cast()); else { diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 2f9f9464c..00034087c 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2732,11 +2732,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_STANDALONE_APPLICATION if (wxGetApp().is_editor()) -#else - if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION _show_warning_texture_if_needed(WarningTexture::ToolpathOutside); } @@ -4306,11 +4302,7 @@ void GLCanvas3D::update_ui_from_settings() #endif // ENABLE_RETINA_GL #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_editor()) -#else - if (wxGetApp().mainframe != nullptr && wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION 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"; @@ -5413,11 +5405,7 @@ void GLCanvas3D::_render_background() const { #if ENABLE_GCODE_VIEWER bool use_error_color = false; -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_editor()) { -#else - if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION use_error_color = m_dynamic_background_enabled; if (!m_volumes.empty()) use_error_color &= _is_any_volume_outside(); @@ -7146,11 +7134,7 @@ void GLCanvas3D::_show_warning_texture_if_needed(WarningTexture::Warning warning if (!m_volumes.empty()) show = _is_any_volume_outside(); else { -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_editor()) { -#else - if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION 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) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index aeac415f7..f6b0a4414 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -434,15 +434,15 @@ static void generic_exception_handle() IMPLEMENT_APP(GUI_App) -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER GUI_App::GUI_App(EAppMode mode) #else GUI_App::GUI_App() -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER : wxApp() -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER , m_app_mode(mode) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER , m_em_unit(10) , m_imgui(new ImGuiWrapper()) , m_wizard(nullptr) @@ -498,11 +498,11 @@ void GUI_App::init_app_config() if (!app_config) app_config = new AppConfig(); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (is_gcode_viewer()) // disable config save to avoid to mess it up for the editor app_config->enable_save(false); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // load settings app_conf_exists = app_config->exists(); @@ -577,11 +577,11 @@ bool GUI_App::on_init_inner() wxInitAllImageHandlers(); wxBitmap bitmap = create_scaled_bitmap("prusa_slicer_logo", nullptr, 400); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER wxBitmap bmp(is_editor() ? from_u8(var("splashscreen.jpg")) : from_u8(var("splashscreen-gcodeviewer.jpg")), wxBITMAP_TYPE_JPEG); #else wxBitmap bmp(from_u8(var("splashscreen.jpg")), wxBITMAP_TYPE_JPEG); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER DecorateSplashScreen(bmp); @@ -594,9 +594,9 @@ bool GUI_App::on_init_inner() // supplied as argument to --datadir; in that case we should still run the wizard preset_bundle->setup_directories(); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (is_editor()) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER #ifdef __WXMSW__ associate_3mf_files(); #endif // __WXMSW__ @@ -611,9 +611,9 @@ bool GUI_App::on_init_inner() } } }); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // initialize label colors and fonts init_label_colours(); @@ -641,9 +641,9 @@ bool GUI_App::on_init_inner() Slic3r::I18N::set_translate_callback(libslic3r_translate_callback); // application frame -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (is_editor()) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER scrn->SetText(_L("Creating settings tabs...")); mainframe = new MainFrame(); @@ -679,9 +679,9 @@ bool GUI_App::on_init_inner() static bool once = true; if (once) { once = false; -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (preset_updater != nullptr) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER check_updates(false); CallAfter([this] { @@ -689,9 +689,9 @@ bool GUI_App::on_init_inner() preset_updater->slic3r_update_notify(); preset_updater->sync(preset_bundle); }); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER #ifdef _WIN32 //sets window property to mainframe so other instances can indentify it @@ -700,7 +700,7 @@ bool GUI_App::on_init_inner() } }); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (is_gcode_viewer()) { mainframe->update_layout(); if (plater_ != nullptr) @@ -708,7 +708,7 @@ bool GUI_App::on_init_inner() plater_->set_printer_technology(ptFFF); } else -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER load_current_presets(); mainframe->Show(true); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index d63825de3..9bf470a42 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -94,7 +94,7 @@ static wxString dots("…", wxConvUTF8); class GUI_App : public wxApp { -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER public: enum class EAppMode : unsigned char { @@ -103,13 +103,13 @@ public: }; private: -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER bool m_initialized { false }; bool app_conf_exists{ false }; -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER EAppMode m_app_mode{ EAppMode::Editor }; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER wxColour m_color_label_modified; wxColour m_color_label_sys; @@ -144,18 +144,18 @@ public: bool OnInit() override; bool initialized() const { return m_initialized; } -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER explicit GUI_App(EAppMode mode = EAppMode::Editor); #else GUI_App(); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER ~GUI_App() override; -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER EAppMode get_app_mode() const { return m_app_mode; } bool is_editor() const { return m_app_mode == EAppMode::Editor; } bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER static std::string get_gl_info(bool format_as_html, bool extensions); wxGLContext* init_glcontext(wxGLCanvas& canvas); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 530b3358e..8ea54c6f1 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -1234,11 +1234,7 @@ void Preview::load_print_as_fff(bool keep_z_range) } #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_editor() && !has_layers) -#else - if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer && !has_layers) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #else if (! has_layers) #endif // ENABLE_GCODE_VIEWER diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 629766306..c0a457d9c 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -194,9 +194,7 @@ Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, #if ENABLE_GCODE_VIEWER void update_bottom_toolbar(); void update_moves_slider(); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION void hide_layers_slider(); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #endif // ENABLE_GCODE_VIEWER private: @@ -205,16 +203,12 @@ private: void bind_event_handlers(); void unbind_event_handlers(); -#if ENABLE_GCODE_VIEWER -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - void hide_layers_slider(); -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -#else +#if !ENABLE_GCODE_VIEWER void show_hide_ui_elements(const std::string& what); void reset_sliders(bool reset_all); void update_sliders(const std::vector& layers_z, bool keep_z_range = false); -#endif // ENABLE_GCODE_VIEWER +#endif // !ENABLE_GCODE_VIEWER void on_size(wxSizeEvent& evt); void on_choice_view_type(wxCommandEvent& evt); diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 632bc48ed..0875b76a4 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -95,15 +95,7 @@ void KBShortcutsDialog::fill_shortcuts() const std::string& alt = GUI::shortkey_alt_prefix(); #if ENABLE_GCODE_VIEWER -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - bool is_gcode_viewer = wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer; -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_editor()) { -#else - if (!is_gcode_viewer) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #endif // ENABLE_GCODE_VIEWER Shortcuts commands_shortcuts = { // File diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 5e3fe4cde..2589691a3 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -95,15 +95,15 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO)); } #else -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER switch (wxGetApp().get_app_mode()) { default: case GUI_App::EAppMode::Editor: { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG)); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER break; } case GUI_App::EAppMode::GCodeViewer: @@ -112,7 +112,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S break; } } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER #endif // _WIN32 // initialize status bar @@ -126,15 +126,10 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S // initialize tabpanel and menubar init_tabpanel(); #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_gcode_viewer()) init_menubar_as_gcodeviewer(); else init_menubar_as_editor(); -#else - init_menubar_as_editor(); - init_menubar_as_gcodeviewer(); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #if _WIN32 // This is needed on Windows to fake the CTRL+# of the window menu when using the numpad @@ -165,9 +160,9 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S sizer->Add(m_main_sizer, 1, wxEXPAND); SetSizer(sizer); // initialize layout from config -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (wxGetApp().is_editor()) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER update_layout(); sizer->SetSizeHints(this); Fit(); @@ -320,17 +315,10 @@ void MainFrame::update_layout() }; #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION ESettingsLayout layout = wxGetApp().is_gcode_viewer() ? ESettingsLayout::GCodeViewer : (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); -#else - 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 : - wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #else ESettingsLayout layout = wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old : wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New : @@ -402,12 +390,10 @@ void MainFrame::update_layout() case ESettingsLayout::GCodeViewer: { m_main_sizer->Add(m_plater, 1, wxEXPAND); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, "", "", true); m_plater->enable_view_toolbar(false); m_plater->get_collapse_toolbar().set_enabled(false); m_plater->collapse_sidebar(true); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION m_plater->Show(); break; } @@ -514,17 +500,6 @@ void MainFrame::shutdown() m_settings_dialog.Close(); if (m_plater != nullptr) { -#if ENABLE_GCODE_VIEWER -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - // 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); - - // restore sla printer if it was deselected when switching to gcode viewer mode - if (m_restore_from_gcode_viewer.sla_technology) - m_plater->set_printer_technology(ptSLA); -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -#endif // ENABLE_GCODE_VIEWER // Stop the background thread (Windows and Linux). // Disconnect from a 3DConnextion driver (OSX). m_plater->get_mouse3d_controller().shutdown(); @@ -625,9 +600,9 @@ void MainFrame::init_tabpanel() // or when the preset's "modified" status changes. Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this); // #ys_FIXME_to_delete -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (wxGetApp().is_editor()) -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER create_preset_tabs(); if (m_plater) { @@ -1093,17 +1068,6 @@ void MainFrame::init_menubar() [this](wxCommandEvent&) { repair_stl(); }, "wrench", nullptr, [this]() { return true; }, this); fileMenu->AppendSeparator(); -#if ENABLE_GCODE_VIEWER -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview"), _L("Switch to G-code preview mode"), - [this](wxCommandEvent&) { - if (m_plater->model().objects.empty() || - wxMessageDialog((wxWindow*)this, _L("Switching to G-code preview mode will remove all objects, continue?"), - wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTRE).ShowModal() == wxID_YES) - set_mode(EMode::GCodeViewer); - }, "", nullptr); -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -#endif // ENABLE_GCODE_VIEWER append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview") + dots, _L("Open G-code viewer"), [this](wxCommandEvent&) { start_new_gcodeviewer_open_file(this); }, "", nullptr); fileMenu->AppendSeparator(); @@ -1319,7 +1283,6 @@ void MainFrame::init_menubar() // assign menubar to frame after appending items, otherwise special items // will not be handled correctly #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION m_menubar = new wxMenuBar(); m_menubar->Append(fileMenu, _L("&File")); if (editMenu) m_menubar->Append(editMenu, _L("&Edit")); @@ -1329,17 +1292,6 @@ void MainFrame::init_menubar() wxGetApp().add_config_menu(m_menubar); m_menubar->Append(helpMenu, _L("&Help")); SetMenuBar(m_menubar); -#else - m_editor_menubar = new wxMenuBar(); - m_editor_menubar->Append(fileMenu, _L("&File")); - if (editMenu) m_editor_menubar->Append(editMenu, _L("&Edit")); - m_editor_menubar->Append(windowMenu, _L("&Window")); - if (viewMenu) m_editor_menubar->Append(viewMenu, _L("&View")); - // Add additional menus from C++ - wxGetApp().add_config_menu(m_editor_menubar); - m_editor_menubar->Append(helpMenu, _L("&Help")); - SetMenuBar(m_editor_menubar); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #else auto menubar = new wxMenuBar(); menubar->Append(fileMenu, _L("&File")); @@ -1356,11 +1308,7 @@ void MainFrame::init_menubar() // 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 -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION wxMenu* apple_menu = m_menubar->OSXGetAppleMenu(); -#else - wxMenu* apple_menu = m_editor_menubar->OSXGetAppleMenu(); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #else wxMenu *apple_menu = menubar->OSXGetAppleMenu(); #endif // ENABLE_GCODE_VIEWER @@ -1387,11 +1335,6 @@ void MainFrame::init_menubar_as_gcodeviewer() append_menu_item(fileMenu, wxID_ANY, _L("Export &toolpaths as OBJ") + dots, _L("Export toolpaths as OBJ"), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->export_toolpaths_to_obj(); }, "export_plater", nullptr, [this]() {return can_export_toolpaths(); }, this); -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - fileMenu->AppendSeparator(); - append_menu_item(fileMenu, wxID_ANY, _L("Exit &G-code preview"), _L("Switch to editor mode"), - [this](wxCommandEvent&) { set_mode(EMode::Editor); }); -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION fileMenu->AppendSeparator(); append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME), [this](wxCommandEvent&) { Close(false); }); @@ -1407,28 +1350,16 @@ void MainFrame::init_menubar_as_gcodeviewer() // helpmenu auto helpMenu = generate_help_menu(); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION m_menubar = new wxMenuBar(); m_menubar->Append(fileMenu, _L("&File")); if (viewMenu != nullptr) m_menubar->Append(viewMenu, _L("&View")); m_menubar->Append(helpMenu, _L("&Help")); SetMenuBar(m_menubar); -#else - m_gcodeviewer_menubar = new wxMenuBar(); - m_gcodeviewer_menubar->Append(fileMenu, _L("&File")); - if (viewMenu != nullptr) - m_gcodeviewer_menubar->Append(viewMenu, _L("&View")); - m_gcodeviewer_menubar->Append(helpMenu, _L("&Help")); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #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_STANDALONE_APPLICATION wxMenu* apple_menu = m_menubar->OSXGetAppleMenu(); -#else - wxMenu* apple_menu = m_gcodeviewer_menubar->OSXGetAppleMenu(); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (apple_menu != nullptr) { apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent&) { Close(); @@ -1436,150 +1367,14 @@ void MainFrame::init_menubar_as_gcodeviewer() } #endif // __APPLE__ } - -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -void MainFrame::set_mode(EMode mode) -{ - if (m_mode == mode) - return; - - wxBusyCursor busy; - - m_mode = mode; - switch (m_mode) - { - default: - case EMode::Editor: - { - update_layout(); - select_tab(0); - - m_plater->reset(); - m_plater->reset_gcode_toolpaths(); - - m_plater->Freeze(); - - // reinitialize undo/redo stack - m_plater->clear_undo_redo_stack_main(); - m_plater->take_snapshot(_L("New Project")); - - // restore sla printer if it was deselected when switching to gcode viewer mode - if (m_restore_from_gcode_viewer.sla_technology) { - m_plater->set_printer_technology(ptSLA); - m_restore_from_gcode_viewer.sla_technology = false; - } - - // switch view - m_plater->select_view_3D("3D"); - m_plater->select_view("iso"); - - // switch printbed - m_plater->set_bed_shape(); - - // switch menubar - SetMenuBar(m_editor_menubar); - - // show toolbars - m_plater->enable_view_toolbar(true); - - if (m_restore_from_gcode_viewer.collapse_toolbar_enabled) { - m_plater->get_collapse_toolbar().set_enabled(true); - m_restore_from_gcode_viewer.collapse_toolbar_enabled = false; - } - - // show sidebar - if (m_restore_from_gcode_viewer.collapsed_sidebar) { - m_plater->collapse_sidebar(false); - m_restore_from_gcode_viewer.collapsed_sidebar = false; - } - - m_plater->Thaw(); - -// SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG)); - // Load the icon either from the exe, or from the ico file. -#if _WIN32 - { - - TCHAR szExeFileName[MAX_PATH]; - GetModuleFileName(nullptr, szExeFileName, MAX_PATH); - SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO)); - } -#else - SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG)); -#endif // _WIN32 -#if ENABLE_GCODE_VIEWER_TASKBAR_ICON - if (m_taskbar_icon != nullptr) { - m_taskbar_icon->RemoveIcon(); - m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer"); - } -#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON - - break; - } - case EMode::GCodeViewer: - { - update_layout(); - - m_plater->reset(); - m_plater->reset_last_loaded_gcode(); - m_plater->reset_gcode_toolpaths(); - - m_plater->Freeze(); - - // reinitialize undo/redo stack - m_plater->clear_undo_redo_stack_main(); - m_plater->take_snapshot(_L("New Project")); - - // switch to FFF printer mode - m_restore_from_gcode_viewer.sla_technology = m_plater->set_printer_technology(ptFFF); - - // switch view - m_plater->select_view_3D("Preview"); - m_plater->select_view("iso"); - - // switch printbed - m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, "", "", true); - - // switch menubar - SetMenuBar(m_gcodeviewer_menubar); - - // hide toolbars - m_plater->enable_view_toolbar(false); - - if (wxGetApp().app_config->get("show_collapse_button") == "1") { - m_plater->get_collapse_toolbar().set_enabled(false); - m_restore_from_gcode_viewer.collapse_toolbar_enabled = true; - } - - // hide sidebar - if (wxGetApp().app_config->get("collapsed_sidebar") != "1") { - m_plater->collapse_sidebar(true); - m_restore_from_gcode_viewer.collapsed_sidebar = true; - } - - m_plater->Thaw(); - - SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG)); -#if ENABLE_GCODE_VIEWER_TASKBAR_ICON - if (m_taskbar_icon != nullptr) { - m_taskbar_icon->RemoveIcon(); - m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer-GCode viewer"); - } -#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON - - break; - } - } -} -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #endif // ENABLE_GCODE_VIEWER void MainFrame::update_menubar() { -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (wxGetApp().is_gcode_viewer()) return; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER const bool is_fff = plater()->printer_technology() == ptFFF; @@ -2069,10 +1864,10 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe) wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"), m_main_frame(mainframe) { -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (wxGetApp().is_gcode_viewer()) return; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER #if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__) // ys_FIXME! temporary workaround for correct font scaling @@ -2146,10 +1941,10 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe) void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect) { -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (wxGetApp().is_gcode_viewer()) return; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER const int& em = em_unit(); const wxSize& size = wxSize(85 * em, 50 * em); diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 867e11e86..868a68492 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -72,21 +72,7 @@ class MainFrame : public DPIFrame wxString m_qs_last_output_file = wxEmptyString; wxString m_last_config = wxEmptyString; #if ENABLE_GCODE_VIEWER -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - wxMenuBar* m_menubar{ nullptr }; -#else - wxMenuBar* m_editor_menubar{ nullptr }; - wxMenuBar* m_gcodeviewer_menubar{ nullptr }; - - struct RestoreFromGCodeViewer - { - bool collapsed_sidebar{ false }; - bool collapse_toolbar_enabled{ false }; - bool sla_technology{ false }; - }; - - RestoreFromGCodeViewer m_restore_from_gcode_viewer; -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION + wxMenuBar* m_menubar{ nullptr }; #endif // ENABLE_GCODE_VIEWER #if 0 @@ -149,20 +135,6 @@ class MainFrame : public DPIFrame ESettingsLayout m_layout{ ESettingsLayout::Unknown }; -#if ENABLE_GCODE_VIEWER -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -public: - enum class EMode : unsigned char - { - Editor, - GCodeViewer - }; - -private: - EMode m_mode{ EMode::Editor }; -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -#endif // ENABLE_GCODE_VIEWER - protected: virtual void on_dpi_changed(const wxRect &suggested_rect); virtual void on_sys_color_changed() override; @@ -190,11 +162,6 @@ public: #if ENABLE_GCODE_VIEWER void init_menubar_as_editor(); void init_menubar_as_gcodeviewer(); - -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - EMode get_mode() const { return m_mode; } - void set_mode(EMode mode); -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #else void init_menubar(); #endif // ENABLE_GCODE_VIEWER diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 061084f57..b4f900b0c 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1369,9 +1369,7 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi this->MSWUpdateDragImageOnLeave(); #endif // WIN32 -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION if (wxGetApp().is_gcode_viewer()) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION // gcode section for (const auto& filename : filenames) { fs::path path(into_path(filename)); @@ -1385,33 +1383,11 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi return false; } else if (paths.size() == 1) { -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) { -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION plater->load_gcode(from_path(paths.front())); return true; -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - } - else { - if (wxMessageDialog((wxWindow*)plater, _L("Do you want to switch to G-code preview ?"), - wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop G-code file"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) { - - if (plater->model().objects.empty() || - wxMessageDialog((wxWindow*)plater, _L("Switching to G-code preview mode will remove all objects, continue?"), - wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) { - wxGetApp().mainframe->set_mode(MainFrame::EMode::GCodeViewer); - plater->load_gcode(from_path(paths.front())); - return true; - } - } - return false; - } -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION } -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION return false; } -#endif //ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION #endif // ENABLE_GCODE_VIEWER // editor section @@ -1423,18 +1399,6 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi return false; } -#if ENABLE_GCODE_VIEWER -#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION - if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) { - if (wxMessageDialog((wxWindow*)plater, _L("Do you want to exit G-code preview ?"), - wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop model file"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) - wxGetApp().mainframe->set_mode(MainFrame::EMode::Editor); - else - return false; - } -#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION -#endif // ENABLE_GCODE_VIEWER - wxString snapshot_label; assert(! paths.empty()); if (paths.size() == 1) { @@ -1983,13 +1947,13 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership q->Layout(); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER set_current_panel(wxGetApp().is_editor() ? (wxPanel*)view3D : (wxPanel*)preview); if (wxGetApp().is_gcode_viewer()) preview->hide_layers_slider(); #else set_current_panel(view3D); -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // updates camera type from .ini file camera.set_type(get_config("use_perspective_camera")); @@ -2009,9 +1973,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) #endif /* _WIN32 */ notification_manager = new NotificationManager(this->q); -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER if (wxGetApp().is_editor()) { -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER this->q->Bind(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, [this](EjectDriveNotificationClickedEvent&) { this->q->eject_drive(); }); this->q->Bind(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, [this](ExportGcodeNotificationClickedEvent&) { this->q->export_gcode(true); }); this->q->Bind(EVT_PRESET_UPDATE_AVIABLE_CLICKED, [this](PresetUpdateAviableClickedEvent&) { wxGetApp().get_preset_updater()->on_update_notification_confirm(); }); @@ -2038,9 +2002,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); }); this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); }); #endif /* _WIN32 */ -#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#if ENABLE_GCODE_VIEWER } -#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION +#endif // ENABLE_GCODE_VIEWER // Initialize the Undo / Redo stack with a first snapshot. this->take_snapshot(_L("New Project")); @@ -5408,7 +5372,9 @@ void Plater::on_config_change(const DynamicPrintConfig &config) this->set_printer_technology(config.opt_enum(opt_key)); // print technology is changed, so we should to update a search list p->sidebar->update_searcher(); +#if ENABLE_GCODE_VIEWER p->reset_gcode_toolpaths(); +#endif // ENABLE_GCODE_VIEWER } else if ((opt_key == "bed_shape") || (opt_key == "bed_custom_texture") || (opt_key == "bed_custom_model")) { bed_shape_changed = true;