Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Config.xsp « xsp « xs - github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a9de4f49f86d3b8c97a2a300b6001fcafd3c1f2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
%module{Slic3r::XS};

%{
#include <xsinit.h>
#include "libslic3r/PrintConfig.hpp"
%}

%name{Slic3r::Config} class DynamicPrintConfig {
    DynamicPrintConfig();
    ~DynamicPrintConfig();
    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 = ConfigBase__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(DynamicPrintConfig* other)
        %code{% THIS->apply(*other, true); %};
    std::vector<std::string> diff(DynamicPrintConfig* other)
        %code{% RETVAL = THIS->diff(*other); %};
    bool equals(DynamicPrintConfig* other)
        %code{% RETVAL = THIS->equals(*other); %};
    void apply_static(FullPrintConfig* other)
        %code{% THIS->apply(*other, true); %};
    %name{get_keys} std::vector<std::string> keys();
    void erase(t_config_option_key opt_key);
    void normalize();
    %name{setenv} void setenv_();
    double min_object_distance();
};

%name{Slic3r::Config::GCode} class GCodeConfig {
    GCodeConfig();
    ~GCodeConfig();
    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_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();
    %name{setenv} void setenv_();
    double min_object_distance();
};

%package{Slic3r::Config};

%{
PROTOTYPES: DISABLE

SV*
print_config_def()
    CODE:
        t_optiondef_map &def = Slic3r::print_config_def.options;
        FullPrintConfig config;
        
        HV* options_hv = newHV();
        for (t_optiondef_map::iterator oit = def.begin(); oit != def.end(); ++oit) {
            HV* hv = newHV();
            
            t_config_option_key opt_key = oit->first;
            ConfigOptionDef* optdef     = &oit->second;
            
            const char* opt_type;
            if (optdef->type == coFloat || optdef->type == coFloats || optdef->type == coFloatOrPercent) {
                opt_type = "f";
            } else if (optdef->type == coPercent) {
                opt_type = "percent";
            } else if (optdef->type == coInt || optdef->type == coInts) {
                opt_type = "i";
            } else if (optdef->type == coString) {
                opt_type = "s";
            } else if (optdef->type == coStrings) {
                opt_type = "s@";
            } else if (optdef->type == coPoint || optdef->type == coPoints) {
                opt_type = "point";
            } else if (optdef->type == coBool || optdef->type == coBools) {
                opt_type = "bool";
            } else if (optdef->type == coEnum) {
                opt_type = "select";
            } else {
                throw "Unknown option type";
            }
            (void)hv_stores( hv, "type",        newSVpv(opt_type, 0) );
            (void)hv_stores( hv, "gui_type",    newSVpvn(optdef->gui_type.c_str(), optdef->gui_type.length()) );
            (void)hv_stores( hv, "gui_flags",   newSVpvn(optdef->gui_flags.c_str(), optdef->gui_flags.length()) );
            (void)hv_stores( hv, "label",       newSVpvn_utf8(optdef->label.c_str(), optdef->label.length(), true) );
            if (!optdef->full_label.empty())
                (void)hv_stores( hv, "full_label",  newSVpvn_utf8(optdef->full_label.c_str(), optdef->full_label.length(), true) );
            (void)hv_stores( hv, "category",    newSVpvn(optdef->category.c_str(), optdef->category.length()) );
            (void)hv_stores( hv, "tooltip",     newSVpvn_utf8(optdef->tooltip.c_str(), optdef->tooltip.length(), true) );
            (void)hv_stores( hv, "sidetext",    newSVpvn_utf8(optdef->sidetext.c_str(), optdef->sidetext.length(), true) );
            (void)hv_stores( hv, "cli",         newSVpvn(optdef->cli.c_str(), optdef->cli.length()) );
            (void)hv_stores( hv, "ratio_over",  newSVpvn(optdef->ratio_over.c_str(), optdef->ratio_over.length()) );
            (void)hv_stores( hv, "multiline",   newSViv(optdef->multiline ? 1 : 0) );
            (void)hv_stores( hv, "full_width",  newSViv(optdef->full_width ? 1 : 0) );
            (void)hv_stores( hv, "readonly",    newSViv(optdef->readonly ? 1 : 0) );
            (void)hv_stores( hv, "height",      newSViv(optdef->height) );
            (void)hv_stores( hv, "width",       newSViv(optdef->width) );
            (void)hv_stores( hv, "min",         newSViv(optdef->min) );
            (void)hv_stores( hv, "max",         newSViv(optdef->max) );
            
            // aliases
            if (!optdef->aliases.empty()) {
                AV* av = newAV();
                av_fill(av, optdef->aliases.size()-1);
                for (std::vector<t_config_option_key>::iterator it = optdef->aliases.begin(); it != optdef->aliases.end(); ++it)
                    av_store(av, it - optdef->aliases.begin(), newSVpvn(it->c_str(), it->length()));
                (void)hv_stores( hv, "aliases", newRV_noinc((SV*)av) );
            }
            
            // shortcut
            if (!optdef->shortcut.empty()) {
                AV* av = newAV();
                av_fill(av, optdef->shortcut.size()-1);
                for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it)
                    av_store(av, it - optdef->shortcut.begin(), newSVpvn(it->c_str(), it->length()));
                (void)hv_stores( hv, "shortcut", newRV_noinc((SV*)av) );
            }
            
            // enum_values
            if (!optdef->enum_values.empty()) {
                AV* av = newAV();
                av_fill(av, optdef->enum_values.size()-1);
                for (std::vector<std::string>::iterator it = optdef->enum_values.begin(); it != optdef->enum_values.end(); ++it)
                    av_store(av, it - optdef->enum_values.begin(), newSVpvn(it->c_str(), it->length()));
                (void)hv_stores( hv, "values", newRV_noinc((SV*)av) );
            }
            
            // enum_labels
            if (!optdef->enum_labels.empty()) {
                AV* av = newAV();
                av_fill(av, optdef->enum_labels.size()-1);
                for (std::vector<std::string>::iterator it = optdef->enum_labels.begin(); it != optdef->enum_labels.end(); ++it)
                    av_store(av, it - optdef->enum_labels.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
                (void)hv_stores( hv, "labels", newRV_noinc((SV*)av) );
            }
            
            (void)hv_stores( hv, "default", ConfigBase__get(&config, opt_key) );
            (void)hv_store( options_hv, opt_key.c_str(), opt_key.length(), newRV_noinc((SV*)hv), 0 );
        }
        
        RETVAL = newRV_noinc((SV*)options_hv);
    OUTPUT:
        RETVAL
%}