2013-12-20 15:37:28 +00:00
|
|
|
%module{Slic3r::XS};
|
|
|
|
|
|
|
|
%{
|
|
|
|
#include <myinit.h>
|
2013-12-21 15:15:41 +00:00
|
|
|
#include "PrintConfig.hpp"
|
2013-12-20 15:37:28 +00:00
|
|
|
%}
|
|
|
|
|
2013-12-21 15:15:41 +00:00
|
|
|
%name{Slic3r::Config} class DynamicPrintConfig {
|
|
|
|
DynamicPrintConfig();
|
|
|
|
~DynamicPrintConfig();
|
2013-12-21 20:06:45 +00:00
|
|
|
bool has(t_config_option_key opt_key);
|
|
|
|
SV* as_hash();
|
2013-12-20 15:37:28 +00:00
|
|
|
SV* get(t_config_option_key opt_key);
|
2014-01-04 23:36:33 +00:00
|
|
|
SV* get_at(t_config_option_key opt_key, int i);
|
2014-03-24 00:07:30 +00:00
|
|
|
bool set(t_config_option_key opt_key, SV* value);
|
2014-04-19 17:14:41 +00:00
|
|
|
bool set_deserialize(t_config_option_key opt_key, SV* str);
|
2013-12-20 19:54:11 +00:00
|
|
|
std::string serialize(t_config_option_key opt_key);
|
2013-12-22 00:38:10 +00:00
|
|
|
double get_abs_value(t_config_option_key opt_key);
|
2014-01-02 09:44:54 +00:00
|
|
|
%name{get_abs_value_over}
|
|
|
|
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
2013-12-21 20:06:45 +00:00
|
|
|
void apply(DynamicPrintConfig* other)
|
|
|
|
%code{% THIS->apply(*other, true); %};
|
2014-01-03 17:27:46 +00:00
|
|
|
void apply_static(FullPrintConfig* other)
|
2013-12-21 20:06:45 +00:00
|
|
|
%code{% THIS->apply(*other, true); %};
|
|
|
|
std::vector<std::string> get_keys()
|
|
|
|
%code{% THIS->keys(&RETVAL); %};
|
2014-01-22 20:14:47 +00:00
|
|
|
void erase(t_config_option_key opt_key);
|
2014-03-26 23:01:33 +00:00
|
|
|
void normalize();
|
2014-01-01 16:29:15 +00:00
|
|
|
};
|
2013-12-20 15:37:28 +00:00
|
|
|
|
2014-01-01 16:29:15 +00:00
|
|
|
%name{Slic3r::Config::Print} class PrintConfig {
|
|
|
|
PrintConfig();
|
|
|
|
~PrintConfig();
|
|
|
|
bool has(t_config_option_key opt_key);
|
|
|
|
SV* as_hash();
|
|
|
|
SV* get(t_config_option_key opt_key);
|
2014-01-04 23:36:33 +00:00
|
|
|
SV* get_at(t_config_option_key opt_key, int i);
|
2014-03-24 00:07:30 +00:00
|
|
|
bool set(t_config_option_key opt_key, SV* value);
|
2014-04-19 17:14:41 +00:00
|
|
|
bool set_deserialize(t_config_option_key opt_key, SV* str);
|
2014-01-01 16:29:15 +00:00
|
|
|
std::string serialize(t_config_option_key opt_key);
|
|
|
|
double get_abs_value(t_config_option_key opt_key);
|
2014-01-02 09:44:54 +00:00
|
|
|
%name{get_abs_value_over}
|
|
|
|
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
2014-01-01 16:29:15 +00:00
|
|
|
void apply_dynamic(DynamicPrintConfig* other)
|
|
|
|
%code{% THIS->apply(*other, true); %};
|
|
|
|
std::vector<std::string> get_keys()
|
|
|
|
%code{% THIS->keys(&RETVAL); %};
|
2013-12-20 15:37:28 +00:00
|
|
|
};
|
2013-12-21 15:32:11 +00:00
|
|
|
|
2014-01-02 09:44:54 +00:00
|
|
|
%name{Slic3r::Config::PrintRegion} class PrintRegionConfig {
|
|
|
|
PrintRegionConfig();
|
|
|
|
~PrintRegionConfig();
|
2013-12-21 20:06:45 +00:00
|
|
|
bool has(t_config_option_key opt_key);
|
|
|
|
SV* as_hash();
|
2013-12-21 15:32:11 +00:00
|
|
|
SV* get(t_config_option_key opt_key);
|
2014-01-04 23:36:33 +00:00
|
|
|
SV* get_at(t_config_option_key opt_key, int i);
|
2014-03-24 00:07:30 +00:00
|
|
|
bool set(t_config_option_key opt_key, SV* value);
|
2014-04-19 17:14:41 +00:00
|
|
|
bool set_deserialize(t_config_option_key opt_key, SV* str);
|
2013-12-21 15:32:11 +00:00
|
|
|
std::string serialize(t_config_option_key opt_key);
|
2013-12-22 00:38:10 +00:00
|
|
|
double get_abs_value(t_config_option_key opt_key);
|
2014-01-02 09:44:54 +00:00
|
|
|
%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); %};
|
2013-12-21 20:06:45 +00:00
|
|
|
void apply_dynamic(DynamicPrintConfig* other)
|
|
|
|
%code{% THIS->apply(*other, true); %};
|
|
|
|
std::vector<std::string> get_keys()
|
|
|
|
%code{% THIS->keys(&RETVAL); %};
|
2014-01-01 16:29:15 +00:00
|
|
|
};
|
2013-12-21 15:32:11 +00:00
|
|
|
|
2014-01-02 09:44:54 +00:00
|
|
|
%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);
|
2014-01-04 23:36:33 +00:00
|
|
|
SV* get_at(t_config_option_key opt_key, int i);
|
2014-03-24 00:07:30 +00:00
|
|
|
bool set(t_config_option_key opt_key, SV* value);
|
2014-04-19 17:14:41 +00:00
|
|
|
bool set_deserialize(t_config_option_key opt_key, SV* str);
|
2014-01-02 09:44:54 +00:00
|
|
|
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()
|
|
|
|
%code{% THIS->keys(&RETVAL); %};
|
|
|
|
};
|
|
|
|
|
|
|
|
%name{Slic3r::Config::Full} class FullPrintConfig {
|
|
|
|
FullPrintConfig();
|
|
|
|
~FullPrintConfig();
|
2014-01-01 16:29:15 +00:00
|
|
|
bool has(t_config_option_key opt_key);
|
|
|
|
SV* as_hash();
|
|
|
|
SV* get(t_config_option_key opt_key);
|
2014-01-04 23:36:33 +00:00
|
|
|
SV* get_at(t_config_option_key opt_key, int i);
|
2014-03-24 00:07:30 +00:00
|
|
|
bool set(t_config_option_key opt_key, SV* value);
|
2014-04-19 17:14:41 +00:00
|
|
|
bool set_deserialize(t_config_option_key opt_key, SV* str);
|
2014-01-01 16:29:15 +00:00
|
|
|
std::string serialize(t_config_option_key opt_key);
|
|
|
|
double get_abs_value(t_config_option_key opt_key);
|
2014-01-02 09:44:54 +00:00
|
|
|
%name{get_abs_value_over}
|
|
|
|
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
2014-05-13 06:34:21 +00:00
|
|
|
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); %};
|
2014-01-01 16:29:15 +00:00
|
|
|
void apply_dynamic(DynamicPrintConfig* other)
|
|
|
|
%code{% THIS->apply(*other, true); %};
|
|
|
|
std::vector<std::string> get_keys()
|
|
|
|
%code{% THIS->keys(&RETVAL); %};
|
2014-05-13 06:34:21 +00:00
|
|
|
std::string get_extrusion_axis();
|
2013-12-21 15:32:11 +00:00
|
|
|
};
|
2013-12-21 20:06:45 +00:00
|
|
|
|
|
|
|
%package{Slic3r::Config};
|
|
|
|
|
|
|
|
%{
|
|
|
|
PROTOTYPES: DISABLE
|
|
|
|
|
|
|
|
SV*
|
|
|
|
print_config_def()
|
|
|
|
CODE:
|
2014-01-02 09:44:54 +00:00
|
|
|
FullPrintConfig config;
|
|
|
|
t_optiondef_map* def = config.def;
|
2013-12-21 20:06:45 +00:00
|
|
|
|
|
|
|
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";
|
2014-03-22 15:23:33 +00:00
|
|
|
} else if (optdef->type == coPercent) {
|
|
|
|
opt_type = "percent";
|
2013-12-21 20:06:45 +00:00
|
|
|
} else if (optdef->type == coInt || optdef->type == coInts) {
|
|
|
|
opt_type = "i";
|
|
|
|
} else if (optdef->type == coString) {
|
|
|
|
opt_type = "s";
|
2013-12-21 23:39:03 +00:00
|
|
|
} else if (optdef->type == coStrings) {
|
|
|
|
opt_type = "s@";
|
2013-12-21 20:06:45 +00:00
|
|
|
} 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) );
|
2014-06-19 18:07:16 +00:00
|
|
|
(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()) );
|
2014-02-14 08:35:38 +00:00
|
|
|
(void)hv_stores( hv, "label", newSVpvn_utf8(optdef->label.c_str(), optdef->label.length(), true) );
|
2014-01-05 13:58:41 +00:00
|
|
|
if (!optdef->full_label.empty())
|
2014-02-14 08:35:38 +00:00
|
|
|
(void)hv_stores( hv, "full_label", newSVpvn_utf8(optdef->full_label.c_str(), optdef->full_label.length(), true) );
|
2013-12-21 20:06:45 +00:00
|
|
|
(void)hv_stores( hv, "category", newSVpvn(optdef->category.c_str(), optdef->category.length()) );
|
2014-02-14 08:35:38 +00:00
|
|
|
(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) );
|
2013-12-21 20:06:45 +00:00
|
|
|
(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
|
2013-12-24 00:16:51 +00:00
|
|
|
if (!optdef->aliases.empty()) {
|
2013-12-21 20:06:45 +00:00
|
|
|
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
|
2013-12-24 00:16:51 +00:00
|
|
|
if (!optdef->shortcut.empty()) {
|
2013-12-21 20:06:45 +00:00
|
|
|
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
|
2013-12-24 00:16:51 +00:00
|
|
|
if (!optdef->enum_values.empty()) {
|
2013-12-21 20:06:45 +00:00
|
|
|
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()));
|
2013-12-21 23:39:03 +00:00
|
|
|
(void)hv_stores( hv, "values", newRV_noinc((SV*)av) );
|
2013-12-21 20:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// enum_labels
|
2013-12-24 00:16:51 +00:00
|
|
|
if (!optdef->enum_labels.empty()) {
|
2013-12-21 20:06:45 +00:00
|
|
|
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)
|
2014-02-14 08:35:38 +00:00
|
|
|
av_store(av, it - optdef->enum_labels.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
|
2013-12-21 23:39:03 +00:00
|
|
|
(void)hv_stores( hv, "labels", newRV_noinc((SV*)av) );
|
2013-12-21 20:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(void)hv_stores( hv, "default", config.get(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
|
|
|
|
%}
|