mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 09:25:57 +08:00
Save profile checkbox for template filaments
This commit is contained in:
parent
ed8614945a
commit
88fb13affa
@ -187,16 +187,16 @@ void SavePresetDialog::Item::accept()
|
|||||||
// SavePresetDialog
|
// SavePresetDialog
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix)
|
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix, bool template_filament)
|
||||||
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
||||||
{
|
{
|
||||||
build(std::vector<Preset::Type>{type}, suffix);
|
build(std::vector<Preset::Type>{type}, suffix, template_filament);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix)
|
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix, bool template_filament)
|
||||||
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
||||||
{
|
{
|
||||||
build(types, suffix);
|
build(types, suffix, template_filament);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavePresetDialog::~SavePresetDialog()
|
SavePresetDialog::~SavePresetDialog()
|
||||||
@ -206,7 +206,7 @@ SavePresetDialog::~SavePresetDialog()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix)
|
void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix, bool template_filament)
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
// ys_FIXME! temporary workaround for correct font scaling
|
// ys_FIXME! temporary workaround for correct font scaling
|
||||||
@ -228,6 +228,9 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||||||
for (Preset::Type type : types)
|
for (Preset::Type type : types)
|
||||||
AddItem(type, suffix);
|
AddItem(type, suffix);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add dialog's buttons
|
// Add dialog's buttons
|
||||||
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||||
wxButton* btnOK = static_cast<wxButton*>(this->FindWindowById(wxID_OK, this));
|
wxButton* btnOK = static_cast<wxButton*>(this->FindWindowById(wxID_OK, this));
|
||||||
@ -235,11 +238,22 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||||||
btnOK->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(enable_ok_btn()); });
|
btnOK->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(enable_ok_btn()); });
|
||||||
|
|
||||||
topSizer->Add(m_presets_sizer, 0, wxEXPAND | wxALL, BORDER_W);
|
topSizer->Add(m_presets_sizer, 0, wxEXPAND | wxALL, BORDER_W);
|
||||||
|
|
||||||
|
// Add checkbox for Template filament saving
|
||||||
|
if (template_filament && types.size() == 1 && *types.begin() == Preset::Type::TYPE_FILAMENT) {
|
||||||
|
m_template_filament_checkbox = new wxCheckBox(this, wxID_ANY, _L("Save as profile derived from current printer only."));
|
||||||
|
wxBoxSizer* check_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
check_sizer->Add(m_template_filament_checkbox);
|
||||||
|
topSizer->Add(check_sizer, 0, wxEXPAND | wxALL, BORDER_W);
|
||||||
|
}
|
||||||
|
|
||||||
topSizer->Add(btns, 0, wxEXPAND | wxALL, BORDER_W);
|
topSizer->Add(btns, 0, wxEXPAND | wxALL, BORDER_W);
|
||||||
|
|
||||||
SetSizer(topSizer);
|
SetSizer(topSizer);
|
||||||
topSizer->SetSizeHints(this);
|
topSizer->SetSizeHints(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this->CenterOnScreen();
|
this->CenterOnScreen();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -265,6 +279,15 @@ std::string SavePresetDialog::get_name(Preset::Type type)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SavePresetDialog::get_template_filament_checkbox()
|
||||||
|
{
|
||||||
|
if (m_template_filament_checkbox)
|
||||||
|
{
|
||||||
|
return m_template_filament_checkbox->GetValue();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool SavePresetDialog::enable_ok_btn() const
|
bool SavePresetDialog::enable_ok_btn() const
|
||||||
{
|
{
|
||||||
for (const Item* item : m_items)
|
for (const Item* item : m_items)
|
||||||
|
@ -65,14 +65,15 @@ class SavePresetDialog : public DPIDialog
|
|||||||
wxStaticText* m_label {nullptr};
|
wxStaticText* m_label {nullptr};
|
||||||
wxBoxSizer* m_radio_sizer {nullptr};
|
wxBoxSizer* m_radio_sizer {nullptr};
|
||||||
ActionType m_action {UndefAction};
|
ActionType m_action {UndefAction};
|
||||||
|
wxCheckBox* m_template_filament_checkbox {nullptr};
|
||||||
|
|
||||||
std::string m_ph_printer_name;
|
std::string m_ph_printer_name;
|
||||||
std::string m_old_preset_name;
|
std::string m_old_preset_name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "");
|
SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "", bool template_filament = false);
|
||||||
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "");
|
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "", bool template_filament = false);
|
||||||
~SavePresetDialog();
|
~SavePresetDialog();
|
||||||
|
|
||||||
void AddItem(Preset::Type type, const std::string& suffix);
|
void AddItem(Preset::Type type, const std::string& suffix);
|
||||||
@ -85,12 +86,13 @@ public:
|
|||||||
void update_info_for_edit_ph_printer(const std::string &preset_name);
|
void update_info_for_edit_ph_printer(const std::string &preset_name);
|
||||||
void layout();
|
void layout();
|
||||||
|
|
||||||
|
bool get_template_filament_checkbox();
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
void on_sys_color_changed() override {}
|
void on_sys_color_changed() override {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void build(std::vector<Preset::Type> types, std::string suffix = "");
|
void build(std::vector<Preset::Type> types, std::string suffix = "", bool template_filament = false);
|
||||||
void update_physical_printers(const std::string& preset_name);
|
void update_physical_printers(const std::string& preset_name);
|
||||||
void accept();
|
void accept();
|
||||||
};
|
};
|
||||||
|
@ -3590,15 +3590,44 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
|
|||||||
// focus currently.is there anything better than this ?
|
// focus currently.is there anything better than this ?
|
||||||
//! m_treectrl->OnSetFocus();
|
//! m_treectrl->OnSetFocus();
|
||||||
|
|
||||||
|
auto& old_preset = m_presets->get_edited_preset();
|
||||||
|
bool from_common = false;
|
||||||
|
std::string edited_printer;
|
||||||
|
if (m_type == Preset::TYPE_FILAMENT && old_preset.vendor && old_preset.vendor->common_profile)
|
||||||
|
{
|
||||||
|
//TODO: is this really the best way to get "printer_model" option of currently edited printer?
|
||||||
|
edited_printer = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt<ConfigOptionString>("printer_model")->serialize();
|
||||||
|
from_common = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "");
|
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "", from_common);
|
||||||
if (dlg.ShowModal() != wxID_OK)
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
return;
|
return;
|
||||||
name = dlg.get_name();
|
name = dlg.get_name();
|
||||||
|
if (from_common)
|
||||||
|
{
|
||||||
|
from_common = dlg.get_template_filament_checkbox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini
|
// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini
|
||||||
m_presets->save_current_preset(name, detach);
|
m_presets->save_current_preset(name, detach);
|
||||||
|
|
||||||
|
if (from_common && !edited_printer.empty())
|
||||||
|
{
|
||||||
|
auto& new_preset = m_presets->get_edited_preset();
|
||||||
|
std::string cond = new_preset.compatible_printers_condition();
|
||||||
|
if (!cond.empty())
|
||||||
|
cond += " and ";
|
||||||
|
cond += "printer_model == \""+edited_printer+"\"";
|
||||||
|
new_preset.config.set("compatible_printers_condition", cond);
|
||||||
|
new_preset.save();
|
||||||
|
//TODO actualize text field compatible_printers_condition
|
||||||
|
m_presets->save_current_preset(name, detach);
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "ereh " << cond;
|
||||||
|
}
|
||||||
|
|
||||||
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
// Mark the print & filament enabled if they are compatible with the currently selected 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.
|
// 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.
|
||||||
m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user