2017-10-30 17:41:50 +00:00
|
|
|
#ifndef slic3r_PresetBundle_hpp_
|
|
|
|
#define slic3r_PresetBundle_hpp_
|
|
|
|
|
|
|
|
#include "Preset.hpp"
|
2020-08-08 15:03:20 +00:00
|
|
|
#include "AppConfig.hpp"
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2019-06-17 14:39:22 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <unordered_map>
|
2018-03-29 15:54:43 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
2018-03-09 15:37:33 +00:00
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
// Bundle of Print + Filament + Printer presets.
|
|
|
|
class PresetBundle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PresetBundle();
|
2021-02-04 08:42:32 +00:00
|
|
|
PresetBundle(const PresetBundle &rhs);
|
|
|
|
PresetBundle& operator=(const PresetBundle &rhs);
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2017-12-19 18:51:22 +00:00
|
|
|
// Remove all the presets but the "-- default --".
|
|
|
|
// Optionally remove all the files referenced by the presets from the user profile directory.
|
|
|
|
void reset(bool delete_files);
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
void setup_directories();
|
|
|
|
|
2017-12-10 21:11:00 +00:00
|
|
|
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
2017-10-30 17:41:50 +00:00
|
|
|
// Load selections (current print, current filaments, current printer) from config.ini
|
2021-02-08 14:56:32 +00:00
|
|
|
void load_presets(AppConfig &config, const std::string &preferred_model_id = std::string());
|
2018-03-09 15:37:33 +00:00
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
// Export selections (current print, current filaments, current printer) into config.ini
|
|
|
|
void export_selections(AppConfig &config);
|
|
|
|
|
|
|
|
PresetCollection prints;
|
2018-11-16 16:36:23 +00:00
|
|
|
PresetCollection sla_prints;
|
2017-10-30 17:41:50 +00:00
|
|
|
PresetCollection filaments;
|
2018-07-31 13:09:57 +00:00
|
|
|
PresetCollection sla_materials;
|
2020-03-14 17:35:42 +00:00
|
|
|
PresetCollection& materials(PrinterTechnology pt) { return pt == ptFFF ? this->filaments : this->sla_materials; }
|
|
|
|
const PresetCollection& materials(PrinterTechnology pt) const { return pt == ptFFF ? this->filaments : this->sla_materials; }
|
2018-10-31 15:22:36 +00:00
|
|
|
PrinterPresetCollection printers;
|
2020-06-24 06:50:01 +00:00
|
|
|
PhysicalPrinterCollection physical_printers;
|
2017-10-30 17:41:50 +00:00
|
|
|
// Filament preset names for a multi-extruder or multi-material print.
|
|
|
|
// extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size()
|
|
|
|
std::vector<std::string> filament_presets;
|
|
|
|
|
2018-03-14 10:54:11 +00:00
|
|
|
// The project configuration values are kept separated from the print/filament/printer preset,
|
|
|
|
// they are being serialized / deserialized from / to the .amf, .3mf, .config, .gcode,
|
|
|
|
// and they are being used by slicing core.
|
|
|
|
DynamicPrintConfig project_config;
|
|
|
|
|
2018-03-09 15:37:33 +00:00
|
|
|
// There will be an entry for each system profile loaded,
|
|
|
|
// and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors.
|
2020-01-24 14:16:28 +00:00
|
|
|
VendorMap vendors;
|
2018-03-09 15:37:33 +00:00
|
|
|
|
2018-05-16 14:34:07 +00:00
|
|
|
struct ObsoletePresets {
|
|
|
|
std::vector<std::string> prints;
|
2018-11-16 16:36:23 +00:00
|
|
|
std::vector<std::string> sla_prints;
|
2018-05-16 14:34:07 +00:00
|
|
|
std::vector<std::string> filaments;
|
2018-07-31 13:09:57 +00:00
|
|
|
std::vector<std::string> sla_materials;
|
2018-05-16 14:34:07 +00:00
|
|
|
std::vector<std::string> printers;
|
|
|
|
};
|
|
|
|
ObsoletePresets obsolete_presets;
|
|
|
|
|
2017-11-02 15:21:34 +00:00
|
|
|
bool has_defauls_only() const
|
2018-08-01 09:09:51 +00:00
|
|
|
{ return prints.has_defaults_only() && filaments.has_defaults_only() && printers.has_defaults_only(); }
|
2017-11-02 15:21:34 +00:00
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
DynamicPrintConfig full_config() const;
|
2018-12-06 13:42:15 +00:00
|
|
|
// full_config() with the "printhost_apikey" and "printhost_cafile" removed.
|
|
|
|
DynamicPrintConfig full_config_secure() const;
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2017-12-20 10:28:16 +00:00
|
|
|
// Load user configuration and store it into the user profiles.
|
|
|
|
// This method is called by the configuration wizard.
|
1) Storing the physical_printer_settings_id into the 3MF, AMF, GCode.
2) Activating the physical_printer_settings_id when loading from 3MF, AMF, GCode.
The physical printer is only activated if it references the printer_settings_id
loaded from the same file.
3) When loading the presets from 3MF, AMF, GCode, the "external" profiles
are no more created for profiles which differ from the local profiles
the loaded profiles reference. Instead, the referenced profile is activated
and modified with the loaded preset. If the referenced profile does not
exist, but the profile refers to a system profile with the "inherits"
fileds, the system profile is loaded and modified instead.
This works for all profiles with the exception of multi-extruder
printer with multiple filament profiles modified. In that case
the first modified filament profile will be loaded as modified,
while the other modified profiles will be loaded as "external".
This should fix
Physical printer + 3mf file, wrong preset used to generate gcode #5178
and possibly
https://github.com/prusa3d/PrusaSlicer/issues/5272
2020-12-04 09:48:44 +00:00
|
|
|
void load_config_from_wizard(const std::string &name, DynamicPrintConfig config)
|
2017-12-20 10:28:16 +00:00
|
|
|
{ this->load_config_file_config(name, false, std::move(config)); }
|
|
|
|
|
2018-09-17 10:15:11 +00:00
|
|
|
// Load configuration that comes from a model file containing configuration, such as 3MF et al.
|
|
|
|
// This method is called by the Plater.
|
|
|
|
void load_config_model(const std::string &name, DynamicPrintConfig config)
|
|
|
|
{ this->load_config_file_config(name, true, std::move(config)); }
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
// Load an external config file containing the print, filament and printer presets.
|
|
|
|
// Instead of a config file, a G-code may be loaded containing the full set of parameters.
|
|
|
|
// In the future the configuration will likely be read from an AMF file as well.
|
|
|
|
// If the file is loaded successfully, its print / filament / printer profiles will be activated.
|
|
|
|
void load_config_file(const std::string &path);
|
|
|
|
|
|
|
|
// Load a config bundle file, into presets and store the loaded presets into separate files
|
|
|
|
// of the local configuration directory.
|
|
|
|
// Load settings into the provided settings instance.
|
|
|
|
// Activate the presets stored in the config bundle.
|
|
|
|
// Returns the number of presets loaded successfully.
|
2017-12-19 18:51:22 +00:00
|
|
|
enum {
|
|
|
|
// Save the profiles, which have been loaded.
|
|
|
|
LOAD_CFGBNDLE_SAVE = 1,
|
|
|
|
// Delete all old config profiles before loading.
|
2018-03-09 15:37:33 +00:00
|
|
|
LOAD_CFGBNDLE_RESET_USER_PROFILE = 2,
|
|
|
|
// Load a system config bundle.
|
|
|
|
LOAD_CFGBNDLE_SYSTEM = 4,
|
2018-03-13 11:39:57 +00:00
|
|
|
LOAD_CFGBUNDLE_VENDOR_ONLY = 8,
|
2017-12-19 18:51:22 +00:00
|
|
|
};
|
|
|
|
// Load the config bundle, store it to the user profile directory by default.
|
|
|
|
size_t load_configbundle(const std::string &path, unsigned int flags = LOAD_CFGBNDLE_SAVE);
|
2017-10-30 17:41:50 +00:00
|
|
|
|
|
|
|
// Export a config bundle file containing all the presets and the names of the active presets.
|
2020-10-01 20:48:00 +00:00
|
|
|
void export_configbundle(const std::string &path, bool export_system_settings = false, bool export_physical_printers = false);
|
2017-10-30 17:41:50 +00:00
|
|
|
|
|
|
|
// Enable / disable the "- default -" preset.
|
|
|
|
void set_default_suppressed(bool default_suppressed);
|
|
|
|
|
|
|
|
// Set the filament preset name. As the name could come from the UI selection box,
|
|
|
|
// an optional "(modified)" suffix will be removed from the filament name.
|
|
|
|
void set_filament_preset(size_t idx, const std::string &name);
|
|
|
|
|
|
|
|
// Read out the number of extruders from an active printer preset,
|
|
|
|
// update size and content of filament_presets.
|
|
|
|
void update_multi_material_filament_presets();
|
|
|
|
|
2017-11-10 16:27:05 +00:00
|
|
|
// Update the is_compatible flag of all print and filament presets depending on whether they are marked
|
2018-12-04 16:56:49 +00:00
|
|
|
// as compatible with the currently selected printer (and print in case of filament presets).
|
2017-11-10 16:27:05 +00:00
|
|
|
// Also updates the is_visible flag of each preset.
|
|
|
|
// If select_other_if_incompatible is true, then the print or filament preset is switched to some compatible
|
|
|
|
// preset if the current print or filament preset is not compatible.
|
Various changes in handling of profile compatiblilities
and the "show incompatible profiles" option.
It was not able to select the incompatible Print profile, which is
possible now.
(see Cannot select incompatible printer profile #3715)
When the Printer profile derived from the Prusa3D system profile was
active or a system Prusa3D profile was active, and when the Print profile
with the removed "inherits" field was active (or any other profile
derived from the "-- default --" profile was active), then the filament
selector offered just the profiles with the removed "inherits" field
(or any other profile derived from the "-- default--") profile.
This behavior has been now changed, so that in this scenario the Filament selector
will offer the Prusa3D vendor profiles compatible with the active Print
and Printer profile as well as the user profiles.
Slicer was also changed to keep an incompatible preset selected
at its respective tab if its respective "Red flag" is enabled.
For example, if an incompatible Print preset is selected and a Printer
profile is switched to another one which is not compatible with the active
Print preset that was red already, the active Print preset is
not switched if the Print "Red flag" is active. However, if the Print profile
was compatible before the Printer profile is switched and now the Print
profile becomes incompatible, another compatible Print profile is selected.
A likely bug in wxWidgets was worked around when switching a Print preset
on Plater, if the last item in the Print preset was active and incompatible,
and another Print preset was selected by the user. On Windows, an CBN_EDITCHANGE
is sent just after combo box selection change event and the CBN_EDITCHANGE
holds an index of the combo box item, which will be removed by the 1st event,
therefore leading to an assert in wxWidgets on CBN_EDITCHANGE. The workaround
is to disable processing of CBN_EDITCHANGE on Windows for the Plater
preset selection combo boxes.
2020-02-27 10:44:01 +00:00
|
|
|
void update_compatible(PresetSelectCompatibleType select_other_print_if_incompatible, PresetSelectCompatibleType select_other_filament_if_incompatible);
|
|
|
|
void update_compatible(PresetSelectCompatibleType select_other_if_incompatible) { this->update_compatible(select_other_if_incompatible, select_other_if_incompatible); }
|
2017-11-10 16:27:05 +00:00
|
|
|
|
2019-08-30 15:40:25 +00:00
|
|
|
// Set the is_visible flag for printer vendors, printer models and printer variants
|
|
|
|
// based on the user configuration.
|
|
|
|
// If the "vendor" section is missing, enable all models and variants of the particular vendor.
|
|
|
|
void load_installed_printers(const AppConfig &config);
|
|
|
|
|
2019-11-29 10:02:30 +00:00
|
|
|
const std::string& get_preset_name_by_alias(const Preset::Type& preset_type, const std::string& alias) const;
|
|
|
|
|
2020-08-14 16:17:16 +00:00
|
|
|
// Save current preset of a required type under a new name. If the name is different from the old one,
|
|
|
|
// Unselected option would be reverted to the beginning values
|
|
|
|
void save_changes_for_preset(const std::string& new_name, Preset::Type type, const std::vector<std::string>& unselected_options);
|
|
|
|
|
2019-06-17 14:39:22 +00:00
|
|
|
static const char *PRUSA_BUNDLE;
|
2017-10-30 17:41:50 +00:00
|
|
|
private:
|
2018-03-09 15:37:33 +00:00
|
|
|
std::string load_system_presets();
|
2018-04-18 11:35:51 +00:00
|
|
|
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
|
|
|
std::vector<std::string> merge_presets(PresetBundle &&other);
|
2020-03-14 19:18:31 +00:00
|
|
|
// Update renamed_from and alias maps of system profiles.
|
|
|
|
void update_system_maps();
|
2018-03-09 15:37:33 +00:00
|
|
|
|
2019-08-30 15:40:25 +00:00
|
|
|
// Set the is_visible flag for filaments and sla materials,
|
2019-08-27 14:59:07 +00:00
|
|
|
// apply defaults based on enabled printers when no filaments/materials are installed.
|
|
|
|
void load_installed_filaments(AppConfig &config);
|
|
|
|
void load_installed_sla_materials(AppConfig &config);
|
|
|
|
|
2018-03-09 15:37:33 +00:00
|
|
|
// Load selections (current print, current filaments, current printer) from config.ini
|
|
|
|
// This is done just once on application start up.
|
2019-08-27 14:59:07 +00:00
|
|
|
void load_selections(AppConfig &config, const std::string &preferred_model_id = "");
|
2018-03-09 15:37:33 +00:00
|
|
|
|
2017-12-20 10:28:16 +00:00
|
|
|
// Load print, filament & printer presets from a config. If it is an external config, then the name is extracted from the external path.
|
|
|
|
// and the external config is just referenced, not stored into user profile directory.
|
|
|
|
// If it is not an external config, then the config will be stored into the user profile directory.
|
|
|
|
void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config);
|
2017-11-01 18:30:05 +00:00
|
|
|
void load_config_file_config_bundle(const std::string &path, const boost::property_tree::ptree &tree);
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2018-07-31 13:09:57 +00:00
|
|
|
DynamicPrintConfig full_fff_config() const;
|
|
|
|
DynamicPrintConfig full_sla_config() const;
|
2017-10-30 17:41:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif /* slic3r_PresetBundle_hpp_ */
|