mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-01 21:21:10 -06:00
More work
This commit is contained in:
parent
0883d0f4eb
commit
e2f1040a76
11 changed files with 126 additions and 56 deletions
|
|
@ -956,7 +956,6 @@ class PrintObjectConfig : public virtual StaticConfig
|
|||
if (opt_key == "support_material_speed") return &this->support_material_speed;
|
||||
if (opt_key == "support_material_threshold") return &this->support_material_threshold;
|
||||
|
||||
if (create) throw "Attempt to create non-existing option in StaticConfig object";
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
|
@ -1039,7 +1038,6 @@ class PrintRegionConfig : public virtual StaticConfig
|
|||
if (opt_key == "top_infill_extrusion_width") return &this->top_infill_extrusion_width;
|
||||
if (opt_key == "top_solid_layers") return &this->top_solid_layers;
|
||||
|
||||
if (create) throw "Attempt to create non-existing option in StaticConfig object";
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
|
@ -1332,7 +1330,6 @@ class PrintConfig : public virtual StaticConfig
|
|||
if (opt_key == "wipe") return &this->wipe;
|
||||
if (opt_key == "z_offset") return &this->z_offset;
|
||||
|
||||
if (create) throw "Attempt to create non-existing option in StaticConfig object";
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
|
@ -1345,7 +1342,15 @@ class DynamicPrintConfig : public DynamicConfig
|
|||
};
|
||||
};
|
||||
|
||||
class FullPrintConfig : public PrintObjectConfig, public PrintRegionConfig, public PrintConfig {};
|
||||
class FullPrintConfig : public PrintObjectConfig, public PrintRegionConfig, public PrintConfig {
|
||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
||||
ConfigOption* opt;
|
||||
if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintConfig::option(opt_key, create)) != NULL) return opt;
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use warnings;
|
|||
use Slic3r::XS;
|
||||
use Test::More tests => 79;
|
||||
|
||||
foreach my $config (Slic3r::Config->new, Slic3r::Config::Print->new) {
|
||||
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
||||
$config->set('layer_height', 0.3);
|
||||
ok abs($config->get('layer_height') - 0.3) < 1e-4, 'set/get float';
|
||||
is $config->serialize('layer_height'), '0.3', 'serialize float';
|
||||
|
|
@ -94,13 +94,13 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Print->new) {
|
|||
# test that no crash happens when using set_deserialize() with a key that hasn't been set() yet
|
||||
$config->set_deserialize('filament_diameter', '3');
|
||||
|
||||
my $config2 = Slic3r::Config::Print->new;
|
||||
my $config2 = Slic3r::Config::Full->new;
|
||||
$config2->apply_dynamic($config);
|
||||
is $config2->get('perimeters'), 2, 'apply_dynamic';
|
||||
}
|
||||
|
||||
{
|
||||
my $config = Slic3r::Config::Print->new;
|
||||
my $config = Slic3r::Config::Full->new;
|
||||
my $config2 = Slic3r::Config->new;
|
||||
$config2->apply_static($config);
|
||||
is $config2->get('perimeters'), Slic3r::Config::print_config_def()->{perimeters}{default}, 'apply_static and print_config_def';
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@
|
|||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
%name{get_abs_value_over}
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
void apply(DynamicPrintConfig* other)
|
||||
%code{% THIS->apply(*other, true); %};
|
||||
void apply_static(PrintConfig* other)
|
||||
|
|
@ -34,16 +35,17 @@
|
|||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
%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); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Print} class PrintConfig {
|
||||
PrintConfig();
|
||||
~PrintConfig();
|
||||
%name{Slic3r::Config::PrintRegion} class PrintRegionConfig {
|
||||
PrintRegionConfig();
|
||||
~PrintRegionConfig();
|
||||
bool has(t_config_option_key opt_key);
|
||||
SV* as_hash();
|
||||
SV* get(t_config_option_key opt_key);
|
||||
|
|
@ -51,16 +53,19 @@
|
|||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
%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); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Print} class PrintConfig {
|
||||
PrintConfig();
|
||||
~PrintConfig();
|
||||
%name{Slic3r::Config::PrintObject} class PrintObjectConfig {
|
||||
PrintObjectConfig();
|
||||
~PrintObjectConfig();
|
||||
bool has(t_config_option_key opt_key);
|
||||
SV* as_hash();
|
||||
SV* get(t_config_option_key opt_key);
|
||||
|
|
@ -68,7 +73,30 @@
|
|||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
%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); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Full} class FullPrintConfig {
|
||||
FullPrintConfig();
|
||||
~FullPrintConfig();
|
||||
bool has(t_config_option_key opt_key);
|
||||
SV* as_hash();
|
||||
SV* get(t_config_option_key opt_key);
|
||||
void set(t_config_option_key opt_key, SV* value);
|
||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
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); %};
|
||||
std::vector<std::string> get_keys()
|
||||
|
|
@ -83,7 +111,8 @@ PROTOTYPES: DISABLE
|
|||
SV*
|
||||
print_config_def()
|
||||
CODE:
|
||||
t_optiondef_map* def = &PrintConfigDef::def;
|
||||
FullPrintConfig config;
|
||||
t_optiondef_map* def = config.def;
|
||||
|
||||
HV* options_hv = newHV();
|
||||
for (t_optiondef_map::iterator oit = def->begin(); oit != def->end(); ++oit) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ std::vector<Points::size_type> T_STD_VECTOR_INT
|
|||
t_config_option_key T_STD_STRING
|
||||
|
||||
DynamicPrintConfig* O_OBJECT
|
||||
PrintObjectConfig* O_OBJECT
|
||||
PrintRegionConfig* O_OBJECT
|
||||
PrintConfig* O_OBJECT
|
||||
FullPrintConfig* O_OBJECT
|
||||
ZTable* O_OBJECT
|
||||
TriangleMesh* O_OBJECT
|
||||
Point* O_OBJECT
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@
|
|||
%typemap{AV*};
|
||||
%typemap{Point*};
|
||||
%typemap{DynamicPrintConfig*};
|
||||
%typemap{PrintObjectConfig*};
|
||||
%typemap{PrintRegionConfig*};
|
||||
%typemap{PrintConfig*};
|
||||
%typemap{FullPrintConfig*};
|
||||
%typemap{ExPolygon*};
|
||||
%typemap{ExPolygonCollection*};
|
||||
%typemap{Line*};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue