Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kocik <kocikdav@gmail.com>2022-02-14 13:26:50 +0300
committerDavid Kocik <kocikdav@gmail.com>2022-02-14 13:26:50 +0300
commit88fb13affa04a7e3a2001afd4073012bf98f90b9 (patch)
treeafd6edcc39aba3b64faea7656dd0f3539bb71f3f
parented8614945a12f3e72d20a9503240d7ebd271de3a (diff)
Save profile checkbox for template filamentsdk_comp
-rw-r--r--src/slic3r/GUI/SavePresetDialog.cpp33
-rw-r--r--src/slic3r/GUI/SavePresetDialog.hpp8
-rw-r--r--src/slic3r/GUI/Tab.cpp31
3 files changed, 63 insertions, 9 deletions
diff --git a/src/slic3r/GUI/SavePresetDialog.cpp b/src/slic3r/GUI/SavePresetDialog.cpp
index 460b30126..762e98a84 100644
--- a/src/slic3r/GUI/SavePresetDialog.cpp
+++ b/src/slic3r/GUI/SavePresetDialog.cpp
@@ -187,16 +187,16 @@ void SavePresetDialog::Item::accept()
// 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)
{
- 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)
{
- build(types, suffix);
+ build(types, suffix, template_filament);
}
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__)
// 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)
AddItem(type, suffix);
+
+
+
// Add dialog's buttons
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
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()); });
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);
SetSizer(topSizer);
topSizer->SetSizeHints(this);
+
+
this->CenterOnScreen();
#ifdef _WIN32
@@ -265,6 +279,15 @@ std::string SavePresetDialog::get_name(Preset::Type type)
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
{
for (const Item* item : m_items)
diff --git a/src/slic3r/GUI/SavePresetDialog.hpp b/src/slic3r/GUI/SavePresetDialog.hpp
index cc1ea1f24..a31634180 100644
--- a/src/slic3r/GUI/SavePresetDialog.hpp
+++ b/src/slic3r/GUI/SavePresetDialog.hpp
@@ -65,14 +65,15 @@ class SavePresetDialog : public DPIDialog
wxStaticText* m_label {nullptr};
wxBoxSizer* m_radio_sizer {nullptr};
ActionType m_action {UndefAction};
+ wxCheckBox* m_template_filament_checkbox {nullptr};
std::string m_ph_printer_name;
std::string m_old_preset_name;
public:
- SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "");
- SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, 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 = "", bool template_filament = false);
~SavePresetDialog();
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 layout();
+ bool get_template_filament_checkbox();
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_sys_color_changed() override {}
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 accept();
};
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 044a0c77d..a12eafaf6 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -3590,15 +3590,44 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
// focus currently.is there anything better than this ?
//! 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()) {
- 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)
return;
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
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.
// 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);