mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
Moved the Slic3rPE/print,filament,printer folders to
Slic3rPE/presets/print,filament,printer to separate the presets from further data stored into the Slic3rPE directory.
This commit is contained in:
parent
ca4bd96d5d
commit
679aa2822c
8 changed files with 21 additions and 41 deletions
|
@ -100,16 +100,12 @@ sub OnInit {
|
||||||
|
|
||||||
# Suppress the '- default -' presets.
|
# Suppress the '- default -' presets.
|
||||||
$self->{preset_bundle}->set_default_suppressed($self->{app_config}->get('no_defaults') ? 1 : 0);
|
$self->{preset_bundle}->set_default_suppressed($self->{app_config}->get('no_defaults') ? 1 : 0);
|
||||||
eval {
|
eval { $self->{preset_bundle}->load_presets };
|
||||||
$self->{preset_bundle}->load_presets(Slic3r::data_dir);
|
|
||||||
};
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
warn $@ . "\n";
|
warn $@ . "\n";
|
||||||
show_error(undef, $@);
|
show_error(undef, $@);
|
||||||
}
|
}
|
||||||
eval {
|
eval { $self->{preset_bundle}->load_selections($self->{app_config}) };
|
||||||
$self->{preset_bundle}->load_selections($self->{app_config});
|
|
||||||
};
|
|
||||||
$run_wizard = 1 if $self->{preset_bundle}->has_defauls_only;
|
$run_wizard = 1 if $self->{preset_bundle}->has_defauls_only;
|
||||||
|
|
||||||
# application frame
|
# application frame
|
||||||
|
|
|
@ -147,7 +147,7 @@ sub save_preset {
|
||||||
return unless $dlg->ShowModal == wxID_OK;
|
return unless $dlg->ShowModal == wxID_OK;
|
||||||
$name = $dlg->get_name;
|
$name = $dlg->get_name;
|
||||||
}
|
}
|
||||||
# Save the preset into Slic3r::data_dir/section_name/preset_name.ini
|
# Save the preset into Slic3r::data_dir/presets/section_name/preset_name.ini
|
||||||
eval { $self->{presets}->save_current_preset($name); };
|
eval { $self->{presets}->save_current_preset($name); };
|
||||||
Slic3r::GUI::catch_error($self) and return;
|
Slic3r::GUI::catch_error($self) and return;
|
||||||
# Add the new item into the UI component, remove dirty flags and activate the saved item.
|
# Add the new item into the UI component, remove dirty flags and activate the saved item.
|
||||||
|
|
|
@ -24,11 +24,6 @@ const std::string& resources_dir();
|
||||||
void set_data_dir(const std::string &path);
|
void set_data_dir(const std::string &path);
|
||||||
// Return a full path to the GUI resource files.
|
// Return a full path to the GUI resource files.
|
||||||
const std::string& data_dir();
|
const std::string& data_dir();
|
||||||
// Return a full path to a configuration file given its file name..
|
|
||||||
std::string config_path(const std::string &file_name);
|
|
||||||
// Return a full path to a configuration file given the section and name.
|
|
||||||
// The suffix ".ini" will be added if it is missing in the name.
|
|
||||||
std::string config_path(const std::string §ion, const std::string &name);
|
|
||||||
|
|
||||||
extern std::string encode_path(const char *src);
|
extern std::string encode_path(const char *src);
|
||||||
extern std::string decode_path(const char *src);
|
extern std::string decode_path(const char *src);
|
||||||
|
|
|
@ -113,19 +113,6 @@ const std::string& data_dir()
|
||||||
return g_data_dir;
|
return g_data_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string config_path(const std::string &file_name)
|
|
||||||
{
|
|
||||||
auto file = (boost::filesystem::path(g_data_dir) / file_name).make_preferred();
|
|
||||||
return file.string();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string config_path(const std::string §ion, const std::string &name)
|
|
||||||
{
|
|
||||||
auto file_name = boost::algorithm::iends_with(name, ".ini") ? name : name + ".ini";
|
|
||||||
auto file = (boost::filesystem::path(g_data_dir) / section / file_name).make_preferred();
|
|
||||||
return file.string();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
#ifdef SLIC3R_HAS_BROKEN_CROAK
|
#ifdef SLIC3R_HAS_BROKEN_CROAK
|
||||||
|
|
|
@ -66,7 +66,12 @@ PresetBundle::~PresetBundle()
|
||||||
void PresetBundle::setup_directories()
|
void PresetBundle::setup_directories()
|
||||||
{
|
{
|
||||||
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
|
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
|
||||||
std::initializer_list<boost::filesystem::path> paths = { data_dir, data_dir / "print", data_dir / "filament", data_dir / "printer" };
|
std::initializer_list<boost::filesystem::path> paths = {
|
||||||
|
data_dir,
|
||||||
|
data_dir / "presets",
|
||||||
|
data_dir / "presets" / "print",
|
||||||
|
data_dir / "presets" / "filament",
|
||||||
|
data_dir / "presets" / "printer" };
|
||||||
for (const boost::filesystem::path &path : paths) {
|
for (const boost::filesystem::path &path : paths) {
|
||||||
boost::filesystem::path subdir = path;
|
boost::filesystem::path subdir = path;
|
||||||
subdir.make_preferred();
|
subdir.make_preferred();
|
||||||
|
@ -76,9 +81,10 @@ void PresetBundle::setup_directories()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetBundle::load_presets(const std::string &dir_path)
|
void PresetBundle::load_presets()
|
||||||
{
|
{
|
||||||
std::string errors_cummulative;
|
std::string errors_cummulative;
|
||||||
|
const std::string dir_path = data_dir() + "/presets";
|
||||||
try {
|
try {
|
||||||
this->prints.load_presets(dir_path, "print");
|
this->prints.load_presets(dir_path, "print");
|
||||||
} catch (const std::runtime_error &err) {
|
} catch (const std::runtime_error &err) {
|
||||||
|
@ -465,8 +471,11 @@ size_t PresetBundle::load_configbundle(const std::string &path)
|
||||||
for (auto &kvp : section.second)
|
for (auto &kvp : section.second)
|
||||||
config.set_deserialize(kvp.first, kvp.second.data());
|
config.set_deserialize(kvp.first, kvp.second.data());
|
||||||
Preset::normalize(config);
|
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();
|
||||||
// Load the preset into the list of presets, save it to disk.
|
// Load the preset into the list of presets, save it to disk.
|
||||||
presets->load_preset(Slic3r::config_path(presets->name(), preset_name), preset_name, std::move(config), false).save();
|
presets->load_preset(file_path.string(), preset_name, std::move(config), false).save();
|
||||||
++ presets_loaded;
|
++ presets_loaded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ public:
|
||||||
|
|
||||||
void setup_directories();
|
void setup_directories();
|
||||||
|
|
||||||
// Load ini files of all types (print, filament, printer) from the provided directory path.
|
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
||||||
void load_presets(const std::string &dir_path);
|
void load_presets();
|
||||||
|
|
||||||
// Load selections (current print, current filaments, current printer) from config.ini
|
// Load selections (current print, current filaments, current printer) from config.ini
|
||||||
// This is done just once on application start up.
|
// This is done just once on application start up.
|
||||||
|
|
|
@ -106,12 +106,13 @@ PresetCollection::arrayref()
|
||||||
croak("Cannot create configuration directories:\n%s\n", e.what());
|
croak("Cannot create configuration directories:\n%s\n", e.what());
|
||||||
}
|
}
|
||||||
%};
|
%};
|
||||||
void load_presets(const char *dir_path)
|
void load_presets()
|
||||||
%code%{
|
%code%{
|
||||||
try {
|
try {
|
||||||
THIS->load_presets(dir_path);
|
THIS->load_presets();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
croak("Loading of Slic3r presets from %s failed.\n\n%s\n", dir_path, e.what());
|
croak("Loading of Slic3r presets from %s failed.\n\n%s\n",
|
||||||
|
Slic3r::data_dir().c_str(), e.what());
|
||||||
}
|
}
|
||||||
%};
|
%};
|
||||||
void load_config_file(const char *path)
|
void load_config_file(const char *path)
|
||||||
|
|
|
@ -91,14 +91,6 @@ data_dir()
|
||||||
RETVAL = const_cast<char*>(Slic3r::data_dir().c_str());
|
RETVAL = const_cast<char*>(Slic3r::data_dir().c_str());
|
||||||
OUTPUT: RETVAL
|
OUTPUT: RETVAL
|
||||||
|
|
||||||
std::string
|
|
||||||
config_path(section, name)
|
|
||||||
const char *section;
|
|
||||||
const char *name;
|
|
||||||
CODE:
|
|
||||||
RETVAL = Slic3r::config_path(section, name);
|
|
||||||
OUTPUT: RETVAL
|
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
encode_path(src)
|
encode_path(src)
|
||||||
const char *src;
|
const char *src;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue