ENH: refine the logic of filament map dialog

1. Always change the map and mode in plate if plate mode is not default
2. Always add pop up before slice
3. Fix the mapping issue in gcode viewer

jira: studio-9523,studio-9519,studio-9513,studio-9479

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I0d7d5daf081951ea2d49e06565762ac24064e77c
This commit is contained in:
xun.zhang 2025-01-08 21:14:10 +08:00 committed by lane.wei
parent 3060a8606a
commit afaa48520e
12 changed files with 262 additions and 160 deletions

View File

@ -273,8 +273,8 @@ void AppConfig::set_defaults()
set_bool("ignore_ext_filament_in_filament_map", false);
}
if (get("pop_up_filament_map_mode").empty()){
set_bool("pop_up_filament_map_mode", true);
if (get("pop_up_filament_map_dialog").empty()){
set_bool("pop_up_filament_map_dialog", true);
}
if (get("prefered_filament_map_mode").empty()){

View File

@ -3,6 +3,7 @@
#include "MsgDialog.hpp"
#include "wx/dcgraph.h"
#include "I18N.hpp"
#include "PartPlate.hpp"
namespace Slic3r { namespace GUI {
@ -12,7 +13,8 @@ static const wxColour GreyColor = wxColour("#6B6B6B");
static const wxColour GreenColor = wxColour("#00AE42");
static const wxColour BackGroundColor = wxColour("#FFFFFF");
static bool is_multi_extruder()
static bool should_pop_up()
{
const auto &preset_bundle = wxGetApp().preset_bundle;
const auto &full_config = preset_bundle->full_config();
@ -20,7 +22,7 @@ static bool is_multi_extruder()
return nozzle_diameters->size() > 1;
}
FilamentMapMode get_prefered_map_mode()
static FilamentMapMode get_prefered_map_mode()
{
const static std::map<std::string, int> enum_keys_map = ConfigOptionEnum<FilamentMapMode>::get_enum_values();
auto &app_config = wxGetApp().app_config;
@ -44,25 +46,6 @@ static void set_prefered_map_mode(FilamentMapMode mode)
app_config->set("prefered_filament_map_mode", mode_str);
}
static bool get_pop_up_remind_flag()
{
auto &app_config = wxGetApp().app_config;
return app_config->get_bool("pop_up_filament_map_mode");
}
static void set_pop_up_remind_flag(bool remind)
{
auto &app_config = wxGetApp().app_config;
app_config->set_bool("pop_up_filament_map_mode", remind);
}
bool is_pop_up_required()
{
FilamentMapMode mode = get_prefered_map_mode();
bool is_manual_mode_ = FilamentMapMode::fmmManual == mode;
bool is_multi_extruder_ = is_multi_extruder();
return is_multi_extruder_ && is_manual_mode_;
}
FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS)
{
@ -161,20 +144,8 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w
wiki_link->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent &) { wxLaunchDefaultBrowser("http//:example.com"); });
wiki_sizer->Add(wiki_link, 0, wxALIGN_CENTER | wxALL, FromDIP(3));
auto* checkbox_sizer = new wxBoxSizer(wxHORIZONTAL);
remind_checkbox = new CheckBox(this);
remind_checkbox->Bind(wxEVT_TOGGLEBUTTON, &FilamentGroupPopup::OnRemindBtn, this);
checkbox_sizer->Add(remind_checkbox, 0, wxALIGN_CENTER, 0);
auto checkbox_title = new Label(this, _L("Don't remind me again"));
checkbox_title->SetBackgroundColour(BackGroundColor);
checkbox_title->SetForegroundColour(GreyColor);
checkbox_title->SetFont(Label::Body_12);
checkbox_sizer->Add(checkbox_title, 0, wxALIGN_CENTER | wxALL, FromDIP(3));
button_sizer->Add(wiki_sizer, 0, wxLEFT, horizontal_margin);
button_sizer->AddStretchSpacer();
button_sizer->Add(checkbox_sizer, 0, wxRIGHT, horizontal_margin);
top_sizer->Add(button_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, horizontal_margin);
}
@ -242,27 +213,22 @@ void FilamentGroupPopup::Init()
button_desps[ButtonType::btForMatch]->SetLabel(MachineSyncTip);
}
m_mode = get_prefered_map_mode();
m_mode = GetFilamentMapMode();
if (m_mode == fmmAutoForMatch && !m_connected) {
set_prefered_map_mode(fmmAutoForFlush);
SetFilamentMapMode(fmmAutoForFlush);
m_mode = fmmAutoForFlush;
}
bool check_state = get_pop_up_remind_flag() ? false : true;
remind_checkbox->SetValue(check_state);
UpdateButtonStatus();
}
void FilamentGroupPopup::tryPopup(bool connect_status)
void FilamentGroupPopup::tryPopup(Plater* plater,PartPlate* partplate,bool skip_plate_sync)
{
auto canPopup = [this]() {
bool is_multi_extruder_ = is_multi_extruder();
bool pop_up_flag = get_pop_up_remind_flag();
return is_multi_extruder_ && pop_up_flag;
};
if (canPopup()) {
if (should_pop_up()) {
bool connect_status = plater->get_machine_sync_status();
this->partplate_ref = partplate;
this->plater_ref = plater;
this->m_sync_plate = !skip_plate_sync && partplate->get_filament_map_mode() != fmmDefault;
if (m_active) {
if (m_connected != connect_status) { Init(); }
m_connected = connect_status;
@ -278,6 +244,25 @@ void FilamentGroupPopup::tryPopup(bool connect_status)
}
}
FilamentMapMode FilamentGroupPopup::GetFilamentMapMode() const
{
const auto& proj_config = wxGetApp().preset_bundle->project_config;
if (m_sync_plate)
return partplate_ref->get_real_filament_map_mode(proj_config);
return plater_ref->get_global_filament_map_mode();
}
void FilamentGroupPopup::SetFilamentMapMode(const FilamentMapMode mode)
{
if (m_sync_plate) {
partplate_ref->set_filament_map_mode(mode);
return;
}
plater_ref->set_global_filament_map_mode(mode);
}
void FilamentGroupPopup::tryClose() { StartTimer(); }
void FilamentGroupPopup::OnPaint(wxPaintEvent&)
@ -298,24 +283,11 @@ void FilamentGroupPopup::OnRadioBtn(int idx)
return;
m_mode = mode_list.at(idx);
set_prefered_map_mode(m_mode);
SetFilamentMapMode(m_mode);
UpdateButtonStatus(m_mode);
}
void FilamentGroupPopup::OnRemindBtn(wxCommandEvent &event)
{
bool is_checked = remind_checkbox->GetValue();
remind_checkbox->SetValue(is_checked);
set_pop_up_remind_flag(!is_checked);
if (is_checked) {
MessageDialog dialog(nullptr, _L("No further pop-up will appear. You can reopen it in 'Preferences'"), _L("Tips"), wxICON_INFORMATION | wxOK);
dialog.ShowModal();
Dismiss();
}
}
void FilamentGroupPopup::OnTimer(wxTimerEvent &event) { Dismiss(); }
void FilamentGroupPopup::Dismiss() {
@ -362,11 +334,6 @@ void FilamentGroupPopup::UpdateButtonStatus(int hover_idx)
}
}
if (m_mode == FilamentMapMode::fmmAutoForMatch)
remind_checkbox->Enable(false);
else
remind_checkbox->Enable(true);
Layout();
Fit();
}

View File

@ -2,19 +2,19 @@
#define FILAMENT_GROUP_HOVER_HPP
#include "Widgets/PopupWindow.hpp"
#include "Widgets/CheckBox.hpp"
#include "Widgets/Label.hpp"
namespace Slic3r { namespace GUI {
bool is_pop_up_required();
FilamentMapMode get_prefered_map_mode();
class PartPlate;
class Plater;
class FilamentGroupPopup : public PopupWindow
{
public:
FilamentGroupPopup(wxWindow *parent);
void tryPopup(bool connect_status);
void tryPopup(Plater* plater,PartPlate* plate,bool skip_plate_sync);
void tryClose();
FilamentMapMode GetSelectedMode() const { return m_mode; }
@ -27,30 +27,36 @@ private:
void OnLeaveWindow(wxMouseEvent &);
void OnEnterWindow(wxMouseEvent &);
void OnTimer(wxTimerEvent &event);
void OnRemindBtn(wxCommandEvent &event);
void Dismiss();
void Init();
void UpdateButtonStatus(int hover_idx = -1);
void DrawRoundedCorner(int radius);
private:
FilamentMapMode GetFilamentMapMode() const;
void SetFilamentMapMode(const FilamentMapMode mode);
private:
enum ButtonType { btForFlush, btForMatch, btManual, btCount };
const std::vector<FilamentMapMode> mode_list = {fmmAutoForFlush, fmmAutoForMatch, fmmManual};
FilamentMapMode m_mode;
bool m_connected{ false };
wxTimer *m_timer;
bool m_active{ false };
bool m_sync_plate{ false };
FilamentMapMode m_mode;
wxTimer *m_timer;
std::vector<wxBitmapButton *> radio_btns;
std::vector<Label *> button_labels;
std::vector<Label *> button_desps;
std::vector<Label *> detail_infos;
wxStaticText *wiki_link;
CheckBox* remind_checkbox;
PartPlate* partplate_ref{ nullptr };
Plater* plater_ref{ nullptr };
};
}} // namespace Slic3r::GUI
#endif

View File

@ -1,14 +1,98 @@
#include "FilamentMapDialog.hpp"
#include "DragDropPanel.hpp"
#include "Widgets/Button.hpp"
#include "Widgets/SwitchButton.hpp"
#include "I18N.hpp"
#include "GUI_App.hpp"
#include "CapsuleButton.hpp"
#include "SelectMachine.hpp"
#include "MsgDialog.hpp"
namespace Slic3r { namespace GUI {
static bool get_pop_up_remind_flag()
{
auto &app_config = wxGetApp().app_config;
return app_config->get_bool("pop_up_filament_map_dialog");
}
static void set_pop_up_remind_flag(bool remind)
{
auto &app_config = wxGetApp().app_config;
app_config->set_bool("pop_up_filament_map_dialog", remind);
}
static FilamentMapMode get_applied_map_mode(DynamicConfig& proj_config, const Plater* plater_ref, const PartPlate* partplate_ref, const bool sync_plate)
{
if (sync_plate)
return partplate_ref->get_real_filament_map_mode(proj_config);
return plater_ref->get_global_filament_map_mode();
}
static std::vector<int> get_applied_map(DynamicConfig& proj_config, const Plater* plater_ref, const PartPlate* partplate_ref, const bool sync_plate)
{
if (sync_plate)
return partplate_ref->get_real_filament_maps(proj_config);
return plater_ref->get_global_filament_map();
}
bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate* partplate_ref)
{
auto full_config = wxGetApp().preset_bundle->full_config();
const auto nozzle_diameters = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter");
if (nozzle_diameters->size() <= 1)
return true;
bool force_pop_up = get_pop_up_remind_flag();
bool sync_plate = !skip_plate_sync && partplate_ref->get_filament_map_mode() != fmmDefault;
std::vector<std::string> filament_colors = full_config.option<ConfigOptionStrings>("filament_colour")->values;
FilamentMapMode applied_mode = get_applied_map_mode(full_config, plater_ref,partplate_ref, sync_plate);
std::vector<int> applied_maps = get_applied_map(full_config, plater_ref, partplate_ref, sync_plate);
applied_maps.resize(filament_colors.size(), 1);
if (!force_pop_up && applied_mode != fmmManual)
return true;
std::vector<int> filament_lists;
if (skip_plate_sync) {
filament_lists.resize(filament_colors.size());
std::iota(filament_lists.begin(), filament_lists.end(), 1);
}
else {
filament_lists = partplate_ref->get_extruders();
}
FilamentMapDialog map_dlg(plater_ref,
filament_colors,
applied_maps,
filament_lists,
applied_mode,
plater_ref->get_machine_sync_status(),
false,
force_pop_up
);
auto ret = map_dlg.ShowModal();
if (ret == wxID_OK) {
FilamentMapMode new_mode = map_dlg.get_mode();
std::vector<int> new_maps = map_dlg.get_filament_maps();
if (sync_plate) {
partplate_ref->set_filament_map_mode(new_mode);
if (new_mode == fmmManual)
partplate_ref->set_filament_maps(new_maps);
}
else {
plater_ref->set_global_filament_map_mode(new_mode);
if (new_mode == fmmManual)
plater_ref->set_global_filament_map(new_maps);
}
return true;
}
return false;
}
static const StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
@ -31,13 +115,14 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent,
const std::vector<int> &filaments,
const FilamentMapMode mode,
bool machine_synced,
bool show_default)
bool show_default,
bool with_checkbox)
: wxDialog(parent, wxID_ANY, _L("Filament arrangement method"), wxDefaultPosition, wxDefaultSize,wxDEFAULT_DIALOG_STYLE), m_filament_color(filament_color), m_filament_map(filament_map)
{
SetBackgroundColour(*wxWHITE);
SetMinSize(wxSize(FromDIP(550), -1));
SetMaxSize(wxSize(FromDIP(550), -1));
SetMinSize(wxSize(FromDIP(580), -1));
SetMaxSize(wxSize(FromDIP(580), -1));
if (mode < fmmManual)
m_page_type = PageType::ptAuto;
@ -86,24 +171,50 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent,
if (show_default) panel_sizer->Add(m_default_map_panel, 0, wxALIGN_CENTER | wxEXPAND);
main_sizer->Add(panel_sizer, 0, wxEXPAND);
wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
m_ok_btn = new Button(this, _L("OK"));
m_cancel_btn = new Button(this, _L("Cancel"));
m_ok_btn->SetCornerRadius(FromDIP(12));
m_cancel_btn->SetCornerRadius(FromDIP(12));
m_ok_btn->SetFont(Label::Body_12);
m_cancel_btn->SetFont(Label::Body_12);
wxPanel* bottom_panel = new wxPanel(this);
bottom_panel->SetBackgroundColour(*wxWHITE);
wxBoxSizer *bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
bottom_panel->SetSizer(bottom_sizer);
bottom_sizer->Fit(bottom_panel);
m_ok_btn->SetBackgroundColor(btn_bg_green);
m_ok_btn->SetBorderColor(btn_bd_green);
m_ok_btn->SetTextColor(btn_text_green);
m_cancel_btn->SetBackgroundColor(btn_bg_white);
m_cancel_btn->SetBorderColor(btn_bd_white);
m_cancel_btn->SetTextColor(btn_text_white);
if(with_checkbox)
{
auto* checkbox_sizer = new wxBoxSizer(wxHORIZONTAL);
m_checkbox = new CheckBox(bottom_panel);
m_checkbox->Bind(wxEVT_TOGGLEBUTTON, &FilamentMapDialog::on_checkbox, this);
checkbox_sizer->Add(m_checkbox, 0, wxALIGN_CENTER, 0);
button_sizer->Add(m_ok_btn, 0, wxALL, FromDIP(8));
button_sizer->Add(m_cancel_btn, 0, wxALL, FromDIP(8));
main_sizer->Add(button_sizer, 0, wxALIGN_RIGHT | wxALL, FromDIP(15));
auto* checkbox_label = new Label(bottom_panel, _L("Don't remind me again"));
checkbox_label->SetFont(Label::Body_12);
checkbox_sizer->Add(checkbox_label, 0, wxLEFT| wxALIGN_CENTER , FromDIP(3));
bottom_sizer->Add(checkbox_sizer, 0 , wxALIGN_CENTER | wxALL, FromDIP(15));
}
bottom_sizer->AddStretchSpacer();
{
wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
m_ok_btn = new Button(bottom_panel, _L("OK"));
m_cancel_btn = new Button(bottom_panel, _L("Cancel"));
m_ok_btn->SetCornerRadius(FromDIP(12));
m_cancel_btn->SetCornerRadius(FromDIP(12));
m_ok_btn->SetFont(Label::Body_12);
m_cancel_btn->SetFont(Label::Body_12);
m_ok_btn->SetBackgroundColor(btn_bg_green);
m_ok_btn->SetBorderColor(btn_bd_green);
m_ok_btn->SetTextColor(btn_text_green);
m_cancel_btn->SetBackgroundColor(btn_bg_white);
m_cancel_btn->SetBorderColor(btn_bd_white);
m_cancel_btn->SetTextColor(btn_text_white);
button_sizer->Add(m_ok_btn, 1, wxRIGHT, FromDIP(4));
button_sizer->Add(m_cancel_btn, 1, wxLEFT, FromDIP(4));
bottom_sizer->Add(button_sizer, 0, wxALIGN_CENTER | wxALL, FromDIP(15));
}
main_sizer->Add(bottom_panel, 0, wxEXPAND);
m_ok_btn->Bind(wxEVT_BUTTON, &FilamentMapDialog::on_ok, this);
m_cancel_btn->Bind(wxEVT_BUTTON, &FilamentMapDialog::on_cancle, this);
@ -133,6 +244,19 @@ int FilamentMapDialog::ShowModal()
return wxDialog::ShowModal();
}
void FilamentMapDialog::on_checkbox(wxCommandEvent &event)
{
bool is_checked = m_checkbox->GetValue();
m_checkbox->SetValue(is_checked);
set_pop_up_remind_flag(!is_checked);
if (is_checked) {
MessageDialog dialog(nullptr, _L("No further pop-up will appear. You can reopen it in 'Preferences'"), _L("Tips"), wxICON_INFORMATION | wxOK);
dialog.ShowModal();
this->Close();
}
}
void FilamentMapDialog::on_ok(wxCommandEvent &event)
{
if (m_page_type == PageType::ptManual) {

View File

@ -4,17 +4,31 @@
#include "FilamentMapPanel.hpp"
#include <vector>
#include "CapsuleButton.hpp"
#include "Widgets/CheckBox.hpp"
class SwitchButton;
class ScalableButton;
class Button;
class wxStaticText;
namespace Slic3r {
class DynamicPrintConfig;
namespace GUI {
class DragDropPanel;
class Plater;
class PartPlate;
/**
* @brief Try to pop up the filament map dialog before slicing.
*
* Only pop up in multi extruder machines. If user don't want the pop up, we
* pop up if the applied filament map mode in manual
*
* @param skip_plate_sync whether sync the map mode change to plate. In slice all, we should skip the sync and change on global param
* @param plater_ref Plater to get/set global filament map
* @param partplate_ref Partplate to get/set plate filament map mode
* @return whether continue slicing
*/
bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate* partplate_ref);
class FilamentMapDialog : public wxDialog
{
@ -30,11 +44,16 @@ public:
const std::vector<int> &filaments,
const FilamentMapMode mode,
bool machine_synced,
bool show_default=true
bool show_default=true,
bool with_checkbox = false
);
FilamentMapMode get_mode();
const std::vector<int>& get_filament_maps() const { return m_filament_map; }
std::vector<int> get_filament_maps() const {
if (m_page_type == PageType::ptManual)
return m_filament_map;
return {};
}
int ShowModal();
void set_modal_btn_labels(const wxString& left_label, const wxString& right_label);
@ -42,6 +61,7 @@ private:
void on_ok(wxCommandEvent &event);
void on_cancle(wxCommandEvent &event);
void on_switch_mode(wxCommandEvent &event);
void on_checkbox(wxCommandEvent &event);
void update_panel_status(PageType page);
@ -56,6 +76,7 @@ private:
Button* m_ok_btn;
Button* m_cancel_btn;
CheckBox* m_checkbox;
PageType m_page_type;

View File

@ -127,7 +127,7 @@ GUI::FilamentMapBtnPanel::FilamentMapBtnPanel(wxWindow *parent, const wxString &
auto label_sizer = new wxBoxSizer(wxHORIZONTAL);
label_sizer->AddStretchSpacer();
label_sizer->Add(m_btn, 0, wxALIGN_CENTER | wxEXPAND);
label_sizer->Add(m_label, 0, wxALIGN_CENTER | wxEXPAND);
label_sizer->Add(m_label, 0, wxALIGN_CENTER | wxEXPAND| wxALL, FromDIP(3));
label_sizer->AddStretchSpacer();
sizer->AddSpacer(FromDIP(32));

View File

@ -1608,40 +1608,10 @@ wxBoxSizer* MainFrame::create_side_tools()
bool slice = true;
auto full_config = wxGetApp().preset_bundle->full_config();
std::vector<int>g_filament_map = full_config.option<ConfigOptionInts>("filament_map")->values;
FilamentMapMode g_filament_map_mode = get_prefered_map_mode();
if (is_pop_up_required()) {
auto filament_colors = full_config.option<ConfigOptionStrings>("filament_colour")->values;
g_filament_map.resize(filament_colors.size());
std::vector<int> filament_lists(filament_colors.size());
std::iota(filament_lists.begin(), filament_lists.end(), 1);
FilamentMapDialog filament_dlg(this,
filament_colors,
g_filament_map,
filament_lists,
FilamentMapMode::fmmManual,
m_plater->get_machine_sync_status(),
false
);
auto ret = filament_dlg.ShowModal();
if (ret == wxID_OK) {
g_filament_map_mode = filament_dlg.get_mode();
g_filament_map = filament_dlg.get_filament_maps();
}
else {
slice = false;
}
}
auto curr_plate = m_plater->get_partplate_list().get_curr_plate();
slice = try_pop_up_before_slice(m_slice_select == eSliceAll, m_plater, curr_plate);
if (slice) {
if (m_plater->get_global_filament_map_mode() != g_filament_map_mode)
m_plater->on_filament_map_mode_change();
m_plater->set_global_filament_map_mode(g_filament_map_mode);
if (g_filament_map_mode == FilamentMapMode::fmmManual)
m_plater->set_global_filament_map(g_filament_map);
if (m_slice_select == eSliceAll)
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SLICE_ALL));
else
@ -1655,8 +1625,10 @@ wxBoxSizer* MainFrame::create_side_tools()
pos.y += m_slice_btn->GetRect().height * 1.25;
pos.x -= (m_slice_option_btn->GetRect().width + FromDIP(380) * 0.6);
auto curr_plate=this->m_plater->get_partplate_list().get_curr_plate();
m_filament_group_popup->SetPosition(pos);
m_filament_group_popup->tryPopup(m_plater->get_machine_sync_status());
m_filament_group_popup->tryPopup(m_plater,curr_plate, m_slice_select == eSliceAll);
});
m_slice_btn->Bind(wxEVT_LEAVE_WINDOW, [this](auto& event) {

View File

@ -2940,7 +2940,18 @@ FilamentMapMode PartPlate::get_filament_map_mode() const
void PartPlate::set_filament_map_mode(const FilamentMapMode& mode)
{
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = mode;
const auto& proj_config = wxGetApp().preset_bundle->project_config;
FilamentMapMode global_mode = proj_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode")->value;
FilamentMapMode old_mode = get_filament_map_mode();
FilamentMapMode old_real_mode = old_mode == fmmDefault ? global_mode : old_mode;
FilamentMapMode new_real_mode = mode == fmmDefault ? global_mode : mode;
if (old_real_mode != new_real_mode)
clear_filament_map();
if (mode == fmmDefault)
clear_filament_map_mode();
else
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = mode;
}
std::vector<int> PartPlate::get_filament_maps() const

View File

@ -183,6 +183,8 @@ private:
std::array<float, 4> picking_color_component(int idx) const;
void release_opengl_resource();
void on_filament_map_mode_change();
public:
static const unsigned int PLATE_BASE_ID = 255 * 255 * 253;
static const unsigned int PLATE_FILAMENT_MAP_ID = 6;
@ -305,10 +307,11 @@ public:
Vec3d estimate_wipe_tower_size(const DynamicPrintConfig & config, const double w, const double wipe_volume, int plate_extruder_size = 0, bool use_global_objects = false) const;
arrangement::ArrangePolygon estimate_wipe_tower_polygon(const DynamicPrintConfig & config, int plate_index, int plate_extruder_size = 0, bool use_global_objects = false) const;
bool check_objects_empty_and_gcode3mf(std::vector<int> &result) const;
// get used filaments from config, 1 based idx
std::vector<int> get_extruders(bool conside_custom_gcode = false) const;
std::vector<int> get_extruders_under_cli(bool conside_custom_gcode, DynamicPrintConfig& full_config) const;
std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const;
// get used filaments, 1 based idx
// get used filaments from gcode result, 1 based idx
std::vector<int> get_used_filaments();
int get_physical_extruder_by_filament_id(const DynamicConfig& g_config, int idx) const;
bool check_tpu_printable_status(const DynamicPrintConfig & config, const std::vector<int> &tpu_filaments);

View File

@ -14644,7 +14644,11 @@ std::vector<std::string> Plater::get_colors_for_color_print(const GCodeProcessor
void Plater::set_global_filament_map_mode(FilamentMapMode mode)
{
auto& project_config = wxGetApp().preset_bundle->project_config;
project_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode")->value = mode;
auto mode_ptr = project_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode");
FilamentMapMode old_mode = mode_ptr->value;
if(mode != old_mode)
on_filament_map_mode_change();
mode_ptr->value = mode;
}
void Plater::set_global_filament_map(const std::vector<int>& filament_map)
@ -15474,45 +15478,39 @@ void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt)
const auto& project_config = wxGetApp().preset_bundle->project_config;
auto filament_colors = config()->option<ConfigOptionStrings>("filament_colour")->values;
auto plate_filament_maps = curr_plate->get_real_filament_maps(project_config);
auto plate_filament_map_mode = curr_plate->get_filament_map_mode();
if (plate_filament_maps.size() != filament_colors.size()) // refine it later, save filament map to app config
plate_filament_maps.resize(filament_colors.size(), 1);
FilamentMapMode display_mode = force_manual ? FilamentMapMode::fmmManual : plate_filament_map_mode;
FilamentMapDialog filament_dlg(this,
filament_colors,
plate_filament_maps,
curr_plate->get_extruders(true),
display_mode,
plate_filament_map_mode,
this->get_machine_sync_status(),
true
);
if (filament_dlg.ShowModal() == wxID_OK) {
std::vector<int> new_filament_maps = filament_dlg.get_filament_maps();
std::vector<int> old_filament_maps = curr_plate->get_filament_maps();
std::vector<int> old_filament_maps = curr_plate->get_real_filament_maps(project_config);
FilamentMapMode old_map_mode = plate_filament_map_mode;
FilamentMapMode old_map_mode = curr_plate->get_filament_map_mode();
FilamentMapMode new_map_mode = filament_dlg.get_mode();
if (new_map_mode != old_map_mode) {
curr_plate->set_filament_map_mode(new_map_mode);
}
if (new_map_mode == fmmManual && old_filament_maps != new_filament_maps){
curr_plate->set_filament_maps(new_filament_maps);
}
bool need_invalidate = (old_map_mode != new_map_mode ||
old_filament_maps != new_filament_maps);
if (old_map_mode != new_map_mode) {
curr_plate->set_filament_map_mode(new_map_mode);
curr_plate->clear_filament_map();
}
if (old_filament_maps != new_filament_maps && new_map_mode==fmmManual)
curr_plate->set_filament_maps(new_filament_maps);
if (new_map_mode == fmmDefault) {
curr_plate->clear_filament_map();
curr_plate->clear_filament_map_mode();
}
if (need_invalidate) {
if (need_slice) {
wxPostEvent(this, SimpleEvent(EVT_GLTOOLBAR_SLICE_PLATE));

View File

@ -463,7 +463,6 @@ public:
void set_global_filament_map(const std::vector<int>& filament_map);
std::vector<int> get_global_filament_map() const;
FilamentMapMode get_global_filament_map_mode() const;
void on_filament_map_mode_change();
void update_menus();
// BBS
@ -815,6 +814,7 @@ private:
void _calib_pa_tower(const Calib_Params &params);
void _calib_pa_select_added_objects();
void on_filament_map_mode_change();
friend class SuppressBackgroundProcessingUpdate;
};

View File

@ -1244,7 +1244,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto title_filament_group = create_item_title(_L("Filament Arrange"), page, _L("Filament Arrange"));
auto item_ignore_ext_filament = create_item_checkbox(_L("Ignore ext filament when auto grouping"), page, _L("Ignore ext filament when auto grouping"), 50, "ignore_ext_filament_when_group");
auto item_pop_filament_group_mode = create_item_checkbox(_L("Pop up to select filament map mode"), page, _L("Pop up to select filament map mode"), 50, "pop_up_filament_map_mode");
auto item_pop_up_filament_map_dialog = create_item_checkbox(_L("Pop up to select filament map mode"), page, _L("Pop up to select filament map mode"), 50, "pop_up_filament_map_dialog");
auto title_user_experience = create_item_title(_L("User Experience"), page, _L("User Experience"));
auto item_priv_policy = create_item_checkbox(_L("Join Customer Experience Improvement Program."), page, "", 50, "privacyuse");
@ -1318,7 +1318,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(title_filament_group, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_ignore_ext_filament, 0, wxEXPAND, FromDIP(3));
sizer_page->Add(item_pop_filament_group_mode, 0, wxEXPAND, FromDIP(3));
sizer_page->Add(item_pop_up_filament_map_dialog, 0, wxEXPAND, FromDIP(3));
sizer_page->Add(title_user_experience, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_priv_policy, 0, wxTOP, FromDIP(3));