Apply printer model / variant preferences when loading presets

This commit is contained in:
Vojtech Kral 2018-03-29 17:54:43 +02:00
parent 57e47a3296
commit e53949f2c8
17 changed files with 218 additions and 64 deletions

View file

@ -4,6 +4,7 @@
#include "PresetBundle.hpp"
#include "BitmapCache.hpp"
#include <iostream> // XXX
#include <algorithm>
#include <fstream>
#include <boost/filesystem.hpp>
@ -105,7 +106,7 @@ void PresetBundle::setup_directories()
std::initializer_list<boost::filesystem::path> paths = {
data_dir,
data_dir / "vendor",
data_dir / "cache",
data_dir / "cache", // TODO: rename as vendor-cache? (Check usage elsewhere!)
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
// Store the print/filament/printer presets into a "presets" directory.
data_dir / "presets",
@ -200,8 +201,12 @@ static inline std::string remove_ini_suffix(const std::string &name)
// If the "vendor" section is missing, enable all models and variants of the particular vendor.
void PresetBundle::load_installed_printers(const AppConfig &config)
{
// TODO
// m_storage
std::cerr << "load_installed_printers()" << std::endl;
for (auto &preset : printers) {
std::cerr << "preset: printer: " << preset.name << std::endl;
preset.set_visible_from_appconfig(config);
}
}
// Load selections (current print, current filaments, current printer) from config.ini
@ -221,6 +226,10 @@ void PresetBundle::load_selections(const AppConfig &config)
break;
this->set_filament_preset(i, remove_ini_suffix(config.get("presets", name)));
}
// Update visibility of presets based on application vendor / model / variant configuration.
this->load_installed_printers(config);
// Update visibility of presets based on their compatibility with the active printer.
// Always try to select a compatible print and filament preset to the current printer preset,
// as the application may have been closed with an active "external" preset, which does not
@ -708,6 +717,11 @@ static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorP
void PresetBundle::install_vendor_configbundle(const std::string &src_path0)
{
boost::filesystem::path src_path(src_path0);
install_vendor_configbundle(src_path);
}
void PresetBundle::install_vendor_configbundle(const boost::filesystem::path &src_path)
{
boost::filesystem::copy_file(src_path, (boost::filesystem::path(data_dir()) / "vendor" / src_path.filename()).make_preferred(), boost::filesystem::copy_option::overwrite_if_exists);
}