mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Merge branch 'master' of github.com:prusa3d/Slic3r
This commit is contained in:
		
						commit
						2ef071d1a9
					
				
					 7 changed files with 54 additions and 12 deletions
				
			
		| 
						 | 
					@ -1860,5 +1860,18 @@ int Print::get_extruder(const ExtrusionEntityCollection& fill, const PrintRegion
 | 
				
			||||||
                                    std::max<int>(region.config().perimeter_extruder.value - 1, 0);
 | 
					                                    std::max<int>(region.config().perimeter_extruder.value - 1, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::string Print::output_filename() const 
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					    // Set the placeholders for the data know first after the G-code export is finished.
 | 
				
			||||||
 | 
					    // These values will be just propagated into the output file name.
 | 
				
			||||||
 | 
					    DynamicConfig config;
 | 
				
			||||||
 | 
					    for (const std::string &key : { 
 | 
				
			||||||
 | 
					        "print_time", "normal_print_time", "silent_print_time", 
 | 
				
			||||||
 | 
					        "used_filament", "extruded_volume", "total_cost", "total_weight", 
 | 
				
			||||||
 | 
					        "total_wipe_tower_cost", "total_wipe_tower_filament"})
 | 
				
			||||||
 | 
					        config.set_key_value(key, new ConfigOptionString(std::string("{") + key + "}"));
 | 
				
			||||||
 | 
					    return this->PrintBase::output_filename(m_config.output_filename_format.value, "gcode", &config);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Slic3r
 | 
					} // namespace Slic3r
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -345,8 +345,7 @@ public:
 | 
				
			||||||
    bool                        has_wipe_tower() const;
 | 
					    bool                        has_wipe_tower() const;
 | 
				
			||||||
    const WipeTowerData&        wipe_tower_data() const { return m_wipe_tower_data; }
 | 
					    const WipeTowerData&        wipe_tower_data() const { return m_wipe_tower_data; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::string                 output_filename() const override 
 | 
						std::string                 output_filename() const override;
 | 
				
			||||||
        { return this->PrintBase::output_filename(m_config.output_filename_format.value, "gcode"); }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Accessed by SupportMaterial
 | 
					    // Accessed by SupportMaterial
 | 
				
			||||||
    const PrintRegion*  get_region(size_t idx) const  { return m_regions[idx]; }
 | 
					    const PrintRegion*  get_region(size_t idx) const  { return m_regions[idx]; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,12 +48,14 @@ void PrintBase::update_object_placeholders()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string PrintBase::output_filename(const std::string &format, const std::string &default_ext) const
 | 
					std::string PrintBase::output_filename(const std::string &format, const std::string &default_ext, const DynamicConfig *config_override) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    DynamicConfig cfg_timestamp;
 | 
					    DynamicConfig cfg;
 | 
				
			||||||
    PlaceholderParser::update_timestamp(cfg_timestamp);
 | 
					    if (config_override != nullptr)
 | 
				
			||||||
 | 
					    	cfg = *config_override;
 | 
				
			||||||
 | 
					    PlaceholderParser::update_timestamp(cfg);
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        boost::filesystem::path filename = this->placeholder_parser().process(format, 0, &cfg_timestamp);
 | 
					        boost::filesystem::path filename = this->placeholder_parser().process(format, 0, &cfg);
 | 
				
			||||||
        if (filename.extension().empty())
 | 
					        if (filename.extension().empty())
 | 
				
			||||||
        	filename = boost::filesystem::change_extension(filename, default_ext);
 | 
					        	filename = boost::filesystem::change_extension(filename, default_ext);
 | 
				
			||||||
        return filename.string();
 | 
					        return filename.string();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -307,7 +307,7 @@ protected:
 | 
				
			||||||
    void                   throw_if_canceled() const { if (m_cancel_status) throw CanceledException(); }
 | 
					    void                   throw_if_canceled() const { if (m_cancel_status) throw CanceledException(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // To be called by this->output_filename() with the format string pulled from the configuration layer.
 | 
					    // To be called by this->output_filename() with the format string pulled from the configuration layer.
 | 
				
			||||||
    std::string            output_filename(const std::string &format, const std::string &default_ext) const;
 | 
					    std::string            output_filename(const std::string &format, const std::string &default_ext, const DynamicConfig *config_override = nullptr) const;
 | 
				
			||||||
    // Update "scale", "input_filename", "input_filename_base" placeholders from the current printable ModelObjects.
 | 
					    // Update "scale", "input_filename", "input_filename_base" placeholders from the current printable ModelObjects.
 | 
				
			||||||
    void                   update_object_placeholders();
 | 
					    void                   update_object_placeholders();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <boost/format.hpp>
 | 
					#include <boost/format.hpp>
 | 
				
			||||||
#include <boost/filesystem/path.hpp>
 | 
					#include <boost/filesystem/path.hpp>
 | 
				
			||||||
 | 
					#include <boost/log/trivial.hpp>
 | 
				
			||||||
#include <boost/nowide/cstdio.hpp>
 | 
					#include <boost/nowide/cstdio.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Slic3r {
 | 
					namespace Slic3r {
 | 
				
			||||||
| 
						 | 
					@ -72,11 +73,38 @@ void BackgroundSlicingProcess::process_fff()
 | 
				
			||||||
	if (this->set_step_started(bspsGCodeFinalize)) {
 | 
						if (this->set_step_started(bspsGCodeFinalize)) {
 | 
				
			||||||
	    if (! m_export_path.empty()) {
 | 
						    if (! m_export_path.empty()) {
 | 
				
			||||||
	    	//FIXME localize the messages
 | 
						    	//FIXME localize the messages
 | 
				
			||||||
		    if (copy_file(m_temp_output_path, m_export_path) != 0)
 | 
						    	// Perform the final post-processing of the export path by applying the print statistics over the file name.
 | 
				
			||||||
 | 
						    	std::string export_path;
 | 
				
			||||||
 | 
						    	{
 | 
				
			||||||
 | 
							    	const PrintStatistics &stats = m_fff_print->print_statistics();
 | 
				
			||||||
 | 
							    	PlaceholderParser pp;
 | 
				
			||||||
 | 
							    	std::string normal_print_time = stats.estimated_normal_print_time;
 | 
				
			||||||
 | 
							    	std::string silent_print_time = stats.estimated_silent_print_time;
 | 
				
			||||||
 | 
									normal_print_time.erase(std::remove_if(normal_print_time.begin(), normal_print_time.end(), std::isspace), normal_print_time.end());
 | 
				
			||||||
 | 
									silent_print_time.erase(std::remove_if(silent_print_time.begin(), silent_print_time.end(), std::isspace), silent_print_time.end());
 | 
				
			||||||
 | 
							    	pp.set("print_time",        		new ConfigOptionString(normal_print_time));
 | 
				
			||||||
 | 
							    	pp.set("normal_print_time", 		new ConfigOptionString(normal_print_time));
 | 
				
			||||||
 | 
							    	pp.set("silent_print_time", 		new ConfigOptionString(silent_print_time));
 | 
				
			||||||
 | 
							    	pp.set("used_filament",     		new ConfigOptionFloat (stats.total_used_filament));
 | 
				
			||||||
 | 
									pp.set("extruded_volume",     		new ConfigOptionFloat (stats.total_extruded_volume));
 | 
				
			||||||
 | 
									pp.set("total_cost",     			new ConfigOptionFloat (stats.total_cost));
 | 
				
			||||||
 | 
									pp.set("total_weight",    			new ConfigOptionFloat (stats.total_weight));
 | 
				
			||||||
 | 
									pp.set("total_wipe_tower_cost",     new ConfigOptionFloat (stats.total_wipe_tower_cost));
 | 
				
			||||||
 | 
									pp.set("total_wipe_tower_filament", new ConfigOptionFloat (stats.total_wipe_tower_filament));
 | 
				
			||||||
 | 
						    		boost::filesystem::path path(m_export_path);
 | 
				
			||||||
 | 
									try {
 | 
				
			||||||
 | 
										std::string new_stem = pp.process(path.stem().string(), 0);
 | 
				
			||||||
 | 
										export_path = (path.parent_path() / (new_stem + path.extension().string())).string();
 | 
				
			||||||
 | 
									} catch (const std::exception &ex) {
 | 
				
			||||||
 | 
					    				BOOST_LOG_TRIVIAL(error) << "Failed to apply the print statistics to the export file name: " << ex.what();
 | 
				
			||||||
 | 
										export_path = m_export_path;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							    if (copy_file(m_temp_output_path, export_path) != 0)
 | 
				
			||||||
	    		throw std::runtime_error("Copying of the temporary G-code to the output G-code failed");
 | 
						    		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");
 | 
						    	m_print->set_status(95, "Running post-processing scripts");
 | 
				
			||||||
	    	run_post_process_scripts(m_export_path, m_fff_print->config());
 | 
						    	run_post_process_scripts(export_path, m_fff_print->config());
 | 
				
			||||||
	    	m_print->set_status(100, "G-code file exported to " + m_export_path);
 | 
						    	m_print->set_status(100, "G-code file exported to " + export_path);
 | 
				
			||||||
	    } else {
 | 
						    } else {
 | 
				
			||||||
	    	m_print->set_status(100, "Slicing complete");
 | 
						    	m_print->set_status(100, "Slicing complete");
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -581,7 +581,7 @@ void GLCanvas3D::Bed::_render_custom() const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ::glEnableClientState(GL_VERTEX_ARRAY);
 | 
					        ::glEnableClientState(GL_VERTEX_ARRAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ::glColor4f(0.8f, 0.6f, 0.5f, 0.4f);
 | 
					        ::glColor4f(0.35f, 0.35f, 0.35f, 0.4f);
 | 
				
			||||||
        ::glNormal3d(0.0f, 0.0f, 1.0f);
 | 
					        ::glNormal3d(0.0f, 0.0f, 1.0f);
 | 
				
			||||||
        ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_triangles.get_vertices());
 | 
					        ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_triangles.get_vertices());
 | 
				
			||||||
        ::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount);
 | 
					        ::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -147,7 +147,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
 | 
				
			||||||
			config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
 | 
								config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case coStrings:{
 | 
							case coStrings:{
 | 
				
			||||||
			if (opt_key == "compatible_prints" || opt_key == "compatible_printers") {
 | 
								if (opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "post_process") {
 | 
				
			||||||
				config.option<ConfigOptionStrings>(opt_key)->values = 
 | 
									config.option<ConfigOptionStrings>(opt_key)->values = 
 | 
				
			||||||
					boost::any_cast<std::vector<std::string>>(value);
 | 
										boost::any_cast<std::vector<std::string>>(value);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue