5
#include "PrintConfig.hpp"
8
%name{Slic3r::Config} class DynamicPrintConfig {
10
~DynamicPrintConfig();
11
bool has(t_config_option_key opt_key);
13
SV* get(t_config_option_key opt_key);
14
SV* get_at(t_config_option_key opt_key, int i);
15
bool set(t_config_option_key opt_key, SV* value);
16
bool set_deserialize(t_config_option_key opt_key, SV* str);
17
std::string serialize(t_config_option_key opt_key);
18
double get_abs_value(t_config_option_key opt_key);
19
%name{get_abs_value_over}
20
double get_abs_value(t_config_option_key opt_key, double ratio_over);
21
void apply(DynamicPrintConfig* other)
22
%code{% THIS->apply(*other, true); %};
23
void apply_static(FullPrintConfig* other)
24
%code{% THIS->apply(*other, true); %};
25
std::vector<std::string> get_keys()
26
%code{% THIS->keys(&RETVAL); %};
27
void erase(t_config_option_key opt_key);
31
%name{Slic3r::Config::Print} class PrintConfig {
34
bool has(t_config_option_key opt_key);
36
SV* get(t_config_option_key opt_key);
37
SV* get_at(t_config_option_key opt_key, int i);
38
bool set(t_config_option_key opt_key, SV* value);
39
bool set_deserialize(t_config_option_key opt_key, SV* str);
40
std::string serialize(t_config_option_key opt_key);
41
double get_abs_value(t_config_option_key opt_key);
42
%name{get_abs_value_over}
43
double get_abs_value(t_config_option_key opt_key, double ratio_over);
44
void apply_dynamic(DynamicPrintConfig* other)
45
%code{% THIS->apply(*other, true); %};
46
std::vector<std::string> get_keys()
47
%code{% THIS->keys(&RETVAL); %};
50
%name{Slic3r::Config::PrintRegion} class PrintRegionConfig {
53
bool has(t_config_option_key opt_key);
55
SV* get(t_config_option_key opt_key);
56
SV* get_at(t_config_option_key opt_key, int i);
57
bool set(t_config_option_key opt_key, SV* value);
58
bool set_deserialize(t_config_option_key opt_key, SV* str);
59
std::string serialize(t_config_option_key opt_key);
60
double get_abs_value(t_config_option_key opt_key);
61
%name{get_abs_value_over}
62
double get_abs_value(t_config_option_key opt_key, double ratio_over);
63
void apply(PrintRegionConfig* other)
64
%code{% THIS->apply(*other, true); %};
65
void apply_dynamic(DynamicPrintConfig* other)
66
%code{% THIS->apply(*other, true); %};
67
std::vector<std::string> get_keys()
68
%code{% THIS->keys(&RETVAL); %};
71
%name{Slic3r::Config::PrintObject} class PrintObjectConfig {
74
bool has(t_config_option_key opt_key);
76
SV* get(t_config_option_key opt_key);
77
SV* get_at(t_config_option_key opt_key, int i);
78
bool set(t_config_option_key opt_key, SV* value);
79
bool set_deserialize(t_config_option_key opt_key, SV* str);
80
std::string serialize(t_config_option_key opt_key);
81
double get_abs_value(t_config_option_key opt_key);
82
%name{get_abs_value_over}
83
double get_abs_value(t_config_option_key opt_key, double ratio_over);
84
void apply(PrintObjectConfig* other)
85
%code{% THIS->apply(*other, true); %};
86
void apply_dynamic(DynamicPrintConfig* other)
87
%code{% THIS->apply(*other, true); %};
88
std::vector<std::string> get_keys()
89
%code{% THIS->keys(&RETVAL); %};
92
%name{Slic3r::Config::Full} class FullPrintConfig {
95
bool has(t_config_option_key opt_key);
97
SV* get(t_config_option_key opt_key);
98
SV* get_at(t_config_option_key opt_key, int i);
99
bool set(t_config_option_key opt_key, SV* value);
100
bool set_deserialize(t_config_option_key opt_key, SV* str);
101
std::string serialize(t_config_option_key opt_key);
102
double get_abs_value(t_config_option_key opt_key);
103
%name{get_abs_value_over}
104
double get_abs_value(t_config_option_key opt_key, double ratio_over);
105
void apply_print_config(PrintConfig* other)
106
%code{% THIS->apply(*other, true); %};
107
void apply_object_config(PrintObjectConfig* other)
108
%code{% THIS->apply(*other, true); %};
109
void apply_region_config(PrintRegionConfig* other)
110
%code{% THIS->apply(*other, true); %};
111
void apply_dynamic(DynamicPrintConfig* other)
112
%code{% THIS->apply(*other, true); %};
113
std::vector<std::string> get_keys()
114
%code{% THIS->keys(&RETVAL); %};
115
std::string get_extrusion_axis();
118
%package{Slic3r::Config};
126
FullPrintConfig config;
127
t_optiondef_map* def = config.def;
129
HV* options_hv = newHV();
130
for (t_optiondef_map::iterator oit = def->begin(); oit != def->end(); ++oit) {
133
t_config_option_key opt_key = oit->first;
134
ConfigOptionDef* optdef = &oit->second;
136
const char* opt_type;
137
if (optdef->type == coFloat || optdef->type == coFloats || optdef->type == coFloatOrPercent) {
139
} else if (optdef->type == coPercent) {
140
opt_type = "percent";
141
} else if (optdef->type == coInt || optdef->type == coInts) {
143
} else if (optdef->type == coString) {
145
} else if (optdef->type == coStrings) {
147
} else if (optdef->type == coPoint || optdef->type == coPoints) {
149
} else if (optdef->type == coBool || optdef->type == coBools) {
151
} else if (optdef->type == coEnum) {
154
throw "Unknown option type";
156
(void)hv_stores( hv, "type", newSVpv(opt_type, 0) );
157
(void)hv_stores( hv, "label", newSVpvn_utf8(optdef->label.c_str(), optdef->label.length(), true) );
158
if (!optdef->full_label.empty())
159
(void)hv_stores( hv, "full_label", newSVpvn_utf8(optdef->full_label.c_str(), optdef->full_label.length(), true) );
160
(void)hv_stores( hv, "category", newSVpvn(optdef->category.c_str(), optdef->category.length()) );
161
(void)hv_stores( hv, "tooltip", newSVpvn_utf8(optdef->tooltip.c_str(), optdef->tooltip.length(), true) );
162
(void)hv_stores( hv, "sidetext", newSVpvn_utf8(optdef->sidetext.c_str(), optdef->sidetext.length(), true) );
163
(void)hv_stores( hv, "cli", newSVpvn(optdef->cli.c_str(), optdef->cli.length()) );
164
(void)hv_stores( hv, "ratio_over", newSVpvn(optdef->ratio_over.c_str(), optdef->ratio_over.length()) );
165
(void)hv_stores( hv, "multiline", newSViv(optdef->multiline ? 1 : 0) );
166
(void)hv_stores( hv, "full_width", newSViv(optdef->full_width ? 1 : 0) );
167
(void)hv_stores( hv, "readonly", newSViv(optdef->readonly ? 1 : 0) );
168
(void)hv_stores( hv, "height", newSViv(optdef->height) );
169
(void)hv_stores( hv, "width", newSViv(optdef->width) );
170
(void)hv_stores( hv, "min", newSViv(optdef->min) );
171
(void)hv_stores( hv, "max", newSViv(optdef->max) );
174
if (!optdef->aliases.empty()) {
176
av_fill(av, optdef->aliases.size()-1);
177
for (std::vector<t_config_option_key>::iterator it = optdef->aliases.begin(); it != optdef->aliases.end(); ++it)
178
av_store(av, it - optdef->aliases.begin(), newSVpvn(it->c_str(), it->length()));
179
(void)hv_stores( hv, "aliases", newRV_noinc((SV*)av) );
183
if (!optdef->shortcut.empty()) {
185
av_fill(av, optdef->shortcut.size()-1);
186
for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it)
187
av_store(av, it - optdef->shortcut.begin(), newSVpvn(it->c_str(), it->length()));
188
(void)hv_stores( hv, "shortcut", newRV_noinc((SV*)av) );
192
if (!optdef->enum_values.empty()) {
194
av_fill(av, optdef->enum_values.size()-1);
195
for (std::vector<std::string>::iterator it = optdef->enum_values.begin(); it != optdef->enum_values.end(); ++it)
196
av_store(av, it - optdef->enum_values.begin(), newSVpvn(it->c_str(), it->length()));
197
(void)hv_stores( hv, "values", newRV_noinc((SV*)av) );
201
if (!optdef->enum_labels.empty()) {
203
av_fill(av, optdef->enum_labels.size()-1);
204
for (std::vector<std::string>::iterator it = optdef->enum_labels.begin(); it != optdef->enum_labels.end(); ++it)
205
av_store(av, it - optdef->enum_labels.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
206
(void)hv_stores( hv, "labels", newRV_noinc((SV*)av) );
209
(void)hv_stores( hv, "default", config.get(opt_key) );
210
(void)hv_store( options_hv, opt_key.c_str(), opt_key.length(), newRV_noinc((SV*)hv), 0 );
213
RETVAL = newRV_noinc((SV*)options_hv);