OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::PhysicalPrinterCollection Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Preset.hpp>

Collaboration diagram for Slic3r::PhysicalPrinterCollection:

Public Types

typedef std::deque< PhysicalPrinter >::iterator Iterator
typedef std::deque< PhysicalPrinter >::const_iterator ConstIterator

Public Member Functions

 PhysicalPrinterCollection (const std::vector< std::string > &keys)
Iterator begin ()
ConstIterator begin () const
ConstIterator cbegin () const
Iterator end ()
ConstIterator end () const
ConstIterator cend () const
bool empty () const
void reset (bool delete_files)
const std::deque< PhysicalPrinter > & operator() () const
void load_printers (const std::string &dir_path, const std::string &subdir, PresetsConfigSubstitutions &substitutions, ForwardCompatibilitySubstitutionRule rule)
void load_printers_from_presets (PrinterPresetCollection &printer_presets)
void load_printer (const std::string &path, const std::string &name, DynamicPrintConfig &&config, bool select, bool save=false)
void save_printer (PhysicalPrinter &printer, const std::string &renamed_from="")
bool delete_printer (const std::string &name)
bool delete_selected_printer ()
bool delete_preset_from_printers (const std::string &preset_name)
std::vector< std::string > get_printers_with_preset (const std::string &preset_name)
std::vector< std::string > get_printers_with_only_preset (const std::string &preset_name)
PhysicalPrinter & get_selected_printer ()
const PhysicalPrinter & get_selected_printer () const
size_t get_selected_idx () const
std::string get_selected_printer_name () const
DynamicPrintConfig * get_selected_printer_config ()
PrinterTechnology get_selected_printer_technology ()
std::string get_selected_full_printer_name () const
std::string get_selected_printer_preset_name () const
void select_printer (const std::string &full_name)
void select_printer (const PhysicalPrinter &printer)
void select_printer (const std::string &printer_name, const std::string &preset_name)
bool has_selection () const
void unselect_printer ()
bool is_selected (ConstIterator it, const std::string &preset_name) const
PhysicalPrinter & printer (size_t idx)
const PhysicalPrinter & printer (size_t idx) const
PhysicalPrinter * find_printer (const std::string &name, bool case_sensitive_search=true)
const PhysicalPrinter * find_printer (const std::string &name, bool case_sensitive_search=true) const
std::string path_from_name (const std::string &new_name) const
const DynamicPrintConfig & default_config () const

Private Member Functions

 PhysicalPrinterCollection ()=default
PhysicalPrinterCollection & operator= (const PhysicalPrinterCollection &other)=default
std::deque< PhysicalPrinter >::iterator find_printer_internal (const std::string &name, bool case_sensitive_search=true)
std::deque< PhysicalPrinter >::const_iterator find_printer_internal (const std::string &name, bool case_sensitive_search=true) const

Private Attributes

std::deque< PhysicalPrinter > m_printers
DynamicPrintConfig m_default_config
size_t m_idx_selected = size_t(-1)
std::string m_selected_preset
std::string m_dir_path

Friends

class PresetBundle

Detailed Description

Member Typedef Documentation

◆ ConstIterator

◆ Iterator

Constructor & Destructor Documentation

◆ PhysicalPrinterCollection() [1/2]

Slic3r::PhysicalPrinterCollection::PhysicalPrinterCollection ( const std::vector< std::string > & keys)
4720{
4721 // Default config for a physical printer containing all key/value pairs of PhysicalPrinter::printer_options().
4722 for (const std::string &key : keys) {
4723 const ConfigOptionDef *opt = print_config_def.get(key);
4724 assert(opt);
4725 assert(opt->default_value);
4726 m_default_config.set_key_value(key, opt->default_value->clone());
4727 }
4728}
const ConfigOptionDef * get(const t_config_option_key &opt_key) const
Definition Config.hpp:2662
DynamicPrintConfig m_default_config
Definition Preset.hpp:1335
const PrintConfigDef print_config_def
Definition PrintConfig.cpp:10099

References m_default_config, and Slic3r::print_config_def.

Referenced by find_printer(), find_printer_internal(), operator=(), and printer().

Here is the caller graph for this function:

◆ PhysicalPrinterCollection() [2/2]

Slic3r::PhysicalPrinterCollection::PhysicalPrinterCollection ( )
privatedefault

Member Function Documentation

◆ begin() [1/2]

Iterator Slic3r::PhysicalPrinterCollection::begin ( )
inline
1229{ return m_printers.begin(); }
std::deque< PhysicalPrinter > m_printers
Definition Preset.hpp:1332

References m_printers.

◆ begin() [2/2]

ConstIterator Slic3r::PhysicalPrinterCollection::begin ( ) const
inline
1230{ return m_printers.cbegin(); }

References m_printers.

◆ cbegin()

ConstIterator Slic3r::PhysicalPrinterCollection::cbegin ( ) const
inline
1231{ return m_printers.cbegin(); }

References m_printers.

◆ cend()

ConstIterator Slic3r::PhysicalPrinterCollection::cend ( ) const
inline
1234{ return m_printers.cend(); }

References m_printers.

◆ default_config()

const DynamicPrintConfig & Slic3r::PhysicalPrinterCollection::default_config ( ) const
inline
1313{ return m_default_config; }

References m_default_config.

Referenced by load_printers(), and load_printers_from_presets().

Here is the caller graph for this function:

◆ delete_preset_from_printers()

bool Slic3r::PhysicalPrinterCollection::delete_preset_from_printers ( const std::string & preset_name)
4981{
4982 std::vector<std::string> printers_for_delete;
4983 for (PhysicalPrinter& printer : m_printers) {
4984 if (printer.preset_names.size() == 1 && *printer.preset_names.begin() == preset_name)
4985 printers_for_delete.emplace_back(printer.name);
4986 else if (printer.delete_preset(preset_name))
4988 }
4989
4990 if (!printers_for_delete.empty())
4991 for (const std::string& printer_name : printers_for_delete)
4992 delete_printer(printer_name);
4993
4995 return true;
4996}
PhysicalPrinter & printer(size_t idx)
Definition Preset.hpp:1298
bool delete_printer(const std::string &name)
Definition Preset.cpp:4945
void unselect_printer()
Definition Preset.cpp:5067
void save_printer(PhysicalPrinter &printer, const std::string &renamed_from="")
Definition Preset.cpp:4905

References delete_printer(), m_printers, printer(), save_printer(), and unselect_printer().

Referenced by Slic3r::GUI::Tab::delete_preset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_printer()

bool Slic3r::PhysicalPrinterCollection::delete_printer ( const std::string & name)
4946{
4947 auto it = this->find_printer_internal(name);
4948 if (it == m_printers.end())
4949 return false;
4950
4951 const PhysicalPrinter& printer = *it;
4952 // Erase the preset file.
4953 {
4954 InstanceLock instance_lock(user_presets_lock_path());
4955 boost::nowide::remove(printer.file.c_str());
4956 }
4957 m_printers.erase(it);
4958 return true;
4959}
std::deque< PhysicalPrinter >::iterator find_printer_internal(const std::string &name, bool case_sensitive_search=true)
Definition Preset.cpp:4877
std::string user_presets_lock_path(bool read_only)
Definition Preset.cpp:146

References find_printer_internal(), m_printers, printer(), and Slic3r::user_presets_lock_path().

Referenced by delete_preset_from_printers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_selected_printer()

bool Slic3r::PhysicalPrinterCollection::delete_selected_printer ( )
4962{
4963 if (!has_selection())
4964 return false;
4965 const PhysicalPrinter& printer = this->get_selected_printer();
4966
4967 // Erase the preset file.
4968 {
4969 InstanceLock instance_lock(user_presets_lock_path());
4970 boost::nowide::remove(printer.file.c_str());
4971 }
4972 // Remove the preset from the list.
4973 m_printers.erase(m_printers.begin() + m_idx_selected);
4974 // unselect all printers
4976
4977 return true;
4978}
size_t m_idx_selected
Definition Preset.hpp:1338
bool has_selection() const
Definition Preset.cpp:5062
PhysicalPrinter & get_selected_printer()
Definition Preset.hpp:1270

References get_selected_printer(), has_selection(), m_idx_selected, m_printers, printer(), unselect_printer(), and Slic3r::user_presets_lock_path().

Here is the call graph for this function:

◆ empty()

bool Slic3r::PhysicalPrinterCollection::empty ( ) const
inline
1236{return m_printers.empty(); }

References m_printers.

Referenced by Slic3r::GUI::Tab::delete_preset().

Here is the caller graph for this function:

◆ end() [1/2]

Iterator Slic3r::PhysicalPrinterCollection::end ( )
inline
1232{ return m_printers.end(); }

References m_printers.

◆ end() [2/2]

ConstIterator Slic3r::PhysicalPrinterCollection::end ( ) const
inline
1233{ return m_printers.cend(); }

References m_printers.

◆ find_printer() [1/2]

PhysicalPrinter * Slic3r::PhysicalPrinterCollection::find_printer ( const std::string & name,
bool case_sensitive_search = true )
4862{
4863 auto it = this->find_printer_internal(name, case_sensitive_search);
4864
4865 // Ensure that a temporary copy is returned if the preset found is currently selected.
4866 auto is_equal_name = [name, case_sensitive_search](const std::string& in_name) {
4867 if (case_sensitive_search)
4868 return in_name == name;
4869 return boost::to_lower_copy<std::string>(in_name) == boost::to_lower_copy<std::string>(name);
4870 };
4871
4872 if (it == m_printers.end() || !is_equal_name(it->name))
4873 return nullptr;
4874 return &this->printer(it - m_printers.begin());
4875}

References find_printer_internal(), m_printers, and printer().

Referenced by find_printer(), load_printers(), and load_printers_from_presets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_printer() [2/2]

const PhysicalPrinter * Slic3r::PhysicalPrinterCollection::find_printer ( const std::string & name,
bool case_sensitive_search = true ) const
inline
1306 {
1307 return const_cast<PhysicalPrinterCollection*>(this)->find_printer(name, case_sensitive_search);
1308 }
PhysicalPrinter * find_printer(const std::string &name, bool case_sensitive_search=true)
Definition Preset.cpp:4861
PhysicalPrinterCollection(const std::vector< std::string > &keys)
Definition Preset.cpp:4719

References PhysicalPrinterCollection(), and find_printer().

Here is the call graph for this function:

◆ find_printer_internal() [1/2]

std::deque< PhysicalPrinter >::iterator Slic3r::PhysicalPrinterCollection::find_printer_internal ( const std::string & name,
bool case_sensitive_search = true )
private
4878{
4879 if (case_sensitive_search)
4880 return Slic3r::lower_bound_by_predicate(m_printers.begin(), m_printers.end(), [&name](const auto& l) { return l.name < name; });
4881
4882 std::string low_name = boost::to_lower_copy<std::string>(name);
4883
4884 size_t i = 0;
4885 for (const PhysicalPrinter& printer : m_printers) {
4886 if (boost::to_lower_copy<std::string>(printer.name) == low_name)
4887 break;
4888 i++;
4889 }
4890 if (i == m_printers.size())
4891 return m_printers.end();
4892
4893 return m_printers.begin() + i;
4894}
ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKeyPredicate lower_than_key)
Definition libslic3r.h:246

References Slic3r::lower_bound_by_predicate(), m_printers, and printer().

Referenced by delete_printer(), find_printer(), find_printer_internal(), load_printer(), operator=(), save_printer(), and select_printer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_printer_internal() [2/2]

std::deque< PhysicalPrinter >::const_iterator Slic3r::PhysicalPrinterCollection::find_printer_internal ( const std::string & name,
bool case_sensitive_search = true ) const
inlineprivate
1325 {
1326 return const_cast<PhysicalPrinterCollection*>(this)->find_printer_internal(name);
1327 }

References PhysicalPrinterCollection(), and find_printer_internal().

Here is the call graph for this function:

◆ get_printers_with_only_preset()

std::vector< std::string > Slic3r::PhysicalPrinterCollection::get_printers_with_only_preset ( const std::string & preset_name)
5015{
5016 std::vector<std::string> printers;
5017
5018 for (auto printer : m_printers)
5019 if (printer.preset_names.size() == 1 && *printer.preset_names.begin() == preset_name)
5020 printers.emplace_back(printer.name);
5021
5022 return printers;
5023}

References m_printers, and printer().

Referenced by Slic3r::GUI::Tab::delete_preset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printers_with_preset()

std::vector< std::string > Slic3r::PhysicalPrinterCollection::get_printers_with_preset ( const std::string & preset_name)
5000{
5001 std::vector<std::string> printers;
5002
5003 for (auto printer : m_printers) {
5004 if (printer.preset_names.size() == 1)
5005 continue;
5006 if (printer.preset_names.find(preset_name) != printer.preset_names.end())
5007 printers.emplace_back(printer.name);
5008 }
5009
5010 return printers;
5011}

References m_printers, and printer().

Referenced by Slic3r::GUI::Tab::delete_preset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_selected_full_printer_name()

std::string Slic3r::PhysicalPrinterCollection::get_selected_full_printer_name ( ) const
5026{
5027 return (m_idx_selected == size_t(-1)) ? std::string() : this->get_selected_printer().get_full_name(m_selected_preset);
5028}
std::string m_selected_preset
Definition Preset.hpp:1340

References Slic3r::PhysicalPrinter::get_full_name(), get_selected_printer(), m_idx_selected, and m_selected_preset.

Referenced by Slic3r::GUI::PresetComboBox::selection_is_changed_according_to_physical_printers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_selected_idx()

size_t Slic3r::PhysicalPrinterCollection::get_selected_idx ( ) const
inline
1273{ return m_idx_selected; }

References m_idx_selected.

◆ get_selected_printer() [1/2]

PhysicalPrinter & Slic3r::PhysicalPrinterCollection::get_selected_printer ( )
inline
1270{ return m_printers[m_idx_selected]; }

References m_idx_selected, and m_printers.

Referenced by Slic3r::GUI::Tab::delete_preset(), delete_selected_printer(), get_selected_full_printer_name(), get_selected_printer_config(), get_selected_printer_name(), get_selected_printer_technology(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

Here is the caller graph for this function:

◆ get_selected_printer() [2/2]

const PhysicalPrinter & Slic3r::PhysicalPrinterCollection::get_selected_printer ( ) const
inline
1271{ return m_printers[m_idx_selected]; }

References m_idx_selected, and m_printers.

◆ get_selected_printer_config()

DynamicPrintConfig * Slic3r::PhysicalPrinterCollection::get_selected_printer_config ( )
inline
1277{ return (m_idx_selected == size_t(-1)) ? nullptr : &(this->get_selected_printer().config); }
DynamicPrintConfig config
Definition Preset.hpp:1160

References get_selected_printer(), and m_idx_selected.

Here is the call graph for this function:

◆ get_selected_printer_name()

std::string Slic3r::PhysicalPrinterCollection::get_selected_printer_name ( ) const
inline
1275{ return (m_idx_selected == size_t(-1)) ? std::string() : this->get_selected_printer().name; }

References get_selected_printer(), and m_idx_selected.

Referenced by Slic3r::GUI::SavePresetDialog::add_info_for_edit_ph_printer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_selected_printer_preset_name()

std::string Slic3r::PhysicalPrinterCollection::get_selected_printer_preset_name ( ) const
inline
1286{ return (m_idx_selected == size_t(-1)) ? std::string() : m_selected_preset; }

References m_idx_selected, and m_selected_preset.

Referenced by Slic3r::GUI::SavePresetDialog::add_info_for_edit_ph_printer(), Slic3r::GUI::Tab::delete_preset(), Slic3r::GUI::Plater::priv::on_select_preset(), Slic3r::GUI::PresetComboBox::selection_is_changed_according_to_physical_printers(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

Here is the caller graph for this function:

◆ get_selected_printer_technology()

PrinterTechnology Slic3r::PhysicalPrinterCollection::get_selected_printer_technology ( )
inline
static PrinterTechnology printer_technology(const DynamicPrintConfig &cfg)
Definition Preset.hpp:1192
@ ptAny
Definition Config.hpp:237

References get_selected_printer(), m_idx_selected, and Slic3r::ptAny.

Here is the call graph for this function:

◆ has_selection()

bool Slic3r::PhysicalPrinterCollection::has_selection ( ) const
5063{
5064 return m_idx_selected != size_t(-1);
5065}

References m_idx_selected.

Referenced by delete_selected_printer(), Slic3r::GUI::PresetComboBox::selection_is_changed_according_to_physical_printers(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

Here is the caller graph for this function:

◆ is_selected()

bool Slic3r::PhysicalPrinterCollection::is_selected ( PhysicalPrinterCollection::ConstIterator it,
const std::string & preset_name ) const
5074{
5075 return m_idx_selected == size_t(it - m_printers.begin()) &&
5076 m_selected_preset == preset_name;
5077}

References m_idx_selected, m_printers, and m_selected_preset.

◆ load_printer()

void Slic3r::PhysicalPrinterCollection::load_printer ( const std::string & path,
const std::string & name,
DynamicPrintConfig && config,
bool select,
bool save = false )
4796{
4797 auto it = this->find_printer_internal(name);
4798 if (it == m_printers.end() || it->name != name) {
4799 // The preset was not found. Create a new preset.
4800 it = m_printers.emplace(it, PhysicalPrinter(name, config));
4801 }
4802
4803 it->file = path;
4804 it->config = std::move(config);
4805 it->loaded = true;
4806 if (select)
4807 this->select_printer(*it);
4808
4809 if (save)
4810 it->save(nullptr);
4811}
void save(Archive &archive, wxString const &d)
Definition GLGizmoEmboss.cpp:3403
void select_printer(const std::string &full_name)
Definition Preset.cpp:5030

References find_printer_internal(), m_printers, save(), and select_printer().

Here is the call graph for this function:

◆ load_printers()

void Slic3r::PhysicalPrinterCollection::load_printers ( const std::string & dir_path,
const std::string & subdir,
PresetsConfigSubstitutions & substitutions,
ForwardCompatibilitySubstitutionRule rule )
4735{
4736 // Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points,
4737 // see https://github.com/prusa3d/PrusaSlicer/issues/732
4738 boost::filesystem::path dir = boost::filesystem::absolute(boost::filesystem::path(dir_path) / subdir).make_preferred();
4739 m_dir_path = dir.string();
4740 if(!boost::filesystem::exists(dir))
4741 return;
4742 std::string errors_cummulative;
4743 // Store the loaded printers into a new vector, otherwise the binary search for already existing presets would be broken.
4744 std::deque<PhysicalPrinter> printers_loaded;
4745 //BBS: change to json format
4746 for (auto& dir_entry : boost::filesystem::directory_iterator(dir))
4747 {
4748 std::string file_name = dir_entry.path().filename().string();
4749 //if (Slic3r::is_ini_file(dir_entry)) {
4750 if (Slic3r::is_json_file(file_name)) {
4751 // Remove the .json suffix.
4752 std::string name = file_name.erase(file_name.size() - 5);
4753 if (this->find_printer(name, false)) {
4754 // This happens when there's is a preset (most likely legacy one) with the same name as a system preset
4755 // that's already been loaded from a bundle.
4756 BOOST_LOG_TRIVIAL(warning) << "Printer already present, not loading: " << name;
4757 continue;
4758 }
4759 try {
4760 InstanceLock instance_lock(user_presets_lock_path());
4761 PhysicalPrinter printer(name, this->default_config());
4762 printer.file = dir_entry.path().string();
4763 // Load the preset file, apply preset values on top of defaults.
4764 try {
4765 DynamicPrintConfig config;
4766 //ConfigSubstitutions config_substitutions = config.load_from_ini(printer.file, substitution_rule);
4767 std::map<std::string, std::string> key_values;
4768 std::string reason;
4769 ConfigSubstitutions config_substitutions = config.load_from_json(printer.file, substitution_rule, key_values, reason);
4770 if (! config_substitutions.empty())
4771 substitutions.push_back({ name, Preset::TYPE_PHYSICAL_PRINTER, PresetConfigSubstitutions::Source::UserFile, printer.file, std::move(config_substitutions) });
4772 printer.update_from_config(config);
4773 printer.loaded = true;
4774 }
4775 catch (const std::ifstream::failure& err) {
4776 throw Slic3r::RuntimeError((boost::format(_u8L("The selected preset cannot be loaded: %1%\n\tReason: %2%")) % printer.file % err.what()).str());
4777 }
4778 catch (const std::runtime_error& err) {
4779 throw Slic3r::RuntimeError((boost::format(_u8L("Failed loading the preset file: %1%\n\tReason: %2%")) % printer.file % err.what()).str());
4780 }
4781 printers_loaded.emplace_back(printer);
4782 }
4783 catch (const std::runtime_error& err) {
4784 errors_cummulative += err.what();
4785 errors_cummulative += "\n";
4786 }
4787 }
4788 }
4789 m_printers.insert(m_printers.end(), std::make_move_iterator(printers_loaded.begin()), std::make_move_iterator(printers_loaded.end()));
4790 std::sort(m_printers.begin(), m_printers.end());
4791 if (!errors_cummulative.empty())
4792 throw Slic3r::RuntimeError(errors_cummulative);
4793}
std::string m_dir_path
Definition Preset.hpp:1343
const DynamicPrintConfig & default_config() const
Definition Preset.hpp:1313
@ TYPE_PHYSICAL_PRINTER
Definition Preset.hpp:254
std::vector< ConfigSubstitution > ConfigSubstitutions
Definition Config.hpp:269
bool is_json_file(const std::string &path)
Definition utils.cpp:1214
#define _u8L(s)
Definition I18N.hpp:11
@ UserFile
Definition Preset.hpp:537

References _u8L, default_config(), Slic3r::PhysicalPrinter::file, find_printer(), Slic3r::is_json_file(), Slic3r::ConfigBase::load_from_json(), m_dir_path, m_printers, printer(), Slic3r::Preset::TYPE_PHYSICAL_PRINTER, Slic3r::user_presets_lock_path(), and Slic3r::PresetConfigSubstitutions::UserFile.

Here is the call graph for this function:

◆ load_printers_from_presets()

void Slic3r::PhysicalPrinterCollection::load_printers_from_presets ( PrinterPresetCollection & printer_presets)
4817{
4818//BBS
4819#if 0
4820 int cnt=0;
4821 for (Preset& preset: printer_presets) {
4822 DynamicPrintConfig& config = preset.config;
4823 for(const char* option : legacy_print_host_options) {
4824 if (!config.opt_string(option).empty()) {
4825 // check if printer with those "Print Host upload" options already exist
4826 PhysicalPrinter* existed_printer = find_printer_with_same_config(config);
4827 if (existed_printer)
4828 // just add preset for this printer
4829 existed_printer->add_preset(preset.name);
4830 else {
4831 std::string new_printer_name = (boost::format("Printer %1%") % ++cnt ).str();
4832 while (find_printer(new_printer_name))
4833 new_printer_name = (boost::format("Printer %1%") % ++cnt).str();
4834
4835 // create new printer from this preset
4836 PhysicalPrinter printer(new_printer_name, this->default_config(), preset);
4837 printer.loaded = true;
4839 }
4840
4841 // erase "Print Host upload" information from the preset
4842 for (const char *opt : legacy_print_host_options)
4843 config.opt_string(opt).clear();
4844 // save changes for preset
4845 preset.save(nullptr);
4846
4847 // update those changes for edited preset if it's equal to the preset
4849 if (preset.name == edited.name) {
4850 for (const char *opt : legacy_print_host_options)
4851 edited.config.opt_string(opt).clear();
4852 }
4853
4854 break;
4855 }
4856 }
4857 }
4858#endif
4859}
Preset & get_edited_preset()
Definition Preset.hpp:756
PresetCollection & printer_presets(PresetBundle &bundle)
Definition PluginHostPresets.cpp:50
@ Preset
Definition calib.hpp:39

References Slic3r::PhysicalPrinter::add_preset(), Slic3r::Preset::config, default_config(), find_printer(), Slic3r::PresetCollection::get_edited_preset(), Slic3r::Preset::name, Slic3r::DynamicConfig::opt_string(), printer(), and save_printer().

Here is the call graph for this function:

◆ operator()()

const std::deque< PhysicalPrinter > & Slic3r::PhysicalPrinterCollection::operator() ( ) const
inline
1240{ return m_printers; }

References m_printers.

◆ operator=()

PhysicalPrinterCollection & Slic3r::PhysicalPrinterCollection::operator= ( const PhysicalPrinterCollection & other)
privatedefault

References PhysicalPrinterCollection(), and find_printer_internal().

Here is the call graph for this function:

◆ path_from_name()

std::string Slic3r::PhysicalPrinterCollection::path_from_name ( const std::string & new_name) const
4898{
4899 //BBS: change to json format
4900 //std::string file_name = boost::iends_with(new_name, ".ini") ? new_name : (new_name + ".ini");
4901 std::string file_name = boost::iends_with(new_name, ".json") ? new_name : (new_name + ".json");
4902 return (boost::filesystem::path(m_dir_path) / file_name).make_preferred().string();
4903}

References m_dir_path.

Referenced by save_printer().

Here is the caller graph for this function:

◆ printer() [1/2]

PhysicalPrinter & Slic3r::PhysicalPrinterCollection::printer ( size_t idx)
inline
1298{ return m_printers[idx]; }

References m_printers.

Referenced by delete_preset_from_printers(), delete_printer(), delete_selected_printer(), find_printer(), find_printer_internal(), get_printers_with_only_preset(), get_printers_with_preset(), load_printers(), load_printers_from_presets(), save_printer(), and select_printer().

Here is the caller graph for this function:

◆ printer() [2/2]

const PhysicalPrinter & Slic3r::PhysicalPrinterCollection::printer ( size_t idx) const
inline
1299{ return const_cast<PhysicalPrinterCollection*>(this)->printer(idx); }

References PhysicalPrinterCollection(), and printer().

Referenced by printer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void Slic3r::PhysicalPrinterCollection::reset ( bool delete_files)
inline
1238{};

◆ save_printer()

void Slic3r::PhysicalPrinterCollection::save_printer ( PhysicalPrinter & printer,
const std::string & renamed_from = "" )
4906{
4907 // controll and update preset_names in edited_printer config
4908 edited_printer.update_preset_names_in_config();
4909
4910 std::string name = renamed_from.empty() ? edited_printer.name : renamed_from;
4911 // 1) Find the printer with a new_name or create a new one,
4912 // initialize it with the edited config.
4913 auto it = this->find_printer_internal(name);
4914 if (it != m_printers.end() && it->name == name) {
4915 // Printer with the same name found.
4916 // Overwriting an existing preset.
4917 it->config = std::move(edited_printer.config);
4918 it->name = edited_printer.name;
4919 it->preset_names = edited_printer.preset_names;
4920 // sort printers and get new it
4921 std::sort(m_printers.begin(), m_printers.end());
4922 it = this->find_printer_internal(edited_printer.name);
4923 }
4924 else {
4925 // Creating a new printer.
4926 it = m_printers.emplace(it, edited_printer);
4927 }
4928 assert(it != m_printers.end());
4929
4930 // 2) Save printer
4931 PhysicalPrinter& printer = *it;
4932 if (printer.file.empty())
4933 printer.file = this->path_from_name(printer.name);
4934
4935 if (printer.file == this->path_from_name(printer.name))
4936 printer.save(nullptr);
4937 else
4938 // if printer was renamed, we should rename a file and than save the config
4939 printer.save(printer.file, this->path_from_name(printer.name));
4940
4941 // update idx_selected
4942 m_idx_selected = it - m_printers.begin();
4943}
std::string path_from_name(const std::string &new_name) const
Definition Preset.cpp:4897

References Slic3r::PhysicalPrinter::config, find_printer_internal(), m_idx_selected, m_printers, Slic3r::PhysicalPrinter::name, path_from_name(), Slic3r::PhysicalPrinter::preset_names, printer(), and Slic3r::PhysicalPrinter::update_preset_names_in_config().

Referenced by delete_preset_from_printers(), load_printers_from_presets(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_printer() [1/3]

void Slic3r::PhysicalPrinterCollection::select_printer ( const PhysicalPrinter & printer)
5058{
5059 return select_printer(printer.name);
5060}

References printer(), and select_printer().

Here is the call graph for this function:

◆ select_printer() [2/3]

void Slic3r::PhysicalPrinterCollection::select_printer ( const std::string & full_name)
5031{
5032 std::string printer_name = PhysicalPrinter::get_short_name(full_name);
5033 auto it = this->find_printer_internal(printer_name);
5034 if (it == m_printers.end()) {
5036 return;
5037 }
5038
5039 // update idx_selected
5040 m_idx_selected = it - m_printers.begin();
5041
5042 // update name of the currently selected preset
5043 if (printer_name == full_name)
5044 // use first preset in the list
5045 m_selected_preset = *it->preset_names.begin();
5046 else
5047 m_selected_preset = it->get_preset_name(full_name);
5048}
static std::string get_short_name(std::string full_name)
Definition Preset.cpp:4699

References find_printer_internal(), Slic3r::PhysicalPrinter::get_short_name(), m_idx_selected, m_printers, m_selected_preset, and unselect_printer().

Referenced by Slic3r::GUI::Tab::delete_preset(), load_printer(), select_printer(), select_printer(), Slic3r::GUI::PresetComboBox::selection_is_changed_according_to_physical_printers(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_printer() [3/3]

void Slic3r::PhysicalPrinterCollection::select_printer ( const std::string & printer_name,
const std::string & preset_name )
5051{
5052 if (preset_name.empty())
5053 return select_printer(printer_name);
5054 return select_printer(printer_name + PhysicalPrinter::separator() + preset_name);
5055}
static std::string separator()
Definition Preset.cpp:4547

References select_printer(), and Slic3r::PhysicalPrinter::separator().

Here is the call graph for this function:

◆ unselect_printer()

void Slic3r::PhysicalPrinterCollection::unselect_printer ( )
5068{
5069 m_idx_selected = size_t(-1);
5070 m_selected_preset.clear();
5071}

References m_idx_selected, and m_selected_preset.

Referenced by delete_preset_from_printers(), delete_selected_printer(), Slic3r::GUI::Plater::priv::on_select_preset(), select_printer(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

Here is the caller graph for this function:

◆ PresetBundle

friend class PresetBundle
friend

References PresetBundle.

Referenced by PresetBundle.

Member Data Documentation

◆ m_default_config

DynamicPrintConfig Slic3r::PhysicalPrinterCollection::m_default_config
private

◆ m_dir_path

std::string Slic3r::PhysicalPrinterCollection::m_dir_path
private

Referenced by load_printers(), and path_from_name().

◆ m_idx_selected

◆ m_printers

◆ m_selected_preset

std::string Slic3r::PhysicalPrinterCollection::m_selected_preset
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Preset.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Preset.cpp