mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 10:25:59 +08:00
Print & printer custom variables are now scalar and not arrays.
This commit is contained in:
parent
f85b5992be
commit
c680aff561
@ -1496,6 +1496,9 @@ bool PlaceholderParser::evaluate_boolean_expression(const std::string &templ, co
|
|||||||
|
|
||||||
|
|
||||||
void PlaceholderParser::append_custom_variables(std::map<std::string, std::vector<std::string>> name2var_array, int nb_extruders) {
|
void PlaceholderParser::append_custom_variables(std::map<std::string, std::vector<std::string>> name2var_array, int nb_extruders) {
|
||||||
|
|
||||||
|
bool is_array = nb_extruders > 0;
|
||||||
|
if (!is_array) nb_extruders = 1;
|
||||||
std::regex is_a_name("[a-zA-Z_]+");
|
std::regex is_a_name("[a-zA-Z_]+");
|
||||||
for (const auto& entry : name2var_array) {
|
for (const auto& entry : name2var_array) {
|
||||||
if (entry.first.empty())
|
if (entry.first.empty())
|
||||||
@ -1575,17 +1578,27 @@ void PlaceholderParser::append_custom_variables(std::map<std::string, std::vecto
|
|||||||
log << "Parsing NUM custom variable '" << entry.first << "' : ";
|
log << "Parsing NUM custom variable '" << entry.first << "' : ";
|
||||||
for (auto s : double_values) log << ", " << s;
|
for (auto s : double_values) log << ", " << s;
|
||||||
BOOST_LOG_TRIVIAL(trace) << log.str();
|
BOOST_LOG_TRIVIAL(trace) << log.str();
|
||||||
|
if (is_array) {
|
||||||
ConfigOptionFloats* conf = new ConfigOptionFloats(double_values);
|
ConfigOptionFloats* conf = new ConfigOptionFloats(double_values);
|
||||||
conf->set_is_extruder_size(true);
|
conf->set_is_extruder_size(true);
|
||||||
this->set(entry.first, conf);
|
this->set(entry.first, conf);
|
||||||
|
} else {
|
||||||
|
ConfigOptionFloat* conf = new ConfigOptionFloat(double_values[0]);
|
||||||
|
this->set(entry.first, conf);
|
||||||
|
}
|
||||||
} else if (!is_not_bool) {
|
} else if (!is_not_bool) {
|
||||||
std::stringstream log;
|
std::stringstream log;
|
||||||
log << "Parsing BOOL custom variable '" << entry.first << "' : ";
|
log << "Parsing BOOL custom variable '" << entry.first << "' : ";
|
||||||
for (auto s : bool_values) log << ", " << s;
|
for (auto s : bool_values) log << ", " << s;
|
||||||
BOOST_LOG_TRIVIAL(trace) << log.str();
|
BOOST_LOG_TRIVIAL(trace) << log.str();
|
||||||
|
if (is_array) {
|
||||||
ConfigOptionBools* conf = new ConfigOptionBools(bool_values);
|
ConfigOptionBools* conf = new ConfigOptionBools(bool_values);
|
||||||
conf->set_is_extruder_size(true);
|
conf->set_is_extruder_size(true);
|
||||||
this->set(entry.first, conf);
|
this->set(entry.first, conf);
|
||||||
|
} else {
|
||||||
|
ConfigOptionBool* conf = new ConfigOptionBool(bool_values[0]);
|
||||||
|
this->set(entry.first, conf);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (std::string& s : string_values)
|
for (std::string& s : string_values)
|
||||||
boost::replace_all(s, "\\n", "\n");
|
boost::replace_all(s, "\\n", "\n");
|
||||||
@ -1593,9 +1606,14 @@ void PlaceholderParser::append_custom_variables(std::map<std::string, std::vecto
|
|||||||
log << "Parsing STR custom variable '" << entry.first << "' : ";
|
log << "Parsing STR custom variable '" << entry.first << "' : ";
|
||||||
for (auto s : string_values) log << ", " << s;
|
for (auto s : string_values) log << ", " << s;
|
||||||
BOOST_LOG_TRIVIAL(trace) << log.str();
|
BOOST_LOG_TRIVIAL(trace) << log.str();
|
||||||
|
if (is_array) {
|
||||||
ConfigOptionStrings* conf = new ConfigOptionStrings(string_values);
|
ConfigOptionStrings* conf = new ConfigOptionStrings(string_values);
|
||||||
conf->set_is_extruder_size(true);
|
conf->set_is_extruder_size(true);
|
||||||
this->set(entry.first, conf);
|
this->set(entry.first, conf);
|
||||||
|
} else {
|
||||||
|
ConfigOptionString* conf = new ConfigOptionString(string_values[0]);
|
||||||
|
this->set(entry.first, conf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1623,7 +1641,7 @@ void PlaceholderParser::parse_custom_variables(const ConfigOptionString& custom_
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
append_custom_variables(name2var_array, 1);
|
append_custom_variables(name2var_array, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaceholderParser::parse_custom_variables(const ConfigOptionStrings& filament_custom_variables)
|
void PlaceholderParser::parse_custom_variables(const ConfigOptionStrings& filament_custom_variables)
|
||||||
|
@ -898,7 +898,7 @@ const std::vector<std::string>& Preset::sla_printer_options()
|
|||||||
"min_initial_exposure_time", "max_initial_exposure_time",
|
"min_initial_exposure_time", "max_initial_exposure_time",
|
||||||
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
|
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
|
||||||
"print_host", "printhost_apikey", "printhost_cafile", "printhost_port",
|
"print_host", "printhost_apikey", "printhost_cafile", "printhost_port",
|
||||||
"printer_custom_variables",
|
"printer_notes",
|
||||||
"inherits",
|
"inherits",
|
||||||
"thumbnails",
|
"thumbnails",
|
||||||
"thumbnails_color",
|
"thumbnails_color",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user