NEW: new fan ctrl

JIRA: none

Change-Id: I4e84d455fa728dffb00706f4c07310fcd1b8335c
(cherry picked from commit 0a739fe087933cc89af541817315c7a3d6096b22)
This commit is contained in:
Kunlong Ma
2024-12-06 15:23:28 +08:00
committed by Noisyfox
parent de0ad1b642
commit 2bbb99eadf
11 changed files with 912 additions and 526 deletions

View File

@@ -1815,40 +1815,17 @@ int MachineObject::command_go_home2()
}
// Old protocol
int MachineObject::command_control_fan(FanType fan_type, bool on_off)
{
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (on_off ? 255 : 0)).str();
return this->publish_gcode(gcode);
}
// Old protocol
int MachineObject::command_control_fan_val(FanType fan_type, int val)
int MachineObject::command_control_fan(int fan_type, int val)
{
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (val)).str();
return this->publish_gcode(gcode);
}
// New protocol
int MachineObject::command_control_fan(int fan_id, bool on_off)
{
BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(switch on/of status), fan_id = " << fan_id;
json j;
j["print"]["command"] = "set_fan";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["fan_index"] = fan_id;
// wait add, set on or off
j["print"]["speed"] = 50;
BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_fan, command info need to update, to set on or off status.";
return this->publish_json(j.dump());
}
// New protocol
int MachineObject::command_control_fan_val(int fan_id, int val)
int MachineObject::command_control_fan_new(int fan_id, int val, const CommandCallBack &cb)
{
BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(set speed), fan_id = " << fan_id;
m_callback_list[std::to_string(m_sequence_id)] = cb;
json j;
j["print"]["command"] = "set_fan";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
@@ -1859,6 +1836,17 @@ int MachineObject::command_control_fan_val(int fan_id, int val)
return this->publish_json(j.dump());
}
int MachineObject::command_control_air_duct(int mode_id, const CommandCallBack &cb)
{
BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_air_duct, set air duct, d = " << mode_id;
m_callback_list[std::to_string(m_sequence_id)] = cb;
json j;
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["command"] = "set_airduct";
j["print"]["modeId"] = mode_id;
return this->publish_json(j.dump());
}
int MachineObject::command_task_abort()
{
@@ -3671,7 +3659,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
big_fan2_speed = 0;
}
}
converse_to_duct();
if (jj.contains("heatbreak_fan_speed")) {
heatbreak_fan_speed = stoi(jj["heatbreak_fan_speed"].get<std::string>());
}
@@ -3693,35 +3681,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
//new fan data
if (jj.contains("airduct")) {
m_air_duct_data.airducts.clear();
m_air_duct_data.curren_duct = jj["airduct"]["cur"].get<int>();
m_air_duct_data.ducts_ctrl.push_back(jj["airduct"]["ctrl"].get<int>());
for (auto it_airduct = jj["airduct"]["info"].begin(); it_airduct != jj["airduct"]["info"].end(); it_airduct++) {
AirDuct air_duct;
air_duct.airduct_id = (*it_airduct)["id"].get<int>();
air_duct.fans_ctrl.push_back((*it_airduct)["ctrl"].get<int>());
for (auto it_fan = (*it_airduct)["info"].begin(); it_fan != (*it_airduct)["info"].end(); it_airduct++) {
AirDuctFan fan;
fan.use_new_protocol = true;
auto type = (*it_fan)["type"].get<unsigned>();
fan.id = std::log2(type >> 4);
if (type & 0x01) fan.type = AIR_DOOR_TYPE;
else if (type & 0x10) fan.type = AIR_FAN_TYPE;
fan.func = (*it_fan)["func"].get<int>();
unsigned speed = (*it_fan)["speed"].get<unsigned>();
fan.current_speed = (speed) & 0xFFFF;
fan.target_speed = (speed >> 16) & 0xFFFF;
air_duct.fans_list.push_back(fan);
}
m_air_duct_data.airducts.push_back(air_duct);
}
BOOST_LOG_TRIVIAL(trace) << "New protocol of fans, dir duct num = " << m_air_duct_data.airducts.size();
}
try {
if (jj.contains("stg")) {
stage_list_info.clear();
@@ -5033,6 +4992,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
} catch (...) {}
}
}
command_handle_response(jj);
}
}
@@ -5447,14 +5407,14 @@ bool MachineObject::is_firmware_info_valid()
return m_firmware_valid;
}
std::string MachineObject::get_string_from_fantype(FanType type)
std::string MachineObject::get_string_from_fantype(int type)
{
switch (type) {
case FanType::COOLING_FAN:
case 1:
return "cooling_fan";
case FanType::BIG_COOLING_FAN:
case 2:
return "big_cooling_fan";
case FanType::CHAMBER_FAN:
case 3:
return "chamber_fan";
default:
return "";
@@ -5462,32 +5422,45 @@ std::string MachineObject::get_string_from_fantype(FanType type)
return "";
}
void MachineObject::converse_to_duct() {
AirDuct duct;
duct.airduct_id = -1;
AirDuctFan part_fan;
part_fan.type = AIR_FAN_TYPE;
part_fan.id = 1;
part_fan.func = int(FAN_func_e::FAN_FUNC_PART_COOLING);
part_fan.current_speed = cooling_fan_speed;
duct.fans_list.push_back(part_fan);
void MachineObject::converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun)
{
m_air_duct_data.modes.clear();
m_air_duct_data.parts.clear();
m_air_duct_data.curren_mode = -1; //def mode
AirDuctFan aux_fan;
aux_fan.type = AIR_FAN_TYPE;
aux_fan.id = 2;
aux_fan.func = int(FAN_func_e::FAN_FUNC_AUX_COOLING);
aux_fan.current_speed = big_fan1_speed;
duct.fans_list.push_back(aux_fan);
AirDuctFan chamber_fan;
chamber_fan.type = AIR_FAN_TYPE;
chamber_fan.id = 3;
chamber_fan.func = int(FAN_func_e::FAN_FUNC_EXHAUST);
chamber_fan.current_speed = cooling_fan_speed;
duct.fans_list.push_back(chamber_fan);
this->m_air_duct_data.airducts.clear();
this->m_air_duct_data.airducts.push_back(duct);
this->m_air_duct_data.curren_duct = -1;
if (is_suppt_part_fun) {
AirParts part_fan;
part_fan.type = int(AirDuctType::AIR_FAN_TYPE);
part_fan.id = int(AIR_FUN::FAN_COOLING_0_AIRDOOR);
part_fan.func = int(AIR_FUN::FAN_COOLING_0_AIRDOOR);
part_fan.state = 0;
part_fan.range_start = 0;
part_fan.range_end = 100;
m_air_duct_data.parts.push_back(part_fan);
}
if (is_suppt_aux_fun) {
AirParts aux_fan;
aux_fan.type = int(AirDuctType::AIR_FAN_TYPE);
aux_fan.id = int(AIR_FUN::FAN_REMOTE_COOLING_0_IDX);
aux_fan.func = int(AIR_FUN::FAN_REMOTE_COOLING_0_IDX);
aux_fan.state = 0;
aux_fan.range_start = 0;
aux_fan.range_end = 100;
m_air_duct_data.parts.push_back(aux_fan);
}
if (is_suppt_aux_fun) {
AirParts chamber_fan;
chamber_fan.type = int(AirDuctType::AIR_FAN_TYPE);
chamber_fan.id = int(AIR_FUN::FAN_CHAMBER_0_IDX);
chamber_fan.func = int(AIR_FUN::FAN_CHAMBER_0_IDX);
chamber_fan.state = 0;
chamber_fan.range_start = 0;
chamber_fan.range_end = 100;
m_air_duct_data.parts.push_back(chamber_fan);
}
}
AmsTray MachineObject::parse_vt_tray(json vtray)
@@ -5740,6 +5713,46 @@ void MachineObject::parse_new_info(json print)
if (print.contains("device")) {
json const& device = print["device"];
//new fan data
if (device.contains("airduct")) {
m_air_duct_data.curren_mode = -1;
m_air_duct_data.modes.clear();
m_air_duct_data.parts.clear();
m_air_duct_data.curren_mode = device["airduct"]["modeCur"].get<int>();
for (auto it_mode = device["airduct"]["modeList"].begin(); it_mode != device["airduct"]["modeList"].end(); it_mode++) {
AirMode mode;
mode.id = (*it_mode)["modeId"].get<int>();
for (auto it_mode_ctrl = (*it_mode)["ctrl"].begin(); it_mode_ctrl != (*it_mode)["ctrl"].end(); it_mode_ctrl++) {
mode.ctrl.push_back((*it_mode_ctrl).get<int>() >> 4);
}
for (auto it_mode_off = (*it_mode)["off"].begin(); it_mode_off != (*it_mode)["off"].begin(); *it_mode_off++) {
mode.off.push_back((*it_mode_off).get<int>() >> 4);
}
m_air_duct_data.modes.push_back(mode);
}
for (auto it_part = device["airduct"]["parts"].begin(); it_part != device["airduct"]["parts"].end(); it_part++) {
int state = (*it_part)["state"].get<int>();
int range = (*it_part)["range"].get<int>();
AirParts part;
part.type = get_flag_bits((*it_part)["id"].get<int>(), 0, 3);
part.id = get_flag_bits((*it_part)["id"].get<int>(), 4, 12);
part.func = (*it_part)["func"].get<int>();
part.state = get_flag_bits(state, 0, 8);
part.range_start = get_flag_bits(range, 0, 15);
part.range_end = get_flag_bits(range, 16, 15);
m_air_duct_data.parts.push_back(part);
}
}
if (device.contains("type")) {
int type = device["type"]; //FDM:1<<0 Laser:1<< Cut:1<<2
}
@@ -6197,6 +6210,23 @@ void MachineObject::check_ams_filament_valid()
}
}
int MachineObject::command_handle_response(const json &response)
{
if (!response.contains("sequence_id")) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ", error reponse.";
return -1;
}
std::string reply = response["sequence_id"].get<std::string>();
auto it = m_callback_list.find(reply);
if (it != m_callback_list.end()) {
it->second(response);
m_callback_list.erase(it);
}
return 0;
}
bool DeviceManager::EnableMultiMachine = false;
bool DeviceManager::key_field_only = false;

View File

@@ -230,29 +230,30 @@ struct ExtderData
std::vector<Extder> extders;
};
struct AirDuctFan
struct AirMode
{
//Fan and door may use the same mode_id, but they are different, they need to be distinguished by the m_type field
AirDuctType type; //Type of part, fan or door
bool use_new_protocol{ false };
int id; //the id of fan or air door
int func{ 0 }; //UI display, fan or door
int current_speed{0};
int target_speed{0};
int id{-1};
std::vector<int> ctrl;
// If the fan is off, it cannot be controlled and is displayed as off
std::vector<int> off;
// If the fan is not off or ctrl, it will be displayed as auto
};
struct AirDuct
struct AirParts
{
int airduct_id{ 0 }; //Determine the UI display content, click radonbutton to switch
std::vector<bool> fans_ctrl; //Control status of each (fan) / (air door)
std::vector<AirDuctFan> fans_list; //Fan or air door s
int type{ 0 };
int id{ 0 };
int func{ 0 };
int state{ 0 };// 100%
int range_start{ 0 };// 100%
int range_end{ 0 };// 100%
};
struct AirDuctData
{
int curren_duct{0};
std::vector<bool> ducts_ctrl; //Control status of each duct
std::vector<AirDuct> airducts;
int curren_mode{ 0 };
std::vector<AirMode> modes;
std::vector<AirParts> parts;
};
struct RatingInfo {
@@ -420,21 +421,24 @@ enum HMSMessageLevel {
};
enum FAN_func_e {
FAN_FUNC_PART_COOLING = 0,
FAN_FUNC_AUX_COOLING,
FAN_FUNC_EXHAUST,
FAN_FUNC_FILTER,
FAN_FUNC_HEATING
enum AIR_FUN {
FAN_HEAT_BREAK_0_IDX = 0,
FAN_COOLING_0_AIRDOOR = 1,
FAN_REMOTE_COOLING_0_IDX = 2,
FAN_CHAMBER_0_IDX = 3,
FAN_HEAT_BREAK_1_IDX = 4,
FAN_MC_BOARD_0_IDX = 5,
FAN_INNNER_LOOP_FAN_0_IDX = 6,
FAN_TOTAL_COUNT = 7
};
enum AIR_DOOR_func_e {
enum AIR_DOOR {
AIR_DOOR_FUNC_CHAMBER = 0,
AIR_DOOR_FUNC_INNERLOOP,
AIR_DOOR_FUNC_TOP
};
enum AIR_DUCT_mode_e {
enum AIR_DUCT {
AIR_DUCT_NONE = -1,
AIR_DUCT_COOLING_FILT = 0,
AIR_DUCT_HEATING_INTERNAL_FILT,
@@ -491,9 +495,10 @@ private:
// type, time stamp, delay
std::vector<std::tuple<std::string, uint64_t, uint64_t>> message_delay;
public:
typedef std::function<void(const json &)> CommandCallBack;
enum LIGHT_EFFECT {
LIGHT_EFFECT_ON,
LIGHT_EFFECT_OFF,
@@ -738,7 +743,7 @@ public:
//new fan data
AirDuctData m_air_duct_data;
void converse_to_duct(); //Convert the data to duct type to make the newand old protocols consistent
void converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun); // Convert the data to duct type to make the newand old protocols consistent
/* signals */
std::string wifi_signal;
@@ -1001,6 +1006,9 @@ public:
boost::thread* get_slice_info_thread { nullptr };
boost::thread* get_model_task_thread { nullptr };
/* key: sequence id, value: callback */
std::map<std::string, CommandCallBack> m_callback_list;
bool is_makeworld_subtask();
@@ -1052,10 +1060,9 @@ public:
int command_auto_leveling();
int command_go_home();
int command_go_home2();
int command_control_fan(FanType fan_type, bool on_off); //Old protocol
int command_control_fan_val(FanType fan_type, int val); //Old protocol
int command_control_fan(int fan_id, bool on_off); //New protocol
int command_control_fan_val(int fan_id, int val); //New protocol
int command_control_fan(int fan_type, int val); // Old protocol
int command_control_fan_new(int fan_id, int val, const CommandCallBack &cb); // New protocol
int command_control_air_duct(int mode_id, const CommandCallBack& cb);
int command_task_abort();
/* cancelled the job_id */
int command_task_cancel(std::string job_id);
@@ -1177,7 +1184,7 @@ public:
bool m_firmware_thread_started { false };
void get_firmware_info();
bool is_firmware_info_valid();
std::string get_string_from_fantype(FanType type);
std::string get_string_from_fantype(int type);
/*for more extruder*/
bool is_enable_np{ false };
@@ -1208,6 +1215,7 @@ public:
void update_printer_preset_name();
void check_ams_filament_valid();
int command_handle_response(const json &response);
};
class DeviceManager

View File

@@ -131,26 +131,25 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
/*mode switch*/
/* auto m_sizer_mode_switch = new wxBoxSizer(wxHORIZONTAL);
/*auto m_sizer_mode_switch = new wxBoxSizer(wxHORIZONTAL);
m_mode_print = new SendModeSwitchButton(this, _L("Print"), true);
m_mode_send = new SendModeSwitchButton(this,_L("Save to printer"), false);
m_sizer_mode_switch->Add(m_mode_print, 0, wxALIGN_CENTER, 0);
m_sizer_mode_switch->Add(0, 0, 0, wxLEFT, FromDIP(8));
m_sizer_mode_switch->Add(m_mode_send,0, wxALIGN_CENTER, 0);*/
m_sizer_mode_switch->Add(m_mode_send,0, wxALIGN_CENTER, 0);
//m_mode_print->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
// m_mode_print->setSelected(true);
// m_mode_send->setSelected(false);
// e.Skip();
//});
m_mode_print->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
m_mode_print->setSelected(true);
m_mode_send->setSelected(false);
e.Skip();
});
//m_mode_send->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
// m_mode_print->setSelected(false);
// m_mode_send->setSelected(true);
// e.Skip();
//});
m_mode_send->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
m_mode_print->setSelected(false);
m_mode_send->setSelected(true);
e.Skip();
});*/
m_basic_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_basic_panel->SetBackgroundColour(*wxWHITE);

View File

@@ -331,7 +331,6 @@ void ExtruderImage::doRender(wxDC& dc)
dc.DrawBitmap(right_nozzle_bmp->bmp(), pot.x, pot.y + right_pipe_bmp->GetBmpSize().y);
}
else{
ScalableBitmap* nozzle_bmp;
switch (m_single_ext_state)
{
case Slic3r::GUI::FILLED_LOAD: m_extruder_single_nozzle_filled_load; break;
@@ -1419,8 +1418,8 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
auto sizer = new wxBoxSizer(wxVERTICAL);
wxWindowID nozzle_id = wxWindow::NewControlId();
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"),
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_MAIN_NOZZLE_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"),
wxString("monitor_nozzle_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE);
m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]);
m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]);
@@ -1523,10 +1522,10 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
m_switch_lamp->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
line_sizer->Add(m_switch_lamp, 1, wxALIGN_CENTER | wxALL, 0);
/*sizer->Add(line_sizer, 0, wxEXPAND, FromDIP(5));
//sizer->Add(line_sizer, 0, wxEXPAND, FromDIP(5));
line = new StaticLine(parent);
line->SetLineColour(STATIC_BOX_LINE_COL);
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);*/
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
m_fan_panel = new StaticBox(parent);
m_fan_panel->SetMinSize(MISC_BUTTON_PANEL_SIZE);
@@ -1536,6 +1535,7 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
m_fan_panel->SetCornerRadius(0);
auto fan_line_sizer = new wxBoxSizer(wxHORIZONTAL);
/*
m_switch_nozzle_fan = new FanSwitchButton(m_fan_panel, m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
@@ -1588,20 +1588,33 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int)StateColor::Normal)));
m_switch_cham_fan->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {
m_fan_panel->SetBackgroundColor(wxColour(0, 150, 136));
m_fan_panel->SetBackgroundColor(wxColour(0, 174, 66));
});
m_switch_cham_fan->Bind(wxEVT_LEAVE_WINDOW, [this, parent](auto& e) {
m_fan_panel->SetBackgroundColor(parent->GetBackgroundColour());
});
*/
m_switch_fan = new FanSwitchButton(m_fan_panel, m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_fan->SetValue(false);
m_switch_fan->SetMinSize(MISC_BUTTON_1FAN_SIZE);
m_switch_fan->SetMaxSize(MISC_BUTTON_1FAN_SIZE);
m_switch_fan->SetPadding(FromDIP(1));
m_switch_fan->SetBorderWidth(0);
m_switch_fan->SetCornerRadius(0);
m_switch_fan->SetFont(::Label::Body_10);
m_switch_fan->SetTextColor(
StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int)StateColor::Normal)));
m_switch_fan->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {
m_fan_panel->SetBackgroundColor(wxColour(0, 150, 136));
});
fan_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(2));
fan_line_sizer->Add(m_switch_nozzle_fan, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM , FromDIP(2));
fan_line_sizer->Add(m_switch_printing_fan, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, FromDIP(2));
fan_line_sizer->Add(m_switch_cham_fan, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM , FromDIP(2));
//fan_line_sizer->Add(m_switch_block_fan, 1, wxEXPAND | wxTOP | wxBOTTOM , FromDIP(2));
fan_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(2));
m_switch_fan->Bind(wxEVT_LEAVE_WINDOW, [this, parent](auto& e) {
m_fan_panel->SetBackgroundColor(parent->GetBackgroundColour());
});
fan_line_sizer->Add(m_switch_fan, 1, wxEXPAND|wxALL, FromDIP(2));
m_fan_panel->SetSizer(fan_line_sizer);
m_fan_panel->Layout();
@@ -1639,9 +1652,9 @@ void StatusBasePanel::reset_temp_misc_control()
m_switch_speed->SetValue(false);
m_switch_lamp->SetLabels(_L("Lamp"), _L("Lamp"));
m_switch_lamp->SetValue(false);
m_switch_nozzle_fan->SetValue(false);
/*m_switch_nozzle_fan->SetValue(false);
m_switch_printing_fan->SetValue(false);
m_switch_cham_fan->SetValue(false);
m_switch_cham_fan->SetValue(false);*/
}
wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent)
@@ -1733,6 +1746,84 @@ wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent)
return sizer;
}
//wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent)
//{
// wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
// wxBoxSizer *bSizer_z_ctrl = new wxBoxSizer(wxVERTICAL);
// auto panel = new wxPanel(parent, wxID_ANY);
// panel->SetBackgroundColour(*wxWHITE);
//
// panel->SetSize(wxSize(FromDIP(278), -1));
// panel->SetMinSize(wxSize(FromDIP(278), -1));
// panel->SetMaxSize(wxSize(FromDIP(278), -1));
//
// StateColor z_10_ctrl_bg(std::pair<wxColour, int>(BUTTON_PRESS_COL, StateColor::Pressed), std::pair<wxColour, int>(BUTTON_NORMAL1_COL, StateColor::Normal));
// StateColor z_10_ctrl_bd(std::pair<wxColour, int>(BUTTON_HOVER_COL, StateColor::Hovered), std::pair<wxColour, int>(BUTTON_NORMAL1_COL, StateColor::Normal));
//
// StateColor z_1_ctrl_bg(std::pair<wxColour, int>(BUTTON_PRESS_COL, StateColor::Pressed), std::pair<wxColour, int>(BUTTON_NORMAL2_COL, StateColor::Normal));
// StateColor z_1_ctrl_bd(std::pair<wxColour, int>(BUTTON_HOVER_COL, StateColor::Hovered), std::pair<wxColour, int>(BUTTON_NORMAL2_COL, StateColor::Normal));
//
// bSizer_z_ctrl->AddStretchSpacer();
// m_bpButton_z_10 = new Button(panel, wxString("10"), "monitor_bed_up", 0, FromDIP(15));
// m_bpButton_z_10->SetFont(::Label::Body_13);
// m_bpButton_z_10->SetBorderWidth(2);
// m_bpButton_z_10->SetBackgroundColor(z_10_ctrl_bg);
// m_bpButton_z_10->SetBorderColor(z_10_ctrl_bd);
// m_bpButton_z_10->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
// m_bpButton_z_10->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_10->SetCornerRadius(0);
//
// bSizer_z_ctrl->Add(m_bpButton_z_10, 0, wxEXPAND | wxALL, 0);
//
// m_bpButton_z_1 = new Button(panel, wxString(" 1"), "monitor_bed_up", 0, FromDIP(15));
// m_bpButton_z_1->SetFont(::Label::Body_13);
// m_bpButton_z_1->SetBorderWidth(2);
// m_bpButton_z_1->SetBackgroundColor(z_1_ctrl_bg);
// m_bpButton_z_1->SetBorderColor(z_1_ctrl_bd);
// m_bpButton_z_1->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_1->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
//
// bSizer_z_ctrl->Add(m_bpButton_z_1, 0, wxEXPAND | wxALL, 0);
// //bSizer_z_ctrl->Add(0, FromDIP(6), 0, wxEXPAND, 0);
//
// m_staticText_z_tip = new wxStaticText(panel, wxID_ANY, _L("Bed"), wxDefaultPosition, wxDefaultSize, 0);
// m_staticText_z_tip->SetFont(::Label::Body_13);
// if (wxGetApp().app_config->get("language") == "de_DE") m_staticText_z_tip->SetFont(::Label::Body_11);
// m_staticText_z_tip->Wrap(-1);
// m_staticText_z_tip->SetForegroundColour(TEXT_LIGHT_FONT_COL);
// bSizer_z_ctrl->Add(m_staticText_z_tip, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(5));
//
// m_bpButton_z_down_1 = new Button(panel, wxString(" 1"), "monitor_bed_down", 0, FromDIP(15));
// m_bpButton_z_down_1->SetFont(::Label::Body_13);
// m_bpButton_z_down_1->SetBorderWidth(2);
// m_bpButton_z_down_1->SetBackgroundColor(z_1_ctrl_bg);
// m_bpButton_z_down_1->SetBorderColor(z_1_ctrl_bd);
// m_bpButton_z_down_1->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_down_1->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
// bSizer_z_ctrl->Add(m_bpButton_z_down_1, 0, wxEXPAND | wxALL, 0);
//
// m_bpButton_z_down_10 = new Button(panel, wxString("10"), "monitor_bed_down", 0, FromDIP(15));
// m_bpButton_z_down_10->SetFont(::Label::Body_13);
// m_bpButton_z_down_10->SetBorderWidth(2);
// m_bpButton_z_down_10->SetBackgroundColor(z_10_ctrl_bg);
// m_bpButton_z_down_10->SetBorderColor(z_10_ctrl_bd);
// m_bpButton_z_down_10->SetMinSize(Z_BUTTON_SIZE);
// m_bpButton_z_down_10->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int)StateColor::Normal)));
//
// bSizer_z_ctrl->Add(m_bpButton_z_down_10, 0, wxEXPAND | wxALL, 0);
// bSizer_z_ctrl->Add(0, FromDIP(16), 0, wxEXPAND, 0);
//
// /*panel->SetSizer(bSizer_z_ctrl);
// panel->Layout();
// sizer->Add(panel, 1, wxEXPAND, 0);*/
// /*m_staticText_xy = new wxStaticText(parent, wxID_ANY, _L("X/Y Axis"), wxDefaultPosition, wxDefaultSize, 0);
// m_staticText_xy->Wrap(-1);
//
// m_staticText_xy->SetForegroundColour(TEXT_LIGHT_FONT_COL);
// sizer->Add(m_staticText_xy, 0, wxBOTTOM | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));*/
// return sizer;
//}
wxPanel *StatusBasePanel::create_bed_control(wxWindow *parent)
{
wxBoxSizer *bSizer_z_ctrl = new wxBoxSizer(wxHORIZONTAL);
@@ -2079,7 +2170,6 @@ void StatusPanel::update_camera_state(MachineObject* obj)
StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name)
: StatusBasePanel(parent, id, pos, size, style)
, m_fan_control_popup(new FanControlPopup(this))
{
init_scaled_buttons();
m_buttons.push_back(m_bpButton_z_10);
@@ -2094,9 +2184,9 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
m_score_data->rating_id = -1;
/* set default values */
m_switch_lamp->SetValue(false);
m_switch_printing_fan->SetValue(false);
/*m_switch_printing_fan->SetValue(false);
m_switch_nozzle_fan->SetValue(false);
m_switch_cham_fan->SetValue(false);
m_switch_cham_fan->SetValue(false);*/
//m_switch_fan->SetValue(false);
/* set default enable state */
@@ -2139,11 +2229,11 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
m_tempCtrl_chamber->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_cham_temp_kill_focus), NULL, this);
m_tempCtrl_chamber->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_cham_temp_set_focus), NULL, this);
m_switch_lamp->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this);
m_switch_nozzle_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
m_switch_printing_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_cham_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_nozzle_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
//m_switch_printing_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_cham_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
//m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
@@ -2202,13 +2292,13 @@ StatusPanel::~StatusPanel()
m_tempCtrl_nozzle->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_kill_focus), NULL, this);
m_tempCtrl_nozzle->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this);
m_switch_lamp->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this);
m_switch_nozzle_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
/*m_switch_nozzle_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_printing_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_cham_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_cham_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);*/
//m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
//m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_switch_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
m_bpButton_xy->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_xy), NULL, this);
m_bpButton_z_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_10), NULL, this);
@@ -2696,11 +2786,11 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
} else {
m_switch_speed->Enable();
m_switch_lamp->Enable();
m_switch_nozzle_fan->Enable();
/*m_switch_nozzle_fan->Enable();
m_switch_printing_fan->Enable();
m_switch_cham_fan->Enable();
m_switch_cham_fan->Enable();*/
//m_switch_fan->Enable();
m_switch_fan->Enable();
m_bpButton_xy->Enable();
m_bpButton_z_10->Enable();
@@ -2730,10 +2820,10 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
m_switch_speed->Enable(false);
m_switch_speed->SetValue(false);
m_switch_lamp->Enable(false);
m_switch_nozzle_fan->Enable(false);
/*m_switch_nozzle_fan->Enable(false);
m_switch_printing_fan->Enable(false);
m_switch_cham_fan->Enable(false);
//m_switch_fan->Enable(false);
m_switch_cham_fan->Enable(false);*/
m_switch_fan->Enable(false);
} else {
m_tempCtrl_nozzle->Enable();
m_tempCtrl_nozzle_deputy->Enable();
@@ -2742,10 +2832,10 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
m_switch_speed->Enable();
m_switch_speed->SetValue(true);
m_switch_lamp->Enable();
m_switch_nozzle_fan->Enable();
/*m_switch_nozzle_fan->Enable();
m_switch_printing_fan->Enable();
m_switch_cham_fan->Enable();
//m_switch_fan->Enable();
m_switch_cham_fan->Enable();*/
m_switch_fan->Enable();
}
}
@@ -2887,91 +2977,15 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
// update extruder icon
update_extruder_status(obj);
bool is_suppt_part_fun = true;
bool is_suppt_aux_fun = obj->is_support_aux_fan;
bool is_suppt_cham_fun = obj->is_support_chamber_fan;
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(obj);
}
//update cham fan
if (m_current_support_cham_fan != is_suppt_cham_fun) {
if (is_suppt_cham_fun) {
m_switch_cham_fan->Show();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
m_switch_printing_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
}
else {
m_switch_cham_fan->Hide();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
m_switch_printing_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
}
m_misc_ctrl_sizer->Layout();
}
if (m_current_support_aux_fan != is_suppt_aux_fun) {
if (is_suppt_aux_fun) {
m_switch_printing_fan->Show();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
}
else {
m_switch_printing_fan->Hide();
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
}
m_misc_ctrl_sizer->Layout();
}
if (!is_suppt_aux_fun && !is_suppt_cham_fun) {
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_1FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_1FAN_SIZE);
m_misc_ctrl_sizer->Layout();
}
// nozzle fan
if (m_switch_nozzle_fan_timeout > 0) {
m_switch_nozzle_fan_timeout--;
} else{
int speed = round(obj->cooling_fan_speed / float(25.5));
m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
m_switch_nozzle_fan->setFanValue(speed * 10);
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(MachineObject::FanType::COOLING_FAN, obj);
}
}
// printing fan
if (m_switch_printing_fan_timeout > 0) {
m_switch_printing_fan_timeout--;
}else{
int speed = round(obj->big_fan1_speed / float(25.5));
m_switch_printing_fan->SetValue(speed > 0 ? true : false);
m_switch_printing_fan->setFanValue(speed * 10);
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(MachineObject::FanType::BIG_COOLING_FAN, obj);
}
}
// cham fan
if (m_switch_cham_fan_timeout > 0) {
m_switch_cham_fan_timeout--;
}else{
int speed = round(obj->big_fan2_speed / float(25.5));
m_switch_cham_fan->SetValue(speed > 0 ? true : false);
m_switch_cham_fan->setFanValue(speed * 10);
if (m_fan_control_popup) {
m_fan_control_popup->update_fan_data(MachineObject::FanType::CHAMBER_FAN, obj);
}
}
/*other*/
bool light_on = obj->chamber_light != MachineObject::LIGHT_EFFECT::LIGHT_EFFECT_OFF;
BOOST_LOG_TRIVIAL(trace) << "light: " << (light_on ? "on" : "off");
if (m_switch_lamp_timeout > 0)
@@ -2990,16 +3004,14 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
wxString text_speed = wxString::Format("%d%%", obj->printing_speed_mag);
m_switch_speed->SetLabels(text_speed, text_speed);
}
m_current_support_aux_fan = is_suppt_aux_fun;
m_current_support_cham_fan = is_suppt_cham_fun;
}
void StatusPanel::update_extruder_status(MachineObject* obj)
{
if (!obj) return;
wxBitmap tmp;
if (obj->is_filament_at_extruder()) {
//wait add
/*if (obj->is_filament_at_extruder()) {
if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) {
tmp = m_bitmap_extruder_filled_load;
}
@@ -3009,17 +3021,11 @@ void StatusPanel::update_extruder_status(MachineObject* obj)
}
else {
if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) {
tmp = m_bitmap_extruder_empty_load;
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_load);
} else {
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_unload);
}
else {
tmp = m_bitmap_extruder_empty_unload;
}
}
if (!tmp.IsSameAs(m_bitmap_extruder_now)) {
m_bitmap_extruder_now = tmp;
//m_bitmap_extruder_img->SetBitmap(tmp);
}
}*/
}
void StatusPanel::update_ams(MachineObject *obj)
@@ -4517,23 +4523,23 @@ void StatusPanel::on_fan_changed(wxCommandEvent& event)
{
auto type = event.GetInt();
auto speed = atoi(event.GetString().c_str());
//set_hold_count(this->m_switch_cham_fan_timeout);
//return;
set_hold_count(this->m_switch_cham_fan_timeout);
return;
if (type == MachineObject::FanType::COOLING_FAN) {
set_hold_count(this->m_switch_nozzle_fan_timeout);
m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
m_switch_nozzle_fan->setFanValue(speed * 10);
/*m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
m_switch_nozzle_fan->setFanValue(speed * 10);*/
}
else if (type == MachineObject::FanType::BIG_COOLING_FAN) {
set_hold_count(this->m_switch_printing_fan_timeout);
m_switch_printing_fan->SetValue(speed > 0 ? true : false);
m_switch_printing_fan->setFanValue(speed * 10);
/*m_switch_printing_fan->SetValue(speed > 0 ? true : false);
m_switch_printing_fan->setFanValue(speed * 10);*/
}
else if (type == MachineObject::FanType::CHAMBER_FAN) {
set_hold_count(this->m_switch_cham_fan_timeout);
m_switch_cham_fan->SetValue(speed > 0 ? true : false);
m_switch_cham_fan->setFanValue(speed * 10);
/*m_switch_cham_fan->SetValue(speed > 0 ? true : false);
m_switch_cham_fan->setFanValue(speed * 10);*/
}
}
@@ -4662,29 +4668,35 @@ void StatusPanel::on_printing_fan_switch(wxCommandEvent &event)
void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event)
{
m_fan_control_popup->Destroy();
m_fan_control_popup = nullptr;
m_fan_control_popup = new FanControlPopup(this);
if (obj) {
m_fan_control_popup->show_cham_fan(obj->is_support_chamber_fan);
m_fan_control_popup->show_aux_fan(obj->is_support_aux_fan);
if (m_fan_control_popup) {
m_fan_control_popup->Destroy();
m_fan_control_popup = nullptr;
}
if (!obj)
return;
auto pos = m_switch_nozzle_fan->GetScreenPosition();
pos.y = pos.y + m_switch_nozzle_fan->GetSize().y;
if (!obj->is_enable_np)
obj->converse_to_duct(true, obj->is_support_aux_fan, obj->is_support_chamber_fan);
m_fan_control_popup = new FanControlPopupNew(this, obj, obj->m_air_duct_data);
auto pos = m_switch_fan->GetScreenPosition();
pos.y = pos.y + m_switch_fan->GetSize().y;
int display_idx = wxDisplay::GetFromWindow(this);
auto display = wxDisplay(display_idx).GetClientArea();
wxSize screenSize = wxSize(display.GetWidth(), display.GetHeight());
auto fan_popup_size = m_fan_control_popup->GetSize();
wxSize fan_popup_size = m_fan_control_popup->GetSize();
pos.x -= FromDIP(150);
pos.y -= FromDIP(20);
if (screenSize.y - fan_popup_size.y < FromDIP(300)) {
pos.x += FromDIP(50);
pos.y = (screenSize.y - fan_popup_size.y) / 2;
}
m_fan_control_popup->SetPosition(pos);
m_fan_control_popup->Popup();
@@ -5083,12 +5095,15 @@ void StatusPanel::msw_rescale()
m_switch_lamp->SetImages(m_bitmap_lamp_on, m_bitmap_lamp_off);
m_switch_lamp->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_lamp->Rescale();
m_switch_nozzle_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
/*m_switch_nozzle_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_nozzle_fan->Rescale();
m_switch_printing_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_printing_fan->Rescale();
m_switch_cham_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_cham_fan->Rescale();
m_switch_cham_fan->Rescale();*/
m_switch_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
m_switch_fan->Rescale();
//m_switch_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
//m_switch_fan->Rescale();

View File

@@ -416,8 +416,6 @@ protected:
int m_temp_bed_timeout {0};
TempInput * m_tempCtrl_chamber;
int m_temp_chamber_timeout {0};
bool m_current_support_cham_fan{true};
bool m_current_support_aux_fan{true};
FanSwitchButton *m_switch_nozzle_fan;
int m_switch_nozzle_fan_timeout{0};
FanSwitchButton *m_switch_printing_fan;
@@ -560,7 +558,7 @@ protected:
SecondaryCheckDialog* ctrl_e_hint_dlg = nullptr;
SecondaryCheckDialog* sdcard_hint_dlg = nullptr;
FanControlPopup* m_fan_control_popup{nullptr};
FanControlPopupNew* m_fan_control_popup{nullptr};
ExtrusionCalibration *m_extrusion_cali_dlg{nullptr};

View File

@@ -15,6 +15,8 @@ wxDEFINE_EVENT(EVT_FAN_ADD, wxCommandEvent);
wxDEFINE_EVENT(EVT_FAN_DEC, wxCommandEvent);
wxDEFINE_EVENT(EVT_FAN_CHANGED, wxCommandEvent);
constexpr int time_out = 20;
/*************************************************
Description:Fan
**************************************************/
@@ -174,8 +176,8 @@ void FanOperate::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, con
wxWindow::Create(parent, id, pos, size, wxBORDER_NONE);
SetBackgroundColour(*wxWHITE);
m_bitmap_add = ScalableBitmap(this, "fan_control_add", FromDIP(11));
m_bitmap_decrease = ScalableBitmap(this, "fan_control_decrease", FromDIP(11));
m_bitmap_add = ScalableBitmap(this, "fan_control_add", FromDIP(24));
m_bitmap_decrease = ScalableBitmap(this, "fan_control_decrease", FromDIP(24));
SetMinSize(wxSize(FromDIP(SIZE_OF_FAN_OPERATE.x), FromDIP(SIZE_OF_FAN_OPERATE.y)));
Bind(wxEVT_PAINT, &FanOperate::paintEvent, this);
@@ -189,15 +191,15 @@ void FanOperate::on_left_down(wxMouseEvent& event)
auto mouse_pos = ClientToScreen(event.GetPosition());
auto win_pos = ClientToScreen(wxPoint(0, 0));
auto decrease_fir = GetSize().x / 3 + win_pos.x;
auto add_fir = GetSize().x / 3 * 2 + win_pos.x;
auto decrease_fir = FromDIP(24);
auto add_fir = GetSize().x - FromDIP(24);
if (mouse_pos.x > win_pos.x && mouse_pos.x < decrease_fir && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
if (mouse_pos.x > win_pos.x && mouse_pos.x < (decrease_fir + win_pos.x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
decrease_fan_speeds();
return;
}
if (mouse_pos.x > add_fir && mouse_pos.x < (win_pos.x + GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
if (mouse_pos.x > (add_fir + win_pos.x) && mouse_pos.x < (win_pos.x + GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
add_fan_speeds();
return;
}
@@ -277,112 +279,110 @@ void FanOperate::doRender(wxDC& dc)
//splt
auto left_fir = size.x / 3;
dc.DrawLine(left_fir, FromDIP(4), left_fir, size.y - FromDIP(4));
dc.DrawLine(left_fir * 2, FromDIP(4), left_fir * 2, size.y - FromDIP(4));
dc.DrawBitmap(m_bitmap_decrease.bmp(), 0, (size.y - m_bitmap_decrease.GetBmpHeight()) / 2);
dc.DrawBitmap(m_bitmap_add.bmp(), size.x - m_bitmap_add.GetBmpWidth(), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
dc.DrawBitmap(m_bitmap_decrease.bmp(), (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2, (size.y - m_bitmap_decrease.GetBmpSize().y) / 2);
dc.DrawBitmap(m_bitmap_add.bmp(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
wxPoint pot(m_bitmap_decrease.GetBmpWidth(), (size.y - m_bitmap_decrease.GetBmpHeight()) / 2);
dc.DrawLine(pot.x, 0, pot.x, size.y);
dc.DrawLine(size.x - m_bitmap_add.GetBmpWidth(), 0, size.x - m_bitmap_add.GetBmpWidth(), size.y);
//txt
dc.SetFont(::Label::Body_12);
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x898989)));
wxString text = wxString::Format("%d%%", 10);
wxString text = wxString::Format("%d%%", m_current_speeds * 10);
wxSize text_size = dc.GetTextExtent(text);
dc.DrawText(text, wxPoint(left_fir + (left_fir- text_size.x) / 2, (size.y- text_size.y) / 2));
auto text_width = size.x - m_bitmap_decrease.GetBmpWidth() * 2;
dc.DrawText(text, wxPoint(pot.x + (text_width - text_size.x) / 2, (size.y - text_size.y) / 2));
}
void FanOperate::msw_rescale() {
}
/*************************************************
Description:FanControl
static void nop_deleter_fan_control(FanControlNew* ){}
/*************************************************
Description:FanControlNew
**************************************************/
FanControl::FanControl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size)
:wxWindow(parent, id, pos, size)
FanControlNew::FanControlNew(wxWindow *parent, const AirDuctData &fan_data, int mode_id, int part_id, wxWindowID id, const wxPoint &pos, const wxSize &size)
: wxWindow(parent, id, pos, size)
, m_fan_data(fan_data)
, m_mode_id(mode_id)
, m_part_id(part_id)
{
auto m_bitmap_fan = new ScalableBitmap(this, "fan_icon", 18);
m_bitmap_toggle_off = new ScalableBitmap(this, "toggle_off", 14);
m_bitmap_toggle_on = new ScalableBitmap(this, "toggle_on", 14);
SetMaxSize(wxSize(FromDIP(180), FromDIP(80)));
SetMinSize(wxSize(FromDIP(180), FromDIP(80)));
auto m_bitmap_fan = new ScalableBitmap(this, "fan_icon", 20);
m_bitmap_toggle_off = new ScalableBitmap(this, "toggle_off", 16);
m_bitmap_toggle_on = new ScalableBitmap(this, "toggle_on", 16);
SetBackgroundColour(*wxWHITE);
SetBackgroundColour(wxColour(248, 248, 248));
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxHORIZONTAL);
m_fan = new Fan(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_sizer_main->Add(m_fan, 1, wxEXPAND | wxALL, 0);
m_sizer_main->Add(0, 0, 0, wxLEFT, FromDIP(18));
//m_sizer_main->Add(0, 0, 0, wxLEFT, FromDIP(18));
wxBoxSizer* sizer_control = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sizer_control_top = new wxBoxSizer(wxHORIZONTAL);
m_sizer_control_bottom = new wxBoxSizer(wxVERTICAL);
auto m_static_bitmap_fan = new wxStaticBitmap(this, wxID_ANY, m_bitmap_fan->bmp(), wxDefaultPosition, wxDefaultSize);
m_static_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END|wxALIGN_CENTER_HORIZONTAL);
m_static_name->SetForegroundColour(wxColour(DRAW_TEXT_COLOUR));
m_static_name->SetBackgroundColour(*wxWHITE);
m_static_name->SetMinSize(wxSize(FromDIP(50), -1));
m_static_name->SetMaxSize(wxSize(FromDIP(50), -1));
m_static_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END | wxALIGN_CENTER_HORIZONTAL);
m_static_name->SetForegroundColour(wxColour(DRAW_HEAD_TEXT_COLOUR));
m_static_name->SetBackgroundColour(wxColour(248, 248, 248));
m_static_name->SetFont(Label::Head_18);
m_static_name->SetMinSize(wxSize(FromDIP(100), -1));
m_static_name->SetMaxSize(wxSize(FromDIP(100), -1));
m_switch_button = new wxStaticBitmap(this, wxID_ANY, m_bitmap_toggle_off->bmp(), wxDefaultPosition, wxDefaultSize, 0);
m_switch_button->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); });
m_switch_button->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_RIGHT_ARROW); });
m_switch_button->Bind(wxEVT_LEFT_DOWN, &FanControl::on_swith_fan, this);
m_switch_button->Bind(wxEVT_LEFT_DOWN, &FanControlNew::on_swith_fan, this);
sizer_control_top->Add(m_static_bitmap_fan, 0, wxALIGN_CENTER, 5);
sizer_control_top->Add(m_static_name, 0, wxALIGN_CENTER, 0);
sizer_control_top->Add( 0, 0, 1, wxEXPAND, 0 );
sizer_control_top->Add(m_switch_button, 0, wxALIGN_CENTER, 0);
sizer_control_top->Add(m_static_bitmap_fan, 0, wxLEFT | wxTOP, FromDIP(8));
sizer_control_top->Add(m_static_name, 0, wxLEFT | wxTOP, FromDIP(5));
sizer_control_top->Add(0, 0, 1, wxEXPAND, 0);
sizer_control_top->Add(m_switch_button, 0, wxALIGN_RIGHT | wxRIGHT | wxTOP, FromDIP(10));
sizer_control->Add(sizer_control_top, 0, wxEXPAND, 0);
sizer_control->Add(sizer_control_top, 0, wxALIGN_CENTER, 0);
sizer_control->Add(0, 0, 0, wxTOP, FromDIP(15));
m_static_status_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END | wxALIGN_CENTER_HORIZONTAL);
m_static_status_name->SetForegroundColour(wxColour(0x00AE42));
m_static_status_name->SetBackgroundColour(wxColour(248, 248, 248));
m_static_status_name->SetFont(Label::Head_18);
m_static_status_name->SetMinSize(wxSize(FromDIP(100), -1));
m_static_status_name->SetMaxSize(wxSize(FromDIP(100), -1));
m_fan_operate = new FanOperate(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
sizer_control->Add(m_fan_operate, 0, wxALIGN_CENTER, 0);
m_fan_operate->Bind(EVT_FAN_SWITCH_ON, [this](const wxCommandEvent &e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
m_switch_fan = true;
});
m_fan_operate->Bind(EVT_FAN_SWITCH_OFF, [this](const wxCommandEvent &e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
m_switch_fan = false;
});
m_fan_operate->Bind(EVT_FAN_ADD, [this](const wxCommandEvent &e) {
m_current_speed = e.GetInt();
command_control_fan();
});
m_sizer_control_bottom->Add(m_static_status_name, 0, wxALL, FromDIP(10));
m_sizer_control_bottom->Add(m_fan_operate, 0, wxALL, FromDIP(10));
sizer_control->Add(m_sizer_control_bottom, 0, wxALL, 0);
m_sizer_main->Add(sizer_control, 0, wxALIGN_CENTER, 0);
update_mode();
this->SetSizer(m_sizer_main);
this->Layout();
m_sizer_main->Fit(this);
m_fan_operate->Bind(EVT_FAN_SWITCH_ON, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
m_switch_fan = true;
m_fan->set_fan_speeds(m_current_speed);
});
m_fan_operate->Bind(EVT_FAN_SWITCH_OFF, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
m_switch_fan = false;
m_fan->set_fan_speeds(m_current_speed);
});
m_fan_operate->Bind(EVT_FAN_ADD, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_fan->set_fan_speeds(m_current_speed);
command_control_fan();
});
m_fan_operate->Bind(EVT_FAN_DEC, [this](wxCommandEvent& e) {
m_current_speed = e.GetInt();
m_fan->set_fan_speeds(m_current_speed);
command_control_fan();
});
}
void FanControl::on_left_down(wxMouseEvent& evt)
void FanControlNew::on_left_down(wxMouseEvent& evt)
{
auto mouse_pos = ClientToScreen(evt.GetPosition());
auto tag_pos = m_fan_operate->ScreenToClient(mouse_pos);
@@ -390,17 +390,28 @@ void FanControl::on_left_down(wxMouseEvent& evt)
m_fan_operate->on_left_down(evt);
}
void FanControl::command_control_fan()
void FanControlNew::command_control_fan()
{
if (m_current_speed < 0 || m_current_speed > 10) { return; }
int speed = floor(m_current_speed * float(25.5));
if (m_update_already && m_obj) {
m_obj->command_control_fan_val(m_type, speed);
post_event(wxCommandEvent(EVT_FAN_CHANGED));
BOOST_LOG_TRIVIAL(info) << "Functions Need to be supplemented! :FanControlNew::command_control_fan. the speed may change";
token.reset(this, nop_deleter_fan_control);
if (m_obj) {
if (!m_obj->is_enable_np){
int speed = floor(m_current_speed * float(25.5));
m_obj->command_control_fan(m_part_id, speed);
} else {
m_obj->command_control_fan_new(m_part_id, m_current_speed, [this, w = std::weak_ptr<FanControlNew>(token)](const json &reply) {
if (w.expired())
return;
post_event(1);
});
}
post_event(0);
}
}
void FanControl::on_swith_fan(wxMouseEvent& evt)
void FanControlNew::on_swith_fan(wxMouseEvent& evt)
{
int speed = 0;
if (m_switch_fan) {
@@ -417,7 +428,7 @@ void FanControl::on_swith_fan(wxMouseEvent& evt)
command_control_fan();
}
void FanControl::on_swith_fan(bool on)
void FanControlNew::on_swith_fan(bool on)
{
m_switch_fan = on;
if (m_switch_fan) {
@@ -428,30 +439,58 @@ void FanControl::on_swith_fan(bool on)
}
}
void FanControl::set_machine_obj(MachineObject* obj)
void FanControlNew::update_mode()
{
int cur_mode = m_mode_id;
if (cur_mode < 0) {
m_static_status_name->Hide();
m_fan_operate->Show();
} else {
auto mode = m_fan_data.modes[cur_mode];
auto it = std::find(mode.off.begin(), mode.off.end(), m_part_id);
if (it != mode.off.end()) {
m_show_mode = 2;
m_static_status_name->SetLabelText(_L("Off"));
} else {
auto it_ctrl = std::find(mode.ctrl.begin(), mode.ctrl.end(), m_part_id);
if (it_ctrl == mode.ctrl.end()) {
m_show_mode = 1;
m_static_status_name->SetLabelText(_L("Auto"));
} else {
m_show_mode = 0;
}
}
if (m_show_mode == 0) {
m_static_status_name->Hide();
m_switch_button->Show();
m_fan_operate->Show();
} else {
m_static_status_name->Show();
m_switch_button->Hide();
m_fan_operate->Hide();
}
}
}
void FanControlNew::set_machine_obj(MachineObject* obj)
{
m_update_already = true;
m_obj = obj;
}
void FanControl::set_type(MachineObject::FanType type)
{
m_type = type;
}
void FanControl::set_name(wxString name)
{
void FanControlNew::set_name(wxString name) {
m_static_name->SetLabelText(name);
}
void FanControl::set_fan_speed(int g)
void FanControlNew::set_fan_speed(int g)
{
if (g < 0 || g > 255) return;
int speed = round(float(g) / float(25.5));
if (m_current_speed != speed) {
m_current_speed = speed;
m_fan->set_fan_speeds(speed);
m_fan_operate->set_fan_speeds(m_current_speed);
if (m_current_speed <= 0) {
@@ -461,191 +500,308 @@ void FanControl::set_fan_speed(int g)
on_swith_fan(true);
}
}
}
void FanControl::set_fan_switch(bool s)
void FanControlNew::set_fan_speed_percent(int speed)
{
if (m_current_speed != speed) {
m_current_speed = speed;
m_fan_operate->set_fan_speeds(m_current_speed);
if (m_current_speed <= 0) {
on_swith_fan(false);
} else {
on_swith_fan(true);
}
}
}
void FanControl::post_event(wxCommandEvent&& event)
void FanControlNew::set_fan_switch(bool s)
{
event.SetInt(m_type);
}
void FanControlNew::post_event(int type)
{
auto event = wxCommandEvent(EVT_FAN_CHANGED);
event.SetInt(type);
event.SetString(wxString::Format("%d", m_current_speed));
event.SetEventObject(GetParent());
wxPostEvent(GetParent(), event);
event.Skip();
}
/*************************************************
Description:FanControlPopup
Description:FanControlPopupNew
**************************************************/
FanControlPopup::FanControlPopup(wxWindow* parent)
static void nop_deleter_fan_control_popup(FanControlPopupNew *) {}
FanControlPopupNew::FanControlPopupNew(wxWindow* parent, MachineObject* obj,AirDuctData data)
:PopupWindow(parent, wxBORDER_NONE)
{
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
SetBackgroundColour(*wxWHITE);
init_names();
m_data = data;
m_obj = obj;
m_sizer_main = new wxBoxSizer(wxVERTICAL);
m_part_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_part_fan->set_type(MachineObject::FanType::COOLING_FAN);
m_part_fan->set_name(_L("Part"));
m_radio_btn_sizer = new wxGridSizer( 0, 3, 3, 3 );
m_sizer_fanControl = new wxGridSizer( 0, 3, 3, 10 );
m_aux_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_aux_fan->set_type(MachineObject::FanType::BIG_COOLING_FAN);
m_aux_fan->set_name(_L("Aux"));
m_mode_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cham_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_cham_fan->set_type(MachineObject::FanType::CHAMBER_FAN);
m_cham_fan->set_name(_L("Cham"));
m_button_refresh = new Button(this, wxString(""), "fan_poppingup_refresh", 0, FromDIP(24));
m_button_refresh->SetBackgroundColor(*wxWHITE);
m_button_refresh->SetBorderColor(*wxWHITE);
m_button_refresh->SetMinSize(wxSize(FromDIP(26), FromDIP(26)));
m_button_refresh->SetMaxSize(wxSize(FromDIP(26), FromDIP(26)));
m_line_top = new wxWindow(this, wxID_ANY);
m_line_top->SetSize(wxSize(-1, 1));
m_line_top->SetBackgroundColour(0xF1F1F1);
m_mode_sizer->Add(m_radio_btn_sizer, 0, wxALIGN_CENTRE_VERTICAL, 0);
m_mode_sizer->Add(m_button_refresh, 0, wxALIGN_CENTRE_VERTICAL, 0);
m_line_bottom = new wxWindow(this, wxID_ANY);
m_line_bottom->SetSize(wxSize(-1, 1));
m_line_bottom->SetBackgroundColour(0xF1F1F1);
m_cooling_text = new wxStaticText(this, wxID_ANY, wxT(""));
m_cooling_text->SetBackgroundColour(*wxWHITE);
//Control the show or hide of controls based on id
m_sizer_main->Add(m_part_fan, 0, wxALL, FromDIP(14));
m_sizer_main->Add(m_line_top, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(8));
m_sizer_main->Add(m_aux_fan, 0, wxALL, FromDIP(14));
m_sizer_main->Add(m_line_bottom, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(8));
m_sizer_main->Add(m_cham_fan, 0, wxALL, FromDIP(14));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(23));
m_sizer_main->Add(m_mode_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_cooling_text, 0, wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_sizer_fanControl, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(16));
CreateDuct();
this->SetSizer(m_sizer_main);
this->Layout();
m_sizer_main->Fit(this);
SetSizer(m_sizer_main);
Layout();
Fit();
this->Centre(wxBOTH);
Bind(wxEVT_PAINT, &FanControlPopup::paintEvent, this);
Bind(wxEVT_PAINT, &FanControlPopupNew::paintEvent, this);
#if __APPLE__
Bind(wxEVT_LEFT_DOWN, &FanControlPopup::on_left_down, this);
Bind(wxEVT_LEFT_DOWN, &FanControlPopupNew::on_left_down, this);
#endif
#ifdef __WXOSX__
Bind(wxEVT_IDLE, [](wxIdleEvent& evt) {});
#endif
Bind(wxEVT_SHOW, &FanControlPopupNew::on_show, this);
Bind(EVT_FAN_CHANGED, &FanControlPopupNew::on_fan_changed, this);
Bind(wxEVT_SHOW, &FanControlPopup::on_show, this);
SetBackgroundColour(*wxWHITE);
for (const auto& btn : m_mode_switch_btn_list) {
btn->Bind(wxEVT_LEFT_DOWN, &FanControlPopupNew::on_mode_changed, this);
}
}
void FanControlPopup::show_cham_fan(bool support_cham_fun)
void FanControlPopupNew::CreateDuct(){
//tips
UpdateTips(m_data.curren_mode);
//fan or door
UpdateParts(m_data.curren_mode);
if (m_data.modes.empty()) {
m_button_refresh->Hide();
return;
}
size_t mode_size = m_data.modes.size();
for (auto i = 0; i < mode_size; i++) {
wxString text = wxString::Format("%s", radio_btn_name[AIR_DUCT(m_data.modes[i].id)]);
SendModeSwitchButton *radio_btn = new SendModeSwitchButton(this, text, m_data.curren_mode == m_data.modes[i].id);
m_mode_switch_btn_list.emplace_back(radio_btn);
m_radio_btn_sizer->Add(radio_btn, wxALL, FromDIP(5));
}
}
void FanControlPopupNew::UpdateParts(int mode_id)
{
if (support_cham_fun && !m_is_suppt_cham_fun) {
m_cham_fan->Show();
m_line_bottom->Show();
Layout();
Fit();
m_sizer_fanControl->Clear(true);
for (const auto& part : m_data.parts) {
auto part_id = part.id;
auto part_func = part.func;
auto part_name = fan_func_name[AIR_FUN(part_id)];
auto part_state = part.state;
auto fan_control = new FanControlNew(this, m_data, mode_id, part_id, wxID_ANY, wxDefaultPosition, wxDefaultSize);
fan_control->set_machine_obj(m_obj);
fan_control->set_name(part_name);
m_fan_control_list[part_id] = fan_control;
m_sizer_fanControl->Add(fan_control, 0, wxALL, FromDIP(5));
/*if (fan_control.type == AIR_FAN_TYPE)
m_duct_fans_list[fan.id] = fan_control;
else if (fan_control.type == AIR_DOOR_TYPE)
m_duct_doors_list[fan.id] = fan_control;*/
}
if (!support_cham_fun && m_is_suppt_cham_fun) {
m_cham_fan->Hide();
m_line_bottom->Hide();
Layout();
Fit();
}
m_is_suppt_cham_fun = support_cham_fun;
m_sizer_fanControl->Layout();
/*update state*/
//m_sizer_fanControl->Clear();
//if (m_fan_control_list.find(duct_id) == m_fan_control_list.end()) return;
//for (auto fan_control_list : m_fan_control_list){
// if (fan_control_list.first == duct_id) continue;
// for (auto fan_control : fan_control_list.second){
// fan_control.second->Hide();
// }
//}
//auto fan_control_new_list = m_fan_control_list[duct_id];
//for (auto it : fan_control_new_list){
// //m_sizer_fanControl->Add(it.second, 0, wxALL | wxEXPAND, 0);
// m_sizer_fanControl->Add(it.second, 0, wxALL, 5);
// it.second->Show();
//}
//m_sizer_fanControl->Layout();
}
void FanControlPopup::show_aux_fan(bool support_aux_fun)
void FanControlPopupNew::UpdateTips(int model)
{
auto text = label_text[AIR_DUCT(model)];
m_cooling_text->SetLabelText(text);
m_cooling_text->Wrap(FromDIP(600));
Layout();
}
void FanControlPopupNew::update_fan_data(MachineObject *obj)
{
if (!obj)
return;
if (obj->is_enable_np) {
if (m_air_duct_time_out == 0) {
m_air_duct_time_out--;
return;
}
update_fan_data(obj->m_air_duct_data);
} else {
if (m_fan_set_time_out > 0) {
m_fan_set_time_out--;
return;
}
int cooling_fan_speed = round(obj->cooling_fan_speed / float(25.5));
int big_fan1_speed = round(obj->big_fan1_speed / float(25.5));
int big_fan2_speed = round(obj->big_fan2_speed / float(25.5));
update_fan_data(AIR_FUN::FAN_COOLING_0_AIRDOOR, cooling_fan_speed);
update_fan_data(AIR_FUN::FAN_REMOTE_COOLING_0_IDX, big_fan1_speed);
update_fan_data(AIR_FUN::FAN_REMOTE_COOLING_0_IDX, big_fan2_speed);
}
}
void FanControlPopupNew::update_fan_data(const AirDuctData &data)
{
m_data = data;
for (const auto& part : m_data.parts) {
auto part_id = part.id;
auto part_func = part.func;
auto part_name = fan_func_name[AIR_FUN(part_id)];
auto part_state = part.state;
auto it = m_fan_control_list.find(part_id);
if (it != m_fan_control_list.end()) {
auto fan_control = m_fan_control_list[part_id];
fan_control->set_fan_speed_percent(part_state);
}
}
}
void FanControlPopupNew::update_fan_data(AIR_FUN id, int speed)
{
for (auto& part : m_data.parts) {
auto part_id = part.id;
auto part_func = part.func;
auto part_name = fan_func_name[AIR_FUN(part_id)];
if (id == part_id) {
part.state = speed;
auto it = m_fan_control_list.find(part_id);
if (it != m_fan_control_list.end()) {
auto fan_control = m_fan_control_list[part_id];
fan_control->update_mode();
fan_control->set_fan_speed_percent(speed);
}
}
}
}
// device change
void FanControlPopupNew::update_device(AirDuctData data, MachineObject* obj)
{
if (support_aux_fun && !m_is_suppt_aux_fun) {
m_aux_fan->Show();
m_line_bottom->Show();
Layout();
Fit();
}
//for (int i = 0; i < data.airducts.size(); i++){
// auto duct = data.airducts[i];
// if (m_fan_control_list.find(duct.airduct_id) == m_fan_control_list.end())
// CreateDuct(duct);
// else{
// auto fan_list = m_fan_control_list[duct.airduct_id];
// for (auto fan : duct.fans_list){
// if (fan_list.find(fan.id) == fan_list.end())
// CreateFanAndDoor(duct.airduct_id, fan);
// else{
// auto fan_control = fan_list[fan.id];
// fan_control->update_fan_data(fan);
// }
// }
// }
// m_duct_ctrl[duct.airduct_id] = duct.fans_ctrl[i];
//}
//m_data = data;
//for (auto fan_list_of_duct : m_fan_control_list){
// for (auto fan : fan_list_of_duct.second){
// if (fan.second != nullptr)
// fan.second->set_machine_obj(obj);
// }
//}
////auto text = wxString::Format("%s", radio_btn_name[AIR_DUCT_mode_e(m_data.curren_duct)]);
//auto text = wxT("The fan controls the temperature during printing to improve print quality.The system automatically adjusts the fan's switch and speed according to dif");
//m_cooling_text->SetLabelText(text);
//m_cooling_text->Wrap(FromDIP(360));
if (!support_aux_fun && m_is_suppt_aux_fun) {
m_aux_fan->Hide();
m_line_bottom->Hide();
Layout();
Fit();
}
m_is_suppt_aux_fun = support_aux_fun;
//ChangeCoolingTips(m_data.airducts.size());
//if (data.airducts.size() <= 1)
// m_radio_btn_sizer->Show(false);
//else
// m_radio_btn_sizer->Show(true);
//this->Layout();
//Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
// post_event(e.GetInt(), e.GetString());
// });
}
void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject* obj)
{
m_is_suppt_cham_fun = obj->is_support_chamber_fan;
show_cham_fan(m_is_suppt_cham_fun);
if (type == MachineObject::FanType::COOLING_FAN && obj->cooling_fan_speed >= 0) {
m_part_fan->set_fan_speed(obj->cooling_fan_speed);
}
if (type == MachineObject::FanType::BIG_COOLING_FAN && obj->big_fan1_speed >= 0) {
m_aux_fan->set_fan_speed(obj->big_fan1_speed);
}
if (type == MachineObject::FanType::CHAMBER_FAN && obj->big_fan2_speed >= 0) {
m_cham_fan->set_fan_speed(obj->big_fan2_speed);
}
m_part_fan->set_machine_obj(obj);
m_aux_fan->set_machine_obj(obj);
m_cham_fan->set_machine_obj(obj);
Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
post_event(e.GetInt(), e.GetString());
});
}
void FanControlPopup::on_left_down(wxMouseEvent& evt)
void FanControlPopupNew::on_left_down(wxMouseEvent& evt)
{
auto mouse_pos = ClientToScreen(evt.GetPosition());
auto win_pos = m_part_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
auto size = m_part_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_part_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_part_fan->m_switch_button->GetSize().y)) {
m_part_fan->on_swith_fan(evt);
}
win_pos = m_aux_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
size = m_aux_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_aux_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_aux_fan->m_switch_button->GetSize().y)) {
m_aux_fan->on_swith_fan(evt);
}
win_pos = m_cham_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
size = m_cham_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_cham_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_cham_fan->m_switch_button->GetSize().y)) {
m_cham_fan->on_swith_fan(evt);
}
auto part_tag_pos = m_part_fan->ScreenToClient(mouse_pos);
evt.SetPosition(part_tag_pos);
m_part_fan->on_left_down(evt);
auto aux_tag_pos = m_aux_fan->ScreenToClient(mouse_pos);
evt.SetPosition(aux_tag_pos);
m_aux_fan->on_left_down(evt);
for (auto fan_it : m_fan_control_list){
auto fan = fan_it.second;
auto win_pos = fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
auto size = fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y &&
mouse_pos.y < (win_pos.y + fan->m_switch_button->GetSize().y)) {
fan->on_swith_fan(evt);
}
}
auto cham_tag_pos = m_cham_fan->ScreenToClient(mouse_pos);
evt.SetPosition(cham_tag_pos);
m_cham_fan->on_left_down(evt);
evt.Skip();
}
void FanControlPopup::OnDismiss()
void FanControlPopupNew::OnDismiss()
{
m_part_fan->update_obj_state(false);
m_aux_fan->update_obj_state(false);
m_cham_fan->update_obj_state(false);
}
void FanControlPopup::post_event(int fan_type, wxString speed)
void FanControlPopupNew::post_event(int fan_type, wxString speed)
{
wxCommandEvent event(EVT_FAN_CHANGED);
// id, speed
wxCommandEvent event(EVT_FAN_CHANGED);
event.SetInt(fan_type);
event.SetString(speed);
event.SetEventObject(GetParent());
@@ -653,21 +809,114 @@ void FanControlPopup::post_event(int fan_type, wxString speed)
event.Skip();
}
bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event)
bool FanControlPopupNew::ProcessLeftDown(wxMouseEvent& event)
{
return PopupWindow::ProcessLeftDown(event);
}
void FanControlPopup::on_show(wxShowEvent& evt)
void FanControlPopupNew::on_show(wxShowEvent& evt)
{
wxGetApp().UpdateDarkUIWin(this);
}
void FanControlPopup::paintEvent(wxPaintEvent& evt)
void FanControlPopupNew::command_control_air_duct(int mode_id)
{
m_air_duct_time_out = time_out;
token.reset(this, nop_deleter_fan_control_popup);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", control air duct, id = " << mode_id;
if (m_obj) {
m_obj->command_control_air_duct(mode_id, [this, w = std::weak_ptr<FanControlPopupNew>(token), mode_id](const json& reply) {
if (w.expired())
return;
m_air_duct_time_out = 0;
if (reply.contains("errno")) {
int result = reply["errno"].get<int>();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", control air duct, errno = " << result;
if (result == 0) {
int update_id = mode_id;
if (reply.contains("modeId")) {
update_id = reply["modeId"].get<int>();
this->UpdateParts(update_id);
this->UpdateTips(update_id);
}
}
this->Layout();
this->Refresh();
}
});
}
}
void FanControlPopupNew::paintEvent(wxPaintEvent& evt)
{
wxPaintDC dc(this);
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
}
void FanControlPopupNew::on_mode_changed(const wxMouseEvent &event)
{
size_t btn_list_size = m_mode_switch_btn_list.size();
for (size_t i = 0; i < btn_list_size; ++i) {
if (m_mode_switch_btn_list[i]->GetId() == event.GetId()) {
if (m_mode_switch_btn_list[i]->isSelected())
return;
m_mode_switch_btn_list[i]->setSelected(true);
command_control_air_duct(i);
} else {
m_mode_switch_btn_list[i]->setSelected(false);
}
}
}
void FanControlPopupNew::on_fan_changed(const wxCommandEvent &event)
{
int type = event.GetInt();
if (type == 0)
m_fan_set_time_out = time_out;
else
m_fan_set_time_out = 0;
}
void FanControlPopupNew::init_names() {
//Iint fan/door/func/duct name lists
radio_btn_name[AIR_DUCT::AIR_DUCT_COOLING_FILT] = _L("Cooling Filter");
radio_btn_name[AIR_DUCT::AIR_DUCT_HEATING_INTERNAL_FILT] = L("Internal Filter");
radio_btn_name[AIR_DUCT::AIR_DUCT_EXHAUST] = L("Exhaust");
radio_btn_name[AIR_DUCT::AIR_DUCT_FULL_COOLING] = L("Full Cooling");
radio_btn_name[AIR_DUCT::AIR_DUCT_NUM] = L("Num?");
radio_btn_name[AIR_DUCT::AIR_DUCT_INIT] = L("Init");
fan_func_name[AIR_FUN::FAN_HEAT_BREAK_0_IDX] = _L("Nozzle0");
fan_func_name[AIR_FUN::FAN_COOLING_0_AIRDOOR] = _L("Part");
fan_func_name[AIR_FUN::FAN_REMOTE_COOLING_0_IDX] = _L("Aux");
fan_func_name[AIR_FUN::FAN_CHAMBER_0_IDX] = _L("Chamber");
fan_func_name[AIR_FUN::FAN_HEAT_BREAK_1_IDX] = _L("Nozzle1");
fan_func_name[AIR_FUN::FAN_MC_BOARD_0_IDX] = _L("MC Board");
fan_func_name[AIR_FUN::FAN_INNNER_LOOP_FAN_0_IDX] = _L("Innerloop");
air_door_func_name[AIR_DOOR::AIR_DOOR_FUNC_CHAMBER] = _L("Chamber");
air_door_func_name[AIR_DOOR::AIR_DOOR_FUNC_INNERLOOP] = _L("Innerloop");
air_door_func_name[AIR_DOOR::AIR_DOOR_FUNC_TOP] = _L("Top");
label_text[AIR_DUCT::AIR_DUCT_NONE] = _L("The fan controls the temperature during printing to improve print quality.The system automatically adjusts the fan's switch and speed according to different printing materials.");
label_text[AIR_DUCT::AIR_DUCT_COOLING_FILT] = L("Cooling-filtering mode is suitable for printing PLA/PETG/TPU materials. In this mode, the chamber temperature is low, and the air in the chamber can be filtered while cooling the printed part.");
label_text[AIR_DUCT::AIR_DUCT_HEATING_INTERNAL_FILT] = L("Cooling-filtering mode is suitable for printing PLA/PETG/TPU materials. In this mode, the chamber temperature is low, and the air in the chamber can be filtered while cooling the printed part.");
label_text[AIR_DUCT::AIR_DUCT_EXHAUST] = L("Exhaust");
label_text[AIR_DUCT::AIR_DUCT_FULL_COOLING] = L("Strong cooling mode is suitable for printing PLA/TPU materials. In this mode, the printed part will be cooled in all directions.");
label_text[AIR_DUCT::AIR_DUCT_NUM] = _L("Num");
label_text[AIR_DUCT::AIR_DUCT_INIT] = _L("Init");
/*label_text[AIR_DUCT_mode_e::AIR_DUCT_NONE] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_COOLING_FILT] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_HEATING_INTERNAL_FILT] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_EXHAUST] = "Exhaust";
label_text[AIR_DUCT_mode_e::AIR_DUCT_FULL_COOLING] = "...";
label_text[AIR_DUCT_mode_e::AIR_DUCT_NUM] = "Num";
label_text[AIR_DUCT_mode_e::AIR_DUCT_INIT] = "Init";*/
}
}} // namespace Slic3r::GUI

View File

@@ -6,6 +6,7 @@
#include "StepCtrl.hpp"
#include "Button.hpp"
#include "PopupWindow.hpp"
#include "../SelectMachine.hpp"
#include "../DeviceManager.hpp"
#include "slic3r/GUI/Event.hpp"
#include <wx/simplebook.h>
@@ -21,11 +22,22 @@ namespace GUI {
/*************************************************
Description:Fan
**************************************************/
#define SIZE_OF_FAN_OPERATE wxSize(100, 28)
#define SIZE_OF_FAN_OPERATE wxSize(154, 28)
#define DRAW_TEXT_COLOUR wxColour(0x898989)
#define DRAW_HEAD_TEXT_COLOUR wxColour(0x262e30)
#define DRAW_OPERATE_LINE_COLOUR wxColour(0xDEDEDE)
enum FanControlType
{
PART_FAN = 0,
AUX_FAN,
EXHAUST_FAN,
FILTER_FAN,
CHAMBER_FAN,
TOP_FAN
};
struct RotateOffSet
{
float rotate;
@@ -94,80 +106,145 @@ public:
void decrease_fan_speeds();
private:
int m_current_speeds;
int m_target_speed;
int m_min_speeds;
int m_max_speeds;
ScalableBitmap m_bitmap_add;
ScalableBitmap m_bitmap_decrease;
};
/*************************************************
Description:FanControl
Description:FanControlNew
**************************************************/
class FanControl : public wxWindow
class FanControlNew : public wxWindow
{
public:
FanControl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
~FanControl() {};
FanControlNew(wxWindow *parent, const AirDuctData& fan_data, int mode_id, int part_id, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~FanControlNew() {};
protected:
MachineObject::FanType m_type;
MachineObject* m_obj;
wxStaticText* m_static_name{ nullptr };
int m_fan_id;
ScalableBitmap* m_bitmap_toggle_off{ nullptr };
ScalableBitmap* m_bitmap_toggle_on{ nullptr };
Fan* m_fan{ nullptr };
FanOperate* m_fan_operate{ nullptr };
bool m_switch_fan{ false };
bool m_update_already{false};
int m_current_speed{0};
bool m_update_already{ false };
int m_current_speed{ 0 };
int m_part_id{0};
int m_mode_id{0};
wxBoxSizer *m_sizer_control_bottom{ nullptr };
wxStaticText *m_static_status_name{nullptr};
int m_show_mode{0};// 0 - ctrl, 1 - auto, 2 - off
//Fan and door may use the same mode_id, but they are different, they need to be distinguished by the m_type field
AirDuctData m_fan_data;
bool m_new_protocol{ false };
std::shared_ptr<FanControlNew> token;
public:
wxStaticBitmap* m_switch_button{ nullptr };
void update_obj_state(bool stat) {m_update_already = stat;};
void update_obj_state(bool stat) { m_update_already = stat; };
void update_fan_data(const AirDuctData& data) { m_fan_data = data; };
void command_control_fan();
void set_machine_obj(MachineObject* obj);
void set_type(MachineObject::FanType type);
void set_name(wxString name);
void set_part_id(int id){m_part_id = id;};
void set_fan_speed(int g);
void set_fan_speed_percent(int speed);
void set_fan_switch(bool s);
void post_event(wxCommandEvent&& event);
void post_event(int type);
void on_swith_fan(wxMouseEvent& evt);
void on_swith_fan(bool on);
void update_mode();
void on_left_down(wxMouseEvent& event);
void on_mode_change(wxMouseEvent& event);
};
/*************************************************
Description:FanControlPopup
**************************************************/
class FanControlPopup : public PopupWindow
class FanControlPopupNew : public PopupWindow
{
public:
FanControlPopup(wxWindow* parent);
~FanControlPopup() {};
FanControlPopupNew(wxWindow* parent, MachineObject* obj, AirDuctData data);
~FanControlPopupNew() {};
private:
wxBoxSizer* m_sizer_main;
FanControl* m_part_fan;
FanControl* m_aux_fan;
FanControl* m_cham_fan;
wxBoxSizer* m_sizer_main{ nullptr };
//old protocol
//FanControl* m_part_fan;
//FanControl* m_aux_fan;
//FanControl* m_cham_fan;
wxWindow* m_line_top;
wxWindow* m_line_bottom;
bool m_is_suppt_cham_fun{true};
bool m_is_suppt_aux_fun{true};
bool m_is_suppt_cham_fun{ true };
bool m_is_suppt_aux_fun{ true };
//new protocol
wxGridSizer* m_radio_btn_sizer{ nullptr };
wxGridSizer* m_sizer_fanControl { nullptr };
wxBoxSizer *m_mode_sizer{ nullptr };
wxBoxSizer *m_bottom_sizer{ nullptr };
AirDuctData m_data;
std::map<int, FanControlNew*> m_fan_control_list; //<duct_id, <fan_id, FanControl>>
std::vector<SendModeSwitchButton*> m_mode_switch_btn_list;
int m_air_duct_time_out { 0 };
int m_fan_set_time_out{ 0 };
std::map<int, bool> m_duct_ctrl;
std::map<int, FanControlNew*> m_duct_fans_list;
std::map<int, FanControlNew*> m_duct_doors_list;
Button* m_button_refresh;
wxStaticText* m_cooling_text;
MachineObject *m_obj{nullptr};
std::string m_strong_str = "Strong string ...wait fill";
std::string m_filter_str = "Filtering string ...wait fill";
std::string m_chamber_str = "Chamber string ...wait fill";
std::string m_normal_str = "Normal string ...wait fill"; //For X version machine
std::map<AIR_DUCT, wxString> radio_btn_name;
std::map<AIR_FUN, wxString> fan_func_name;
std::map<AIR_DOOR, wxString> air_door_func_name;
std::map<AIR_DUCT, wxString> label_text;
std::shared_ptr<FanControlPopupNew> token;
void on_mode_changed(const wxMouseEvent &event);
void on_fan_changed(const wxCommandEvent &event);
void init_names();
void CreateDuct();
void UpdateParts(int mode_id);
void UpdateTips(int mode_id);
void BackupOfCreate();
void update_fans(); //New protocol
public:
void show_cham_fan(bool support_cham_fun);
void show_aux_fan(bool support_aux_fun);
void update_fan_data(MachineObject::FanType type, MachineObject* obj);
void update_fan_data(MachineObject *obj);
void update_fan_data(const AirDuctData& data);
void update_fan_data(AIR_FUN id, int speed);
void update_device(AirDuctData data, MachineObject *obj); // New protocol
void on_left_down(wxMouseEvent& evt);
void paintEvent(wxPaintEvent& evt);
void post_event(int fan_type, wxString speed);
void on_show(wxShowEvent& evt);
void command_control_air_duct(int mode_id);
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
};
wxDECLARE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent);
wxDECLARE_EVENT(EVT_FAN_SWITCH_OFF, wxCommandEvent);
wxDECLARE_EVENT(EVT_FAN_ADD, wxCommandEvent);

View File

@@ -286,7 +286,10 @@ void FanSwitchButton::render(wxDC& dc)
dc.DrawText(fan_txt, pt);
pt.y = size.y / 2 + FromDIP(3);
wxString fan_num_txt = GetLabel();
dc.SetFont(::Label::Body_11);
dc.SetFont(::Label::Body_12);
dc.SetTextForeground(0x6b6b6b);
dc.DrawText(fan_num_txt, pt);