mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-22 12:45:17 +00:00
Remove duplicated code
(cherry picked from commit 4732123bb8c1c1e3952d45d3b84b4377fad7fb35)
This commit is contained in:
@@ -1101,18 +1101,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||||||
ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament");
|
ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament");
|
||||||
add_btn->SetToolTip(_L("Add one filament"));
|
add_btn->SetToolTip(_L("Add one filament"));
|
||||||
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
|
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
|
||||||
// Orca: limit filament choices to MAXIMUM_EXTRUDER_NUMBER
|
add_filament();
|
||||||
if (p->combos_filament.size() >= MAXIMUM_EXTRUDER_NUMBER)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int filament_count = p->combos_filament.size() + 1;
|
|
||||||
wxColour new_col = Plater::get_next_color_for_filament();
|
|
||||||
std::string new_color = new_col.GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
|
|
||||||
wxGetApp().preset_bundle->set_num_filaments(filament_count, new_color);
|
|
||||||
wxGetApp().plater()->on_filaments_change(filament_count);
|
|
||||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update();
|
|
||||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
|
||||||
auto_calc_flushing_volumes(filament_count - 1);
|
|
||||||
});
|
});
|
||||||
p->m_bpButton_add_filament = add_btn;
|
p->m_bpButton_add_filament = add_btn;
|
||||||
|
|
||||||
@@ -1121,22 +1110,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||||||
ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament");
|
ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament");
|
||||||
del_btn->SetToolTip(_L("Remove last filament"));
|
del_btn->SetToolTip(_L("Remove last filament"));
|
||||||
del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
|
del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
|
||||||
if (p->combos_filament.size() <= 1)
|
delete_filament();
|
||||||
return;
|
|
||||||
|
|
||||||
size_t filament_count = p->combos_filament.size() - 1;
|
|
||||||
if (wxGetApp().preset_bundle->is_the_only_edited_filament(filament_count) || (filament_count == 1)) {
|
|
||||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0], false, "", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p->editing_filament >= filament_count) {
|
|
||||||
p->editing_filament = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxGetApp().preset_bundle->set_num_filaments(filament_count);
|
|
||||||
wxGetApp().plater()->on_filaments_change(filament_count);
|
|
||||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update();
|
|
||||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
|
||||||
});
|
});
|
||||||
p->m_bpButton_del_filament = del_btn;
|
p->m_bpButton_del_filament = del_btn;
|
||||||
|
|
||||||
@@ -1188,33 +1162,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||||||
p->combos_filament.push_back(nullptr);
|
p->combos_filament.push_back(nullptr);
|
||||||
|
|
||||||
/* first filament item */
|
/* first filament item */
|
||||||
p->combos_filament[0] = new PlaterPresetComboBox(p->m_panel_filament_content, Preset::TYPE_FILAMENT);
|
init_filament_combo(&p->combos_filament[0], 0);
|
||||||
auto combo_and_btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
// BBS: filament double columns
|
|
||||||
combo_and_btn_sizer->AddSpacer(FromDIP(SidebarProps::ContentMargin()));
|
|
||||||
if (p->combos_filament[0]->clr_picker) {
|
|
||||||
p->combos_filament[0]->clr_picker->SetLabel("1");
|
|
||||||
combo_and_btn_sizer->Add(p->combos_filament[0]->clr_picker, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT,FromDIP(SidebarProps::ElementSpacing()) - FromDIP(2)); // ElementSpacing - 2 (from combo box))
|
|
||||||
}
|
|
||||||
combo_and_btn_sizer->Add(p->combos_filament[0], 1, wxALL | wxEXPAND, FromDIP(2))->SetMinSize({-1, FromDIP(30) });
|
|
||||||
|
|
||||||
ScalableButton* edit_btn = new ScalableButton(p->m_panel_filament_content, wxID_ANY, "edit");
|
|
||||||
edit_btn->SetBackgroundColour(wxColour(255, 255, 255));
|
|
||||||
edit_btn->SetToolTip(_L("Click to edit preset"));
|
|
||||||
|
|
||||||
PlaterPresetComboBox* combobox = p->combos_filament[0];
|
|
||||||
edit_btn->Bind(wxEVT_BUTTON, [this, combobox](wxCommandEvent)
|
|
||||||
{
|
|
||||||
p->editing_filament = 0;
|
|
||||||
combobox->switch_to_tab();
|
|
||||||
});
|
|
||||||
combobox->edit_btn = edit_btn;
|
|
||||||
|
|
||||||
combo_and_btn_sizer->Add(edit_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(SidebarProps::ElementSpacing()) - FromDIP(2)); // ElementSpacing - 2 (from combo box))
|
|
||||||
combo_and_btn_sizer->AddSpacer(FromDIP(SidebarProps::ContentMargin()));
|
|
||||||
|
|
||||||
p->combos_filament[0]->set_filament_idx(0);
|
|
||||||
p->sizer_filaments->GetItem((size_t)0)->GetSizer()->Add(combo_and_btn_sizer, 1, wxEXPAND);
|
|
||||||
|
|
||||||
//bSizer_filament_content->Add(p->sizer_filaments, 1, wxALIGN_CENTER | wxALL);
|
//bSizer_filament_content->Add(p->sizer_filaments, 1, wxALIGN_CENTER | wxALL);
|
||||||
wxSizer *sizer_filaments2 = new wxBoxSizer(wxVERTICAL);
|
wxSizer *sizer_filaments2 = new wxBoxSizer(wxVERTICAL);
|
||||||
@@ -1391,7 +1339,7 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame
|
|||||||
auto /***/sizer_filaments = this->p->sizer_filaments->GetItem(side)->GetSizer();
|
auto /***/sizer_filaments = this->p->sizer_filaments->GetItem(side)->GetSizer();
|
||||||
if (side == 1 && filament_idx > 1) sizer_filaments->Remove(filament_idx / 2);
|
if (side == 1 && filament_idx > 1) sizer_filaments->Remove(filament_idx / 2);
|
||||||
sizer_filaments->Add(combo_and_btn_sizer, 1, wxEXPAND);
|
sizer_filaments->Add(combo_and_btn_sizer, 1, wxEXPAND);
|
||||||
if (side == 0) {
|
if (side == 0 && filament_idx > 0) {
|
||||||
sizer_filaments = this->p->sizer_filaments->GetItem(1)->GetSizer();
|
sizer_filaments = this->p->sizer_filaments->GetItem(1)->GetSizer();
|
||||||
sizer_filaments->AddStretchSpacer(1);
|
sizer_filaments->AddStretchSpacer(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user