From 291225ae358e3b9ddc494ca70cf178619e7da9b4 Mon Sep 17 00:00:00 2001 From: "hang.xu" Date: Tue, 10 Sep 2024 10:11:10 +0800 Subject: [PATCH] FIX: Aix and temp control jira: none Change-Id: I7a9db8178a77727c85ad2b727771179fc5e8050a (cherry picked from commit e6b14bdefb949d3a61479e54b7b27450b344de18) --- resources/images/L.svg | 3 + resources/images/R.svg | 3 + .../images/left_extruder_active_empty.svg | 16 + .../images/left_extruder_active_filled.svg | 16 + .../images/left_extruder_unactive_empty.svg | 18 + .../images/left_extruder_unactive_filled.svg | 18 + resources/images/pipe_of_empty.svg | 19 + resources/images/pipe_of_filled.svg | 19 + resources/images/pipe_of_loading_selected.svg | 22 + .../images/pipe_of_loading_unselected.svg | 22 + .../images/pipe_of_unloading_selected.svg | 22 + .../images/pipe_of_unloading_unselected.svg | 22 + .../images/right_extruder_active_empty.svg | 16 + .../images/right_extruder_active_filled.svg | 16 + .../images/right_extruder_unactive_empty.svg | 18 + .../images/right_extruder_unactive_filled.svg | 18 + src/slic3r/GUI/DeviceManager.cpp | 116 +++- src/slic3r/GUI/DeviceManager.hpp | 67 +- src/slic3r/GUI/Plater.cpp | 5 + src/slic3r/GUI/PrintOptionsDialog.cpp | 289 +++++++- src/slic3r/GUI/PrintOptionsDialog.hpp | 17 + src/slic3r/GUI/StatusPanel.cpp | 622 ++++++++++++++---- src/slic3r/GUI/StatusPanel.hpp | 78 ++- src/slic3r/GUI/Widgets/ImageSwitchButton.cpp | 23 +- src/slic3r/GUI/Widgets/SwitchButton.cpp | 119 ++++ src/slic3r/GUI/Widgets/SwitchButton.hpp | 21 + src/slic3r/GUI/Widgets/TempInput.cpp | 85 ++- src/slic3r/GUI/Widgets/TempInput.hpp | 12 + 28 files changed, 1544 insertions(+), 178 deletions(-) create mode 100644 resources/images/L.svg create mode 100644 resources/images/R.svg create mode 100644 resources/images/left_extruder_active_empty.svg create mode 100644 resources/images/left_extruder_active_filled.svg create mode 100644 resources/images/left_extruder_unactive_empty.svg create mode 100644 resources/images/left_extruder_unactive_filled.svg create mode 100644 resources/images/pipe_of_empty.svg create mode 100644 resources/images/pipe_of_filled.svg create mode 100644 resources/images/pipe_of_loading_selected.svg create mode 100644 resources/images/pipe_of_loading_unselected.svg create mode 100644 resources/images/pipe_of_unloading_selected.svg create mode 100644 resources/images/pipe_of_unloading_unselected.svg create mode 100644 resources/images/right_extruder_active_empty.svg create mode 100644 resources/images/right_extruder_active_filled.svg create mode 100644 resources/images/right_extruder_unactive_empty.svg create mode 100644 resources/images/right_extruder_unactive_filled.svg diff --git a/resources/images/L.svg b/resources/images/L.svg new file mode 100644 index 0000000000..74e8ce2436 --- /dev/null +++ b/resources/images/L.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/images/R.svg b/resources/images/R.svg new file mode 100644 index 0000000000..98e2a29935 --- /dev/null +++ b/resources/images/R.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/images/left_extruder_active_empty.svg b/resources/images/left_extruder_active_empty.svg new file mode 100644 index 0000000000..04aa8fa5e7 --- /dev/null +++ b/resources/images/left_extruder_active_empty.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/images/left_extruder_active_filled.svg b/resources/images/left_extruder_active_filled.svg new file mode 100644 index 0000000000..887ed13590 --- /dev/null +++ b/resources/images/left_extruder_active_filled.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/images/left_extruder_unactive_empty.svg b/resources/images/left_extruder_unactive_empty.svg new file mode 100644 index 0000000000..6daa358f10 --- /dev/null +++ b/resources/images/left_extruder_unactive_empty.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/images/left_extruder_unactive_filled.svg b/resources/images/left_extruder_unactive_filled.svg new file mode 100644 index 0000000000..6daa358f10 --- /dev/null +++ b/resources/images/left_extruder_unactive_filled.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/images/pipe_of_empty.svg b/resources/images/pipe_of_empty.svg new file mode 100644 index 0000000000..1e8b2324c6 --- /dev/null +++ b/resources/images/pipe_of_empty.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/pipe_of_filled.svg b/resources/images/pipe_of_filled.svg new file mode 100644 index 0000000000..631d0e7dca --- /dev/null +++ b/resources/images/pipe_of_filled.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/pipe_of_loading_selected.svg b/resources/images/pipe_of_loading_selected.svg new file mode 100644 index 0000000000..bbc95c2f61 --- /dev/null +++ b/resources/images/pipe_of_loading_selected.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/pipe_of_loading_unselected.svg b/resources/images/pipe_of_loading_unselected.svg new file mode 100644 index 0000000000..7d47a04acc --- /dev/null +++ b/resources/images/pipe_of_loading_unselected.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/pipe_of_unloading_selected.svg b/resources/images/pipe_of_unloading_selected.svg new file mode 100644 index 0000000000..bd19107467 --- /dev/null +++ b/resources/images/pipe_of_unloading_selected.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/pipe_of_unloading_unselected.svg b/resources/images/pipe_of_unloading_unselected.svg new file mode 100644 index 0000000000..22638cb039 --- /dev/null +++ b/resources/images/pipe_of_unloading_unselected.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/right_extruder_active_empty.svg b/resources/images/right_extruder_active_empty.svg new file mode 100644 index 0000000000..ccbc111ab5 --- /dev/null +++ b/resources/images/right_extruder_active_empty.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/images/right_extruder_active_filled.svg b/resources/images/right_extruder_active_filled.svg new file mode 100644 index 0000000000..b160ee80dc --- /dev/null +++ b/resources/images/right_extruder_active_filled.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/images/right_extruder_unactive_empty.svg b/resources/images/right_extruder_unactive_empty.svg new file mode 100644 index 0000000000..6d62ac7737 --- /dev/null +++ b/resources/images/right_extruder_unactive_empty.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/images/right_extruder_unactive_filled.svg b/resources/images/right_extruder_unactive_filled.svg new file mode 100644 index 0000000000..6d62ac7737 --- /dev/null +++ b/resources/images/right_extruder_unactive_filled.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index a727c646ee..51c52ad5ea 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1800,18 +1800,51 @@ int MachineObject::command_go_home2() return this->publish_json(j.dump()); } +// 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) { 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) +{ + BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(set speed), 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; + + j["print"]["speed"] = val; + BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_fan_val, set the speed of fan, fan_id = " << fan_id; + return this->publish_json(j.dump()); +} + int MachineObject::command_task_abort() { @@ -3554,7 +3587,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) else { cooling_fan_speed = 0; } - if (jj.contains("big_fan1_speed")) { big_fan1_speed = stoi(jj["big_fan1_speed"].get()); big_fan1_speed = round( floor(big_fan1_speed / float(1.5)) * float(25.5) ); @@ -3562,7 +3594,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) else { big_fan1_speed = 0; } - if (jj.contains("big_fan2_speed")) { big_fan2_speed = stoi(jj["big_fan2_speed"].get()); big_fan2_speed = round( floor(big_fan2_speed / float(1.5)) * float(25.5) ); @@ -3571,7 +3602,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()); } @@ -3593,6 +3624,35 @@ 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(); + m_air_duct_data.ducts_ctrl.push_back(jj["airduct"]["ctrl"].get()); + 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(); + air_duct.fans_ctrl.push_back((*it_airduct)["ctrl"].get()); + 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(); + 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(); + + unsigned speed = (*it_fan)["speed"].get(); + 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(); @@ -5333,6 +5393,34 @@ 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); + + 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; +} + AmsTray MachineObject::parse_vt_tray(json vtray) { auto vt_tray = AmsTray(std::to_string(VIRTUAL_TRAY_MAIN_ID)); @@ -5512,9 +5600,9 @@ void MachineObject::parse_new_info(json print) printing_speed_lvl = (PrintingSpeedLevel)get_flag_bits(cfg, 8, 3); //is_support_build_plate_marker_detect = get_flag_bits(cfg, 12); todo yangcong - xcam_first_layer_inspector = get_flag_bits(cfg, 13); + xcam_first_layer_inspector = get_flag_bits(cfg, 12); - switch (get_flag_bits(cfg, 14, 2)) + switch (get_flag_bits(cfg, 13, 2)) { case 0: xcam_ai_monitoring_sensitivity = "never_halt"; @@ -5530,14 +5618,14 @@ void MachineObject::parse_new_info(json print) break; } - xcam_ai_monitoring = get_flag_bits(cfg, 16); - xcam_auto_recovery_step_loss = get_flag_bits(cfg, 17); - ams_calibrate_remain_flag = get_flag_bits(cfg, 18); - ams_auto_switch_filament_flag = get_flag_bits(cfg, 19); - xcam_allow_prompt_sound = get_flag_bits(cfg, 23); - xcam_filament_tangle_detect = get_flag_bits(cfg, 24); - nozzle_blob_detection_enabled = get_flag_bits(cfg, 25); - installed_upgrade_kit = get_flag_bits(cfg, 26); + xcam_ai_monitoring = get_flag_bits(cfg, 15); + xcam_auto_recovery_step_loss = get_flag_bits(cfg, 16); + ams_calibrate_remain_flag = get_flag_bits(cfg, 17); + ams_auto_switch_filament_flag = get_flag_bits(cfg, 18); + xcam_allow_prompt_sound = get_flag_bits(cfg, 22); + xcam_filament_tangle_detect = get_flag_bits(cfg, 23); + nozzle_blob_detection_enabled = get_flag_bits(cfg, 24); + installed_upgrade_kit = get_flag_bits(cfg, 25); } /*fun*/ @@ -5557,7 +5645,7 @@ void MachineObject::parse_new_info(json print) is_support_motor_noise_cali = get_flag_bits(fun, 10); is_support_user_preset = get_flag_bits(fun, 11); is_support_nozzle_blob_detection = get_flag_bits(fun, 13); - is_support_upgrade_kit = get_flag_bits(cfg, 14); + is_support_upgrade_kit = get_flag_bits(fun, 14); is_support_command_homing = get_flag_bits(fun, 32); } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 3b0c526052..246de84e59 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -141,6 +141,11 @@ enum ManualPaCaliMethod { PA_PATTERN, }; +enum AirDuctType { + AIR_FAN_TYPE, + AIR_DOOR_TYPE +}; + struct AmsSlot { @@ -201,6 +206,31 @@ struct ExtderData std::vector extders; }; +struct AirDuctFan +{ + //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}; +}; + +struct AirDuct +{ + int airduct_id{ 0 }; //Determine the UI display content, click radonbutton to switch + std::vector fans_ctrl; //Control status of each (fan) / (air door) + std::vector fans_list; //Fan or air door s +}; + +struct AirDuctData +{ + int curren_duct{0}; + std::vector ducts_ctrl; //Control status of each duct + std::vector airducts; +}; + struct RatingInfo { bool request_successful; int http_code; @@ -365,6 +395,31 @@ enum HMSMessageLevel { HMS_MSG_LEVEL_MAX, }; + +enum FAN_func_e { + FAN_FUNC_PART_COOLING = 0, + FAN_FUNC_AUX_COOLING, + FAN_FUNC_EXHAUST, + FAN_FUNC_FILTER, + FAN_FUNC_HEATING +}; + +enum AIR_DOOR_func_e { + AIR_DOOR_FUNC_CHAMBER = 0, + AIR_DOOR_FUNC_INNERLOOP, + AIR_DOOR_FUNC_TOP +}; + +enum AIR_DUCT_mode_e { + AIR_DUCT_NONE = -1, + AIR_DUCT_COOLING_FILT = 0, + AIR_DUCT_HEATING_INTERNAL_FILT, + AIR_DUCT_EXHAUST, + AIR_DUCT_FULL_COOLING, + AIR_DUCT_NUM, + AIR_DUCT_INIT = 0xFF //Initial mode, only used within mc +}; + class HMSItem { public: @@ -426,6 +481,8 @@ public: COOLING_FAN = 1, BIG_COOLING_FAN = 2, CHAMBER_FAN = 3, + EXHAUST_FAN, + FILTER_FAN, }; enum UpgradingDisplayState { @@ -654,6 +711,10 @@ public: int big_fan2_speed = 0; uint32_t fan_gear = 0; + //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 + /* signals */ std::string wifi_signal; std::string link_th; @@ -963,8 +1024,10 @@ public: int command_auto_leveling(); int command_go_home(); int command_go_home2(); - int command_control_fan(FanType fan_type, bool on_off); - int command_control_fan_val(FanType fan_type, int val); + 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_task_abort(); /* cancelled the job_id */ int command_task_cancel(std::string job_id); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 56a33c3efa..fce30a5d60 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -766,6 +766,11 @@ void Sidebar::priv::sync_extruder_list() dlg.ShowModal(); return; } + if (obj->m_extder_data.extders.size() != 2) { + MessageDialog dlg(this->plater, _L("The currently connected printer does not have two extruders."), _L("Sync extruder infomation"), wxOK | wxICON_WARNING); + dlg.ShowModal(); + return; + } std::string machine_print_name = obj->printer_type; PresetBundle *preset_bundle = wxGetApp().preset_bundle; diff --git a/src/slic3r/GUI/PrintOptionsDialog.cpp b/src/slic3r/GUI/PrintOptionsDialog.cpp index f5fb3bfbe5..5a66338803 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.cpp +++ b/src/slic3r/GUI/PrintOptionsDialog.cpp @@ -440,9 +440,15 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent) nozzle_type_map[NozzleType::ntHardenedSteel] = _L("Hardened Steel"); nozzle_type_map[NozzleType::ntStainlessSteel] = _L("Stainless Steel"); + //nozzle_flow_map[NozzleFlowType::S_FLOW] = _L("Standard"); + //nozzle_flow_map[NozzleFlowType::H_FLOW] = _L("High flow"); + nozzle_type_selection_map[NozzleType::ntHardenedSteel] = 0; nozzle_type_selection_map[NozzleType::ntStainlessSteel] = 1; + //nozzle_flow_selection_map[NozzleFlowType::S_FLOW] = 0; + //nozzle_flow_selection_map[NozzleFlowType::H_FLOW] = 1; + nozzle_stainless_diameter_map[0] = 0.2; nozzle_stainless_diameter_map[1] = 0.4; @@ -451,16 +457,25 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent) nozzle_hard_diameter_map[2] = 0.8; SetBackgroundColour(*wxWHITE); - wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); - + + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + wxBoxSizer* single_sizer = new wxBoxSizer(wxVERTICAL); + single_panel = new wxPanel(this); + single_panel->SetBackgroundColour(*wxWHITE); + + wxBoxSizer* multiple_sizer = new wxBoxSizer(wxVERTICAL); + multiple_panel = new wxPanel(this); + multiple_panel->SetBackgroundColour(*wxWHITE); auto m_line = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); m_line->SetBackgroundColour(wxColour(166, 169, 170)); - + + /*single nozzle*/ //nozzle type wxBoxSizer* line_sizer_nozzle_type = new wxBoxSizer(wxHORIZONTAL); - auto nozzle_type = new Label(this, _L("Nozzle Type")); + auto nozzle_type = new Label(single_panel, _L("Nozzle Type")); nozzle_type->SetFont(Label::Body_14); nozzle_type->SetMinSize(wxSize(FromDIP(180), -1)); nozzle_type->SetMaxSize(wxSize(FromDIP(180), -1)); @@ -470,7 +485,7 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent) ID_NOZZLE_TYPE_CHECKBOX_SINGLE = wxNewId(); ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE = wxNewId(); - nozzle_type_checkbox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + nozzle_type_checkbox = new ComboBox(single_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); nozzle_type_checkbox->Append(nozzle_type_map[NozzleType::ntHardenedSteel]); nozzle_type_checkbox->Append(nozzle_type_map[NozzleType::ntStainlessSteel]); nozzle_type_checkbox->SetSelection(0); @@ -483,30 +498,137 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent) //nozzle diameter wxBoxSizer* line_sizer_nozzle_diameter = new wxBoxSizer(wxHORIZONTAL); - auto nozzle_diameter = new Label(this, _L("Nozzle Diameter")); + auto nozzle_diameter = new Label(single_panel, _L("Nozzle Diameter")); nozzle_diameter->SetFont(Label::Body_14); nozzle_diameter->SetMinSize(wxSize(FromDIP(180), -1)); nozzle_diameter->SetMaxSize(wxSize(FromDIP(180), -1)); nozzle_diameter->SetForegroundColour(STATIC_TEXT_CAPTION_COL); nozzle_diameter->Wrap(-1); - nozzle_diameter_checkbox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); - + nozzle_diameter_checkbox = new ComboBox(single_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); line_sizer_nozzle_diameter->Add(nozzle_diameter, 0, wxALIGN_CENTER, 5); line_sizer_nozzle_diameter->Add(0, 0, 1, wxEXPAND, 5); line_sizer_nozzle_diameter->Add(nozzle_diameter_checkbox, 0, wxALIGN_CENTER, 5); - sizer->Add(m_line, 0, wxEXPAND, 0); - sizer->Add(0, 0, 0, wxTOP, FromDIP(24)); - sizer->Add(line_sizer_nozzle_type, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(18)); - sizer->Add(0, 0, 0, wxTOP, FromDIP(20)); - sizer->Add(line_sizer_nozzle_diameter, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(18)); - sizer->Add(0, 0, 0, wxTOP, FromDIP(24)); + single_sizer->Add(m_line, 0, wxEXPAND, 0); + single_sizer->Add(0, 0, 0, wxTOP, FromDIP(24)); + single_sizer->Add(line_sizer_nozzle_type, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(18)); + single_sizer->Add(0, 0, 0, wxTOP, FromDIP(20)); + single_sizer->Add(line_sizer_nozzle_diameter, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(18)); + single_sizer->Add(0, 0, 0, wxTOP, FromDIP(24)); + single_panel->SetSizer(single_sizer); + single_panel->Layout(); + single_panel->Fit(); + + /*multiple nozzle*/ + /*left*/ + auto leftTitle = new Label(multiple_panel, _L("Left Nozzle")); + leftTitle->SetFont(::Label::Head_15); + leftTitle->SetForegroundColour(0x2e2630); + + wxBoxSizer *multiple_left_line_sizer = new wxBoxSizer(wxHORIZONTAL); + auto multiple_left_nozzle_type = new Label(multiple_panel, _L("Nozzle Type")); + multiple_left_nozzle_type->SetFont(Label::Body_14); + multiple_left_nozzle_type->SetMinSize(wxSize(FromDIP(80), -1)); + multiple_left_nozzle_type->SetMaxSize(wxSize(FromDIP(80), -1)); + multiple_left_nozzle_type->SetForegroundColour(STATIC_TEXT_CAPTION_COL); + + multiple_left_nozzle_type_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + multiple_left_nozzle_type_checkbox->Append(_L("Stainless Steel")); + multiple_left_nozzle_type_checkbox->Append(_L("Hardened Steel")); + multiple_left_nozzle_type_checkbox->SetSelection(0); + + auto multiple_left_nozzle_diameter = new Label(multiple_panel, _L("Nozzle Diameter")); + multiple_left_nozzle_diameter->SetFont(Label::Body_14); + multiple_left_nozzle_diameter->SetMinSize(wxSize(FromDIP(80), -1)); + multiple_left_nozzle_diameter->SetMaxSize(wxSize(FromDIP(80), -1)); + multiple_left_nozzle_diameter->SetForegroundColour(STATIC_TEXT_CAPTION_COL); + multiple_left_nozzle_diameter_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + + auto multiple_left_nozzle_flow = new Label(multiple_panel, _L("Nozzle Flow")); + multiple_left_nozzle_flow->SetFont(Label::Body_14); + multiple_left_nozzle_flow->SetMinSize(wxSize(FromDIP(80), -1)); + multiple_left_nozzle_flow->SetMaxSize(wxSize(FromDIP(80), -1)); + multiple_left_nozzle_flow->SetForegroundColour(STATIC_TEXT_CAPTION_COL); + multiple_left_nozzle_flow_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + + multiple_left_line_sizer->Add(multiple_left_nozzle_type, 0, wxALIGN_CENTER, 0); + multiple_left_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(8)); + multiple_left_line_sizer->Add(multiple_left_nozzle_type_checkbox, 0, wxALIGN_CENTER, 0); + multiple_left_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(15)); + multiple_left_line_sizer->Add(multiple_left_nozzle_diameter, 0, wxALIGN_CENTER, 0); + multiple_left_line_sizer->Add(0, 0, 1, wxEXPAND, FromDIP(8)); + multiple_left_line_sizer->Add(multiple_left_nozzle_diameter_checkbox, 0, wxALIGN_CENTER, 0); + multiple_left_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(15)); + multiple_left_line_sizer->Add(multiple_left_nozzle_flow, 0, wxALIGN_CENTER, 0); + multiple_left_line_sizer->Add(0, 0, 1, wxEXPAND, FromDIP(8)); + multiple_left_line_sizer->Add(multiple_left_nozzle_flow_checkbox, 0, wxALIGN_CENTER, 0); + + /*right*/ + auto rightTitle = new Label(multiple_panel, _L("Right Nozzle")); + rightTitle->SetFont(::Label::Head_15); + rightTitle->SetForegroundColour(0x2e2630); + + wxBoxSizer *multiple_right_line_sizer = new wxBoxSizer(wxHORIZONTAL); + auto multiple_right_nozzle_type = new Label(multiple_panel, _L("Nozzle Type")); + multiple_right_nozzle_type->SetFont(Label::Body_14); + multiple_right_nozzle_type->SetMinSize(wxSize(FromDIP(80), -1)); + multiple_right_nozzle_type->SetMaxSize(wxSize(FromDIP(80), -1)); + multiple_right_nozzle_type->SetForegroundColour(STATIC_TEXT_CAPTION_COL); + + multiple_right_nozzle_type_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + multiple_right_nozzle_type_checkbox->Append(_L("Stainless Steel")); + multiple_right_nozzle_type_checkbox->Append(_L("Hardened Steel")); + multiple_right_nozzle_type_checkbox->SetSelection(0); + + auto multiple_right_nozzle_diameter = new Label(multiple_panel, _L("Nozzle Diameter")); + multiple_right_nozzle_diameter->SetFont(Label::Body_14); + multiple_right_nozzle_diameter->SetMinSize(wxSize(FromDIP(80), -1)); + multiple_right_nozzle_diameter->SetMaxSize(wxSize(FromDIP(80), -1)); + multiple_right_nozzle_diameter->SetForegroundColour(STATIC_TEXT_CAPTION_COL); + multiple_right_nozzle_diameter_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + + auto multiple_right_nozzle_flow = new Label(multiple_panel, _L("Nozzle Flow")); + multiple_right_nozzle_flow->SetFont(Label::Body_14); + multiple_right_nozzle_flow->SetMinSize(wxSize(FromDIP(80), -1)); + multiple_right_nozzle_flow->SetMaxSize(wxSize(FromDIP(80), -1)); + multiple_right_nozzle_flow->SetForegroundColour(STATIC_TEXT_CAPTION_COL); + multiple_right_nozzle_flow_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY); + + multiple_right_line_sizer->Add(multiple_right_nozzle_type, 0, wxALIGN_CENTER, 0); + multiple_right_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(8)); + multiple_right_line_sizer->Add(multiple_right_nozzle_type_checkbox, 0, wxALIGN_CENTER, 0); + multiple_right_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(15)); + multiple_right_line_sizer->Add(multiple_right_nozzle_diameter, 0, wxALIGN_CENTER, 0); + multiple_right_line_sizer->Add(0, 0, 1, wxEXPAND, FromDIP(8)); + multiple_right_line_sizer->Add(multiple_right_nozzle_diameter_checkbox, 0, wxALIGN_CENTER, 0); + multiple_right_line_sizer->Add(0, 0, 0, wxLEFT, FromDIP(15)); + multiple_right_line_sizer->Add(multiple_right_nozzle_flow, 0, wxALIGN_CENTER, 0); + multiple_right_line_sizer->Add(0, 0, 1, wxEXPAND, FromDIP(8)); + multiple_right_line_sizer->Add(multiple_right_nozzle_flow_checkbox, 0, wxALIGN_CENTER, 0); + + multiple_sizer->Add(0, 0, 0, wxTOP, FromDIP(40)); + multiple_sizer->Add(leftTitle, 0, wxLEFT, FromDIP(18)); + multiple_sizer->Add(multiple_left_line_sizer, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(18)); + multiple_sizer->Add(0, 0, 0, wxTOP, FromDIP(40)); + multiple_sizer->Add(rightTitle, 0, wxLEFT, FromDIP(18)); + multiple_sizer->Add(multiple_right_line_sizer, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(18)); + multiple_sizer->Add(0, 0, 0, wxTOP, FromDIP(40)); + + multiple_panel->SetSizer(multiple_sizer); + multiple_panel->Layout(); + multiple_panel->Fit(); + + sizer->Add(single_panel, 0, wxEXPAND, 0); + sizer->Add(multiple_panel, 0, wxEXPAND, 0); SetSizer(sizer); Layout(); Fit(); + + single_panel->Hide(); + wxGetApp().UpdateDlgDarkUI(this); nozzle_type_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this); @@ -593,31 +715,134 @@ bool PrinterPartsDialog::Show(bool show) wxGetApp().UpdateDlgDarkUI(this); CentreOnParent(); - auto type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type; - auto diameter = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter; + if (obj->m_extder_data.extders.size() <= 1) { + single_panel->Show(); + multiple_panel->Hide(); - nozzle_diameter_checkbox->Clear(); + auto type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type; + auto diameter = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter; - if (type == NozzleType::ntUndefine) { - nozzle_type_checkbox->SetValue(wxEmptyString); - nozzle_diameter_checkbox->SetValue(wxEmptyString); - } else { - std::map diameter_map; - if (type == NozzleType::ntHardenedSteel) { - diameter_map = nozzle_hard_diameter_map; - } else if (type == NozzleType::ntStainlessSteel) { - diameter_map = nozzle_stainless_diameter_map; - } + nozzle_diameter_checkbox->Clear(); - for (int i = 0; i < diameter_map.size(); i++) { - nozzle_diameter_checkbox->Append(wxString::Format(_L("%.1f"), diameter_map[i])); - if (diameter == diameter_map[i]) { - nozzle_diameter_checkbox->SetSelection(i); + if (type == NozzleType::ntUndefine) { + nozzle_type_checkbox->SetValue(wxEmptyString); + nozzle_diameter_checkbox->SetValue(wxEmptyString); + + nozzle_type_checkbox->Disable(); + nozzle_diameter_checkbox->Disable(); + return DPIDialog::Show(show); + } else { + nozzle_type_checkbox->Enable(); + nozzle_diameter_checkbox->Enable(); + + std::map diameter_map; + if (type == NozzleType::ntHardenedSteel) { + diameter_map = nozzle_hard_diameter_map; + } else if (type == NozzleType::ntStainlessSteel) { + diameter_map = nozzle_stainless_diameter_map; } + + for (int i = 0; i < diameter_map.size(); i++) { + nozzle_diameter_checkbox->Append(wxString::Format(_L("%.1f"), diameter_map[i])); + if (diameter == diameter_map[i]) { + nozzle_diameter_checkbox->SetSelection(i); + } + } + + nozzle_type_checkbox->SetSelection(nozzle_type_selection_map[type]); } - nozzle_type_checkbox->SetSelection(nozzle_type_selection_map[type]); + } else { + single_panel->Hide(); + multiple_panel->Show(); + + //left + auto type = obj->m_extder_data.extders[DEPUTY_NOZZLE_ID].current_nozzle_type; + auto diameter = obj->m_extder_data.extders[DEPUTY_NOZZLE_ID].current_nozzle_diameter; + //auto flow_type = obj->m_extder_data.extders[DEPUTY_NOZZLE_ID].current_nozzle_flow_type; + + multiple_left_nozzle_type_checkbox->Enable(); + multiple_left_nozzle_diameter_checkbox->Enable(); + multiple_left_nozzle_flow_checkbox->Enable(); + + multiple_left_nozzle_diameter_checkbox->Clear(); + + if (type == NozzleType::ntUndefine) + { + multiple_left_nozzle_type_checkbox->SetValue(wxEmptyString); + multiple_left_nozzle_diameter_checkbox->SetValue(wxEmptyString); + multiple_left_nozzle_flow_checkbox->SetValue(wxEmptyString); + } + else + { + std::map diameter_map; + if (type == NozzleType::ntHardenedSteel) + { + diameter_map = nozzle_hard_diameter_map; + } + else if (type == NozzleType::ntStainlessSteel) + { + diameter_map = nozzle_stainless_diameter_map; + } + + for (int i = 0; i < diameter_map.size(); i++) + { + multiple_left_nozzle_diameter_checkbox->Append(wxString::Format(_L("%.1f"), diameter_map[i])); + if (diameter == diameter_map[i]) + { + multiple_left_nozzle_diameter_checkbox->SetSelection(i); + } + } + + multiple_left_nozzle_type_checkbox->SetSelection(nozzle_type_selection_map[type]); + //if (flow_type != NozzleFlowType::NONE_FLOWTYPE) {multiple_left_nozzle_flow_checkbox->SetSelection(nozzle_flow_selection_map[flow_type]);} + } + + //right + type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type; + diameter = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter; + //flow_type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_flow_type; + + multiple_right_nozzle_diameter_checkbox->Clear(); + + multiple_right_nozzle_type_checkbox->Enable(); + multiple_right_nozzle_diameter_checkbox->Enable(); + multiple_right_nozzle_flow_checkbox->Enable(); + + if (type == NozzleType::ntUndefine) + { + multiple_right_nozzle_type_checkbox->SetValue(wxEmptyString); + multiple_right_nozzle_diameter_checkbox->SetValue(wxEmptyString); + multiple_right_nozzle_flow_checkbox->SetValue(wxEmptyString); + } + else + { + std::map diameter_map; + if (type == NozzleType::ntHardenedSteel) + { + diameter_map = nozzle_hard_diameter_map; + } + else if (type == NozzleType::ntStainlessSteel) + { + diameter_map = nozzle_stainless_diameter_map; + } + + for (int i = 0; i < diameter_map.size(); i++) + { + multiple_right_nozzle_diameter_checkbox->Append(wxString::Format(_L("%.1f"), diameter_map[i])); + if (diameter == diameter_map[i]) + { + multiple_right_nozzle_diameter_checkbox->SetSelection(i); + } + } + + multiple_right_nozzle_type_checkbox->SetSelection(nozzle_type_selection_map[type]); + //if (flow_type != NozzleFlowType::NONE_FLOWTYPE) { multiple_right_nozzle_flow_checkbox->SetSelection(nozzle_flow_selection_map[flow_type]); }; + } } + + Layout(); + Fit(); } return DPIDialog::Show(show); } diff --git a/src/slic3r/GUI/PrintOptionsDialog.hpp b/src/slic3r/GUI/PrintOptionsDialog.hpp index 7450933a43..694118aed4 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.hpp +++ b/src/slic3r/GUI/PrintOptionsDialog.hpp @@ -26,11 +26,28 @@ protected: wxWindowID ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE; MachineObject* obj{ nullptr }; + ComboBox* nozzle_type_checkbox; ComboBox* nozzle_diameter_checkbox; + + ComboBox* multiple_left_nozzle_type_checkbox; + ComboBox *multiple_left_nozzle_diameter_checkbox; + ComboBox *multiple_left_nozzle_flow_checkbox; + + ComboBox *multiple_right_nozzle_type_checkbox; + ComboBox *multiple_right_nozzle_diameter_checkbox; + ComboBox *multiple_right_nozzle_flow_checkbox; + + wxPanel *single_panel; + wxPanel *multiple_panel; + std::string last_nozzle_type; std::map nozzle_type_map; std::map nozzle_type_selection_map; + + //std::map nozzle_flow_map; + //std::map nozzle_flow_selection_map; + std::map nozzle_stainless_diameter_map; std::map nozzle_hard_diameter_map; public: diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 9c191118d1..b27e80d676 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -117,13 +117,14 @@ static wxImage fail_image; #define TASK_THUMBNAIL_SIZE (wxSize(FromDIP(120), FromDIP(120))) #define TASK_BUTTON_SIZE (wxSize(FromDIP(48), FromDIP(24))) #define TASK_BUTTON_SIZE2 (wxSize(-1, FromDIP(24))) -#define Z_BUTTON_SIZE (wxSize(FromDIP(52), FromDIP(52))) +#define Z_BUTTON_SIZE (wxSize(FromDIP(44), FromDIP(40))) #define MISC_BUTTON_PANEL_SIZE (wxSize(FromDIP(136), FromDIP(55))) #define MISC_BUTTON_1FAN_SIZE (wxSize(FromDIP(132), FromDIP(51))) #define MISC_BUTTON_2FAN_SIZE (wxSize(FromDIP(66), FromDIP(51))) #define MISC_BUTTON_3FAN_SIZE (wxSize(FromDIP(44), FromDIP(51))) -#define TEMP_CTRL_MIN_SIZE (wxSize(FromDIP(122), FromDIP(52))) -#define AXIS_MIN_SIZE (wxSize(FromDIP(220), FromDIP(220))) +#define TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE (wxSize(FromDIP(122), FromDIP(52))) +#define TEMP_CTRL_MIN_SIZE_OF_DOUBLE_NOZZLE (wxSize(FromDIP(122), FromDIP(48))) +#define AXIS_MIN_SIZE (wxSize(FromDIP(258), FromDIP(258))) #define EXTRUDER_IMAGE_SIZE (wxSize(FromDIP(48), FromDIP(76))) static void market_model_scoring_page(int design_id) @@ -148,6 +149,203 @@ static void market_model_scoring_page(int design_id) } } +/************************************************* +Description:Extruder +**************************************************/ + +ExtruderImage::ExtruderImage(wxWindow* parent, wxWindowID id, int nozzle_num, const wxPoint& pos, const wxSize& size) +{ + wxWindow::Create(parent, id, pos, wxSize(FromDIP(45), FromDIP(112))); + SetBackgroundColour(*wxWHITE); + m_nozzle_num = nozzle_num; + SetSize(wxSize(FromDIP(45), FromDIP(112))); + SetMinSize(wxSize(FromDIP(45), FromDIP(112))); + SetMaxSize(wxSize(FromDIP(45), FromDIP(112))); + + m_pipe_filled_load = new ScalableBitmap(this, "pipe_of_loading_selected", 50); + m_pipe_filled_unload = new ScalableBitmap(this, "pipe_of_unloading_selected", 50); + m_pipe_empty_load = new ScalableBitmap(this, "pipe_of_empty", 50); + m_pipe_empty_unload = new ScalableBitmap(this, "pipe_of_empty", 50); + m_pipe_filled_load_unselected = new ScalableBitmap(this, "pipe_of_loading_unselected", 50); + m_pipe_filled_unload_unselected = new ScalableBitmap(this, "pipe_of_unloading_unselected", 50); + m_pipe_empty_load_unselected = new ScalableBitmap(this, "pipe_of_empty", 50); + m_pipe_empty_unload_unselected = new ScalableBitmap(this, "pipe_of_empty", 50); + + m_left_extruder_active_filled = new ScalableBitmap(this, "left_extruder_active_filled", 62); + m_left_extruder_active_empty = new ScalableBitmap(this, "left_extruder_active_empty", 62); + m_left_extruder_unactive_filled = new ScalableBitmap(this, "left_extruder_unactive_filled", 62); + m_left_extruder_unactive_empty = new ScalableBitmap(this, "left_extruder_unactive_empty", 62); + m_right_extruder_active_filled = new ScalableBitmap(this, "right_extruder_active_filled", 62); + m_right_extruder_active_empty = new ScalableBitmap(this, "right_extruder_active_empty", 62); + m_right_extruder_unactive_filled = new ScalableBitmap(this, "right_extruder_unactive_filled", 62); + m_right_extruder_unactive_empty = new ScalableBitmap(this, "right_extruder_unactive_empty", 62); + + m_extruder_single_nozzle_empty_load = new ScalableBitmap(this, "monitor_extruder_empty_load", 106); + m_extruder_single_nozzle_empty_unload = new ScalableBitmap(this, "monitor_extruder_empty_unload", 106); + m_extruder_single_nozzle_filled_load = new ScalableBitmap(this, "monitor_extruder_filled_load", 106); + m_extruder_single_nozzle_filled_unload = new ScalableBitmap(this, "monitor_extruder_filled_unload", 106); + + Bind(wxEVT_PAINT, &ExtruderImage::paintEvent, this); +} + +ExtruderImage::~ExtruderImage() {} + +void ExtruderImage::msw_rescale() +{ + //m_ams_extruder.SetSize(AMS_EXTRUDER_BITMAP_SIZE); + //auto image = m_ams_extruder.ConvertToImage(); + //m_extruder_pipe = ScalableBitmap(this, "pipe_of_extruder_control", 50); + + m_pipe_filled_load->msw_rescale(); + m_pipe_filled_unload->msw_rescale(); + m_pipe_empty_load->msw_rescale(); + m_pipe_empty_unload->msw_rescale(); + m_pipe_filled_load_unselected->msw_rescale(); + m_pipe_filled_unload_unselected->msw_rescale(); + m_pipe_empty_load_unselected->msw_rescale(); + m_pipe_empty_unload_unselected->msw_rescale(); + + m_left_extruder_active_filled->msw_rescale(); + m_left_extruder_active_empty->msw_rescale(); + m_left_extruder_unactive_filled->msw_rescale(); + m_left_extruder_unactive_empty->msw_rescale(); + m_right_extruder_active_filled->msw_rescale(); + m_right_extruder_active_empty->msw_rescale(); + m_right_extruder_unactive_filled->msw_rescale(); + m_right_extruder_unactive_empty->msw_rescale(); + + m_extruder_single_nozzle_empty_load->msw_rescale(); + m_extruder_single_nozzle_empty_unload->msw_rescale(); + m_extruder_single_nozzle_filled_load->msw_rescale(); + m_extruder_single_nozzle_filled_unload->msw_rescale(); + Layout(); + Refresh(); +} + +void ExtruderImage::setExtruderCount(int nozzle_num) +{ + m_nozzle_num = nozzle_num; +} + +void ExtruderImage::setExtruderUsed(std::string loc) +{ + //current_nozzle_idx = nozzle_id; + current_nozzle_loc = loc; +} + +void ExtruderImage::update(ExtruderState right_state, ExtruderState left_state) { + m_left_ext_state = left_state; + m_right_ext_state = right_state; +} + +void ExtruderImage::paintEvent(wxPaintEvent& evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void ExtruderImage::render(wxDC& dc) +{ +#ifdef __WXMSW__ + wxSize size = GetSize(); + wxMemoryDC memdc; + wxBitmap bmp(size.x, size.y); + memdc.SelectObject(bmp); + memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 }); + + { + wxGCDC dc2(memdc); + doRender(dc2); + } + + memdc.SelectObject(wxNullBitmap); + dc.DrawBitmap(bmp, 0, 0); +#else + doRender(dc); +#endif +} + +void ExtruderImage::doRender(wxDC& dc) +{ + auto size = GetSize(); + //dc.DrawRectangle(0, FromDIP(5), size.x, size.y - FromDIP(5) - FromDIP(2)); + + auto pot = wxPoint(size.x / 2, (size.y - m_pipe_filled_load->GetBmpSize().y - m_left_extruder_active_filled->GetBmpSize().y) / 2); + + if (m_nozzle_num >= 2){ + ScalableBitmap* left_nozzle_bmp; + ScalableBitmap* right_nozzle_bmp; + ScalableBitmap* left_pipe_bmp; + ScalableBitmap* right_pipe_bmp; + + switch (m_right_ext_state) + { + case Slic3r::GUI::FILLED_LOAD: + right_pipe_bmp = current_nozzle_loc == "right" ? m_pipe_filled_load : m_pipe_filled_load_unselected; + right_nozzle_bmp = current_nozzle_loc == "right" ? m_right_extruder_active_filled : m_right_extruder_unactive_filled; + break; + case Slic3r::GUI::FILLED_UNLOAD: + right_pipe_bmp = current_nozzle_loc == "right" ? m_pipe_filled_unload : m_pipe_filled_unload_unselected; + right_nozzle_bmp = current_nozzle_loc == "right" ? m_right_extruder_active_filled : m_right_extruder_unactive_filled; + break; + case Slic3r::GUI::EMPTY_LOAD: + right_pipe_bmp = current_nozzle_loc == "right" ? m_pipe_empty_load : m_pipe_empty_load_unselected; + right_nozzle_bmp = current_nozzle_loc == "right" ? m_right_extruder_active_empty : m_right_extruder_unactive_empty; + break; + case Slic3r::GUI::EMPTY_UNLOAD: + right_pipe_bmp = current_nozzle_loc == "right" ? m_pipe_empty_unload : m_pipe_empty_unload_unselected; + right_nozzle_bmp = current_nozzle_loc == "right" ? m_right_extruder_active_empty : m_right_extruder_unactive_empty; + break; + default: + break; + } + + switch (m_left_ext_state) + { + case Slic3r::GUI::FILLED_LOAD: + left_pipe_bmp = current_nozzle_loc == "left" ? m_pipe_filled_load : m_pipe_filled_load_unselected; + left_nozzle_bmp = current_nozzle_loc == "left" ? m_left_extruder_active_filled : m_left_extruder_unactive_filled; + break; + case Slic3r::GUI::FILLED_UNLOAD: + left_pipe_bmp = current_nozzle_loc == "left" ? m_pipe_filled_unload : m_pipe_filled_unload_unselected; + left_nozzle_bmp = current_nozzle_loc == "left" ? m_left_extruder_active_filled : m_left_extruder_unactive_filled; + break; + case Slic3r::GUI::EMPTY_LOAD: + left_pipe_bmp = current_nozzle_loc == "left" ? m_pipe_empty_load : m_pipe_empty_load_unselected; + left_nozzle_bmp = current_nozzle_loc == "left" ? m_left_extruder_active_empty : m_left_extruder_unactive_empty; + break; + case Slic3r::GUI::EMPTY_UNLOAD: + left_pipe_bmp = current_nozzle_loc == "left" ? m_pipe_empty_unload : m_pipe_empty_unload_unselected; + left_nozzle_bmp = current_nozzle_loc == "left" ? m_left_extruder_active_empty : m_left_extruder_unactive_empty; + break; + default: + break; + } + + left_pipe_bmp = m_pipe_filled_load; + right_pipe_bmp = m_pipe_filled_load; + + dc.DrawBitmap(left_pipe_bmp->bmp(), pot.x - left_nozzle_bmp->GetBmpWidth() / 2 - left_pipe_bmp->GetBmpWidth() / 2, pot.y); + dc.DrawBitmap(left_nozzle_bmp->bmp(), pot.x - left_nozzle_bmp->GetBmpWidth(), pot.y + left_pipe_bmp->GetBmpSize().y); + dc.DrawBitmap(right_pipe_bmp->bmp(), pot.x + right_nozzle_bmp->GetBmpWidth() / 2 - right_pipe_bmp->GetBmpWidth() / 2, pot.y); + 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; + case Slic3r::GUI::FILLED_UNLOAD: m_extruder_single_nozzle_filled_unload; break; + case Slic3r::GUI::EMPTY_LOAD: m_extruder_single_nozzle_empty_load; break; + case Slic3r::GUI::EMPTY_UNLOAD: m_extruder_single_nozzle_empty_unload; break; + default: + break; + } + dc.DrawBitmap(m_extruder_single_nozzle_empty_load->bmp(), pot.x - m_extruder_single_nozzle_empty_load->GetBmpWidth() / 2, (size.y - m_extruder_single_nozzle_empty_load->GetBmpHeight()) / 2); + } +} + + PrintingTaskPanel::PrintingTaskPanel(wxWindow* parent, PrintingTaskType type) : wxPanel(parent, wxID_ANY,wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) { @@ -1144,11 +1342,11 @@ wxBoxSizer *StatusBasePanel::create_machine_control_page(wxWindow *parent) wxBoxSizer *bSizer_control = new wxBoxSizer(wxVERTICAL); auto temp_axis_ctrl_sizer = create_temp_axis_group(parent); - bSizer_control->Add(temp_axis_ctrl_sizer, 0, wxEXPAND, 0); - auto m_ams_ctrl_sizer = create_ams_group(parent); - bSizer_control->Add(m_ams_ctrl_sizer, 0, wxEXPAND|wxBOTTOM, FromDIP(10)); + bSizer_control->Add(temp_axis_ctrl_sizer, 0, wxALL | wxEXPAND, FromDIP(4)); + bSizer_control->Add(0, 0, 0, wxTOP, FromDIP(10)); + bSizer_control->Add(m_ams_ctrl_sizer, 0, wxALL | wxEXPAND, FromDIP(4)); bSizer_right->Add(bSizer_control, 1, wxEXPAND | wxALL, 0); return bSizer_right; @@ -1173,29 +1371,41 @@ wxBoxSizer *StatusBasePanel::create_temp_axis_group(wxWindow *parent) wxBoxSizer *m_temp_ctrl = create_temp_control(box); - m_temp_extruder_line = new StaticLine(box, true); - m_temp_extruder_line->SetLineColour(STATIC_BOX_LINE_COL); + m_temp_temp_line = new wxPanel(box); + m_temp_temp_line->SetMaxSize(wxSize(FromDIP(1), -1)); + m_temp_temp_line->SetMinSize(wxSize(FromDIP(1), -1)); + m_temp_temp_line->SetBackgroundColour(STATIC_BOX_LINE_COL); auto m_axis_sizer = create_axis_control(box); + auto bedPanel = create_bed_control(box); - - wxBoxSizer *bed_sizer = create_bed_control(box); wxBoxSizer *extruder_sizer = create_extruder_control(box); + wxBoxSizer* axis_and_bed_control_sizer = new wxBoxSizer(wxVERTICAL); + axis_and_bed_control_sizer->Add(m_axis_sizer, 0, wxEXPAND | wxALL, 0); + axis_and_bed_control_sizer->Add(bedPanel, 0, wxALIGN_CENTER, 0); content_sizer->Add(m_temp_ctrl, 0, wxEXPAND | wxALL, FromDIP(5)); - content_sizer->Add(m_temp_extruder_line, 0, wxEXPAND, 1); - content_sizer->Add(FromDIP(9), 0, 0, wxEXPAND, 1); - content_sizer->Add(0, 0, 0, wxLEFT, FromDIP(18)); + content_sizer->Add(m_temp_temp_line, 0, wxEXPAND, 1); + //content_sizer->Add(FromDIP(9), 0, 0, wxEXPAND, 1); + /*content_sizer->Add(0, 0, 0, wxLEFT, FromDIP(18)); content_sizer->Add(m_axis_sizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); content_sizer->Add(0, 0, 0, wxLEFT, FromDIP(18)); - content_sizer->Add(bed_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, FromDIP(12)); - content_sizer->Add(0, 0, 0, wxLEFT, FromDIP(18)); + content_sizer->Add(bed_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, FromDIP(12));*/ + content_sizer->Add(axis_and_bed_control_sizer, 1, wxALIGN_CENTER, 0); + //content_sizer->Add(0, 0, 0, wxLEFT, FromDIP(18)); + + m_temp_extruder_line = new wxPanel(box); + m_temp_extruder_line->SetMaxSize(wxSize(FromDIP(1), -1)); + m_temp_extruder_line->SetMinSize(wxSize(FromDIP(1), -1)); + m_temp_extruder_line->SetBackgroundColour(STATIC_BOX_LINE_COL); + + content_sizer->Add(m_temp_extruder_line, 0, wxEXPAND, 1); content_sizer->Add(extruder_sizer, 0, wxEXPAND | wxTOP | wxBOTTOM, FromDIP(12)); + content_sizer->Add(0, 0, 0, wxRIGHT, FromDIP(3)); box->SetSizer(content_sizer); sizer->Add(box, 0, wxEXPAND | wxALL, FromDIP(9)); - return sizer; } @@ -1204,9 +1414,9 @@ 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, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"), + 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); + 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]); m_tempCtrl_nozzle->SetBorderWidth(FromDIP(2)); @@ -1219,6 +1429,18 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent) m_tempCtrl_nozzle->SetBorderColor(tempinput_border_colour); sizer->Add(m_tempCtrl_nozzle, 0, wxEXPAND | wxALL, 1); + m_tempCtrl_nozzle_deputy = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_DEPUTY_NOZZLE_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"), + wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); + m_tempCtrl_nozzle_deputy->SetMinSize(TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE); + m_tempCtrl_nozzle_deputy->SetMinTemp(nozzle_temp_range[0]); + m_tempCtrl_nozzle_deputy->SetMaxTemp(nozzle_temp_range[1]); + m_tempCtrl_nozzle_deputy->SetBorderWidth(FromDIP(2)); + + m_tempCtrl_nozzle_deputy->SetTextColor(tempinput_text_colour); + m_tempCtrl_nozzle_deputy->SetBorderColor(tempinput_border_colour); + + sizer->Add(m_tempCtrl_nozzle_deputy, 0, wxEXPAND | wxALL, 1); + //m_tempCtrl_nozzle_deputy->Hide(); m_line_nozzle = new StaticLine(parent); m_line_nozzle->SetLineColour(STATIC_BOX_LINE_COL); @@ -1226,11 +1448,11 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent) sizer->Add(m_line_nozzle, 0, wxEXPAND | wxLEFT | wxRIGHT, 12); wxWindowID bed_id = wxWindow::NewControlId(); - m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_bed_temp"), wxString("monitor_bed_temp_active"), wxDefaultPosition, - wxDefaultSize, wxALIGN_CENTER); + m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_bed_temp"), + wxString("monitor_bed_temp_active"), wxDefaultPosition,wxDefaultSize, wxALIGN_CENTER); m_tempCtrl_bed->SetMinTemp(bed_temp_range[0]); m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]); - m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE); + m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE); m_tempCtrl_bed->SetBorderWidth(FromDIP(2)); m_tempCtrl_bed->SetTextColor(tempinput_text_colour); m_tempCtrl_bed->SetBorderColor(tempinput_border_colour); @@ -1241,12 +1463,12 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent) sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12); wxWindowID frame_id = wxWindow::NewControlId(); - m_tempCtrl_chamber = new TempInput(parent, frame_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_frame_temp"), wxString("monitor_frame_temp_active"), wxDefaultPosition, - wxDefaultSize, wxALIGN_CENTER); + m_tempCtrl_chamber = new TempInput(parent, frame_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_frame_temp"), + wxString("monitor_frame_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); m_tempCtrl_chamber->SetReadOnly(true); m_tempCtrl_chamber->SetMinTemp(nozzle_chamber_range[0]); m_tempCtrl_chamber->SetMaxTemp(nozzle_chamber_range[1]); - m_tempCtrl_chamber->SetMinSize(TEMP_CTRL_MIN_SIZE); + m_tempCtrl_chamber->SetMinSize(TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE); m_tempCtrl_chamber->SetBorderWidth(FromDIP(2)); m_tempCtrl_chamber->SetTextColor(tempinput_text_colour); m_tempCtrl_chamber->SetBorderColor(tempinput_border_colour); @@ -1296,10 +1518,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); @@ -1368,8 +1590,6 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent) m_fan_panel->SetBackgroundColor(parent->GetBackgroundColour()); }); - //m_switch_block_fan = new wxPanel(m_fan_panel); - //m_switch_block_fan->SetBackgroundColour(parent->GetBackgroundColour()); 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)); @@ -1382,8 +1602,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent) m_fan_panel->Layout(); m_fan_panel->Fit(); sizer->Add(m_fan_panel, 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_sizer, 0, wxEXPAND, FromDIP(5)); return sizer; } @@ -1392,13 +1615,18 @@ void StatusBasePanel::reset_temp_misc_control() // reset temp string m_tempCtrl_nozzle->SetLabel(TEMP_BLANK_STR); m_tempCtrl_nozzle->GetTextCtrl()->SetValue(TEMP_BLANK_STR); + + m_tempCtrl_nozzle_deputy->SetLabel(TEMP_BLANK_STR); + m_tempCtrl_nozzle_deputy->GetTextCtrl()->SetValue(TEMP_BLANK_STR); + m_tempCtrl_bed->SetLabel(TEMP_BLANK_STR); m_tempCtrl_bed->GetTextCtrl()->SetValue(TEMP_BLANK_STR); m_tempCtrl_chamber->SetLabel(TEMP_BLANK_STR); m_tempCtrl_chamber->GetTextCtrl()->SetValue(TEMP_BLANK_STR); - m_button_unload->Show(); + //m_button_unload->Show(); m_tempCtrl_nozzle->Enable(true); + m_tempCtrl_nozzle_deputy->Enable(true); m_tempCtrl_chamber->Enable(true); m_tempCtrl_bed->Enable(true); @@ -1424,26 +1652,14 @@ wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent) sizer->Add(m_bpButton_xy, 0, wxALIGN_CENTER | wxALL, 0); sizer->AddStretchSpacer(); - /*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; -} - -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); + /* + wxBoxSizer* bSizer_z_ctrl = new wxBoxSizer(wxHORIZONTAL); + auto panel = new wxPanel(parent, wxID_ANY); panel->SetBackgroundColour(*wxWHITE); - panel->SetSize(wxSize(FromDIP(52), -1)); - panel->SetMinSize(wxSize(FromDIP(52), -1)); - panel->SetMaxSize(wxSize(FromDIP(52), -1)); - - + 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(BUTTON_PRESS_COL, StateColor::Pressed), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); StateColor z_10_ctrl_bd(std::pair(BUTTON_HOVER_COL, StateColor::Hovered), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); @@ -1457,7 +1673,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) 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->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); @@ -1469,11 +1685,17 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) 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))); + 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); - 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); @@ -1481,8 +1703,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) 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))); - + 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)); @@ -1491,24 +1712,95 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) 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))); + 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); + auto panel = new wxPanel(parent, wxID_ANY); + panel->SetBackgroundColour(*wxWHITE); + + /* panel->SetSize(wxSize(FromDIP(268), -1)); + panel->SetMinSize(wxSize(FromDIP(268), -1)); + panel->SetMaxSize(wxSize(FromDIP(268), -1));*/ + + + + StateColor z_10_ctrl_bg(std::pair(BUTTON_PRESS_COL, StateColor::Pressed), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); + StateColor z_10_ctrl_bd(std::pair(BUTTON_HOVER_COL, StateColor::Hovered), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); + + StateColor z_1_ctrl_bg(std::pair(BUTTON_PRESS_COL, StateColor::Pressed), std::pair(BUTTON_NORMAL2_COL, StateColor::Normal)); + StateColor z_1_ctrl_bd(std::pair(BUTTON_HOVER_COL, StateColor::Hovered), std::pair(BUTTON_NORMAL2_COL, StateColor::Normal)); + + m_bpButton_z_10 = new Button(panel, wxString("10"), "monitor_bed_up", 0, FromDIP(15)); + m_bpButton_z_10->SetFont(::Label::Body_12); + m_bpButton_z_10->SetBorderWidth(0); + 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->SetMaxSize(Z_BUTTON_SIZE); + m_bpButton_z_10->SetCornerRadius(0); + m_bpButton_z_1 = new Button(panel, wxString(" 1"), "monitor_bed_up", 0, FromDIP(15)); + m_bpButton_z_1->SetFont(::Label::Body_12); + m_bpButton_z_1->SetBorderWidth(0); + 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->SetMaxSize(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(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); + m_staticText_z_tip->SetFont(::Label::Body_12); 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, wxBOTTOM | wxALIGN_CENTER_HORIZONTAL, 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_12); + m_bpButton_z_down_1->SetBorderWidth(0); + 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->SetSize(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))); + + m_bpButton_z_down_10 = new Button(panel, wxString("10"), "monitor_bed_down", 0, FromDIP(15)); + m_bpButton_z_down_10->SetFont(::Label::Body_12); + m_bpButton_z_down_10->SetBorderWidth(0); + 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->SetSize(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_10, 0, wxEXPAND | wxALL, 0); + bSizer_z_ctrl->Add(m_bpButton_z_1, 0, wxEXPAND | wxALL, 0); + bSizer_z_ctrl->Add(m_staticText_z_tip, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, FromDIP(17)); + bSizer_z_ctrl->Add(m_bpButton_z_down_1, 0, wxEXPAND | wxALL, 0); + bSizer_z_ctrl->Add(m_bpButton_z_down_10, 0, wxEXPAND | wxALL, 0); panel->SetSizer(bSizer_z_ctrl); panel->Layout(); - sizer->Add(panel, 1, wxEXPAND, 0); + panel->Fit(); - return sizer; + return panel; } wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent) @@ -1516,40 +1808,40 @@ wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent) wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *bSizer_e_ctrl = new wxBoxSizer(wxVERTICAL); auto panel = new wxPanel(parent,wxID_ANY); + panel->SetBackgroundColour(*wxWHITE); - - - panel->SetSize(wxSize(FromDIP(52), -1)); - panel->SetMinSize(wxSize(FromDIP(52), -1)); - panel->SetMaxSize(wxSize(FromDIP(52), -1)); + panel->SetSize(wxSize(FromDIP(143), -1)); + panel->SetMinSize(wxSize(FromDIP(143), -1)); + panel->SetMaxSize(wxSize(FromDIP(143), -1)); StateColor e_ctrl_bg(std::pair(BUTTON_PRESS_COL, StateColor::Pressed), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); StateColor e_ctrl_bd(std::pair(BUTTON_HOVER_COL, StateColor::Hovered), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); + + m_left_right_btn_panel = new SwitchBoard(panel, _L("Left"), _L("Right"), wxSize(FromDIP(126), FromDIP(26))); + m_bpButton_e_10 = new Button(panel, "", "monitor_extruder_up", 0, FromDIP(22)); m_bpButton_e_10->SetBorderWidth(2); m_bpButton_e_10->SetBackgroundColor(e_ctrl_bg); m_bpButton_e_10->SetBorderColor(e_ctrl_bd); m_bpButton_e_10->SetMinSize(wxSize(FromDIP(40), FromDIP(40))); - bSizer_e_ctrl->AddStretchSpacer(); - bSizer_e_ctrl->Add(m_bpButton_e_10, 0, wxALIGN_CENTER_HORIZONTAL, 0); - bSizer_e_ctrl->Add(0, FromDIP(7), 0, 0, 0); + m_extruder_book = new wxSimplebook(panel, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(45), FromDIP(112)), 0); - m_bitmap_extruder_img = new wxStaticBitmap(panel, wxID_ANY, m_bitmap_extruder_empty_load, wxDefaultPosition, wxDefaultSize, 0); - m_bitmap_extruder_img->SetMinSize(EXTRUDER_IMAGE_SIZE); + m_extruder_book->InsertPage(0, new wxPanel(panel), ""); + for (int nozzle_num = 1; nozzle_num <= 2; nozzle_num++) { + auto extruder_img = new ExtruderImage(m_extruder_book, wxID_ANY, nozzle_num); + m_extruder_book->InsertPage(nozzle_num, extruder_img, ""); + m_extruderImage.push_back(extruder_img); + } + m_extruder_book->SetSelection(0); - bSizer_e_ctrl->Add(m_bitmap_extruder_img, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, FromDIP(5)); - bSizer_e_ctrl->Add(0, FromDIP(7), 0, 0, 0); m_bpButton_e_down_10 = new Button(panel, "", "monitor_extruder_down", 0, FromDIP(22)); m_bpButton_e_down_10->SetBorderWidth(2); m_bpButton_e_down_10->SetBackgroundColor(e_ctrl_bg); m_bpButton_e_down_10->SetBorderColor(e_ctrl_bd); m_bpButton_e_down_10->SetMinSize(wxSize(FromDIP(40), FromDIP(40))); - bSizer_e_ctrl->Add(m_bpButton_e_down_10, 0, wxALIGN_CENTER_HORIZONTAL, 0); - - - m_button_unload = new Button(panel, _L("Unload")); + /*m_button_unload = new Button(panel, _L("Unload")); StateColor abort_bg(std::pair(wxColour(255, 255, 255), StateColor::Disabled), std::pair(wxColour(206, 206, 206), StateColor::Pressed), std::pair(wxColour(238, 238, 238), StateColor::Hovered), std::pair(wxColour(255, 255, 255), StateColor::Enabled), @@ -1563,20 +1855,26 @@ wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent) m_button_unload->SetMinSize(wxSize(-1, FromDIP(24))); m_button_unload->SetCornerRadius(FromDIP(12)); bSizer_e_ctrl->Add(0, 0, 1, wxEXPAND, 0); - bSizer_e_ctrl->Add(m_button_unload, 0, wxALIGN_CENTER_HORIZONTAL| wxTOP|wxBOTTOM, FromDIP(5)); + bSizer_e_ctrl->Add(m_button_unload, 0, wxALIGN_CENTER_HORIZONTAL| wxTOP|wxBOTTOM, FromDIP(5));*/ + m_extruder_label = new ::Label(panel, _L("Extruder")); + m_extruder_label->SetFont(::Label::Body_13); + m_extruder_label->SetForegroundColour(TEXT_LIGHT_FONT_COL); - bSizer_e_ctrl->Add(0, FromDIP(9), 0, wxEXPAND, 0); - - m_staticText_e = new wxStaticText(panel, wxID_ANY, _L("Extruder"), wxDefaultPosition, wxDefaultSize, 0); - m_staticText_e->SetFont(::Label::Body_13); - m_staticText_e->Wrap(-1); - m_staticText_e->SetForegroundColour(TEXT_LIGHT_FONT_COL); - bSizer_e_ctrl->Add(m_staticText_e, 0, wxBOTTOM | wxALIGN_CENTER_HORIZONTAL, FromDIP(5)); + bSizer_e_ctrl->Add(0, 0, 0, wxTOP, FromDIP(15)); + bSizer_e_ctrl->Add(m_left_right_btn_panel, 0, wxALIGN_CENTER_HORIZONTAL, 0); + bSizer_e_ctrl->Add(0, 0, 0, wxTOP, FromDIP(15)); + bSizer_e_ctrl->Add(m_bpButton_e_10, 0, wxALIGN_CENTER_HORIZONTAL, 0); + bSizer_e_ctrl->Add(0, 0, 0, wxTOP, FromDIP(7)); + bSizer_e_ctrl->Add(m_extruder_book, 0, wxALIGN_CENTER_HORIZONTAL, 0); + bSizer_e_ctrl->Add(0, 0, 0, wxTOP, FromDIP(7)); + bSizer_e_ctrl->Add(m_bpButton_e_down_10, 0, wxALIGN_CENTER_HORIZONTAL, 0); + bSizer_e_ctrl->Add(0, 0, 1, wxEXPAND, 0); + bSizer_e_ctrl->Add(m_extruder_label, 0, wxBOTTOM | wxALIGN_CENTER_HORIZONTAL, FromDIP(5)); + bSizer_e_ctrl->Add(0, 0, 0, wxTOP, FromDIP(8)); panel->SetSizer(bSizer_e_ctrl); panel->Layout(); sizer->Add(panel, 1, wxEXPAND, 0); - return sizer; } @@ -1713,7 +2011,7 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co , m_fan_control_popup(new FanControlPopup(this)) { init_scaled_buttons(); - m_buttons.push_back(m_button_unload); + //m_buttons.push_back(m_button_unload); m_buttons.push_back(m_bpButton_z_10); m_buttons.push_back(m_bpButton_z_1); m_buttons.push_back(m_bpButton_z_down_1); @@ -1729,6 +2027,7 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co m_switch_printing_fan->SetValue(false); m_switch_nozzle_fan->SetValue(false); m_switch_cham_fan->SetValue(false); + //m_switch_fan->SetValue(false); /* set default enable state */ m_project_task_panel->enable_pause_resume_button(false, "resume_disable"); @@ -1769,6 +2068,11 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co 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); + //m_switch_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); + m_bpButton_xy->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_xy), NULL, this); // TODO m_bpButton_z_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_10), NULL, this); m_bpButton_z_1->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_1), NULL, this); @@ -1776,7 +2080,7 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co m_bpButton_z_down_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_down_10), NULL, this); m_bpButton_e_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_up_10), NULL, this); m_bpButton_e_down_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_down_10), NULL, this); - m_button_unload->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_unload), NULL, this); + //m_button_unload->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_unload), NULL, this); Bind(EVT_AMS_EXTRUSION_CALI, &StatusPanel::on_filament_extrusion_cali, this); Bind(EVT_AMS_LOAD, &StatusPanel::on_ams_load, this); Bind(EVT_AMS_UNLOAD, &StatusPanel::on_ams_unload, this); @@ -1826,6 +2130,11 @@ StatusPanel::~StatusPanel() 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_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); m_bpButton_z_1->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_1), NULL, this); @@ -1837,7 +2146,7 @@ StatusPanel::~StatusPanel() m_calibration_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this); m_options_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_show_print_options), NULL, this); m_parts_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_show_parts_options), NULL, this); - m_button_unload->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_unload), NULL, this); + //m_button_unload->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_unload), NULL, this); // remove warning dialogs if (m_print_error_dlg != nullptr) @@ -1860,8 +2169,8 @@ StatusPanel::~StatusPanel() void StatusPanel::init_scaled_buttons() { m_project_task_panel->init_scaled_buttons(); - m_button_unload->SetMinSize(wxSize(-1, FromDIP(24))); - m_button_unload->SetCornerRadius(FromDIP(12)); + //m_button_unload->SetMinSize(wxSize(-1, FromDIP(24))); + //m_button_unload->SetCornerRadius(FromDIP(12)); m_bpButton_z_10->SetMinSize(Z_BUTTON_SIZE); m_bpButton_z_10->SetCornerRadius(0); m_bpButton_z_1->SetMinSize(Z_BUTTON_SIZE); @@ -2096,6 +2405,9 @@ void StatusPanel::update(MachineObject *obj) update_cali(obj); if (obj) { + //nozzle ui + //m_button_left_of_extruder->SetSelected(); + // update extrusion calibration if (m_extrusion_cali_dlg) { m_extrusion_cali_dlg->update_machine_obj(obj); @@ -2306,8 +2618,8 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) m_bpButton_e_down_10->SetIcon("monitor_extrduer_down_disable"); m_staticText_z_tip->SetForegroundColour(DISCONNECT_TEXT_COL); - m_staticText_e->SetForegroundColour(DISCONNECT_TEXT_COL); - m_button_unload->Enable(false); + m_extruder_label->SetForegroundColour(DISCONNECT_TEXT_COL); + //m_button_unload->Enable(false); m_switch_speed->SetValue(false); } else { m_switch_speed->Enable(); @@ -2315,6 +2627,9 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) m_switch_nozzle_fan->Enable(); m_switch_printing_fan->Enable(); m_switch_cham_fan->Enable(); + + //m_switch_fan->Enable(); + m_bpButton_xy->Enable(); m_bpButton_z_10->Enable(); m_bpButton_z_1->Enable(); @@ -2331,13 +2646,14 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) m_bpButton_e_down_10->SetIcon("monitor_extrduer_down"); m_staticText_z_tip->SetForegroundColour(TEXT_LIGHT_FONT_COL); - m_staticText_e->SetForegroundColour(TEXT_LIGHT_FONT_COL); - m_button_unload->Enable(); + m_extruder_label->SetForegroundColour(TEXT_LIGHT_FONT_COL); + //m_button_unload->Enable(); m_switch_speed->SetValue(true); } if (!temp_area) { m_tempCtrl_nozzle->Enable(false); + m_tempCtrl_nozzle_deputy->Enable(false); m_tempCtrl_bed->Enable(false); m_tempCtrl_chamber->Enable(false); m_switch_speed->Enable(false); @@ -2346,8 +2662,10 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) m_switch_nozzle_fan->Enable(false); m_switch_printing_fan->Enable(false); m_switch_cham_fan->Enable(false); + //m_switch_fan->Enable(false); } else { m_tempCtrl_nozzle->Enable(); + m_tempCtrl_nozzle_deputy->Enable(); m_tempCtrl_bed->Enable(); m_tempCtrl_chamber->Enable(); m_switch_speed->Enable(); @@ -2356,6 +2674,7 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) m_switch_nozzle_fan->Enable(); m_switch_printing_fan->Enable(); m_switch_cham_fan->Enable(); + //m_switch_fan->Enable(); } } @@ -2363,6 +2682,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) { if (!obj) return; + int nozzle_num = obj->m_extder_data.total_extder_count; m_tempCtrl_bed->SetCurrTemp((int) obj->bed_temp); m_tempCtrl_bed->SetMaxTemp(obj->get_bed_temperature_limit()); @@ -2380,11 +2700,14 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) } m_tempCtrl_nozzle->SetCurrTemp((int) obj->m_extder_data.extders[0].temp); + if(nozzle_num == 2 && obj->m_extder_data.extders.size() > 1) m_tempCtrl_nozzle_deputy->SetCurrTemp((int)obj->m_extder_data.extders[0].temp); if (obj->nozzle_max_temperature > -1) { if (m_tempCtrl_nozzle) m_tempCtrl_nozzle->SetMaxTemp(obj->nozzle_max_temperature); + if (m_tempCtrl_nozzle_deputy && nozzle_num >= 2) m_tempCtrl_nozzle_deputy->SetMaxTemp(obj->nozzle_max_temperature); } else { if (m_tempCtrl_nozzle) m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]); + if (m_tempCtrl_nozzle_deputy && nozzle_num >= 2) m_tempCtrl_nozzle_deputy->SetMaxTemp(nozzle_temp_range[1]); } if (m_temp_nozzle_timeout > 0) { @@ -2393,12 +2716,28 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) if (!nozzle_temp_input) { m_tempCtrl_nozzle->SetTagTemp((int) obj->m_extder_data.extders[0].target_temp); } } + if (m_temp_nozzle_deputy_timeout > 0) { + m_temp_nozzle_deputy_timeout--; + } + else { + if (!nozzle_temp_input && nozzle_num >= 2) { m_tempCtrl_nozzle_deputy->SetTagTemp((int)obj->m_extder_data.extders[0].target_temp); } + } + if ((obj->m_extder_data.extders[0].target_temp - obj->m_extder_data.extders[0].temp) >= TEMP_THRESHOLD_VAL) { m_tempCtrl_nozzle->SetIconActive(); } else { m_tempCtrl_nozzle->SetIconNormal(); } + if (nozzle_num >= 2 && obj->m_extder_data.extders.size() > 1){ + if ((obj->m_extder_data.extders[1].target_temp - obj->m_extder_data.extders[1].temp) >= TEMP_THRESHOLD_VAL) { + m_tempCtrl_nozzle_deputy->SetIconActive(); + } + else { + m_tempCtrl_nozzle_deputy->SetIconNormal(); + } + } + m_tempCtrl_chamber->SetCurrTemp(obj->chamber_temp); // update temprature if not input temp target if (m_temp_chamber_timeout > 0) { @@ -2420,18 +2759,51 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj) { if (!obj) return; - if (obj->can_unload_filament()) { - if (!m_button_unload->IsShown()) { - m_button_unload->Show(); - m_button_unload->GetParent()->Layout(); + /*extder*/ + m_nozzle_num = obj->m_extder_data.total_extder_count; + int select_index = m_nozzle_num - 1; + + if (m_nozzle_num >= 2) { + m_extruder_book->SetSelection(m_nozzle_num); + + /*style*/ + if (m_nozzle_num == 2) { + m_left_right_btn_panel->Show(); + } else { + m_left_right_btn_panel->Hide(); } + + m_extruderImage[select_index]->setExtruderCount(m_nozzle_num); + m_extruderImage[select_index]->update(ExtruderState::FILLED_LOAD, ExtruderState::FILLED_UNLOAD); + + /*current*/ + if (obj->m_extder_data.current_extder_id == 0xf) { + m_extruderImage[select_index]->setExtruderUsed(""); + m_left_right_btn_panel->updateState(""); + } else if (obj->m_extder_data.current_extder_id == MAIN_NOZZLE_ID) { + m_extruderImage[select_index]->setExtruderUsed("right"); + m_left_right_btn_panel->updateState("right"); + } else if (obj->m_extder_data.current_extder_id == DEPUTY_NOZZLE_ID) { + m_extruderImage[select_index]->setExtruderUsed("left"); + m_left_right_btn_panel->updateState("left"); + } + Layout(); } else { - if (m_button_unload->IsShown()) { - m_button_unload->Hide(); - m_button_unload->GetParent()->Layout(); - } + m_extruder_book->SetSelection(m_nozzle_num); + m_extruderImage[select_index]->setExtruderCount(m_nozzle_num); } + /*switch extder*/ + /*for (auto i = 0; i < obj->m_extder_data.extders.size(); i++) { + obj->m_extder_data.extders[i].ams_stat; + }*/ + + + + + //m_extruder_label = new ::Label(panel, _L("Extruder")); + + /*other*/ if (obj->is_core_xy()) { m_staticText_z_tip->SetLabel(_L("Bed")); } else { @@ -2552,20 +2924,27 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj) void StatusPanel::update_extruder_status(MachineObject* obj) { if (!obj) return; + wxBitmap tmp; if (obj->is_filament_at_extruder()) { if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) { - m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_filled_load); + tmp = m_bitmap_extruder_filled_load; } else { - m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_filled_unload); + tmp = m_bitmap_extruder_filled_unload; } } else { if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) { - m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_load); - } else { - m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_unload); + tmp = m_bitmap_extruder_empty_load; } + 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); } } @@ -2652,7 +3031,7 @@ void StatusPanel::update_ams(MachineObject *obj) ext_info.push_back(info); } std::string dev_id = obj->dev_id; - NozzleData data = obj->m_nozzle_data; + ExtderData data = obj->m_extder_data; //if (obj->ams_exist_bits != last_ams_exist_bits || obj->tray_exist_bits != last_tray_exist_bits || obj->tray_is_bbl_bits != last_tray_is_bbl_bits || // obj->tray_read_done_bits != last_read_done_bits || obj->ams_version != last_ams_version) { // m_ams_control->UpdateAms(ams_info, false); @@ -3475,6 +3854,9 @@ void StatusPanel::on_set_bed_temp() void StatusPanel::on_set_nozzle_temp() { wxString str = m_tempCtrl_nozzle->GetTextCtrl()->GetValue(); + wxString str_deputy; + int nozzle_num = obj->m_extder_data.total_extder_count; + if (nozzle_num >= 2) str_deputy = m_tempCtrl_nozzle_deputy->GetTextCtrl()->GetValue(); try { long nozzle_temp; if (str.ToLong(&nozzle_temp) && obj) { @@ -3486,6 +3868,15 @@ void StatusPanel::on_set_nozzle_temp() } obj->command_set_nozzle(nozzle_temp); } + if (nozzle_num >= 2 && str_deputy.ToLong(&nozzle_temp) && obj) { + //set_hold_count(m_temp_nozzle_deputy_timeout); + if (nozzle_temp > m_tempCtrl_nozzle_deputy->get_max_temp()) { + nozzle_temp = m_tempCtrl_nozzle_deputy->get_max_temp(); + m_tempCtrl_nozzle_deputy->SetTagTemp(wxString::Format("%d", nozzle_temp)); + m_tempCtrl_nozzle_deputy->Warning(false); + } + obj->command_set_nozzle(nozzle_temp); + } } catch (...) { ; } @@ -3976,6 +4367,8 @@ 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; if (type == MachineObject::FanType::COOLING_FAN) { set_hold_count(this->m_switch_nozzle_fan_timeout); @@ -4498,19 +4891,23 @@ void StatusPanel::msw_rescale() m_bpButton_xy->SetSize(AXIS_MIN_SIZE); m_temp_extruder_line->SetSize(wxSize(FromDIP(1), -1)); update_extruder_status(obj); - m_bitmap_extruder_img->SetMinSize(EXTRUDER_IMAGE_SIZE); + //m_bitmap_extruder_img->SetMinSize(EXTRUDER_IMAGE_SIZE); for (Button *btn : m_buttons) { btn->Rescale(); } init_scaled_buttons(); m_bpButton_xy->Rescale(); - m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE); + auto size = TEMP_CTRL_MIN_SIZE_OF_SINGLE_NOZZLE; + if (obj->m_extder_data.total_extder_count >= 2) size = TEMP_CTRL_MIN_SIZE_OF_DOUBLE_NOZZLE; + m_tempCtrl_nozzle->SetMinSize(size); m_tempCtrl_nozzle->Rescale(); + m_tempCtrl_nozzle_deputy->SetMinSize(size); + m_tempCtrl_nozzle_deputy->Rescale(); m_line_nozzle->SetSize(wxSize(-1, FromDIP(1))); - m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE); + m_tempCtrl_bed->SetMinSize(size); m_tempCtrl_bed->Rescale(); - m_tempCtrl_chamber->SetMinSize(TEMP_CTRL_MIN_SIZE); + m_tempCtrl_chamber->SetMinSize(size); m_tempCtrl_chamber->Rescale(); m_bitmap_speed.msw_rescale(); @@ -4529,6 +4926,9 @@ void StatusPanel::msw_rescale() m_switch_cham_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off); m_switch_cham_fan->Rescale(); + //m_switch_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off); + //m_switch_fan->Rescale(); + m_ams_control->msw_rescale(); // m_filament_step->Rescale(); diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index 287858de9a..2bbba9e5da 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -62,6 +62,13 @@ enum PrintingTaskType { NOT_CLEAR }; +enum ExtruderState { + FILLED_LOAD, + FILLED_UNLOAD, + EMPTY_LOAD, + EMPTY_UNLOAD +}; + struct ScoreData { int rating_id; @@ -78,6 +85,58 @@ struct ScoreData typedef std::function OnGetSubTaskFn; +class ExtruderImage : public wxWindow +{ + ScalableBitmap *m_pipe_filled_load; + ScalableBitmap *m_pipe_filled_unload; + ScalableBitmap *m_pipe_empty_load; + ScalableBitmap *m_pipe_empty_unload; + + ScalableBitmap *m_pipe_filled_load_unselected; + ScalableBitmap *m_pipe_filled_unload_unselected; + ScalableBitmap *m_pipe_empty_load_unselected; + ScalableBitmap *m_pipe_empty_unload_unselected; + + ScalableBitmap *m_left_extruder_active_filled; + ScalableBitmap *m_left_extruder_active_empty; + ScalableBitmap *m_left_extruder_unactive_filled; + ScalableBitmap *m_left_extruder_unactive_empty; + ScalableBitmap *m_right_extruder_active_filled; + ScalableBitmap *m_right_extruder_active_empty; + ScalableBitmap *m_right_extruder_unactive_filled; + ScalableBitmap *m_right_extruder_unactive_empty; + + ScalableBitmap *m_extruder_single_nozzle_empty_load; + ScalableBitmap *m_extruder_single_nozzle_empty_unload; + ScalableBitmap *m_extruder_single_nozzle_filled_load; + ScalableBitmap *m_extruder_single_nozzle_filled_unload; + + ExtruderState m_left_ext_state = {ExtruderState::EMPTY_LOAD}; + ExtruderState m_right_ext_state = {ExtruderState::EMPTY_LOAD}; + ExtruderState m_single_ext_state = {ExtruderState::EMPTY_LOAD}; + +public: + void update(int nozzle_num, int nozzle_id); + void update(ExtruderState right_state, ExtruderState left_state); + void msw_rescale(); + void setExtruderCount(int nozzle_num); + void setExtruderUsed(std::string loc); + void paintEvent(wxPaintEvent &evt); + + void render(wxDC &dc); + bool m_show_state = {false}; + int m_nozzle_num = 1; + int current_nozzle_idx = 0; + std::string current_nozzle_loc = ""; + wxColour m_colour; + + string m_file_name; + bool m_ams_loading{false}; + void doRender(wxDC &dc); + ExtruderImage(wxWindow *parent, wxWindowID id, int nozzle_num, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize); + ~ExtruderImage(); +}; + class ScoreDialog : public GUI::DPIDialog { public: @@ -273,6 +332,7 @@ protected: wxBitmap m_bitmap_extruder_filled_load; wxBitmap m_bitmap_extruder_empty_unload; wxBitmap m_bitmap_extruder_filled_unload; + wxBitmap m_bitmap_extruder_now; CameraRecordingStatus m_state_recording{CameraRecordingStatus::RECORDING_NONE}; CameraTimelapseStatus m_state_timelapse{CameraTimelapseStatus::TIMELAPSE_NONE}; @@ -332,6 +392,9 @@ protected: ScalableButton *m_button_abort; Button * m_button_clean; wxWebView * m_custom_camera_view{nullptr}; + wxSimplebook* m_extruder_book; + std::vector m_extruderImage; + SwitchBoard * m_left_right_btn_panel; wxStaticText * m_text_tasklist_caption; @@ -346,6 +409,8 @@ protected: StaticLine * m_line_nozzle; TempInput* m_tempCtrl_nozzle; int m_temp_nozzle_timeout{ 0 }; + TempInput* m_tempCtrl_nozzle_deputy; + int m_temp_nozzle_deputy_timeout{ 0 }; TempInput * m_tempCtrl_bed; int m_temp_bed_timeout {0}; TempInput * m_tempCtrl_chamber; @@ -357,8 +422,11 @@ protected: FanSwitchButton *m_switch_printing_fan; int m_switch_printing_fan_timeout{0}; FanSwitchButton *m_switch_cham_fan; + FanSwitchButton *m_switch_fan; int m_switch_cham_fan_timeout{0}; wxPanel* m_switch_block_fan; + int m_nozzle_num{ 0 }; + int m_current_nozzle_id{ 0 }; float m_fixed_aspect_ratio{1.8}; @@ -368,12 +436,13 @@ protected: Button * m_bpButton_z_1; Button * m_bpButton_z_down_1; Button * m_bpButton_z_down_10; - Button * m_button_unload; + //Button * m_button_unload; wxStaticText * m_staticText_z_tip; - wxStaticText * m_staticText_e; + Label * m_extruder_label; Button * m_bpButton_e_10; Button * m_bpButton_e_down_10; - StaticLine * m_temp_extruder_line; + wxPanel * m_temp_temp_line; + wxPanel * m_temp_extruder_line; wxBoxSizer* m_ams_list; wxStaticText * m_ams_debug; bool m_show_ams_group{false}; @@ -381,6 +450,7 @@ protected: StaticBox* m_ams_control_box; wxStaticBitmap *m_ams_extruder_img; wxStaticBitmap* m_bitmap_extruder_img; + wxPanel * m_panel_separator_right; wxPanel * m_panel_separotor_bottom; wxGridBagSizer *m_tasklist_info_sizer{nullptr}; @@ -444,7 +514,7 @@ public: wxBoxSizer *create_temp_control(wxWindow *parent); wxBoxSizer *create_misc_control(wxWindow *parent); wxBoxSizer *create_axis_control(wxWindow *parent); - wxBoxSizer *create_bed_control(wxWindow *parent); + wxPanel *create_bed_control(wxWindow *parent); wxBoxSizer *create_extruder_control(wxWindow *parent); void reset_temp_misc_control(); diff --git a/src/slic3r/GUI/Widgets/ImageSwitchButton.cpp b/src/slic3r/GUI/Widgets/ImageSwitchButton.cpp index af48b6d27a..763aec2308 100644 --- a/src/slic3r/GUI/Widgets/ImageSwitchButton.cpp +++ b/src/slic3r/GUI/Widgets/ImageSwitchButton.cpp @@ -272,7 +272,26 @@ void FanSwitchButton::render(wxDC& dc) ScalableBitmap& icon = GetValue() ? m_on : m_off; //int content_height = icon.GetBmpHeight() + textSize.y + m_padding; - int content_height = m_padding; + + wxPoint pt = wxPoint(FromDIP(10), (size.y - icon.GetBmpHeight()) / 2); + + if (icon.bmp().IsOk()) { + dc.DrawBitmap(icon.bmp(), pt); + pt.x += icon.GetBmpWidth() + FromDIP(9); + } + + wxString fan_txt = "Fan"; + dc.SetFont(::Label::Head_15); + pt.y = FromDIP(9); + dc.DrawText(fan_txt, pt); + pt.y = size.y / 2 + FromDIP(3); + wxString fan_num_txt = GetLabel(); + dc.SetFont(::Label::Body_11); + dc.DrawText(fan_num_txt, pt); + + + //int content_height = icon.GetBmpHeight() + textSize.y + m_padding; + /*int content_height = m_padding; wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2); @@ -315,7 +334,7 @@ void FanSwitchButton::render(wxDC& dc) pt.x = (size.x - dc.GetTextExtent(speed).x) / 2; pt.y += FromDIP(1); - dc.DrawText(speed, pt); + dc.DrawText(speed, pt);*/ } void FanSwitchButton::Rescale() diff --git a/src/slic3r/GUI/Widgets/SwitchButton.cpp b/src/slic3r/GUI/Widgets/SwitchButton.cpp index b30f473a46..90f040a85b 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.cpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.cpp @@ -155,3 +155,122 @@ void SwitchButton::update() { SetBitmap((GetValue() ? m_on : m_off).bmp()); } + +SwitchBoard::SwitchBoard(wxWindow *parent, wxString leftL, wxString right, wxSize size) + : wxWindow(parent, wxID_ANY, wxDefaultPosition, size) +{ +#ifdef __WINDOWS__ + SetDoubleBuffered(true); +#endif //__WINDOWS__ + + SetBackgroundColour(*wxWHITE); + leftLabel = leftL; + rightLabel = right; + + SetMinSize(size); + SetMaxSize(size); + + Bind(wxEVT_PAINT, &SwitchBoard::paintEvent, this); + Bind(wxEVT_LEFT_DOWN, &SwitchBoard::on_left_down, this); + + Bind(wxEVT_ENTER_WINDOW, [this](auto &e) { SetCursor(wxCURSOR_HAND); }); + Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) { SetCursor(wxCURSOR_ARROW); }); +} + +void SwitchBoard::updateState(wxString target) +{ + if (target.empty()) { + switch_left = false; + switch_right = false; + } else { + if (target == "left") { + switch_left = true; + switch_right = false; + } else if (target == "right") { + switch_left = false; + switch_right = true; + } + } + Refresh(); +} + +void SwitchBoard::paintEvent(wxPaintEvent &evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void SwitchBoard::render(wxDC &dc) +{ +#ifdef __WXMSW__ + wxSize size = GetSize(); + wxMemoryDC memdc; + wxBitmap bmp(size.x, size.y); + memdc.SelectObject(bmp); + memdc.Blit({0, 0}, size, &dc, {0, 0}); + + { + wxGCDC dc2(memdc); + doRender(dc2); + } + + memdc.SelectObject(wxNullBitmap); + dc.DrawBitmap(bmp, 0, 0); +#else + doRender(dc); +#endif +} + +void SwitchBoard::doRender(wxDC &dc) +{ + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(wxBrush(0xeeeeee)); + dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 8); + + /*left*/ + if (switch_left) { + dc.SetBrush(wxBrush(wxColour(0, 174, 66))); + dc.DrawRoundedRectangle(0, 0, GetSize().x / 2, GetSize().y, 8); + } + + auto left_txt_size = dc.GetTextExtent(leftLabel); + dc.SetFont(::Label::Body_13); + if (switch_left) { + dc.SetTextForeground(*wxWHITE); + } else { + dc.SetTextForeground(0x333333); + } + + dc.DrawText(leftLabel, wxPoint((GetSize().x / 2 - left_txt_size.x) / 2, (GetSize().y - left_txt_size.y) / 2)); + + /*right*/ + if (switch_right) { + dc.SetBrush(wxBrush(wxColour(0, 174, 66))); + dc.DrawRoundedRectangle(GetSize().x / 2, 0, GetSize().x / 2, GetSize().y, 8); + } + + auto right_txt_size = dc.GetTextExtent(rightLabel); + dc.SetFont(::Label::Body_13); + if (switch_right) { + dc.SetTextForeground(*wxWHITE); + } else { + dc.SetTextForeground(0x333333); + } + dc.DrawText(rightLabel, wxPoint((GetSize().x / 2 - left_txt_size.x) / 2 + GetSize().x / 2, (GetSize().y - right_txt_size.y) / 2)); + +} + +void SwitchBoard::on_left_down(wxMouseEvent &evt) +{ + auto pos = ClientToScreen(evt.GetPosition()); + auto rect = ClientToScreen(wxPoint(0, 0)); + + if (pos.x > 0 && pos.x < rect.x + GetSize().x / 2) { + switch_left = true; + switch_right = false; + } else { + switch_left = false; + switch_right = true; + } + Refresh(); +} \ No newline at end of file diff --git a/src/slic3r/GUI/Widgets/SwitchButton.hpp b/src/slic3r/GUI/Widgets/SwitchButton.hpp index 71436d13e1..cfc1991186 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.hpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.hpp @@ -5,6 +5,8 @@ #include "StateColor.hpp" #include +#include "Label.hpp" +#include "Button.hpp" class SwitchButton : public wxBitmapToggleButton { @@ -40,4 +42,23 @@ private: StateColor thumb_color; }; +class SwitchBoard : public wxWindow +{ +public: + SwitchBoard(wxWindow *parent = NULL, wxString leftL = "", wxString right = "", wxSize size = wxDefaultSize); + wxString leftLabel; + wxString rightLabel; + + void updateState(wxString target); + + bool switch_left{false}; + bool switch_right{false}; + +public: + void paintEvent(wxPaintEvent &evt); + void render(wxDC &dc); + void doRender(wxDC &dc); + void on_left_down(wxMouseEvent &evt); +}; + #endif // !slic3r_GUI_SwitchButton_hpp_ diff --git a/src/slic3r/GUI/Widgets/TempInput.cpp b/src/slic3r/GUI/Widgets/TempInput.cpp index 37ed6f2fa6..e1fcf813a0 100644 --- a/src/slic3r/GUI/Widgets/TempInput.cpp +++ b/src/slic3r/GUI/Widgets/TempInput.cpp @@ -31,11 +31,12 @@ TempInput::TempInput() SetFont(Label::Body_12); } -TempInput::TempInput(wxWindow *parent, int type, wxString text, wxString label, wxString normal_icon, wxString actice_icon, const wxPoint &pos, const wxSize &size, long style) +TempInput::TempInput(wxWindow *parent, int type, wxString text, TempInputType input_type, wxString label, wxString normal_icon, wxString actice_icon, const wxPoint &pos, const wxSize &size, long style) : TempInput() { actice = false; temp_type = type; + m_input_type = input_type; Create(parent, text, label, normal_icon, actice_icon, pos, size, style); } @@ -120,6 +121,8 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString text_ctrl->SetForegroundColour(StateColor::darkModeColorFor(*wxBLACK)); if (!normal_icon.IsEmpty()) { this->normal_icon = ScalableBitmap(this, normal_icon.ToStdString(), 16); } if (!actice_icon.IsEmpty()) { this->actice_icon = ScalableBitmap(this, actice_icon.ToStdString(), 16); } + this->left_icon = ScalableBitmap(this, "L", 16); + this->right_icon = ScalableBitmap(this, "R", 16); this->degree_icon = ScalableBitmap(this, "degree", 16); messureSize(); } @@ -184,6 +187,10 @@ void TempInput::SetCurrTemp(wxString temp) SetLabel(temp); } +void TempInput::SetCurrType(TempInputType type) { + m_input_type = type; +} + void TempInput::Warning(bool warn, WarningType type) { warning_mode = warn; @@ -282,6 +289,8 @@ void TempInput::Rescale() { if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale(); if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_rescale(); + if (this->left_icon.bmp().IsOk()) this->left_icon.msw_rescale(); + if (this->right_icon.bmp().IsOk()) this->right_icon.msw_rescale(); messureSize(); } @@ -314,6 +323,7 @@ void TempInput::DoSetSize(int x, int y, int width, int height, int sizeFlags) wxWindow::DoSetSize(x, y, width, height, sizeFlags); if (sizeFlags & wxSIZE_USE_EXISTING) return; + padding_left = FromDIP(10); auto left = padding_left; wxClientDC dc(this); if (normal_icon.bmp().IsOk()) { @@ -324,6 +334,11 @@ void TempInput::DoSetSize(int x, int y, int width, int height, int sizeFlags) // interval left += 9; + if (m_input_type == TEMP_OF_MAIN_NOZZLE_TYPE || m_input_type == TEMP_OF_DEPUTY_NOZZLE_TYPE) { + wxSize szIcon = left_icon.GetBmpSize(); + left += szIcon.x + 3; + } + // label dc.SetFont(::Label::Head_14); labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel()); @@ -377,21 +392,53 @@ void TempInput::render(wxDC &dc) dc.SetBrush(*wxTRANSPARENT_BRUSH); // start draw + padding_left = FromDIP(10); wxPoint pt = {padding_left, 0}; - if (actice_icon.bmp().IsOk() && actice) { - wxSize szIcon = actice_icon.GetBmpSize(); - pt.y = (size.y - szIcon.y) / 2; - dc.DrawBitmap(actice_icon.bmp(), pt); - pt.x += szIcon.x + 9; - } else { - actice = false; + wxSize szIcon; + if (normal_icon.bmp().IsOk()) szIcon = normal_icon.GetBmpSize(); + else if (actice_icon.bmp().IsOk()) szIcon = actice_icon.GetBmpSize(); + + if (m_input_type != TEMP_OF_DEPUTY_NOZZLE_TYPE) { + if (actice_icon.bmp().IsOk() && actice) { + szIcon = actice_icon.GetBmpSize(); + pt.y = (size.y - szIcon.y) / 2; + dc.DrawBitmap(actice_icon.bmp(), pt); + } + else { + actice = false; + } + if (normal_icon.bmp().IsOk() && !actice) { + szIcon = normal_icon.GetBmpSize(); + pt.y = (size.y - szIcon.y) / 2; + dc.DrawBitmap(normal_icon.bmp(), pt); + } } - if (normal_icon.bmp().IsOk() && !actice) { - wxSize szIcon = normal_icon.GetBmpSize(); - pt.y = (size.y - szIcon.y) / 2; - dc.DrawBitmap(normal_icon.bmp(), pt); - pt.x += szIcon.x + 9; + pt.x += szIcon.x + 9; + if (left_icon.bmp().IsOk() && m_input_type == TEMP_OF_DEPUTY_NOZZLE_TYPE){ + wxSize szIcon = left_icon.GetBmpSize(); + pt.y = (size.y - szIcon.y) / 2; + dc.DrawBitmap(left_icon.bmp(), pt); + + dc.SetFont(::Label::Body_12); + auto sepSize = dc.GetMultiLineTextExtent(wxString("L")); + dc.SetTextForeground(*wxWHITE); + dc.SetTextBackground(*wxWHITE); + dc.DrawText(wxString("L"), pt.x + (szIcon.x - sepSize.x) / 2, (size.y - sepSize.y) / 2); + pt.x += szIcon.x + 3; + } + + if (right_icon.bmp().IsOk() && m_input_type == TEMP_OF_MAIN_NOZZLE_TYPE) { + wxSize szIcon = right_icon.GetBmpSize(); + pt.y = (size.y - szIcon.y) / 2; + dc.DrawBitmap(right_icon.bmp(), pt); + + dc.SetFont(::Label::Body_12); + auto sepSize = dc.GetMultiLineTextExtent(wxString("L")); + dc.SetTextForeground(*wxWHITE); + dc.SetTextBackground(*wxWHITE); + dc.DrawText(wxString("R"), pt.x + (szIcon.x - sepSize.x) / 2, (size.y - sepSize.y) / 2); + pt.x += szIcon.x + 3; } // label @@ -460,6 +507,12 @@ void TempInput::messureMiniSize() // interval width += 9; + if (m_input_type == TEMP_OF_MAIN_NOZZLE_TYPE || m_input_type == TEMP_OF_DEPUTY_NOZZLE_TYPE) { + wxSize szIcon = left_icon.GetBmpSize(); + width += szIcon.x; + } + width += 3; + // label dc.SetFont(::Label::Head_14); labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel()); @@ -514,6 +567,12 @@ void TempInput::messureSize() // interval width += 9; + if (m_input_type == TEMP_OF_MAIN_NOZZLE_TYPE || m_input_type == TEMP_OF_DEPUTY_NOZZLE_TYPE) { + wxSize szIcon = left_icon.GetBmpSize(); + width += szIcon.x; + } + width += 3; + // label dc.SetFont(::Label::Head_14); labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel()); diff --git a/src/slic3r/GUI/Widgets/TempInput.hpp b/src/slic3r/GUI/Widgets/TempInput.hpp index d1d1ad4e06..b0b23d5f10 100644 --- a/src/slic3r/GUI/Widgets/TempInput.hpp +++ b/src/slic3r/GUI/Widgets/TempInput.hpp @@ -8,6 +8,12 @@ wxDECLARE_EVENT(wxCUSTOMEVT_SET_TEMP_FINISH, wxCommandEvent); +enum TempInputType { + TEMP_OF_MAIN_NOZZLE_TYPE, + TEMP_OF_DEPUTY_NOZZLE_TYPE, + TEMP_OF_NORMAL_TYPE +}; + class TempInput : public wxNavigationEnabled { bool hover; @@ -18,6 +24,9 @@ class TempInput : public wxNavigationEnabled ScalableBitmap actice_icon; ScalableBitmap degree_icon; + ScalableBitmap left_icon; + ScalableBitmap right_icon; + StateColor label_color; StateColor text_color; @@ -27,6 +36,7 @@ class TempInput : public wxNavigationEnabled int max_temp = 0; int min_temp = 0; bool warning_mode = false; + TempInputType m_input_type; int padding_left = 0; static const int TempInputWidth = 200; @@ -43,6 +53,7 @@ public: TempInput(wxWindow * parent, int type, wxString text, + TempInputType input_type, wxString label = "", wxString normal_icon = "", wxString actice_icon = "", @@ -73,6 +84,7 @@ public: void SetCurrTemp(int temp); void SetCurrTemp(wxString temp); + void SetCurrType(TempInputType type); bool AllisNum(std::string str); void SetFinish();