diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 891e6d0dd..19fb9e72d 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -12,7 +12,6 @@ #include "MsgDialog.hpp" #include "FileHelp.hpp" #include "Tab.hpp" -#include "ParamsDialog.hpp" #include "MainFrame.hpp" #define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24)) @@ -4431,10 +4430,12 @@ void EditFilamentPresetDialog::edit_preset() wxGetApp().get_tab(need_edit_preset->type)->select_preset(need_edit_preset_name); // when some preset have modified, if the printer is not need_edit_preset_name compatible printer, the preset will jump to other preset, need select again if (!need_edit_preset->is_compatible) wxGetApp().get_tab(need_edit_preset->type)->select_preset(need_edit_preset_name); - wxGetApp().params_dialog()->Popup(true); m_selected_printer.clear(); m_need_edit_preset_index = -1; + + wxGetApp().params_dialog()->set_editing_filament_id(m_filament_id); + EndModal(wxID_EDIT); } wxBoxSizer *EditFilamentPresetDialog::create_filament_basic_info() @@ -4917,7 +4918,7 @@ wxPanel *PresetTree::get_child_item(wxPanel *parent, std::shared_ptr pre edit_preset_btn->SetBackgroundColor(flush_bg_col); edit_preset_btn->SetBorderColor(flush_bd_col); edit_preset_btn->SetTextColor(flush_fg_col); - edit_preset_btn->Hide(); + //edit_preset_btn->Hide(); sizer->Add(edit_preset_btn, 0, wxALL | wxALIGN_CENTER_VERTICAL, 0); sizer->Add(0, 0, 0, wxLEFT, 5); diff --git a/src/slic3r/GUI/CreatePresetsDialog.hpp b/src/slic3r/GUI/CreatePresetsDialog.hpp index 20f076c6d..c23341761 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.hpp +++ b/src/slic3r/GUI/CreatePresetsDialog.hpp @@ -11,17 +11,11 @@ #include "Widgets/CheckBox.hpp" #include "Widgets/ComboBox.hpp" #include "miniz.h" +#include "ParamsDialog.hpp" namespace Slic3r { namespace GUI { -class FilamentInfomation : public wxObject -{ -public: - std::string filament_id; - std::string filament_name; -}; - class CreateFilamentPresetDialog : public DPIDialog { public: diff --git a/src/slic3r/GUI/ParamsDialog.cpp b/src/slic3r/GUI/ParamsDialog.cpp index 6089116a8..b4440a875 100644 --- a/src/slic3r/GUI/ParamsDialog.cpp +++ b/src/slic3r/GUI/ParamsDialog.cpp @@ -52,6 +52,12 @@ ParamsDialog::ParamsDialog(wxWindow * parent) } #else Hide(); + if (!m_editing_filament_id.empty()) { + FilamentInfomation *filament_info = new FilamentInfomation(); + filament_info->filament_id = m_editing_filament_id; + wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_MODIFY_FILAMENT, filament_info)); + m_editing_filament_id.clear(); + } #endif wxGetApp().sidebar().finish_param_edit(); }); diff --git a/src/slic3r/GUI/ParamsDialog.hpp b/src/slic3r/GUI/ParamsDialog.hpp index 683a23ad9..df5388b19 100644 --- a/src/slic3r/GUI/ParamsDialog.hpp +++ b/src/slic3r/GUI/ParamsDialog.hpp @@ -11,6 +11,15 @@ namespace Slic3r { namespace GUI { +wxDECLARE_EVENT(EVT_MODIFY_FILAMENT, SimpleEvent); + +class FilamentInfomation : public wxObject +{ +public: + std::string filament_id; + std::string filament_name; +}; + class ParamsPanel; class ParamsDialog : public DPIDialog @@ -22,10 +31,13 @@ public: void Popup(bool just_edit = false); + void set_editing_filament_id(std::string id) { m_editing_filament_id = id; } + protected: void on_dpi_changed(const wxRect& suggested_rect) override; private: + std::string m_editing_filament_id; ParamsPanel * m_panel; wxWindowDisabler *m_winDisabler = nullptr; }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index b2df6d975..4e968745b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7633,12 +7633,18 @@ void Plater::priv::on_create_filament(SimpleEvent &) void Plater::priv::on_modify_filament(SimpleEvent &evt) { - FilamentInfomation * filament_info = static_cast(evt.GetEventObject()); - EditFilamentPresetDialog dlg(wxGetApp().mainframe, filament_info); - int res = dlg.ShowModal(); + FilamentInfomation *filament_info = static_cast(evt.GetEventObject()); + int res; + { + EditFilamentPresetDialog dlg(wxGetApp().mainframe, filament_info); + res = dlg.ShowModal(); + } wxGetApp().mainframe->update_side_preset_ui(); update_ui_from_settings(); sidebar->update_all_preset_comboboxes(); + if (wxID_EDIT == res) { + wxGetApp().params_dialog()->Popup(true); + } } void Plater::priv::enter_gizmos_stack() diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index b9d73bf4e..881208cd0 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -367,11 +367,8 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) this->EndModal(wxID_OK); wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_CREATE_FILAMENT)); } else if (strCmd == "modify_custom_filament") { - this->EndModal(wxID_OK); - FilamentInfomation *filament_info = new FilamentInfomation(); - filament_info->filament_id = j["id"]; - //filament_info->filament_name = j["name"]; - wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_MODIFY_FILAMENT, filament_info)); + m_editing_filament_id = j["id"]; + this->EndModal(wxID_EDIT); } else if (strCmd == "save_userguide_models") { @@ -917,6 +914,12 @@ bool GuideFrame::run() } else return false; + } else if (result == wxID_EDIT) { + this->Close(); + FilamentInfomation *filament_info = new FilamentInfomation(); + filament_info->filament_id = m_editing_filament_id; + wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_MODIFY_FILAMENT, filament_info)); + return false; } else return false; diff --git a/src/slic3r/GUI/WebGuideDialog.hpp b/src/slic3r/GUI/WebGuideDialog.hpp index f941f7916..ff66f5cb3 100644 --- a/src/slic3r/GUI/WebGuideDialog.hpp +++ b/src/slic3r/GUI/WebGuideDialog.hpp @@ -124,6 +124,7 @@ private: wxString m_response_js; wxString m_bbl_user_agent; + std::string m_editing_filament_id; }; }} // namespace Slic3r::GUI