Satisfy test suite with new XS based config
This commit is contained in:
parent
9fb62e671f
commit
c0070a8d54
@ -905,13 +905,13 @@ sub write_gcode {
|
|||||||
$extruder->absolute_E, $extruder->extruded_volume/1000;
|
$extruder->absolute_E, $extruder->extruded_volume/1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Slic3r::Config->gcode_comments) {
|
if ($self->config->gcode_comments) {
|
||||||
# append full config
|
# append full config
|
||||||
print $fh "\n";
|
print $fh "\n";
|
||||||
foreach my $opt_key (sort keys %{$Slic3r::Config}) {
|
foreach my $opt_key (sort @{$self->config->get_keys}) {
|
||||||
next if $Slic3r::Config::Options->{$opt_key}{shortcut};
|
next if $Slic3r::Config::Options->{$opt_key}{shortcut};
|
||||||
next if $Slic3r::Config::Options->{$opt_key}{gui_only};
|
next if $Slic3r::Config::Options->{$opt_key}{gui_only};
|
||||||
printf $fh "; %s = %s\n", $opt_key, $Slic3r::Config->serialize($opt_key);
|
printf $fh "; %s = %s\n", $opt_key, $self->config->serialize($opt_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str)
|
|||||||
opt->deserialize(str);
|
opt->deserialize(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
double
|
||||||
ConfigBase::get_abs_value(const t_config_option_key opt_key) {
|
ConfigBase::get_abs_value(const t_config_option_key opt_key) {
|
||||||
// get option definition
|
// get option definition
|
||||||
assert(this->def->count(opt_key) != 0);
|
assert(this->def->count(opt_key) != 0);
|
||||||
@ -84,7 +84,7 @@ ConfigBase::get(t_config_option_key opt_key) {
|
|||||||
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
|
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
|
||||||
AV* av = newAV();
|
AV* av = newAV();
|
||||||
av_fill(av, optv->values.size()-1);
|
av_fill(av, optv->values.size()-1);
|
||||||
for (std::vector<float>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
|
for (std::vector<double>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
|
||||||
av_store(av, it - optv->values.begin(), newSVnv(*it));
|
av_store(av, it - optv->values.begin(), newSVnv(*it));
|
||||||
return newRV_noinc((SV*)av);
|
return newRV_noinc((SV*)av);
|
||||||
} else if (ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt)) {
|
} else if (ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt)) {
|
||||||
|
@ -46,11 +46,11 @@ class ConfigOptionFloat : public ConfigOption
|
|||||||
class ConfigOptionFloats : public ConfigOption
|
class ConfigOptionFloats : public ConfigOption
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<float> values;
|
std::vector<double> values;
|
||||||
|
|
||||||
std::string serialize() {
|
std::string serialize() {
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
for (std::vector<float>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
|
for (std::vector<double>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
|
||||||
if (it - this->values.begin() != 0) ss << ",";
|
if (it - this->values.begin() != 0) ss << ",";
|
||||||
ss << *it;
|
ss << *it;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ class ConfigOptionStrings : public ConfigOption
|
|||||||
class ConfigOptionFloatOrPercent : public ConfigOption
|
class ConfigOptionFloatOrPercent : public ConfigOption
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float value;
|
double value;
|
||||||
bool percent;
|
bool percent;
|
||||||
ConfigOptionFloatOrPercent() : value(0), percent(false) {};
|
ConfigOptionFloatOrPercent() : value(0), percent(false) {};
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ class ConfigOptionFloatOrPercent : public ConfigOption
|
|||||||
|
|
||||||
void deserialize(std::string str) {
|
void deserialize(std::string str) {
|
||||||
if (str.find_first_of("%") != std::string::npos) {
|
if (str.find_first_of("%") != std::string::npos) {
|
||||||
sscanf(str.c_str(), "%f%%", &this->value);
|
sscanf(str.c_str(), "%lf%%", &this->value);
|
||||||
this->percent = true;
|
this->percent = true;
|
||||||
} else {
|
} else {
|
||||||
this->value = ::atof(str.c_str());
|
this->value = ::atof(str.c_str());
|
||||||
@ -211,7 +211,7 @@ class ConfigOptionPoint : public ConfigOption
|
|||||||
};
|
};
|
||||||
|
|
||||||
void deserialize(std::string str) {
|
void deserialize(std::string str) {
|
||||||
sscanf(str.c_str(), "%f%*1[,x]%f", &this->point.x, &this->point.y);
|
sscanf(str.c_str(), "%lf%*1[,x]%lf", &this->point.x, &this->point.y);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ class ConfigOptionPoints : public ConfigOption
|
|||||||
std::string point_str;
|
std::string point_str;
|
||||||
while (std::getline(is, point_str, ',')) {
|
while (std::getline(is, point_str, ',')) {
|
||||||
Pointf point;
|
Pointf point;
|
||||||
sscanf(point_str.c_str(), "%fx%f", &point.x, &point.y);
|
sscanf(point_str.c_str(), "%lfx%lf", &point.x, &point.y);
|
||||||
this->points.push_back(point);
|
this->points.push_back(point);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -392,7 +392,7 @@ class ConfigBase
|
|||||||
void apply(ConfigBase &other, bool ignore_nonexistent = false);
|
void apply(ConfigBase &other, bool ignore_nonexistent = false);
|
||||||
std::string serialize(const t_config_option_key opt_key);
|
std::string serialize(const t_config_option_key opt_key);
|
||||||
void set_deserialize(const t_config_option_key opt_key, std::string str);
|
void set_deserialize(const t_config_option_key opt_key, std::string str);
|
||||||
float get_abs_value(const t_config_option_key opt_key);
|
double get_abs_value(const t_config_option_key opt_key);
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
SV* as_hash();
|
SV* as_hash();
|
||||||
|
@ -47,9 +47,9 @@ class Point
|
|||||||
class Pointf
|
class Pointf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float x;
|
double x;
|
||||||
float y;
|
double y;
|
||||||
explicit Pointf(float _x = 0, float _y = 0): x(_x), y(_y) {};
|
explicit Pointf(double _x = 0, double _y = 0): x(_x), y(_y) {};
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
void from_SV(SV* point_sv);
|
void from_SV(SV* point_sv);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
void set(t_config_option_key opt_key, SV* value);
|
void set(t_config_option_key opt_key, SV* value);
|
||||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||||
std::string serialize(t_config_option_key opt_key);
|
std::string serialize(t_config_option_key opt_key);
|
||||||
float get_abs_value(t_config_option_key opt_key);
|
double get_abs_value(t_config_option_key opt_key);
|
||||||
void apply(DynamicPrintConfig* other)
|
void apply(DynamicPrintConfig* other)
|
||||||
%code{% THIS->apply(*other, true); %};
|
%code{% THIS->apply(*other, true); %};
|
||||||
void apply_static(PrintConfig* other)
|
void apply_static(PrintConfig* other)
|
||||||
@ -35,7 +35,7 @@
|
|||||||
void set(t_config_option_key opt_key, SV* value);
|
void set(t_config_option_key opt_key, SV* value);
|
||||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||||
std::string serialize(t_config_option_key opt_key);
|
std::string serialize(t_config_option_key opt_key);
|
||||||
float get_abs_value(t_config_option_key opt_key);
|
double get_abs_value(t_config_option_key opt_key);
|
||||||
void apply_dynamic(DynamicPrintConfig* other)
|
void apply_dynamic(DynamicPrintConfig* other)
|
||||||
%code{% THIS->apply(*other, true); %};
|
%code{% THIS->apply(*other, true); %};
|
||||||
std::vector<std::string> get_keys()
|
std::vector<std::string> get_keys()
|
||||||
|
Loading…
Reference in New Issue
Block a user