mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Removed Print.pm,
ported execution of post processing scripts into C++ (WIP, waits for update of boost::system module on our build server) Removed other mention of the "Controller".
This commit is contained in:
		
							parent
							
								
									bb7f504296
								
							
						
					
					
						commit
						d934b63424
					
				
					 19 changed files with 124 additions and 126 deletions
				
			
		|  | @ -105,6 +105,8 @@ add_library(libslic3r STATIC | |||
|     ${LIBDIR}/libslic3r/GCode/Analyzer.hpp | ||||
|     ${LIBDIR}/libslic3r/GCode/CoolingBuffer.cpp | ||||
|     ${LIBDIR}/libslic3r/GCode/CoolingBuffer.hpp | ||||
|     ${LIBDIR}/libslic3r/GCode/PostProcessor.cpp | ||||
|     ${LIBDIR}/libslic3r/GCode/PostProcessor.hpp     | ||||
|     ${LIBDIR}/libslic3r/GCode/PressureEqualizer.cpp | ||||
|     ${LIBDIR}/libslic3r/GCode/PressureEqualizer.hpp | ||||
|     ${LIBDIR}/libslic3r/GCode/PreviewData.cpp | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ | |||
| #include <boost/algorithm/string.hpp> | ||||
| #include <boost/algorithm/string/find.hpp> | ||||
| #include <boost/foreach.hpp> | ||||
| #include <boost/filesystem.hpp> | ||||
| #include <boost/log/trivial.hpp> | ||||
| 
 | ||||
| #include <boost/nowide/iostream.hpp> | ||||
|  | @ -418,14 +419,9 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_ | |||
| { | ||||
|     PROFILE_CLEAR(); | ||||
| 
 | ||||
|     if (print->is_step_done(psGCodeExport)) { | ||||
|         // Does the file exist? If so, we hope that it is still valid.
 | ||||
|         FILE *f = boost::nowide::fopen(path, "r"); | ||||
|         if (f != nullptr) { | ||||
|             ::fclose(f); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|     // Does the file exist? If so, we hope that it is still valid.
 | ||||
|     if (print->is_step_done(psGCodeExport) && boost::filesystem::exists(boost::filesystem::path(path))) | ||||
|         return; | ||||
| 
 | ||||
| 	print->set_started(psGCodeExport); | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										55
									
								
								xs/src/libslic3r/GCode/PostProcessor.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								xs/src/libslic3r/GCode/PostProcessor.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,55 @@ | |||
| #include "PostProcessor.hpp" | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| 
 | ||||
| #ifdef WIN32 | ||||
| 
 | ||||
| //FIXME Ignore until we include boost::process
 | ||||
| void run_post_process_scripts(const std::string &path, const PrintConfig &config) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| #include <boost/process/system.hpp> | ||||
| 
 | ||||
| void run_post_process_scripts(const std::string &path, const PrintConfig &config) | ||||
| { | ||||
|     if (config.post_process.values.empty()) | ||||
|         return; | ||||
|     config.setenv_(); | ||||
|     for (std::string script: config.post_process.values) { | ||||
|         // Ignore empty post processing script lines.
 | ||||
|         boost::trim(script); | ||||
|         if (script.empty()) | ||||
|             continue; | ||||
|         BOOST_LOG_TRIVIAL(info) << "Executing script " << script << " on file " << path; | ||||
|         if (! boost::filesystem::exists(boost::filesystem::path(path))) | ||||
|             throw std::runtime_exception(std::string("The configured post-processing script does not exist: ") + path); | ||||
| #ifndef WIN32 | ||||
|         file_status fs = boost::filesystem::status(path); | ||||
|         //FIXME test if executible by the effective UID / GID.
 | ||||
|         // throw std::runtime_exception(std::string("The configured post-processing script is not executable: check permissions. ") + path));
 | ||||
| #endif | ||||
|         int result = 0; | ||||
| #ifdef WIN32 | ||||
|         if (boost::iends_with(file, ".gcode")) { | ||||
|             // The current process may be slic3r.exe or slic3r-console.exe.
 | ||||
|             // Find the path of the process:
 | ||||
|             wchar_t wpath_exe[_MAX_PATH + 1]; | ||||
|             ::GetModuleFileNameW(nullptr, wpath_exe, _MAX_PATH); | ||||
|             boost::filesystem::path path_exe(wpath_exe); | ||||
|             // Replace it with the current perl interpreter.
 | ||||
|             result = boost::process::system((path_exe.parent_path() / "perl5.24.0.exe").string(), script, output_file); | ||||
|         } else | ||||
| #else | ||||
|         result = boost::process::system(script, output_file); | ||||
| #endif | ||||
|         if (result < 0) | ||||
|             BOOST_LOG_TRIVIAL(error) << "Script " << script << " on file " << path << " failed. Negative error code returned."; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| } // namespace Slic3r
 | ||||
							
								
								
									
										15
									
								
								xs/src/libslic3r/GCode/PostProcessor.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								xs/src/libslic3r/GCode/PostProcessor.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| #ifndef slic3r_GCode_PostProcessor_hpp_ | ||||
| #define slic3r_GCode_PostProcessor_hpp_ | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| #include "../libslic3r.h" | ||||
| #include "../PrintConfig.hpp" | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| 
 | ||||
| extern void run_post_process_scripts(const std::string &path, const PrintConfig &config); | ||||
| 
 | ||||
| } // namespace Slic3r
 | ||||
| 
 | ||||
| #endif /* slic3r_GCode_PostProcessor_hpp_ */ | ||||
|  | @ -1331,8 +1331,15 @@ std::string Print::output_filepath(const std::string &path) const | |||
|     return path; | ||||
| } | ||||
| 
 | ||||
| void Print::print_to_png(const std::string &dirpath) | ||||
| void Print::export_png(const std::string &dirpath) | ||||
| { | ||||
|     size_t idx = 0; | ||||
|     for (PrintObject *obj : m_objects) { | ||||
|         obj->slice(); | ||||
|         this->set_status(int(floor(idx * 100. / m_objects.size() + 0.5)), "Slicing..."); | ||||
|         ++ idx; | ||||
|     } | ||||
|     this->set_status(90, "Exporting zipped archive..."); | ||||
|     print_to<FilePrinterFormat::PNG>(*this, | ||||
|         dirpath, | ||||
|         float(m_config.bed_size_x.value), | ||||
|  | @ -1341,6 +1348,7 @@ void Print::print_to_png(const std::string &dirpath) | |||
|         int(m_config.pixel_height.value), | ||||
|         float(m_config.exp_time.value), | ||||
|         float(m_config.exp_time_first.value)); | ||||
|     this->set_status(100, "Done."); | ||||
| } | ||||
| 
 | ||||
| // Returns extruder this eec should be printed with, according to PrintRegion config
 | ||||
|  |  | |||
|  | @ -368,7 +368,7 @@ public: | |||
|     void                process(); | ||||
|     void                export_gcode(const std::string &path_template, GCodePreviewData *preview_data); | ||||
|     // SLA export, temporary.
 | ||||
|     void                print_to_png(const std::string &dirpath); | ||||
|     void                export_png(const std::string &dirpath); | ||||
| 
 | ||||
|     // methods for handling state
 | ||||
|     bool                is_step_done(PrintStep step) const { return m_state.is_done(step); } | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
| 
 | ||||
| // Print now includes tbb, and tbb includes Windows. This breaks compilation of wxWidgets if included before wx.
 | ||||
| #include "../../libslic3r/Print.hpp" | ||||
| #include "../../libslic3r/GCode/PostProcessor.hpp" | ||||
| 
 | ||||
| //#undef NDEBUG
 | ||||
| #include <cassert> | ||||
|  | @ -59,9 +60,12 @@ void BackgroundSlicingProcess::thread_proc() | |||
| 		    if (! m_print->canceled()) { | ||||
| 				wxQueueEvent(GUI::g_wxPlater, new wxCommandEvent(m_event_sliced_id)); | ||||
| 			    m_print->export_gcode(m_temp_output_path, m_gcode_preview_data); | ||||
| 			    if (! m_print->canceled() && ! m_output_path.empty() && | ||||
| 			    	copy_file(m_temp_output_path, m_output_path) != 0) | ||||
| 		    		throw std::runtime_error("Copying of the temporary G-code to the output G-code failed"); | ||||
| 			    if (! m_print->canceled() && ! m_output_path.empty()) { | ||||
| 			    	if (copy_file(m_temp_output_path, m_output_path) != 0) | ||||
| 		    			throw std::runtime_error("Copying of the temporary G-code to the output G-code failed"); | ||||
| 		    		m_print->set_status(95, "Running post-processing scripts"); | ||||
| 		    		run_post_process_scripts(m_output_path, m_print->config()); | ||||
| 		    	} | ||||
| 		    } | ||||
| 		} catch (CanceledException &ex) { | ||||
| 			// Canceled, this is all right.
 | ||||
|  |  | |||
|  | @ -611,13 +611,13 @@ void open_preferences_dialog(int event_preferences) | |||
| 	dlg->ShowModal(); | ||||
| } | ||||
| 
 | ||||
| void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) | ||||
| void create_preset_tabs(int event_value_change, int event_presets_changed) | ||||
| {	 | ||||
| 	update_label_colours_from_appconfig(); | ||||
| 	add_created_tab(new TabPrint	    (g_wxTabPanel, no_controller), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabFilament	    (g_wxTabPanel, no_controller), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabSLAMaterial  (g_wxTabPanel, no_controller), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabPrinter	    (g_wxTabPanel, no_controller), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabPrint	    (g_wxTabPanel), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabFilament	    (g_wxTabPanel), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabSLAMaterial  (g_wxTabPanel), event_value_change, event_presets_changed); | ||||
| 	add_created_tab(new TabPrinter	    (g_wxTabPanel), event_value_change, event_presets_changed); | ||||
| } | ||||
| 
 | ||||
| std::vector<PresetTab> preset_tabs = { | ||||
|  |  | |||
|  | @ -165,7 +165,7 @@ extern void config_wizard(int run_reason); | |||
| extern void open_preferences_dialog(int event_preferences); | ||||
| 
 | ||||
| // Create a new preset tab (print, filament and printer),
 | ||||
| void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed); | ||||
| void create_preset_tabs(int event_value_change, int event_presets_changed); | ||||
| TabIface* get_preset_tab_iface(char *name); | ||||
| 
 | ||||
| // add it at the end of the tab panel.
 | ||||
|  |  | |||
|  | @ -71,14 +71,6 @@ void PreferencesDialog::build() | |||
| 	option = Option (def, "preset_update"); | ||||
| 	m_optgroup->append_single_option_line(option); | ||||
| 
 | ||||
| 	def.label = L("Disable USB/serial connection"); | ||||
| 	def.type = coBool; | ||||
| 	def.tooltip = L("Disable communication with the printer over a serial / USB cable. " | ||||
| 					  "This simplifies the user interface in case the printer is never attached to the computer."); | ||||
| 	def.default_value = new ConfigOptionBool{ app_config->get("no_controller")[0] == '1' }; // 1;
 | ||||
| 	option = Option (def,"no_controller"); | ||||
| 	m_optgroup->append_single_option_line(option); | ||||
| 
 | ||||
| 	def.label = L("Suppress \" - default - \" presets"); | ||||
| 	def.type = coBool; | ||||
| 	def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer " | ||||
|  | @ -118,8 +110,7 @@ void PreferencesDialog::build() | |||
| 
 | ||||
| void PreferencesDialog::accept() | ||||
| { | ||||
| 	if (m_values.find("no_controller")    != m_values.end()|| | ||||
| 		m_values.find("no_defaults")      != m_values.end()|| | ||||
| 	if (m_values.find("no_defaults")      != m_values.end()|| | ||||
| 		m_values.find("use_legacy_opengl")!= m_values.end()) { | ||||
| 		warning_catcher(this, _(L("You need to restart Slic3r to make the changes effective."))); | ||||
| 	} | ||||
|  |  | |||
|  | @ -1528,6 +1528,7 @@ void TabPrinter::build_fff() | |||
| 		}; | ||||
| 
 | ||||
| 
 | ||||
| #if 0 | ||||
| 		if (!m_no_controller) | ||||
| 		{ | ||||
| 		optgroup = page->new_optgroup(_(L("USB/Serial connection"))); | ||||
|  | @ -1572,6 +1573,7 @@ void TabPrinter::build_fff() | |||
| 			line.append_widget(serial_test); | ||||
| 			optgroup->append_line(line); | ||||
| 		} | ||||
| #endif | ||||
| 
 | ||||
| 		optgroup = page->new_optgroup(_(L("Printer Host upload"))); | ||||
| 
 | ||||
|  | @ -1745,8 +1747,10 @@ void TabPrinter::build_fff() | |||
| 
 | ||||
| 	build_extruder_pages(); | ||||
| 
 | ||||
| #if 0 | ||||
| 	if (!m_no_controller) | ||||
| 		update_serial_ports(); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| void TabPrinter::build_sla() | ||||
|  |  | |||
|  | @ -170,7 +170,6 @@ protected: | |||
| 	std::vector<PageShp>			m_pages; | ||||
| 	bool				m_disable_tree_sel_changed_event; | ||||
| 	bool				m_show_incompatible_presets; | ||||
| 	bool				m_no_controller; | ||||
| 
 | ||||
| 	std::vector<std::string>	m_reload_dependent_tabs = {}; | ||||
| 	enum OptStatus { osSystemValue = 1, osInitValue = 2 }; | ||||
|  | @ -199,8 +198,8 @@ public: | |||
| 
 | ||||
| public: | ||||
| 	Tab() {} | ||||
| 	Tab(wxNotebook* parent, const wxString& title, const char* name, bool no_controller) :  | ||||
| 		m_parent(parent), m_title(title), m_name(name), m_no_controller(no_controller) { | ||||
| 	Tab(wxNotebook* parent, const wxString& title, const char* name) :  | ||||
| 		m_parent(parent), m_title(title), m_name(name) { | ||||
| 		Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL, name); | ||||
| 		get_tabs_list().push_back(this); | ||||
| 	} | ||||
|  | @ -282,8 +281,8 @@ class TabPrint : public Tab | |||
| { | ||||
| public: | ||||
| 	TabPrint() {} | ||||
| 	TabPrint(wxNotebook* parent, bool no_controller) :  | ||||
| 		Tab(parent, _(L("Print Settings")), "print", no_controller) {} | ||||
| 	TabPrint(wxNotebook* parent) :  | ||||
| 		Tab(parent, _(L("Print Settings")), "print") {} | ||||
| 	~TabPrint(){} | ||||
| 
 | ||||
| 	ogStaticText*	m_recommended_thin_wall_thickness_description_line; | ||||
|  | @ -302,8 +301,8 @@ class TabFilament : public Tab | |||
| 	ogStaticText*	m_cooling_description_line; | ||||
| public: | ||||
| 	TabFilament() {} | ||||
| 	TabFilament(wxNotebook* parent, bool no_controller) :  | ||||
| 		Tab(parent, _(L("Filament Settings")), "filament", no_controller) {} | ||||
| 	TabFilament(wxNotebook* parent) :  | ||||
| 		Tab(parent, _(L("Filament Settings")), "filament") {} | ||||
| 	~TabFilament(){} | ||||
| 
 | ||||
| 	void		build() override; | ||||
|  | @ -335,7 +334,7 @@ public: | |||
|     PrinterTechnology               m_printer_technology = ptFFF; | ||||
| 
 | ||||
| 	TabPrinter() {} | ||||
| 	TabPrinter(wxNotebook* parent, bool no_controller) : Tab(parent, _(L("Printer Settings")), "printer", no_controller) {} | ||||
| 	TabPrinter(wxNotebook* parent) : Tab(parent, _(L("Printer Settings")), "printer") {} | ||||
| 	~TabPrinter(){} | ||||
| 
 | ||||
| 	void		build() override; | ||||
|  | @ -357,8 +356,8 @@ class TabSLAMaterial : public Tab | |||
| { | ||||
| public: | ||||
|     TabSLAMaterial() {} | ||||
|     TabSLAMaterial(wxNotebook* parent, bool no_controller) : | ||||
| 		Tab(parent, _(L("SLA Material Settings")), "sla_material", no_controller) {} | ||||
|     TabSLAMaterial(wxNotebook* parent) : | ||||
| 		Tab(parent, _(L("SLA Material Settings")), "sla_material") {} | ||||
|     ~TabSLAMaterial(){} | ||||
| 
 | ||||
| 	void		build() override; | ||||
|  |  | |||
|  | @ -50,8 +50,8 @@ void set_plater(SV *ui) | |||
| void add_menus(SV *ui, int event_preferences_changed, int event_language_change)     | ||||
|     %code%{ Slic3r::GUI::add_menus((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_preferences_changed, event_language_change); %}; | ||||
| 
 | ||||
| void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) | ||||
|     %code%{ Slic3r::GUI::create_preset_tabs(no_controller, event_value_change, event_presets_changed); %}; | ||||
| void create_preset_tabs(int event_value_change, int event_presets_changed) | ||||
|     %code%{ Slic3r::GUI::create_preset_tabs(event_value_change, event_presets_changed); %}; | ||||
| 
 | ||||
| void show_error_id(int id, std::string msg) | ||||
|     %code%{ Slic3r::GUI::show_error_id(id, msg); %}; | ||||
|  |  | |||
|  | @ -151,8 +151,6 @@ _constant() | |||
|             } | ||||
|         %}; | ||||
|          | ||||
|     void print_to_png(std::string dirpath); | ||||
|      | ||||
|     void add_model_object(ModelObject* model_object, int idx = -1); | ||||
|     bool apply_config(DynamicPrintConfig* config) | ||||
|         %code%{ RETVAL = THIS->apply_config(*config); %}; | ||||
|  | @ -166,6 +164,7 @@ _constant() | |||
|         %}; | ||||
|     Clone<BoundingBox> bounding_box(); | ||||
|     Clone<BoundingBox> total_bounding_box(); | ||||
|     Clone<Point>       size() %code%{ RETVAL = THIS->bounding_box().size(); %}; | ||||
| 
 | ||||
|     void set_callback_event(int evt) %code%{ | ||||
|         %}; | ||||
|  | @ -196,4 +195,11 @@ _constant() | |||
|             } | ||||
|         %}; | ||||
| 
 | ||||
|     void export_png(char *path) %code%{ | ||||
|             try { | ||||
|                 THIS->export_png(path); | ||||
|             } catch (std::exception& e) { | ||||
|                 croak(e.what()); | ||||
|             } | ||||
|         %}; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv