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

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/ui_layout/print.as101
-rw-r--r--resources/ui_layout/print.ui52
-rw-r--r--src/libslic3r/Config.cpp10
-rw-r--r--src/libslic3r/PrintConfig.cpp9
-rw-r--r--src/libslic3r/PrintConfig.hpp7
-rw-r--r--src/slic3r/GUI/ScriptExecutor.cpp100
6 files changed, 229 insertions, 50 deletions
diff --git a/resources/ui_layout/print.as b/resources/ui_layout/print.as
index 83a06432e..77f797c9b 100644
--- a/resources/ui_layout/print.as
+++ b/resources/ui_layout/print.as
@@ -13,6 +13,8 @@
// 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
+// float get_computed_float(string &in key)
+// get the float computed value of the field. Useful if it's a floatOrPercent that is computable.
// 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)
@@ -28,8 +30,13 @@
// void set_string(string &in, string &in new_val))
// if an enum, it's one of the enum_value
//
+// ask_for_refresh()
+// ask for a OPTNAME_set() if in a OPTNAME_get()
+//
//// Functions to define for each script widget ////
//
+// note that you can't call set_thing() in an OPTNAME_get(), you can only call these in an OPTNAME_set()
+//
// 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)
@@ -93,18 +100,12 @@ void s_overhangs_reset(bool set)
float compute_overlap()
{
float height = get_float("layer_height");
- print("layer_height = " + height + "\n");
float width = get_computed_float("solid_infill_extrusion_width");
- print("width = " + width + "\n");
if(height <= 0) return 1;
if(width <= 0) return 1;
float solid_spacing = (width - height * 0.215);
- print("solid_spacing = " + solid_spacing + "\n");
float solid_flow = height * solid_spacing;
- print("solid_flow = " + solid_flow + "\n");
float bridge_spacing = sqrt(solid_flow*1.2739);
- print("bridge_spacing = " + bridge_spacing + "\n");
- print("bridge_spacing/solid_spacing = " + (bridge_spacing / solid_spacing) + "\n");
return bridge_spacing / solid_spacing;
}
@@ -131,7 +132,6 @@ void s_not_thick_bridge_set(bool set)
{
bool var_set = false;
get_custom_bool(0,"not_thick_bridge", var_set);
- print("Me with value " + var_set +" has to be set to " + set+"\n");
if (var_set != set) {
set_custom_bool(0,"not_thick_bridge", set);
}
@@ -139,7 +139,6 @@ void s_not_thick_bridge_set(bool set)
if (get_int("bridge_type") != 2)
set_int("bridge_type", 2);
float overlap = compute_overlap();
- print("overlap = " + overlap + "\n");
set_float("bridge_overlap", overlap);
set_float("bridge_overlap_min", overlap);
} else if (var_set != set) {
@@ -149,11 +148,95 @@ void s_not_thick_bridge_set(bool set)
}
}
+// seam position
+// spRandom [spNearest] spAligned spRear [spCustom] spCost
+// ("Cost-based") ("Random") ("Aligned") ("Rear")
+// -> Corners Nearest Random Aligned Rear Custom
+int s_seam_position_get(string &out get_val)
+{
+ int pos = get_int("seam_position");
+ string seam_pos;
+ get_string("seam_position", seam_pos);
+ if(pos < 5){
+ if (pos == 0) return 2;
+ return pos + 1;
+ } else {
+ float angle = get_float("seam_angle_cost");
+ float travel = get_float("seam_travel_cost");
+ if(angle > travel * 3.9 && angle < travel * 4.1) return 0;
+ if(travel > angle * 1.9 && travel < angle * 2.1) return 1;
+ }
+ return 5;
+}
+
+void s_seam_position_set(string &in set_val, int idx)
+{
+ if (idx == 2 ) {
+ set_int("seam_position", 0);
+ } else if (idx <= 1) {
+ set_int("seam_position", 5);
+ if (idx == 0) {
+ set_percent("seam_angle_cost", 80);
+ set_percent("seam_travel_cost", 20);
+ } else {
+ set_percent("seam_angle_cost", 30);
+ set_percent("seam_travel_cost", 60);
+ }
+ } else if (idx < 5) {
+ set_int("seam_position", idx - 1);
+ } else {
+ set_int("seam_position", 5);
+ back_initial_value("seam_angle_cost");
+ back_initial_value("seam_travel_cost");
+ }
+}
+
+// s_wall_thickness
+// set the perimeter_spacing & external_perimeter_spacing
+// as m * 2 perimeter_spacing + n * 2 * external_perimeter_spacing = o * s_wall_thickness
+
+float s_wall_thickness_get()
+{
+ int nb_peri = 2;
+ get_custom_int(0,"wall_thickness_lines", nb_peri);
+ float ps = get_computed_float("perimeter_extrusion_spacing");
+ float eps = get_computed_float("external_perimeter_extrusion_spacing");
+ //print("s_wall_thickness_get "+ps+" "+eps+" *"+nb_peri+"\n");
+ if (nb_peri<2) nb_peri = 2;
+ return eps * 2 + (nb_peri-2) * ps;
+}
+
+void s_wall_thickness_set(float new_val)
+{
+ float ne = get_float("nozzle_diameter");
+ float nb = new_val / ne;
+ int int_nb = int(floor(nb+0.1));
+ //print("float "+nb+" cast into "+int_nb+"\n");
+ if(int_nb > 1 && int_nb < 4){
+ float ext_spacing = new_val / int_nb;
+ set_float("external_perimeter_extrusion_spacing", ext_spacing);
+ set_float("perimeter_extrusion_spacing", ext_spacing);
+ set_custom_int(0,"wall_thickness_lines", int_nb);
+ }else if(int_nb > 3) {
+ //try with thin external
+ float ext_spacing = ne;
+ float spacing = (new_val - ext_spacing * 2) / (int_nb - 2);
+ if (spacing > ne * 1.5) {
+ // too different, get back to same value
+ ext_spacing = new_val / int_nb;
+ spacing = ext_spacing;
+ }
+ set_float("external_perimeter_extrusion_spacing", ext_spacing);
+ set_float("perimeter_extrusion_spacing", spacing);
+ set_custom_int(0,"wall_thickness_lines", int_nb);
+ }
+// ask_for_refresh();
+}
+
//TODO to replicate prusa:
// brim_type
// cooling
// xy compensation (both)
-// seam position
//test:
diff --git a/resources/ui_layout/print.ui b/resources/ui_layout/print.ui
index 73dded715..f7c24a087 100644
--- a/resources/ui_layout/print.ui
+++ b/resources/ui_layout/print.ui
@@ -2,6 +2,7 @@
page:Perimeters & Shell:shell
group:Vertical shells
setting:width$6:perimeters
+ setting:tags$Simple$SuSi:script:float:depends$perimeter_spacing$external_perimeter_spacing:label$Wall Thickness:tooltip$Change the perimeter extrusion width to ensure that there is an exact number of perimeters for this wall value. It won't put the width below the nozzle diameter, and up to double the size of the nozzle.:s_wall_thickness
setting:spiral_vase
recommended_thin_wall_thickness_description
group:Horizontal shells
@@ -15,6 +16,15 @@ group:Horizontal shells
end_line
top_bottom_shell_thickness_explanation
setting:enforce_full_fill_volume
+group:title_width$0:Infill
+ line:_
+ setting:tags$Simple:label_left:label_width$6:label$Sparse:width$8:sidetext_width$1:fill_density
+ setting:tags$Simple:label_width$0:label$_:fill_pattern
+ end_line
+ line:_
+ setting:tags$Simple:label_left:label_width$20:label$Top:top_fill_pattern
+ end_line
+ setting:tags$Simple:sidetext_width$0:infill_dense
group:Quality
line:Only one perimeter
setting:label_width$8:label$On first layer:only_one_perimeter_first_layer
@@ -62,9 +72,10 @@ group:Advanced
setting:width$5:gap_fill_last
end_line
line:Seam
- setting:label_width$12:sidetext_width$0:seam_position
- setting:width$3:sidetext_width$0:seam_angle_cost
- setting:width$3:sidetext_width$0:seam_travel_cost
+ setting:tags$Simple$Advanced$Prusa$SuSi:script:enum$corners$Corners$nearest$Nearest$random$Random$aligned$Aligned$rear$Rear$custom$Custom:depends$seam_position$seam_angle_cost$seam_travel_cost:label$Seam position:label_width$12:sidetext_width$0:tooltip$Position of perimeters' starting points.\nCustom can be defeined in Advanced or Expert mode.:s_seam_position
+ setting:tags$Expert:label_width$12:sidetext_width$0:seam_position
+ setting:tags$Advanced$Expert$SuSi:width$3:sidetext_width$0:seam_angle_cost
+ setting:tags$Advanced$Expert$SuSi:width$3:sidetext_width$0:seam_travel_cost
end_line
line:One-loop perimeters
setting:sidetext_width$0:label$_:perimeter_loop
@@ -126,8 +137,8 @@ group:Other
page:Infill:infill
group:title_width$0:Infill
line:_
- setting:label_left:label_width$6:label$Sparse:width$8:sidetext_width$1:fill_density
- setting:label_width$0:label$_:fill_pattern
+ setting:tags$Advanced$Expert$Prusa:label_left:label_width$6:label$Sparse:width$8:sidetext_width$1:fill_density
+ setting:tags$Advanced$Expert$Prusa:label_width$0:label$_:fill_pattern
setting:label$_:width$18:infill_connection
end_line
line:_
@@ -139,7 +150,7 @@ group:title_width$0:Infill
setting:label$_:width$18:infill_connection_solid
end_line
line:_
- setting:label_left:label_width$20:label$Top:top_fill_pattern
+ setting:tags$Advanced$Expert$Prusa:label_left:label_width$20:label$Top:top_fill_pattern
setting:label$_:width$18:infill_connection_top
end_line
line:_
@@ -150,7 +161,7 @@ group:Reducing printing time
setting:infill_every_layers
setting:infill_only_where_needed
line:Supporting dense layer
- setting:sidetext_width$0:label$_:infill_dense
+ setting:tags$Advanced$Expert$SuSi:sidetext_width$0:label$_:infill_dense
setting:width$20:infill_dense_algo
end_line
group:sidetext_width$5:Advanced
@@ -185,7 +196,7 @@ group:title_width$19:Ironing post-process (This will go on top of infills and pe
page:Skirt & Brim:skirt+brim
group:Skirt
- setting:skirts
+ setting:tags$Advanced$Expert$Prusa:skirts
line:Distance
setting:skirt_distance
setting:label$from brim:skirt_distance_from_brim
@@ -195,11 +206,11 @@ group:Skirt
setting:skirt_brim
setting:min_skirt_length
group:Brim
- setting:brim_width
+ setting:tags$Advanced$Expert$Prusa:brim_width
setting:brim_inside_holes
setting:brim_width_interior
line:Brim ears
- setting:label$_:sidetext_width$0:brim_ears
+ setting:tags$Advanced$Expert$Prusa:label$_:sidetext_width$0:brim_ears
setting:width$3:sidetext_width$1:brim_ears_max_angle
setting:width$3:sidetext_width$3:brim_ears_detection_length
setting:brim_ears_pattern
@@ -209,8 +220,8 @@ group:Brim
page:Support material:support
group:Support material
- setting:support_material
- setting:support_material_auto
+ setting:tags$Advanced$Expert$Prusa:support_material
+ setting:tags$Advanced$Expert$Prusa:support_material_auto
setting:support_material_threshold
setting:support_material_enforce_layers
group:Raft
@@ -235,7 +246,7 @@ group:Options for support material and raft
setting:support_material_spacing
setting:support_material_angle
setting:support_material_closing_radius
- setting:support_material_buildplate_only
+ setting:tags$Advanced$Expert$Prusa:support_material_buildplate_only
setting:sidetext_width$7:support_material_xy_spacing
setting:dont_support_bridges
setting:support_material_synchronize_layers
@@ -410,7 +421,7 @@ page:Output options:output+page_white
group:Plater
setting:duplicate_distance
group:Sequential printing
- setting:complete_objects
+ setting:tags$Advanced$Expert$Prusa:complete_objects
setting:complete_objects_one_skirt
setting:complete_objects_one_brim
setting:complete_objects_sort
@@ -432,6 +443,7 @@ group:Post-processing milling
setting:milling_extra_size
setting:milling_after_z
setting:milling_speed
+
page:Notes:note
group:no_title:Notes
setting:full_width:height$25:notes
@@ -443,3 +455,15 @@ group:Profile dependencies
setting:compatible_printers
setting:full_width:color:compatible_printers_condition
parent_preset_description
+
+page:Support & Other:wrench
+group:Support Material
+ setting:tags$Simple:support_material
+ setting:tags$Simple:support_material_auto
+ setting:tags$Simple:support_material_buildplate_only
+group:Skirt & Brim
+ setting:tags$Simple:skirts
+ setting:tags$Simple:brim_width
+ setting:tags$Simple:sidetext_width$0:brim_ears
+group:Sequential printing
+ setting:tags$Simple:complete_objects
diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp
index 72afd3ec7..af0fd7c76 100644
--- a/src/libslic3r/Config.cpp
+++ b/src/libslic3r/Config.cpp
@@ -722,6 +722,8 @@ const ConfigOptionDef* ConfigBase::get_option_def(const t_config_option_key& opt
if (def == nullptr)
throw NoDefinitionException(opt_key);
const ConfigOptionDef* opt_def = def->get(opt_key);
+ if(opt_def == nullptr && parent != nullptr)
+ opt_def = parent->get_option_def(opt_key);
return opt_def;
}
@@ -747,7 +749,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
if (raw_opt->type() == coFloatOrPercent) {
auto cofop = static_cast<const ConfigOptionFloatOrPercent*>(raw_opt);
if (cofop->value == 0 && boost::ends_with(opt_key, "_extrusion_width")) {
- return get_computed_value("extrusion_width");
+ return this->get_computed_value("extrusion_width");
}
if (!cofop->percent)
return cofop->value;
@@ -756,7 +758,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
if (raw_opt->type() == coPercent) {
cast_opt = static_cast<const ConfigOptionPercent*>(raw_opt);
}
- const ConfigOptionDef* opt_def = get_option_def(opt_key);
+ const ConfigOptionDef* opt_def = this->get_option_def(opt_key);
if (opt_def == nullptr) // maybe a placeholder?
return cast_opt->get_abs_value(1);
//if over no other key, it's most probably a simple %
@@ -801,7 +803,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
if (!opt_fl_per->values[idx].percent)
return opt_fl_per->values[idx].value;
- const ConfigOptionDef* opt_def = get_option_def(opt_key);
+ const ConfigOptionDef* opt_def = this->get_option_def(opt_key);
if (opt_def == nullptr) // maybe a placeholder?
return opt_fl_per->get_abs_value(extruder_id, 1);
if (opt_def->ratio_over.empty())
@@ -813,7 +815,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
}
if (raw_opt->type() == coPercents) {
const ConfigOptionPercents* opt_per = static_cast<const ConfigOptionPercents*>(raw_opt);
- const ConfigOptionDef* opt_def = get_option_def(opt_key);
+ const ConfigOptionDef* opt_def = this->get_option_def(opt_key);
if (opt_def == nullptr) // maybe a placeholder?
return opt_per->get_abs_value(extruder_id, 1);
if (opt_def->ratio_over.empty())
diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp
index 08d3a0c71..ca23d7715 100644
--- a/src/libslic3r/PrintConfig.cpp
+++ b/src/libslic3r/PrintConfig.cpp
@@ -989,7 +989,7 @@ void PrintConfigDef::init_fff_params()
"each object before moving onto next one (and starting it from its bottom layer). "
"This feature is useful to avoid the risk of ruined prints. "
"Slic3r should warn and prevent you from extruder collisions, but beware.");
- def->mode = comAdvancedE | comPrusa;
+ def->mode = comSimpleAE | comPrusa;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("complete_objects_one_skirt", coBool);
@@ -1197,7 +1197,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm");
def->aliases = { "multiply_distance" };
def->min = 0;
- def->mode = comSimpleAE | comPrusa;
+ def->mode = comExpert | comPrusa | comSuSi;
def->set_default_value(new ConfigOptionFloat(6));
def = this->add("end_gcode", coString);
@@ -4210,7 +4210,8 @@ void PrintConfigDef::init_fff_params()
def->label = L("Seam position");
def->category = OptionCategory::perimeter;
def->tooltip = L("Position of perimeters' starting points."
- "\n ");
+ "\nCost-based option let you choose the angel and travel cost. A high angle cost will place the seam where it can be hidden by a corner"
+ ", the travel cost place the seam near the last position (often at the end of the previous infill).");
def->enum_keys_map = &ConfigOptionEnum<SeamPosition>::get_enum_values();
def->enum_values.push_back("cost");
def->enum_values.push_back("random");
@@ -5848,7 +5849,7 @@ void PrintConfigDef::init_milling_params()
def->category = OptionCategory::milling;
def->tooltip = L("If activated, at the end of each layer, the printer will switch to a milling head and mill the external perimeters."
"\nYou should set the 'Milling extra XY size' to a value high enough to have enough plastic to mill. Also, be sure that your piece is firmly glued to the bed.");
- def->mode = comSimpleAE | comSuSi;
+ def->mode = comAdvancedE | comSuSi;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("milling_extra_size", coFloatOrPercent);
diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp
index ea66fe45b..e141e8a2f 100644
--- a/src/libslic3r/PrintConfig.hpp
+++ b/src/libslic3r/PrintConfig.hpp
@@ -672,9 +672,11 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionPercent, external_perimeter_cut_corners))
((ConfigOptionBool, exact_last_layer_height))
((ConfigOptionFloatOrPercent, extrusion_width))
+ ((ConfigOptionFloatOrPercent, extrusion_spacing))
((ConfigOptionFloatOrPercent, first_layer_acceleration_over_raft))
((ConfigOptionFloatOrPercent, first_layer_height))
((ConfigOptionFloatOrPercent, first_layer_extrusion_width))
+ ((ConfigOptionFloatOrPercent, first_layer_extrusion_spacing))
((ConfigOptionFloat, first_layer_size_compensation)) /* elefant_foot_compensation */
((ConfigOptionInt, first_layer_size_compensation_layers))
((ConfigOptionFloatOrPercent, first_layer_speed_over_raft))
@@ -764,6 +766,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, enforce_full_fill_volume))
((ConfigOptionFloatOrPercent, external_infill_margin))
((ConfigOptionFloatOrPercent, external_perimeter_extrusion_width))
+ ((ConfigOptionFloatOrPercent, external_perimeter_extrusion_spacing))
((ConfigOptionPercent, external_perimeter_overlap))
((ConfigOptionFloatOrPercent, external_perimeter_speed))
((ConfigOptionBool, external_perimeters_first))
@@ -798,6 +801,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, hole_to_polyhole_twisted))
((ConfigOptionInt, infill_extruder))
((ConfigOptionFloatOrPercent, infill_extrusion_width))
+ ((ConfigOptionFloatOrPercent, infill_extrusion_spacing))
((ConfigOptionInt, infill_every_layers))
((ConfigOptionFloatOrPercent, infill_overlap))
((ConfigOptionFloatOrPercent, infill_speed))
@@ -831,6 +835,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, perimeter_round_corners))
((ConfigOptionInt, perimeter_extruder))
((ConfigOptionFloatOrPercent, perimeter_extrusion_width))
+ ((ConfigOptionFloatOrPercent, perimeter_extrusion_spacing))
((ConfigOptionBool, perimeter_loop))
((ConfigOptionEnum<SeamPosition>, perimeter_loop_seam))
((ConfigOptionPercent, perimeter_overlap))
@@ -847,6 +852,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, solid_infill_below_area))
((ConfigOptionInt, solid_infill_extruder))
((ConfigOptionFloatOrPercent, solid_infill_extrusion_width))
+ ((ConfigOptionFloatOrPercent, solid_infill_extrusion_spacing))
((ConfigOptionInt, solid_infill_every_layers))
((ConfigOptionFloatOrPercent, solid_infill_speed))
((ConfigOptionPercent, solid_infill_overlap))
@@ -860,6 +866,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloatOrPercent, thin_walls_speed))
((ConfigOptionEnum<InfillPattern>, top_fill_pattern))
((ConfigOptionFloatOrPercent, top_infill_extrusion_width))
+ ((ConfigOptionFloatOrPercent, top_infill_extrusion_spacing))
((ConfigOptionInt, top_solid_layers))
((ConfigOptionFloat, top_solid_min_thickness))
((ConfigOptionFloatOrPercent, top_solid_infill_speed))
diff --git a/src/slic3r/GUI/ScriptExecutor.cpp b/src/slic3r/GUI/ScriptExecutor.cpp
index 48f7ac924..5be7163a5 100644
--- a/src/slic3r/GUI/ScriptExecutor.cpp
+++ b/src/slic3r/GUI/ScriptExecutor.cpp
@@ -124,12 +124,29 @@ void as_set_int(std::string& key, int val)
new_val->set_at(val, 0);
conf.set_key_value(key, new_val);
} else if (result.second->type() == ConfigOptionType::coEnum) {
- const ConfigOptionDef* def = result.first->get_edited_preset().config.get_option_def(key);
- if (val >= 0 && val < def->enum_values.size()) {
- ConfigOption* copy = result.second->clone();
- copy->setInt(val);
- conf.set_key_value(key, copy);
- }
+ //const ConfigOptionDef* def = result.first->get_edited_preset().config.get_option_def(key);
+ //if (!def->enum_values.empty()) {
+ // std::string key = "";
+ // for (const auto& entry : *def->enum_keys_map) {
+ // if (entry.second == val) {
+ // key = entry.first;
+ // }
+ // }
+ // int32_t value = -1;
+ // for (int i = 0; i < def->enum_values.size(); i++) {
+ // if (def->enum_values[i] == key) {
+ // value = i;
+ // break;
+ // }
+ // }
+ // if (value >= 0 && value < def->enum_values.size()) {
+ ConfigOption* copy = result.second->clone();
+ copy->setInt(val);
+ conf.set_key_value(key, copy);
+ // return;
+ // }
+ //}
+ //BOOST_LOG_TRIVIAL(error) << "Error, can't access enum '" << key << "'";
}
}
float as_get_float(std::string& key)
@@ -218,10 +235,7 @@ void as_get_string(std::string& key, std::string& val)
} else if (opt->type() == ConfigOptionType::coStrings) {
val = ((ConfigOptionStrings*)opt)->get_at(0);
} else if (opt->type() == ConfigOptionType::coEnum) {
- int idx = opt->getInt();
- const ConfigOptionDef* def = result.first->get_edited_preset().config.get_option_def(key);
- if (idx >= 0 && idx < def->enum_values.size())
- val = def->enum_values[idx];
+ val = opt->serialize();
}
}
void as_set_string(std::string& key, std::string& val)
@@ -413,13 +427,60 @@ void as_set_custom_string(int preset, std::string& key, std::string& val)
////// others //////
-float as_get_computed_float(std::string& key)
+class ConfigAdapter : public ConfigBase
{
- try {
- return (float)wxGetApp().plater()->fff_print().full_print_config().get_computed_value(key, 0);
+public:
+ const ConfigBase* real_storage;
+ ConfigAdapter(const ConfigBase* conf) : real_storage(conf) { this->parent = nullptr; }
+ ConfigAdapter(const ConfigBase* conf, const ConfigBase* conf_parent) : real_storage(conf) { this->parent = conf_parent; }
+ virtual ~ConfigAdapter() { if (this->parent != nullptr) delete parent; }
+
+ virtual const ConfigDef* def() const override { return real_storage->def(); }
+ virtual ConfigOption* optptr(const t_config_option_key& opt_key, bool create = false) { return nullptr; }
+ virtual t_config_option_keys keys() const override { return real_storage->keys(); };
+
+ const ConfigOption* optptr(const t_config_option_key& opt_key) const override
+ {
+ const ConfigOption* opt = real_storage->optptr(opt_key);
+ //if not find, try with the parent config.
+ if (opt == nullptr && parent != nullptr)
+ opt = parent->optptr(opt_key);
+ return opt;
}
- catch (Exception e) {
- BOOST_LOG_TRIVIAL(error) << "Error, can't compute option '" << key << "'";
+
+
+};
+
+float as_get_computed_float(std::string& key)
+{
+ if (current_script->tech() == (PrinterTechnology::ptFFF)) {
+ ConfigAdapter fullconfig(
+ &current_script->tab()->m_preset_bundle->fff_prints.get_edited_preset().config,
+ new ConfigAdapter(
+ &current_script->tab()->m_preset_bundle->filaments.get_edited_preset().config,
+ new ConfigAdapter(&current_script->tab()->m_preset_bundle->printers.get_edited_preset().config)));
+ try {
+ return (float)fullconfig.get_computed_value(key, 0);
+ //return (float)wxGetApp().plater()->fff_print().full_print_config().get_computed_value(key, 0);
+ }
+ catch (Exception e) {
+ BOOST_LOG_TRIVIAL(error) << "Error, can't compute fff option '" << key << "'";
+ }
+
+ } else {
+ ConfigAdapter fullconfig(
+ &current_script->tab()->m_preset_bundle->sla_prints.get_edited_preset().config,
+ new ConfigAdapter(
+ &current_script->tab()->m_preset_bundle->sla_materials.get_edited_preset().config,
+ new ConfigAdapter(&current_script->tab()->m_preset_bundle->printers.get_edited_preset().config)));
+ try {
+ return (float)fullconfig.get_computed_value(key, 0);
+ //return (float)wxGetApp().plater()->fff_print().full_print_config().get_computed_value(key, 0);
+ }
+ catch (Exception e) {
+ BOOST_LOG_TRIVIAL(error) << "Error, can't compute sla option '" << key << "'";
+ }
+
}
return 0;
}
@@ -598,7 +659,7 @@ void ScriptContainer::call_script_function_set(const ConfigOptionDef& def, const
case coPercent:
case coPercents:
case coFloat:
- case coFloats: ctx->SetArgFloat(0, boost::any_cast<float>(value)); break;
+ case coFloats: ctx->SetArgFloat(0, (float)boost::any_cast<double>(value)); break;
case coFloatOrPercent:
case coFloatsOrPercents: {
std::string flOrPercent = boost::any_cast<std::string>(value);
@@ -616,8 +677,8 @@ void ScriptContainer::call_script_function_set(const ConfigOptionDef& def, const
break;
}
case coPoint:
- case coPoints: { ctx->SetArgFloat(0, boost::any_cast<float>(value)); ctx->SetArgFloat(1, boost::any_cast<float>(value)); break; } //FIXME
- case coPoint3: { ctx->SetArgFloat(0, boost::any_cast<float>(value)); ctx->SetArgFloat(1, boost::any_cast<float>(value)); ctx->SetArgFloat(2, boost::any_cast<float>(value)); break; }
+ case coPoints: { ctx->SetArgFloat(0, (float)boost::any_cast<double>(value)); ctx->SetArgFloat(1, (float)boost::any_cast<double>(value)); break; } //FIXME
+ case coPoint3: { ctx->SetArgFloat(0, (float)boost::any_cast<double>(value)); ctx->SetArgFloat(1, (float)boost::any_cast<double>(value)); ctx->SetArgFloat(2, (float)boost::any_cast<double>(value)); break; }
case coString:
case coStrings: {
str_arg = boost::any_cast<std::string>(value);
@@ -781,12 +842,13 @@ boost::any ScriptContainer::call_script_function_get_value(const ConfigOptionDef
if (ret_int >= 0 && ret_int < def.enum_values.size()) {
ret_val = int32_t(ret_int);
} else {
+ ret_val = int32_t(0);
for (size_t i = 0; i < def.enum_values.size(); i++) {
if (ret_str == def.enum_values[i])
ret_val = int32_t(i);
}
}
- ret_val = int32_t(0); break; //Choice
+ break; //Choice
}
}
if (m_need_refresh) {