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

@ -31,7 +31,7 @@
%code{% RETVAL = THIS->diff(*other); %};
bool equals(DynamicPrintConfig* other)
%code{% RETVAL = THIS->equals(*other); %};
void apply_static(FullPrintConfig* other)
void apply_static(StaticPrintConfig* other)
%code{% THIS->apply(*other, true); %};
%name{get_keys} std::vector<std::string> keys();
void erase(t_config_option_key opt_key);
@ -40,9 +40,18 @@
double min_object_distance();
};
%name{Slic3r::Config::GCode} class GCodeConfig {
GCodeConfig();
~GCodeConfig();
%name{Slic3r::Config::Static} class StaticPrintConfig {
static StaticPrintConfig* new_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);
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
@ -60,129 +69,19 @@
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)
void apply_static(StaticPrintConfig* 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{Slic3r::Config::Print} class PrintConfig {
PrintConfig();
~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();
std::string get_extrusion_axis()
%code{%
if (GCodeConfig* config = dynamic_cast<GCodeConfig*>(THIS)) {
RETVAL = config->get_extrusion_axis();
} else {
CONFESS("This StaticConfig object does not provide get_extrusion_axis()");
}
%};
%name{setenv} void setenv_();
double min_object_distance();
};

View file

@ -6,7 +6,8 @@
%}
%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();
void reset();
double extrude(double dE);

View file

@ -77,7 +77,7 @@
Ref<Pointf> origin()
%code{% RETVAL = &(THIS->origin); %};
Ref<FullPrintConfig> config()
Ref<StaticPrintConfig> config()
%code{% RETVAL = &(THIS->config); %};
Ref<GCodeWriter> writer()
@ -145,8 +145,14 @@
void set_volumetric_speed(double value)
%code{% THIS->volumetric_speed = value; %};
void apply_print_config(PrintConfig* print_config)
%code{% THIS->apply_print_config(*print_config); %};
void apply_print_config(StaticPrintConfig* 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_origin(Pointf* pointf)
%code{% THIS->set_origin(*pointf); %};

View file

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

View file

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

View file

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

View file

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

View file

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