Reverted the introduction of the "presets" subdir to store

the print/filament/printer profiles.
The change has been reverted to support the upstream slic3r
using the --datadir. While there are breaking changes
in the PlaceholderParser, if the new macro processing is not used,
the two slic3rs are still mostly interchangeable.

The "presets" subdir may be enabled with the SLIC3R_PROFILE_USE_PRESETS_SUBDIR
and it may happen, that it will be activated one day if ever the two
slci3rs diverge too much.
This commit is contained in:
bubnikv 2017-12-14 09:40:45 +01:00
parent 08b74f8caf
commit d30c154e79

View file

@ -25,6 +25,10 @@
#include "../../libslic3r/PlaceholderParser.hpp"
#include "../../libslic3r/Utils.hpp"
// Store the print/filament/printer presets into a "presets" subdirectory of the Slic3rPE config dir.
// This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions.
// #define SLIC3R_PROFILE_USE_PRESETS_SUBDIR
namespace Slic3r {
PresetBundle::PresetBundle() :
@ -68,10 +72,19 @@ void PresetBundle::setup_directories()
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
std::initializer_list<boost::filesystem::path> paths = {
data_dir,
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
// Store the print/filament/printer presets into a "presets" directory.
data_dir / "presets",
data_dir / "presets" / "print",
data_dir / "presets" / "filament",
data_dir / "presets" / "printer" };
data_dir / "presets" / "printer"
#else
// Store the print/filament/printer presets at the same location as the upstream Slic3r.
data_dir / "print",
data_dir / "filament",
data_dir / "printer"
#endif
};
for (const boost::filesystem::path &path : paths) {
boost::filesystem::path subdir = path;
subdir.make_preferred();
@ -84,7 +97,14 @@ void PresetBundle::setup_directories()
void PresetBundle::load_presets()
{
std::string errors_cummulative;
const std::string dir_path = data_dir() + "/presets";
const std::string dir_path = data_dir()
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
// Store the print/filament/printer presets into a "presets" directory.
+ "/presets"
#else
// Store the print/filament/printer presets at the same location as the upstream Slic3r.
#endif
;
try {
this->prints.load_presets(dir_path, "print");
} catch (const std::runtime_error &err) {
@ -473,7 +493,14 @@ size_t PresetBundle::load_configbundle(const std::string &path)
Preset::normalize(config);
// Decide a full path to this .ini file.
auto file_name = boost::algorithm::iends_with(preset_name, ".ini") ? preset_name : preset_name + ".ini";
auto file_path = (boost::filesystem::path(data_dir()) / "presets" / presets->name() / file_name).make_preferred();
auto file_path = (boost::filesystem::path(data_dir())
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
// Store the print/filament/printer presets into a "presets" directory.
/ "presets"
#else
// Store the print/filament/printer presets at the same location as the upstream Slic3r.
#endif
/ presets->name() / file_name).make_preferred();
// Load the preset into the list of presets, save it to disk.
presets->load_preset(file_path.string(), preset_name, std::move(config), false).save();
++ presets_loaded;