mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-29 13:53:20 +08:00
FIX: update the display of switch extruder
jira: [STUDIO-9746] [STUDIO-9359] Change-Id: I12ce46c935883e5dba709576b944275af547d3dd
This commit is contained in:
parent
e591b58c3a
commit
80b5e4f4d6
@ -5979,7 +5979,12 @@ void MachineObject::parse_new_info(json print)
|
||||
extder_data.target_extder_id = get_flag_bits(extruder["state"].get<int>(), 8, 4);
|
||||
extder_data.switch_extder_state = (ExtruderSwitchState) get_flag_bits(extruder["state"].get<int>(), 12, 3);
|
||||
|
||||
if (extder_data.switch_extder_state != ExtruderSwitchState::ES_SWITCHING && extder_data.target_extder_id == extder_data.current_extder_id) {
|
||||
if (m_extder_data.current_extder_id != extder_data.current_extder_id)
|
||||
{
|
||||
flag_update_nozzle = true;
|
||||
}
|
||||
else if (extder_data.switch_extder_state == ES_SWITCHING_FAILED)
|
||||
{
|
||||
flag_update_nozzle = true;
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#define MAIN_NOZZLE_ID 0
|
||||
#define DEPUTY_NOZZLE_ID 1
|
||||
#define UNIQUE_NOZZLE_ID MAIN_NOZZLE_ID
|
||||
#define INVALID_NOZZLE_ID -1
|
||||
|
||||
#define VIRTUAL_TRAY_MAIN_ID 255
|
||||
#define VIRTUAL_TRAY_DEPUTY_ID 254
|
||||
|
@ -229,7 +229,13 @@ void ExtruderImage::setExtruderCount(int nozzle_num)
|
||||
void ExtruderImage::setExtruderUsed(std::string loc)
|
||||
{
|
||||
//current_nozzle_idx = nozzle_id;
|
||||
if (current_nozzle_loc == loc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
current_nozzle_loc = loc;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ExtruderImage::update(ExtruderState single_state)
|
||||
@ -1669,6 +1675,7 @@ wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent)
|
||||
StateColor e_ctrl_bd(std::pair<wxColour, int>(BUTTON_HOVER_COL, StateColor::Hovered), std::pair<wxColour, int>(BUTTON_NORMAL1_COL, StateColor::Normal));
|
||||
|
||||
m_nozzle_btn_panel = new SwitchBoard(panel, _L("Left"), _L("Right"), wxSize(FromDIP(126), FromDIP(26)));
|
||||
m_nozzle_btn_panel->SetAutoDisableWhenSwitch();
|
||||
|
||||
m_bpButton_e_10 = new Button(panel, "", "monitor_extruder_up", 0, FromDIP(22));
|
||||
m_bpButton_e_10->SetBorderWidth(2);
|
||||
@ -2794,15 +2801,6 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
|
||||
|
||||
/*style*/
|
||||
m_nozzle_btn_panel->Show();
|
||||
if (!obj->is_in_printing() && obj->ams_status_main != AMS_STATUS_MAIN_FILAMENT_CHANGE)
|
||||
{
|
||||
m_nozzle_btn_panel->Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nozzle_btn_panel->Disable();
|
||||
}
|
||||
|
||||
m_extruderImage[select_index]->setExtruderCount(m_nozzle_num);
|
||||
|
||||
assert(obj->m_extder_data.extders.size() > 1);
|
||||
@ -2826,6 +2824,21 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
|
||||
m_extruderImage[select_index]->setExtruderUsed("left");
|
||||
m_nozzle_btn_panel->updateState("left");
|
||||
}
|
||||
|
||||
targ_nozzle_id_from_pc = INVALID_NOZZLE_ID;// the switching is finished
|
||||
obj->flag_update_nozzle = false;
|
||||
}
|
||||
|
||||
/*enable status*/
|
||||
if (obj->is_in_printing() ||
|
||||
obj->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE ||
|
||||
targ_nozzle_id_from_pc != INVALID_NOZZLE_ID)
|
||||
{
|
||||
m_nozzle_btn_panel->Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nozzle_btn_panel->Enable();
|
||||
}
|
||||
} else {
|
||||
m_nozzle_btn_panel->Hide();
|
||||
@ -4653,9 +4666,15 @@ void StatusPanel::on_nozzle_selected(wxCommandEvent &event)
|
||||
return;
|
||||
}
|
||||
|
||||
obj->flag_update_nozzle = false;
|
||||
auto nozzle_id = event.GetInt();obj->command_select_extruder(nozzle_id);
|
||||
auto nozzle_id = event.GetInt();
|
||||
if(obj->command_select_extruder(nozzle_id) == 0)
|
||||
{
|
||||
targ_nozzle_id_from_pc = nozzle_id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_nozzle_btn_panel->Enable();
|
||||
}
|
||||
|
||||
void StatusPanel::on_show_print_options(wxCommandEvent& event)
|
||||
|
@ -407,6 +407,9 @@ protected:
|
||||
Button * m_button_clean;
|
||||
wxSimplebook* m_extruder_book;
|
||||
std::vector<ExtruderImage *> m_extruderImage;
|
||||
|
||||
/*the target nozzle id from PC-SwitchBoard, default to INVALID_NOZZLE_ID if not switching*/
|
||||
int targ_nozzle_id_from_pc = INVALID_NOZZLE_ID;
|
||||
SwitchBoard * m_nozzle_btn_panel;
|
||||
|
||||
wxStaticText * m_text_tasklist_caption;
|
||||
|
@ -235,7 +235,7 @@ void SwitchBoard::doRender(wxDC &dc)
|
||||
|
||||
/*left*/
|
||||
if (switch_left) {
|
||||
dc.SetBrush(wxBrush(wxColour(0, 174, 66)));
|
||||
is_enable ? dc.SetBrush(wxBrush(wxColour(0, 174, 66))) : dc.SetBrush(disable_color);
|
||||
dc.DrawRoundedRectangle(0, 0, GetSize().x / 2, GetSize().y, 8);
|
||||
}
|
||||
|
||||
@ -285,9 +285,36 @@ void SwitchBoard::on_left_down(wxMouseEvent &evt)
|
||||
switch_right = true;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (auto_disable_when_switch)
|
||||
{
|
||||
is_enable = false;// make it disable while switching
|
||||
}
|
||||
Refresh();
|
||||
|
||||
wxCommandEvent event(wxCUSTOMEVT_SELECT_NOZZLE_POS);
|
||||
event.SetInt(index);
|
||||
wxPostEvent(this, event);
|
||||
}
|
||||
|
||||
void SwitchBoard::Enable()
|
||||
{
|
||||
if (is_enable == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
is_enable = true;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void SwitchBoard::Disable()
|
||||
{
|
||||
if (is_enable == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
is_enable = false;
|
||||
Refresh();
|
||||
}
|
@ -58,13 +58,20 @@ public:
|
||||
bool is_enable {true};
|
||||
|
||||
public:
|
||||
void paintEvent(wxPaintEvent &evt);
|
||||
void render(wxDC &dc);
|
||||
void doRender(wxDC &dc);
|
||||
void on_left_down(wxMouseEvent &evt);
|
||||
void Enable(){is_enable = true;Refresh();};
|
||||
void Disable(){is_enable = false;Refresh();};
|
||||
void Enable();
|
||||
void Disable();
|
||||
bool IsEnabled(){return is_enable;};
|
||||
|
||||
void SetAutoDisableWhenSwitch() { auto_disable_when_switch = true; };
|
||||
|
||||
protected:
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
void on_left_down(wxMouseEvent& evt);
|
||||
|
||||
private:
|
||||
bool auto_disable_when_switch = false;
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_SwitchButton_hpp_
|
||||
|
Loading…
x
Reference in New Issue
Block a user