Correct switching between printer_technologies (show/hide according tabs)

This commit is contained in:
YuSanka 2018-08-06 17:01:41 +02:00
parent d4c69a6258
commit 2af2b05bd6
7 changed files with 133 additions and 25 deletions

View File

@ -201,6 +201,8 @@ sub _init_tabpanel {
# load initial config # load initial config
my $full_config = wxTheApp->{preset_bundle}->full_config; my $full_config = wxTheApp->{preset_bundle}->full_config;
$self->{plater}->on_config_change($full_config); $self->{plater}->on_config_change($full_config);
#return if $num_extruders is undefined because of SLA printer is selected
return if (!defined $full_config->nozzle_diameter); # ys_FIXME
# Show a correct number of filament fields. # Show a correct number of filament fields.
$self->{plater}->on_extruders_change(int(@{$full_config->nozzle_diameter})); $self->{plater}->on_extruders_change(int(@{$full_config->nozzle_diameter}));
} }

View File

@ -2149,6 +2149,9 @@ void PrintConfigDef::init_sla_params()
def->tooltip = L("Default print profile associated with the current printer profile. " def->tooltip = L("Default print profile associated with the current printer profile. "
"On selection of the current printer profile, this print profile will be activated."); "On selection of the current printer profile, this print profile will be activated.");
def->default_value = new ConfigOptionString(); def->default_value = new ConfigOptionString();
def = this->add("sla_material_settings_id", coString);
def->default_value = new ConfigOptionString("");
} }
void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &value) void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &value)

View File

@ -127,6 +127,11 @@ std::shared_ptr<ConfigOptionsGroup> m_optgroup;
double m_brim_width = 0.0; double m_brim_width = 0.0;
wxButton* g_wiping_dialog_button = nullptr; wxButton* g_wiping_dialog_button = nullptr;
// Windows, associated with Print, Filament & Material Tabs accordingly
wxWindow *g_PrintTab = nullptr;
wxWindow *g_FilamentTab = nullptr;
wxWindow *g_MaterialTab = nullptr;
static void init_label_colours() static void init_label_colours()
{ {
auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
@ -502,7 +507,8 @@ void create_preset_tabs(bool no_controller, int event_value_change, int event_pr
add_created_tab(new TabPrinter (g_wxTabPanel, no_controller)); add_created_tab(new TabPrinter (g_wxTabPanel, no_controller));
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) { for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i)); Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
if (! tab || tab->GetName()=="sla_material") if (! tab ||
tab->GetName() == "sla_material")// ys_FIXME don't set event till doesn't exist material_preset combobox on plater
continue; continue;
tab->set_event_value_change(wxEventType(event_value_change)); tab->set_event_value_change(wxEventType(event_value_change));
tab->set_event_presets_changed(wxEventType(event_presets_changed)); tab->set_event_presets_changed(wxEventType(event_presets_changed));
@ -511,6 +517,9 @@ void create_preset_tabs(bool no_controller, int event_value_change, int event_pr
TabIface* get_preset_tab_iface(char *name) TabIface* get_preset_tab_iface(char *name)
{ {
if (std::strcmp(name, "print") == 0) return new TabIface(dynamic_cast<Tab*>(g_PrintTab));
if (std::strcmp(name, "filament") == 0) return new TabIface(dynamic_cast<Tab*>(g_FilamentTab));
if (std::strcmp(name, "material") == 0) return new TabIface(dynamic_cast<Tab*>(g_MaterialTab));
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) { for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i)); Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
if (! tab) if (! tab)
@ -634,6 +643,23 @@ void add_created_tab(Tab* panel)
// Load the currently selected preset into the GUI, update the preset selection box. // Load the currently selected preset into the GUI, update the preset selection box.
panel->load_current_preset(); panel->load_current_preset();
const wxString& tab_name = panel->GetName();
bool add_panel = true;
if (tab_name == "print") {
g_PrintTab = panel;
add_panel = g_PresetBundle->printers.get_edited_preset().printer_technology() == ptFFF;
}
else if (tab_name == "filament") {
g_FilamentTab = panel;
add_panel = g_PresetBundle->printers.get_edited_preset().printer_technology() == ptFFF;
}
else if (tab_name == "sla_material") {
g_MaterialTab = panel;
add_panel = g_PresetBundle->printers.get_edited_preset().printer_technology() == ptSLA;
}
if (add_panel)
g_wxTabPanel->AddPage(panel, panel->title()); g_wxTabPanel->AddPage(panel, panel->title());
} }
@ -675,6 +701,22 @@ PresetBundle* get_preset_bundle()
return g_PresetBundle; return g_PresetBundle;
} }
wxNotebook* get_tab_panel() {
return g_wxTabPanel;
}
wxWindow* get_print_tab() {
return g_PrintTab;
}
wxWindow* get_filament_tab(){
return g_FilamentTab;
}
wxWindow* get_material_tab(){
return g_MaterialTab;
}
const wxColour& get_label_clr_modified() { const wxColour& get_label_clr_modified() {
return g_color_label_modified; return g_color_label_modified;
} }

View File

@ -96,6 +96,7 @@ void set_3DScene(_3DScene *scene);
AppConfig* get_app_config(); AppConfig* get_app_config();
wxApp* get_app(); wxApp* get_app();
PresetBundle* get_preset_bundle(); PresetBundle* get_preset_bundle();
wxNotebook* get_tab_panel();
const wxColour& get_label_clr_modified(); const wxColour& get_label_clr_modified();
const wxColour& get_label_clr_sys(); const wxColour& get_label_clr_sys();
@ -107,6 +108,10 @@ void set_label_clr_sys(const wxColour& clr);
const wxFont& small_font(); const wxFont& small_font();
const wxFont& bold_font(); const wxFont& bold_font();
wxWindow* get_print_tab();
wxWindow* get_filament_tab();
wxWindow* get_material_tab();
extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change); extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change);
// This is called when closing the application, when loading a config file or when starting the config wizard // This is called when closing the application, when loading a config file or when starting the config wizard

View File

@ -313,6 +313,7 @@ void PresetBundle::load_selections(const AppConfig &config)
sla_materials.select_preset_by_name_strict(initial_sla_material_profile_name); sla_materials.select_preset_by_name_strict(initial_sla_material_profile_name);
printers.select_preset_by_name(initial_printer_profile_name, true); printers.select_preset_by_name(initial_printer_profile_name, true);
if (printers.get_selected_preset().printer_technology() == ptFFF){
// Load the names of the other filament profiles selected for a multi-material printer. // Load the names of the other filament profiles selected for a multi-material printer.
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(printers.get_selected_preset().config.option("nozzle_diameter")); auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(printers.get_selected_preset().config.option("nozzle_diameter"));
size_t num_extruders = nozzle_diameter->values.size(); size_t num_extruders = nozzle_diameter->values.size();
@ -326,6 +327,7 @@ void PresetBundle::load_selections(const AppConfig &config)
} }
// Do not define the missing filaments, so that the update_compatible_with_printer() will use the preferred filaments. // Do not define the missing filaments, so that the update_compatible_with_printer() will use the preferred filaments.
this->filament_presets.resize(num_extruders, ""); this->filament_presets.resize(num_extruders, "");
}
// Update visibility of presets based on their compatibility with the active printer. // Update visibility of presets based on their compatibility with the active printer.
// Always try to select a compatible print and filament preset to the current printer preset, // Always try to select a compatible print and filament preset to the current printer preset,
@ -523,8 +525,8 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
// Collect the "compatible_printers_condition" and "inherits" values over all presets (sla_materials, printers) into a single vector. // Collect the "compatible_printers_condition" and "inherits" values over all presets (sla_materials, printers) into a single vector.
std::vector<std::string> compatible_printers_condition; std::vector<std::string> compatible_printers_condition;
std::vector<std::string> inherits; std::vector<std::string> inherits;
compatible_printers_condition.emplace_back(this->prints.get_edited_preset().compatible_printers_condition()); compatible_printers_condition.emplace_back(this->/*prints*/sla_materials.get_edited_preset().compatible_printers_condition());
inherits .emplace_back(this->prints.get_edited_preset().inherits()); inherits .emplace_back(this->/*prints*/sla_materials.get_edited_preset().inherits());
inherits .emplace_back(this->printers.get_edited_preset().inherits()); inherits .emplace_back(this->printers.get_edited_preset().inherits());
// These two value types clash between the print and filament profiles. They should be renamed. // These two value types clash between the print and filament profiles. They should be renamed.

View File

@ -681,6 +681,8 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
// Show/hide the 'purging volumes' button // Show/hide the 'purging volumes' button
void Tab::update_wiping_button_visibility() { void Tab::update_wiping_button_visibility() {
if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA)
return; // ys_FIXME
bool wipe_tower_enabled = dynamic_cast<ConfigOptionBool*>( (m_preset_bundle->prints.get_edited_preset().config ).option("wipe_tower"))->value; bool wipe_tower_enabled = dynamic_cast<ConfigOptionBool*>( (m_preset_bundle->prints.get_edited_preset().config ).option("wipe_tower"))->value;
bool multiple_extruders = dynamic_cast<ConfigOptionFloats*>((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; bool multiple_extruders = dynamic_cast<ConfigOptionFloats*>((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1;
bool single_extruder_mm = dynamic_cast<ConfigOptionBool*>( (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; bool single_extruder_mm = dynamic_cast<ConfigOptionBool*>( (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value;
@ -700,6 +702,8 @@ void Tab::update_wiping_button_visibility() {
// to uddate number of "filament" selection boxes when the number of extruders change. // to uddate number of "filament" selection boxes when the number of extruders change.
void Tab::on_presets_changed() void Tab::on_presets_changed()
{ {
if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA)
return; // ys_FIXME
if (m_event_presets_changed > 0) { if (m_event_presets_changed > 0) {
wxCommandEvent event(m_event_presets_changed); wxCommandEvent event(m_event_presets_changed);
event.SetString(m_name); event.SetString(m_name);
@ -1007,6 +1011,9 @@ void TabPrint::reload_config(){
void TabPrint::update() void TabPrint::update()
{ {
if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA)
return; // ys_FIXME
Freeze(); Freeze();
double fill_density = m_config->option<ConfigOptionPercent>("fill_density")->value; double fill_density = m_config->option<ConfigOptionPercent>("fill_density")->value;
@ -1363,6 +1370,9 @@ void TabFilament::reload_config(){
void TabFilament::update() void TabFilament::update()
{ {
if (get_preset_bundle()->printers.get_selected_preset().printer_technology() == ptSLA)
return; // ys_FIXME
Freeze(); Freeze();
wxString text = from_u8(PresetHints::cooling_description(m_presets->get_edited_preset())); wxString text = from_u8(PresetHints::cooling_description(m_presets->get_edited_preset()));
m_cooling_description_line->SetText(text); m_cooling_description_line->SetText(text);
@ -1408,6 +1418,13 @@ void TabPrinter::build()
m_presets = &m_preset_bundle->printers; m_presets = &m_preset_bundle->printers;
load_initial_data(); load_initial_data();
m_printer_technology_old = m_presets->get_selected_preset().printer_technology();
if (m_presets->get_selected_preset().printer_technology() == ptSLA){
build_sla();
return;
}
m_current_pages = &m_pages; m_current_pages = &m_pages;
// to avoid redundant memory allocation / deallocation during extruders count changing // to avoid redundant memory allocation / deallocation during extruders count changing
@ -1688,8 +1705,6 @@ void TabPrinter::build()
if (!m_no_controller) if (!m_no_controller)
update_serial_ports(); update_serial_ports();
build_sla();
} }
void TabPrinter::build_sla() void TabPrinter::build_sla()
@ -1947,6 +1962,7 @@ void TabPrinter::build_extruder_pages()
// this gets executed after preset is loaded and before GUI fields are updated // this gets executed after preset is loaded and before GUI fields are updated
void TabPrinter::on_preset_loaded() void TabPrinter::on_preset_loaded()
{ {
return; // ys_FIXME
// update the extruders count field // update the extruders count field
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter")); auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"));
int extruders_count = nozzle_diameter->values.size(); int extruders_count = nozzle_diameter->values.size();
@ -1956,6 +1972,7 @@ void TabPrinter::on_preset_loaded()
} }
void TabPrinter::update(){ void TabPrinter::update(){
return; // ys_FIXME
Freeze(); Freeze();
bool en; bool en;
@ -2060,11 +2077,16 @@ void Tab::load_current_preset()
auto preset = m_presets->get_edited_preset(); auto preset = m_presets->get_edited_preset();
(preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); (preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true);
if (m_name == "printer" && m_presets->get_edited_preset().printer_technology() == ptSLA) {} // ys_FIXME
else {
update(); update();
// For the printer profile, generate the extruder pages. // For the printer profile, generate the extruder pages.
on_preset_loaded(); on_preset_loaded();
// Reload preset pages with the new configuration values. // Reload preset pages with the new configuration values.
reload_config(); reload_config();
}
m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet;
m_ttg_non_system = m_presets->get_selected_preset_parent() ? &m_ttg_value_unlock : &m_ttg_white_bullet_ns; m_ttg_non_system = m_presets->get_selected_preset_parent() ? &m_ttg_value_unlock : &m_ttg_white_bullet_ns;
m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_ttg_white_bullet_ns; m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_ttg_white_bullet_ns;
@ -2080,6 +2102,35 @@ void Tab::load_current_preset()
if (!checked_tab(this)) if (!checked_tab(this))
return; return;
update_tab_ui(); update_tab_ui();
// update show/hide tabs
if (m_name == "printer"){
bool printer_technology = m_presets->get_edited_preset().printer_technology();
if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology_old)
{
wxWindow* del_page = printer_technology == ptFFF ? get_material_tab() : get_print_tab();
int del_page_id = get_tab_panel()->FindPage(del_page);
if (del_page_id != wxNOT_FOUND) {
if (printer_technology == ptFFF)
{
get_tab_panel()->GetPage(del_page_id)->Show(false);
get_tab_panel()->RemovePage(del_page_id);
get_tab_panel()->InsertPage(del_page_id, get_filament_tab(), static_cast<Tab*>(get_filament_tab())->title());
get_tab_panel()->InsertPage(del_page_id, get_print_tab(), static_cast<Tab*>(get_print_tab())->title());
}
else
{
for (int i = 0; i < 2; ++i) {
get_tab_panel()->GetPage(del_page_id)->Show(false);
get_tab_panel()->RemovePage(del_page_id);
}
get_tab_panel()->InsertPage(del_page_id, get_material_tab(), static_cast<Tab*>(get_material_tab())->title());
}
static_cast<TabPrinter*>(this)->m_printer_technology_old = printer_technology;
}
}
}
on_presets_changed(); on_presets_changed();
if (name() == "print") if (name() == "print")
@ -2172,6 +2223,7 @@ void Tab::select_preset(std::string preset_name /*= ""*/)
if (! canceled) { if (! canceled) {
for (PresetUpdate &pu : updates) { for (PresetUpdate &pu : updates) {
// The preset will be switched to a different, compatible preset, or the '-- default --'. // The preset will be switched to a different, compatible preset, or the '-- default --'.
if (pu.technology == new_printer_technology)
m_reload_dependent_tabs.emplace_back(pu.name); m_reload_dependent_tabs.emplace_back(pu.name);
if (pu.old_preset_dirty) if (pu.old_preset_dirty)
pu.presets->discard_current_changes(); pu.presets->discard_current_changes();

View File

@ -330,6 +330,8 @@ public:
size_t m_initial_extruders_count; size_t m_initial_extruders_count;
size_t m_sys_extruders_count; size_t m_sys_extruders_count;
bool m_printer_technology_old = ptFFF;
std::vector<PageShp> *m_current_pages; std::vector<PageShp> *m_current_pages;
TabPrinter() {} TabPrinter() {}