Correct UI updating for SLA tabs

This commit is contained in:
YuSanka 2018-08-08 17:47:59 +02:00
parent adf003f0ed
commit 5dbc8fb427
5 changed files with 47 additions and 18 deletions

View file

@ -2079,14 +2079,15 @@ void PrintConfigDef::init_sla_params()
def->default_value = new ConfigOptionFloat(100.);
def = this->add("display_pixels_x", coInt);
def->label = L("Number of pixels in X");
def->full_label = L("Number of pixels in");
def->label = ("X");
def->tooltip = L("Number of pixels in X");
def->cli = "display-pixels-x=i";
def->min = 100;
def->default_value = new ConfigOptionInt(2000);
def = this->add("display_pixels_y", coInt);
def->label = L("Number of pixels in Y");
def->label = ("Y");
def->tooltip = L("Number of pixels in Y");
def->cli = "display-pixels-y=i";
def->min = 100;

View file

@ -387,6 +387,7 @@ const std::vector<std::string>& Preset::sla_material_options()
"exposure_time", "initial_exposure_time",
"material_correction_printing", "material_correction_curing",
"material_notes",
"compatible_printers",
"compatible_printers_condition", "inherits"
};
}
@ -895,11 +896,11 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui)
return was_dirty != is_dirty;
}
std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool is_printer_type /*= false*/)
std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare /*= false*/)
{
std::vector<std::string> changed;
if (edited != nullptr && reference != nullptr) {
changed = is_printer_type ?
changed = deep_compare ?
reference->config.deep_diff(edited->config) :
reference->config.diff(edited->config);
// The "compatible_printers" option key is handled differently from the others:

View file

@ -342,11 +342,11 @@ public:
// Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ.
bool current_is_dirty() const { return ! this->current_dirty_options().empty(); }
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
std::vector<std::string> current_dirty_options(const bool is_printer_type = false) const
{ return dirty_options(&this->get_edited_preset(), &this->get_selected_preset(), is_printer_type); }
std::vector<std::string> current_dirty_options(const bool deep_compare = false) const
{ return dirty_options(&this->get_edited_preset(), &this->get_selected_preset(), deep_compare); }
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
std::vector<std::string> current_different_from_parent_options(const bool is_printer_type = false) const
{ return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), is_printer_type); }
std::vector<std::string> current_different_from_parent_options(const bool deep_compare = false) const
{ return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), deep_compare); }
// Update the choice UI from the list of presets.
// If show_incompatible, all presets are shown, otherwise only the compatible presets are shown.

View file

@ -314,10 +314,10 @@ void Tab::update_changed_ui()
if (m_postpone_update_ui)
return;
const bool is_printer_type = (name() == "printer");
auto dirty_options = m_presets->current_dirty_options(is_printer_type);
auto nonsys_options = m_presets->current_different_from_parent_options(is_printer_type);
if (is_printer_type){
const bool deep_compare = (m_name == "printer" || m_name == "sla_material");
auto dirty_options = m_presets->current_dirty_options(deep_compare);
auto nonsys_options = m_presets->current_different_from_parent_options(deep_compare);
if (name() == "printer"){
TabPrinter* tab = static_cast<TabPrinter*>(this);
if (tab->m_initial_extruders_count != tab->m_extruders_count)
dirty_options.emplace_back("extruders_count");
@ -398,7 +398,7 @@ void Tab::init_options_list()
}
template<class T>
void add_correct_opts_to_options_list(const std::string &opt_key, std::map<std::string, int>& map, TabPrinter *tab, const int& value)
void add_correct_opts_to_options_list(const std::string &opt_key, std::map<std::string, int>& map, Tab *tab, const int& value)
{
T *opt_cur = static_cast<T*>(tab->m_config->option(opt_key));
for (int i = 0; i < opt_cur->values.size(); i++)
@ -430,6 +430,30 @@ void TabPrinter::init_options_list()
m_options_list.emplace("extruders_count", m_opt_status_value);
}
void TabSLAMaterial::init_options_list()
{
if (!m_options_list.empty())
m_options_list.clear();
for (const auto opt_key : m_config->keys())
{
if (opt_key == "compatible_printers"){
m_options_list.emplace(opt_key, m_opt_status_value);
continue;
}
switch (m_config->option(opt_key)->type())
{
case coInts: add_correct_opts_to_options_list<ConfigOptionInts >(opt_key, m_options_list, this, m_opt_status_value); break;
case coBools: add_correct_opts_to_options_list<ConfigOptionBools >(opt_key, m_options_list, this, m_opt_status_value); break;
case coFloats: add_correct_opts_to_options_list<ConfigOptionFloats >(opt_key, m_options_list, this, m_opt_status_value); break;
case coStrings: add_correct_opts_to_options_list<ConfigOptionStrings >(opt_key, m_options_list, this, m_opt_status_value); break;
case coPercents:add_correct_opts_to_options_list<ConfigOptionPercents >(opt_key, m_options_list, this, m_opt_status_value); break;
case coPoints: add_correct_opts_to_options_list<ConfigOptionPoints >(opt_key, m_options_list, this, m_opt_status_value); break;
default: m_options_list.emplace(opt_key, m_opt_status_value); break;
}
}
}
void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page)
{
auto opt = m_options_list.find(opt_key);
@ -1750,8 +1774,9 @@ void TabPrinter::build_sla()
optgroup->append_single_option_line("display_width");
optgroup->append_single_option_line("display_height");
line = { _(L("Number of pixels in axes")), "" };
line.append_option(optgroup->get_option("display_pixels_x"));
auto option = optgroup->get_option("display_pixels_x");
line = { _(option.opt.full_label), "" };
line.append_option(option);
line.append_option(optgroup->get_option("display_pixels_y"));
optgroup->append_line(line);
@ -1769,7 +1794,7 @@ void TabPrinter::build_sla()
page = add_options_page(_(L("Notes")), "note.png");
optgroup = page->new_optgroup(_(L("Notes")), 0);
auto option = optgroup->get_option("printer_notes");
option = optgroup->get_option("printer_notes");
option.opt.full_width = true;
option.opt.height = 250;
optgroup->append_single_option_line(option);
@ -2215,7 +2240,7 @@ void Tab::select_preset(std::string preset_name /*= ""*/)
auto printer_tab = m_presets->name() == "printer";
auto canceled = false;
m_reload_dependent_tabs = {};
if (!current_dirty && !may_discard_current_dirty_preset()) {
if (current_dirty && !may_discard_current_dirty_preset()) {
canceled = true;
} else if (printer_tab) {
// Before switching the printer to a new one, verify, whether the currently active print and filament
@ -2921,7 +2946,7 @@ void TabSLAMaterial::build()
m_presets = &m_preset_bundle->sla_materials;
load_initial_data();
auto page = add_options_page(_(L("General")), "spool.png");
auto page = add_options_page(_(L("Material")), "spool.png");
auto optgroup = page->new_optgroup(_(L("Layers")));
optgroup->append_single_option_line("layer_height");
@ -2932,6 +2957,7 @@ void TabSLAMaterial::build()
optgroup->append_single_option_line("initial_exposure_time");
optgroup = page->new_optgroup(_(L("Corrections")));
optgroup->label_width = 190;
std::vector<std::string> corrections = { "material_correction_printing", "material_correction_curing" };
std::vector<std::string> axes{ "X", "Y", "Z" };
for (auto& opt_key : corrections){

View file

@ -362,6 +362,7 @@ public:
void build() override;
void update() override;
void init_options_list() override;
};
class SavePresetWindow :public wxDialog