From 610d35fcab1ca223a2f50d1ad397f95424115ffd Mon Sep 17 00:00:00 2001 From: remi durand Date: Wed, 9 Jun 2021 21:21:20 +0200 Subject: [PATCH] fix icon for sla --- src/libslic3r/Preset.cpp | 12 +- src/libslic3r/Preset.hpp | 38 +++-- src/libslic3r/PresetBundle.cpp | 14 +- src/slic3r/GUI/CalibrationBedDialog.cpp | 6 +- src/slic3r/GUI/CalibrationBridgeDialog.cpp | 6 +- src/slic3r/GUI/CalibrationCubeDialog.cpp | 4 +- src/slic3r/GUI/CalibrationFlowDialog.cpp | 6 +- .../GUI/CalibrationOverBridgeDialog.cpp | 4 +- .../GUI/CalibrationRetractionDialog.cpp | 16 +- src/slic3r/GUI/CalibrationTempDialog.cpp | 8 +- src/slic3r/GUI/GLCanvas3D.cpp | 2 +- src/slic3r/GUI/MainFrame.cpp | 152 ++++++++++++------ src/slic3r/GUI/MainFrame.hpp | 12 +- src/slic3r/GUI/Plater.cpp | 22 +-- src/slic3r/GUI/PresetComboBoxes.cpp | 24 +-- src/slic3r/GUI/Search.cpp | 4 +- src/slic3r/GUI/Tab.cpp | 64 ++++---- src/slic3r/GUI/Tab.hpp | 4 +- src/slic3r/GUI/UnsavedChangesDialog.cpp | 4 +- 19 files changed, 231 insertions(+), 171 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 676daa70a..7433980dc 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -420,8 +420,8 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config) if (model.empty() || variant.empty()) return; is_visible = app_config.get_variant(vendor->id, model, variant); - } else if (type == TYPE_FILAMENT || type == TYPE_SLA_MATERIAL) { - const std::string §ion_name = (type == TYPE_FILAMENT) ? AppConfig::SECTION_FILAMENTS : AppConfig::SECTION_MATERIALS; + } else if (type == TYPE_FFF_FILAMENT || type == TYPE_SLA_MATERIAL) { + const std::string §ion_name = (type == TYPE_FFF_FILAMENT) ? AppConfig::SECTION_FILAMENTS : AppConfig::SECTION_MATERIALS; if (app_config.has_section(section_name)) { // Check whether this profile is marked as "installed" in PrusaSlicer.ini, // or whether a profile is marked as "installed", which this profile may have been renamed from. @@ -1551,8 +1551,8 @@ void PresetCollection::update_map_system_profile_renamed() std::string PresetCollection::name() const { switch (this->type()) { - case Preset::TYPE_PRINT: return L("print"); - case Preset::TYPE_FILAMENT: return L("filament"); + case Preset::TYPE_FFF_PRINT: return L("print"); + case Preset::TYPE_FFF_FILAMENT: return L("filament"); case Preset::TYPE_SLA_PRINT: return L("SLA print"); case Preset::TYPE_SLA_MATERIAL: return L("SLA material"); case Preset::TYPE_PRINTER: return L("printer"); @@ -1563,8 +1563,8 @@ std::string PresetCollection::name() const std::string PresetCollection::section_name() const { switch (this->type()) { - case Preset::TYPE_PRINT: return "print"; - case Preset::TYPE_FILAMENT: return "filament"; + case Preset::TYPE_FFF_PRINT: return "print"; + case Preset::TYPE_FFF_FILAMENT: return "filament"; case Preset::TYPE_SLA_PRINT: return "sla_print"; case Preset::TYPE_SLA_MATERIAL: return "sla_material"; case Preset::TYPE_PRINTER: return "printer"; diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index ec57f45c2..2978acbaf 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -110,15 +110,20 @@ typedef std::map VendorMap; class Preset { public: - enum Type + enum Type : uint8_t { - TYPE_INVALID, - TYPE_PRINT, - TYPE_SLA_PRINT, - TYPE_FILAMENT, - TYPE_SLA_MATERIAL, - TYPE_PRINTER, - TYPE_COUNT, + TYPE_INVALID = 0, + TYPE_PRINT1 = 1 << 0, + TYPE_MATERIAL = 1 << 1, + TYPE_PRINTER = 1 << 2, + TYPE_TAB = TYPE_PRINT1 | TYPE_MATERIAL | TYPE_PRINTER, + TYPE_FFF = 1 << 3, + TYPE_FFF_PRINT = TYPE_FFF | TYPE_PRINT1, + TYPE_FFF_FILAMENT = TYPE_FFF | TYPE_MATERIAL, + TYPE_SLA = 1 << 4, + TYPE_SLA_PRINT = TYPE_SLA | TYPE_PRINT1, + TYPE_SLA_MATERIAL = TYPE_SLA | TYPE_MATERIAL, + TYPE_TECHNOLOGY = TYPE_FFF | TYPE_SLA, }; Preset(Type type, const std::string &name, bool is_default = false) : type(type), is_default(is_default), name(name) {} @@ -184,7 +189,7 @@ public: // Returns the "compatible_prints_condition". static std::string& compatible_prints_condition(DynamicPrintConfig &cfg) { return cfg.option("compatible_prints_condition", true)->value; } std::string& compatible_prints_condition() { - assert(this->type == TYPE_FILAMENT || this->type == TYPE_SLA_MATERIAL); + assert(this->type == TYPE_FFF_FILAMENT || this->type == TYPE_SLA_MATERIAL); return Preset::compatible_prints_condition(this->config); } const std::string& compatible_prints_condition() const { return const_cast(this)->compatible_prints_condition(); } @@ -192,7 +197,7 @@ public: // Returns the "compatible_printers_condition". static std::string& compatible_printers_condition(DynamicPrintConfig &cfg) { return cfg.option("compatible_printers_condition", true)->value; } std::string& compatible_printers_condition() { - assert(this->type == TYPE_PRINT || this->type == TYPE_SLA_PRINT || this->type == TYPE_FILAMENT || this->type == TYPE_SLA_MATERIAL); + assert(this->type == TYPE_FFF_PRINT || this->type == TYPE_SLA_PRINT || this->type == TYPE_FFF_FILAMENT || this->type == TYPE_SLA_MATERIAL); return Preset::compatible_printers_condition(this->config); } const std::string& compatible_printers_condition() const { return const_cast(this)->compatible_printers_condition(); } @@ -251,6 +256,19 @@ bool is_compatible_with_print (const PresetWithVendorProfile &preset, const Pre bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config); bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer); +inline Preset::Type operator|(Preset::Type a, Preset::Type b) { + return static_cast(static_cast(a) | static_cast(b)); +} +inline Preset::Type operator&(Preset::Type a, Preset::Type b) { + return static_cast(static_cast(a) & static_cast(b)); +} +inline Preset::Type operator|=(Preset::Type& a, Preset::Type b) { + a = a | b; return a; +} +inline Preset::Type operator&=(Preset::Type& a, Preset::Type b) { + a = a & b; return a; +} + enum class PresetSelectCompatibleType { // Never select a compatible preset if the newly selected profile is not compatible. Never, diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index ce7ca17ce..e5f561342 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -38,8 +38,8 @@ static std::vector s_project_options { const char *PresetBundle::PRUSA_BUNDLE = "PrusaResearch"; PresetBundle::PresetBundle() : - prints(Preset::TYPE_PRINT, Preset::print_options(), static_cast(FullPrintConfig::defaults())), - filaments(Preset::TYPE_FILAMENT, Preset::filament_options(), static_cast(FullPrintConfig::defaults())), + prints(Preset::TYPE_FFF_PRINT, Preset::print_options(), static_cast(FullPrintConfig::defaults())), + filaments(Preset::TYPE_FFF_FILAMENT, Preset::filament_options(), static_cast(FullPrintConfig::defaults())), sla_materials(Preset::TYPE_SLA_MATERIAL, Preset::sla_material_options(), static_cast(SLAFullPrintConfig::defaults())), sla_prints(Preset::TYPE_SLA_PRINT, Preset::sla_print_options(), static_cast(SLAFullPrintConfig::defaults())), printers(Preset::TYPE_PRINTER, Preset::printer_options(), static_cast(FullPrintConfig::defaults()), "- default FFF -"), @@ -320,9 +320,9 @@ const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& p if (preset_type == Preset::TYPE_PRINTER || preset_type == Preset::TYPE_INVALID) return alias; - const PresetCollection& presets = preset_type == Preset::TYPE_PRINT ? prints : + const PresetCollection& presets = preset_type == Preset::TYPE_FFF_PRINT ? prints : preset_type == Preset::TYPE_SLA_PRINT ? sla_prints : - preset_type == Preset::TYPE_FILAMENT ? filaments : + preset_type == Preset::TYPE_FFF_FILAMENT ? filaments : sla_materials; return presets.get_preset_name_by_alias(alias); @@ -331,9 +331,9 @@ const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& p void PresetBundle::save_changes_for_preset(const std::string& new_name, Preset::Type type, const std::vector& unselected_options) { - PresetCollection& presets = type == Preset::TYPE_PRINT ? prints : + PresetCollection& presets = type == Preset::TYPE_FFF_PRINT ? prints : type == Preset::TYPE_SLA_PRINT ? sla_prints : - type == Preset::TYPE_FILAMENT ? filaments : + type == Preset::TYPE_FFF_FILAMENT ? filaments : type == Preset::TYPE_SLA_MATERIAL ? sla_materials : printers; // if we want to save just some from selected options @@ -348,7 +348,7 @@ void PresetBundle::save_changes_for_preset(const std::string& new_name, Preset:: // If saving the preset changes compatibility with other presets, keep the now incompatible dependent presets selected, however with a "red flag" icon showing that they are no more compatible. update_compatible(PresetSelectCompatibleType::Never); - if (type == Preset::TYPE_FILAMENT) { + if (type == Preset::TYPE_FFF_FILAMENT) { // synchronize the first filament presets. set_filament_preset(0, filaments.get_selected_preset_name()); } diff --git a/src/slic3r/GUI/CalibrationBedDialog.cpp b/src/slic3r/GUI/CalibrationBedDialog.cpp index 88bed058f..69ee9a69b 100644 --- a/src/slic3r/GUI/CalibrationBedDialog.cpp +++ b/src/slic3r/GUI/CalibrationBedDialog.cpp @@ -50,7 +50,7 @@ void CalibrationBedDialog::create_geometry(wxCommandEvent& event_args) { Slic3r::resources_dir()+"/calibration/bed_leveling/patch.amf"}, true, false, false); assert(objs_idx.size() == 5); - const DynamicPrintConfig* printConfig = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); + const DynamicPrintConfig* printConfig = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); const DynamicPrintConfig* printerConfig = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); /// --- scale --- @@ -134,10 +134,10 @@ void CalibrationBedDialog::create_geometry(wxCommandEvent& event_args) { } //update plater - this->gui_app->get_tab(Preset::TYPE_PRINT)->load_config(new_print_config); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->load_config(new_print_config); plat->on_config_change(new_print_config); plat->changed_objects(objs_idx); - this->gui_app->get_tab(Preset::TYPE_PRINT)->update_dirty(); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->update_dirty(); //update everything, easier to code. this->gui_app->obj_list()->update_after_undo_redo(); //if(!plat->is_background_process_update_scheduled()) diff --git a/src/slic3r/GUI/CalibrationBridgeDialog.cpp b/src/slic3r/GUI/CalibrationBridgeDialog.cpp index 5e527e06a..894f1bb13 100644 --- a/src/slic3r/GUI/CalibrationBridgeDialog.cpp +++ b/src/slic3r/GUI/CalibrationBridgeDialog.cpp @@ -77,7 +77,7 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool std::vector objs_idx = plat->load_files(items, true, false, false); assert(objs_idx.size() == nb_items); - const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); + const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); const DynamicPrintConfig* printer_config = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); /// --- scale --- @@ -143,10 +143,10 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool } //update plater - this->gui_app->get_tab(Preset::TYPE_PRINT)->load_config(new_print_config); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->load_config(new_print_config); plat->on_config_change(new_print_config); plat->changed_objects(objs_idx); - //this->gui_app->get_tab(Preset::TYPE_PRINT)->update_dirty(); + //this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->update_dirty(); //update everything, easier to code. ObjectList* obj = this->gui_app->obj_list(); obj->update_after_undo_redo(); diff --git a/src/slic3r/GUI/CalibrationCubeDialog.cpp b/src/slic3r/GUI/CalibrationCubeDialog.cpp index 9595ed67c..0d22e9574 100644 --- a/src/slic3r/GUI/CalibrationCubeDialog.cpp +++ b/src/slic3r/GUI/CalibrationCubeDialog.cpp @@ -64,8 +64,8 @@ void CalibrationCubeDialog::create_geometry(std::string calibration_path) { Slic3r::resources_dir()+"/calibration/cube/"+ calibration_path}, true, false, false); assert(objs_idx.size() == 1); - const DynamicPrintConfig* printConfig = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); - const DynamicPrintConfig* filamentConfig = this->gui_app->get_tab(Preset::TYPE_FILAMENT)->get_config(); + const DynamicPrintConfig* printConfig = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); + const DynamicPrintConfig* filamentConfig = this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->get_config(); const DynamicPrintConfig* printerConfig = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); /// --- scale --- diff --git a/src/slic3r/GUI/CalibrationFlowDialog.cpp b/src/slic3r/GUI/CalibrationFlowDialog.cpp index 7233662e7..896de83c6 100644 --- a/src/slic3r/GUI/CalibrationFlowDialog.cpp +++ b/src/slic3r/GUI/CalibrationFlowDialog.cpp @@ -56,7 +56,7 @@ void CalibrationFlowDialog::create_geometry(float start, float delta) { assert(objs_idx.size() == 5); - const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); + const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); const DynamicPrintConfig* printerConfig = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); /// --- scale --- @@ -159,10 +159,10 @@ void CalibrationFlowDialog::create_geometry(float start, float delta) { } //update plater - this->gui_app->get_tab(Preset::TYPE_PRINT)->load_config(new_print_config); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->load_config(new_print_config); plat->on_config_change(new_print_config); plat->changed_objects(objs_idx); - this->gui_app->get_tab(Preset::TYPE_PRINT)->update_dirty(); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->update_dirty(); //update everything, easier to code. ObjectList* obj = this->gui_app->obj_list(); obj->update_after_undo_redo(); diff --git a/src/slic3r/GUI/CalibrationOverBridgeDialog.cpp b/src/slic3r/GUI/CalibrationOverBridgeDialog.cpp index 6a7c9e74c..445febe6c 100644 --- a/src/slic3r/GUI/CalibrationOverBridgeDialog.cpp +++ b/src/slic3r/GUI/CalibrationOverBridgeDialog.cpp @@ -61,7 +61,7 @@ void CalibrationOverBridgeDialog::create_geometry(bool over_bridge) { Slic3r::resources_dir()+"/calibration/over-bridge_tuning/over-bridge_flow_ratio_test.amf"}, true, false, false); assert(objs_idx.size() == 6); - const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); + const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); const DynamicPrintConfig* printer_config = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); /// --- scale --- @@ -135,7 +135,7 @@ void CalibrationOverBridgeDialog::create_geometry(bool over_bridge) { } //update plater - this->gui_app->get_tab(Preset::TYPE_PRINT)->load_config(new_print_config); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->load_config(new_print_config); plat->on_config_change(new_print_config); plat->changed_objects(objs_idx); //update everything, easier to code. diff --git a/src/slic3r/GUI/CalibrationRetractionDialog.cpp b/src/slic3r/GUI/CalibrationRetractionDialog.cpp index 3f83cc084..2cad9e6f5 100644 --- a/src/slic3r/GUI/CalibrationRetractionDialog.cpp +++ b/src/slic3r/GUI/CalibrationRetractionDialog.cpp @@ -38,7 +38,7 @@ void CalibrationRetractionDialog::create_buttons(wxStdDialogButtonSizer* buttons //start_step = new wxComboBox(this, wxID_ANY, wxString{ "current" }, wxDefaultPosition, wxDefaultSize, 7, choices_start); //start_step->SetToolTip(_(L("Select the highest temperature to test for."))); //start_step->SetSelection(0); - const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FILAMENT)->get_config(); + const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->get_config(); int temp = int((2 + filament_config->option("temperature")->get_at(0)) / 5) * 5; auto size = wxSize(4 * em_unit(), wxDefaultCoord); temp_start = new wxTextCtrl(this, wxID_ANY, std::to_string(temp), wxDefaultPosition, size); @@ -76,7 +76,7 @@ void CalibrationRetractionDialog::create_buttons(wxStdDialogButtonSizer* buttons void CalibrationRetractionDialog::remove_slowdown(wxCommandEvent& event_args) { - const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FILAMENT)->get_config(); + const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->get_config(); DynamicPrintConfig new_filament_config = *filament_config; //make a copy const ConfigOptionInts *fil_conf = filament_config->option("slowdown_below_layer_time"); @@ -92,9 +92,9 @@ void CalibrationRetractionDialog::remove_slowdown(wxCommandEvent& event_args) { new_fil_conf->values[0] = 0; new_filament_config.set_key_value("fan_below_layer_time", new_fil_conf); - this->gui_app->get_tab(Preset::TYPE_FILAMENT)->load_config(new_filament_config); + this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->load_config(new_filament_config); this->main_frame->plater()->on_config_change(new_filament_config); - this->gui_app->get_tab(Preset::TYPE_FILAMENT)->update_dirty(); + this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->update_dirty(); } @@ -134,9 +134,9 @@ void CalibrationRetractionDialog::create_geometry(wxCommandEvent& event_args) { assert(objs_idx.size() == nb_items); - const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); + const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); const DynamicPrintConfig* printer_config = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); - const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FILAMENT)->get_config(); + const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->get_config(); double retraction_start = 0; std::string str = temp_start->GetValue().ToStdString(); @@ -248,8 +248,8 @@ void CalibrationRetractionDialog::create_geometry(wxCommandEvent& event_args) { if (print_config->option("skirts")->getInt() > 0 && print_config->option("skirt_height")->getInt() > 0) { new_print_config.set_key_value("complete_objects_one_skirt", new ConfigOptionBool(true)); } - this->gui_app->get_tab(Preset::TYPE_PRINT)->load_config(new_print_config); - this->gui_app->get_tab(Preset::TYPE_PRINT)->update_dirty(); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->load_config(new_print_config); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->update_dirty(); plat->on_config_change(new_print_config); } diff --git a/src/slic3r/GUI/CalibrationTempDialog.cpp b/src/slic3r/GUI/CalibrationTempDialog.cpp index f1525a586..0665de104 100644 --- a/src/slic3r/GUI/CalibrationTempDialog.cpp +++ b/src/slic3r/GUI/CalibrationTempDialog.cpp @@ -63,8 +63,8 @@ void CalibrationTempDialog::create_geometry(wxCommandEvent& event_args) { Slic3r::resources_dir()+"/calibration/filament_temp/Smart_compact_temperature_calibration_item.amf"}, true, false, false); assert(objs_idx.size() == 1); - const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_PRINT)->get_config(); - const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FILAMENT)->get_config(); + const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config(); + const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->get_config(); const DynamicPrintConfig* printer_config = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config(); // -- get temps @@ -165,12 +165,12 @@ void CalibrationTempDialog::create_geometry(wxCommandEvent& event_args) { model.objects[objs_idx[0]]->config.set_key_value("top_fill_pattern", new ConfigOptionEnum(ipRectilinearWGapFill)); //update plater - this->gui_app->get_tab(Preset::TYPE_PRINT)->load_config(new_print_config); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->load_config(new_print_config); plat->on_config_change(new_print_config); //this->gui_app->get_tab(Preset::TYPE_PRINTER)->load_config(new_printer_config); //plat->on_config_change(new_printer_config); plat->changed_objects(objs_idx); - this->gui_app->get_tab(Preset::TYPE_PRINT)->update_dirty(); + this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->update_dirty(); //this->gui_app->get_tab(Preset::TYPE_PRINTER)->update_dirty(); plat->is_preview_shown(); //update everything, easier to code. diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 8cf055446..0218d6b8c 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -6538,7 +6538,7 @@ void GLCanvas3D::WipeTowerInfo::apply_wipe_tower() const cfg.opt("wipe_tower_x", true)->value = m_pos(X); cfg.opt("wipe_tower_y", true)->value = m_pos(Y); cfg.opt("wipe_tower_rotation_angle", true)->value = (180./M_PI) * m_rotation; - wxGetApp().get_tab(Preset::TYPE_PRINT)->load_config(cfg); + wxGetApp().get_tab(Preset::TYPE_FFF_PRINT)->load_config(cfg); } diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 9d945be0e..c0f3cfc6e 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -253,6 +253,61 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S } } +void MainFrame::update_icon() { + + // icons for ESettingsLayout::Hidden + wxImageList* img_list = nullptr; + int icon_size = 0; + try { + icon_size = atoi(wxGetApp().app_config->get("tab_icon_size").c_str()); + } + catch (std::exception e) {} + switch (m_layout) + { + case ESettingsLayout::Unknown: + { + break; + } case ESettingsLayout::Old: + case ESettingsLayout::Hidden: + { + if (m_tabpanel->GetPageCount() == 4 && icon_size >= 8) { + m_tabpanel->SetPageImage(0, 0); + m_tabpanel->SetPageImage(1, 3); + m_tabpanel->SetPageImage(2, m_plater->printer_technology() == PrinterTechnology::ptSLA ? 6 : 4); + m_tabpanel->SetPageImage(3, m_plater->printer_technology() == PrinterTechnology::ptSLA ? 7 : 5); + } + break; + } + case ESettingsLayout::Tabs: + { + if (icon_size >= 8) + { + m_tabpanel->SetPageImage(0, 0); + m_tabpanel->SetPageImage(1, 1); + m_tabpanel->SetPageImage(2, 2); + m_tabpanel->SetPageImage(3, 3); + m_tabpanel->SetPageImage(4, m_plater->printer_technology() == PrinterTechnology::ptSLA ? 6 : 4); + m_tabpanel->SetPageImage(5, m_plater->printer_technology() == PrinterTechnology::ptSLA ? 7 : 5); + } + break; + } + case ESettingsLayout::Dlg: + { + if (m_tabpanel->GetPageCount() == 4 && icon_size >= 8) { + m_tabpanel->SetPageImage(0, 3); + m_tabpanel->SetPageImage(1, m_plater->printer_technology() == PrinterTechnology::ptSLA ? 6 : 4); + m_tabpanel->SetPageImage(2, m_plater->printer_technology() == PrinterTechnology::ptSLA ? 7 : 5); + } + break; + } + case ESettingsLayout::GCodeViewer: + { + break; + } + } + +} + void MainFrame::update_layout() { auto restore_to_creation = [this]() { @@ -262,6 +317,8 @@ void MainFrame::update_layout() } }; + std::cout << "update_layout: " << m_tabpanel->GetPageCount() << "\n"; + // On Linux m_plater needs to be removed from m_tabpanel before to reparent it //clear if previous was old m_tabpanel_stop_event = true; @@ -360,6 +417,7 @@ void MainFrame::update_layout() // From the very beginning the Print settings should be selected m_last_selected_setting_tab = 0; m_last_selected_plater_tab = 999; + std::cout << "update_layout1: " << m_tabpanel->GetPageCount() << "\n"; // Set new settings switch (m_layout) @@ -373,29 +431,7 @@ void MainFrame::update_layout() m_plater->Reparent(m_tabpanel); m_tabpanel->InsertPage(0, m_plater, _L("Plater")); m_main_sizer->Add(m_tabpanel, 1, wxEXPAND); - // icons for ESettingsLayout::Old - wxImageList* img_list = nullptr; - int icon_size = 0; - try { - icon_size = atoi(wxGetApp().app_config->get("tab_icon_size").c_str()); - } - catch (std::exception e) {} - if (m_tabpanel->GetPageCount() == 4 && icon_size >= 8) { - std::initializer_list icon_list = { "plater", "cog", "spool_cog", "printer_cog" }; - if (icon_size < 16) - icon_list = { "plater", "cog", "spool", "printer" }; - for (std::string icon_name : icon_list) { - const wxBitmap& bmp = create_scaled_bitmap(icon_name, this, icon_size); - if (img_list == nullptr) - img_list = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); - img_list->Add(bmp); - } - m_tabpanel->AssignImageList(img_list); - m_tabpanel->SetPageImage(0, 0); - m_tabpanel->SetPageImage(1, 1); - m_tabpanel->SetPageImage(2, 2); - m_tabpanel->SetPageImage(3, 3); - } + update_icon(); // show m_plater->Show(); m_tabpanel->Show(); @@ -407,42 +443,15 @@ void MainFrame::update_layout() m_plater->enable_view_toolbar(false); bool need_freeze = !this->IsFrozen(); if(need_freeze) this->Freeze(); - // icons for ESettingsLayout::Tabs - wxImageList* img_list = nullptr; - int icon_size = 0; - try { - icon_size = atoi(wxGetApp().app_config->get("tab_icon_size").c_str()); - } - catch (std::exception e) {} - if (icon_size >= 8) { - std::initializer_list icon_list = { "editor_menu", "layers", "preview_menu", "cog", "spool_cog", "printer_cog" }; - if (icon_size < 16) - icon_list = { "editor_menu", "layers", "preview_menu", "cog", "spool", "printer" }; - for (std::string icon_name : icon_list) { - const wxBitmap& bmp = create_scaled_bitmap(icon_name, this, icon_size); - if (img_list == nullptr) - img_list = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); - img_list->Add(bmp); - } - } wxPanel* first_panel = new wxPanel(m_tabpanel); m_tabpanel->InsertPage(0, first_panel, _L("3D view")); m_tabpanel->InsertPage(1, new wxPanel(m_tabpanel), _L("Sliced preview")); m_tabpanel->InsertPage(2, new wxPanel(m_tabpanel), _L("Gcode preview")); if (m_tabpanel->GetPageCount() == 6) { - m_tabpanel->AssignImageList(img_list); m_tabpanel->GetPage(0)->SetSizer(new wxBoxSizer(wxVERTICAL)); m_tabpanel->GetPage(1)->SetSizer(new wxBoxSizer(wxVERTICAL)); m_tabpanel->GetPage(2)->SetSizer(new wxBoxSizer(wxVERTICAL)); - if (icon_size >= 8) - { - m_tabpanel->SetPageImage(0, 0); - m_tabpanel->SetPageImage(1, 1); - m_tabpanel->SetPageImage(2, 2); - m_tabpanel->SetPageImage(3, 3); - m_tabpanel->SetPageImage(4, 4); - m_tabpanel->SetPageImage(5, 5); - } + update_icon(); } m_plater->Reparent(first_panel); first_panel->GetSizer()->Add(m_plater, 1, wxEXPAND); @@ -460,6 +469,7 @@ void MainFrame::update_layout() m_main_sizer->Add(m_tabpanel, 1, wxEXPAND); m_plater_page = new wxPanel(m_tabpanel); m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab */ + update_icon(); m_plater->Show(); break; } @@ -468,6 +478,7 @@ void MainFrame::update_layout() m_main_sizer->Add(m_plater, 1, wxEXPAND); m_tabpanel->Reparent(&m_settings_dialog); m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND); + update_icon(); m_tabpanel->Show(); m_plater->Show(); break; @@ -602,6 +613,21 @@ void MainFrame::shutdown() wxGetApp().plater_ = nullptr; } +void MainFrame::change_tab(Tab* old_tab, Tab* new_tab) +{ + int page_id = m_tabpanel->FindPage(old_tab); + if (page_id >= 0 && page_id < m_tabpanel->GetPageCount()) { + m_tabpanel->GetPage(page_id)->Show(false); + m_tabpanel->RemovePage(page_id); + } + m_tabpanel->InsertPage(page_id, new_tab, new_tab->title()); + #ifdef __linux__ // the tabs apparently need to be explicitly shown on Linux (pull request #1563) + int page_id = m_tabpanel->FindPage(new_tab); + m_tabpanel->GetPage(page_id)->Show(true); + #endif // __linux__ + MainFrame::update_icon(); +} + void MainFrame::update_title() { wxString title = wxEmptyString; @@ -653,6 +679,25 @@ void MainFrame::init_tabpanel() m_tabpanel->Hide(); m_settings_dialog.set_tabpanel(m_tabpanel); + // icons for m_tabpanel tabs + wxImageList* img_list = nullptr; + int icon_size = 0; + try { + icon_size = atoi(wxGetApp().app_config->get("tab_icon_size").c_str()); + } + catch (std::exception e) {} + if (icon_size >= 8) { + std::initializer_list icon_list = { "editor_menu", "layers", "preview_menu", "cog", "spool_cog", "printer_cog", "resin_cog", "sla_printer_cog" }; + if (icon_size < 16) + icon_list = { "editor_menu", "layers", "preview_menu", "cog", "spool", "printer", "resin", "sla_printer" }; + for (std::string icon_name : icon_list) { + const wxBitmap& bmp = create_scaled_bitmap(icon_name, this, icon_size); + if (img_list == nullptr) + img_list = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); + img_list->Add(bmp); + } + } + m_tabpanel->AssignImageList(img_list); m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) { if (m_tabpanel_stop_event) @@ -771,6 +816,7 @@ void MainFrame::init_tabpanel() if (wxGetApp().is_editor()) create_preset_tabs(); + std::cout << "create_preset_tabs: " << m_tabpanel->GetPageCount() << "\n"; if (m_plater) { // load initial config @@ -1898,11 +1944,11 @@ void MainFrame::select_tab(Tab* tab) return; ETabType tab_type = ETabType::LastSettings; switch (tab->type()) { - case Preset::Type::TYPE_FILAMENT: + case Preset::Type::TYPE_FFF_FILAMENT: case Preset::Type::TYPE_SLA_MATERIAL: tab_type = ETabType::FilamentSettings; break; - case Preset::Type::TYPE_PRINT: + case Preset::Type::TYPE_FFF_PRINT: case Preset::Type::TYPE_SLA_PRINT: tab_type = ETabType::PrintSettings; break; diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 584f02d5e..6da34046e 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -41,11 +41,11 @@ enum QuickSlice qsExportPNG = 8 }; -struct PresetTab { - std::string name; - Tab* panel; - PrinterTechnology technology; -}; +//struct PresetTab { +// std::string name; +// Tab* panel; +// PrinterTechnology technology; +//}; // ---------------------------------------------------------------------------- // SettingsDialog @@ -89,6 +89,7 @@ class MainFrame : public DPIFrame void on_presets_changed(SimpleEvent&); void on_value_changed(wxCommandEvent&); + void update_icon(); bool can_start_new_project() const; bool can_save() const; @@ -173,6 +174,7 @@ public: void create_preset_tabs(); void add_created_tab(Tab* panel); bool is_active_and_shown_tab(Tab* tab); + void change_tab(Tab* old_tab, Tab* new_tab); // Register Win32 RawInput callbacks (3DConnexion) and removable media insert / remove callbacks. // Called from wxEVT_ACTIVATE, as wxEVT_CREATE was not reliable (bug in wxWidgets?). void register_win32_callbacks(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 069501b88..a210dd8eb 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -299,7 +299,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) : m_og->hide_labels(); m_og->m_on_change = [config, this](t_config_option_key opt_key, boost::any value) { - Tab* tab_print = wxGetApp().get_tab(Preset::TYPE_PRINT); + Tab* tab_print = wxGetApp().get_tab(Preset::TYPE_FFF_PRINT); if (!tab_print) return; if (opt_key == "fill_density") { @@ -692,8 +692,8 @@ Sidebar::Sidebar(Plater *parent) }; p->combos_filament.push_back(nullptr); - init_combo(&p->combo_print, _L("Print settings"), Preset::TYPE_PRINT, false); - init_combo(&p->combos_filament[0], _L("Filament"), Preset::TYPE_FILAMENT, true); + init_combo(&p->combo_print, _L("Print settings"), Preset::TYPE_FFF_PRINT, false); + init_combo(&p->combos_filament[0], _L("Filament"), Preset::TYPE_FFF_FILAMENT, true); init_combo(&p->combo_sla_print, _L("SLA print settings"), Preset::TYPE_SLA_PRINT, false); init_combo(&p->combo_sla_material, _L("SLA material"), Preset::TYPE_SLA_MATERIAL, false); init_combo(&p->combo_printer, _L("Printer"), Preset::TYPE_PRINTER, false); @@ -809,7 +809,7 @@ Sidebar::Sidebar(Plater *parent) Sidebar::~Sidebar() {} void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int extr_idx) { - *combo = new PlaterPresetComboBox(p->presets_panel, Slic3r::Preset::TYPE_FILAMENT); + *combo = new PlaterPresetComboBox(p->presets_panel, Slic3r::Preset::TYPE_FFF_FILAMENT); // # copy icons from first choice // $choice->SetItemBitmap($_, $choices->[0]->GetItemBitmap($_)) for 0..$#presets; @@ -865,7 +865,7 @@ void Sidebar::update_presets(Preset::Type preset_type) const auto print_tech = preset_bundle.printers.get_edited_preset().printer_technology(); switch (preset_type) { - case Preset::TYPE_FILAMENT: + case Preset::TYPE_FFF_FILAMENT: { const size_t extruder_cnt = print_tech != ptFFF ? 1 : dynamic_cast(preset_bundle.printers.get_edited_preset().config.option("nozzle_diameter"))->values.size(); @@ -883,7 +883,7 @@ void Sidebar::update_presets(Preset::Type preset_type) break; } - case Preset::TYPE_PRINT: + case Preset::TYPE_FFF_PRINT: p->combo_print->update(); break; @@ -3602,13 +3602,13 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type, Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data())); - if (preset_type == Preset::TYPE_FILAMENT) { + if (preset_type == Preset::TYPE_FFF_FILAMENT) { wxGetApp().preset_bundle->set_filament_preset(idx, preset_name); } bool select_preset = !combo->selection_is_changed_according_to_physical_printers(); // TODO: ? - if (preset_type == Preset::TYPE_FILAMENT && sidebar->is_multifilament()) { + if (preset_type == Preset::TYPE_FFF_FILAMENT && sidebar->is_multifilament()) { // Only update the plater UI for the 2nd and other filaments. combo->update(); } @@ -3987,7 +3987,7 @@ void Plater::priv::on_wipetower_moved(Vec3dEvent &evt) DynamicPrintConfig cfg; cfg.opt("wipe_tower_x", true)->value = evt.data(0); cfg.opt("wipe_tower_y", true)->value = evt.data(1); - wxGetApp().get_tab(Preset::TYPE_PRINT)->load_config(cfg); + wxGetApp().get_tab(Preset::TYPE_FFF_PRINT)->load_config(cfg); } void Plater::priv::on_wipetower_rotated(Vec3dEvent& evt) @@ -3996,7 +3996,7 @@ void Plater::priv::on_wipetower_rotated(Vec3dEvent& evt) cfg.opt("wipe_tower_x", true)->value = evt.data(0); cfg.opt("wipe_tower_y", true)->value = evt.data(1); cfg.opt("wipe_tower_rotation_angle", true)->value = Geometry::rad2deg(evt.data(2)); - wxGetApp().get_tab(Preset::TYPE_PRINT)->load_config(cfg); + wxGetApp().get_tab(Preset::TYPE_FFF_PRINT)->load_config(cfg); } void Plater::priv::on_update_geometry(Vec3dsEvent<2>&) @@ -4725,7 +4725,7 @@ void Plater::priv::undo_redo_to(std::vector::const_iterator new_config.set_key_value("wipe_tower_x", new ConfigOptionFloat(model.wipe_tower.position.x())); new_config.set_key_value("wipe_tower_y", new ConfigOptionFloat(model.wipe_tower.position.y())); new_config.set_key_value("wipe_tower_rotation_angle", new ConfigOptionFloat(model.wipe_tower.rotation)); - Tab *tab_print = wxGetApp().get_tab(Preset::TYPE_PRINT); + Tab *tab_print = wxGetApp().get_tab(Preset::TYPE_FFF_PRINT); tab_print->load_config(new_config); tab_print->update_dirty(); } diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 9cc2887b6..1c777dc3b 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -78,12 +78,12 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const switch (m_type) { - case Preset::TYPE_PRINT: { + case Preset::TYPE_FFF_PRINT: { m_collection = &m_preset_bundle->prints; m_main_bitmap_name = "cog"; break; } - case Preset::TYPE_FILAMENT: { + case Preset::TYPE_FFF_FILAMENT: { m_collection = &m_preset_bundle->filaments; m_main_bitmap_name = "spool"; break; @@ -396,7 +396,7 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con // Paint a red flag for incompatible presets. bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp()); - if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty()) + if (m_type == Preset::TYPE_FFF_FILAMENT && !filament_rgb.empty()) { unsigned char rgb[3]; // Paint the color bars. @@ -597,7 +597,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset } }); - if (m_type == Preset::TYPE_FILAMENT) + if (m_type == Preset::TYPE_FFF_FILAMENT) { Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) { const Preset* selected_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]); @@ -664,7 +664,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset /* In a case of a multi-material printing, for editing another Filament Preset * it's needed to select this preset for the "Filament settings" Tab */ - if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1) + if (m_type == Preset::TYPE_FFF_FILAMENT && wxGetApp().extruders_edited_cnt() > 1) { const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data(); @@ -749,7 +749,7 @@ void PlaterPresetComboBox::show_edit_menu() // If an incompatible preset is selected, it is shown as well. void PlaterPresetComboBox::update() { - if (m_type == Preset::TYPE_FILAMENT && + if (m_type == Preset::TYPE_FFF_FILAMENT && (m_preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA || m_preset_bundle->filament_presets.size() <= (size_t)m_extruder_idx) ) return; @@ -761,7 +761,7 @@ void PlaterPresetComboBox::update() const Preset* selected_filament_preset = nullptr; std::string extruder_color; - if (m_type == Preset::TYPE_FILAMENT) + if (m_type == Preset::TYPE_FFF_FILAMENT) { unsigned char rgb[3]; extruder_color = m_preset_bundle->printers.get_edited_preset().config.opt_string("extruder_colour", (unsigned int)m_extruder_idx); @@ -773,7 +773,7 @@ void PlaterPresetComboBox::update() } bool has_selection = m_collection->get_selected_idx() != size_t(-1); - const Preset* selected_preset = m_type == Preset::TYPE_FILAMENT ? selected_filament_preset : has_selection ? &m_collection->get_selected_preset() : nullptr; + const Preset* selected_preset = m_type == Preset::TYPE_FFF_FILAMENT ? selected_filament_preset : has_selection ? &m_collection->get_selected_preset() : nullptr; // Show wide icons if the currently selected preset is not compatible with the current printer, // and draw a red flag in front of the selected preset. bool wide_icons = selected_preset && !selected_preset->is_compatible; @@ -790,7 +790,7 @@ void PlaterPresetComboBox::update() for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i) { const Preset& preset = presets[i]; - bool is_selected = m_type == Preset::TYPE_FILAMENT ? + bool is_selected = m_type == Preset::TYPE_FFF_FILAMENT ? m_preset_bundle->filament_presets[m_extruder_idx] == preset.name : // The case, when some physical printer is selected m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection() ? false : @@ -803,7 +803,7 @@ void PlaterPresetComboBox::update() std::string bitmap_type_name = bitmap_key = m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name; bool single_bar = false; - if (m_type == Preset::TYPE_FILAMENT) + if (m_type == Preset::TYPE_FFF_FILAMENT) { // Assign an extruder color to the selected item if the extruder color is defined. filament_rgb = is_selected ? selected_filament_preset->config.opt_string("filament_colour", 0) : @@ -869,11 +869,11 @@ void PlaterPresetComboBox::update() } } - if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) { + if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FFF_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) { wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni"); assert(bmp); - if (m_type == Preset::TYPE_FILAMENT) + if (m_type == Preset::TYPE_FFF_FILAMENT) set_label_marker(Append(separator(L("Add/Remove filaments")), *bmp), LABEL_ITEM_WIZARD_FILAMENTS); else if (m_type == Preset::TYPE_SLA_MATERIAL) set_label_marker(Append(separator(L("Add/Remove materials")), *bmp), LABEL_ITEM_WIZARD_MATERIALS); diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index a3eadca15..e9ad959ae 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -31,10 +31,10 @@ namespace Search { static char marker_by_type(Preset::Type type, PrinterTechnology pt) { switch(type) { - case Preset::TYPE_PRINT: + case Preset::TYPE_FFF_PRINT: case Preset::TYPE_SLA_PRINT: return ImGui::PrintIconMarker; - case Preset::TYPE_FILAMENT: + case Preset::TYPE_FFF_FILAMENT: return ImGui::FilamentIconMarker; case Preset::TYPE_SLA_MATERIAL: return ImGui::MaterialIconMarker; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index d8f5fb359..2f7d9c97a 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -118,7 +118,7 @@ Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) : m_compatible_printers.dialog_title = _L("Compatible printers"); m_compatible_printers.dialog_label = _L("Select the printers this profile is compatible with."); - m_compatible_prints.type = Preset::TYPE_PRINT; + m_compatible_prints.type = Preset::TYPE_FFF_PRINT; m_compatible_prints.key_list = "compatible_prints"; m_compatible_prints.key_condition = "compatible_prints_condition"; m_compatible_prints.dialog_title = _L("Compatible print profiles"); @@ -146,9 +146,9 @@ Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) : void Tab::set_type() { - if (m_name == "print") { m_type = Slic3r::Preset::TYPE_PRINT; } + if (m_name == "print") { m_type = Slic3r::Preset::TYPE_FFF_PRINT; } else if (m_name == "sla_print") { m_type = Slic3r::Preset::TYPE_SLA_PRINT; } - else if (m_name == "filament") { m_type = Slic3r::Preset::TYPE_FILAMENT; } + else if (m_name == "filament") { m_type = Slic3r::Preset::TYPE_FFF_FILAMENT; } else if (m_name == "sla_material") { m_type = Slic3r::Preset::TYPE_SLA_MATERIAL; } else if (m_name == "printer") { m_type = Slic3r::Preset::TYPE_PRINTER; } else { m_type = Slic3r::Preset::TYPE_INVALID; assert(false); } @@ -816,7 +816,7 @@ void Tab::update_changed_tree_ui() get_sys_and_mod_flags(opt_key, sys_page, modified_page); } } - if (m_type == Preset::TYPE_FILAMENT && page->title() == "Advanced") { + if (m_type == Preset::TYPE_FFF_FILAMENT && page->title() == "Advanced") { get_sys_and_mod_flags("filament_ramming_parameters", sys_page, modified_page); } if (page->title() == "Dependencies") { @@ -824,7 +824,7 @@ void Tab::update_changed_tree_ui() sys_page = m_presets->get_selected_preset_parent() != nullptr; modified_page = false; } else { - if (m_type == Slic3r::Preset::TYPE_FILAMENT || m_type == Slic3r::Preset::TYPE_SLA_MATERIAL) + if (m_type == Slic3r::Preset::TYPE_FFF_FILAMENT || m_type == Slic3r::Preset::TYPE_SLA_MATERIAL) get_sys_and_mod_flags("compatible_prints", sys_page, modified_page); get_sys_and_mod_flags("compatible_printers", sys_page, modified_page); } @@ -912,7 +912,7 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/) is_empty ? m_compatible_printers.btn->Disable() : m_compatible_printers.btn->Enable(); } // "compatible_prints" option exists only in Filament Settimgs and Materials Tabs - if ((m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) && (m_options_list["compatible_prints"] & os) == 0) { + if ((m_type == Preset::TYPE_FFF_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) && (m_options_list["compatible_prints"] & os) == 0) { to_sys ? group->back_to_sys_value("compatible_prints") : group->back_to_initial_value("compatible_prints"); load_key_value("compatible_prints", true/*some value*/, true); @@ -3060,7 +3060,8 @@ void Tab::load_current_preset() //merill note: this is a bit of anti-inheritance pattern if (m_type == Slic3r::Preset::TYPE_PRINTER) { const PrinterTechnology printer_technology = m_presets->get_edited_preset().printer_technology(); - if (printer_technology != static_cast(this)->m_printer_technology) + const PrinterTechnology old_printer_technology = static_cast(this)->m_printer_technology; + if (printer_technology != old_printer_technology) { // The change of the technology requires to remove some of unrelated Tabs // During this action, wxNoteBook::RemovePage invoke wxEVT_NOTEBOOK_PAGE_CHANGED @@ -3070,22 +3071,15 @@ void Tab::load_current_preset() Page* tmp_page = m_active_page; m_active_page = nullptr; for (auto tab : wxGetApp().tabs_list) { - if (tab->type() == Preset::TYPE_PRINTER) // Printer tab is shown every time + if (tab->type() == Preset::TYPE_PRINTER) // Printer tab shouln't be swapped continue; if (tab->supports_printer_technology(printer_technology)) { - wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title()); - #ifdef __linux__ // the tabs apparently need to be explicitly shown on Linux (pull request #1563) - int page_id = wxGetApp().tab_panel()->FindPage(tab); - wxGetApp().tab_panel()->GetPage(page_id)->Show(true); - #endif // __linux__ - } - else { - int page_id = wxGetApp().tab_panel()->FindPage(tab); - //TODO shouldn't happen, emit an error here. - if (page_id >= 0 && page_id < wxGetApp().tab_panel()->GetPageCount()) { - wxGetApp().tab_panel()->GetPage(page_id)->Show(false); - wxGetApp().tab_panel()->RemovePage(page_id); + //search the other one to be replaced + for (auto tab_old : wxGetApp().tabs_list) { + if ((tab->type() & Preset::TYPE_TAB) == (tab_old->type() & Preset::TYPE_TAB) && tab_old->supports_printer_technology(old_printer_technology) ) { + wxGetApp().mainframe->change_tab(tab_old, tab); + } } } } @@ -3105,11 +3099,11 @@ void Tab::load_current_preset() } else { on_presets_changed(); - if (m_type == Preset::TYPE_SLA_PRINT || m_type == Preset::TYPE_PRINT) + if (m_type == Preset::TYPE_SLA_PRINT || m_type == Preset::TYPE_FFF_PRINT) update_frequently_changed_parameters(); //update width/spacing links - if (m_type == Preset::TYPE_PRINT) { + if (m_type == Preset::TYPE_FFF_PRINT) { //verify that spacings are set if (m_config && m_config->update_phony({ wxGetApp().plater()->config() })) { update_dirty(); @@ -3207,7 +3201,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, } assert(! delete_current || (m_presets->get_edited_preset().name != preset_name && m_presets->get_edited_preset().is_user())); bool current_dirty = ! delete_current && m_presets->current_is_dirty(); - bool print_tab = m_presets->type() == Preset::TYPE_PRINT || m_presets->type() == Preset::TYPE_SLA_PRINT; + bool print_tab = m_presets->type() == Preset::TYPE_FFF_PRINT || m_presets->type() == Preset::TYPE_SLA_PRINT; bool printer_tab = m_presets->type() == Preset::TYPE_PRINTER; bool canceled = false; bool technology_changed = false; @@ -3229,7 +3223,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, canceled = old_preset_dirty && ! new_preset_compatible && ! may_discard_current_dirty_preset(&dependent, preset_name); if (! canceled) { // The preset will be switched to a different, compatible preset, or the '-- default --'. - m_dependent_tabs.emplace_back((printer_technology == ptFFF) ? Preset::Type::TYPE_FILAMENT : Preset::Type::TYPE_SLA_MATERIAL); + m_dependent_tabs.emplace_back((printer_technology == ptFFF) ? Preset::Type::TYPE_FFF_FILAMENT : Preset::Type::TYPE_SLA_MATERIAL); if (old_preset_dirty && ! new_preset_compatible) dependent.discard_current_changes(); } @@ -3256,9 +3250,9 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, bool new_preset_compatible; }; std::vector updates = { - { Preset::Type::TYPE_PRINT, &m_preset_bundle->prints, ptFFF }, + { Preset::Type::TYPE_FFF_PRINT, &m_preset_bundle->prints, ptFFF }, { Preset::Type::TYPE_SLA_PRINT, &m_preset_bundle->sla_prints, ptSLA }, - { Preset::Type::TYPE_FILAMENT, &m_preset_bundle->filaments, ptFFF }, + { Preset::Type::TYPE_FFF_FILAMENT, &m_preset_bundle->filaments, ptFFF }, { Preset::Type::TYPE_SLA_MATERIAL, &m_preset_bundle->sla_materials,ptSLA } }; for (PresetUpdate &pu : updates) { @@ -3328,8 +3322,8 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, }; if (current_dirty || delete_current || print_tab || printer_tab) m_preset_bundle->update_compatible( - update_compatible_type(technology_changed, print_tab, (print_tab ? this : wxGetApp().get_tab(Preset::TYPE_PRINT))->m_show_incompatible_presets), - update_compatible_type(technology_changed, false, wxGetApp().get_tab(Preset::TYPE_FILAMENT)->m_show_incompatible_presets)); + update_compatible_type(technology_changed, print_tab, (print_tab ? this : wxGetApp().get_tab(Preset::TYPE_FFF_PRINT))->m_show_incompatible_presets), + update_compatible_type(technology_changed, false, wxGetApp().get_tab(Preset::TYPE_FFF_FILAMENT)->m_show_incompatible_presets)); // Initialize the UI from the current preset. if (printer_tab) static_cast(this)->update_pages(); @@ -3345,8 +3339,8 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, * to the corresponding printer_technology */ const PrinterTechnology printer_technology = m_presets->get_edited_preset().printer_technology(); - if (printer_technology == ptFFF && m_dependent_tabs.front() != Preset::Type::TYPE_PRINT) - m_dependent_tabs = { Preset::Type::TYPE_PRINT, Preset::Type::TYPE_FILAMENT }; + if (printer_technology == ptFFF && m_dependent_tabs.front() != Preset::Type::TYPE_FFF_PRINT) + m_dependent_tabs = { Preset::Type::TYPE_FFF_PRINT, Preset::Type::TYPE_FFF_FILAMENT }; else if (printer_technology == ptSLA && m_dependent_tabs.front() != Preset::Type::TYPE_SLA_PRINT) m_dependent_tabs = { Preset::Type::TYPE_SLA_PRINT, Preset::Type::TYPE_SLA_MATERIAL }; } @@ -3390,7 +3384,7 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr // If filament preset is saved for multi-material printer preset, // there are cases when filament comboboxs are updated for old (non-modified) colors, // but in full_config a filament_colors option aren't. - if (presets->type() == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1) + if (presets->type() == Preset::TYPE_FFF_FILAMENT && wxGetApp().extruders_edited_cnt() > 1) wxGetApp().plater()->force_filament_colors_update(); } } @@ -3594,7 +3588,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach) /* If filament preset is saved for multi-material printer preset, * there are cases when filament comboboxs are updated for old (non-modified) colors, * but in full_config a filament_colors option aren't.*/ - if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1) + if (m_type == Preset::TYPE_FFF_FILAMENT && wxGetApp().extruders_edited_cnt() > 1) wxGetApp().plater()->force_filament_colors_update(); { @@ -3602,15 +3596,15 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach) // Update profile selection combo boxes at the depending tabs to reflect modifications in profile compatibility. std::vector dependent; switch (m_type) { - case Preset::TYPE_PRINT: - dependent = { Preset::TYPE_FILAMENT }; + case Preset::TYPE_FFF_PRINT: + dependent = { Preset::TYPE_FFF_FILAMENT }; break; case Preset::TYPE_SLA_PRINT: dependent = { Preset::TYPE_SLA_MATERIAL }; break; case Preset::TYPE_PRINTER: if (static_cast(this)->m_printer_technology == ptFFF) - dependent = { Preset::TYPE_PRINT, Preset::TYPE_FILAMENT }; + dependent = { Preset::TYPE_FFF_PRINT, Preset::TYPE_FFF_FILAMENT }; else dependent = { Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL }; break; diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 29d4699c3..fd541ead2 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -379,7 +379,7 @@ class TabPrint : public Tab public: TabPrint(wxNotebook* parent) : // Tab(parent, _(L("Print Settings")), L("print")) {} - Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_PRINT) {} + Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_FFF_PRINT) {} ~TabPrint() {} void build() override; @@ -411,7 +411,7 @@ protected: public: TabFilament(wxNotebook* parent) : // Tab(parent, _(L("Filament Settings")), L("filament")) {} - Tab(parent, _(L("Filament Settings")), Slic3r::Preset::TYPE_FILAMENT) {} + Tab(parent, _(L("Filament Settings")), Slic3r::Preset::TYPE_FFF_FILAMENT) {} ~TabFilament() {} void build() override; diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index fa1e09d6f..e9687873b 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -40,9 +40,9 @@ namespace GUI { // ---------------------------------------------------------------------------- static const std::map type_icon_names = { - {Preset::TYPE_PRINT, "cog" }, + {Preset::TYPE_FFF_PRINT, "cog" }, {Preset::TYPE_SLA_PRINT, "cog" }, - {Preset::TYPE_FILAMENT, "spool" }, + {Preset::TYPE_FFF_FILAMENT, "spool" }, {Preset::TYPE_SLA_MATERIAL, "resin" }, {Preset::TYPE_PRINTER, "printer" }, };