mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-09 00:07:45 -07:00
ENH: filament actions and dual extruder filaments
Change-Id: I12a83f29c96887fc910976ac8e025c4f1508d945 (cherry picked from commit 0065ea986fc41132df43cca6704c8c98318e6b71)
This commit is contained in:
parent
4861fc7e6b
commit
2fe654587b
6 changed files with 98 additions and 44 deletions
10
resources/images/menu_filament.svg
Normal file
10
resources/images/menu_filament.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_16585_40433)">
|
||||
<path d="M7.21631 13.8672C8.84076 13.8672 10.3987 13.2219 11.5473 12.0732C12.696 10.9246 13.3413 9.36664 13.3413 7.74219C13.3413 6.11774 12.696 4.55982 11.5473 3.41116C10.3987 2.2625 8.84076 1.61719 7.21631 1.61719C5.59186 1.61719 4.03394 2.2625 2.88528 3.41116C1.73662 4.55982 1.09131 6.11774 1.09131 7.74219C1.09131 9.36664 1.73662 10.9246 2.88528 12.0732C4.03394 13.2219 5.59186 13.8672 7.21631 13.8672ZM7.21631 0.742188C9.07282 0.742188 10.8533 1.47969 12.1661 2.79244C13.4788 4.10519 14.2163 5.88567 14.2163 7.74219C14.2163 9.5987 13.4788 11.3792 12.1661 12.6919C10.8533 14.0047 9.07282 14.7422 7.21631 14.7422C5.35979 14.7422 3.57932 14.0047 2.26656 12.6919C0.953807 11.3792 0.216309 9.5987 0.216309 7.74219C0.216309 5.88567 0.953807 4.10519 2.26656 2.79244C3.57932 1.47969 5.35979 0.742188 7.21631 0.742188ZM7.87256 7.74219C7.87256 7.91624 7.80342 8.08316 7.68035 8.20623C7.55728 8.3293 7.39036 8.39844 7.21631 8.39844C7.04226 8.39844 6.87534 8.3293 6.75227 8.20623C6.6292 8.08316 6.56006 7.91624 6.56006 7.74219C6.56006 7.56814 6.6292 7.40122 6.75227 7.27815C6.87534 7.15508 7.04226 7.08594 7.21631 7.08594C7.39036 7.08594 7.55728 7.15508 7.68035 7.27815C7.80342 7.40122 7.87256 7.56814 7.87256 7.74219ZM9.84131 7.08594C10.0154 7.08594 10.1823 7.15508 10.3053 7.27815C10.4284 7.40122 10.4976 7.56814 10.4976 7.74219C10.4976 7.91624 10.4284 8.08316 10.3053 8.20623C10.1823 8.3293 10.0154 8.39844 9.84131 8.39844C9.66726 8.39844 9.50034 8.3293 9.37727 8.20623C9.2542 8.08316 9.18506 7.91624 9.18506 7.74219C9.18506 7.56814 9.2542 7.40122 9.37727 7.27815C9.50034 7.15508 9.66726 7.08594 9.84131 7.08594ZM5.24756 7.74219C5.24756 7.91624 5.17842 8.08316 5.05535 8.20623C4.93228 8.3293 4.76536 8.39844 4.59131 8.39844C4.41726 8.39844 4.25034 8.3293 4.12727 8.20623C4.0042 8.08316 3.93506 7.91624 3.93506 7.74219C3.93506 7.56814 4.0042 7.40122 4.12727 7.27815C4.25034 7.15508 4.41726 7.08594 4.59131 7.08594C4.76536 7.08594 4.93228 7.15508 5.05535 7.27815C5.17842 7.40122 5.24756 7.56814 5.24756 7.74219Z" fill="#6B6B6B"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_16585_40433">
|
||||
<rect width="14" height="14" fill="white" transform="translate(0.216309 0.742188)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
|
|
@ -1467,6 +1467,20 @@ void MenuFactory::create_bbl_assemble_part_menu()
|
|||
menu->AppendSeparator();
|
||||
}
|
||||
|
||||
void MenuFactory::create_filament_action_menu()
|
||||
{
|
||||
wxMenu *menu = &m_filament_action_menu;
|
||||
|
||||
append_menu_item(
|
||||
menu, wxID_ANY, _L("Edit"), "", [](wxCommandEvent &) {
|
||||
plater()->sidebar().edit_filament(); }, "", nullptr,
|
||||
[]() { return true; }, m_parent);
|
||||
append_menu_item(
|
||||
menu, wxID_ANY, _L("Delete"), _L("Delete this filament"), [](wxCommandEvent &) {
|
||||
plater()->sidebar().delete_filament(-2); }, "menu_delete", nullptr,
|
||||
[]() { return plater()->sidebar().combos_filament().size() > 1; }, m_parent);
|
||||
}
|
||||
|
||||
//BBS: add part plate related logic
|
||||
void MenuFactory::create_plate_menu()
|
||||
{
|
||||
|
|
@ -1586,6 +1600,8 @@ void MenuFactory::init(wxWindow* parent)
|
|||
//BBS: add part plate related logic
|
||||
create_plate_menu();
|
||||
|
||||
create_filament_action_menu();
|
||||
|
||||
// create "Instance to Object" menu item
|
||||
append_menu_item_instance_to_object(&m_instance_menu);
|
||||
}
|
||||
|
|
@ -1743,6 +1759,8 @@ wxMenu* MenuFactory::assemble_multi_selection_menu()
|
|||
return menu;
|
||||
}
|
||||
|
||||
wxMenu *MenuFactory::filament_action_menu() { return &m_filament_action_menu; }
|
||||
|
||||
|
||||
//BBS: add partplate related logic
|
||||
wxMenu* MenuFactory::plate_menu()
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ public:
|
|||
wxMenu* assemble_part_menu();
|
||||
wxMenu* assemble_multi_selection_menu();
|
||||
|
||||
wxMenu *filament_action_menu();
|
||||
|
||||
private:
|
||||
enum MenuType {
|
||||
mtObjectFFF = 0,
|
||||
|
|
@ -98,6 +100,8 @@ private:
|
|||
MenuWithSeparators m_plate_menu;
|
||||
MenuWithSeparators m_assemble_object_menu;
|
||||
MenuWithSeparators m_assemble_part_menu;
|
||||
|
||||
wxMenu m_filament_action_menu;
|
||||
|
||||
|
||||
// Removed/Prepended Items according to the view mode
|
||||
|
|
@ -120,6 +124,8 @@ private:
|
|||
void create_bbl_assemble_object_menu();
|
||||
void create_bbl_assemble_part_menu();
|
||||
|
||||
void create_filament_action_menu();
|
||||
|
||||
wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type);
|
||||
// Orca: add submenu for adding handy models
|
||||
wxMenu* append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type);
|
||||
|
|
|
|||
|
|
@ -351,6 +351,7 @@ struct Sidebar::priv
|
|||
ScalableButton * m_bpButton_del_filament;
|
||||
ScalableButton * m_bpButton_ams_filament;
|
||||
ScalableButton * m_bpButton_set_filament;
|
||||
int m_menu_filament_id = -1;
|
||||
wxPanel* m_panel_filament_content;
|
||||
wxScrolledWindow* m_scrolledWindow_filament_content;
|
||||
wxStaticLine* m_staticline2;
|
||||
|
|
@ -1107,20 +1108,20 @@ Sidebar::Sidebar(Plater *parent)
|
|||
|
||||
// ORCA Moved add button after delete button to prevent add button position change when remove icon automatically hidden
|
||||
|
||||
ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament");
|
||||
del_btn->SetToolTip(_L("Remove last filament"));
|
||||
del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
|
||||
delete_filament();
|
||||
});
|
||||
p->m_bpButton_del_filament = del_btn;
|
||||
//ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament");
|
||||
//del_btn->SetToolTip(_L("Remove last filament"));
|
||||
//del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
|
||||
// delete_filament();
|
||||
//});
|
||||
//p->m_bpButton_del_filament = del_btn;
|
||||
|
||||
bSizer39->Add(del_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(SidebarProps::IconSpacing()));
|
||||
//bSizer39->Add(del_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(SidebarProps::IconSpacing()));
|
||||
bSizer39->Add(add_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(SidebarProps::IconSpacing())); // ORCA Moved add button after delete button to prevent add button position change when remove icon automatically hidden
|
||||
bSizer39->AddSpacer(FromDIP(20));
|
||||
|
||||
if (p->combos_filament.size() <= 1) { // ORCA Fix Flushing button and Delete filament button not hidden on launch while only 1 filament exist
|
||||
bSizer39->Hide(p->m_flushing_volume_btn);
|
||||
bSizer39->Hide(p->m_bpButton_del_filament); // ORCA: Hide delete filament button if there is only one filament
|
||||
//bSizer39->Hide(p->m_bpButton_del_filament); // ORCA: Hide delete filament button if there is only one filament
|
||||
}
|
||||
|
||||
ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
|
||||
|
|
@ -1318,16 +1319,18 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame
|
|||
combo_and_btn_sizer->Add(32 * em / 10, 0, 0, 0, 0);
|
||||
combo_and_btn_sizer->Add(del_btn, 0, wxALIGN_CENTER_VERTICAL, 5 * em / 10);
|
||||
*/
|
||||
ScalableButton* edit_btn = new ScalableButton(p->m_panel_filament_content, wxID_ANY, "edit");
|
||||
ScalableButton* edit_btn = new ScalableButton(p->m_panel_filament_content, wxID_ANY, "menu_filament");
|
||||
edit_btn->SetToolTip(_L("Click to edit preset"));
|
||||
|
||||
PlaterPresetComboBox* combobox = (*combo);
|
||||
edit_btn->Bind(wxEVT_BUTTON, [this, combobox, filament_idx](wxCommandEvent)
|
||||
{
|
||||
p->editing_filament = -1;
|
||||
if (combobox->switch_to_tab())
|
||||
p->editing_filament = filament_idx; // sync with TabPresetComboxBox's m_filament_idx
|
||||
});
|
||||
edit_btn->Bind(wxEVT_BUTTON, [this, edit_btn, filament_idx](wxCommandEvent) {
|
||||
auto menu = p->plater->filament_action_menu();
|
||||
wxPoint pt { 0, edit_btn->GetSize().GetHeight() + 10 };
|
||||
pt = edit_btn->ClientToScreen(pt);
|
||||
pt = wxGetApp().mainframe->ScreenToClient(pt);
|
||||
p->m_menu_filament_id = filament_idx;
|
||||
p->plater->PopupMenu(menu, (int) pt.x, pt.y);
|
||||
});
|
||||
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))
|
||||
|
|
@ -1865,6 +1868,9 @@ void Sidebar::delete_filament(size_t filament_id) {
|
|||
if (p->combos_filament.size() <= 1) return;
|
||||
|
||||
size_t filament_count = p->combos_filament.size() - 1;
|
||||
if (filament_id == size_t(-2)) {
|
||||
filament_id = p->m_menu_filament_id;
|
||||
}
|
||||
if (filament_id == size_t(-1)) {
|
||||
filament_id = filament_count;
|
||||
}
|
||||
|
|
@ -1887,6 +1893,14 @@ void Sidebar::delete_filament(size_t filament_id) {
|
|||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
}
|
||||
|
||||
void Sidebar::edit_filament()
|
||||
{
|
||||
p->editing_filament = -1;
|
||||
if (p->m_menu_filament_id >= 0 && p->m_menu_filament_id < p->combos_filament.size()
|
||||
&& p->combos_filament[p->m_menu_filament_id]->switch_to_tab())
|
||||
p->editing_filament = p->m_menu_filament_id; // sync with TabPresetComboxBox's m_filament_idx
|
||||
}
|
||||
|
||||
void Sidebar::add_custom_filament(wxColour new_col) {
|
||||
if (p->combos_filament.size() >= MAXIMUM_EXTRUDER_NUMBER) return;
|
||||
|
||||
|
|
@ -1912,43 +1926,41 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
std::map<int, DynamicPrintConfig> filament_ams_list;
|
||||
if (!obj) return filament_ams_list;
|
||||
|
||||
auto vt_tray = obj->vt_slot[0];
|
||||
if (obj->ams_support_virtual_tray) {
|
||||
DynamicPrintConfig vt_tray_config;
|
||||
vt_tray_config.set_key_value("filament_id", new ConfigOptionStrings{ vt_tray.setting_id });
|
||||
vt_tray_config.set_key_value("tag_uid", new ConfigOptionStrings{ vt_tray.tag_uid });
|
||||
vt_tray_config.set_key_value("filament_type", new ConfigOptionStrings{ vt_tray.type });
|
||||
vt_tray_config.set_key_value("tray_name", new ConfigOptionStrings{ std::string("Ext") });
|
||||
vt_tray_config.set_key_value("filament_colour", new ConfigOptionStrings{ into_u8(wxColour("#" + vt_tray.color).GetAsString(wxC2S_HTML_SYNTAX)) });
|
||||
vt_tray_config.set_key_value("filament_exist", new ConfigOptionBools{ true });
|
||||
auto build_tray_config = [](AmsTray const & tray, std::string const & name) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": name %1% setting_id %2% color %3%") % name % tray.setting_id % tray.color;
|
||||
DynamicPrintConfig tray_config;
|
||||
tray_config.set_key_value("filament_id", new ConfigOptionStrings{tray.setting_id});
|
||||
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{tray.tag_uid});
|
||||
tray_config.set_key_value("filament_type", new ConfigOptionStrings{tray.type});
|
||||
tray_config.set_key_value("tray_name", new ConfigOptionStrings{ name });
|
||||
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.color).GetAsString(wxC2S_HTML_SYNTAX))});
|
||||
tray_config.set_key_value("filament_exist", new ConfigOptionBools{tray.is_exists});
|
||||
|
||||
vt_tray_config.set_key_value("filament_multi_colors", new ConfigOptionStrings{});
|
||||
for (int i = 0; i < vt_tray.cols.size(); ++i) {
|
||||
vt_tray_config.opt<ConfigOptionStrings>("filament_multi_colors")->values.push_back(into_u8(wxColour("#" + vt_tray.cols[i]).GetAsString(wxC2S_HTML_SYNTAX)));
|
||||
tray_config.set_key_value("filament_multi_colors", new ConfigOptionStrings{});
|
||||
for (int i = 0; i < tray.cols.size(); ++i) {
|
||||
tray_config.opt<ConfigOptionStrings>("filament_multi_colors")->values.push_back(into_u8(wxColour("#" + tray.cols[i]).GetAsString(wxC2S_HTML_SYNTAX)));
|
||||
}
|
||||
filament_ams_list.emplace(VIRTUAL_TRAY_MAIN_ID, std::move(vt_tray_config));
|
||||
return tray_config;
|
||||
};
|
||||
|
||||
auto vt_tray = obj->vt_tray;
|
||||
if (obj->ams_support_virtual_tray) {
|
||||
int extruder = 0x10000;
|
||||
//for (auto &vt_tray : obj->vt_slot) {
|
||||
filament_ams_list.emplace(extruder + VIRTUAL_TRAY_ID, build_tray_config(vt_tray, "Ext"));
|
||||
extruder = 0;
|
||||
//}
|
||||
}
|
||||
|
||||
auto list = obj->amsList;
|
||||
for (auto ams : list) {
|
||||
char n = ams.first.front() - '0' + 'A';
|
||||
int extruder = /*ams.nozzle ? 0 :*/ 0x10000;
|
||||
for (auto tray : ams.second->trayList) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__
|
||||
<< boost::format(": ams %1% tray %2% id %3% color %4%") % ams.first % tray.first % tray.second->setting_id % tray.second->color;
|
||||
char t = tray.first.front() - '0' + '1';
|
||||
DynamicPrintConfig tray_config;
|
||||
tray_config.set_key_value("filament_id", new ConfigOptionStrings{ tray.second->setting_id });
|
||||
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{ tray.second->tag_uid });
|
||||
tray_config.set_key_value("filament_type", new ConfigOptionStrings{ tray.second->type });
|
||||
tray_config.set_key_value("tray_name", new ConfigOptionStrings{ std::string(1, n) + std::string(1, t) });
|
||||
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{ into_u8(wxColour("#" + tray.second->color).GetAsString(wxC2S_HTML_SYNTAX)) });
|
||||
tray_config.set_key_value("filament_exist", new ConfigOptionBools{ tray.second->is_exists });
|
||||
|
||||
tray_config.set_key_value("filament_multi_colors", new ConfigOptionStrings{});
|
||||
for (int i = 0; i < tray.second->cols.size(); ++i) {
|
||||
tray_config.opt<ConfigOptionStrings>("filament_multi_colors")->values.push_back(into_u8(wxColour("#" + tray.second->cols[i]).GetAsString(wxC2S_HTML_SYNTAX)));
|
||||
}
|
||||
filament_ams_list.emplace(((n - 'A') * 4 + t - '1'), std::move(tray_config));
|
||||
filament_ams_list.emplace(extruder + ((n - 'A') * 4 + t - '1'),
|
||||
build_tray_config(*tray.second, std::string(1, n) + std::string(1, t)));
|
||||
extruder = 0;
|
||||
}
|
||||
}
|
||||
return filament_ams_list;
|
||||
|
|
@ -15077,6 +15089,7 @@ wxMenu* Plater::default_menu() { return p->menus.default_menu();
|
|||
wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); }
|
||||
wxMenu* Plater::layer_menu() { return p->menus.layer_menu(); }
|
||||
wxMenu* Plater::multi_selection_menu() { return p->menus.multi_selection_menu(); }
|
||||
wxMenu *Plater::filament_action_menu() { return p->menus.filament_action_menu(); }
|
||||
int Plater::GetPlateIndexByRightMenuInLeftUI() { return p->m_is_RightClickInLeftUI; }
|
||||
void Plater::SetPlateIndexByRightMenuInLeftUI(int index) { p->m_is_RightClickInLeftUI = index; }
|
||||
SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() :
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ public:
|
|||
|
||||
void add_filament();
|
||||
void delete_filament(size_t filament_id = size_t(-1));
|
||||
void edit_filament();
|
||||
void add_custom_filament(wxColour new_col);
|
||||
// BBS
|
||||
void on_bed_type_change(BedType bed_type);
|
||||
|
|
@ -782,6 +783,7 @@ public:
|
|||
wxMenu* instance_menu();
|
||||
wxMenu* layer_menu();
|
||||
wxMenu* multi_selection_menu();
|
||||
wxMenu* filament_action_menu();
|
||||
int GetPlateIndexByRightMenuInLeftUI();
|
||||
void SetPlateIndexByRightMenuInLeftUI(int);
|
||||
static bool has_illegal_filename_characters(const wxString& name);
|
||||
|
|
|
|||
|
|
@ -398,10 +398,15 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
|||
{
|
||||
bool is_bbl_vendor_preset = m_preset_bundle->is_bbl_vendor();
|
||||
if (is_bbl_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
|
||||
set_label_marker(Append(separator(L("AMS filaments")), wxNullBitmap));
|
||||
bool dual_extruder = (--m_preset_bundle->filament_ams_list.end())->first & 0x10000;
|
||||
set_label_marker(Append(separator(dual_extruder ? L("Left filaments") : L("AMS filaments")), wxNullBitmap));
|
||||
m_first_ams_filament = GetCount();
|
||||
auto &filaments = m_collection->get_presets();
|
||||
for (auto &entry : m_preset_bundle->filament_ams_list) {
|
||||
if (dual_extruder && (entry.first & 0x10000)) {
|
||||
dual_extruder = false;
|
||||
set_label_marker(Append(separator(L("Right filaments")), wxNullBitmap));
|
||||
}
|
||||
auto & tray = entry.second;
|
||||
std::string filament_id = tray.opt_string("filament_id", 0u);
|
||||
if (filament_id.empty()) continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue