WIP: Time estimate in file names.

This commit is contained in:
bubnikv 2018-12-12 12:00:45 +01:00
parent 2b9f52c33c
commit c0ebcacf1d
6 changed files with 53 additions and 11 deletions

View file

@ -1860,5 +1860,18 @@ int Print::get_extruder(const ExtrusionEntityCollection& fill, const PrintRegion
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

View file

@ -345,8 +345,7 @@ public:
bool has_wipe_tower() const;
const WipeTowerData& wipe_tower_data() const { return m_wipe_tower_data; }
std::string output_filename() const override
{ return this->PrintBase::output_filename(m_config.output_filename_format.value, "gcode"); }
std::string output_filename() const override;
// Accessed by SupportMaterial
const PrintRegion* get_region(size_t idx) const { return m_regions[idx]; }

View file

@ -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;
PlaceholderParser::update_timestamp(cfg_timestamp);
DynamicConfig cfg;
if (config_override != nullptr)
cfg = *config_override;
PlaceholderParser::update_timestamp(cfg);
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())
filename = boost::filesystem::change_extension(filename, default_ext);
return filename.string();

View file

@ -307,7 +307,7 @@ protected:
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.
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.
void update_object_placeholders();