mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	Tech ENABLE_GCODE_APP_CONFIG as default
This commit is contained in:
		
							parent
							
								
									a633979d85
								
							
						
					
					
						commit
						f04d9c1806
					
				
					 11 changed files with 76 additions and 116 deletions
				
			
		|  | @ -557,9 +557,9 @@ struct ConfigWizard::priv | |||
| 
 | ||||
|     priv(ConfigWizard *q) | ||||
|         : q(q) | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         , appconfig_new(AppConfig::EAppMode::Editor) | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         , filaments(T_FFF) | ||||
|         , sla_materials(T_SLA) | ||||
|     {} | ||||
|  |  | |||
|  | @ -632,25 +632,17 @@ void GUI_App::init_app_config() | |||
| 		set_data_dir(wxStandardPaths::Get().GetUserDataDir().ToUTF8().data()); | ||||
| 
 | ||||
| 	if (!app_config) | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         app_config = new AppConfig(is_editor() ? AppConfig::EAppMode::Editor : AppConfig::EAppMode::GCodeViewer); | ||||
| #else | ||||
|         app_config = new AppConfig(); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| #if !ENABLE_GCODE_APP_CONFIG | ||||
|     if (is_gcode_viewer()) | ||||
|         // disable config save to avoid to mess it up for the editor
 | ||||
|         app_config->enable_save(false); | ||||
| #endif // !ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| 	// load settings
 | ||||
| 	m_app_conf_exists = app_config->exists(); | ||||
| 	if (m_app_conf_exists) { | ||||
|         std::string error = app_config->load(); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         if (!error.empty()) { | ||||
|             // Error while parsing config file. We'll customize the error message and rethrow to be displayed.
 | ||||
|             if (is_editor()) { | ||||
|  | @ -673,7 +665,7 @@ void GUI_App::init_app_config() | |||
|                 _u8L("Error parsing PrusaSlicer config file, it is probably corrupted. " | ||||
|                     "Try to manually delete the file to recover from the error. Your user profiles will not be affected.") + | ||||
|                 "\n\n" + AppConfig::config_path() + "\n\n" + error); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -1087,9 +1079,9 @@ void GUI_App::check_printer_presets() | |||
| 
 | ||||
| void GUI_App::recreate_GUI(const wxString& msg_name) | ||||
| { | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_is_recreating_gui = true; | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     mainframe->shutdown(); | ||||
| 
 | ||||
|  | @ -1099,9 +1091,9 @@ void GUI_App::recreate_GUI(const wxString& msg_name) | |||
| 
 | ||||
|     MainFrame *old_main_frame = mainframe; | ||||
|     mainframe = new MainFrame(); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (is_editor()) | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         // hide settings tabs after first Layout
 | ||||
|         mainframe->select_tab(size_t(0)); | ||||
|     // Propagate model objects to object list.
 | ||||
|  | @ -1134,9 +1126,9 @@ void GUI_App::recreate_GUI(const wxString& msg_name) | |||
| //         config_wizard_startup(true);
 | ||||
| //     });
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_is_recreating_gui = false; | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| void GUI_App::system_info() | ||||
|  | @ -1469,17 +1461,17 @@ void GUI_App::add_config_menu(wxMenuBar *menu) | |||
|     const auto config_wizard_name = _(ConfigWizard::name(true)); | ||||
|     const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Run %s"))) % config_wizard_name).str()); | ||||
|     // Cmd+, is standard on OS X - what about other operating systems?
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (is_editor()) { | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip); | ||||
|         local_menu->Append(config_id_base + ConfigMenuSnapshots, _L("&Configuration Snapshots") + dots, _L("Inspect / activate configuration snapshots")); | ||||
|         local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _L("Take Configuration &Snapshot"), _L("Capture a configuration snapshot")); | ||||
|         local_menu->Append(config_id_base + ConfigMenuUpdate, _L("Check for updates"), _L("Check for configuration updates")); | ||||
|         local_menu->AppendSeparator(); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     } | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     local_menu->Append(config_id_base + ConfigMenuPreferences, _L("&Preferences") + dots + | ||||
| #ifdef __APPLE__ | ||||
|         "\tCtrl+,", | ||||
|  | @ -1487,16 +1479,16 @@ void GUI_App::add_config_menu(wxMenuBar *menu) | |||
|         "\tCtrl+P", | ||||
| #endif | ||||
|         _L("Application preferences")); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     wxMenu* mode_menu = nullptr; | ||||
|     if (is_editor()) { | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         local_menu->AppendSeparator(); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         mode_menu = new wxMenu(); | ||||
| #else | ||||
|         auto mode_menu = new wxMenu(); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _L("Simple"), _L("Simple View Mode")); | ||||
| //    mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _L("Advanced"), _L("Advanced View Mode"));
 | ||||
|         mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), _L("Advanced View Mode")); | ||||
|  | @ -1506,21 +1498,21 @@ void GUI_App::add_config_menu(wxMenuBar *menu) | |||
|         Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert); | ||||
| 
 | ||||
|         local_menu->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s View Mode"), SLIC3R_APP_NAME)); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     } | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     local_menu->AppendSeparator(); | ||||
|     local_menu->Append(config_id_base + ConfigMenuLanguage, _L("&Language")); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (is_editor()) { | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         local_menu->AppendSeparator(); | ||||
|         local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _L("Flash printer &firmware"), _L("Upload a firmware image into an Arduino based printer")); | ||||
|         // TODO: for when we're able to flash dictionaries
 | ||||
|         // local_menu->Append(config_id_base + FirmwareMenuDict,  _L("Flash language file"),    _L("Upload a language dictionary file into a Prusa printer"));
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     } | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) { | ||||
|         switch (event.GetId() - config_id_base) { | ||||
|  | @ -1592,19 +1584,19 @@ void GUI_App::add_config_menu(wxMenuBar *menu) | |||
|                 // the dialog needs to be destroyed before the call to switch_language()
 | ||||
|                 // or sometimes the application crashes into wxDialogBase() destructor
 | ||||
|                 // so we put it into an inner scope
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|                 wxString title = is_editor() ? wxString(SLIC3R_APP_NAME) : wxString(GCODEVIEWER_APP_NAME); | ||||
|                 title += " - " + _L("Language selection"); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|                 wxMessageDialog dialog(nullptr, | ||||
|                     _L("Switching the language will trigger application restart.\n" | ||||
|                         "You will lose content of the plater.") + "\n\n" + | ||||
|                     _L("Do you want to proceed?"), | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|                     title, | ||||
| #else | ||||
|                     wxString(SLIC3R_APP_NAME) + " - " + _L("Language selection"), | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|                     wxICON_QUESTION | wxOK | wxCANCEL); | ||||
|                 if (dialog.ShowModal() == wxID_CANCEL) | ||||
|                     return; | ||||
|  | @ -1622,17 +1614,17 @@ void GUI_App::add_config_menu(wxMenuBar *menu) | |||
|     }); | ||||
|      | ||||
|     using std::placeholders::_1; | ||||
|      | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (mode_menu != nullptr) { | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); }; | ||||
|         mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple); | ||||
|         mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced); | ||||
|         mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     } | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     menu->Append(local_menu, _L("&Configuration")); | ||||
| } | ||||
|  |  | |||
|  | @ -109,9 +109,7 @@ private: | |||
|     bool            m_app_conf_exists{ false }; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     EAppMode        m_app_mode{ EAppMode::Editor }; | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
|     bool            m_is_recreating_gui{ false }; | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     wxColour        m_color_label_modified; | ||||
|  | @ -190,9 +188,7 @@ public: | |||
|     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; } | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
|     bool is_recreating_gui() const { return m_is_recreating_gui; } | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     static std::string get_gl_info(bool format_as_html, bool extensions); | ||||
|  |  | |||
|  | @ -1212,11 +1212,7 @@ void Preview::update_double_slider_from_canvas(wxKeyEvent & event) | |||
| void Preview::load_print_as_fff(bool keep_z_range) | ||||
| { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
|     if (wxGetApp().mainframe == nullptr || wxGetApp().is_recreating_gui()) | ||||
| #else | ||||
|     if (wxGetApp().mainframe == nullptr) | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
|         // avoid processing while mainframe is being constructed
 | ||||
|         return; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|  |  | |||
|  | @ -1410,10 +1410,10 @@ void MainFrame::init_menubar_as_gcodeviewer() | |||
|     m_menubar = new wxMenuBar(); | ||||
|     m_menubar->Append(fileMenu, _L("&File")); | ||||
|     if (viewMenu != nullptr) m_menubar->Append(viewMenu, _L("&View")); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     // Add additional menus from C++
 | ||||
|     wxGetApp().add_config_menu(m_menubar); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     m_menubar->Append(helpMenu, _L("&Help")); | ||||
|     SetMenuBar(m_menubar); | ||||
| 
 | ||||
|  |  | |||
|  | @ -36,25 +36,25 @@ void PreferencesDialog::build() | |||
| //        readonly = > !wxTheApp->have_version_check,
 | ||||
| //    ));
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	bool is_editor = wxGetApp().is_editor(); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| 	ConfigOptionDef def; | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	Option option(def, ""); | ||||
| 	if (is_editor) { | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 		def.label = L("Remember output directory"); | ||||
| 		def.type = coBool; | ||||
| 		def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory " | ||||
| 			"instead of the one containing the input files."); | ||||
| 		def.set_default_value(new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true }); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 		option = Option(def, "remember_output_path"); | ||||
| #else | ||||
| 		Option option(def, "remember_output_path"); | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 		m_optgroup_general->append_single_option_line(option); | ||||
| 
 | ||||
| 		def.label = L("Auto-center parts"); | ||||
|  | @ -123,9 +123,9 @@ void PreferencesDialog::build() | |||
| 		def.set_default_value(new ConfigOptionBool{ app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false }); | ||||
| 		option = Option(def, "single_instance"); | ||||
| 		m_optgroup_general->append_single_option_line(option); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	} | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if __APPLE__ | ||||
| 	def.label = L("Use Retina resolution for the 3D scene"); | ||||
|  | @ -179,9 +179,9 @@ void PreferencesDialog::build() | |||
| 
 | ||||
| 	m_optgroup_camera->activate(); | ||||
| 
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	if (is_editor) { | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 		m_optgroup_gui = std::make_shared<ConfigOptionsGroup>(this, _L("GUI")); | ||||
| 		m_optgroup_gui->label_width = 40; | ||||
| 		m_optgroup_gui->m_on_change = [this](t_config_option_key opt_key, boost::any value) { | ||||
|  | @ -229,21 +229,21 @@ void PreferencesDialog::build() | |||
| 
 | ||||
| 		m_optgroup_render->activate(); | ||||
| #endif // ENABLE_ENVIRONMENT_MAP
 | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	} | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| 	auto sizer = new wxBoxSizer(wxVERTICAL); | ||||
| 	sizer->Add(m_optgroup_general->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
| 	sizer->Add(m_optgroup_camera->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	if (m_optgroup_gui != nullptr) | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 		sizer->Add(m_optgroup_gui->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
| #if ENABLE_ENVIRONMENT_MAP | ||||
| #if ENABLE_GCODE_APP_CONFIG | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| 	if (m_optgroup_render != nullptr) | ||||
| #endif // ENABLE_GCODE_APP_CONFIG
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 		sizer->Add(m_optgroup_render->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
| #endif // ENABLE_ENVIRONMENT_MAP
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966