mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Merged Sasa's GUI WIP
This commit is contained in:
		
						commit
						9a5796794e
					
				
					 15 changed files with 1640 additions and 163 deletions
				
			
		|  | @ -1,9 +1,6 @@ | ||||||
| //#include "ConfigBase.hpp"
 |  | ||||||
| #include "Config.hpp" | #include "Config.hpp" | ||||||
| #include "Geometry.hpp" | #include "Geometry.hpp" | ||||||
| //#include "IO.hpp"
 |  | ||||||
| #include "Model.hpp" | #include "Model.hpp" | ||||||
| //#include "SLAPrint.hpp"
 |  | ||||||
| #include "Print.hpp" | #include "Print.hpp" | ||||||
| #include "TriangleMesh.hpp" | #include "TriangleMesh.hpp" | ||||||
| #include "Format/3mf.hpp" | #include "Format/3mf.hpp" | ||||||
|  | @ -21,80 +18,10 @@ | ||||||
| //    #include "GUI/GUI.hpp"
 | //    #include "GUI/GUI.hpp"
 | ||||||
| #endif | #endif | ||||||
| #include "slic3r/GUI/GUI.hpp" | #include "slic3r/GUI/GUI.hpp" | ||||||
|  | #include "slic3r/GUI/GUI_App.hpp" | ||||||
| 
 | 
 | ||||||
| using namespace Slic3r; | using namespace Slic3r; | ||||||
| 
 | 
 | ||||||
| // wxWidgets "Hello world" Program
 |  | ||||||
| // For compilers that support precompilation, includes "wx/wx.h".
 |  | ||||||
| #include <wx/wxprec.h> |  | ||||||
| #ifndef WX_PRECOMP |  | ||||||
|     #include <wx/wx.h> |  | ||||||
| #endif |  | ||||||
| class MyApp: public wxApp |  | ||||||
| { |  | ||||||
| public: |  | ||||||
|     virtual bool OnInit(); |  | ||||||
| }; |  | ||||||
| class MyFrame: public wxFrame |  | ||||||
| { |  | ||||||
| public: |  | ||||||
|     MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); |  | ||||||
| private: |  | ||||||
|     void OnHello(wxCommandEvent& event); |  | ||||||
|     void OnExit(wxCommandEvent& event); |  | ||||||
|     void OnAbout(wxCommandEvent& event); |  | ||||||
|     wxDECLARE_EVENT_TABLE(); |  | ||||||
| }; |  | ||||||
| enum |  | ||||||
| { |  | ||||||
|     ID_Hello = 1 |  | ||||||
| }; |  | ||||||
| wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) |  | ||||||
|     EVT_MENU(ID_Hello,   MyFrame::OnHello) |  | ||||||
|     EVT_MENU(wxID_EXIT,  MyFrame::OnExit) |  | ||||||
|     EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) |  | ||||||
| wxEND_EVENT_TABLE() |  | ||||||
| bool MyApp::OnInit() |  | ||||||
| { |  | ||||||
|     MyFrame *frame = new MyFrame( "Hello World", wxPoint(50, 50), wxSize(450, 340) ); |  | ||||||
|     frame->Show( true ); |  | ||||||
|     return true; |  | ||||||
| } |  | ||||||
| MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) |  | ||||||
|         : wxFrame(NULL, wxID_ANY, title, pos, size) |  | ||||||
| { |  | ||||||
|     wxMenu *menuFile = new wxMenu; |  | ||||||
|     menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", |  | ||||||
|                      "Help string shown in status bar for this menu item"); |  | ||||||
|     menuFile->AppendSeparator(); |  | ||||||
|     menuFile->Append(wxID_EXIT); |  | ||||||
|     wxMenu *menuHelp = new wxMenu; |  | ||||||
|     menuHelp->Append(wxID_ABOUT); |  | ||||||
|     wxMenuBar *menuBar = new wxMenuBar; |  | ||||||
|     menuBar->Append( menuFile, "&File" ); |  | ||||||
|     menuBar->Append( menuHelp, "&Help" ); |  | ||||||
|     SetMenuBar( menuBar ); |  | ||||||
|     CreateStatusBar(); |  | ||||||
|     SetStatusText( "Welcome to wxWidgets!" ); |  | ||||||
|     Slic3r::Model model; |  | ||||||
|     ModelObject *object = model.add_object(); |  | ||||||
|     SetStatusText(Slic3r::GUI::from_u8("HHuhuh")); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void MyFrame::OnExit(wxCommandEvent& event) |  | ||||||
| { |  | ||||||
|     Close( true ); |  | ||||||
| } |  | ||||||
| void MyFrame::OnAbout(wxCommandEvent& event) |  | ||||||
| { |  | ||||||
|     wxMessageBox( "This is a wxWidgets' Hello world sample", |  | ||||||
|                   "About Hello World", wxOK | wxICON_INFORMATION ); |  | ||||||
| } |  | ||||||
| void MyFrame::OnHello(wxCommandEvent& event) |  | ||||||
| { |  | ||||||
|     wxLogMessage("Hello world from wxWidgets!"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /// utility function for displaying CLI usage
 | /// utility function for displaying CLI usage
 | ||||||
| void printUsage(); | void printUsage(); | ||||||
| 
 | 
 | ||||||
|  | @ -121,9 +48,8 @@ int main(int argc, char **argv) | ||||||
|     DynamicPrintConfig print_config; |     DynamicPrintConfig print_config; | ||||||
| 
 | 
 | ||||||
| #if 1 | #if 1 | ||||||
|     MyApp *gui = new MyApp(); |     GUI::GUI_App *gui = new GUI::GUI_App(); | ||||||
| 
 |     GUI::GUI_App::SetInstance(gui); | ||||||
|     MyApp::SetInstance(gui); |  | ||||||
|     wxEntry(argc, argv); |     wxEntry(argc, argv); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -39,6 +39,10 @@ add_library(libslic3r_gui STATIC | ||||||
|     ${LIBDIR}/slic3r/GUI/GUI_Preview.hpp |     ${LIBDIR}/slic3r/GUI/GUI_Preview.hpp | ||||||
|     ${LIBDIR}/slic3r/GUI/GUI_PreviewIface.cpp |     ${LIBDIR}/slic3r/GUI/GUI_PreviewIface.cpp | ||||||
|     ${LIBDIR}/slic3r/GUI/GUI_PreviewIface.hpp |     ${LIBDIR}/slic3r/GUI/GUI_PreviewIface.hpp | ||||||
|  |     ${LIBDIR}/slic3r/GUI/GUI_App.cpp | ||||||
|  |     ${LIBDIR}/slic3r/GUI/GUI_App.hpp | ||||||
|  |     ${LIBDIR}/slic3r/GUI/MainFrame.cpp | ||||||
|  |     ${LIBDIR}/slic3r/GUI/MainFrame.hpp | ||||||
|     ${LIBDIR}/slic3r/GUI/LambdaObjectDialog.cpp |     ${LIBDIR}/slic3r/GUI/LambdaObjectDialog.cpp | ||||||
|     ${LIBDIR}/slic3r/GUI/LambdaObjectDialog.hpp |     ${LIBDIR}/slic3r/GUI/LambdaObjectDialog.hpp | ||||||
|     ${LIBDIR}/slic3r/GUI/Tab.cpp |     ${LIBDIR}/slic3r/GUI/Tab.cpp | ||||||
|  |  | ||||||
|  | @ -291,12 +291,6 @@ void BedShapePanel::update_shape() | ||||||
| // Loads an stl file, projects it to the XY plane and calculates a polygon.
 | // Loads an stl file, projects it to the XY plane and calculates a polygon.
 | ||||||
| void BedShapePanel::load_stl() | void BedShapePanel::load_stl() | ||||||
| { | { | ||||||
| 	t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card(); |  | ||||||
|     std::vector<std::string> file_types = { "known", "stl", "obj", "amf", "3mf", "prusa" }; |  | ||||||
|     wxString MODEL_WILDCARD; |  | ||||||
| 	for (auto file_type: file_types) |  | ||||||
| 		MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|"; |  | ||||||
| 
 |  | ||||||
| 	auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "", | 	auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "", | ||||||
| 		MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); | 		MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||||
| 	if (dialog->ShowModal() != wxID_OK) { | 	if (dialog->ShowModal() != wxID_OK) { | ||||||
|  |  | ||||||
|  | @ -129,9 +129,10 @@ wxColour    g_color_label_modified; | ||||||
| wxColour    g_color_label_sys; | wxColour    g_color_label_sys; | ||||||
| wxColour    g_color_label_default; | wxColour    g_color_label_default; | ||||||
| 
 | 
 | ||||||
|  | // #ys_FIXME_for_delete
 | ||||||
| std::vector<Tab *> g_tabs_list; | std::vector<Tab *> g_tabs_list; | ||||||
| 
 | 
 | ||||||
| wxLocale*	g_wxLocale; | wxLocale*	g_wxLocale {nullptr}; | ||||||
| 
 | 
 | ||||||
| wxFont		g_small_font; | wxFont		g_small_font; | ||||||
| wxFont		g_bold_font; | wxFont		g_bold_font; | ||||||
|  | @ -347,6 +348,11 @@ bool select_language(wxArrayString & names, | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | wxLocale* get_locale() { | ||||||
|  |     return g_wxLocale; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // #ys_FIXME_for_delete
 | ||||||
| bool load_language() | bool load_language() | ||||||
| { | { | ||||||
| 	wxString language = wxEmptyString; | 	wxString language = wxEmptyString; | ||||||
|  | @ -429,7 +435,8 @@ enum ConfigMenuIDs { | ||||||
| 	ConfigMenuFlashFirmware, | 	ConfigMenuFlashFirmware, | ||||||
| 	ConfigMenuCnt, | 	ConfigMenuCnt, | ||||||
| }; | }; | ||||||
| 	 | 
 | ||||||
|  | // #ys_FIXME_for_delete	
 | ||||||
| ConfigMenuIDs get_view_mode() | ConfigMenuIDs get_view_mode() | ||||||
| { | { | ||||||
| 	if (!g_AppConfig->has("view_mode")) | 	if (!g_AppConfig->has("view_mode")) | ||||||
|  | @ -440,7 +447,7 @@ ConfigMenuIDs get_view_mode() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static wxString dots("…", wxConvUTF8); | static wxString dots("…", wxConvUTF8); | ||||||
| 
 | // #ys_FIXME_for_delete
 | ||||||
| void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change) | void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change) | ||||||
| { | { | ||||||
|     auto local_menu = new wxMenu(); |     auto local_menu = new wxMenu(); | ||||||
|  | @ -546,14 +553,8 @@ void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_languag | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void open_model(wxWindow *parent, wxArrayString& input_files){ | void open_model(wxWindow *parent, wxArrayString& input_files){ | ||||||
| 	t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card(); | 	auto dialog = new wxFileDialog(parent /*? parent : GetTopWindow()*/,  | ||||||
| 	std::vector<std::string> file_types = { "known", "stl", "obj", "amf", "3mf", "prusa" }; |         _(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")), | ||||||
| 	wxString MODEL_WILDCARD; |  | ||||||
| 	for (auto file_type : file_types) |  | ||||||
| 		MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|"; |  | ||||||
| 
 |  | ||||||
| 	auto dlg_title = _(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")); |  | ||||||
| 	auto dialog = new wxFileDialog(parent /*? parent : GetTopWindow(g_wxMainFrame)*/, dlg_title,  |  | ||||||
| 		g_AppConfig->get_last_dir(), "", | 		g_AppConfig->get_last_dir(), "", | ||||||
| 		MODEL_WILDCARD, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST); | 		MODEL_WILDCARD, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST); | ||||||
| 	if (dialog->ShowModal() != wxID_OK) { | 	if (dialog->ShowModal() != wxID_OK) { | ||||||
|  | @ -567,6 +568,7 @@ void open_model(wxWindow *parent, wxArrayString& input_files){ | ||||||
| 
 | 
 | ||||||
| // This is called when closing the application, when loading a config file or when starting the config wizard
 | // This is called when closing the application, when loading a config file or when starting the config wizard
 | ||||||
| // to notify the user whether he is aware that some preset changes will be lost.
 | // to notify the user whether he is aware that some preset changes will be lost.
 | ||||||
|  | // #ys_FIXME_for_delete
 | ||||||
| bool check_unsaved_changes() | bool check_unsaved_changes() | ||||||
| { | { | ||||||
| 	std::string dirty; | 	std::string dirty; | ||||||
|  | @ -643,8 +645,8 @@ std::vector<PresetTab> preset_tabs = { | ||||||
|     { "filament",     nullptr, ptFFF }, |     { "filament",     nullptr, ptFFF }, | ||||||
|     { "sla_material", nullptr, ptSLA } |     { "sla_material", nullptr, ptSLA } | ||||||
| }; | }; | ||||||
| const std::vector<PresetTab>& get_preset_tabs() { | std::vector<PresetTab>* get_preset_tabs() { | ||||||
|     return preset_tabs; |     return &preset_tabs; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Tab* get_tab(const std::string& name) | Tab* get_tab(const std::string& name) | ||||||
|  | @ -788,7 +790,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt | ||||||
| 		int i = 0;//no reason, just experiment
 | 		int i = 0;//no reason, just experiment
 | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | // #ys_FIXME_for_delete
 | ||||||
| void add_created_tab(Tab* panel, int event_value_change, int event_presets_changed) | void add_created_tab(Tab* panel, int event_value_change, int event_presets_changed) | ||||||
| { | { | ||||||
| 	panel->create_preset_tab(g_PresetBundle); | 	panel->create_preset_tab(g_PresetBundle); | ||||||
|  | @ -1219,7 +1221,7 @@ bool is_expert_mode(){ | ||||||
| 
 | 
 | ||||||
| ConfigOptionsGroup* get_optgroup(size_t i) | ConfigOptionsGroup* get_optgroup(size_t i) | ||||||
| { | { | ||||||
| 	return m_optgroups[i].get(); | 	return m_optgroups.empty() ? nullptr : m_optgroups[i].get(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector <std::shared_ptr<ConfigOptionsGroup>>& get_optgroups() { | std::vector <std::shared_ptr<ConfigOptionsGroup>>& get_optgroups() { | ||||||
|  |  | ||||||
|  | @ -74,23 +74,24 @@ namespace GUI { | ||||||
| class Tab; | class Tab; | ||||||
| class ConfigOptionsGroup; | class ConfigOptionsGroup; | ||||||
| // Map from an file_type name to full file wildcard name.
 | // Map from an file_type name to full file wildcard name.
 | ||||||
| typedef std::map<std::string, std::string> t_file_wild_card; | const std::map<const std::string, const std::string> FILE_WILDCARDS{ | ||||||
| inline t_file_wild_card& get_file_wild_card() { |     std::make_pair("known", "Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA"), | ||||||
| 	static t_file_wild_card FILE_WILDCARDS; |     std::make_pair("stl",   "STL files (*.stl)|*.stl;*.STL"), | ||||||
| 	if (FILE_WILDCARDS.empty()){ |     std::make_pair("obj",   "OBJ files (*.obj)|*.obj;*.OBJ"), | ||||||
| 		FILE_WILDCARDS["known"]	= "Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA"; |     std::make_pair("amf",   "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML"), | ||||||
| 		FILE_WILDCARDS["stl"]	= "STL files (*.stl)|*.stl;*.STL"; |     std::make_pair("3mf",   "3MF files (*.3mf)|*.3mf;*.3MF;"), | ||||||
| 		FILE_WILDCARDS["obj"]	= "OBJ files (*.obj)|*.obj;*.OBJ"; |     std::make_pair("prusa", "Prusa Control files (*.prusa)|*.prusa;*.PRUSA"), | ||||||
|         FILE_WILDCARDS["amf"]	= "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML"; |     std::make_pair("ini",   "INI files *.ini|*.ini;*.INI"), | ||||||
|         FILE_WILDCARDS["3mf"]	= "3MF files (*.3mf)|*.3mf;*.3MF;"; |     std::make_pair("gcode", "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC"), | ||||||
|         FILE_WILDCARDS["prusa"]	= "Prusa Control files (*.prusa)|*.prusa;*.PRUSA"; |     std::make_pair("svg",   "SVG files *.svg|*.svg;*.SVG") | ||||||
| 		FILE_WILDCARDS["ini"]	= "INI files *.ini|*.ini;*.INI"; | }; | ||||||
| 		FILE_WILDCARDS["gcode"] = "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC"; |  | ||||||
| 		FILE_WILDCARDS["svg"]	= "SVG files *.svg|*.svg;*.SVG"; |  | ||||||
| 	} |  | ||||||
| 	return FILE_WILDCARDS; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
|  | const std::string MODEL_WILDCARD{   FILE_WILDCARDS.at("known") + std::string("|") + | ||||||
|  |                                     FILE_WILDCARDS.at("stl") + std::string("|") + | ||||||
|  |                                     FILE_WILDCARDS.at("obj") + std::string("|") + | ||||||
|  |                                     FILE_WILDCARDS.at("amf") + std::string("|") + | ||||||
|  |                                     FILE_WILDCARDS.at("3mf") + std::string("|") + | ||||||
|  |                                     FILE_WILDCARDS.at("prusa") }; | ||||||
| struct PresetTab { | struct PresetTab { | ||||||
|     std::string       name; |     std::string       name; | ||||||
|     Tab*              panel; |     Tab*              panel; | ||||||
|  | @ -152,7 +153,7 @@ wxWindow*			get_right_panel(); | ||||||
| const size_t&		label_width(); | const size_t&		label_width(); | ||||||
| 
 | 
 | ||||||
| Tab*         get_tab(const std::string& name); | Tab*         get_tab(const std::string& name); | ||||||
| const std::vector<PresetTab>& get_preset_tabs(); | std::vector<PresetTab>* get_preset_tabs(); | ||||||
| 
 | 
 | ||||||
| extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change); | extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change); | ||||||
| 
 | 
 | ||||||
|  | @ -195,6 +196,7 @@ void warning_catcher(wxWindow* parent, const wxString& message); | ||||||
| void set_print_callback_event(Print *print, int id); | void set_print_callback_event(Print *print, int id); | ||||||
| 
 | 
 | ||||||
| // load language saved at application config 
 | // load language saved at application config 
 | ||||||
|  | wxLocale* get_locale(); | ||||||
| bool load_language(); | bool load_language(); | ||||||
| // save language at application config 
 | // save language at application config 
 | ||||||
| void save_language(); | void save_language(); | ||||||
|  |  | ||||||
							
								
								
									
										533
									
								
								src/slic3r/GUI/GUI_App.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										533
									
								
								src/slic3r/GUI/GUI_App.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,533 @@ | ||||||
|  | #include "GUI_App.hpp" | ||||||
|  | 
 | ||||||
|  | #include <boost/lexical_cast.hpp> | ||||||
|  | #include <boost/algorithm/string.hpp> | ||||||
|  | 
 | ||||||
|  | #include <wx/stdpaths.h> | ||||||
|  | #include <wx/imagpng.h> | ||||||
|  | #include <wx/display.h> | ||||||
|  | #include <wx/menu.h> | ||||||
|  | #include <wx/menuitem.h> | ||||||
|  | #include <wx/filedlg.h> | ||||||
|  | 
 | ||||||
|  | #include "Utils.hpp" | ||||||
|  | #include "GUI.hpp" | ||||||
|  | #include "MainFrame.hpp" | ||||||
|  | #include "AppConfig.hpp" | ||||||
|  | #include "PresetBundle.hpp" | ||||||
|  | #include "3DScene.hpp" | ||||||
|  | 
 | ||||||
|  | #include "../Utils/PresetUpdater.hpp" | ||||||
|  | #include "ConfigWizard_private.hpp" | ||||||
|  | #include "slic3r/Config/Snapshot.hpp" | ||||||
|  | #include "ConfigSnapshotDialog.hpp" | ||||||
|  | #include "FirmwareDialog.hpp" | ||||||
|  | #include "Preferences.hpp" | ||||||
|  | #include "Tab.hpp" | ||||||
|  | 
 | ||||||
|  | namespace Slic3r { | ||||||
|  | namespace GUI { | ||||||
|  | 
 | ||||||
|  | IMPLEMENT_APP(GUI_App) | ||||||
|  | bool GUI_App::OnInit() | ||||||
|  | { | ||||||
|  |     SetAppName("Slic3rPE"); | ||||||
|  |     SetAppDisplayName("Slic3r Prusa Edition"); | ||||||
|  | 
 | ||||||
|  | //     Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
 | ||||||
|  | 
 | ||||||
|  |     // Set the Slic3r data directory at the Slic3r XS module.
 | ||||||
|  |     // Unix: ~/ .Slic3r
 | ||||||
|  |     // Windows : "C:\Users\username\AppData\Roaming\Slic3r" or "C:\Documents and Settings\username\Application Data\Slic3r"
 | ||||||
|  |     // Mac : "~/Library/Application Support/Slic3r"
 | ||||||
|  |     datadir.empty() ? | ||||||
|  |         Slic3r::set_data_dir(wxStandardPaths::Get().GetUserDataDir().ToStdString()) : | ||||||
|  |         Slic3r::set_data_dir(datadir); | ||||||
|  |     //     set_wxapp(this); // #ys_FIXME
 | ||||||
|  | 
 | ||||||
|  |     // #ys_FIXME temporary workaround 
 | ||||||
|  |     if (var_dir().empty()) | ||||||
|  |         set_var_dir("c:\\src\\Slic3r_TMP\\resources\\icons"); | ||||||
|  |     if (localization_dir().empty()) | ||||||
|  |         set_local_dir("c:\\src\\Slic3r_TMP\\resources\\localization"); | ||||||
|  | 
 | ||||||
|  |     app_config = new AppConfig(); | ||||||
|  |     //     set_app_config(app_config);// #ys_FIXME
 | ||||||
|  |     preset_bundle = new PresetBundle(); | ||||||
|  |     //     set_preset_bundle(preset_bundle);// #ys_FIXME
 | ||||||
|  | 
 | ||||||
|  |     // just checking for existence of Slic3r::data_dir is not enough : it may be an empty directory
 | ||||||
|  |     // supplied as argument to --datadir; in that case we should still run the wizard
 | ||||||
|  |     //     eval{ 
 | ||||||
|  |     preset_bundle->setup_directories(); | ||||||
|  |     //     };
 | ||||||
|  |     //     if ($@) {
 | ||||||
|  |     //         warn $@ . "\n";
 | ||||||
|  |     //         fatal_error(undef, $@);
 | ||||||
|  |     //     }
 | ||||||
|  |     app_conf_exists = app_config->exists(); | ||||||
|  |     // load settings
 | ||||||
|  |     if (app_conf_exists) app_config->load(); | ||||||
|  |     app_config->set("version", "Slic3r_VERSION"/*Slic3r::VERSION*/); | ||||||
|  |     app_config->save(); | ||||||
|  | 
 | ||||||
|  | //     preset_updater = new PresetUpdater();
 | ||||||
|  | //     set_preset_updater(preset_updater); // #ys_FIXME
 | ||||||
|  | 
 | ||||||
|  |     load_language(); | ||||||
|  | 
 | ||||||
|  |     // Suppress the '- default -' presets.
 | ||||||
|  |     preset_bundle->set_default_suppressed(app_config->get("no_defaults").empty() ? false : true); | ||||||
|  |     //     eval{ 
 | ||||||
|  |     preset_bundle->load_presets(*app_config); | ||||||
|  |     //     };
 | ||||||
|  |     //     if ($@) {
 | ||||||
|  |     //         warn $@ . "\n";
 | ||||||
|  |     //         show_error(undef, $@);
 | ||||||
|  |     //     }
 | ||||||
|  | 
 | ||||||
|  |     // application frame
 | ||||||
|  |     //     print STDERR "Creating main frame...\n";
 | ||||||
|  |     //     wxImage::FindHandlerType(wxBITMAP_TYPE_PNG) ||
 | ||||||
|  |     wxImage::AddHandler(new wxPNGHandler()); | ||||||
|  |     mainframe = new Slic3r::GUI::MainFrame(no_plater, false); | ||||||
|  |     SetTopWindow(mainframe); | ||||||
|  | 
 | ||||||
|  |     // This makes CallAfter() work
 | ||||||
|  |     //     /*mainframe->*/Bind(wxEVT_IDLE, 
 | ||||||
|  | //     [this](wxIdleEvent& event)
 | ||||||
|  | //     {
 | ||||||
|  | //         std::function<void()> cur_cb{ nullptr };
 | ||||||
|  | //         // try to get the mutex. If we can't, just skip this idle event and get the next one.
 | ||||||
|  | //         if (!callback_register.try_lock()) return;
 | ||||||
|  | //         // pop callback
 | ||||||
|  | //         if (m_cb.size() != 0){
 | ||||||
|  | //             cur_cb = m_cb.top();
 | ||||||
|  | //             m_cb.pop();
 | ||||||
|  | //         }
 | ||||||
|  | //         // unlock mutex
 | ||||||
|  | //         this->callback_register.unlock();
 | ||||||
|  | // 
 | ||||||
|  | //         try { // call the function if it's not nullptr;
 | ||||||
|  | //             if (cur_cb != nullptr) cur_cb();
 | ||||||
|  | //         }
 | ||||||
|  | //         catch (std::exception& e) {
 | ||||||
|  | //             //             Slic3r::Log::error(LogChannel, LOG_WSTRING("Exception thrown: " << e.what())); // #ys_FIXME
 | ||||||
|  | //         }
 | ||||||
|  | // 
 | ||||||
|  | //         if (app_config->dirty())
 | ||||||
|  | //             app_config->save();
 | ||||||
|  | //     }
 | ||||||
|  |     ;// #ys_FIXME
 | ||||||
|  |     //     );
 | ||||||
|  | 
 | ||||||
|  |     // On OS X the UI tends to freeze in weird ways if modal dialogs(config wizard, update notifications, ...)
 | ||||||
|  |     // are shown before or in the same event callback with the main frame creation.
 | ||||||
|  |     // Therefore we schedule them for later using CallAfter.
 | ||||||
|  | //     CallAfter([this](){
 | ||||||
|  | //         //         eval{
 | ||||||
|  | //         if (!preset_updater->config_update())
 | ||||||
|  | //             mainframe->Close();
 | ||||||
|  | //         //         };
 | ||||||
|  | //         //         if ($@) {
 | ||||||
|  | //         //             show_error(undef, $@);
 | ||||||
|  | //         //             mainframe->Close();
 | ||||||
|  | //         //         }
 | ||||||
|  | //     });
 | ||||||
|  | // 
 | ||||||
|  | //     CallAfter([this](){
 | ||||||
|  | //         if (!Slic3r::GUI::config_wizard_startup(app_conf_exists)) {
 | ||||||
|  | //             // Only notify if there was not wizard so as not to bother too much ...
 | ||||||
|  | //             preset_updater->slic3r_update_notify();
 | ||||||
|  | //         }
 | ||||||
|  | //         preset_updater->sync(preset_bundle);
 | ||||||
|  | //     });
 | ||||||
|  | // 
 | ||||||
|  | 
 | ||||||
|  |     // #ys_FIXME All of this should to be removed
 | ||||||
|  |     //     # The following event is emited by the C++ menu implementation of preferences change.
 | ||||||
|  |     //     EVT_COMMAND($self, -1, $PREFERENCES_EVENT, sub{
 | ||||||
|  |     //         $self->update_ui_from_settings;
 | ||||||
|  |     //     });
 | ||||||
|  |     // 
 | ||||||
|  |     //     # The following event is emited by PresetUpdater(C++) to inform about
 | ||||||
|  |     //     # the newer Slic3r application version avaiable online.
 | ||||||
|  |     //     EVT_COMMAND($self, -1, $VERSION_ONLINE_EVENT, sub {
 | ||||||
|  |     //         my($self, $event) = @_;
 | ||||||
|  |     //         my $version = $event->GetString;
 | ||||||
|  |     //         $self->{app_config}->set('version_online', $version);
 | ||||||
|  |     //         $self->{app_config}->save;
 | ||||||
|  |     //     });
 | ||||||
|  | 
 | ||||||
|  |     mainframe->Show(true); | ||||||
|  |     return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GUI_App::recreate_GUI() | ||||||
|  | { | ||||||
|  | //     print STDERR "recreate_GUI\n";
 | ||||||
|  | 
 | ||||||
|  |     auto topwindow = GetTopWindow(); | ||||||
|  |     mainframe = new Slic3r::GUI::MainFrame(no_plater,false); | ||||||
|  | 
 | ||||||
|  |     if (topwindow) { | ||||||
|  |         SetTopWindow(mainframe); | ||||||
|  |         topwindow->Destroy(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // On OSX the UI was not initialized correctly if the wizard was called
 | ||||||
|  |     // before the UI was up and running.
 | ||||||
|  |     CallAfter([](){ | ||||||
|  |         // Run the config wizard, don't offer the "reset user profile" checkbox.
 | ||||||
|  |         Slic3r::GUI::config_wizard_startup(true); | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GUI_App::system_info() | ||||||
|  | { | ||||||
|  | //     auto slic3r_info = Slic3r::slic3r_info(format = > 'html');
 | ||||||
|  | //     auto copyright_info = Slic3r::copyright_info(format = > 'html');
 | ||||||
|  | //     auto system_info = Slic3r::system_info(format = > 'html');
 | ||||||
|  |     std::string opengl_info = ""; | ||||||
|  |     std::string opengl_info_txt = ""; | ||||||
|  |     if (mainframe && mainframe->m_plater /*&& mainframe->m_plater->canvas3D*/) { | ||||||
|  |         opengl_info = _3DScene::get_gl_info(true, true); | ||||||
|  |         opengl_info_txt = _3DScene::get_gl_info(false, true); | ||||||
|  |     } | ||||||
|  | //     auto about = new SystemInfo(nullptr, slic3r_info, /*copyright_info,*/system_info, opengl_info,
 | ||||||
|  | //         text_info = > Slic3r::slic3r_info.Slic3r::system_info.$opengl_info_txt,
 | ||||||
|  | //         );
 | ||||||
|  | //     about->ShowModal();
 | ||||||
|  | //     about->Destroy();
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // static method accepting a wxWindow object as first parameter
 | ||||||
|  | bool GUI_App::catch_error(std::function<void()> cb, | ||||||
|  |     //                       wxMessageDialog* message_dialog,
 | ||||||
|  |     const std::string& err /*= ""*/){ | ||||||
|  |     if (!err.empty()) { | ||||||
|  |         if (cb) | ||||||
|  |             cb(); | ||||||
|  |         //         if (message_dialog)
 | ||||||
|  |         //             message_dialog->(err, "Error", wxOK | wxICON_ERROR);
 | ||||||
|  |         show_error(/*this*/nullptr, err); | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  |     return false; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // static method accepting a wxWindow object as first parameter
 | ||||||
|  | void fatal_error(wxWindow* parent){ | ||||||
|  |     show_error(parent, ""); | ||||||
|  |     //     exit 1; // #ys_FIXME
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Called after the Preferences dialog is closed and the program settings are saved.
 | ||||||
|  | // Update the UI based on the current preferences.
 | ||||||
|  | void GUI_App::update_ui_from_settings(){ | ||||||
|  |     mainframe->update_ui_from_settings(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | void GUI_App::open_model(wxWindow *parent, wxArrayString& input_files) | ||||||
|  | { | ||||||
|  |     auto dialog = new wxFileDialog(parent ? parent : GetTopWindow(), | ||||||
|  |         _(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")), | ||||||
|  |         app_config->get_last_dir(), "", | ||||||
|  |         MODEL_WILDCARD, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST); | ||||||
|  |     if (dialog->ShowModal() != wxID_OK) { | ||||||
|  |         dialog->Destroy(); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     dialog->GetPaths(input_files); | ||||||
|  |     dialog->Destroy(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GUI_App::CallAfter(std::function<void()> cb) | ||||||
|  | { | ||||||
|  |     // set mutex
 | ||||||
|  |     callback_register.lock(); | ||||||
|  |     // push function onto stack
 | ||||||
|  |     m_cb.emplace(cb); | ||||||
|  |     // unset mutex
 | ||||||
|  |     callback_register.unlock(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | wxMenuItem* GUI_App::append_menu_item(  wxMenu* menu, | ||||||
|  |                                         int id, | ||||||
|  |                                         const wxString& string, | ||||||
|  |                                         const wxString& description, | ||||||
|  |                                         const std::string& icon, | ||||||
|  |                                         std::function<void(wxCommandEvent& event)> cb, | ||||||
|  |                                         wxItemKind kind/* = wxITEM_NORMAL*/) | ||||||
|  | { | ||||||
|  |     if (id == wxID_ANY) | ||||||
|  |         id = wxNewId(); | ||||||
|  |     auto item = new wxMenuItem(menu, id, string, description, kind); | ||||||
|  |     if (!icon.empty()) | ||||||
|  |         item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG)); | ||||||
|  |     menu->Append(item); | ||||||
|  | 
 | ||||||
|  |     menu->Bind(wxEVT_MENU, /*[cb](wxCommandEvent& event){cb; }*/cb); | ||||||
|  |     return item; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | wxMenuItem* GUI_App::append_submenu(wxMenu* menu, | ||||||
|  |     wxMenu* sub_menu, | ||||||
|  |     int id, | ||||||
|  |     const wxString& string, | ||||||
|  |     const wxString& description, | ||||||
|  |     const std::string& icon) | ||||||
|  | { | ||||||
|  |     if (id == wxID_ANY) | ||||||
|  |         id = wxNewId(); | ||||||
|  |     auto item = new wxMenuItem(menu, id, string, description); | ||||||
|  |     if (!icon.empty()) | ||||||
|  |         item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG)); | ||||||
|  |     item->SetSubMenu(sub_menu); | ||||||
|  |     menu->Append(item); | ||||||
|  | 
 | ||||||
|  |     return item; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GUI_App::save_window_pos(wxTopLevelWindow* window, const std::string& name){ | ||||||
|  |     int x, y; | ||||||
|  |     window->GetScreenPosition(&x, &y); | ||||||
|  |     app_config->set(name + "_pos", wxString::Format("%d,%d", x, y).ToStdString()); | ||||||
|  | 
 | ||||||
|  |     window->GetSize(&x, &y); | ||||||
|  |     app_config->set(name + "_size", wxString::Format("%d,%d", x, y).ToStdString()); | ||||||
|  | 
 | ||||||
|  |     app_config->set(name + "_maximized", window->IsMaximized() ? "1" : "0"); | ||||||
|  | 
 | ||||||
|  |     app_config->save(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GUI_App::restore_window_pos(wxTopLevelWindow* window, const std::string& name){ | ||||||
|  |     if (!app_config->has(name + "_pos")) | ||||||
|  |         return; | ||||||
|  | 
 | ||||||
|  |     std::string str = app_config->get(name + "_size"); | ||||||
|  |     std::vector<std::string> values; | ||||||
|  |     boost::split(values, str, boost::is_any_of(",")); | ||||||
|  |     wxSize size = wxSize(atoi(values[0].c_str()), atoi(values[1].c_str())); | ||||||
|  |     window->SetSize(size); | ||||||
|  | 
 | ||||||
|  |     auto display = (new wxDisplay())->GetClientArea(); | ||||||
|  |     str = app_config->get(name + "_pos"); | ||||||
|  |     values.resize(0); | ||||||
|  |     boost::split(values, str, boost::is_any_of(",")); | ||||||
|  |     wxPoint pos = wxPoint(atoi(values[0].c_str()), atoi(values[1].c_str())); | ||||||
|  |     if (pos.x + 0.5*size.GetWidth() < display.GetRight() && | ||||||
|  |         pos.y + 0.5*size.GetHeight() < display.GetBottom()) | ||||||
|  |         window->Move(pos); | ||||||
|  | 
 | ||||||
|  |     if (app_config->get(name + "_maximized") == "1") | ||||||
|  |         window->Maximize(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool GUI_App::load_language() | ||||||
|  | { | ||||||
|  |     wxString language = wxEmptyString; | ||||||
|  |     if (app_config->has("translation_language")) | ||||||
|  |         language = app_config->get("translation_language"); | ||||||
|  | 
 | ||||||
|  |     if (language.IsEmpty()) | ||||||
|  |         return false; | ||||||
|  |     wxArrayString	names; | ||||||
|  |     wxArrayLong		identifiers; | ||||||
|  |     get_installed_languages(names, identifiers); | ||||||
|  |     for (size_t i = 0; i < identifiers.Count(); i++) | ||||||
|  |     { | ||||||
|  |         if (wxLocale::GetLanguageCanonicalName(identifiers[i]) == language) | ||||||
|  |         { | ||||||
|  |             auto locale = get_locale(); | ||||||
|  |             locale = new wxLocale; | ||||||
|  |             locale->Init(identifiers[i]); | ||||||
|  |             locale->AddCatalogLookupPathPrefix(wxPathOnly(localization_dir())); | ||||||
|  |             locale->AddCatalog(GetAppName()); | ||||||
|  |             wxSetlocale(LC_NUMERIC, "C"); | ||||||
|  |             Preset::update_suffix_modified(); | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     return false; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ConfigMenuIDs GUI_App::get_view_mode() | ||||||
|  | { | ||||||
|  |     if (!app_config->has("view_mode")) | ||||||
|  |         return ConfigMenuModeSimple; | ||||||
|  | 
 | ||||||
|  |     const auto mode = app_config->get("view_mode"); | ||||||
|  |     return mode == "expert" ? ConfigMenuModeExpert : ConfigMenuModeSimple; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static wxString dots("…", wxConvUTF8); | ||||||
|  | 
 | ||||||
|  | void GUI_App::add_config_menu(wxMenuBar *menu) | ||||||
|  | { | ||||||
|  |     auto local_menu = new wxMenu(); | ||||||
|  |     wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt); | ||||||
|  | 
 | ||||||
|  |     const auto config_wizard_name = _(ConfigWizard::name().wx_str()); | ||||||
|  |     const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), config_wizard_name); | ||||||
|  |     // Cmd+, is standard on OS X - what about other operating systems?
 | ||||||
|  |     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(); | ||||||
|  |     local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences")) + dots + "\tCtrl+,", _(L("Application preferences"))); | ||||||
|  |     local_menu->AppendSeparator(); | ||||||
|  |     auto mode_menu = new wxMenu(); | ||||||
|  |     mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("&Simple")), _(L("Simple View Mode"))); | ||||||
|  |     mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("&Expert")), _(L("Expert View Mode"))); | ||||||
|  |     mode_menu->Check(config_id_base + get_view_mode(), true); | ||||||
|  |     local_menu->AppendSubMenu(mode_menu, _(L("&Mode")), _(L("Slic3r View Mode"))); | ||||||
|  |     local_menu->AppendSeparator(); | ||||||
|  |     local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); | ||||||
|  |     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")));
 | ||||||
|  | 
 | ||||||
|  |     local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event){ | ||||||
|  |         switch (event.GetId() - config_id_base) { | ||||||
|  |         case ConfigMenuWizard: | ||||||
|  |             config_wizard(ConfigWizard::RR_USER); | ||||||
|  |             break; | ||||||
|  |         case ConfigMenuTakeSnapshot: | ||||||
|  |             // Take a configuration snapshot.
 | ||||||
|  |             if (check_unsaved_changes()) { | ||||||
|  |                 wxTextEntryDialog dlg(nullptr, _(L("Taking configuration snapshot")), _(L("Snapshot name"))); | ||||||
|  |                 if (dlg.ShowModal() == wxID_OK) | ||||||
|  |                     app_config->set("on_snapshot", | ||||||
|  |                     Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot( | ||||||
|  |                     *app_config, Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER, dlg.GetValue().ToUTF8().data()).id); | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  |         case ConfigMenuSnapshots: | ||||||
|  |             if (check_unsaved_changes()) { | ||||||
|  |                 std::string on_snapshot; | ||||||
|  |                 if (Config::SnapshotDB::singleton().is_on_snapshot(*app_config)) | ||||||
|  |                     on_snapshot = app_config->get("on_snapshot"); | ||||||
|  |                 ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton(), on_snapshot); | ||||||
|  |                 dlg.ShowModal(); | ||||||
|  |                 if (!dlg.snapshot_to_activate().empty()) { | ||||||
|  |                     if (!Config::SnapshotDB::singleton().is_on_snapshot(*app_config)) | ||||||
|  |                         Config::SnapshotDB::singleton().take_snapshot(*app_config, Config::Snapshot::SNAPSHOT_BEFORE_ROLLBACK); | ||||||
|  |                     app_config->set("on_snapshot", | ||||||
|  |                         Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *app_config).id); | ||||||
|  |                     preset_bundle->load_presets(*app_config); | ||||||
|  |                     // Load the currently selected preset into the GUI, update the preset selection box.
 | ||||||
|  |                     load_current_presets(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  |         case ConfigMenuPreferences: | ||||||
|  |         { | ||||||
|  | //             PreferencesDialog dlg(mainframe, event_preferences_changed);
 | ||||||
|  | //             dlg.ShowModal();
 | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |         case ConfigMenuLanguage: | ||||||
|  |         { | ||||||
|  |             wxArrayString names; | ||||||
|  |             wxArrayLong identifiers; | ||||||
|  |             get_installed_languages(names, identifiers); | ||||||
|  |             if (select_language(names, identifiers)) { | ||||||
|  |                 save_language(); | ||||||
|  |                 show_info(mainframe->m_tabpanel, _(L("Application will be restarted")), _(L("Attention!"))); | ||||||
|  |                 _3DScene::remove_all_canvases();// remove all canvas before recreate GUI
 | ||||||
|  |                 recreate_GUI(); | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |         case ConfigMenuFlashFirmware: | ||||||
|  |             FirmwareDialog::run(mainframe); | ||||||
|  |             break; | ||||||
|  |         default: | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |     mode_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) { | ||||||
|  |         std::string mode = event.GetId() - config_id_base == ConfigMenuModeExpert ? | ||||||
|  |             "expert" : "simple"; | ||||||
|  |         app_config->set("view_mode", mode); | ||||||
|  |         app_config->save(); | ||||||
|  |         update_mode(); | ||||||
|  |     }); | ||||||
|  |     menu->Append(local_menu, _(L("&Configuration"))); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // This is called when closing the application, when loading a config file or when starting the config wizard
 | ||||||
|  | // to notify the user whether he is aware that some preset changes will be lost.
 | ||||||
|  | bool GUI_App::check_unsaved_changes() | ||||||
|  | { | ||||||
|  |     std::string dirty; | ||||||
|  |     for (Tab *tab : tabs_list) | ||||||
|  |         if (tab->current_preset_is_dirty()) | ||||||
|  |             if (dirty.empty()) | ||||||
|  |                 dirty = tab->name(); | ||||||
|  |             else | ||||||
|  |                 dirty += std::string(", ") + tab->name(); | ||||||
|  |     if (dirty.empty()) | ||||||
|  |         // No changes, the application may close or reload presets.
 | ||||||
|  |         return true; | ||||||
|  |     // Ask the user.
 | ||||||
|  |     auto dialog = new wxMessageDialog(mainframe, | ||||||
|  |         _(L("You have unsaved changes ")) + dirty + _(L(". Discard changes and continue anyway?")), | ||||||
|  |         _(L("Unsaved Presets")), | ||||||
|  |         wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT); | ||||||
|  |     return dialog->ShowModal() == wxID_YES; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | wxNotebook* GUI_App::tab_panel() const  | ||||||
|  | { | ||||||
|  |     return mainframe->m_tabpanel; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // std::vector<PresetTab>  preset_tabs = {
 | ||||||
|  | //     { "print", nullptr, ptFFF },
 | ||||||
|  | //     { "filament", nullptr, ptFFF },
 | ||||||
|  | //     { "sla_material", nullptr, ptSLA }
 | ||||||
|  | // };
 | ||||||
|  | // 
 | ||||||
|  | // Tab* GUI_App::get_tab(const std::string& name)
 | ||||||
|  | // {
 | ||||||
|  | //     std::vector<PresetTab>::iterator it = std::find_if(preset_tabs.begin(), preset_tabs.end(),
 | ||||||
|  | //         [name](PresetTab& tab){ return name == tab.name; });
 | ||||||
|  | //     return it != preset_tabs.end() ? it->panel : nullptr;
 | ||||||
|  | // }
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // static method accepting a wxWindow object as first parameter
 | ||||||
|  | // void warning_catcher{
 | ||||||
|  | //     my($self, $message_dialog) = @_;
 | ||||||
|  | //     return sub{
 | ||||||
|  | //         my $message = shift;
 | ||||||
|  | //         return if $message = ~/ GLUquadricObjPtr | Attempt to free unreferenced scalar / ;
 | ||||||
|  | //         my @params = ($message, 'Warning', wxOK | wxICON_WARNING);
 | ||||||
|  | //         $message_dialog
 | ||||||
|  | //             ? $message_dialog->(@params)
 | ||||||
|  | //             : Wx::MessageDialog->new($self, @params)->ShowModal;
 | ||||||
|  | //     };
 | ||||||
|  | // }
 | ||||||
|  | 
 | ||||||
|  | // Do we need this function???
 | ||||||
|  | // void GUI_App::notify(message){
 | ||||||
|  | //     auto frame = GetTopWindow();
 | ||||||
|  | //     // try harder to attract user attention on OS X
 | ||||||
|  | //     if (!frame->IsActive())
 | ||||||
|  | //         frame->RequestUserAttention(defined(__WXOSX__/*&Wx::wxMAC */)? wxUSER_ATTENTION_ERROR : wxUSER_ATTENTION_INFO);
 | ||||||
|  | // 
 | ||||||
|  | //     // There used to be notifier using a Growl application for OSX, but Growl is dead.
 | ||||||
|  | //     // The notifier also supported the Linux X D - bus notifications, but that support was broken.
 | ||||||
|  | //     //TODO use wxNotificationMessage ?
 | ||||||
|  | // }
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } // GUI
 | ||||||
|  | } //Slic3r
 | ||||||
							
								
								
									
										104
									
								
								src/slic3r/GUI/GUI_App.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								src/slic3r/GUI/GUI_App.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,104 @@ | ||||||
|  | #ifndef slic3r_GUI_App_hpp_ | ||||||
|  | #define slic3r_GUI_App_hpp_ | ||||||
|  | 
 | ||||||
|  | #include <string> | ||||||
|  | // #include <vector>
 | ||||||
|  | #include "PrintConfig.hpp" | ||||||
|  | // #include "../../libslic3r/Utils.hpp"
 | ||||||
|  | // #include "GUI.hpp"
 | ||||||
|  | 
 | ||||||
|  | #include <wx/app.h> | ||||||
|  | 
 | ||||||
|  | #include <mutex> | ||||||
|  | #include <stack> | ||||||
|  | 
 | ||||||
|  | class wxMenuItem; | ||||||
|  | class wxMenuBar; | ||||||
|  | class wxTopLevelWindow; | ||||||
|  | class wxNotebook; | ||||||
|  | 
 | ||||||
|  | namespace Slic3r { | ||||||
|  | class AppConfig; | ||||||
|  | class PresetBundle; | ||||||
|  | class PresetUpdater; | ||||||
|  | 
 | ||||||
|  | namespace GUI | ||||||
|  | { | ||||||
|  | enum ConfigMenuIDs { | ||||||
|  |     ConfigMenuWizard, | ||||||
|  |     ConfigMenuSnapshots, | ||||||
|  |     ConfigMenuTakeSnapshot, | ||||||
|  |     ConfigMenuUpdate, | ||||||
|  |     ConfigMenuPreferences, | ||||||
|  |     ConfigMenuModeSimple, | ||||||
|  |     ConfigMenuModeExpert, | ||||||
|  |     ConfigMenuLanguage, | ||||||
|  |     ConfigMenuFlashFirmware, | ||||||
|  |     ConfigMenuCnt, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | class MainFrame; | ||||||
|  | class Tab; | ||||||
|  | 
 | ||||||
|  | class GUI_App : public wxApp | ||||||
|  | { | ||||||
|  |     // Datadir provided on the command line.
 | ||||||
|  |     std::string     datadir = ""; | ||||||
|  |     bool            no_plater{ true }; | ||||||
|  |     bool            app_conf_exists{ false }; | ||||||
|  | 
 | ||||||
|  |     // Lock to guard the callback stack
 | ||||||
|  |     std::mutex      callback_register; | ||||||
|  |     // callbacks registered to run during idle event.
 | ||||||
|  |     std::stack<std::function<void()>>    m_cb{}; | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  |     bool            OnInit() override; | ||||||
|  |     GUI_App() : wxApp() {} | ||||||
|  | 
 | ||||||
|  |     void            recreate_GUI(); | ||||||
|  |     void            system_info(); | ||||||
|  |     void            open_model(wxWindow *parent, wxArrayString& input_files); | ||||||
|  |     static bool     catch_error(std::function<void()> cb, | ||||||
|  | //                                 wxMessageDialog* message_dialog,
 | ||||||
|  |                                 const std::string& err); | ||||||
|  | //     void            notify(/*message*/);
 | ||||||
|  |     void            update_ui_from_settings(); | ||||||
|  |     void            CallAfter(std::function<void()> cb); | ||||||
|  |     wxMenuItem*     append_menu_item(   wxMenu* menu, | ||||||
|  |                                         int id, | ||||||
|  |                                         const wxString& string, | ||||||
|  |                                         const wxString& description, | ||||||
|  |                                         const std::string& icon, | ||||||
|  |                                         std::function<void(wxCommandEvent& event)> cb, | ||||||
|  |                                         wxItemKind kind = wxITEM_NORMAL); | ||||||
|  |     wxMenuItem*     append_submenu( wxMenu* menu, | ||||||
|  |                                     wxMenu* sub_menu, | ||||||
|  |                                     int id, | ||||||
|  |                                     const wxString& string, | ||||||
|  |                                     const wxString& description, | ||||||
|  |                                     const std::string& icon); | ||||||
|  |     void            save_window_pos(wxTopLevelWindow* window, const std::string& name); | ||||||
|  |     void            restore_window_pos(wxTopLevelWindow* window, const std::string& name); | ||||||
|  |     bool            load_language(); | ||||||
|  |     ConfigMenuIDs   get_view_mode(); | ||||||
|  |     void            add_config_menu(wxMenuBar *menu); | ||||||
|  |     bool            check_unsaved_changes(); | ||||||
|  |     //     Tab*            get_tab(const std::string& name);
 | ||||||
|  | 
 | ||||||
|  |     AppConfig*      app_config{ nullptr }; | ||||||
|  |     PresetBundle*   preset_bundle{ nullptr }; | ||||||
|  |     PresetUpdater*  preset_updater{ nullptr }; | ||||||
|  |     MainFrame*      mainframe{ nullptr }; | ||||||
|  | 
 | ||||||
|  |     wxNotebook*     tab_panel() const ; | ||||||
|  | 
 | ||||||
|  |     std::vector<Tab *>      tabs_list; | ||||||
|  | 
 | ||||||
|  | }; | ||||||
|  | DECLARE_APP(GUI_App) | ||||||
|  | 
 | ||||||
|  | } // GUI
 | ||||||
|  | } //Slic3r
 | ||||||
|  | 
 | ||||||
|  | #endif // slic3r_GUI_App_hpp_
 | ||||||
|  | @ -15,6 +15,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <wx/glcanvas.h> | #include <wx/glcanvas.h> | ||||||
| #include "3DScene.hpp" | #include "3DScene.hpp" | ||||||
|  | #include "GUI_App.hpp" | ||||||
| 
 | 
 | ||||||
| namespace Slic3r | namespace Slic3r | ||||||
| { | { | ||||||
|  | @ -103,8 +104,8 @@ void get_options_menu(settings_menu_hierarchy& settings_menu, bool is_part) | ||||||
| { | { | ||||||
| 	auto options = get_options(is_part); | 	auto options = get_options(is_part); | ||||||
| 
 | 
 | ||||||
|     auto extruders_cnt = get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA ? 1 : |     auto extruders_cnt = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA ? 1 : | ||||||
|                          get_preset_bundle()->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); |                          wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); | ||||||
| 
 | 
 | ||||||
| 	DynamicPrintConfig config; | 	DynamicPrintConfig config; | ||||||
| 	for (auto& option : options) | 	for (auto& option : options) | ||||||
|  | @ -398,7 +399,7 @@ void update_after_moving() | ||||||
| 
 | 
 | ||||||
| wxSizer* object_movers(wxWindow *win) | wxSizer* object_movers(wxWindow *win) | ||||||
| { | { | ||||||
| // 	DynamicPrintConfig* config = &get_preset_bundle()->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume
 | // 	DynamicPrintConfig* config = &wxGetApp().preset_bundle->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume
 | ||||||
| 	std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "Move"/*, config*/); | 	std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "Move"/*, config*/); | ||||||
| 	optgroup->label_width = 20; | 	optgroup->label_width = 20; | ||||||
| 	optgroup->m_on_change = [](t_config_option_key opt_key, boost::any value){ | 	optgroup->m_on_change = [](t_config_option_key opt_key, boost::any value){ | ||||||
|  | @ -453,7 +454,7 @@ wxSizer* object_movers(wxWindow *win) | ||||||
| 
 | 
 | ||||||
| wxBoxSizer* content_settings(wxWindow *win) | wxBoxSizer* content_settings(wxWindow *win) | ||||||
| { | { | ||||||
| 	DynamicPrintConfig* config = &get_preset_bundle()->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume
 | 	DynamicPrintConfig* config = &wxGetApp().preset_bundle->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume
 | ||||||
| 	std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "Extruders", config); | 	std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "Extruders", config); | ||||||
| 	optgroup->label_width = label_width(); | 	optgroup->label_width = label_width(); | ||||||
| 
 | 
 | ||||||
|  | @ -915,8 +916,8 @@ void update_settings_list() | ||||||
|         std::vector<std::string> categories; |         std::vector<std::string> categories; | ||||||
|         if (!(opt_keys.size() == 1 && opt_keys[0] == "extruder"))// return;
 |         if (!(opt_keys.size() == 1 && opt_keys[0] == "extruder"))// return;
 | ||||||
|         { |         { | ||||||
|             auto extruders_cnt = get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA ? 1 : |             auto extruders_cnt = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA ? 1 : | ||||||
|                 get_preset_bundle()->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); |                 wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); | ||||||
| 
 | 
 | ||||||
|             for (auto& opt_key : opt_keys) { |             for (auto& opt_key : opt_keys) { | ||||||
|                 auto category = (*m_config)->def()->get(opt_key)->category; |                 auto category = (*m_config)->def()->get(opt_key)->category; | ||||||
|  | @ -1461,7 +1462,7 @@ void on_btn_split(const bool split_part) | ||||||
| 		return; | 		return; | ||||||
|     ModelVolume* volume; |     ModelVolume* volume; | ||||||
|     if (!get_volume_by_item(split_part, item, volume)) return; |     if (!get_volume_by_item(split_part, item, volume)) return; | ||||||
|     DynamicPrintConfig&	config = get_preset_bundle()->printers.get_edited_preset().config; |     DynamicPrintConfig&	config = wxGetApp().preset_bundle->printers.get_edited_preset().config; | ||||||
|     const auto nozzle_dmrs_cnt = config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); |     const auto nozzle_dmrs_cnt = config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); | ||||||
|     if (volume->split(nozzle_dmrs_cnt) == 1) { |     if (volume->split(nozzle_dmrs_cnt) == 1) { | ||||||
|         wxMessageBox(_(L("The selected object couldn't be split because it contains only one part."))); |         wxMessageBox(_(L("The selected object couldn't be split because it contains only one part."))); | ||||||
|  | @ -1930,7 +1931,8 @@ void on_drop(wxDataViewEvent &event) | ||||||
| 
 | 
 | ||||||
| void update_objects_list_extruder_column(int extruders_count) | void update_objects_list_extruder_column(int extruders_count) | ||||||
| { | { | ||||||
|     if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA) |     if (!m_objects_ctrl) return; // #ys_FIXME
 | ||||||
|  |     if (wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA) | ||||||
|         extruders_count = 1; |         extruders_count = 1; | ||||||
| 
 | 
 | ||||||
|     // delete old 3rd column
 |     // delete old 3rd column
 | ||||||
|  |  | ||||||
							
								
								
									
										800
									
								
								src/slic3r/GUI/MainFrame.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										800
									
								
								src/slic3r/GUI/MainFrame.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,800 @@ | ||||||
|  | #include "MainFrame.hpp" | ||||||
|  | 
 | ||||||
|  | #include <wx/panel.h> | ||||||
|  | #include <wx/notebook.h> | ||||||
|  | #include <wx/icon.h> | ||||||
|  | #include <wx/sizer.h> | ||||||
|  | #include <wx/menu.h> | ||||||
|  | #include <wx/progdlg.h> | ||||||
|  | 
 | ||||||
|  | #include "Tab.hpp" | ||||||
|  | #include "PresetBundle.hpp" | ||||||
|  | #include "..\AppController.hpp" | ||||||
|  | #include "ProgressStatusBar.hpp" | ||||||
|  | #include "3DScene.hpp" | ||||||
|  | #include "Print.hpp" | ||||||
|  | #include "Polygon.hpp" | ||||||
|  | #include "AppConfig.hpp" | ||||||
|  | 
 | ||||||
|  | #include <fstream> | ||||||
|  | #include <boost/geometry/strategies/spherical/compare_circular.hpp> | ||||||
|  | #include "GUI_App.hpp" | ||||||
|  | 
 | ||||||
|  | namespace Slic3r { | ||||||
|  | namespace GUI { | ||||||
|  | 
 | ||||||
|  | static wxString dots("…", wxConvUTF8); | ||||||
|  | 
 | ||||||
|  | MainFrame::MainFrame(const bool no_plater, const bool loaded) : | ||||||
|  | wxFrame(NULL, wxID_ANY, "FORK_NAME-VERSION", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE), | ||||||
|  |         m_no_plater(no_plater), | ||||||
|  |         m_loaded(loaded) | ||||||
|  | { | ||||||
|  | //     Slic3r::GUI::set_main_frame(this);
 | ||||||
|  |     m_appController = new Slic3r::AppController(); | ||||||
|  | 
 | ||||||
|  | // #if _WIN32
 | ||||||
|  | //     // Load the icon either from the exe, or from the ico file.
 | ||||||
|  | // //     auto iconfile = Slic3r::decode_path($FindBin::Bin) . '\slic3r.exe';
 | ||||||
|  | //         auto iconfile = Slic3r::var("Slic3r.ico");// unless - f iconfile;
 | ||||||
|  | //     SetIcon(wxIcon(iconfile, wxBITMAP_TYPE_ICO));
 | ||||||
|  | // #else
 | ||||||
|  |     SetIcon(wxIcon(Slic3r::var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG)); | ||||||
|  | // #ifdef // _WIN32
 | ||||||
|  | 
 | ||||||
|  |     // initialize tabpanel and menubar
 | ||||||
|  |     init_tabpanel(); | ||||||
|  |     init_menubar(); | ||||||
|  | 
 | ||||||
|  |     // set default tooltip timer in msec
 | ||||||
|  |     // SetAutoPop supposedly accepts long integers but some bug doesn't allow for larger values
 | ||||||
|  |     // (SetAutoPop is not available on GTK.)
 | ||||||
|  |     wxToolTip::SetAutoPop(32767); | ||||||
|  | 
 | ||||||
|  |     // initialize status bar
 | ||||||
|  |     m_statusbar = new Slic3r::GUI::ProgressStatusBar(this); | ||||||
|  |     m_statusbar->embed(this); | ||||||
|  |     m_statusbar->set_status_text(_(L("Version ")) +  | ||||||
|  |                                  "Slic3r_VERSION" + // Slic3r::VERSION + 
 | ||||||
|  |                                  _(L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases"))); | ||||||
|  |     // Make the global status bar and its progress indicator available in C++
 | ||||||
|  |     m_appController->set_global_progress_indicator(m_statusbar); | ||||||
|  | 
 | ||||||
|  | //     m_appController->set_model(m_plater->model);
 | ||||||
|  | //     m_appController->set_print(m_plater->print);
 | ||||||
|  | //     m_plater->appController = m_appController;
 | ||||||
|  | 
 | ||||||
|  |     m_loaded = true; | ||||||
|  | 
 | ||||||
|  |     // initialize layout
 | ||||||
|  |     auto sizer = new wxBoxSizer(wxVERTICAL); | ||||||
|  |     if (m_tabpanel) | ||||||
|  |         sizer->Add(m_tabpanel, 1, wxEXPAND); | ||||||
|  |     sizer->SetSizeHints(this); | ||||||
|  |     SetSizer(sizer); | ||||||
|  |     Fit(); | ||||||
|  |     SetMinSize(wxSize(760, 490)); | ||||||
|  |     SetSize(GetMinSize()); | ||||||
|  |     wxGetApp().restore_window_pos(this, "main_frame"); | ||||||
|  |     Show(); | ||||||
|  |     Layout(); | ||||||
|  | 
 | ||||||
|  |     // declare events
 | ||||||
|  |     Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event){ | ||||||
|  |         if (event.CanVeto() && !wxGetApp().check_unsaved_changes()) { | ||||||
|  |             event.Veto(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         // save window size
 | ||||||
|  |         wxGetApp().save_window_pos(this, "main_frame"); | ||||||
|  |         // Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
 | ||||||
|  |         // but in rare cases it may not have been called yet.
 | ||||||
|  |         wxGetApp().app_config->save(); | ||||||
|  | //         if (m_plater)
 | ||||||
|  | //             m_plater->print = undef;
 | ||||||
|  |         _3DScene::remove_all_canvases(); | ||||||
|  | //         Slic3r::GUI::deregister_on_request_update_callback();
 | ||||||
|  |         // propagate event
 | ||||||
|  |         event.Skip(); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  | //     update_ui_from_settings();
 | ||||||
|  | // 
 | ||||||
|  | //     Slic3r::GUI::update_mode();
 | ||||||
|  | 
 | ||||||
|  |     return; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::init_tabpanel() | ||||||
|  | { | ||||||
|  |     m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL); | ||||||
|  | //     Slic3r::GUI::set_tab_panel(m_tabpanel);
 | ||||||
|  | 
 | ||||||
|  |     m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&){ | ||||||
|  |         auto panel = m_tabpanel->GetCurrentPage(); | ||||||
|  | //             panel->OnActivate(); if panel->can('OnActivate');
 | ||||||
|  | 
 | ||||||
|  |         std::vector<std::string> tab_names = { "print", "filament", "printer" }; | ||||||
|  |         for (auto& tab_name : tab_names) { | ||||||
|  |             if (tab_name == panel->GetName()) | ||||||
|  |                 m_options_tabs.at(tab_name)->OnActivate(); | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     if (!m_no_plater) { | ||||||
|  | //        m_plater = new Slic3r::GUI::Plater(m_tabpanel,
 | ||||||
|  | //             event_object_selection_changed = > $OBJECT_SELECTION_CHANGED_EVENT,
 | ||||||
|  | //             event_object_settings_changed = > $OBJECT_SETTINGS_CHANGED_EVENT,
 | ||||||
|  | //             event_remove_object = > $OBJECT_REMOVE_EVENT,
 | ||||||
|  | //             event_update_scene = > $UPDATE_SCENE_EVENT,
 | ||||||
|  | //             ), L("Plater")
 | ||||||
|  | //         m_tabpanel->AddPage(plater);
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // The following event is emited by the C++ Tab implementation on config value change.
 | ||||||
|  | //     EVT_COMMAND($self, -1, $VALUE_CHANGE_EVENT, sub {
 | ||||||
|  | //         my($self, $event) = @_;
 | ||||||
|  | //         auto str = event->GetString;
 | ||||||
|  | //         my($opt_key, $name) = ($str = ~/ (.*) (.*) / );
 | ||||||
|  | //         auto tab = Slic3r::GUI::get_preset_tab(name);
 | ||||||
|  | //         auto config = tab->get_config();
 | ||||||
|  | //         if (m_plater) {
 | ||||||
|  | //             m_plater->on_config_change(config); // propagate config change events to the plater
 | ||||||
|  | //                 if (opt_key == "extruders_count"){
 | ||||||
|  | //                     auto value = event->GetInt();
 | ||||||
|  | //                     m_plater->on_extruders_change(value);
 | ||||||
|  | //                 }
 | ||||||
|  | //             if (opt_key == "printer_technology"){
 | ||||||
|  | //                 auto value = event->GetInt(); // 0 ~"ptFFF"; 1 ~"ptSLA"
 | ||||||
|  | //                     m_plater->show_preset_comboboxes(value);
 | ||||||
|  | //             }
 | ||||||
|  | //         }
 | ||||||
|  | //         // don't save while loading for the first time
 | ||||||
|  | //         if (Slic3r::GUI::autosave && m_loaded)
 | ||||||
|  | //             m_config->save(Slic3r::GUI::autosave) ;
 | ||||||
|  | //     });
 | ||||||
|  | 
 | ||||||
|  |     // The following event is emited by the C++ Tab implementation on preset selection,
 | ||||||
|  |     // or when the preset's "modified" status changes.
 | ||||||
|  | //     EVT_COMMAND($self, -1, $PRESETS_CHANGED_EVENT, sub {
 | ||||||
|  | //         my($self, $event) = @_;
 | ||||||
|  | //         auto tab_name = event->GetString;
 | ||||||
|  | // 
 | ||||||
|  | //         Tab* tab = Slic3r::GUI::get_preset_tab(tab_name);
 | ||||||
|  | //         if (m_plater) {
 | ||||||
|  | //             // Update preset combo boxes(Print settings, Filament, Material, Printer) from their respective tabs.
 | ||||||
|  | //             auto presets = tab->get_presets();
 | ||||||
|  | //             if (presets){
 | ||||||
|  | //                 auto reload_dependent_tabs = tab->get_dependent_tabs();
 | ||||||
|  | //                 m_plater->update_presets(tab_name, reload_dependent_tabs, presets);
 | ||||||
|  | //                 m_plater->{"selected_item_$tab_name"} = tab->get_selected_preset_item();
 | ||||||
|  | //                 if (tab_name == "printer") {
 | ||||||
|  | //                     // Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
 | ||||||
|  | //                     std::vector<std::string> tab_names_other = { "print", "filament", "sla_materialprinter" };
 | ||||||
|  | //                     for (const auto tab_name_other : tab_names_other) {
 | ||||||
|  | //                         Tab* cur_tab = m_options_tabs[tab_name_other];
 | ||||||
|  | //                         // If the printer tells us that the print or filament preset has been switched or invalidated,
 | ||||||
|  | //                         // refresh the print or filament tab page.Otherwise just refresh the combo box.
 | ||||||
|  | //                         if (reload_dependent_tabs.empty() ||
 | ||||||
|  | //                             find(reload_dependent_tabs.begin(), reload_dependent_tabs.end(), tab_name_other) ==
 | ||||||
|  | //                             reload_dependent_tabs.end() )
 | ||||||
|  | //                             cur_tab->update_tab_ui();
 | ||||||
|  | //                         else
 | ||||||
|  | //                             cur_tab->load_current_preset();
 | ||||||
|  | //                             
 | ||||||
|  | //                     }
 | ||||||
|  | //                 }
 | ||||||
|  | //                 m_plater->on_config_change(tab->get_config());
 | ||||||
|  | //             }
 | ||||||
|  | //         }
 | ||||||
|  | //     });
 | ||||||
|  | 
 | ||||||
|  |     // The following event is emited by the C++ Tab implementation on object selection change.
 | ||||||
|  | //     EVT_COMMAND($self, -1, $OBJECT_SELECTION_CHANGED_EVENT, sub {
 | ||||||
|  | //         auto obj_idx = event->GetId();
 | ||||||
|  | //         // my $child = $event->GetInt == 1 ? 1 : undef;
 | ||||||
|  | //         // $self->{plater}->select_object($obj_idx < 0 ? undef : $obj_idx, $child);
 | ||||||
|  | //         // $self->{plater}->item_changed_selection($obj_idx);
 | ||||||
|  | // 
 | ||||||
|  | //         auto vol_idx = event->GetInt();
 | ||||||
|  | //         m_plater->select_object_from_cpp(obj_idx < 0 ? undef : obj_idx, vol_idx < 0 ? -1 : vol_idx);
 | ||||||
|  | //     });
 | ||||||
|  | 
 | ||||||
|  |     // The following event is emited by the C++ GUI implementation on object settings change.
 | ||||||
|  | //     EVT_COMMAND($self, -1, $OBJECT_SETTINGS_CHANGED_EVENT, sub {
 | ||||||
|  | //         auto line = event->GetString();
 | ||||||
|  | //         my($obj_idx, $parts_changed, $part_settings_changed) = split('', $line);
 | ||||||
|  | // 
 | ||||||
|  | //         m_plater->changed_object_settings(obj_idx, parts_changed, part_settings_changed);
 | ||||||
|  | //     });
 | ||||||
|  | 
 | ||||||
|  |     // The following event is emited by the C++ GUI implementation on object remove.
 | ||||||
|  | //     EVT_COMMAND($self, -1, $OBJECT_REMOVE_EVENT, sub {
 | ||||||
|  | //         m_plater->remove();
 | ||||||
|  | //     });
 | ||||||
|  | // 
 | ||||||
|  | //     // The following event is emited by the C++ GUI implementation on extruder change for object.
 | ||||||
|  | //     EVT_COMMAND($self, -1, $UPDATE_SCENE_EVENT, sub {
 | ||||||
|  | //         m_plater->update();
 | ||||||
|  | //     });
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     create_preset_tabs(); | ||||||
|  |     std::vector<std::string> tab_names = { "print", "filament", "sla_material", "printer" };     | ||||||
|  |     for (auto tab_name : tab_names) | ||||||
|  |         m_options_tabs[tab_name] = get_preset_tab(tab_name.c_str());  | ||||||
|  | 
 | ||||||
|  |     if (m_plater) { | ||||||
|  | //         m_plater->on_select_preset(sub{
 | ||||||
|  | //             my($group, $name) = @_;
 | ||||||
|  | //             $self->{options_tabs}{$group}->select_preset($name);
 | ||||||
|  | //         });
 | ||||||
|  |         // load initial config
 | ||||||
|  |         auto full_config = wxGetApp().preset_bundle->full_config(); | ||||||
|  | //         m_plater->on_config_change(full_config);
 | ||||||
|  | 
 | ||||||
|  |         // Show a correct number of filament fields.
 | ||||||
|  | //         if (defined full_config->nozzle_diameter){
 | ||||||
|  | //             // nozzle_diameter is undefined when SLA printer is selected
 | ||||||
|  | //             m_plater->on_extruders_change(int(@{$full_config->nozzle_diameter}));
 | ||||||
|  | //         }
 | ||||||
|  | 
 | ||||||
|  |         // Show correct preset comboboxes according to the printer_technology
 | ||||||
|  | //         m_plater->show_preset_comboboxes(full_config.printer_technology() == "FFF" ? 0 : 1);
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Tab* MainFrame::get_preset_tab(const std::string& name) | ||||||
|  | { | ||||||
|  |     Tab* tab = get_tab(name); | ||||||
|  |     if (tab) return tab; | ||||||
|  | 
 | ||||||
|  |     for (size_t i = 0; i < m_tabpanel->GetPageCount(); ++i) { | ||||||
|  |         tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(i)); | ||||||
|  |         if (!tab) | ||||||
|  |             continue; | ||||||
|  |         if (tab->name() == name) { | ||||||
|  |             return tab; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     return nullptr; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::create_preset_tabs() | ||||||
|  | { | ||||||
|  | //    update_label_colours_from_appconfig();
 | ||||||
|  |     add_created_tab(new TabPrint(m_tabpanel)); | ||||||
|  |     add_created_tab(new TabFilament(m_tabpanel)); | ||||||
|  |     add_created_tab(new TabSLAMaterial(m_tabpanel)); | ||||||
|  |     add_created_tab(new TabPrinter(m_tabpanel)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::add_created_tab(Tab* panel) | ||||||
|  | { | ||||||
|  |     panel->create_preset_tab(wxGetApp().preset_bundle); | ||||||
|  | 
 | ||||||
|  |     // Load the currently selected preset into the GUI, update the preset selection box.
 | ||||||
|  |     panel->load_current_preset(); | ||||||
|  | 
 | ||||||
|  |     const wxString& tab_name = panel->GetName(); | ||||||
|  |     bool add_panel = true; | ||||||
|  | 
 | ||||||
|  |     auto preset_tabs = get_preset_tabs(); | ||||||
|  |     auto it = std::find_if(preset_tabs->begin(), preset_tabs->end(), | ||||||
|  |         [tab_name](PresetTab& tab){return tab.name == tab_name; }); | ||||||
|  |     if (it != preset_tabs->end()) { | ||||||
|  |         it->panel = panel; | ||||||
|  |         add_panel = it->technology == wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (add_panel) | ||||||
|  |         m_tabpanel->AddPage(panel, panel->title()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::init_menubar() | ||||||
|  | { | ||||||
|  |     // File menu
 | ||||||
|  |     wxMenu* fileMenu = new wxMenu; | ||||||
|  |     { | ||||||
|  |         wxGetApp().append_menu_item(fileMenu, wxID_ANY, _(L("Open STL/OBJ/AMF/3MF…\tCtrl+O")), _(L("Open a model")),  | ||||||
|  |             "", [](wxCommandEvent&){ | ||||||
|  | //             if (m_plater) m_plater->add();
 | ||||||
|  |         }); //'brick_add.png');
 | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config…\tCtrl+L")), _(L("Load exported configuration file")),  | ||||||
|  |                         [this](wxCommandEvent&){ load_config_file(); }, "plugin_add.png"); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config…\tCtrl+E")), _(L("Export current configuration to file")),  | ||||||
|  |                         [this](wxCommandEvent&){ export_config(); }, "plugin_go.png"); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config Bundle…")), _(L("Load presets from a bundle")),  | ||||||
|  |                         [this](wxCommandEvent&){ load_configbundle(); }, "lorry_add.png"); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config Bundle…")), _(L("Export all presets to file")),  | ||||||
|  |                         [this](wxCommandEvent&){ export_configbundle(); }, "lorry_go.png"); | ||||||
|  |         fileMenu->AppendSeparator(); | ||||||
|  |         wxMenuItem* repeat = nullptr; | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("Q&uick Slice…\tCtrl+U")), _(L("Slice a file into a G-code")),  | ||||||
|  |             [this, repeat](wxCommandEvent&){ | ||||||
|  |                 wxTheApp->CallAfter([this, repeat](){ | ||||||
|  |                     quick_slice(); | ||||||
|  |                     repeat->Enable(is_last_input_file()); | ||||||
|  |             }); }, "cog_go.png"); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("Quick Slice and Save &As…\tCtrl+Alt+U")), _(L("Slice a file into a G-code, save as")),  | ||||||
|  |             [this, repeat](wxCommandEvent&){ | ||||||
|  |                 wxTheApp->CallAfter([this, repeat](){ | ||||||
|  |                     quick_slice(qsSaveAs); | ||||||
|  |                     repeat->Enable(is_last_input_file()); | ||||||
|  |             }); }, "cog_go.png"); | ||||||
|  |         repeat = append_menu_item(fileMenu, wxID_ANY, _(L("&Repeat Last Quick Slice\tCtrl+Shift+U")), _(L("Repeat last quick slice")),  | ||||||
|  |             [this](wxCommandEvent&){ | ||||||
|  |             wxTheApp->CallAfter([this](){ | ||||||
|  |                 quick_slice(qsReslice); | ||||||
|  |             }); }, "cog_go.png"); | ||||||
|  |         repeat->Enable(0); | ||||||
|  |         fileMenu->AppendSeparator(); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("Slice to SV&G…\tCtrl+G")), _(L("Slice file to a multi-layer SVG")), | ||||||
|  |             [this](wxCommandEvent&){ quick_slice(qsSaveAs | qsExportSVG); }, "shape_handles.png"); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("Slice to PNG…")), _(L("Slice file to a set of PNG files")), | ||||||
|  |             [this](wxCommandEvent&){ slice_to_png(); /*$self->quick_slice(save_as = > 0, export_png = > 1);*/ }, "shape_handles.png"); | ||||||
|  |         m_menu_item_reslice_now = append_menu_item(fileMenu, wxID_ANY, _(L("(&Re)Slice Now\tCtrl+S")), _(L("Start new slicing process")), | ||||||
|  |             [this](wxCommandEvent&){ reslice_now(); }, "shape_handles.png"); | ||||||
|  |         fileMenu->AppendSeparator(); | ||||||
|  |         append_menu_item(fileMenu, wxID_ANY, _(L("Repair STL file…")), _(L("Automatically repair an STL file")), | ||||||
|  |             [this](wxCommandEvent&){ repair_stl(); }, "wrench.png"); | ||||||
|  |         fileMenu->AppendSeparator(); | ||||||
|  |         append_menu_item(fileMenu, wxID_EXIT, _(L("&Quit")), _(L("Quit Slic3r")), | ||||||
|  |             [this](wxCommandEvent&){ Close(false); } ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Plater menu
 | ||||||
|  |     if(m_plater) { | ||||||
|  |         auto plater_menu = new wxMenu(); | ||||||
|  |         append_menu_item(plater_menu, wxID_ANY, L("Export G-code..."), L("Export current plate as G-code"),  | ||||||
|  |             [this](wxCommandEvent&){ /*m_plater->export_gcode(); */}, "cog_go.png"); | ||||||
|  |         append_menu_item(plater_menu, wxID_ANY, L("Export plate as STL..."), L("Export current plate as STL"),  | ||||||
|  |             [this](wxCommandEvent&){ /*m_plater->export_stl(); */}, "brick_go.png"); | ||||||
|  |         append_menu_item(plater_menu, wxID_ANY, L("Export plate as AMF..."), L("Export current plate as AMF"),  | ||||||
|  |             [this](wxCommandEvent&){ /*m_plater->export_amf();*/ }, "brick_go.png"); | ||||||
|  |         append_menu_item(plater_menu, wxID_ANY, L("Export plate as 3MF..."), L("Export current plate as 3MF"),  | ||||||
|  |             [this](wxCommandEvent&){ /*m_plater->export_3mf(); */}, "brick_go.png"); | ||||||
|  | 
 | ||||||
|  | //         m_object_menu = m_plater->object_menu;
 | ||||||
|  |         on_plater_selection_changed(false); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Window menu
 | ||||||
|  |     auto windowMenu = new wxMenu(); | ||||||
|  |     { | ||||||
|  |         size_t tab_offset = 0; | ||||||
|  |         if (m_plater) { | ||||||
|  |             append_menu_item(windowMenu, wxID_ANY, L("Select &Plater Tab\tCtrl+1"), L("Show the plater"),  | ||||||
|  |                 [this](wxCommandEvent&){ select_tab(0); }, "application_view_tile.png"); | ||||||
|  |             tab_offset += 1; | ||||||
|  |         } | ||||||
|  |         if (tab_offset > 0) { | ||||||
|  |             windowMenu->AppendSeparator(); | ||||||
|  |         } | ||||||
|  |         append_menu_item(windowMenu, wxID_ANY, L("Select P&rint Settings Tab\tCtrl+2"), L("Show the print settings"),  | ||||||
|  |             [this, tab_offset](wxCommandEvent&){ select_tab(tab_offset + 0); }, "cog.png"); | ||||||
|  |         append_menu_item(windowMenu, wxID_ANY, L("Select &Filament Settings Tab\tCtrl+3"), L("Show the filament settings"),  | ||||||
|  |             [this, tab_offset](wxCommandEvent&){ select_tab(tab_offset + 1); }, "spool.png"); | ||||||
|  |         append_menu_item(windowMenu, wxID_ANY, L("Select Print&er Settings Tab\tCtrl+4"), L("Show the printer settings"),  | ||||||
|  |             [this, tab_offset](wxCommandEvent&){ select_tab(tab_offset + 2); }, "printer_empty.png"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // View menu
 | ||||||
|  |     if (m_plater) { | ||||||
|  |         m_viewMenu = new wxMenu(); | ||||||
|  | // \xA0 is a non-breaing space. It is entered here to spoil the automatic accelerators,
 | ||||||
|  |         // as the simple numeric accelerators spoil all numeric data entry.
 | ||||||
|  |         // The camera control accelerators are captured by 3DScene Perl module instead.
 | ||||||
|  |         auto accel = [](const wxString& st1, const wxString& st2) { | ||||||
|  | //             if ($^O eq "MSWin32")
 | ||||||
|  | //                 return st1 + "\t\xA0" + st2;
 | ||||||
|  | //             else
 | ||||||
|  |                 return st1;  | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Iso")), "0"),     L("Iso View"),   [this](wxCommandEvent&){ select_view("iso"); }); | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Top")), "1"),     L("Top View"),   [this](wxCommandEvent&){ select_view("top"); }); | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Bottom")), "2"),  L("Bottom View"),[this](wxCommandEvent&){ select_view("bottom"); }); | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Front")), "3"),   L("Front View"), [this](wxCommandEvent&){ select_view("front"); }); | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Rear")), "4"),    L("Rear View"),  [this](wxCommandEvent&){ select_view("rear"); }); | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Left")), "5"),    L("Left View"),  [this](wxCommandEvent&){ select_view("left"); }); | ||||||
|  |         append_menu_item(m_viewMenu, wxID_ANY, accel(_(L("Right")), "6"),   L("Right View"), [this](wxCommandEvent&){ select_view("right"); }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Help menu
 | ||||||
|  |     auto helpMenu = new wxMenu(); | ||||||
|  |     { | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("Prusa 3D Drivers")), _(L("Open the Prusa3D drivers download page in your browser")),  | ||||||
|  |             [this](wxCommandEvent&){ wxLaunchDefaultBrowser("http://www.prusa3d.com/drivers/"); }); | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("Prusa Edition Releases")), _(L("Open the Prusa Edition releases page in your browser")),  | ||||||
|  |             [this](wxCommandEvent&){ wxLaunchDefaultBrowser("http://github.com/prusa3d/slic3r/releases"); }); | ||||||
|  | //#        my $versioncheck = $self->_append_menu_item($helpMenu, "Check for &Updates...", "Check for new Slic3r versions", sub{
 | ||||||
|  | //#            wxTheApp->check_version(1);
 | ||||||
|  | //#        });
 | ||||||
|  | //#        $versioncheck->Enable(wxTheApp->have_version_check);
 | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("Slic3r &Website")), _(L("Open the Slic3r website in your browser")),  | ||||||
|  |             [this](wxCommandEvent&){ wxLaunchDefaultBrowser("http://slic3r.org/"); }); | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("Slic3r &Manual")), _(L("Open the Slic3r manual in your browser")),  | ||||||
|  |             [this](wxCommandEvent&){ wxLaunchDefaultBrowser("http://manual.slic3r.org/"); }); | ||||||
|  |         helpMenu->AppendSeparator(); | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("System Info")), _(L("Show system information")),  | ||||||
|  |             [this](wxCommandEvent&){ wxGetApp().system_info(); }); | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("Show &Configuration Folder")), _(L("Show user configuration folder (datadir)")),  | ||||||
|  |             [this](wxCommandEvent&){ Slic3r::GUI::desktop_open_datadir_folder(); }); | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("Report an Issue")), _(L("Report an issue on the Slic3r Prusa Edition")),  | ||||||
|  |             [this](wxCommandEvent&){ wxLaunchDefaultBrowser("http://github.com/prusa3d/slic3r/issues/new"); }); | ||||||
|  |         append_menu_item(helpMenu, wxID_ANY, _(L("&About Slic3r")), _(L("Show about dialog")),  | ||||||
|  |             [this](wxCommandEvent&){ Slic3r::GUI::about(); }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // menubar
 | ||||||
|  |     // assign menubar to frame after appending items, otherwise special items
 | ||||||
|  |     // will not be handled correctly
 | ||||||
|  |     { | ||||||
|  |         auto menubar = new wxMenuBar(); | ||||||
|  |         menubar->Append(fileMenu, L("&File")); | ||||||
|  |         if (m_plater_menu) menubar->Append(m_plater_menu, L("&Plater")) ; | ||||||
|  |         if (m_object_menu) menubar->Append(m_object_menu, L("&Object")) ; | ||||||
|  |         menubar->Append(windowMenu, L("&Window")); | ||||||
|  |         if (m_viewMenu) menubar->Append(m_viewMenu, L("&View")); | ||||||
|  |         // Add additional menus from C++
 | ||||||
|  |         wxGetApp().add_config_menu(menubar); | ||||||
|  |         menubar->Append(helpMenu, L("&Help")); | ||||||
|  |         SetMenuBar(menubar); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Selection of a 3D object changed on the platter.
 | ||||||
|  | void MainFrame::on_plater_selection_changed(const bool have_selection) | ||||||
|  | { | ||||||
|  |     if (!m_object_menu) return; | ||||||
|  |      | ||||||
|  |     for (auto item : m_object_menu->GetMenuItems()) | ||||||
|  |         m_object_menu->Enable(item->GetId(), have_selection); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::slice_to_png(){ | ||||||
|  | //     m_plater->stop_background_process();
 | ||||||
|  | //     m_plater->async_apply_config();
 | ||||||
|  |     m_appController->print_ctl()->slice_to_png(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
 | ||||||
|  | void MainFrame::quick_slice(const int qs){ | ||||||
|  | //     my $progress_dialog;
 | ||||||
|  |     wxString input_file; | ||||||
|  | //  eval
 | ||||||
|  | //     {
 | ||||||
|  |     // validate configuration
 | ||||||
|  |     auto config = wxGetApp().preset_bundle->full_config(); | ||||||
|  |     config.validate(); | ||||||
|  | 
 | ||||||
|  |     // select input file
 | ||||||
|  |     if (!(qs & qsReslice)) { | ||||||
|  |         auto dlg = new wxFileDialog(this, _(L("Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):")), | ||||||
|  |             wxGetApp().app_config->get_last_dir(), "", | ||||||
|  |             MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) { | ||||||
|  |             dlg->Destroy(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         input_file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |         if (!(qs & qsExportSVG)) | ||||||
|  |             m_qs_last_input_file = input_file; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         if (m_qs_last_input_file.IsEmpty()) { | ||||||
|  |             auto dlg = new wxMessageDialog(this, _(L("No previously sliced file.")), | ||||||
|  |                 _(L("Error")), wxICON_ERROR | wxOK); | ||||||
|  |             dlg->ShowModal(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         if (std::ifstream(m_qs_last_input_file.char_str())) { | ||||||
|  |             auto dlg = new wxMessageDialog(this, _(L("Previously sliced file ("))+m_qs_last_input_file+_(L(") not found.")), | ||||||
|  |                 _(L("File Not Found")), wxICON_ERROR | wxOK); | ||||||
|  |             dlg->ShowModal(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         input_file = m_qs_last_input_file; | ||||||
|  |     } | ||||||
|  |     auto input_file_basename = get_base_name(input_file); | ||||||
|  |     wxGetApp().app_config->update_skein_dir(get_dir_name(input_file)); | ||||||
|  | 
 | ||||||
|  |     auto bed_shape = Slic3r::Polygon::new_scale(config.option<ConfigOptionPoints>("bed_shape")->values); | ||||||
|  | //     auto print_center = Slic3r::Pointf->new_unscale(bed_shape.bounding_box().center());
 | ||||||
|  | // 
 | ||||||
|  | //     auto sprint = new Slic3r::Print::Simple(
 | ||||||
|  | //         print_center = > print_center,
 | ||||||
|  | //         status_cb = > [](int percent, const wxString& msg){
 | ||||||
|  | //         m_progress_dialog->Update(percent, msg+"…");
 | ||||||
|  | //     });
 | ||||||
|  | 
 | ||||||
|  |     // keep model around
 | ||||||
|  |     auto model = Slic3r::Model::read_from_file(input_file.ToStdString()); | ||||||
|  | 
 | ||||||
|  | //     sprint->apply_config(config);
 | ||||||
|  | //     sprint->set_model(model);
 | ||||||
|  | 
 | ||||||
|  |     // Copy the names of active presets into the placeholder parser.
 | ||||||
|  | //     wxGetApp().preset_bundle->export_selections(sprint->placeholder_parser);
 | ||||||
|  | 
 | ||||||
|  |     // select output file
 | ||||||
|  |     wxString output_file; | ||||||
|  |     if (qs & qsReslice) { | ||||||
|  |         if (!m_qs_last_output_file.IsEmpty()) | ||||||
|  |             output_file = m_qs_last_output_file; | ||||||
|  |     }  | ||||||
|  |     else if (qs & qsSaveAs) { | ||||||
|  |         // The following line may die if the output_filename_format template substitution fails.
 | ||||||
|  | //         output_file = sprint->output_filepath;
 | ||||||
|  | //         if (export_svg)
 | ||||||
|  | //         output_file = ~s / \.[gG][cC][oO][dD][eE]$ / .svg /;
 | ||||||
|  |         auto dlg = new wxFileDialog(this, _(L("Save ")) + (qs & qsExportSVG ? _(L("SVG")) : _(L("G-code"))) + _(L(" file as:")), | ||||||
|  |             wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file),  | ||||||
|  |             qs & qsExportSVG ? FILE_WILDCARDS.at("svg") : FILE_WILDCARDS.at("gcode"), | ||||||
|  |             wxFD_SAVE | wxFD_OVERWRITE_PROMPT); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) { | ||||||
|  |             dlg->Destroy(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         output_file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |         if (!(qs & qsExportSVG)) | ||||||
|  |             m_qs_last_output_file = output_file; | ||||||
|  |         wxGetApp().app_config->update_last_output_dir(get_dir_name(output_file)); | ||||||
|  |     }  | ||||||
|  |     else if (qs & qsExportPNG) { | ||||||
|  | //         output_file = sprint->output_filepath;
 | ||||||
|  | //         output_file = ~s / \.[gG][cC][oO][dD][eE]$ / .zip / ;
 | ||||||
|  |         auto dlg = new wxFileDialog(this, _(L("Save zip file as:")), | ||||||
|  |             wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), | ||||||
|  |             get_base_name(output_file), "*.zip", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) { | ||||||
|  |             dlg->Destroy(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         output_file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // show processbar dialog
 | ||||||
|  |     m_progress_dialog = new wxProgressDialog(_(L("Slicing…")), _(L("Processing ")) + input_file_basename + "…", | ||||||
|  |         100, this, 4); | ||||||
|  |     m_progress_dialog->Pulse(); | ||||||
|  |     { | ||||||
|  | //         my @warnings = ();
 | ||||||
|  | //         local $SIG{ __WARN__ } = sub{ push @warnings, $_[0] };
 | ||||||
|  | 
 | ||||||
|  | //         sprint->output_file(output_file);
 | ||||||
|  | //         if (export_svg) {
 | ||||||
|  | //             sprint->export_svg();
 | ||||||
|  | //         }
 | ||||||
|  | //         else if(export_png) {
 | ||||||
|  | //             sprint->export_png();
 | ||||||
|  | //         }
 | ||||||
|  | //         else {
 | ||||||
|  | //             sprint->export_gcode();
 | ||||||
|  | //         }
 | ||||||
|  | //         sprint->status_cb(undef);
 | ||||||
|  | //         Slic3r::GUI::warning_catcher($self)->($_) for @warnings;
 | ||||||
|  |     } | ||||||
|  |     m_progress_dialog->Destroy(); | ||||||
|  |     m_progress_dialog = nullptr; | ||||||
|  | 
 | ||||||
|  |     auto message = input_file_basename + _(L(" was successfully sliced.")); | ||||||
|  | //     wxTheApp->notify(message);
 | ||||||
|  |     wxMessageDialog(this, message, _(L("Slicing Done!")), wxOK | wxICON_INFORMATION).ShowModal(); | ||||||
|  | //     };
 | ||||||
|  | //     Slic3r::GUI::catch_error(this, [](){ if (m_progress_dialog) m_progress_dialog->Destroy(); });
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::reslice_now(){ | ||||||
|  | //     if (m_plater)
 | ||||||
|  | //         m_plater->reslice();
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::repair_stl() | ||||||
|  | { | ||||||
|  |     wxString input_file; | ||||||
|  |     { | ||||||
|  |         auto dlg = new wxFileDialog(this, _(L("Select the STL file to repair:")), | ||||||
|  |             wxGetApp().app_config->get_last_dir(), "", | ||||||
|  |             FILE_WILDCARDS.at("stl"), wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) { | ||||||
|  |             dlg->Destroy(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         input_file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     auto output_file = input_file; | ||||||
|  |     { | ||||||
|  | //         output_file = ~s / \.[sS][tT][lL]$ / _fixed.obj / ;
 | ||||||
|  |         auto dlg = new wxFileDialog( this, L("Save OBJ file (less prone to coordinate errors than STL) as:"),  | ||||||
|  |                                         get_dir_name(output_file), get_base_name(output_file),  | ||||||
|  |                                         FILE_WILDCARDS.at("obj"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) { | ||||||
|  |             dlg->Destroy(); | ||||||
|  |             return /*undef*/; | ||||||
|  |         } | ||||||
|  |         output_file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     auto tmesh = new Slic3r::TriangleMesh(); | ||||||
|  |     tmesh->ReadSTLFile(input_file.char_str()); | ||||||
|  |     tmesh->repair(); | ||||||
|  |     tmesh->WriteOBJFile(output_file.char_str()); | ||||||
|  |     Slic3r::GUI::show_info(this, L("Your file was repaired."), L("Repair")); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::export_config() | ||||||
|  | { | ||||||
|  |     // Generate a cummulative configuration for the selected print, filaments and printer.
 | ||||||
|  |     auto config = wxGetApp().preset_bundle->full_config(); | ||||||
|  |     // Validate the cummulative configuration.
 | ||||||
|  |     auto valid = config.validate(); | ||||||
|  |     if (!valid.empty()) { | ||||||
|  | //         Slic3r::GUI::catch_error(this);
 | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |     // Ask user for the file name for the config file.
 | ||||||
|  |     auto dlg = new wxFileDialog(this, _(L("Save configuration as:")), | ||||||
|  |         !m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(), | ||||||
|  |         !m_last_config.IsEmpty() ? get_base_name(m_last_config) : "config.ini", | ||||||
|  |         FILE_WILDCARDS.at("ini"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); | ||||||
|  |     wxString file = dlg->ShowModal() == wxID_OK ? dlg->GetPath() : wxEmptyString; | ||||||
|  |     dlg->Destroy(); | ||||||
|  |     if (!file.IsEmpty()) { | ||||||
|  |         wxGetApp().app_config->update_config_dir(get_dir_name(file)); | ||||||
|  |         m_last_config = file; | ||||||
|  |         config.save(file.ToStdString()); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Load a config file containing a Print, Filament & Printer preset.
 | ||||||
|  | void MainFrame::load_config_file(wxString file/* = wxEmptyString*/) | ||||||
|  | { | ||||||
|  |     if (file.IsEmpty()) { | ||||||
|  |         if (!wxGetApp().check_unsaved_changes()) | ||||||
|  |             return; | ||||||
|  |         auto dlg = new wxFileDialog(this, _(L("Select configuration to load:")), | ||||||
|  |             !m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(), | ||||||
|  |             "config.ini", "INI files (*.ini, *.gcode)|*.ini;*.INI;*.gcode;*.g", wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) | ||||||
|  |             return; | ||||||
|  |         file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |     } | ||||||
|  | //     eval{ 
 | ||||||
|  |         wxGetApp().preset_bundle->load_config_file(file.ToStdString());  | ||||||
|  | //     };
 | ||||||
|  |     // Dont proceed further if the config file cannot be loaded.
 | ||||||
|  | //     if (Slic3r::GUI::catch_error(this))
 | ||||||
|  | //         return;
 | ||||||
|  |     for (auto tab : m_options_tabs ) | ||||||
|  |         tab.second->load_current_preset(); | ||||||
|  |     wxGetApp().app_config->update_config_dir(get_dir_name(file)); | ||||||
|  |     m_last_config = file; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::export_configbundle() | ||||||
|  | { | ||||||
|  |     if (!wxGetApp().check_unsaved_changes()) | ||||||
|  |         return; | ||||||
|  |     // validate current configuration in case it's dirty
 | ||||||
|  |     auto valid = wxGetApp().preset_bundle->full_config().validate(); | ||||||
|  |     if (!valid.empty()) { | ||||||
|  | //         Slic3r::GUI::catch_error(this);
 | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |     // Ask user for a file name.
 | ||||||
|  |     auto dlg = new wxFileDialog(this, _(L("Save presets bundle as:")), | ||||||
|  |         !m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(), | ||||||
|  |         "Slic3r_config_bundle.ini", | ||||||
|  |         FILE_WILDCARDS.at("ini"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); | ||||||
|  |     wxString file = dlg->ShowModal() == wxID_OK ? dlg->GetPath() : wxEmptyString; | ||||||
|  |     dlg->Destroy(); | ||||||
|  |     if (!file.IsEmpty()) { | ||||||
|  |         // Export the config bundle.
 | ||||||
|  |        wxGetApp().app_config->update_config_dir(get_dir_name(file)); | ||||||
|  | //         eval{ 
 | ||||||
|  |             wxGetApp().preset_bundle->export_configbundle(file.ToStdString());  | ||||||
|  | //         };
 | ||||||
|  | //         Slic3r::GUI::catch_error(this);
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Loading a config bundle with an external file name used to be used
 | ||||||
|  | // to auto - install a config bundle on a fresh user account,
 | ||||||
|  | // but that behavior was not documented and likely buggy.
 | ||||||
|  | void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool reset_user_profile*/){ | ||||||
|  |     if (!wxGetApp().check_unsaved_changes()) | ||||||
|  |         return; | ||||||
|  |     if (file.IsEmpty()) { | ||||||
|  |         auto dlg = new wxFileDialog(this, _(L("Select configuration to load:")), | ||||||
|  |             !m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(), | ||||||
|  |             "config.ini", FILE_WILDCARDS.at("ini"), wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||||
|  |         if (dlg->ShowModal() != wxID_OK) | ||||||
|  |             return; | ||||||
|  |         file = dlg->GetPath(); | ||||||
|  |         dlg->Destroy(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     wxGetApp().app_config->update_config_dir(get_dir_name(file)); | ||||||
|  | 
 | ||||||
|  |     auto presets_imported = 0; | ||||||
|  | //     eval{ 
 | ||||||
|  |     presets_imported = wxGetApp().preset_bundle->load_configbundle(file.ToStdString()); | ||||||
|  | //     };
 | ||||||
|  | //     Slic3r::GUI::catch_error(this) and return;
 | ||||||
|  | 
 | ||||||
|  |     // Load the currently selected preset into the GUI, update the preset selection box.
 | ||||||
|  |     for (auto tab : m_options_tabs) | ||||||
|  |         tab.second->load_current_preset(); | ||||||
|  | 
 | ||||||
|  |     const auto message = wxString::Format(_(L("%d presets successfully imported.")), presets_imported); | ||||||
|  |     Slic3r::GUI::show_info(this, message, "Info"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Load a provied DynamicConfig into the Print / Filament / Printer tabs, thus modifying the active preset.
 | ||||||
|  | // Also update the platter with the new presets.
 | ||||||
|  | void MainFrame::load_config(const DynamicPrintConfig& config){ | ||||||
|  |     for (auto tab : m_options_tabs) | ||||||
|  |         tab.second->load_config(config); | ||||||
|  | //     if (m_plater) m_plater->on_config_change(config);
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MainFrame::select_tab(size_t tab) const{ | ||||||
|  |     m_tabpanel->SetSelection(tab); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Set a camera direction, zoom to all objects.
 | ||||||
|  | void MainFrame::select_view(const std::string& direction){ | ||||||
|  | //     if (m_plater)
 | ||||||
|  | //         m_plater->select_view(direction);
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | wxMenuItem* MainFrame::append_menu_item(wxMenu* menu,  | ||||||
|  |                                         int id,  | ||||||
|  |                                         const wxString& string, | ||||||
|  |                                         const wxString& description, | ||||||
|  |                                         std::function<void(wxCommandEvent& event)> cb,  | ||||||
|  |                                         const std::string& icon /*= ""*/) | ||||||
|  | { | ||||||
|  |     if (id == wxID_ANY) | ||||||
|  |         id = wxNewId(); | ||||||
|  |     auto item = menu->Append(id, string, description); | ||||||
|  |     if (!icon.empty()) | ||||||
|  |         item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG)); | ||||||
|  |     menu->Bind(wxEVT_MENU, /*[cb](wxCommandEvent& event){cb; }*/cb); | ||||||
|  |     return item; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Called after the Preferences dialog is closed and the program settings are saved.
 | ||||||
|  | // Update the UI based on the current preferences.
 | ||||||
|  | void MainFrame::update_ui_from_settings() | ||||||
|  | { | ||||||
|  |     m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1"); | ||||||
|  | //     if (m_plater) m_plater->update_ui_from_settings();
 | ||||||
|  |     std::vector<std::string> tab_names = { "print", "filament", "printer" }; | ||||||
|  |     for (auto tab_name: tab_names) | ||||||
|  |         m_options_tabs[tab_name]->update_ui_from_settings(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | std::string MainFrame::get_base_name(const wxString full_name) const  | ||||||
|  | { | ||||||
|  |     return boost::filesystem::path(full_name).filename().string(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::string MainFrame::get_dir_name(const wxString full_name) const  | ||||||
|  | { | ||||||
|  |     return boost::filesystem::path(full_name).parent_path().string(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } // GUI
 | ||||||
|  | } // Slic3r
 | ||||||
							
								
								
									
										104
									
								
								src/slic3r/GUI/MainFrame.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								src/slic3r/GUI/MainFrame.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,104 @@ | ||||||
|  | #ifndef slic3r_MainFrame_hpp_ | ||||||
|  | #define slic3r_MainFrame_hpp_ | ||||||
|  | 
 | ||||||
|  | #include "PrintConfig.hpp" | ||||||
|  | 
 | ||||||
|  | #include <wx/frame.h> | ||||||
|  | 
 | ||||||
|  | #include <string> | ||||||
|  | #include <map> | ||||||
|  | 
 | ||||||
|  | class wxMenuBar; | ||||||
|  | class wxNotebook; | ||||||
|  | class wxPanel; | ||||||
|  | class wxMenu; | ||||||
|  | class wxProgressDialog; | ||||||
|  | 
 | ||||||
|  | namespace Slic3r { | ||||||
|  | 
 | ||||||
|  | class ProgressStatusBar; | ||||||
|  | class AppController; | ||||||
|  | 
 | ||||||
|  | // #define _(s)    Slic3r::GUI::I18N::translate((s))
 | ||||||
|  | 
 | ||||||
|  | namespace GUI | ||||||
|  | { | ||||||
|  | class Tab; | ||||||
|  | 
 | ||||||
|  | enum QuickSlice | ||||||
|  | { | ||||||
|  |     qsUndef, | ||||||
|  |     qsReslice, | ||||||
|  |     qsSaveAs, | ||||||
|  |     qsExportSVG, | ||||||
|  |     qsExportPNG | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | class MainFrame : public wxFrame | ||||||
|  | { | ||||||
|  |     bool        m_no_plater; | ||||||
|  |     bool        m_loaded; | ||||||
|  |     int         m_lang_ch_event; | ||||||
|  |     int         m_preferences_event; | ||||||
|  | 
 | ||||||
|  |     wxString    m_qs_last_input_file = wxEmptyString; | ||||||
|  |     wxString    m_qs_last_output_file = wxEmptyString; | ||||||
|  |     wxString    m_last_config = wxEmptyString; | ||||||
|  | 
 | ||||||
|  |     ProgressStatusBar*              m_statusbar { nullptr }; | ||||||
|  |     AppController*                  m_appController { nullptr }; | ||||||
|  |     std::map<std::string, Tab*>     m_options_tabs; | ||||||
|  | 
 | ||||||
|  |     wxMenuItem* append_menu_item(wxMenu* menu, | ||||||
|  |                                  int id, | ||||||
|  |                                  const wxString& string, | ||||||
|  |                                  const wxString& description, | ||||||
|  |                                  std::function<void(wxCommandEvent& event)> cb, | ||||||
|  |                                  const std::string& icon = ""); | ||||||
|  | 
 | ||||||
|  |     wxMenuItem* m_menu_item_reslice_now { nullptr }; | ||||||
|  |     wxMenu*     m_plater_menu { nullptr }; | ||||||
|  |     wxMenu*     m_object_menu { nullptr }; | ||||||
|  |     wxMenu*     m_viewMenu { nullptr }; | ||||||
|  | 
 | ||||||
|  |     std::string     get_base_name(const wxString full_name) const ; | ||||||
|  |     std::string     get_dir_name(const wxString full_name) const ; | ||||||
|  | public: | ||||||
|  |     MainFrame() {} | ||||||
|  |     MainFrame(const bool no_plater, const bool loaded); | ||||||
|  |     ~MainFrame() {} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     void        init_tabpanel(); | ||||||
|  |     Tab*        get_preset_tab(const std::string& name); | ||||||
|  |     void        create_preset_tabs(); | ||||||
|  |     void        add_created_tab(Tab* panel); | ||||||
|  |     void        init_menubar(); | ||||||
|  | 
 | ||||||
|  |     void        update_ui_from_settings(); | ||||||
|  |     bool        is_loaded() const { return m_loaded; } | ||||||
|  |     bool        is_last_input_file() const  { return !m_qs_last_input_file.IsEmpty(); } | ||||||
|  | 
 | ||||||
|  |     void        on_plater_selection_changed(const bool have_selection); | ||||||
|  |     void        slice_to_png(); | ||||||
|  |     void        quick_slice(const int qs = qsUndef); | ||||||
|  |     void        reslice_now(); | ||||||
|  |     void        repair_stl(); | ||||||
|  |     void        export_config(); | ||||||
|  |     void        load_config_file(wxString file = wxEmptyString); | ||||||
|  |     void        export_configbundle(); | ||||||
|  |     void        load_configbundle(wxString file = wxEmptyString); | ||||||
|  |     void        load_config(const DynamicPrintConfig& config); | ||||||
|  |     void        select_tab(size_t tab) const; | ||||||
|  |     void        select_view(const std::string& direction); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     wxPanel*            m_plater {nullptr}; | ||||||
|  |     wxNotebook*         m_tabpanel { nullptr }; | ||||||
|  |     wxProgressDialog*   m_progress_dialog { nullptr }; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // GUI
 | ||||||
|  | } //Slic3r
 | ||||||
|  | 
 | ||||||
|  | #endif // slic3r_MainFrame_hpp_
 | ||||||
|  | @ -218,10 +218,10 @@ void OptionsGroup::append_line(const Line& line, wxStaticText**	colored_Label/* | ||||||
| 
 | 
 | ||||||
| 		add_undo_buttuns_to_sizer(sizer, field); | 		add_undo_buttuns_to_sizer(sizer, field); | ||||||
| 		if (is_window_field(field))  | 		if (is_window_field(field))  | ||||||
| 			sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, (option.opt.full_width ? wxEXPAND : 0) | | 			sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, //(option.opt.full_width ? wxEXPAND : 0) |
 | ||||||
| 							wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, (wxOSX||!staticbox) ? 0 : 2); |             wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2); | ||||||
| 		if (is_sizer_field(field))  | 		if (is_sizer_field(field))  | ||||||
| 			sizer->Add(field->getSizer(), 1, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0); | 			sizer->Add(field->getSizer(), 1, /*(*/option.opt.full_width ? wxEXPAND : /*0) |*/ wxALIGN_CENTER_VERTICAL, 0); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -244,7 +244,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText**	colored_Label/* | ||||||
| // 								L_str(option.label);
 | // 								L_str(option.label);
 | ||||||
| 			label = new wxStaticText(parent(), wxID_ANY, str_label + ":", wxDefaultPosition, wxDefaultSize); | 			label = new wxStaticText(parent(), wxID_ANY, str_label + ":", wxDefaultPosition, wxDefaultSize); | ||||||
| 			label->SetFont(label_font); | 			label->SetFont(label_font); | ||||||
| 			sizer_tmp->Add(label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 0); | 			sizer_tmp->Add(label, 0, /*wxALIGN_RIGHT |*/ wxALIGN_CENTER_VERTICAL, 0); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// add field
 | 		// add field
 | ||||||
|  |  | ||||||
|  | @ -130,7 +130,7 @@ void ProgressStatusBar::run(int rate) | ||||||
| 
 | 
 | ||||||
| void ProgressStatusBar::embed(wxFrame *frame) | void ProgressStatusBar::embed(wxFrame *frame) | ||||||
| { | { | ||||||
|     wxFrame* mf = frame? frame : GUI::get_main_frame(); |     wxFrame* mf = frame ? frame : GUI::get_main_frame(); | ||||||
|     mf->SetStatusBar(self); |     mf->SetStatusBar(self); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -28,6 +28,7 @@ | ||||||
| #include <wx/wupdlock.h> | #include <wx/wupdlock.h> | ||||||
| 
 | 
 | ||||||
| #include <chrono> | #include <chrono> | ||||||
|  | #include "GUI_App.hpp" | ||||||
| 
 | 
 | ||||||
| namespace Slic3r { | namespace Slic3r { | ||||||
| namespace GUI { | namespace GUI { | ||||||
|  | @ -513,8 +514,8 @@ void Tab::update_changed_tree_ui() | ||||||
| 			} | 			} | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 		auto next_item = m_treectrl->GetNextVisible(cur_item); |         auto next_item = m_treectrl->GetNextVisible(cur_item); | ||||||
| 		cur_item = next_item; |         cur_item = !m_treectrl->IsVisible(cur_item) ? m_treectrl->GetNextVisible(cur_item) : nullptr;// next_item;
 | ||||||
| 	} | 	} | ||||||
| 	update_undo_buttons(); | 	update_undo_buttons(); | ||||||
| } | } | ||||||
|  | @ -713,15 +714,16 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) | ||||||
| 
 | 
 | ||||||
| // Show/hide the 'purging volumes' button
 | // Show/hide the 'purging volumes' button
 | ||||||
| void Tab::update_wiping_button_visibility() { | void Tab::update_wiping_button_visibility() { | ||||||
|     if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA) |     if (wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA) | ||||||
|         return; // ys_FIXME
 |         return; // ys_FIXME
 | ||||||
|     bool wipe_tower_enabled = dynamic_cast<ConfigOptionBool*>(  (m_preset_bundle->prints.get_edited_preset().config  ).option("wipe_tower"))->value; |     bool wipe_tower_enabled = dynamic_cast<ConfigOptionBool*>(  (m_preset_bundle->prints.get_edited_preset().config  ).option("wipe_tower"))->value; | ||||||
|     bool multiple_extruders = dynamic_cast<ConfigOptionFloats*>((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; |     bool multiple_extruders = dynamic_cast<ConfigOptionFloats*>((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; | ||||||
|     bool single_extruder_mm = dynamic_cast<ConfigOptionBool*>(  (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; |     bool single_extruder_mm = dynamic_cast<ConfigOptionBool*>(  (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; | ||||||
| 
 | 
 | ||||||
| 	get_wiping_dialog_button()->Show(wipe_tower_enabled && multiple_extruders && single_extruder_mm); |     if (get_wiping_dialog_button()) { | ||||||
| 	 | 	get_wiping_dialog_button()->Show(wipe_tower_enabled && multiple_extruders && single_extruder_mm);	 | ||||||
|     (get_wiping_dialog_button()->GetParent())->Layout(); |     (get_wiping_dialog_button()->GetParent())->Layout(); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -787,6 +789,7 @@ void Tab::update_preset_description_line() | ||||||
| 
 | 
 | ||||||
| void Tab::update_frequently_changed_parameters() | void Tab::update_frequently_changed_parameters() | ||||||
| { | { | ||||||
|  |     if (!get_optgroup(ogFrequentlyChangingParameters)) return; | ||||||
| 	boost::any value = get_optgroup(ogFrequentlyChangingParameters)->get_config_value(*m_config, "fill_density"); | 	boost::any value = get_optgroup(ogFrequentlyChangingParameters)->get_config_value(*m_config, "fill_density"); | ||||||
| 	get_optgroup(ogFrequentlyChangingParameters)->set_value("fill_density", value); | 	get_optgroup(ogFrequentlyChangingParameters)->set_value("fill_density", value); | ||||||
| 
 | 
 | ||||||
|  | @ -1041,7 +1044,7 @@ void TabPrint::reload_config(){ | ||||||
| 
 | 
 | ||||||
| void TabPrint::update() | void TabPrint::update() | ||||||
| { | { | ||||||
|     if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA) |     if (wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA) | ||||||
|         return; // ys_FIXME
 |         return; // ys_FIXME
 | ||||||
| 
 | 
 | ||||||
| 	Freeze(); | 	Freeze(); | ||||||
|  | @ -1407,7 +1410,7 @@ void TabFilament::reload_config(){ | ||||||
| 
 | 
 | ||||||
| void TabFilament::update() | void TabFilament::update() | ||||||
| { | { | ||||||
|     if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA) |     if (wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA) | ||||||
|         return; // ys_FIXME
 |         return; // ys_FIXME
 | ||||||
| 
 | 
 | ||||||
| 	Freeze(); | 	Freeze(); | ||||||
|  | @ -2189,15 +2192,15 @@ void Tab::load_current_preset() | ||||||
|             PrinterTechnology& printer_technology = m_presets->get_edited_preset().printer_technology(); |             PrinterTechnology& printer_technology = m_presets->get_edited_preset().printer_technology(); | ||||||
|             if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology) |             if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology) | ||||||
|             { |             { | ||||||
|                 for (auto& tab : get_preset_tabs()){ |                 for (auto& tab : *get_preset_tabs()){ | ||||||
|                     if (tab.technology != printer_technology) |                     if (tab.technology != printer_technology) | ||||||
|                     { |                     { | ||||||
|                         int page_id = get_tab_panel()->FindPage(tab.panel); |                         int page_id = wxGetApp().tab_panel()->FindPage(tab.panel); | ||||||
|                         get_tab_panel()->GetPage(page_id)->Show(false); |                         wxGetApp().tab_panel()->GetPage(page_id)->Show(false); | ||||||
|                         get_tab_panel()->RemovePage(page_id); |                         wxGetApp().tab_panel()->RemovePage(page_id); | ||||||
|                     } |                     } | ||||||
|                     else |                     else | ||||||
|                         get_tab_panel()->InsertPage(get_tab_panel()->FindPage(this), tab.panel, tab.panel->title()); |                         wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab.panel, tab.panel->title()); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 static_cast<TabPrinter*>(this)->m_printer_technology = printer_technology; |                 static_cast<TabPrinter*>(this)->m_printer_technology = printer_technology; | ||||||
|  | @ -2225,8 +2228,9 @@ void Tab::rebuild_page_tree(bool tree_sel_change_event /*= false*/) | ||||||
| { | { | ||||||
| 	Freeze(); | 	Freeze(); | ||||||
| 	// get label of the currently selected item
 | 	// get label of the currently selected item
 | ||||||
| 	auto selected = m_treectrl->GetItemText(m_treectrl->GetSelection()); |     const auto sel_item = m_treectrl->GetSelection(); | ||||||
| 	auto rootItem = m_treectrl->GetRootItem(); | 	const auto selected = sel_item ? m_treectrl->GetItemText(sel_item) : ""; | ||||||
|  | 	const auto rootItem = m_treectrl->GetRootItem(); | ||||||
| 
 | 
 | ||||||
| 	auto have_selection = 0; | 	auto have_selection = 0; | ||||||
| 	m_treectrl->DeleteChildren(rootItem); | 	m_treectrl->DeleteChildren(rootItem); | ||||||
|  | @ -2375,7 +2379,8 @@ void Tab::OnTreeSelChange(wxTreeEvent& event) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 	Page* page = nullptr; | 	Page* page = nullptr; | ||||||
| 	auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); |     const auto sel_item = m_treectrl->GetSelection(); | ||||||
|  |     const auto selection = sel_item ? m_treectrl->GetItemText(sel_item) : ""; | ||||||
| 	for (auto p : m_pages) | 	for (auto p : m_pages) | ||||||
| 		if (p->title() == selection) | 		if (p->title() == selection) | ||||||
| 		{ | 		{ | ||||||
|  | @ -2517,7 +2522,7 @@ void Tab::update_ui_from_settings() | ||||||
| { | { | ||||||
| 	// Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled
 | 	// Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled
 | ||||||
| 	// in application preferences.
 | 	// in application preferences.
 | ||||||
| 	m_show_btn_incompatible_presets = get_app_config()->get("show_incompatible_presets")[0] == '1' ? true : false; | 	m_show_btn_incompatible_presets = wxGetApp().app_config->get("show_incompatible_presets")[0] == '1' ? true : false; | ||||||
| 	bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0; | 	bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0; | ||||||
| 	show ? m_btn_hide_incompatible_presets->Show() :  m_btn_hide_incompatible_presets->Hide(); | 	show ? m_btn_hide_incompatible_presets->Show() :  m_btn_hide_incompatible_presets->Hide(); | ||||||
| 	// If the 'show / hide presets' button is hidden, hide the incompatible presets.
 | 	// If the 'show / hide presets' button is hidden, hide the incompatible presets.
 | ||||||
|  | @ -2616,7 +2621,7 @@ void Tab::update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible) | ||||||
| 	auto root_sys = ui->AppendContainer(wxDataViewItem(0), _(L("System presets"))); | 	auto root_sys = ui->AppendContainer(wxDataViewItem(0), _(L("System presets"))); | ||||||
| 	auto root_def = ui->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); | 	auto root_def = ui->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); | ||||||
| 
 | 
 | ||||||
| 	auto show_def = get_app_config()->get("no_defaults")[0] != '1'; | 	auto show_def = wxGetApp().app_config->get("no_defaults")[0] != '1'; | ||||||
| 
 | 
 | ||||||
| 	for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { | 	for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { | ||||||
| 		const Preset &preset = presets[i]; | 		const Preset &preset = presets[i]; | ||||||
|  | @ -2702,7 +2707,7 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) | ||||||
| 		auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); | 		auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); | ||||||
| 		auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); | 		auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); | ||||||
| 
 | 
 | ||||||
| 		auto show_def = get_app_config()->get("no_defaults")[0] != '1'; | 		auto show_def = wxGetApp().app_config->get("no_defaults")[0] != '1'; | ||||||
| 
 | 
 | ||||||
| 		for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { | 		for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { | ||||||
| 			const Preset &preset = presets[i]; | 			const Preset &preset = presets[i]; | ||||||
|  | @ -3025,7 +3030,7 @@ void TabSLAMaterial::build() | ||||||
| 
 | 
 | ||||||
| void TabSLAMaterial::update() | void TabSLAMaterial::update() | ||||||
| { | { | ||||||
|     if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptFFF) |     if (wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptFFF) | ||||||
|         return; // ys_FIXME
 |         return; // ys_FIXME
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
| #include "slic3r/Utils/Http.hpp" | #include "slic3r/Utils/Http.hpp" | ||||||
| #include "slic3r/Config/Version.hpp" | #include "slic3r/Config/Version.hpp" | ||||||
| #include "slic3r/Config/Snapshot.hpp" | #include "slic3r/Config/Snapshot.hpp" | ||||||
|  | #include "slic3r/GUI/GUI_App.hpp" | ||||||
| 
 | 
 | ||||||
| namespace fs = boost::filesystem; | namespace fs = boost::filesystem; | ||||||
| using Slic3r::GUI::Config::Index; | using Slic3r::GUI::Config::Index; | ||||||
|  | @ -90,7 +91,6 @@ struct Updates | ||||||
| 
 | 
 | ||||||
| struct PresetUpdater::priv | struct PresetUpdater::priv | ||||||
| { | { | ||||||
| 	int version_online_event; |  | ||||||
| 	std::vector<Index> index_db; | 	std::vector<Index> index_db; | ||||||
| 
 | 
 | ||||||
| 	bool enabled_version_check; | 	bool enabled_version_check; | ||||||
|  | @ -105,7 +105,7 @@ struct PresetUpdater::priv | ||||||
| 	bool cancel; | 	bool cancel; | ||||||
| 	std::thread thread; | 	std::thread thread; | ||||||
| 
 | 
 | ||||||
| 	priv(int version_online_event); | 	priv(); | ||||||
| 
 | 
 | ||||||
| 	void set_download_prefs(AppConfig *app_config); | 	void set_download_prefs(AppConfig *app_config); | ||||||
| 	bool get_file(const std::string &url, const fs::path &target_path) const; | 	bool get_file(const std::string &url, const fs::path &target_path) const; | ||||||
|  | @ -120,15 +120,14 @@ struct PresetUpdater::priv | ||||||
| 	static void copy_file(const fs::path &from, const fs::path &to); | 	static void copy_file(const fs::path &from, const fs::path &to); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| PresetUpdater::priv::priv(int version_online_event) : | PresetUpdater::priv::priv() : | ||||||
| 	version_online_event(version_online_event), |  | ||||||
| 	had_config_update(false), | 	had_config_update(false), | ||||||
| 	cache_path(fs::path(Slic3r::data_dir()) / "cache"), | 	cache_path(fs::path(Slic3r::data_dir()) / "cache"), | ||||||
| 	rsrc_path(fs::path(resources_dir()) / "profiles"), | 	rsrc_path(fs::path(resources_dir()) / "profiles"), | ||||||
| 	vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), | 	vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), | ||||||
| 	cancel(false) | 	cancel(false) | ||||||
| { | { | ||||||
| 	set_download_prefs(GUI::get_app_config()); | 	set_download_prefs(GUI::wxGetApp().app_config); | ||||||
| 	check_install_indices(); | 	check_install_indices(); | ||||||
| 	index_db = std::move(Index::load_db()); | 	index_db = std::move(Index::load_db()); | ||||||
| } | } | ||||||
|  | @ -209,9 +208,11 @@ void PresetUpdater::priv::sync_version() const | ||||||
| 		.on_complete([&](std::string body, unsigned /* http_status */) { | 		.on_complete([&](std::string body, unsigned /* http_status */) { | ||||||
| 			boost::trim(body); | 			boost::trim(body); | ||||||
| 			BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body; | 			BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body; | ||||||
| 			wxCommandEvent* evt = new wxCommandEvent(version_online_event); | // 			wxCommandEvent* evt = new wxCommandEvent(version_online_event);
 | ||||||
| 			evt->SetString(body); | // 			evt->SetString(body);
 | ||||||
| 			GUI::get_app()->QueueEvent(evt); | // 			GUI::get_app()->QueueEvent(evt);
 | ||||||
|  | 	        GUI::wxGetApp().app_config->set("version_online", body); | ||||||
|  | 	        GUI::wxGetApp().app_config->save(); | ||||||
| 		}) | 		}) | ||||||
| 		.perform_sync(); | 		.perform_sync(); | ||||||
| } | } | ||||||
|  | @ -395,7 +396,7 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons | ||||||
| 	if (updates.incompats.size() > 0) { | 	if (updates.incompats.size() > 0) { | ||||||
| 		if (snapshot) { | 		if (snapshot) { | ||||||
| 			BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; | 			BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; | ||||||
| 			SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_DOWNGRADE); | 			SnapshotDB::singleton().take_snapshot(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_DOWNGRADE); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% incompatible bundles") % updates.incompats.size(); | 		BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% incompatible bundles") % updates.incompats.size(); | ||||||
|  | @ -408,7 +409,7 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons | ||||||
| 	else if (updates.updates.size() > 0) { | 	else if (updates.updates.size() > 0) { | ||||||
| 		if (snapshot) { | 		if (snapshot) { | ||||||
| 			BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; | 			BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; | ||||||
| 			SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); | 			SnapshotDB::singleton().take_snapshot(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_UPGRADE); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		BOOST_LOG_TRIVIAL(info) << boost::format("Performing %1% updates") % updates.updates.size(); | 		BOOST_LOG_TRIVIAL(info) << boost::format("Performing %1% updates") % updates.updates.size(); | ||||||
|  | @ -466,8 +467,8 @@ void PresetUpdater::priv::copy_file(const fs::path &source, const fs::path &targ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| PresetUpdater::PresetUpdater(int version_online_event) : | PresetUpdater::PresetUpdater() : | ||||||
| 	p(new priv(version_online_event)) | 	p(new priv()) | ||||||
| {} | {} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -485,7 +486,7 @@ PresetUpdater::~PresetUpdater() | ||||||
| 
 | 
 | ||||||
| void PresetUpdater::sync(PresetBundle *preset_bundle) | void PresetUpdater::sync(PresetBundle *preset_bundle) | ||||||
| { | { | ||||||
| 	p->set_download_prefs(GUI::get_app_config()); | 	p->set_download_prefs(GUI::wxGetApp().app_config); | ||||||
| 	if (!p->enabled_version_check && !p->enabled_config_update) { return; } | 	if (!p->enabled_version_check && !p->enabled_config_update) { return; } | ||||||
| 
 | 
 | ||||||
| 	// Copy the whole vendors data for use in the background thread
 | 	// Copy the whole vendors data for use in the background thread
 | ||||||
|  | @ -509,7 +510,7 @@ void PresetUpdater::slic3r_update_notify() | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	auto* app_config = GUI::get_app_config(); | 	auto* app_config = GUI::wxGetApp().app_config; | ||||||
| 	const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); | 	const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); | ||||||
| 	const auto ver_online_str = app_config->get("version_online"); | 	const auto ver_online_str = app_config->get("version_online"); | ||||||
| 	const auto ver_online = Semver::parse(ver_online_str); | 	const auto ver_online = Semver::parse(ver_online_str); | ||||||
|  | @ -601,7 +602,7 @@ bool PresetUpdater::config_update() const | ||||||
| 			p->perform_updates(std::move(updates)); | 			p->perform_updates(std::move(updates)); | ||||||
| 
 | 
 | ||||||
| 			// Reload global configuration
 | 			// Reload global configuration
 | ||||||
| 			auto *app_config = GUI::get_app_config(); | 			auto *app_config = GUI::wxGetApp().app_config; | ||||||
| 			GUI::get_preset_bundle()->load_presets(*app_config); | 			GUI::get_preset_bundle()->load_presets(*app_config); | ||||||
| 			GUI::load_current_presets(); | 			GUI::load_current_presets(); | ||||||
| 		} else { | 		} else { | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ class PresetBundle; | ||||||
| class PresetUpdater | class PresetUpdater | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	PresetUpdater(int version_online_event); | 	PresetUpdater(); | ||||||
| 	PresetUpdater(PresetUpdater &&) = delete; | 	PresetUpdater(PresetUpdater &&) = delete; | ||||||
| 	PresetUpdater(const PresetUpdater &) = delete; | 	PresetUpdater(const PresetUpdater &) = delete; | ||||||
| 	PresetUpdater &operator=(PresetUpdater &&) = delete; | 	PresetUpdater &operator=(PresetUpdater &&) = delete; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv