SLA exposure bounds to printer params.

This commit is contained in:
tamasmeszaros 2019-08-20 17:24:48 +02:00
parent 88dcb7f366
commit b58713c06f
5 changed files with 50 additions and 94 deletions

View file

@ -2412,7 +2412,7 @@ void PrintConfigDef::init_sla_params()
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionInt(10)); def->set_default_value(new ConfigOptionInt(10));
def = this->add("exposure_time_min", coFloat); def = this->add("min_exposure_time", coFloat);
def->label = L("Minimum exposure time"); def->label = L("Minimum exposure time");
def->tooltip = L("Minimum exposure time"); def->tooltip = L("Minimum exposure time");
def->sidetext = L("s"); def->sidetext = L("s");
@ -2420,7 +2420,7 @@ void PrintConfigDef::init_sla_params()
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("exposure_time_max", coFloat); def = this->add("max_exposure_time", coFloat);
def->label = L("Maximum exposure time"); def->label = L("Maximum exposure time");
def->tooltip = L("Maximum exposure time"); def->tooltip = L("Maximum exposure time");
def->sidetext = L("s"); def->sidetext = L("s");
@ -2435,7 +2435,7 @@ void PrintConfigDef::init_sla_params()
def->min = 0; def->min = 0;
def->set_default_value(new ConfigOptionFloat(10)); def->set_default_value(new ConfigOptionFloat(10));
def = this->add("initial_exposure_time_min", coFloat); def = this->add("min_initial_exposure_time", coFloat);
def->label = L("Minimum initial exposure time"); def->label = L("Minimum initial exposure time");
def->tooltip = L("Minimum initial exposure time"); def->tooltip = L("Minimum initial exposure time");
def->sidetext = L("s"); def->sidetext = L("s");
@ -2443,7 +2443,7 @@ void PrintConfigDef::init_sla_params()
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("initial_exposure_time_max", coFloat); def = this->add("max_initial_exposure_time", coFloat);
def->label = L("Maximum initial exposure time"); def->label = L("Maximum initial exposure time");
def->tooltip = L("Maximum initial exposure time"); def->tooltip = L("Maximum initial exposure time");
def->sidetext = L("s"); def->sidetext = L("s");

View file

@ -1098,22 +1098,14 @@ class SLAMaterialConfig : public StaticPrintConfig
STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig) STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig)
public: public:
ConfigOptionFloat initial_layer_height; ConfigOptionFloat initial_layer_height;
ConfigOptionFloat exposure_time_min;
ConfigOptionFloat exposure_time_max;
ConfigOptionFloat exposure_time; ConfigOptionFloat exposure_time;
ConfigOptionFloat initial_exposure_time_min;
ConfigOptionFloat initial_exposure_time_max;
ConfigOptionFloat initial_exposure_time; ConfigOptionFloat initial_exposure_time;
ConfigOptionFloats material_correction; ConfigOptionFloats material_correction;
protected: protected:
void initialize(StaticCacheBase &cache, const char *base_ptr) void initialize(StaticCacheBase &cache, const char *base_ptr)
{ {
OPT_PTR(initial_layer_height); OPT_PTR(initial_layer_height);
OPT_PTR(exposure_time_min);
OPT_PTR(exposure_time_max);
OPT_PTR(exposure_time); OPT_PTR(exposure_time);
OPT_PTR(initial_exposure_time_min);
OPT_PTR(initial_exposure_time_max);
OPT_PTR(initial_exposure_time); OPT_PTR(initial_exposure_time);
OPT_PTR(material_correction); OPT_PTR(material_correction);
} }
@ -1139,6 +1131,10 @@ public:
ConfigOptionFloat fast_tilt_time; ConfigOptionFloat fast_tilt_time;
ConfigOptionFloat slow_tilt_time; ConfigOptionFloat slow_tilt_time;
ConfigOptionFloat area_fill; ConfigOptionFloat area_fill;
ConfigOptionFloat min_exposure_time;
ConfigOptionFloat max_exposure_time;
ConfigOptionFloat min_initial_exposure_time;
ConfigOptionFloat max_initial_exposure_time;
protected: protected:
void initialize(StaticCacheBase &cache, const char *base_ptr) void initialize(StaticCacheBase &cache, const char *base_ptr)
{ {
@ -1158,6 +1154,10 @@ protected:
OPT_PTR(fast_tilt_time); OPT_PTR(fast_tilt_time);
OPT_PTR(slow_tilt_time); OPT_PTR(slow_tilt_time);
OPT_PTR(area_fill); OPT_PTR(area_fill);
OPT_PTR(min_exposure_time);
OPT_PTR(max_exposure_time);
OPT_PTR(min_initial_exposure_time);
OPT_PTR(max_initial_exposure_time);
} }
}; };

View file

@ -692,19 +692,19 @@ std::string SLAPrint::validate() const
} }
} }
double expt_max = m_material_config.exposure_time_max.getFloat(); double expt_max = m_printer_config.max_exposure_time.getFloat();
double expt_min = m_material_config.exposure_time_min.getFloat(); double expt_min = m_printer_config.min_exposure_time.getFloat();
double expt_cur = m_material_config.exposure_time.getFloat(); double expt_cur = m_material_config.exposure_time.getFloat();
if (expt_cur < expt_min || expt_cur > expt_max) if (expt_cur < expt_min || expt_cur > expt_max)
return L("Exposition time is out of predefined bounds."); return L("Exposition time is out of printer profile bounds.");
double iexpt_max = m_material_config.initial_exposure_time_max.getFloat(); double iexpt_max = m_printer_config.max_initial_exposure_time.getFloat();
double iexpt_min = m_material_config.initial_exposure_time_min.getFloat(); double iexpt_min = m_printer_config.min_initial_exposure_time.getFloat();
double iexpt_cur = m_material_config.initial_exposure_time.getFloat(); double iexpt_cur = m_material_config.initial_exposure_time.getFloat();
if (iexpt_cur < iexpt_min || iexpt_cur > iexpt_max) if (iexpt_cur < iexpt_min || iexpt_cur > iexpt_max)
return L("Initial exposition time is out of predefined bounds."); return L("Initial exposition time is out of printer profile bounds.");
return ""; return "";
} }
@ -1600,11 +1600,11 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
// Cache the plenty of parameters, which influence the final rasterization only, // Cache the plenty of parameters, which influence the final rasterization only,
// or they are only notes not influencing the rasterization step. // or they are only notes not influencing the rasterization step.
static std::unordered_set<std::string> steps_rasterize = { static std::unordered_set<std::string> steps_rasterize = {
"exposure_time_min", "min_exposure_time",
"exposure_time_max", "max_exposure_time",
"exposure_time", "exposure_time",
"initial_exposure_time_min", "min_initial_exposure_time",
"initial_exposure_time_max", "max_initial_exposure_time",
"initial_exposure_time", "initial_exposure_time",
"display_width", "display_width",
"display_height", "display_height",

View file

@ -500,8 +500,8 @@ const std::vector<std::string>& Preset::sla_material_options()
if (s_opts.empty()) { if (s_opts.empty()) {
s_opts = { s_opts = {
"initial_layer_height", "initial_layer_height",
"exposure_time_min", "exposure_time_max", "exposure_time", "exposure_time",
"initial_exposure_time_min", "initial_exposure_time_max", "initial_exposure_time", "initial_exposure_time",
"material_correction", "material_correction",
"material_notes", "material_notes",
"default_sla_material_profile", "default_sla_material_profile",
@ -527,6 +527,8 @@ const std::vector<std::string>& Preset::sla_printer_options()
"relative_correction", "relative_correction",
"absolute_correction", "absolute_correction",
"gamma_correction", "gamma_correction",
"min_exposure_time", "max_exposure_time",
"min_initial_exposure_time", "max_initial_exposure_time",
"print_host", "printhost_apikey", "printhost_cafile", "print_host", "printhost_apikey", "printhost_cafile",
"printer_notes", "printer_notes",
"inherits" "inherits"

View file

@ -2290,6 +2290,12 @@ void TabPrinter::build_sla()
optgroup->append_single_option_line("absolute_correction"); optgroup->append_single_option_line("absolute_correction");
optgroup->append_single_option_line("gamma_correction"); optgroup->append_single_option_line("gamma_correction");
optgroup = page->new_optgroup(_(L("Exposure")));
optgroup->append_single_option_line("min_exposure_time");
optgroup->append_single_option_line("max_exposure_time");
optgroup->append_single_option_line("min_initial_exposure_time");
optgroup->append_single_option_line("max_initial_exposure_time");
optgroup = page->new_optgroup(_(L("Print Host upload"))); optgroup = page->new_optgroup(_(L("Print Host upload")));
build_printhost(optgroup.get()); build_printhost(optgroup.get());
@ -3614,11 +3620,7 @@ void TabSLAMaterial::build()
optgroup->append_single_option_line("initial_layer_height"); optgroup->append_single_option_line("initial_layer_height");
optgroup = page->new_optgroup(_(L("Exposure"))); optgroup = page->new_optgroup(_(L("Exposure")));
optgroup->append_single_option_line("exposure_time_min");
optgroup->append_single_option_line("exposure_time_max");
optgroup->append_single_option_line("exposure_time"); optgroup->append_single_option_line("exposure_time");
optgroup->append_single_option_line("initial_exposure_time_min");
optgroup->append_single_option_line("initial_exposure_time_max");
optgroup->append_single_option_line("initial_exposure_time"); optgroup->append_single_option_line("initial_exposure_time");
optgroup = page->new_optgroup(_(L("Corrections"))); optgroup = page->new_optgroup(_(L("Corrections")));
@ -3683,59 +3685,11 @@ void TabSLAMaterial::reload_config()
Tab::reload_config(); Tab::reload_config();
} }
namespace {
enum e_cmp {EQUAL = 1, SMALLER = 2, GREATER = 4, SMALLER_EQ = 3, GREATER_EQ = 5};
void bound_check(Tab &tb, e_cmp cmp, const char *id, const char *boundid)
{
double bound = tb.m_config->opt_float(boundid);
double value = tb.m_config->opt_float(id);
auto boundlabel = tb.m_config->def()->get(boundid)->label;
auto valuelabel = tb.m_config->def()->get(id)->label;
double ddiff = value - bound;
int diff = ddiff < 0 ? SMALLER : (std::abs(ddiff) < EPSILON ? EQUAL : GREATER);
if ((cmp | diff) != cmp) {
wxString fmt;
switch (cmp) {
case EQUAL: fmt = _(L("%s should be equal to %s")); break;
case SMALLER: fmt = _(L("%s should be smaller than %s")); break;
case GREATER: fmt = _(L("%s should be greater than %s")); break;
case SMALLER_EQ: fmt = _(L("%s should be smaller or equal to %s")); break;
case GREATER_EQ: fmt = _(L("%s should be greater or equal to %s")); break;
}
wxString msg_text = wxString::Format(fmt, valuelabel, boundlabel);
wxMessageDialog dialog(tb.parent(), msg_text,
_(L("Value outside bounds")),
wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *tb.m_config;
if (dialog.ShowModal() == wxID_OK)
new_conf.set_key_value(id, new ConfigOptionFloat(bound));
tb.load_config(new_conf);
}
};
}
void TabSLAMaterial::update() void TabSLAMaterial::update()
{ {
if (m_preset_bundle->printers.get_selected_preset().printer_technology() == ptFFF) if (m_preset_bundle->printers.get_selected_preset().printer_technology() == ptFFF)
return; return;
bound_check(*this, e_cmp::GREATER_EQ, "exposure_time", "exposure_time_min");
bound_check(*this, e_cmp::SMALLER_EQ, "exposure_time", "exposure_time_max");
bound_check(*this, e_cmp::GREATER_EQ, "initial_exposure_time", "initial_exposure_time_min");
bound_check(*this, e_cmp::SMALLER_EQ, "initial_exposure_time", "initial_exposure_time_max");
// #ys_FIXME. Just a template for this function // #ys_FIXME. Just a template for this function
// m_update_cnt++; // m_update_cnt++;
// ! something to update // ! something to update