mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-18 22:31:13 -06:00
ENH: remember the filament_opts and limit minimum flushing volumes
Change-Id: I7b2538fcaf5b5fc5e4f86191207de981bd766a89 (cherry picked from commit 392be8d2a4e9465fffc4018da77c6ee00ad46ade)
This commit is contained in:
parent
eb80720e75
commit
13df80ffb7
8 changed files with 99 additions and 3 deletions
|
@ -482,7 +482,14 @@ std::string AppConfig::load()
|
|||
} else {
|
||||
m_storage[it.key()][iter.key()] = "false";
|
||||
}
|
||||
} else {
|
||||
} else if (iter.key() == "filament_presets") {
|
||||
m_filament_presets = iter.value().get<std::vector<std::string>>();
|
||||
} else if (iter.key() == "filament_colors") {
|
||||
m_filament_colors = iter.value().get<std::vector<std::string>>();
|
||||
} else if (iter.key() == "flushing_volumes") {
|
||||
m_flush_volumes_matrix = iter.value().get<std::vector<float>>();
|
||||
}
|
||||
else {
|
||||
if (iter.value().is_string())
|
||||
m_storage[it.key()][iter.key()] = iter.value().get<std::string>();
|
||||
else {
|
||||
|
@ -565,6 +572,18 @@ void AppConfig::save()
|
|||
j["app"][kvp.first] = kvp.second;
|
||||
}
|
||||
|
||||
for (const auto &filament_preset : m_filament_presets) {
|
||||
j["app"]["filament_presets"].push_back(filament_preset);
|
||||
}
|
||||
|
||||
for (const auto &filament_color : m_filament_colors) {
|
||||
j["app"]["filament_colors"].push_back(filament_color);
|
||||
}
|
||||
|
||||
for (double flushing_volume : m_flush_volumes_matrix) {
|
||||
j["app"]["flushing_volumes"].push_back(flushing_volume);
|
||||
}
|
||||
|
||||
// Write the other categories.
|
||||
for (const auto& category : m_storage) {
|
||||
if (category.first.empty())
|
||||
|
|
|
@ -164,6 +164,22 @@ public:
|
|||
void set_vendors(VendorMap &&vendors) { m_vendors = std::move(vendors); m_dirty = true; }
|
||||
const VendorMap& vendors() const { return m_vendors; }
|
||||
|
||||
const std::vector<std::string> &get_filament_presets() const { return m_filament_presets; }
|
||||
void set_filament_presets(const std::vector<std::string> &filament_presets){
|
||||
m_filament_presets = filament_presets;
|
||||
m_dirty = true;
|
||||
}
|
||||
const std::vector<std::string> &get_filament_colors() const { return m_filament_colors; }
|
||||
void set_filament_colors(const std::vector<std::string> &filament_colors){
|
||||
m_filament_colors = filament_colors;
|
||||
m_dirty = true;
|
||||
}
|
||||
const std::vector<float> &get_flush_volumes_matrix() const { return m_flush_volumes_matrix; }
|
||||
void set_flush_volumes_matrix(const std::vector<float> &flush_volumes_matrix){
|
||||
m_flush_volumes_matrix = flush_volumes_matrix;
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
// return recent/last_opened_folder or recent/settings_folder or empty string.
|
||||
std::string get_last_dir() const;
|
||||
void update_config_dir(const std::string &dir);
|
||||
|
@ -259,6 +275,10 @@ private:
|
|||
bool m_legacy_datadir;
|
||||
|
||||
std::string m_loading_path;
|
||||
|
||||
std::vector<std::string> m_filament_presets;
|
||||
std::vector<std::string> m_filament_colors;
|
||||
std::vector<float> m_flush_volumes_matrix;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -809,6 +809,36 @@ void PresetBundle::update_system_preset_setting_ids(std::map<std::string, std::m
|
|||
return;
|
||||
}
|
||||
|
||||
void PresetBundle::load_default_setting_from_app_config(const AppConfig &config) {
|
||||
auto config_filament_presets = config.get_filament_presets();
|
||||
if (!config_filament_presets.empty())
|
||||
this->filament_presets = config_filament_presets;
|
||||
|
||||
auto config_filament_colors = config.get_filament_colors();
|
||||
if (!config_filament_colors.empty()) {
|
||||
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
|
||||
filament_color->resize(config_filament_colors.size());
|
||||
filament_color->values = config_filament_colors;
|
||||
}
|
||||
|
||||
auto config_flush_volumes_matrix = config.get_flush_volumes_matrix();
|
||||
if (!config_flush_volumes_matrix.empty()) {
|
||||
ConfigOptionFloats *flush_volumes_matrix = project_config.option<ConfigOptionFloats>("flush_volumes_matrix");
|
||||
flush_volumes_matrix->values = std::vector<double>(config_flush_volumes_matrix.begin(), config_flush_volumes_matrix.end());
|
||||
}
|
||||
}
|
||||
|
||||
void PresetBundle::update_filament_info_to_app_config(AppConfig &config)
|
||||
{
|
||||
config.set_filament_presets(this->filament_presets);
|
||||
|
||||
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
|
||||
config.set_filament_colors(filament_color->values);
|
||||
|
||||
ConfigOptionFloats *flush_volumes_matrix = project_config.option<ConfigOptionFloats>("flush_volumes_matrix");
|
||||
config.set_flush_volumes_matrix(std::vector<float>(flush_volumes_matrix->values.begin(), flush_volumes_matrix->values.end()));
|
||||
}
|
||||
|
||||
//BBS: validate printers from previous project
|
||||
bool PresetBundle::validate_printers(const std::string &name, DynamicPrintConfig& config)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,8 @@ public:
|
|||
void update_user_presets_directory(const std::string preset_folder);
|
||||
void remove_user_presets_directory(const std::string preset_folder);
|
||||
void update_system_preset_setting_ids(std::map<std::string, std::map<std::string, std::string>>& system_presets);
|
||||
void load_default_setting_from_app_config(const AppConfig &config);
|
||||
void update_filament_info_to_app_config(AppConfig &config);
|
||||
|
||||
//BBS: add API to get previous machine
|
||||
bool validate_printers(const std::string &name, DynamicPrintConfig& config);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue