Refactored the Config XS bindings

This commit is contained in:
Alessandro Ranellucci 2015-12-16 12:33:19 +01:00
parent c73378744f
commit 3c862836f2
18 changed files with 104 additions and 194 deletions

View File

@ -186,6 +186,7 @@ sub thread_cleanup {
*Slic3r::Config::Print::DESTROY = sub {}; *Slic3r::Config::Print::DESTROY = sub {};
*Slic3r::Config::PrintObject::DESTROY = sub {}; *Slic3r::Config::PrintObject::DESTROY = sub {};
*Slic3r::Config::PrintRegion::DESTROY = sub {}; *Slic3r::Config::PrintRegion::DESTROY = sub {};
*Slic3r::Config::Static::DESTROY = sub {};
*Slic3r::ExPolygon::DESTROY = sub {}; *Slic3r::ExPolygon::DESTROY = sub {};
*Slic3r::ExPolygon::Collection::DESTROY = sub {}; *Slic3r::ExPolygon::Collection::DESTROY = sub {};
*Slic3r::Extruder::DESTROY = sub {}; *Slic3r::Extruder::DESTROY = sub {};

View File

@ -389,19 +389,13 @@ sub read_ini {
return $ini; return $ini;
} }
package Slic3r::Config::GCode; package Slic3r::Config::Static;
use parent 'Slic3r::Config'; use parent 'Slic3r::Config';
package Slic3r::Config::Print; sub Slic3r::Config::GCode::new { Slic3r::Config::Static::new_GCodeConfig }
use parent 'Slic3r::Config'; sub Slic3r::Config::Print::new { Slic3r::Config::Static::new_PrintConfig }
sub Slic3r::Config::PrintObject::new { Slic3r::Config::Static::new_PrintObjectConfig }
package Slic3r::Config::PrintObject; sub Slic3r::Config::PrintRegion::new { Slic3r::Config::Static::new_PrintRegionConfig }
use parent 'Slic3r::Config'; sub Slic3r::Config::Full::new { Slic3r::Config::Static::new_FullPrintConfig }
package Slic3r::Config::PrintRegion;
use parent 'Slic3r::Config';
package Slic3r::Config::Full;
use parent 'Slic3r::Config';
1; 1;

View File

@ -15,7 +15,7 @@ my @AXES = qw(X Y Z E);
sub apply_print_config { sub apply_print_config {
my ($self, $print_config) = @_; my ($self, $print_config) = @_;
$self->config->apply_print_config($print_config); $self->config->apply_static($print_config);
$self->_extrusion_axis($self->config->get_extrusion_axis); $self->_extrusion_axis($self->config->get_extrusion_axis);
} }

View File

@ -287,7 +287,7 @@ sub make_skirt {
$extruded_length[$extruder_idx] ||= 0; $extruded_length[$extruder_idx] ||= 0;
if (!$extruders_e_per_mm[$extruder_idx]) { if (!$extruders_e_per_mm[$extruder_idx]) {
my $config = Slic3r::Config::GCode->new; my $config = Slic3r::Config::GCode->new;
$config->apply_print_config($self->config); $config->apply_static($self->config);
my $extruder = Slic3r::Extruder->new($extruder_idx, $config); my $extruder = Slic3r::Extruder->new($extruder_idx, $config);
$extruders_e_per_mm[$extruder_idx] = $extruder->e_per_mm($mm3_per_mm); $extruders_e_per_mm[$extruder_idx] = $extruder->e_per_mm($mm3_per_mm);
} }

View File

@ -353,7 +353,7 @@ sub process_layer {
my $gcode = ""; my $gcode = "";
my $object = $layer->object; my $object = $layer->object;
$self->_gcodegen->config->apply_object_config($object->config); $self->_gcodegen->config->apply_static($object->config);
# check whether we're going to apply spiralvase logic # check whether we're going to apply spiralvase logic
if (defined $self->_spiral_vase) { if (defined $self->_spiral_vase) {
@ -594,7 +594,7 @@ sub _extrude_perimeters {
my $gcode = ""; my $gcode = "";
foreach my $region_id (sort keys %$entities_by_region) { foreach my $region_id (sort keys %$entities_by_region) {
$self->_gcodegen->config->apply_region_config($self->print->get_region($region_id)->config); $self->_gcodegen->config->apply_static($self->print->get_region($region_id)->config);
$gcode .= $self->_gcodegen->extrude($_, 'perimeter', -1) $gcode .= $self->_gcodegen->extrude($_, 'perimeter', -1)
for @{ $entities_by_region->{$region_id} }; for @{ $entities_by_region->{$region_id} };
} }
@ -606,7 +606,7 @@ sub _extrude_infill {
my $gcode = ""; my $gcode = "";
foreach my $region_id (sort keys %$entities_by_region) { foreach my $region_id (sort keys %$entities_by_region) {
$self->_gcodegen->config->apply_region_config($self->print->get_region($region_id)->config); $self->_gcodegen->config->apply_static($self->print->get_region($region_id)->config);
my $collection = Slic3r::ExtrusionPath::Collection->new(@{ $entities_by_region->{$region_id} }); my $collection = Slic3r::ExtrusionPath::Collection->new(@{ $entities_by_region->{$region_id} });
for my $fill (@{$collection->chained_path_from($self->_gcodegen->last_pos, 0)}) { for my $fill (@{$collection->chained_path_from($self->_gcodegen->last_pos, 0)}) {

View File

@ -208,6 +208,7 @@ for my $class (qw(
Slic3r::Config::Print Slic3r::Config::Print
Slic3r::Config::PrintObject Slic3r::Config::PrintObject
Slic3r::Config::PrintRegion Slic3r::Config::PrintRegion
Slic3r::Config::Static
Slic3r::ExPolygon Slic3r::ExPolygon
Slic3r::ExPolygon::Collection Slic3r::ExPolygon::Collection
Slic3r::Extruder Slic3r::Extruder

View File

@ -150,6 +150,16 @@ ConfigBase::setenv_()
#endif #endif
} }
const ConfigOption*
ConfigBase::option(const t_config_option_key &opt_key) const {
return const_cast<ConfigBase*>(this)->option(opt_key, false);
}
ConfigOption*
ConfigBase::option(const t_config_option_key &opt_key, bool create) {
return this->optptr(opt_key, create);
}
DynamicConfig& DynamicConfig::operator= (DynamicConfig other) DynamicConfig& DynamicConfig::operator= (DynamicConfig other)
{ {
this->swap(other); this->swap(other);
@ -175,7 +185,7 @@ DynamicConfig::DynamicConfig (const DynamicConfig& other) {
} }
ConfigOption* ConfigOption*
DynamicConfig::option(const t_config_option_key &opt_key, bool create) { DynamicConfig::optptr(const t_config_option_key &opt_key, bool create) {
if (this->options.count(opt_key) == 0) { if (this->options.count(opt_key) == 0) {
if (create) { if (create) {
const ConfigOptionDef* optdef = this->def->get(opt_key); const ConfigOptionDef* optdef = this->def->get(opt_key);
@ -231,11 +241,6 @@ template ConfigOptionBool* DynamicConfig::opt<ConfigOptionBool>(const t_config_o
template ConfigOptionBools* DynamicConfig::opt<ConfigOptionBools>(const t_config_option_key &opt_key, bool create); template ConfigOptionBools* DynamicConfig::opt<ConfigOptionBools>(const t_config_option_key &opt_key, bool create);
template ConfigOptionPercent* DynamicConfig::opt<ConfigOptionPercent>(const t_config_option_key &opt_key, bool create); template ConfigOptionPercent* DynamicConfig::opt<ConfigOptionPercent>(const t_config_option_key &opt_key, bool create);
const ConfigOption*
DynamicConfig::option(const t_config_option_key &opt_key) const {
return const_cast<DynamicConfig*>(this)->option(opt_key, false);
}
t_config_option_keys t_config_option_keys
DynamicConfig::keys() const { DynamicConfig::keys() const {
t_config_option_keys keys; t_config_option_keys keys;
@ -273,10 +278,4 @@ StaticConfig::keys() const {
return keys; return keys;
} }
const ConfigOption*
StaticConfig::option(const t_config_option_key &opt_key) const
{
return const_cast<StaticConfig*>(this)->option(opt_key, false);
}
} }

View File

@ -546,9 +546,11 @@ class ConfigBase
const ConfigDef* def; const ConfigDef* def;
ConfigBase() : def(NULL) {}; ConfigBase() : def(NULL) {};
virtual ~ConfigBase() {};
bool has(const t_config_option_key &opt_key); bool has(const t_config_option_key &opt_key);
virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; const ConfigOption* option(const t_config_option_key &opt_key) const;
virtual const ConfigOption* option(const t_config_option_key &opt_key) const = 0; ConfigOption* option(const t_config_option_key &opt_key, bool create = false);
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) = 0;
virtual t_config_option_keys keys() const = 0; virtual t_config_option_keys keys() const = 0;
void apply(const ConfigBase &other, bool ignore_nonexistent = false); void apply(const ConfigBase &other, bool ignore_nonexistent = false);
bool equals(ConfigBase &other); bool equals(ConfigBase &other);
@ -567,10 +569,9 @@ class DynamicConfig : public virtual ConfigBase
DynamicConfig(const DynamicConfig& other); DynamicConfig(const DynamicConfig& other);
DynamicConfig& operator= (DynamicConfig other); DynamicConfig& operator= (DynamicConfig other);
void swap(DynamicConfig &other); void swap(DynamicConfig &other);
~DynamicConfig(); virtual ~DynamicConfig();
template<class T> T* opt(const t_config_option_key &opt_key, bool create = false); template<class T> T* opt(const t_config_option_key &opt_key, bool create = false);
ConfigOption* option(const t_config_option_key &opt_key, bool create = false); virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false);
const ConfigOption* option(const t_config_option_key &opt_key) const;
t_config_option_keys keys() const; t_config_option_keys keys() const;
void erase(const t_config_option_key &opt_key); void erase(const t_config_option_key &opt_key);
@ -584,8 +585,7 @@ class StaticConfig : public virtual ConfigBase
public: public:
StaticConfig() : ConfigBase() {}; StaticConfig() : ConfigBase() {};
t_config_option_keys keys() const; t_config_option_keys keys() const;
virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; //virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) = 0;
const ConfigOption* option(const t_config_option_key &opt_key) const;
void set_defaults(); void set_defaults();
}; };

View File

@ -93,13 +93,13 @@ class DynamicPrintConfig : public PrintConfigBase, public DynamicConfig
void normalize(); void normalize();
}; };
class StaticPrintConfigBase : public PrintConfigBase, public StaticConfig class StaticPrintConfig : public PrintConfigBase, public StaticConfig
{ {
public: public:
StaticPrintConfigBase() : PrintConfigBase(), StaticConfig() {}; StaticPrintConfig() : PrintConfigBase(), StaticConfig() {};
}; };
class PrintObjectConfig : public virtual StaticPrintConfigBase class PrintObjectConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionBool dont_support_bridges; ConfigOptionBool dont_support_bridges;
@ -126,11 +126,11 @@ class PrintObjectConfig : public virtual StaticPrintConfigBase
ConfigOptionInt support_material_threshold; ConfigOptionInt support_material_threshold;
ConfigOptionFloat xy_size_compensation; ConfigOptionFloat xy_size_compensation;
PrintObjectConfig() : StaticPrintConfigBase() { PrintObjectConfig() : StaticPrintConfig() {
this->set_defaults(); this->set_defaults();
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(dont_support_bridges); OPT_PTR(dont_support_bridges);
OPT_PTR(extrusion_width); OPT_PTR(extrusion_width);
OPT_PTR(first_layer_height); OPT_PTR(first_layer_height);
@ -159,7 +159,7 @@ class PrintObjectConfig : public virtual StaticPrintConfigBase
}; };
}; };
class PrintRegionConfig : public virtual StaticPrintConfigBase class PrintRegionConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionInt bottom_solid_layers; ConfigOptionInt bottom_solid_layers;
@ -195,11 +195,11 @@ class PrintRegionConfig : public virtual StaticPrintConfigBase
ConfigOptionInt top_solid_layers; ConfigOptionInt top_solid_layers;
ConfigOptionFloatOrPercent top_solid_infill_speed; ConfigOptionFloatOrPercent top_solid_infill_speed;
PrintRegionConfig() : StaticPrintConfigBase() { PrintRegionConfig() : StaticPrintConfig() {
this->set_defaults(); this->set_defaults();
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(bottom_solid_layers); OPT_PTR(bottom_solid_layers);
OPT_PTR(bridge_flow_ratio); OPT_PTR(bridge_flow_ratio);
OPT_PTR(bridge_speed); OPT_PTR(bridge_speed);
@ -237,7 +237,7 @@ class PrintRegionConfig : public virtual StaticPrintConfigBase
}; };
}; };
class GCodeConfig : public virtual StaticPrintConfigBase class GCodeConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionString before_layer_gcode; ConfigOptionString before_layer_gcode;
@ -264,11 +264,11 @@ class GCodeConfig : public virtual StaticPrintConfigBase
ConfigOptionBool use_relative_e_distances; ConfigOptionBool use_relative_e_distances;
ConfigOptionBool use_volumetric_e; ConfigOptionBool use_volumetric_e;
GCodeConfig() : StaticPrintConfigBase() { GCodeConfig() : StaticPrintConfig() {
this->set_defaults(); this->set_defaults();
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(before_layer_gcode); OPT_PTR(before_layer_gcode);
OPT_PTR(end_gcode); OPT_PTR(end_gcode);
OPT_PTR(extrusion_axis); OPT_PTR(extrusion_axis);
@ -366,7 +366,7 @@ class PrintConfig : public GCodeConfig
this->set_defaults(); this->set_defaults();
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(avoid_crossing_perimeters); OPT_PTR(avoid_crossing_perimeters);
OPT_PTR(bed_shape); OPT_PTR(bed_shape);
OPT_PTR(bed_temperature); OPT_PTR(bed_temperature);
@ -420,13 +420,13 @@ class PrintConfig : public GCodeConfig
// look in parent class // look in parent class
ConfigOption* opt; ConfigOption* opt;
if ((opt = GCodeConfig::option(opt_key, create)) != NULL) return opt; if ((opt = GCodeConfig::optptr(opt_key, create)) != NULL) return opt;
return NULL; return NULL;
}; };
}; };
class HostConfig : public virtual StaticPrintConfigBase class HostConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionString octoprint_host; ConfigOptionString octoprint_host;
@ -434,11 +434,11 @@ class HostConfig : public virtual StaticPrintConfigBase
ConfigOptionString serial_port; ConfigOptionString serial_port;
ConfigOptionInt serial_speed; ConfigOptionInt serial_speed;
HostConfig() : StaticPrintConfigBase() { HostConfig() : StaticPrintConfig() {
this->set_defaults(); this->set_defaults();
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(octoprint_host); OPT_PTR(octoprint_host);
OPT_PTR(octoprint_apikey); OPT_PTR(octoprint_apikey);
OPT_PTR(serial_port); OPT_PTR(serial_port);
@ -452,12 +452,12 @@ class FullPrintConfig
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig : public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
{ {
public: public:
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
ConfigOption* opt; ConfigOption* opt;
if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt; if ((opt = PrintObjectConfig::optptr(opt_key, create)) != NULL) return opt;
if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt; if ((opt = PrintRegionConfig::optptr(opt_key, create)) != NULL) return opt;
if ((opt = PrintConfig::option(opt_key, create)) != NULL) return opt; if ((opt = PrintConfig::optptr(opt_key, create)) != NULL) return opt;
if ((opt = HostConfig::option(opt_key, create)) != NULL) return opt; if ((opt = HostConfig::optptr(opt_key, create)) != NULL) return opt;
return NULL; return NULL;
}; };
}; };

View File

@ -45,6 +45,7 @@ REGISTER_CLASS(Point3, "Point3");
REGISTER_CLASS(Pointf, "Pointf"); REGISTER_CLASS(Pointf, "Pointf");
REGISTER_CLASS(Pointf3, "Pointf3"); REGISTER_CLASS(Pointf3, "Pointf3");
REGISTER_CLASS(DynamicPrintConfig, "Config"); REGISTER_CLASS(DynamicPrintConfig, "Config");
REGISTER_CLASS(StaticPrintConfig, "Config::Static");
REGISTER_CLASS(PrintObjectConfig, "Config::PrintObject"); REGISTER_CLASS(PrintObjectConfig, "Config::PrintObject");
REGISTER_CLASS(PrintRegionConfig, "Config::PrintRegion"); REGISTER_CLASS(PrintRegionConfig, "Config::PrintRegion");
REGISTER_CLASS(GCodeConfig, "Config::GCode"); REGISTER_CLASS(GCodeConfig, "Config::GCode");

View File

@ -31,7 +31,7 @@
%code{% RETVAL = THIS->diff(*other); %}; %code{% RETVAL = THIS->diff(*other); %};
bool equals(DynamicPrintConfig* other) bool equals(DynamicPrintConfig* other)
%code{% RETVAL = THIS->equals(*other); %}; %code{% RETVAL = THIS->equals(*other); %};
void apply_static(FullPrintConfig* other) void apply_static(StaticPrintConfig* other)
%code{% THIS->apply(*other, true); %}; %code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys(); %name{get_keys} std::vector<std::string> keys();
void erase(t_config_option_key opt_key); void erase(t_config_option_key opt_key);
@ -40,9 +40,18 @@
double min_object_distance(); double min_object_distance();
}; };
%name{Slic3r::Config::GCode} class GCodeConfig { %name{Slic3r::Config::Static} class StaticPrintConfig {
GCodeConfig(); static StaticPrintConfig* new_GCodeConfig()
~GCodeConfig(); %code{% RETVAL = new GCodeConfig (); %};
static StaticPrintConfig* new_PrintConfig()
%code{% RETVAL = new PrintConfig (); %};
static StaticPrintConfig* new_PrintObjectConfig()
%code{% RETVAL = new PrintObjectConfig (); %};
static StaticPrintConfig* new_PrintRegionConfig()
%code{% RETVAL = new PrintRegionConfig (); %};
static StaticPrintConfig* new_FullPrintConfig()
%code{% RETVAL = new FullPrintConfig (); %};
~StaticPrintConfig();
bool has(t_config_option_key opt_key); bool has(t_config_option_key opt_key);
SV* as_hash() SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %}; %code{% RETVAL = ConfigBase__as_hash(THIS); %};
@ -60,129 +69,19 @@
double get_abs_value(t_config_option_key opt_key); double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over} %name{get_abs_value_over}
double get_abs_value(t_config_option_key opt_key, double ratio_over); double get_abs_value(t_config_option_key opt_key, double ratio_over);
void apply_print_config(PrintConfig* other) void apply_static(StaticPrintConfig* other)
%code{% THIS->apply(*other, true); %}; %code{% THIS->apply(*other, true); %};
void apply_dynamic(DynamicPrintConfig* other) void apply_dynamic(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %}; %code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys(); %name{get_keys} std::vector<std::string> keys();
std::string get_extrusion_axis(); std::string get_extrusion_axis()
%name{setenv} void setenv_(); %code{%
}; if (GCodeConfig* config = dynamic_cast<GCodeConfig*>(THIS)) {
RETVAL = config->get_extrusion_axis();
%name{Slic3r::Config::Print} class PrintConfig { } else {
PrintConfig(); CONFESS("This StaticConfig object does not provide get_extrusion_axis()");
~PrintConfig(); }
bool has(t_config_option_key opt_key); %};
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
SV* get(t_config_option_key opt_key)
%code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
SV* get_at(t_config_option_key opt_key, int i)
%code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
bool set(t_config_option_key opt_key, SV* value)
%code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
bool set_deserialize(t_config_option_key opt_key, SV* str)
%code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
%code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
double get_abs_value(t_config_option_key opt_key, double ratio_over);
void apply_dynamic(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys();
std::string get_extrusion_axis();
%name{setenv} void setenv_();
double min_object_distance();
};
%name{Slic3r::Config::PrintRegion} class PrintRegionConfig {
PrintRegionConfig();
~PrintRegionConfig();
bool has(t_config_option_key opt_key);
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
SV* get(t_config_option_key opt_key)
%code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
SV* get_at(t_config_option_key opt_key, int i)
%code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
bool set(t_config_option_key opt_key, SV* value)
%code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
bool set_deserialize(t_config_option_key opt_key, SV* str)
%code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
%code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
double get_abs_value(t_config_option_key opt_key, double ratio_over);
void apply(PrintRegionConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_dynamic(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys();
%name{setenv} void setenv_();
};
%name{Slic3r::Config::PrintObject} class PrintObjectConfig {
PrintObjectConfig();
~PrintObjectConfig();
bool has(t_config_option_key opt_key);
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
SV* get(t_config_option_key opt_key)
%code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
SV* get_at(t_config_option_key opt_key, int i)
%code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
bool set(t_config_option_key opt_key, SV* value)
%code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
bool set_deserialize(t_config_option_key opt_key, SV* str)
%code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
%code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
double get_abs_value(t_config_option_key opt_key, double ratio_over);
void apply(PrintObjectConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_dynamic(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys();
%name{setenv} void setenv_();
};
%name{Slic3r::Config::Full} class FullPrintConfig {
FullPrintConfig();
~FullPrintConfig();
bool has(t_config_option_key opt_key);
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
SV* get(t_config_option_key opt_key)
%code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
SV* get_at(t_config_option_key opt_key, int i)
%code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
bool set(t_config_option_key opt_key, SV* value)
%code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
bool set_deserialize(t_config_option_key opt_key, SV* str)
%code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
%code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
double get_abs_value(t_config_option_key opt_key, double ratio_over);
void apply_print_config(PrintConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_object_config(PrintObjectConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_region_config(PrintRegionConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_dynamic(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys();
std::string get_extrusion_axis();
%name{setenv} void setenv_(); %name{setenv} void setenv_();
double min_object_distance(); double min_object_distance();
}; };

View File

@ -6,7 +6,8 @@
%} %}
%name{Slic3r::Extruder} class Extruder { %name{Slic3r::Extruder} class Extruder {
Extruder(unsigned int id, GCodeConfig *config); Extruder(unsigned int id, StaticPrintConfig* config)
%code%{ RETVAL = new Extruder (id, dynamic_cast<GCodeConfig*>(config)); %};
~Extruder(); ~Extruder();
void reset(); void reset();
double extrude(double dE); double extrude(double dE);

View File

@ -77,7 +77,7 @@
Ref<Pointf> origin() Ref<Pointf> origin()
%code{% RETVAL = &(THIS->origin); %}; %code{% RETVAL = &(THIS->origin); %};
Ref<FullPrintConfig> config() Ref<StaticPrintConfig> config()
%code{% RETVAL = &(THIS->config); %}; %code{% RETVAL = &(THIS->config); %};
Ref<GCodeWriter> writer() Ref<GCodeWriter> writer()
@ -145,8 +145,14 @@
void set_volumetric_speed(double value) void set_volumetric_speed(double value)
%code{% THIS->volumetric_speed = value; %}; %code{% THIS->volumetric_speed = value; %};
void apply_print_config(PrintConfig* print_config) void apply_print_config(StaticPrintConfig* print_config)
%code{% THIS->apply_print_config(*print_config); %}; %code{%
if (const PrintConfig* config = dynamic_cast<PrintConfig*>(print_config)) {
THIS->apply_print_config(*config);
} else {
CONFESS("A PrintConfig object was not supplied to apply_print_config()");
}
%};
void set_extruders(std::vector<unsigned int> extruder_ids); void set_extruders(std::vector<unsigned int> extruder_ids);
void set_origin(Pointf* pointf) void set_origin(Pointf* pointf)
%code{% THIS->set_origin(*pointf); %}; %code{% THIS->set_origin(*pointf); %};

View File

@ -9,7 +9,7 @@
GCodeWriter(); GCodeWriter();
~GCodeWriter(); ~GCodeWriter();
Ref<GCodeConfig> config() Ref<StaticPrintConfig> config()
%code%{ RETVAL = &THIS->config; %}; %code%{ RETVAL = &THIS->config; %};
bool multiple_extruders() bool multiple_extruders()
%code{% RETVAL = THIS->multiple_extruders; %}; %code{% RETVAL = THIS->multiple_extruders; %};

View File

@ -7,11 +7,14 @@
%name{Slic3r::Layer::PerimeterGenerator} class PerimeterGenerator { %name{Slic3r::Layer::PerimeterGenerator} class PerimeterGenerator {
PerimeterGenerator(SurfaceCollection* slices, double layer_height, Flow* flow, PerimeterGenerator(SurfaceCollection* slices, double layer_height, Flow* flow,
PrintRegionConfig* config, PrintObjectConfig* object_config, StaticPrintConfig* region_config, StaticPrintConfig* object_config,
PrintConfig* print_config, ExtrusionEntityCollection* loops, StaticPrintConfig* print_config, ExtrusionEntityCollection* loops,
ExtrusionEntityCollection* gap_fill, SurfaceCollection* fill_surfaces) ExtrusionEntityCollection* gap_fill, SurfaceCollection* fill_surfaces)
%code{% RETVAL = new PerimeterGenerator(slices, layer_height, *flow, %code{% RETVAL = new PerimeterGenerator(slices, layer_height, *flow,
config, object_config, print_config, loops, gap_fill, fill_surfaces); %}; dynamic_cast<PrintRegionConfig*>(region_config),
dynamic_cast<PrintObjectConfig*>(object_config),
dynamic_cast<PrintConfig*>(print_config),
loops, gap_fill, fill_surfaces); %};
~PerimeterGenerator(); ~PerimeterGenerator();
void set_lower_slices(ExPolygonCollection* lower_slices) void set_lower_slices(ExPolygonCollection* lower_slices)
@ -27,7 +30,7 @@
void set_solid_infill_flow(Flow* flow) void set_solid_infill_flow(Flow* flow)
%code{% THIS->solid_infill_flow = *flow; %}; %code{% THIS->solid_infill_flow = *flow; %};
Ref<PrintRegionConfig> config() Ref<StaticPrintConfig> config()
%code{% RETVAL = THIS->config; %}; %code{% RETVAL = THIS->config; %};
void process(); void process();

View File

@ -30,7 +30,7 @@ _constant()
%name{Slic3r::Print::Region} class PrintRegion { %name{Slic3r::Print::Region} class PrintRegion {
// owned by Print, no constructor/destructor // owned by Print, no constructor/destructor
Ref<PrintRegionConfig> config() Ref<StaticPrintConfig> config()
%code%{ RETVAL = &THIS->config; %}; %code%{ RETVAL = &THIS->config; %};
Ref<Print> print(); Ref<Print> print();
@ -53,7 +53,7 @@ _constant()
Ref<Print> print(); Ref<Print> print();
Ref<ModelObject> model_object(); Ref<ModelObject> model_object();
Ref<PrintObjectConfig> config() Ref<StaticPrintConfig> config()
%code%{ RETVAL = &THIS->config; %}; %code%{ RETVAL = &THIS->config; %};
Points copies(); Points copies();
t_layer_height_ranges layer_height_ranges() t_layer_height_ranges layer_height_ranges()
@ -119,11 +119,11 @@ _constant()
Print(); Print();
~Print(); ~Print();
Ref<PrintConfig> config() Ref<StaticPrintConfig> config()
%code%{ RETVAL = &THIS->config; %}; %code%{ RETVAL = &THIS->config; %};
Ref<PrintObjectConfig> default_object_config() Ref<StaticPrintConfig> default_object_config()
%code%{ RETVAL = &THIS->default_object_config; %}; %code%{ RETVAL = &THIS->default_object_config; %};
Ref<PrintRegionConfig> default_region_config() Ref<StaticPrintConfig> default_region_config()
%code%{ RETVAL = &THIS->default_region_config; %}; %code%{ RETVAL = &THIS->default_region_config; %};
Ref<PlaceholderParser> placeholder_parser() Ref<PlaceholderParser> placeholder_parser()
%code%{ RETVAL = &THIS->placeholder_parser; %}; %code%{ RETVAL = &THIS->placeholder_parser; %};

View File

@ -32,6 +32,9 @@ Clone<BoundingBoxf3> O_OBJECT_SLIC3R_T
DynamicPrintConfig* O_OBJECT_SLIC3R DynamicPrintConfig* O_OBJECT_SLIC3R
Ref<DynamicPrintConfig> O_OBJECT_SLIC3R_T Ref<DynamicPrintConfig> O_OBJECT_SLIC3R_T
StaticPrintConfig* O_OBJECT_SLIC3R
Ref<StaticPrintConfig> O_OBJECT_SLIC3R_T
PrintObjectConfig* O_OBJECT_SLIC3R PrintObjectConfig* O_OBJECT_SLIC3R
Ref<PrintObjectConfig> O_OBJECT_SLIC3R_T Ref<PrintObjectConfig> O_OBJECT_SLIC3R_T

View File

@ -39,6 +39,8 @@
%typemap{Clone<BoundingBoxf3>}{simple}; %typemap{Clone<BoundingBoxf3>}{simple};
%typemap{DynamicPrintConfig*}; %typemap{DynamicPrintConfig*};
%typemap{Ref<DynamicPrintConfig>}{simple}; %typemap{Ref<DynamicPrintConfig>}{simple};
%typemap{StaticPrintConfig*};
%typemap{Ref<StaticPrintConfig>}{simple};
%typemap{PrintObjectConfig*}; %typemap{PrintObjectConfig*};
%typemap{Ref<PrintObjectConfig>}{simple}; %typemap{Ref<PrintObjectConfig>}{simple};
%typemap{PrintRegionConfig*}; %typemap{PrintRegionConfig*};