Implemented UI to "Idle temperature" parameter
This commit is contained in:
parent
a067da6d53
commit
71cedd2eea
5 changed files with 122 additions and 68 deletions
|
@ -3740,8 +3740,8 @@ void PrintConfigDef::init_sla_params()
|
|||
def->tooltip = L("Nozzle temperature when the tool is currently not used in multi-tool setups."
|
||||
"This is only used when 'Ooze prevention is active in Print Settings.'");
|
||||
def->sidetext = L("°C");
|
||||
//def->min = 0;
|
||||
//def->max = max_temp;
|
||||
def->min = 0;
|
||||
def->max = max_temp;
|
||||
def->set_default_value(new ConfigOptionIntsNullable { ConfigOptionIntsNullable::nil_value() });
|
||||
|
||||
def = this->add("bottle_volume", coFloat);
|
||||
|
|
|
@ -762,28 +762,26 @@ void SpinCtrl::BUILD() {
|
|||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
|
||||
|
||||
wxString text_value = wxString("");
|
||||
int default_value = 0;
|
||||
int default_value = UNDEF_VALUE;
|
||||
|
||||
switch (m_opt.type) {
|
||||
case coInt:
|
||||
default_value = m_opt.default_value->getInt();
|
||||
text_value = wxString::Format(_T("%i"), default_value);
|
||||
break;
|
||||
case coInts:
|
||||
{
|
||||
const ConfigOptionInts *vec = m_opt.get_default_value<ConfigOptionInts>();
|
||||
if (vec == nullptr || vec->empty()) break;
|
||||
for (size_t id = 0; id < vec->size(); ++id)
|
||||
{
|
||||
default_value = vec->get_at(id);
|
||||
text_value += wxString::Format(_T("%i"), default_value);
|
||||
}
|
||||
default_value = m_opt.get_default_value<ConfigOptionInts>()->get_at(m_opt_idx);
|
||||
if (m_opt.nullable)
|
||||
m_last_meaningful_value = default_value == ConfigOptionIntsNullable::nil_value() ? static_cast<int>(m_opt.max) : default_value;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (default_value != UNDEF_VALUE)
|
||||
text_value = wxString::Format(_T("%i"), default_value);
|
||||
|
||||
const int min_val = m_opt.min == -FLT_MAX
|
||||
#ifdef __WXOSX__
|
||||
// We will forcibly set the input value for SpinControl, since the value
|
||||
|
@ -882,6 +880,50 @@ void SpinCtrl::BUILD() {
|
|||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
void SpinCtrl::set_value(const boost::any& value, bool change_event/* = false*/)
|
||||
{
|
||||
m_disable_change_event = !change_event;
|
||||
tmp_value = boost::any_cast<int>(value);
|
||||
m_value = value;
|
||||
if (m_opt.nullable) {
|
||||
const bool m_is_na_val = tmp_value == ConfigOptionIntsNullable::nil_value();
|
||||
if (m_is_na_val)
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(na_value());
|
||||
else {
|
||||
m_last_meaningful_value = value;
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
|
||||
}
|
||||
}
|
||||
else
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
|
||||
m_disable_change_event = false;
|
||||
}
|
||||
|
||||
void SpinCtrl::set_last_meaningful_value()
|
||||
{
|
||||
const int val = boost::any_cast<int>(m_last_meaningful_value);
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(val);
|
||||
tmp_value = val;
|
||||
propagate_value();
|
||||
}
|
||||
|
||||
void SpinCtrl::set_na_value()
|
||||
{
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(na_value());
|
||||
m_value = ConfigOptionIntsNullable::nil_value();
|
||||
propagate_value();
|
||||
}
|
||||
|
||||
boost::any& SpinCtrl::get_value()
|
||||
{
|
||||
wxSpinCtrl* spin = static_cast<wxSpinCtrl*>(window);
|
||||
if (spin->GetTextValue() == na_value())
|
||||
return m_value;
|
||||
|
||||
int value = spin->GetValue();
|
||||
return m_value = value;
|
||||
}
|
||||
|
||||
void SpinCtrl::propagate_value()
|
||||
{
|
||||
// check if value was really changed
|
||||
|
|
|
@ -330,24 +330,18 @@ public:
|
|||
void BUILD() override;
|
||||
/// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
|
||||
void propagate_value() ;
|
||||
|
||||
/*
|
||||
void set_value(const std::string& value, bool change_event = false) {
|
||||
m_disable_change_event = !change_event;
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(value);
|
||||
m_disable_change_event = false;
|
||||
}
|
||||
void set_value(const boost::any& value, bool change_event = false) override {
|
||||
m_disable_change_event = !change_event;
|
||||
tmp_value = boost::any_cast<int>(value);
|
||||
m_value = value;
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
|
||||
m_disable_change_event = false;
|
||||
}
|
||||
*/
|
||||
void set_value(const boost::any& value, bool change_event = false) override;
|
||||
void set_last_meaningful_value() override;
|
||||
void set_na_value() override;
|
||||
|
||||
boost::any& get_value() override {
|
||||
int value = static_cast<wxSpinCtrl*>(window)->GetValue();
|
||||
return m_value = value;
|
||||
}
|
||||
boost::any& get_value() override;
|
||||
|
||||
void msw_rescale() override;
|
||||
|
||||
|
|
|
@ -1826,45 +1826,59 @@ static void validate_custom_gcode_cb(Tab* tab, const wxString& title, const t_co
|
|||
tab->on_value_change(opt_key, value);
|
||||
}
|
||||
|
||||
void TabFilament::create_line_with_near_label_widget(ConfigOptionsGroupShp optgroup, const std::string& opt_key, int opt_index/* = 0*/)
|
||||
{
|
||||
Line line {"",""};
|
||||
if (opt_key == "filament_retract_lift_above" || opt_key == "filament_retract_lift_below") {
|
||||
Option opt = optgroup->get_option(opt_key);
|
||||
opt.opt.label = opt.opt.full_label;
|
||||
line = optgroup->create_single_option_line(opt);
|
||||
}
|
||||
else
|
||||
line = optgroup->create_single_option_line(optgroup->get_option(opt_key));
|
||||
|
||||
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
|
||||
wxCheckBox* check_box = new wxCheckBox(parent, wxID_ANY, "");
|
||||
|
||||
check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
|
||||
const bool is_checked = evt.IsChecked();
|
||||
if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) {
|
||||
if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) {
|
||||
field->toggle(is_checked);
|
||||
if (is_checked)
|
||||
field->set_last_meaningful_value();
|
||||
else
|
||||
field->set_na_value();
|
||||
}
|
||||
}
|
||||
}, check_box->GetId());
|
||||
|
||||
m_overrides_options[opt_key] = check_box;
|
||||
return check_box;
|
||||
};
|
||||
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
void TabFilament::update_line_with_near_label_widget(ConfigOptionsGroupShp optgroup, const std::string& opt_key, int opt_index/* = 0*/, bool is_checked/* = true*/)
|
||||
{
|
||||
if (!m_overrides_options[opt_key])
|
||||
return;
|
||||
m_overrides_options[opt_key]->Enable(is_checked);
|
||||
|
||||
is_checked &= !m_config->option(opt_key)->is_nil();
|
||||
m_overrides_options[opt_key]->SetValue(is_checked);
|
||||
|
||||
Field* field = optgroup->get_fieldc(opt_key, opt_index);
|
||||
if (field != nullptr)
|
||||
field->toggle(is_checked);
|
||||
}
|
||||
|
||||
void TabFilament::add_filament_overrides_page()
|
||||
{
|
||||
PageShp page = add_options_page(L("Filament Overrides"), "wrench");
|
||||
ConfigOptionsGroupShp optgroup = page->new_optgroup(L("Retraction"));
|
||||
|
||||
auto append_single_option_line = [optgroup, this](const std::string& opt_key, int opt_index)
|
||||
{
|
||||
Line line {"",""};
|
||||
if (opt_key == "filament_retract_lift_above" || opt_key == "filament_retract_lift_below") {
|
||||
Option opt = optgroup->get_option(opt_key);
|
||||
opt.opt.label = opt.opt.full_label;
|
||||
line = optgroup->create_single_option_line(opt);
|
||||
}
|
||||
else
|
||||
line = optgroup->create_single_option_line(optgroup->get_option(opt_key));
|
||||
|
||||
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
|
||||
wxCheckBox* check_box = new wxCheckBox(parent, wxID_ANY, "");
|
||||
|
||||
check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
|
||||
const bool is_checked = evt.IsChecked();
|
||||
if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) {
|
||||
if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) {
|
||||
field->toggle(is_checked);
|
||||
if (is_checked)
|
||||
field->set_last_meaningful_value();
|
||||
else
|
||||
field->set_na_value();
|
||||
}
|
||||
}
|
||||
}, check_box->GetId());
|
||||
|
||||
m_overrides_options[opt_key] = check_box;
|
||||
return check_box;
|
||||
};
|
||||
|
||||
optgroup->append_line(line);
|
||||
};
|
||||
|
||||
const int extruder_idx = 0; // #ys_FIXME
|
||||
|
||||
for (const std::string opt_key : { "filament_retract_length",
|
||||
|
@ -1879,7 +1893,7 @@ void TabFilament::add_filament_overrides_page()
|
|||
"filament_wipe",
|
||||
"filament_retract_before_wipe"
|
||||
})
|
||||
append_single_option_line(opt_key, extruder_idx);
|
||||
create_line_with_near_label_widget(optgroup, opt_key, extruder_idx);
|
||||
}
|
||||
|
||||
void TabFilament::update_filament_overrides_page()
|
||||
|
@ -1914,14 +1928,7 @@ void TabFilament::update_filament_overrides_page()
|
|||
for (const std::string& opt_key : opt_keys)
|
||||
{
|
||||
bool is_checked = opt_key=="filament_retract_length" ? true : have_retract_length;
|
||||
m_overrides_options[opt_key]->Enable(is_checked);
|
||||
|
||||
is_checked &= !m_config->option(opt_key)->is_nil();
|
||||
m_overrides_options[opt_key]->SetValue(is_checked);
|
||||
|
||||
Field* field = optgroup->get_fieldc(opt_key, extruder_idx);
|
||||
if (field != nullptr)
|
||||
field->toggle(is_checked);
|
||||
update_line_with_near_label_widget(optgroup, opt_key, extruder_idx, is_checked);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1952,13 +1959,14 @@ void TabFilament::build()
|
|||
};
|
||||
|
||||
optgroup = page->new_optgroup(L("Temperature"));
|
||||
|
||||
create_line_with_near_label_widget(optgroup, "idle_temperature");
|
||||
|
||||
Line line = { L("Nozzle"), "" };
|
||||
line.append_option(optgroup->get_option("first_layer_temperature"));
|
||||
line.append_option(optgroup->get_option("temperature"));
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup->append_single_option_line("idle_temperature");
|
||||
|
||||
line = { L("Bed"), "" };
|
||||
line.append_option(optgroup->get_option("first_layer_bed_temperature"));
|
||||
line.append_option(optgroup->get_option("bed_temperature"));
|
||||
|
@ -2144,6 +2152,14 @@ void TabFilament::toggle_options()
|
|||
|
||||
if (m_active_page->title() == "Filament Overrides")
|
||||
update_filament_overrides_page();
|
||||
|
||||
if (m_active_page->title() == "Filament") {
|
||||
Page* page = m_active_page;
|
||||
|
||||
const auto og_it = std::find_if(page->m_optgroups.begin(), page->m_optgroups.end(), [](const ConfigOptionsGroupShp og) { return og->title == "Temperature"; });
|
||||
if (og_it != page->m_optgroups.end())
|
||||
update_line_with_near_label_widget(*og_it, "idle_temperature");
|
||||
}
|
||||
}
|
||||
|
||||
void TabFilament::update()
|
||||
|
|
|
@ -436,6 +436,8 @@ private:
|
|||
ogStaticText* m_volumetric_speed_description_line {nullptr};
|
||||
ogStaticText* m_cooling_description_line {nullptr};
|
||||
|
||||
void create_line_with_near_label_widget(ConfigOptionsGroupShp optgroup, const std::string &opt_key, int opt_index = 0);
|
||||
void update_line_with_near_label_widget(ConfigOptionsGroupShp optgroup, const std::string &opt_key, int opt_index = 0, bool is_checked = true);
|
||||
void add_filament_overrides_page();
|
||||
void update_filament_overrides_page();
|
||||
void update_volumetric_flow_preset_hints();
|
||||
|
|
Loading…
Reference in a new issue