Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::CustomGCode Namespace Reference

Classes

struct  Info
 
struct  Item
 

Enumerations

enum  Type {
  ColorChange , PausePrint , ToolChange , Template ,
  Custom
}
 
enum  Mode { Undef , SingleExtruder , MultiAsSingle , MultiExtruder }
 

Functions

void update_custom_gcode_per_print_z_from_config (Info &info, DynamicPrintConfig *config)
 
void check_mode_for_custom_gcode_per_print_z (Info &info)
 
std::vector< std::pair< double, unsigned int > > custom_tool_changes (const Info &custom_gcode_per_print_z, size_t num_extruders)
 

Variables

static constexpr char SingleExtruderMode [] = "SingleExtruder"
 
static constexpr char MultiAsSingleMode [] = "MultiAsSingle"
 
static constexpr char MultiExtruderMode [] = "MultiExtruder"
 

Enumeration Type Documentation

◆ Mode

Enumerator
Undef 
SingleExtruder 
MultiAsSingle 
MultiExtruder 
48{
49 Undef,
50 SingleExtruder, // Single extruder printer preset is selected
51 MultiAsSingle, // Multiple extruder printer preset is selected, but
52 // this mode works just for Single extruder print
53 // (The same extruder is assigned to all ModelObjects and ModelVolumes).
54 MultiExtruder // Multiple extruder printer preset is selected
55};
@ Undef
Definition CustomGCode.hpp:49
@ MultiAsSingle
Definition CustomGCode.hpp:51
@ SingleExtruder
Definition CustomGCode.hpp:50
@ MultiExtruder
Definition CustomGCode.hpp:54

◆ Type

Enumerator
ColorChange 
PausePrint 
ToolChange 
Template 
Custom 
14{
19 Custom
20};
@ PausePrint
Definition CustomGCode.hpp:16
@ ToolChange
Definition CustomGCode.hpp:17
@ Template
Definition CustomGCode.hpp:18
@ Custom
Definition CustomGCode.hpp:19
@ ColorChange
Definition CustomGCode.hpp:15

Function Documentation

◆ check_mode_for_custom_gcode_per_print_z()

void Slic3r::CustomGCode::check_mode_for_custom_gcode_per_print_z ( Info info)
39{
40 if (info.mode != Undef)
41 return;
42
43 bool is_single_extruder = true;
44 for (const Item& item : info.gcodes)
45 {
46 if (item.type == ToolChange) {
47 info.mode = MultiAsSingle;
48 return;
49 }
50 if (item.type == ColorChange && item.extruder > 1)
51 is_single_extruder = false;
52 }
53
54 info.mode = is_single_extruder ? SingleExtruder : MultiExtruder;
55}
Mode mode
Definition CustomGCode.hpp:64
Definition CustomGCode.hpp:23

References ColorChange, Slic3r::CustomGCode::Info::gcodes, Slic3r::CustomGCode::Info::mode, MultiAsSingle, MultiExtruder, SingleExtruder, ToolChange, and Undef.

Referenced by Slic3r::Model::read_from_archive(), and Slic3r::Model::read_from_file().

+ Here is the caller graph for this function:

◆ custom_tool_changes()

std::vector< std::pair< double, unsigned int > > Slic3r::CustomGCode::custom_tool_changes ( const Info custom_gcode_per_print_z,
size_t  num_extruders 
)
60{
61 std::vector<std::pair<double, unsigned int>> custom_tool_changes;
62 for (const Item& custom_gcode : custom_gcode_per_print_z.gcodes)
63 if (custom_gcode.type == ToolChange) {
64 // If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders
65 assert(custom_gcode.extruder >= 0);
66 custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast<unsigned int>(size_t(custom_gcode.extruder) > num_extruders ? 1 : custom_gcode.extruder));
67 }
69}
if(!(yy_init))
Definition lexer.c:1190
std::vector< std::pair< double, unsigned int > > custom_tool_changes(const Info &custom_gcode_per_print_z, size_t num_extruders)
Definition CustomGCode.cpp:59

References custom_tool_changes(), Slic3r::CustomGCode::Info::gcodes, and ToolChange.

Referenced by Slic3r::ToolOrdering::ToolOrdering(), and custom_tool_changes().

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

◆ update_custom_gcode_per_print_z_from_config()

void Slic3r::CustomGCode::update_custom_gcode_per_print_z_from_config ( Info info,
DynamicPrintConfig config 
)
14{
15 auto *colorprint_heights = config->option<ConfigOptionFloats>("colorprint_heights");
16 if (colorprint_heights == nullptr)
17 return;
18 if (info.gcodes.empty() && ! colorprint_heights->values.empty()) {
19 // Convert the old colorprint_heighs only if there is no equivalent data in a new format.
20 const std::vector<std::string>& colors = ColorPrintColors::get();
21 const auto& colorprint_values = colorprint_heights->values;
22 info.gcodes.clear();
23 info.gcodes.reserve(colorprint_values.size());
24 int i = 0;
25 for (auto val : colorprint_values)
26 info.gcodes.emplace_back(Item{ val, ColorChange, 1, colors[(++i)%7] });
27
28 info.mode = SingleExtruder;
29 }
30
31 // The "colorprint_heights" config value has been deprecated. At this point of time it has been converted
32 // to a new format and therefore it shall be erased.
33 config->erase("colorprint_heights");
34}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2169
Definition Config.hpp:595
bool erase(const t_config_option_key &opt_key)
Definition Config.hpp:2405
std::vector< Item > gcodes
Definition CustomGCode.hpp:65

References ColorChange, Slic3r::CustomGCode::Info::gcodes, Slic3r::ColorPrintColors::get(), Slic3r::CustomGCode::Info::mode, Slic3r::ConfigBase::option(), and SingleExtruder.

Referenced by Slic3r::GUI::Plater::priv::load_files(), Slic3r::Model::read_from_archive(), and Slic3r::Model::read_from_file().

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

Variable Documentation

◆ MultiAsSingleMode

constexpr char Slic3r::CustomGCode::MultiAsSingleMode[] = "MultiAsSingle"
staticconstexpr

◆ MultiExtruderMode

constexpr char Slic3r::CustomGCode::MultiExtruderMode[] = "MultiExtruder"
staticconstexpr

◆ SingleExtruderMode

constexpr char Slic3r::CustomGCode::SingleExtruderMode[] = "SingleExtruder"
staticconstexpr