mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
Renamed the "compatible_printers_condition" and "inherits" vectors
to "compatible_printers_condition_cummulative" and "inherits_cummulative" when storing to AMF/3MF/Config files. Improved escaping of strings stored / loaded from config files.
This commit is contained in:
parent
80b430ad94
commit
26b003073b
8 changed files with 76 additions and 84 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
// Escape \n, \r and \\
|
||||
std::string escape_string_cstyle(const std::string &str)
|
||||
{
|
||||
// Allocate a buffer twice the input string length,
|
||||
|
@ -28,9 +29,15 @@ std::string escape_string_cstyle(const std::string &str)
|
|||
char *outptr = out.data();
|
||||
for (size_t i = 0; i < str.size(); ++ i) {
|
||||
char c = str[i];
|
||||
if (c == '\n' || c == '\r') {
|
||||
if (c == '\r') {
|
||||
(*outptr ++) = '\\';
|
||||
(*outptr ++) = 'r';
|
||||
} else if (c == '\n') {
|
||||
(*outptr ++) = '\\';
|
||||
(*outptr ++) = 'n';
|
||||
} else if (c == '\\') {
|
||||
(*outptr ++) = '\\';
|
||||
(*outptr ++) = '\\';
|
||||
} else
|
||||
(*outptr ++) = c;
|
||||
}
|
||||
|
@ -69,7 +76,10 @@ std::string escape_strings_cstyle(const std::vector<std::string> &strs)
|
|||
if (c == '\\' || c == '"') {
|
||||
(*outptr ++) = '\\';
|
||||
(*outptr ++) = c;
|
||||
} else if (c == '\n' || c == '\r') {
|
||||
} else if (c == '\r') {
|
||||
(*outptr ++) = '\\';
|
||||
(*outptr ++) = 'r';
|
||||
} else if (c == '\n') {
|
||||
(*outptr ++) = '\\';
|
||||
(*outptr ++) = 'n';
|
||||
} else
|
||||
|
@ -84,6 +94,7 @@ std::string escape_strings_cstyle(const std::vector<std::string> &strs)
|
|||
return std::string(out.data(), outptr - out.data());
|
||||
}
|
||||
|
||||
// Unescape \n, \r and \\
|
||||
bool unescape_string_cstyle(const std::string &str, std::string &str_out)
|
||||
{
|
||||
std::vector<char> out(str.size(), 0);
|
||||
|
@ -94,8 +105,12 @@ bool unescape_string_cstyle(const std::string &str, std::string &str_out)
|
|||
if (++ i == str.size())
|
||||
return false;
|
||||
c = str[i];
|
||||
if (c == 'n')
|
||||
if (c == 'r')
|
||||
(*outptr ++) = '\r';
|
||||
else if (c == 'n')
|
||||
(*outptr ++) = '\n';
|
||||
else
|
||||
(*outptr ++) = c;
|
||||
} else
|
||||
(*outptr ++) = c;
|
||||
}
|
||||
|
@ -134,7 +149,9 @@ bool unescape_strings_cstyle(const std::string &str, std::vector<std::string> &o
|
|||
if (++ i == str.size())
|
||||
return false;
|
||||
c = str[i];
|
||||
if (c == 'n')
|
||||
if (c == 'r')
|
||||
c = '\r';
|
||||
else if (c == 'n')
|
||||
c = '\n';
|
||||
}
|
||||
buf.push_back(c);
|
||||
|
|
|
@ -1422,7 +1422,7 @@ void GCode::append_full_config(const Print& print, std::string& str)
|
|||
for (const char *key : {
|
||||
"print_settings_id", "filament_settings_id", "printer_settings_id",
|
||||
"printer_model", "printer_variant", "default_print_profile", "default_filament_profile",
|
||||
"compatible_printers_condition", "inherits" }) {
|
||||
"compatible_printers_condition_cummulative", "inherits_cummulative" }) {
|
||||
const ConfigOption *opt = full_config.option(key);
|
||||
if (opt != nullptr)
|
||||
str += std::string("; ") + key + " = " + opt->serialize() + "\n";
|
||||
|
|
|
@ -147,15 +147,17 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->label = L("Compatible printers");
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
|
||||
// The following value is defined as a vector of strings, so it could
|
||||
// collect the "inherits" values over the print and filaments profiles
|
||||
// when storing into a project file (AMF, 3MF, Config ...)
|
||||
def = this->add("compatible_printers_condition", coStrings);
|
||||
def = this->add("compatible_printers_condition", coString);
|
||||
def->label = L("Compatible printers condition");
|
||||
def->tooltip = L("A boolean expression using the configuration values of an active printer profile. "
|
||||
"If this expression evaluates to true, this profile is considered compatible "
|
||||
"with the active printer profile.");
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
def->default_value = new ConfigOptionString();
|
||||
|
||||
// The following value is to be stored into the project file (AMF, 3MF, Config ...)
|
||||
// and it contains a sum of "compatible_printers_condition" values over the print and filament profiles.
|
||||
def = this->add("compatible_printers_condition_cummulative", coStrings);
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
|
||||
def = this->add("complete_objects", coBool);
|
||||
def->label = L("Complete individual objects");
|
||||
|
@ -822,15 +824,17 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->min = 0;
|
||||
def->default_value = new ConfigOptionFloat(80);
|
||||
|
||||
// The following value is defined as a vector of strings, so it could
|
||||
// collect the "inherits" values over the print and filaments profiles
|
||||
// when storing into a project file (AMF, 3MF, Config ...)
|
||||
def = this->add("inherits", coStrings);
|
||||
def = this->add("inherits", coString);
|
||||
def->label = L("Inherits profile");
|
||||
def->tooltip = L("Name of the profile, from which this profile inherits.");
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
def->default_value = new ConfigOptionString();
|
||||
|
||||
// The following value is to be stored into the project file (AMF, 3MF, Config ...)
|
||||
// and it contains a sum of "inherits" values over the print and filament profiles.
|
||||
def = this->add("inherits_cummulative", coStrings);
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
|
||||
def = this->add("interface_shells", coBool);
|
||||
def->label = L("Interface shells");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue