Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::PhysicalPrinter Class Reference

#include <src/libslic3r/Preset.hpp>

+ Collaboration diagram for Slic3r::PhysicalPrinter:

Public Member Functions

 PhysicalPrinter (const std::string &name, const DynamicPrintConfig &default_config)
 
 PhysicalPrinter (const std::string &name, const DynamicPrintConfig &default_config, const Preset &preset)
 
void set_name (const std::string &name)
 
const std::set< std::string > & get_preset_names () const
 
bool has_empty_config () const
 
void update_preset_names_in_config ()
 
void save ()
 
void save (const std::string &file_name_from, const std::string &file_name_to)
 
void update_from_preset (const Preset &preset)
 
void update_from_config (const DynamicPrintConfig &new_config)
 
bool add_preset (const std::string &preset_name)
 
bool delete_preset (const std::string &preset_name)
 
void reset_presets ()
 
PrinterTechnology printer_technology () const
 
bool operator< (const PhysicalPrinter &other) const
 
std::string get_full_name (const std::string &preset_name) const
 

Static Public Member Functions

static std::string separator ()
 
static const std::vector< std::string > & printer_options ()
 
static const std::vector< std::string > & print_host_options ()
 
static std::vector< std::string > presets_with_print_host_information (const PrinterPresetCollection &printer_presets)
 
static bool has_print_host_information (const DynamicPrintConfig &config)
 
static PrinterTechnology printer_technology (const DynamicPrintConfig &cfg)
 
static std::string get_short_name (std::string full_name)
 
static std::string get_preset_name (std::string full_name)
 

Public Attributes

std::string name
 
std::string file
 
DynamicPrintConfig config
 
std::set< std::string > preset_names
 
bool loaded = false
 

Friends

class PhysicalPrinterCollection
 

Detailed Description

Constructor & Destructor Documentation

◆ PhysicalPrinter() [1/2]

Slic3r::PhysicalPrinter::PhysicalPrinter ( const std::string &  name,
const DynamicPrintConfig default_config 
)
1702 :
1703 name(name), config(default_config)
1704{
1706}
void update_from_config(const DynamicPrintConfig &new_config)
Definition Preset.cpp:1671
std::string name
Definition Preset.hpp:641
DynamicPrintConfig config
Definition Preset.hpp:645

References config, and update_from_config().

+ Here is the call graph for this function:

◆ PhysicalPrinter() [2/2]

Slic3r::PhysicalPrinter::PhysicalPrinter ( const std::string &  name,
const DynamicPrintConfig default_config,
const Preset preset 
)
1708 :
1709 name(name), config(default_config)
1710{
1711 update_from_preset(preset);
1712}
void update_from_preset(const Preset &preset)
Definition Preset.cpp:1663

References update_from_preset().

+ Here is the call graph for this function:

Member Function Documentation

◆ add_preset()

bool Slic3r::PhysicalPrinter::add_preset ( const std::string &  preset_name)
1693{
1694 return preset_names.emplace(preset_name).second;
1695}
std::set< std::string > preset_names
Definition Preset.hpp:647

References preset_names.

Referenced by Slic3r::PhysicalPrinterCollection::load_printers_from_presets(), Slic3r::GUI::PhysicalPrinterDialog::OnOK(), Slic3r::PhysicalPrinterCollection::rename_preset_in_printers(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

+ Here is the caller graph for this function:

◆ delete_preset()

bool Slic3r::PhysicalPrinter::delete_preset ( const std::string &  preset_name)
1698{
1699 return preset_names.erase(preset_name) > 0;
1700}

References preset_names.

Referenced by Slic3r::GUI::Tab::delete_preset(), Slic3r::PhysicalPrinterCollection::delete_preset_from_printers(), Slic3r::PhysicalPrinterCollection::rename_preset_in_printers(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

+ Here is the caller graph for this function:

◆ get_full_name()

std::string Slic3r::PhysicalPrinter::get_full_name ( const std::string &  preset_name) const
1720{
1721 return name + separator() + preset_name;
1722}
static std::string separator()
Definition Preset.cpp:1565

References name, and separator().

Referenced by Slic3r::PhysicalPrinterCollection::get_selected_full_printer_name(), and Slic3r::GUI::SavePresetDialog::update_physical_printers().

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

◆ get_preset_name()

std::string Slic3r::PhysicalPrinter::get_preset_name ( std::string  full_name)
static
1733{
1734 int pos = name.find(separator());
1735 boost::erase_head(name, pos + 3);
1737}
static std::string remove_suffix_modified(const std::string &name)
Definition Preset.cpp:258
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:14

References name, Slic3r::Preset::remove_suffix_modified(), and separator().

Referenced by Slic3r::GUI::TabPresetComboBox::update_dirty().

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

◆ get_preset_names()

const std::set< std::string > & Slic3r::PhysicalPrinter::get_preset_names ( ) const
1617{
1618 return preset_names;
1619}

References preset_names.

Referenced by Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog().

+ Here is the caller graph for this function:

◆ get_short_name()

std::string Slic3r::PhysicalPrinter::get_short_name ( std::string  full_name)
static
1725{
1726 int pos = full_name.find(separator());
1727 if (pos > 0)
1728 boost::erase_tail(full_name, full_name.length() - pos);
1729 return full_name;
1730}

References separator().

Referenced by Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::PhysicalPrinterCollection::select_printer(), and Slic3r::GUI::TabPresetComboBox::update_dirty().

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

◆ has_empty_config()

bool Slic3r::PhysicalPrinter::has_empty_config ( ) const
1622{
1623 return config.opt_string("print_host" ).empty() &&
1624 config.opt_string("printhost_apikey" ).empty() &&
1625 config.opt_string("printhost_cafile" ).empty() &&
1626 config.opt_string("printhost_port" ).empty() &&
1627 config.opt_string("printhost_user" ).empty() &&
1628 config.opt_string("printhost_password").empty();
1629}
std::string & opt_string(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2276

References config, and Slic3r::ConfigBase::opt_string().

Referenced by Slic3r::GUI::PresetForPrinter::PresetForPrinter().

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

◆ has_print_host_information()

bool Slic3r::PhysicalPrinter::has_print_host_information ( const DynamicPrintConfig config)
static
1608{
1609 for (const char *opt : legacy_print_host_options)
1610 if (!config.opt_string(opt).empty())
1611 return true;
1612
1613 return false;
1614}
if(!(yy_init))
Definition lexer.c:1190
static constexpr auto legacy_print_host_options
Definition Preset.cpp:1591
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:229

References config, Slic3r::legacy_print_host_options, and Slic3r::ConfigBase::opt_string().

Referenced by presets_with_print_host_information().

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

◆ operator<()

bool Slic3r::PhysicalPrinter::operator< ( const PhysicalPrinter other) const
inline
685{ return this->name < other.name; }

References name.

◆ presets_with_print_host_information()

std::vector< std::string > Slic3r::PhysicalPrinter::presets_with_print_host_information ( const PrinterPresetCollection printer_presets)
static
1598{
1599 std::vector<std::string> presets;
1600 for (const Preset& preset : printer_presets)
1602 presets.emplace_back(preset.name);
1603
1604 return presets;
1605}
static bool has_print_host_information(const DynamicPrintConfig &config)
Definition Preset.cpp:1607

References has_print_host_information().

Referenced by Slic3r::GUI::GUI_App::check_printer_presets().

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

◆ print_host_options()

static const std::vector< std::string > & Slic3r::PhysicalPrinter::print_host_options ( )
static

◆ printer_options()

const std::vector< std::string > & Slic3r::PhysicalPrinter::printer_options ( )
static
1587{
1589}
static std::vector< std::string > s_PhysicalPrinter_opts
Definition Preset.cpp:1570

References Slic3r::s_PhysicalPrinter_opts.

Referenced by update_from_config(), and update_from_preset().

+ Here is the caller graph for this function:

◆ printer_technology() [1/2]

PrinterTechnology Slic3r::PhysicalPrinter::printer_technology ( ) const
inline
682{ return printer_technology(this->config); }
PrinterTechnology printer_technology() const
Definition Preset.hpp:682

References printer_technology().

Referenced by printer_technology().

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

◆ printer_technology() [2/2]

static PrinterTechnology Slic3r::PhysicalPrinter::printer_technology ( const DynamicPrintConfig cfg)
inlinestatic
676 {
677 auto* opt = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
678 // The following assert may trigger when importing some legacy profile,
679 // but it is safer to keep it here to capture the cases where the "printer_technology" key is queried, where it should not.
680 return (opt == nullptr) ? ptFFF : opt->value;
681 }
@ ptFFF
Definition Config.hpp:207
ConfigOptionEnum< PrinterTechnology >
Definition PrintConfig.hpp:1079

References Slic3r::ConfigBase::option(), and Slic3r::ptFFF.

Referenced by Slic3r::GUI::PhysicalPrinterDialog::get_printer_technology(), and Slic3r::PhysicalPrinterCollection::get_selected_printer_technology().

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

◆ reset_presets()

void Slic3r::PhysicalPrinter::reset_presets ( )
1688{
1689 return preset_names.clear();
1690}

References preset_names.

Referenced by Slic3r::GUI::PhysicalPrinterDialog::OnOK().

+ Here is the caller graph for this function:

◆ save() [1/2]

void Slic3r::PhysicalPrinter::save ( )
inline
663{ this->config.save(this->file); }
void save(const std::string &file) const
Definition Config.cpp:1030
std::string file
Definition Preset.hpp:643

References Slic3r::ConfigBase::save().

Referenced by Slic3r::PhysicalPrinterCollection::rename_preset_in_printers(), and Slic3r::PhysicalPrinterCollection::save_printer().

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

◆ save() [2/2]

void Slic3r::PhysicalPrinter::save ( const std::string &  file_name_from,
const std::string &  file_name_to 
)
1655{
1656 // rename the file
1657 boost::nowide::rename(file_name_from.data(), file_name_to.data());
1658 this->file = file_name_to;
1659 // save configuration
1660 this->config.save(this->file);
1661}

References config, file, and Slic3r::ConfigBase::save().

+ Here is the call graph for this function:

◆ separator()

std::string Slic3r::PhysicalPrinter::separator ( )
static
1566{
1567 return " * ";
1568}

Referenced by get_full_name(), get_preset_name(), get_short_name(), Slic3r::PhysicalPrinterCollection::select_printer(), Slic3r::GUI::TabPresetComboBox::update_dirty(), and Slic3r::GUI::PresetForPrinter::update_full_printer_name().

+ Here is the caller graph for this function:

◆ set_name()

void Slic3r::PhysicalPrinter::set_name ( const std::string &  name)
1715{
1716 this->name = name;
1717}

References name.

Referenced by Slic3r::GUI::PhysicalPrinterDialog::OnOK().

+ Here is the caller graph for this function:

◆ update_from_config()

void Slic3r::PhysicalPrinter::update_from_config ( const DynamicPrintConfig new_config)
1672{
1673 config.apply_only(new_config, printer_options(), false);
1674
1675 const std::vector<std::string>& values = config.option<ConfigOptionStrings>("preset_names")->values;
1676
1677 if (values.empty())
1678 preset_names.clear();
1679 else {
1680 for (const std::string& val : values)
1681 preset_names.emplace(val);
1682 // temporary workaround for compatibility with older Slicer
1684 }
1685}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2169
void apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent=false)
Definition Config.cpp:466
static const std::vector< std::string > & printer_options()
Definition Preset.cpp:1586
static void update_preset_name_option(const std::set< std::string > &preset_names, DynamicPrintConfig &config)
Definition Preset.cpp:1632

References Slic3r::ConfigBase::apply_only(), config, Slic3r::ConfigBase::option(), preset_names, printer_options(), and Slic3r::update_preset_name_option().

Referenced by PhysicalPrinter(), and Slic3r::PhysicalPrinterCollection::load_printers().

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

◆ update_from_preset()

void Slic3r::PhysicalPrinter::update_from_preset ( const Preset preset)
1664{
1665 config.apply_only(preset.config, printer_options(), true);
1666 // add preset names to the options list
1667 preset_names.emplace(preset.name);
1669}
void update_preset_names_in_config()
Definition Preset.cpp:1641

References Slic3r::ConfigBase::apply_only(), Slic3r::Preset::config, config, Slic3r::Preset::name, preset_names, printer_options(), and update_preset_names_in_config().

Referenced by PhysicalPrinter(), and Slic3r::GUI::PresetForPrinter::PresetForPrinter().

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

◆ update_preset_names_in_config()

void Slic3r::PhysicalPrinter::update_preset_names_in_config ( )
1642{
1643 if (!preset_names.empty()) {
1644 std::vector<std::string>& values = config.option<ConfigOptionStrings>("preset_names")->values;
1645 values.clear();
1646 for (const std::string& preset : preset_names)
1647 values.push_back(preset);
1648
1649 // temporary workaround for compatibility with older Slicer
1651 }
1652}

References Slic3r::ConfigOptionVector< T >::clear(), config, Slic3r::ConfigBase::option(), preset_names, and Slic3r::update_preset_name_option().

Referenced by Slic3r::PhysicalPrinterCollection::rename_preset_in_printers(), Slic3r::PhysicalPrinterCollection::save_printer(), and update_from_preset().

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

Friends And Related Symbol Documentation

◆ PhysicalPrinterCollection

friend class PhysicalPrinterCollection
friend

Member Data Documentation

◆ config

◆ file

◆ loaded

◆ name

◆ preset_names


The documentation for this class was generated from the following files: