123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- //////////////////////////////////////////
- // Api for SuperSlicer scripted widgets:
- //
- //// Functions callable ////
- //
- // -- to print on the console, for debugging --
- // void print(string &out)
- // void print_float(float)
- //
- // -- to get the value of real settings --
- // bool get_bool(string &in key)
- // int get_int(string &in key)
- // can be used by type int and enum (return the index)
- // float get_float(string &in key)
- // can be used by type float, percent and flaot_or_percent
- // bool is_percent(string &in key)
- // void get_string(string &in key, string &out get_val)
- // can be used by type string and enum (return the enum_value, not the label)
- //
- // -- to set the value of real settings --
- // void set_bool(string &in, bool new_val)
- // void set_int(string &in, int new_val)
- // if an enum, it's the index
- // void set_float(string &in, float new_val)
- // if a float_or_percent, unset the percent flag at the same time
- // void set_percent(string &in, float new_val)
- // if a float_or_percent, set the percent flag at the same time
- // void set_string(string &in, string &in new_val))
- // if an enum, it's one of the enum_value
- //
- //// Functions to define for each script widget ////
- //
- // type bool:
- // int OPTNAME_get()
- // will return 1 if checkd, 0 if unchecked and -1 if half-checked (not all os, will be uncehcked if not available)
- // void OPTNAME_set(bool set)
- //
- // type int:
- // int OPTNAME_get()
- // void OPTNAME_set(int set)
- //
- // type float & percent:
- // float OPTNAME_get()
- // void OPTNAME_set(float set)
- //
- // type float_or_percent:
- // float OPTNAME_get(bool &out is_percent)
- // void OPTNAME_set(float set, bool is_percent)
- //
- // type string:
- // void OPTNAME_get(string &out get)
- // void OPTNAME_set(string &in set)
- //
- // type enum:
- // int OPTNAME_get(string &out enum_value)
- // Only the return value is used unless it's out of bounds, then it tries to use the enum_value
- // void OPTNAME_set(string &in set_enum_value, int set_idx)
- //
- //
- int s_overhangs_get()
- {
- if (get_float("overhangs_width_speed") == 0) return 0;
- float width = get_float("overhangs_width");
- bool percent = is_percent("overhangs_width");
- if((percent && width > 50.f) || ((!percent) && width > 0.2f)) return 1;
- return -1;
- }
- void s_overhangs_set(bool set)
- {
- if (set) {
- set_percent("overhangs_width_speed", 55.f);
- float width = get_float("overhangs_width");
- bool percent = is_percent("overhangs_width");
- if((percent && width < 50.f) || ((!percent) && width < 0.2f))
- set_percent("overhangs_width", 75.f);
- } else {
- set_float("overhangs_width_speed", 0.);
- }
- }
- //test:
- // setting:script:bool:easy:depends$enforce_full_fill_volume:label$fullfill-lol:s_fullfill
- // setting:script:int:easy:depends$perimeters:label$perimeters-lol:s_perimeter
- // setting:script:float:easy:depends$top_solid_min_thickness:label$thickness-lol:s_thickness
- // setting:script:percent:easy:depends$bridge_flow_ratio:label$bridgeflow-lol:s_bridgeflow
- // setting:script:string:easy:depends$notes:label$notes-lol:s_notes
- // setting:script:enum$b$bof$m$mouaif:easy:depends$no_perimeter_unsupported_algo:label$noperi-lol:s_noperi
- int s_fullfill_get()
- {
- if (get_bool("enforce_full_fill_volume")) return 1;
- return 0;
- }
- void s_fullfill_set(bool set)
- {
- set_bool("enforce_full_fill_volume", set);
- }
- int s_perimeter_get()
- {
- return get_int("perimeters");
- }
- void s_perimeter_set(int set)
- {
- set_int("perimeters", set);
- }
- float s_thickness_get()
- {
- return get_float("top_solid_min_thickness");
- }
- void s_thickness_set(float set)
- {
- set_float("top_solid_min_thickness", set);
- }
- float s_bridgeflow_get()
- {
- return get_float("bridge_flow_ratio");
- }
- void s_bridgeflow_set(float set)
- {
- set_percent("bridge_flow_ratio", set);
- }
- void s_notes_get(string &out get_val)
- {
- get_string("notes", get_val);
- }
- void s_notes_set(string &out set_val)
- {
- set_string("notes", set_val);
- }
- int s_noperi_get(string &out get_val)
- {
- return get_int("no_perimeter_unsupported_algo") == 0 ? 0 : 1;
- }
- void s_noperi_set(string &out set_val, int idx)
- {
- //set_int("no_perimeter_unsupported_algo", idx == 0 ? 0 : 3);
- if (idx == 0) set_int("no_perimeter_unsupported_algo",0);
- else set_string("no_perimeter_unsupported_algo", "filled");
- }
|