Support latest BambuLab P/X/A firmwares & AMS 2/HT (#9517)

# How to download this
To download the latest test version of this PR, click the "Checks" tab
on top of this page, then click "Build All", then you will find the
latest build:

![image](https://github.com/user-attachments/assets/48bd3d59-941b-48d8-a004-8e8944a31984)

![image](https://github.com/user-attachments/assets/82945f81-2d31-4962-9307-c9a74975aba4)


-----------------


# About this PR

An option has been added in preference to toggle between the new network
plugin and the legacy one:

![image](https://github.com/user-attachments/assets/1b059f60-cd53-40b4-9415-d786048f41ba)


By default it uses the legacy network plugin, which does not come with
the authentication feature. You can use it if your printer is on an old
firmware and do not need to use the new AMS 2 pro/HT etc.

To support the new AMS 2 or if you just decided to update to the latest
firmware, uncheck this option and restart Orca, which will tell it to
use the latest bambu network plugin. I don't have X1/A1 so I could not
test it to see if you could still use the BambuCloud print with the new
plugin, or maybe you have to switch to Lan/Dev mode. However cloud print
does still work for P1 with firmware 1.8.0.




![image](https://github.com/user-attachments/assets/35ffd8bf-90b7-4ef3-8e6f-edd7f8cafadb)

![Image](https://github.com/user-attachments/assets/b3b43bc1-6aa2-4b1f-acd2-ebe0f0123dc9)

![image](https://github.com/user-attachments/assets/8f880110-83ea-4e1f-bddc-ebd0afde2f82)

![image](https://github.com/user-attachments/assets/44915c4b-f02a-4ae3-9466-dc533c047702)


Other updates:

- [x] Support print all plates for P1P/P1S
- [x] Support showing humidity percentage
- [x] Support showing info of AMS 2 pro
- [x] Work with AMS HT properly
- [x] Show AMS temp & drying
This commit is contained in:
SoftFever
2025-07-06 16:28:02 +08:00
committed by GitHub
284 changed files with 12051 additions and 6666 deletions
+3
View File
@@ -257,6 +257,9 @@ void AppConfig::set_defaults()
if (get("stealth_mode").empty()) {
set_bool("stealth_mode", false);
}
if (get("legacy_networking").empty()) {
set_bool("legacy_networking", true);
}
if(get("check_stable_update_only").empty()) {
set_bool("check_stable_update_only", false);
+29 -3
View File
@@ -291,6 +291,8 @@ static constexpr const char* FIRST_LAYER_PRINT_SEQUENCE_ATTR = "first_layer_prin
static constexpr const char* OTHER_LAYERS_PRINT_SEQUENCE_ATTR = "other_layers_print_sequence";
static constexpr const char* OTHER_LAYERS_PRINT_SEQUENCE_NUMS_ATTR = "other_layers_print_sequence_nums";
static constexpr const char* SPIRAL_VASE_MODE = "spiral_mode";
static constexpr const char* FILAMENT_MAP_MODE_ATTR = "filament_map_mode";
static constexpr const char* FILAMENT_MAP_ATTR = "filament_maps";
static constexpr const char* GCODE_FILE_ATTR = "gcode_file";
static constexpr const char* THUMBNAIL_FILE_ATTR = "thumbnail_file";
static constexpr const char* NO_LIGHT_THUMBNAIL_FILE_ATTR = "thumbnail_no_light_file";
@@ -5598,7 +5600,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
bool _add_project_config_file_to_archive(mz_zip_archive& archive, const DynamicPrintConfig &config, Model& model);
//BBS: add project embedded preset files
bool _add_project_embedded_presets_to_archive(mz_zip_archive& archive, Model& model, std::vector<Preset*> project_presets);
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, const ObjectToObjectDataMap &objects_data, int export_plate_idx = -1, bool save_gcode = true, bool use_loaded_id = false);
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, const ObjectToObjectDataMap &objects_data, const DynamicPrintConfig& config, int export_plate_idx = -1, bool save_gcode = true, bool use_loaded_id = false);
bool _add_cut_information_file_to_archive(mz_zip_archive &archive, Model &model);
bool _add_slice_info_config_file_to_archive(mz_zip_archive &archive, const Model &model, PlateDataPtrs &plate_data_list, const ObjectToObjectDataMap &objects_data, const DynamicPrintConfig& config);
bool _add_gcode_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, Export3mfProgressFn proFn = nullptr);
@@ -6114,7 +6116,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
// This file contains all the attributes of all ModelObjects and their ModelVolumes (names, parameter overrides).
// As there is just a single Indexed Triangle Set data stored per ModelObject, offsets of volumes into their respective Indexed Triangle Set data
// is stored here as well.
if (!_add_model_config_file_to_archive(archive, model, plate_data_list, objects_data, export_plate_idx, m_save_gcode, m_use_loaded_id)) {
if (!_add_model_config_file_to_archive(archive, model, plate_data_list, objects_data, *config, export_plate_idx, m_save_gcode, m_use_loaded_id)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":" << __LINE__ << boost::format(", _add_model_config_file_to_archive failed\n");
return false;
}
@@ -7443,7 +7445,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
return true;
}
bool _BBS_3MF_Exporter::_add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, const ObjectToObjectDataMap &objects_data, int export_plate_idx, bool save_gcode, bool use_loaded_id)
bool _BBS_3MF_Exporter::_add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, const ObjectToObjectDataMap &objects_data, const DynamicPrintConfig& config, int export_plate_idx, bool save_gcode, bool use_loaded_id)
{
std::stringstream stream;
// Store mesh transformation in full precision, as the volumes are stored transformed and they need to be transformed back
@@ -7623,6 +7625,20 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
if (spiral_mode_opt)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SPIRAL_VASE_MODE << "\" " << VALUE_ATTR << "=\"" << spiral_mode_opt->getBool() << "\"/>\n";
// TODO: Orca: hack
//filament map related
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_MODE_ATTR << "\" " << VALUE_ATTR << "=\"" << "Auto For Flush" << "\"/>\n";
// filament map override global settings only when group mode overrides the global settings
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_ATTR << "\" " << VALUE_ATTR << "=\"";
const size_t filaments_count = dynamic_cast<const ConfigOptionStrings*>(config.option("filament_colour"))->values.size();
for (int i = 0; i < filaments_count; ++i) {
stream << "1"; // Orca hack: for now, all filaments are mapped to extruder 1
if (i != (filaments_count - 1))
stream << " ";
}
stream << "\"/>\n";
if (save_gcode)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << GCODE_FILE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha << xml_escape(plate_data->gcode_file) << "\"/>\n";
if (!plate_data->gcode_file.empty()) {
@@ -7791,6 +7807,16 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SUPPORT_USED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_support_used << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << LABEL_OBJECT_ENABLED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_label_object_enabled << "\"/>\n";
// TODO: Orca: hack
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_ATTR << "\" " << VALUE_ATTR << "=\"";
const size_t filaments_count = dynamic_cast<const ConfigOptionStrings*>(config.option("filament_colour"))->values.size();
for (int i = 0; i < filaments_count; ++i) {
stream << "1"; // Orca hack: for now, all filaments are mapped to extruder 1
if (i != (filaments_count - 1))
stream << " ";
}
stream << "\"/>\n";
for (auto it = plate_data->objects_and_instances.begin(); it != plate_data->objects_and_instances.end(); it++)
{
int obj_id = it->first;
+13
View File
@@ -299,6 +299,13 @@ static std::unordered_map<NozzleType, std::string>NozzleTypeEumnToStr = {
{NozzleType::ntBrass, "brass"}
};
static std::unordered_map<std::string, NozzleType>NozzleTypeStrToEumn = {
{"undefine", NozzleType::ntUndefine},
{"hardened_steel", NozzleType::ntHardenedSteel},
{"stainless_steel", NozzleType::ntStainlessSteel},
{"brass", NozzleType::ntBrass}
};
// BBS
enum PrinterStructure {
psUndefine=0,
@@ -317,6 +324,12 @@ enum ZHopType {
zhtCount
};
enum NozzleVolumeType {
nvtNormal = 0,
nvtBigTraffic,
nvtMaxNozzleVolumeType = nvtBigTraffic
};
enum RetractLiftEnforceType {
rletAllSurfaces = 0,
rletTopOnly,
+4
View File
@@ -49,6 +49,10 @@ struct FilamentInfo
int ctype = 0;
std::vector<std::string> colors = std::vector<std::string>();
int mapping_result = 0;
/*for new ams mapping*/
std::string ams_id;
std::string slot_id;
};
class BBLSliceInfo {
+32 -2
View File
@@ -32,6 +32,7 @@ enum class CalibState { Start = 0, Preset, Calibration, CoarseSave, FineCalibrat
struct Calib_Params
{
Calib_Params() : mode(CalibMode::Calib_None){};
int extruder_id = 0;
double start, end, step;
bool print_numbers;
double freqStartX, freqEndX, freqStartY, freqEndY;
@@ -52,8 +53,12 @@ class X1CCalibInfos
public:
struct X1CCalibInfo
{
int extruder_id = -1;
int tray_id;
int ams_id = 0;
int slot_id = 0;
int bed_temp;
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtNormal;
int nozzle_temp;
float nozzle_diameter;
std::string filament_id;
@@ -102,7 +107,11 @@ public:
CALI_RESULT_PROBLEM = 1,
CALI_RESULT_FAILED = 2,
};
int tray_id;
int extruder_id = -1;
NozzleVolumeType nozzle_volume_type;
int tray_id = 0;
int ams_id = 0;
int slot_id = 0;
int cali_idx = -1;
float nozzle_diameter;
std::string filament_id;
@@ -115,12 +124,33 @@ public:
struct PACalibIndexInfo
{
int tray_id;
int extruder_id = -1;
NozzleVolumeType nozzle_volume_type;
int tray_id = 0;
int ams_id = 0;
int slot_id = 0;
int cali_idx;
float nozzle_diameter;
std::string filament_id;
};
struct PACalibExtruderInfo
{
int extruder_id = -1;
NozzleVolumeType nozzle_volume_type;
float nozzle_diameter;
std::string filament_id = "";
bool use_extruder_id{true};
bool use_nozzle_volume_type{true};
};
struct PACalibTabInfo
{
float pa_calib_tab_nozzle_dia;
int extruder_id;
NozzleVolumeType nozzle_volume_type;
};
class FlowRatioCalibResult
{
public:
+7
View File
@@ -62,6 +62,8 @@ set(SLIC3R_GUI_SOURCES
GUI/Widgets/TempInput.hpp
GUI/Widgets/AMSControl.cpp
GUI/Widgets/AMSControl.hpp
GUI/Widgets/AMSItem.cpp
GUI/Widgets/AMSItem.hpp
GUI/Widgets/FanControl.cpp
GUI/Widgets/FanControl.hpp
GUI/Widgets/Scrollbar.cpp
@@ -444,6 +446,8 @@ set(SLIC3R_GUI_SOURCES
GUI/ModelMall.cpp
GUI/SelectMachine.hpp
GUI/SelectMachine.cpp
GUI/SelectMachinePop.hpp
GUI/SelectMachinePop.cpp
GUI/SendToPrinter.hpp
GUI/SendToPrinter.cpp
GUI/AmsMappingPopup.hpp
@@ -582,8 +586,11 @@ set(SLIC3R_GUI_SOURCES
Utils/ElegooLink.hpp
Utils/ElegooLink.cpp
Utils/WebSocketClient.hpp
Utils/bambu_networking.hpp
)
add_subdirectory(GUI/DeviceTab)
if (WIN32)
list(APPEND SLIC3R_GUI_SOURCES
GUI/dark_mode/dark_mode.hpp
+134 -54
View File
@@ -13,6 +13,31 @@ namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent);
static void get_default_k_n_value(const std::string &filament_id, float &k, float &n)
{
if (filament_id.compare("GFG00") == 0) {
// PETG
k = 0.04;
n = 1.0;
} else if (filament_id.compare("GFB00") == 0 || filament_id.compare("GFB50") == 0) {
// ABS
k = 0.04;
n = 1.0;
} else if (filament_id.compare("GFU01") == 0) {
// TPU
k = 0.2;
n = 1.0;
} else if (filament_id.compare("GFB01") == 0) {
// ASA
k = 0.04;
n = 1.0;
} else {
// PLA , other
k = 0.02;
n = 1.0;
}
}
static std::string float_to_string_with_precision(float value, int precision = 3)
{
std::stringstream stream;
@@ -76,7 +101,7 @@ void AMSMaterialsSetting::create()
m_sizer_button->Add(m_button_close, 0, wxALIGN_CENTER, 0);
m_sizer_main->Add(m_panel_normal, 0, wxALL, FromDIP(2));
m_sizer_main->Add(m_panel_kn, 0, wxALL, FromDIP(2));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(24));
@@ -353,7 +378,7 @@ void AMSMaterialsSetting::create_panel_kn(wxWindow* parent)
parent->SetSizer(sizer);
}
void AMSMaterialsSetting::paintEvent(wxPaintEvent &evt)
void AMSMaterialsSetting::paintEvent(wxPaintEvent &evt)
{
auto size = GetSize();
wxPaintDC dc(this);
@@ -368,7 +393,7 @@ AMSMaterialsSetting::~AMSMaterialsSetting()
m_comboBox_cali_result->Disconnect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(AMSMaterialsSetting::on_select_cali_result), NULL, this);
}
void AMSMaterialsSetting::input_min_finish()
void AMSMaterialsSetting::input_min_finish()
{
if (m_input_nozzle_min->GetTextCtrl()->GetValue().empty()) return;
@@ -423,7 +448,7 @@ void AMSMaterialsSetting::enable_confirm_button(bool en)
}
if (!m_is_third) {
m_tip_readonly->Hide();
m_tip_readonly->Hide();
}
else {
if (!obj->is_support_filament_setting_inprinting) {
@@ -457,21 +482,32 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
long nozzle_temp_max_int = 0;
wxColour color = *wxWHITE;
char col_buf[10];
sprintf(col_buf, "%02X%02X%02XFF", (int)color.Red(), (int)color.Green(), (int)color.Blue());
sprintf(col_buf, "%02X%02X%02X00", (int)color.Red(), (int)color.Green(), (int)color.Blue());
std::string color_str; // reset use empty string
std::string selected_ams_id;
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
if (preset_bundle) {
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
std::string filament_id = filament_item.filament_id;
if (it->filament_id.compare(filament_id) == 0) {
selected_ams_id = it->filament_id;
break;
}
}
}
if (obj) {
// set filament
if (is_virtual_tray()) {
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
}
else if(m_is_third){
obj->command_ams_filament_settings(ams_id, tray_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
if(m_is_third){
obj->command_ams_filament_settings(ams_id, slot_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int,
nozzle_temp_max_int);
}
// set k / n value
if (obj->cali_version <= -1 && obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
// set extrusion cali ratio
int cali_tray_id = ams_id * 4 + tray_id;
int cali_tray_id = ams_id * 4 + slot_id;
double k = 0.0;
try {
@@ -492,10 +528,23 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
}
else {
PACalibIndexInfo select_index_info;
int tray_id = ams_id * 4 + slot_id;
if (is_virtual_tray()) {
tray_id = ams_id;
if (!obj->is_enable_np) {
tray_id = VIRTUAL_TRAY_ID;
}
// TODO: Orca hack
ams_id = 255;
slot_id = 0;
}
select_index_info.tray_id = tray_id;
select_index_info.nozzle_diameter = obj->nozzle_diameter;
select_index_info.ams_id = ams_id;
select_index_info.slot_id = slot_id;
select_index_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter;
select_index_info.cali_idx = -1;
select_index_info.filament_id = ams_filament_id;
select_index_info.filament_id = selected_ams_id;
CalibUtils::select_PA_calib_result(select_index_info);
}
}
@@ -530,7 +579,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
std::string vendor_name = vendor->values[0];
DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, in_blacklist, action, info);
}
if (in_blacklist) {
if (action == "prohibition") {
@@ -575,14 +624,9 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
// set filament
if (m_is_third) {
if (is_virtual_tray()) {
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
}
else {
obj->command_ams_filament_settings(ams_id, tray_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
}
obj->command_ams_filament_settings(ams_id, slot_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
}
//reset param
wxString k_text = m_input_k_val->GetTextCtrl()->GetValue();
wxString n_text = m_input_n_val->GetTextCtrl()->GetValue();
@@ -612,10 +656,17 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
;
}
auto vt_tray = ams_id;
if (!obj->is_enable_np) {
vt_tray = VIRTUAL_TRAY_ID;
}
if (obj->cali_version >= 0) {
PACalibIndexInfo select_index_info;
select_index_info.tray_id = tray_id;
select_index_info.nozzle_diameter = obj->nozzle_diameter;
select_index_info.tray_id = vt_tray;
select_index_info.ams_id = 255; // TODO: Orca hack
select_index_info.slot_id = 0;
select_index_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter;
auto cali_select_id = m_comboBox_cali_result->GetSelection();
if (m_pa_profile_items.size() > 0 && cali_select_id >= 0) {
@@ -630,11 +681,11 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
CalibUtils::select_PA_calib_result(select_index_info);
}
else {
obj->command_extrusion_cali_set(VIRTUAL_TRAY_ID, "", "", k, n);
obj->command_extrusion_cali_set(vt_tray, "", "", k, n);
}
}
else {
int cali_tray_id = ams_id * 4 + tray_id;
int cali_tray_id = ams_id * 4 + slot_id;
double k = 0.0;
try {
k_text.ToDouble(&k);
@@ -654,10 +705,12 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
if (obj->cali_version >= 0) {
PACalibIndexInfo select_index_info;
select_index_info.tray_id = cali_tray_id;
select_index_info.nozzle_diameter = obj->nozzle_diameter;
select_index_info.ams_id = ams_id;
select_index_info.slot_id = slot_id;
select_index_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter;
auto cali_select_id = m_comboBox_cali_result->GetSelection();
if (m_pa_profile_items.size() > 0 && cali_select_id >= 0) {
if (m_pa_profile_items.size() > 0 && cali_select_id > 0) {
select_index_info.cali_idx = m_pa_profile_items[cali_select_id].cali_idx;
select_index_info.filament_id = m_pa_profile_items[cali_select_id].filament_id;
}
@@ -710,7 +763,7 @@ void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event)
set_color(wxColour(color_num>>24&0xFF, color_num>>16&0xFF, color_num>>8&0xFF, color_num&0xFF));
}
void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
{
if(!m_is_third)
return;
@@ -741,7 +794,7 @@ void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
bool AMSMaterialsSetting::is_virtual_tray()
{
if (tray_id == VIRTUAL_TRAY_ID)
if (ams_id == VIRTUAL_TRAY_ID)
return true;
return false;
}
@@ -769,8 +822,8 @@ void AMSMaterialsSetting::update_widgets()
Layout();
}
bool AMSMaterialsSetting::Show(bool show)
{
bool AMSMaterialsSetting::Show(bool show)
{
if (show) {
m_button_confirm->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
@@ -794,7 +847,7 @@ bool AMSMaterialsSetting::Show(bool show)
Fit();
wxGetApp().UpdateDarkUI(this);
}
return DPIDialog::Show(show);
return DPIDialog::Show(show);
}
void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_min, wxString temp_max, wxString k, wxString n)
@@ -817,10 +870,10 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
std::set<std::string> filament_id_set;
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
std::ostringstream stream;
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
stream << std::fixed << std::setprecision(1) << obj->m_extder_data.extders[0].current_nozzle_diameter;
std::string nozzle_diameter_str = stream.str();
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type), nozzle_diameter_str);
if (preset_bundle) {
BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size();
for (auto filament_it = preset_bundle->filaments.begin(); filament_it != preset_bundle->filaments.end(); filament_it++) {
@@ -832,7 +885,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
if (preset_bundle->filaments.get_preset_base(*filament_it) != &preset || (!filament_it->is_system && !obj->is_support_user_preset)) {
continue;
}
ConfigOption * printer_opt = filament_it->config.option("compatible_printers");
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
for (auto printer_str : printer_strs->values) {
@@ -867,7 +920,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
if (filament_it->filament_id == ams_filament_id) {
selection_idx = idx;
bambu_filament_name = filament_it->alias;
// update if nozzle_temperature_range is found
ConfigOption *opt_min = filament_it->config.option("nozzle_temperature_range_low");
@@ -891,7 +944,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
}
}
}
}
}
@@ -913,7 +966,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
else {
m_readonly_filament->SetLabel(bambu_filament_name);
}
m_input_nozzle_min->GetTextCtrl()->SetValue(temp_min);
m_input_nozzle_max->GetTextCtrl()->SetValue(temp_max);
}
@@ -934,7 +987,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
}
m_button_reset->Show();
//m_button_confirm->Show();
//m_button_confirm->Show();
}
m_comboBox_filament->Set(filament_items);
@@ -983,7 +1036,7 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
if (preset_bundle) {
std::ostringstream stream;
if (obj)
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
stream << std::fixed << std::setprecision(1) << obj->m_extder_data.extders[0].current_nozzle_diameter;
std::string nozzle_diameter_str = stream.str();
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type),
nozzle_diameter_str);
@@ -1093,40 +1146,67 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
wxArrayString items;
m_pa_profile_items.clear();
m_comboBox_cali_result->SetValue(wxEmptyString);
// TODO: Orca hack
int extruder_id = 0;
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtNormal;
if (obj->cali_version >= 0) {
// add default item
PACalibResult default_item;
default_item.cali_idx = -1;
get_default_k_n_value(ams_filament_id, default_item.k_value, default_item.n_coef);
m_pa_profile_items.emplace_back(default_item);
items.push_back(_L("Default"));
m_input_k_val->GetTextCtrl()->SetValue(wxEmptyString);
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
for (auto cali_item : cali_history) {
if (cali_item.filament_id == ams_filament_id) {
if (obj->is_multi_extruders() && (cali_item.extruder_id != extruder_id || cali_item.nozzle_volume_type != nozzle_volume_type)) {
continue;
}
items.push_back(from_u8(cali_item.name));
m_pa_profile_items.push_back(cali_item);
}
}
m_comboBox_cali_result->Set(items);
if (tray_id == VIRTUAL_TRAY_ID) {
if (ams_id == VIRTUAL_TRAY_ID) {
AmsTray selected_tray = this->obj->vt_tray;
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items,selected_tray.cali_idx);
if (cali_select_idx >= 0) {
m_comboBox_cali_result->SetSelection(cali_select_idx);
}
else {
m_comboBox_cali_result->SetSelection(0);
}
}
else {
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
if(!selected_ams) return;
AmsTray* selected_tray = selected_ams->trayList[std::to_string(tray_id)];
if(!selected_tray) return;
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items, selected_tray->cali_idx);
if (cali_select_idx >= 0) {
if (this->obj->amsList.find(std::to_string(ams_id)) != this->obj->amsList.end()) {
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
if (!selected_ams)
return;
AmsTray* selected_tray = selected_ams->trayList[std::to_string(slot_id)];
if (!selected_tray)
return;
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items, selected_tray->cali_idx);
if (cali_select_idx < 0) {
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_status_error: cannot find pa profile, ams_id = " << ams_id
<< ", slot_id = " << slot_id << ", cali_idx = " << selected_tray->cali_idx;
cali_select_idx = 0;
}
m_comboBox_cali_result->SetSelection(cali_select_idx);
}
}
if (cali_select_idx >= 0) {
m_input_k_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].k_value));
m_input_n_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].n_coef));
}
else {
m_input_k_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[0].k_value));
m_input_n_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[0].n_coef));
}
}
else {
if (!ams_filament_id.empty()) {
@@ -1140,8 +1220,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
}
}
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
{
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
{
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
//m_clr_picker->msw_rescale();
@@ -1154,7 +1234,7 @@ void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
m_button_confirm->SetCornerRadius(FromDIP(12));
m_button_close->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
m_button_close->SetCornerRadius(FromDIP(12));
this->Refresh();
this->Refresh();
}
ColorPicker::ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/)
@@ -1603,7 +1683,7 @@ void ColorPickerPopup::paintEvent(wxPaintEvent& evt)
void ColorPickerPopup::OnDismiss() {}
void ColorPickerPopup::Popup()
void ColorPickerPopup::Popup()
{
PopupWindow::Popup();
}
+1 -1
View File
@@ -118,7 +118,7 @@ public:
void on_picker_color(wxCommandEvent& color);
MachineObject* obj{ nullptr };
int ams_id { 0 }; /* 0 ~ 3 */
int tray_id { 0 }; /* 0 ~ 3 */
int slot_id { 0 }; /* 0 ~ 3 */
std::string ams_filament_id;
std::string ams_setting_id;
+1 -1
View File
@@ -315,7 +315,7 @@ AboutDialog::AboutDialog()
copyright_hor_sizer->Add(copyright_ver_sizer, 0, wxLEFT, FromDIP(20));
wxStaticText *html_text = new wxStaticText(this, wxID_ANY, "Copyright(C) 2022-2024 Li Jiang All Rights Reserved", wxDefaultPosition, wxDefaultSize);
wxStaticText *html_text = new wxStaticText(this, wxID_ANY, "Copyright(C) 2022-2025 Li Jiang All Rights Reserved", wxDefaultPosition, wxDefaultSize);
html_text->SetForegroundColour(wxColour(107, 107, 107));
copyright_ver_sizer->Add(html_text, 0, wxALL , 0);
+95 -75
View File
@@ -286,19 +286,19 @@ void MaterialItem::doRender(wxDC &dc)
AmsMapingPopup::AmsMapingPopup(wxWindow *parent)
: PopupWindow(parent, wxBORDER_NONE)
{
SetSize(wxSize(FromDIP(252), -1));
SetMinSize(wxSize(FromDIP(252), -1));
SetMaxSize(wxSize(FromDIP(252), -1));
Bind(wxEVT_PAINT, &AmsMapingPopup::paintEvent, this);
#if __APPLE__
Bind(wxEVT_LEFT_DOWN, &AmsMapingPopup::on_left_down, this);
#endif
SetBackgroundColour(*wxWHITE);
m_sizer_main = new wxBoxSizer(wxVERTICAL);
//m_sizer_main->Add(0, 0, 1, wxEXPAND, 0);
m_sizer_main = new wxBoxSizer(wxVERTICAL);
m_sizer_ams = new wxBoxSizer(wxHORIZONTAL);
m_sizer_ams_left = new wxBoxSizer(wxVERTICAL);
m_sizer_ams_right = new wxBoxSizer(wxVERTICAL);
auto title_panel = new wxPanel(this, wxID_ANY);
title_panel->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8));
@@ -307,7 +307,6 @@ void MaterialItem::doRender(wxDC &dc)
wxBoxSizer *title_sizer_h= new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *title_sizer_v = new wxBoxSizer(wxVERTICAL);
auto title_text = new wxStaticText(title_panel, wxID_ANY, _L("AMS Slots"));
@@ -319,19 +318,15 @@ void MaterialItem::doRender(wxDC &dc)
title_panel->Layout();
title_panel->Fit();
m_sizer_list = new wxBoxSizer(wxVERTICAL);
for (auto i = 0; i < AMS_TOTAL_COUNT; i++) {
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
/*auto ams_mapping_item_container = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_mapping_container", this, 78), wxDefaultPosition,
wxSize(FromDIP(230), FromDIP(78)), 0);*/
auto ams_mapping_item_container = new MappingContainer(this);
ams_mapping_item_container->SetSizer(sizer_mapping_list);
ams_mapping_item_container->Layout();
//ams_mapping_item_container->Hide();
m_amsmapping_container_sizer_list.push_back(sizer_mapping_list);
m_amsmapping_container_list.push_back(ams_mapping_item_container);
m_sizer_list->Add(ams_mapping_item_container, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxBOTTOM, FromDIP(5));
}
auto left_ams_title_text = new wxStaticText(this, wxID_ANY, _L("Left Ams"));
auto right_ams_title_text = new wxStaticText(this, wxID_ANY, _L("Right Ams"));
m_sizer_ams_left->Add(left_ams_title_text, 0, wxALIGN_CENTER, 0);
m_sizer_ams_right->Add(right_ams_title_text, 0, wxALIGN_CENTER, 0);
m_sizer_ams->Add(m_sizer_ams_left, 0, wxEXPAND | wxALL, FromDIP(0));
m_sizer_ams->Add(m_sizer_ams_right, 0, wxEXPAND | wxALL, FromDIP(0));
m_warning_text = new wxStaticText(this, wxID_ANY, wxEmptyString);
m_warning_text->SetForegroundColour(wxColour(0xFF, 0x6F, 0x00));
@@ -342,9 +337,7 @@ void MaterialItem::doRender(wxDC &dc)
m_warning_text->Wrap(FromDIP(248));
m_sizer_main->Add(title_panel, 0, wxEXPAND | wxALL, FromDIP(2));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
m_sizer_main->Add(m_sizer_list, 0, wxEXPAND | wxALL, FromDIP(0));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
m_sizer_main->Add(m_sizer_ams, 0, wxEXPAND | wxALL, FromDIP(2));
m_sizer_main->Add(m_warning_text, 0, wxEXPAND | wxALL, FromDIP(6));
SetSizer(m_sizer_main);
@@ -456,73 +449,94 @@ void AmsMapingPopup::update_ams_data_multi_machines()
void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
{
m_has_unmatch_filament = false;
//m_mapping_item_list.clear();
std::map<std::string, Ams *>::iterator ams_iter;
BOOST_LOG_TRIVIAL(trace) << "ams_mapping total count " << amsList.size();
for (auto& ams_container : m_amsmapping_container_list) {
ams_container->Hide();
ams_container->Destroy();
}
for (wxWindow *mitem : m_mapping_item_list) {
mitem->Destroy();
mitem = nullptr;
}
m_mapping_item_list.clear();
if (m_amsmapping_container_sizer_list.size() > 0) {
for (wxBoxSizer *siz : m_amsmapping_container_sizer_list) {
siz->Clear(true);
}
}
std::map<std::string, Ams *>::iterator ams_iter;
BOOST_LOG_TRIVIAL(trace) << "ams_mapping total count " << amsList.size();
int m_amsmapping_container_list_index = 0;
m_amsmapping_container_list.clear();
m_amsmapping_container_sizer_list.clear();
m_mapping_item_list.clear();
for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
auto ams_indx = atoi(ams_iter->first.c_str());
Ams *ams_group = ams_iter->second;
std::vector<TrayData> tray_datas;
std::map<std::string, AmsTray *>::iterator tray_iter;
int ams_indx = atoi(ams_iter->first.c_str());
int ams_type = ams_iter->second->type;
int nozzle_id = ams_iter->second->nozzle;
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) {
AmsTray *tray_data = tray_iter->second;
TrayData td;
if (ams_type >=1 || ams_type <= 3) { //1:ams 2:ams-lite 3:n3f
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
auto ams_mapping_item_container = new MappingContainer(this);
ams_mapping_item_container->SetSizer(sizer_mapping_list);
ams_mapping_item_container->Layout();
m_has_unmatch_filament = false;
if (!tray_data->is_exists) {
td.type = EMPTY;
} else {
if (!tray_data->is_tray_info_ready()) {
td.type = THIRD;
} else {
td.type = NORMAL;
td.colour = AmsTray::decode_color(tray_data->color);
td.name = tray_data->get_display_filament_type();
td.filament_type = tray_data->get_filament_type();
td.ctype = tray_data->ctype;
for (auto col : tray_data->cols) {
td.material_cols.push_back(AmsTray::decode_color(col));
}
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
Ams* ams_group = ams_iter->second;
std::vector<TrayData> tray_datas;
std::map<std::string, AmsTray*>::iterator tray_iter;
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) {
AmsTray* tray_data = tray_iter->second;
TrayData td;
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
if (!tray_data->is_exists) {
td.type = EMPTY;
}
else {
if (!tray_data->is_tray_info_ready()) {
td.type = THIRD;
}
else {
td.type = NORMAL;
td.colour = AmsTray::decode_color(tray_data->color);
td.name = tray_data->get_display_filament_type();
td.filament_type = tray_data->get_filament_type();
td.ctype = tray_data->ctype;
for (auto col : tray_data->cols) {
td.material_cols.push_back(AmsTray::decode_color(col));
}
}
td.ams_id = std::stoi(ams_iter->second->id);
td.slot_id = std::stoi(tray_iter->second->id);
}
tray_datas.push_back(td);
}
tray_datas.push_back(td);
}
ams_mapping_item_container->Show();
add_ams_mapping(tray_datas, ams_mapping_item_container, sizer_mapping_list);
m_amsmapping_container_list[m_amsmapping_container_list_index]->Show();
add_ams_mapping(tray_datas, m_amsmapping_container_list[m_amsmapping_container_list_index], m_amsmapping_container_sizer_list[m_amsmapping_container_list_index]);
m_amsmapping_container_list_index++;
m_amsmapping_container_sizer_list.push_back(sizer_mapping_list);
m_amsmapping_container_list.push_back(ams_mapping_item_container);
//main nozzle = right nozzle
if (nozzle_id == 0) {
m_sizer_ams_right->Add(ams_mapping_item_container, 0, wxALIGN_CENTER, 0);
}
else if (nozzle_id == 1) {
m_sizer_ams_left->Add(ams_mapping_item_container, 0, wxALIGN_CENTER, 0);
}
//m_warning_text->Show(m_has_unmatch_filament);
}
else if(ams_type == 4){ //4:n3s
}
}
/*extra tray*/
m_warning_text->Show(m_has_unmatch_filament);
Layout();
Fit();
}
@@ -583,6 +597,9 @@ void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data, wxWindow*
// set button
MappingItem *m_mapping_item = new MappingItem(container);
m_mapping_item->m_ams_id = tray_data[i].ams_id;
m_mapping_item->m_slot_id = tray_data[i].slot_id;
m_mapping_item->SetSize(wxSize(FromDIP(68 * 0.7), FromDIP(100 * 0.6)));
m_mapping_item->SetMinSize(wxSize(FromDIP(68 * 0.7), FromDIP(100 * 0.6)));
m_mapping_item->SetMaxSize(wxSize(FromDIP(68 * 0.7), FromDIP(100 * 0.6)));
@@ -675,7 +692,8 @@ void MappingItem::send_event(int fliament_id)
wxCommandEvent event(EVT_SET_FINISH_MAPPING);
event.SetInt(m_tray_data.id);
wxString param = wxString::Format("%d|%d|%d|%d|%s|%d", m_coloul.Red(), m_coloul.Green(), m_coloul.Blue(), m_coloul.Alpha(), number, fliament_id);
wxString param = wxString::Format("%d|%d|%d|%d|%s|%d|%d|%d", m_coloul.Red(), m_coloul.Green(), m_coloul.Blue(), m_coloul.Alpha(), number, fliament_id,
m_tray_data.ams_id, m_tray_data.slot_id);
event.SetString(param);
event.SetEventObject(this->GetParent()->GetParent());
wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
@@ -1385,7 +1403,9 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
//creat group
int group_index = 0;
for (int filam : m_obj->filam_bak) {
const Extder& extder = m_obj->m_extder_data.extders[MAIN_NOZZLE_ID];
for (int filam : extder.filam_bak) {
auto status_list = GetStatus(filam);
std::map<std::string, wxColour> group_info;
+9
View File
@@ -60,6 +60,9 @@ struct TrayData
std::string filament_type;
wxColour colour;
std::vector<wxColour> material_cols = std::vector<wxColour>();
int ams_id = 0;
int slot_id = 0;
};
class MaterialItem: public wxPanel
@@ -116,6 +119,9 @@ public:
ScalableBitmap m_transparent_mapping_item;
bool m_unmatch{false};
int m_ams_id{255};
int m_slot_id{255};
void msw_rescale();
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
@@ -150,6 +156,9 @@ public:
int m_current_filament_id;
std::string m_tag_material;
wxBoxSizer *m_sizer_main{nullptr};
wxBoxSizer *m_sizer_ams{nullptr};
wxBoxSizer *m_sizer_ams_left{nullptr};
wxBoxSizer *m_sizer_ams_right{nullptr};
wxBoxSizer *m_sizer_list{nullptr};
wxWindow *m_parent_item{nullptr};
+21 -14
View File
@@ -11,7 +11,7 @@
namespace Slic3r {
namespace GUI {
#define HISTORY_WINDOW_SIZE wxSize(FromDIP(700), FromDIP(600))
#define EDIT_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(160), FromDIP(24))
#define NEW_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(250), FromDIP(24))
@@ -180,7 +180,7 @@ void HistoryWindow::on_device_connected(MachineObject* obj)
int selection = 1;
for (int i = 0; i < nozzle_diameter_list.size(); i++) {
m_comboBox_nozzle_dia->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i]));
if (abs(curr_obj->nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
if (abs(curr_obj->m_extder_data.extders[0].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
selection = i;
}
}
@@ -201,9 +201,8 @@ void HistoryWindow::update(MachineObject* obj)
{
if (!obj) return;
if (obj->cali_version != history_version) {
if (obj->cali_version != obj->last_cali_version) {
if (obj->has_get_pa_calib_tab) {
history_version = obj->cali_version;
reqeust_history_result(obj);
}
}
@@ -217,20 +216,23 @@ void HistoryWindow::update(MachineObject* obj)
void HistoryWindow::on_select_nozzle(wxCommandEvent& evt)
{
reqeust_history_result(curr_obj);
}
void HistoryWindow::reqeust_history_result(MachineObject* obj)
{
if (curr_obj) {
// reset
// reset
curr_obj->reset_pa_cali_history_result();
m_calib_results_history.clear();
sync_history_data();
float nozzle_value = get_nozzle_value();
if (nozzle_value > 0) {
CalibUtils::emit_get_PA_calib_infos(nozzle_value);
PACalibExtruderInfo cali_info;
cali_info.nozzle_diameter = nozzle_value;
cali_info.use_nozzle_volume_type = false;
CalibUtils::emit_get_PA_calib_infos(cali_info);
m_tips->SetLabel(_L("Refreshing the historical Flow Dynamics Calibration records"));
BOOST_LOG_TRIVIAL(info) << "request calib history";
}
@@ -303,7 +305,12 @@ void HistoryWindow::sync_history_data() {
gbSizer->SetEmptyCellSize({ 0,0 });
m_history_data_panel->Layout();
m_history_data_panel->Fit();
CalibUtils::delete_PA_calib_result({ result.tray_id, result.cali_idx, result.nozzle_diameter, result.filament_id });
PACalibIndexInfo cali_info;
cali_info.tray_id = result.tray_id;
cali_info.cali_idx = result.cali_idx;
cali_info.nozzle_diameter = result.nozzle_diameter;
cali_info.filament_id = result.filament_id;
CalibUtils::delete_PA_calib_result(cali_info);
});
auto edit_button = new Button(m_history_data_panel, _L("Edit"));
@@ -468,7 +475,7 @@ void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
return;
m_new_result.name = m_name_value->GetTextCtrl()->GetValue().ToUTF8().data();
float k = 0.0f;
if (!CalibUtils::validate_input_k_value(m_k_value->GetTextCtrl()->GetValue(), &k)) {
MessageDialog msg_dlg(nullptr, wxString::Format(_L("Please input a valid value (K in %.1f~%.1f)"), MIN_PA_K_VALUE, MAX_PA_K_VALUE), wxEmptyString, wxICON_WARNING | wxOK);
@@ -499,7 +506,7 @@ wxArrayString NewCalibrationHistoryDialog::get_all_filaments(const MachineObject
std::set<std::string> filament_id_set;
std::set<std::string> printer_names;
std::ostringstream stream;
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
stream << std::fixed << std::setprecision(1) << obj->m_extder_data.extders[0].current_nozzle_diameter;
std::string nozzle_diameter_str = stream.str();
for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) {
@@ -616,11 +623,11 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
static std::array<float, 4> nozzle_diameter_list = {0.2f, 0.4f, 0.6f, 0.8f};
for (int i = 0; i < nozzle_diameter_list.size(); i++) {
m_comboBox_nozzle_diameter->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i]));
if (abs(obj->nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
if (abs(obj->m_extder_data.extders[0].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
m_comboBox_nozzle_diameter->SetSelection(i);
}
}
// Nozzle Diameter
flex_sizer->Add(nozzle_diameter_title);
flex_sizer->Add(m_comboBox_nozzle_diameter);
@@ -628,7 +635,7 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
Label *k_title = new Label(top_panel, _L("Factor K"));
auto k_str = wxString::Format("%.3f", m_new_result.k_value);
m_k_value = new TextInput(top_panel, k_str, "", "", wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, wxTE_PROCESS_ENTER);
// Factor K
flex_sizer->Add(k_title);
flex_sizer->Add(m_k_value);
@@ -703,7 +710,7 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
m_new_result.k_value = k;
m_new_result.tray_id = -1;
m_new_result.cali_idx = -1;
m_new_result.nozzle_diameter = nozzle_value;
m_new_result.filament_id = filament_id;
m_new_result.setting_id = setting_id;
-1
View File
@@ -36,7 +36,6 @@ protected:
bool& m_show_history_dialog;
std::vector<PACalibResult> m_calib_results_history;
MachineObject* curr_obj { nullptr };
int history_version = -1;
};
class EditCalibrationHistoryDialog : public DPIDialog
+3 -1
View File
@@ -4,11 +4,13 @@
#include "MainFrame.hpp"
#include "CalibrationPanel.hpp"
#include "I18N.hpp"
#include "SelectMachine.hpp"
#include "SelectMachinePop.hpp"
namespace Slic3r { namespace GUI {
#define REFRESH_INTERVAL 1000
#define INITIAL_NUMBER_OF_MACHINES 0
#define LIST_REFRESH_INTERVAL 200
#define MACHINE_LIST_REFRESH_INTERVAL 2000
-8
View File
@@ -7,16 +7,8 @@
namespace Slic3r { namespace GUI {
#define SELECT_MACHINE_GREY900 wxColour(38, 46, 48)
#define SELECT_MACHINE_GREY600 wxColour(144,144,144)
#define SELECT_MACHINE_GREY400 wxColour(206, 206, 206)
#define SELECT_MACHINE_BRAND wxColour(0, 150, 136)
#define SELECT_MACHINE_REMIND wxColour(255,111,0)
#define SELECT_MACHINE_LIGHT_GREEN wxColour(219, 253, 231)
#define CALI_MODE_COUNT 2
wxString get_calibration_type_name(CalibMode cali_mode);
class MObjectPanel : public wxPanel
+50 -20
View File
@@ -17,7 +17,6 @@ wxDEFINE_EVENT(EVT_CALIBRATION_JOB_FINISHED, wxCommandEvent);
static const wxString NA_STR = _L("N/A");
static const float MIN_PA_K_VALUE_STEP = 0.001;
static const int MAX_PA_HISTORY_RESULTS_NUMS = 16;
std::map<int, Preset*> get_cached_selected_filament(MachineObject* obj) {
std::map<int, Preset*> selected_filament_map;
if (!obj) return selected_filament_map;
@@ -46,7 +45,7 @@ bool is_pa_params_valid(const Calib_Params& params)
}
CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxPanel(parent, id, pos, size, style)
: wxPanel(parent, id, pos, size, style)
, m_mode(mode)
{
SetBackgroundColour(wxColour(0xEEEEEE));
@@ -58,8 +57,8 @@ CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowI
m_scrolledWindow->SetBackgroundColour(*wxWHITE);
wxBoxSizer* padding_sizer = new wxBoxSizer(wxHORIZONTAL);
padding_sizer->Add(0, 0, 1);
padding_sizer->Add(0, 0, 1);
m_all_pages_sizer = new wxBoxSizer(wxVERTICAL);
padding_sizer->Add(m_all_pages_sizer, 0);
@@ -103,6 +102,26 @@ CalibrationWizard::~CalibrationWizard()
;
}
void CalibrationWizard::get_tray_ams_and_slot_id(int in_tray_id, int &ams_id, int &slot_id, int &tray_id)
{
assert(curr_obj);
if (!curr_obj)
return;
if (in_tray_id == VIRTUAL_TRAY_ID || in_tray_id == VIRTUAL_TRAY_ID) {
ams_id = in_tray_id;
slot_id = 0;
tray_id = ams_id;
if (!curr_obj->is_enable_np)
tray_id = VIRTUAL_TRAY_ID;
}
else {
ams_id = in_tray_id / 4;
slot_id = in_tray_id % 4;
tray_id = in_tray_id;
}
}
void CalibrationWizard::on_cali_job_finished(wxCommandEvent& event)
{
this->on_cali_job_finished(event.GetString());
@@ -320,7 +339,7 @@ void CalibrationWizard::back_preset_info(MachineObject *obj, bool cali_finish, b
wxGetApp().app_config->save_printer_cali_infos(printer_cali_info, back_cali_flag);
}
void CalibrationWizard::msw_rescale()
void CalibrationWizard::msw_rescale()
{
for (int i = 0; i < m_page_steps.size(); i++) {
if (m_page_steps[i]->page)
@@ -402,7 +421,7 @@ void PressureAdvanceWizard::create_pages()
preset_step = new CalibrationWizardPageStep(new CalibrationPresetPage(m_scrolledWindow, m_mode, false));
cali_step = new CalibrationWizardPageStep(new CalibrationCaliPage(m_scrolledWindow, m_mode));
save_step = new CalibrationWizardPageStep(new CalibrationPASavePage(m_scrolledWindow));
m_all_pages_sizer->Add(start_step->page, 1, wxEXPAND | wxALL, FromDIP(25));
m_all_pages_sizer->Add(preset_step->page, 1, wxEXPAND | wxALL, FromDIP(25));
m_all_pages_sizer->Add(cali_step->page, 1, wxEXPAND | wxALL, FromDIP(25));
@@ -477,7 +496,11 @@ void PressureAdvanceWizard::update(MachineObject* obj)
if (!m_show_result_dialog) {
if (obj->cali_version != -1 && obj->cali_version != cali_version) {
cali_version = obj->cali_version;
CalibUtils::emit_get_PA_calib_info(obj->nozzle_diameter, "");
PACalibExtruderInfo cali_info;
cali_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter;
cali_info.use_extruder_id = false;
cali_info.use_nozzle_volume_type = false;
CalibUtils::emit_get_PA_calib_infos(cali_info);
}
}
}
@@ -589,7 +612,7 @@ void PressureAdvanceWizard::on_cali_start()
}
X1CCalibInfos::X1CCalibInfo calib_info;
calib_info.tray_id = item.first;
get_tray_ams_and_slot_id(item.first, calib_info.ams_id, calib_info.slot_id, calib_info.tray_id);
calib_info.nozzle_diameter = nozzle_dia;
calib_info.filament_id = item.second->filament_id;
calib_info.setting_id = item.second->setting_id;
@@ -620,10 +643,12 @@ void PressureAdvanceWizard::on_cali_start()
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
return;
}
int selected_tray_id = 0;
CalibInfo calib_info;
calib_info.dev_id = curr_obj->dev_id;
calib_info.select_ams = "[" + std::to_string(selected_filaments.begin()->first) + "]";
get_tray_ams_and_slot_id(selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
Preset *preset = selected_filaments.begin()->second;
Preset * temp_filament_preset = new Preset(preset->type, preset->name + "_temp");
temp_filament_preset->config = preset->config;
@@ -656,10 +681,10 @@ void PressureAdvanceWizard::on_cali_start()
pa_cali_method = ManualPaCaliMethod::PA_LINE;
else if (calib_info.params.mode == CalibMode::Calib_PA_Pattern)
pa_cali_method = ManualPaCaliMethod::PA_PATTERN;
cali_page->set_pa_cali_image(int(pa_cali_method));
curr_obj->manual_pa_cali_method = pa_cali_method;
if (curr_obj->get_printer_series() != PrinterSeries::SERIES_X1 && curr_obj->pa_calib_tab.size() >= MAX_PA_HISTORY_RESULTS_NUMS) {
MessageDialog msg_dlg(nullptr, wxString::Format(_L("This machine type can only hold 16 history results per nozzle. "
"You can delete the existing historical results and then start calibration. "
@@ -740,7 +765,7 @@ void PressureAdvanceWizard::on_cali_save()
auto iter = std::find_if(curr_obj->pa_calib_tab.begin(), curr_obj->pa_calib_tab.end(), [&new_pa_cali_result](const PACalibResult &item) {
return item.name == new_pa_cali_result.name && item.filament_id == item.filament_id;
});
if (iter != curr_obj->pa_calib_tab.end()) {
MessageDialog
msg_dlg(nullptr,
@@ -819,7 +844,7 @@ void FlowRateWizard::create_pages()
coarse_save_step = new CalibrationWizardPageStep(new CalibrationFlowCoarseSavePage(m_scrolledWindow));
cali_fine_step = new CalibrationWizardPageStep(new CalibrationCaliPage(m_scrolledWindow, m_mode, CaliPageType::CALI_PAGE_FINE_CALI));
fine_save_step = new CalibrationWizardPageStep(new CalibrationFlowFineSavePage(m_scrolledWindow));
// auto
cali_step = new CalibrationWizardPageStep(new CalibrationCaliPage(m_scrolledWindow, m_mode));
save_step = new CalibrationWizardPageStep(new CalibrationFlowX1SavePage(m_scrolledWindow));
@@ -897,7 +922,7 @@ void FlowRateWizard::on_cali_action(wxCommandEvent& evt)
else if (action == CaliPageActionType::CALI_ACTION_CALI) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
on_cali_start();
}
}
else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
CaliPresetStage stage = CaliPresetStage::CALI_MANULA_STAGE_NONE;
float cali_value = 0.0f;
@@ -908,7 +933,7 @@ void FlowRateWizard::on_cali_action(wxCommandEvent& evt)
m_curr_step->chain(cali_fine_step);
}
// automatically jump to next step when print job is sending finished.
}
}
else {
on_cali_start();
}
@@ -989,6 +1014,7 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
X1CCalibInfos::X1CCalibInfo calib_info;
calib_info.tray_id = item.first;
get_tray_ams_and_slot_id(item.first, calib_info.ams_id, calib_info.slot_id, calib_info.tray_id);
calib_info.nozzle_diameter = nozzle_dia;
calib_info.filament_id = item.second->filament_id;
calib_info.setting_id = item.second->setting_id;
@@ -1039,7 +1065,9 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
}
if (!selected_filaments.empty()) {
calib_info.select_ams = "[" + std::to_string(selected_filaments.begin()->first) + "]";
int selected_tray_id = 0;
get_tray_ams_and_slot_id(selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
Preset* preset = selected_filaments.begin()->second;
temp_filament_preset = new Preset(preset->type, preset->name + "_temp");
temp_filament_preset->config = preset->config;
@@ -1307,7 +1335,7 @@ void FlowRateWizard::cache_coarse_info(MachineObject *obj)
wxString out_name;
coarse_page->get_result(&obj->cache_flow_ratio, &out_name);
back_preset_info(obj, false);
}
@@ -1317,7 +1345,7 @@ MaxVolumetricSpeedWizard::MaxVolumetricSpeedWizard(wxWindow* parent, wxWindowID
create_pages();
}
void MaxVolumetricSpeedWizard::create_pages()
void MaxVolumetricSpeedWizard::create_pages()
{
start_step = new CalibrationWizardPageStep(new CalibrationMaxVolumetricSpeedStartPage(m_scrolledWindow));
preset_step = new CalibrationWizardPageStep(new MaxVolumetricSpeedPresetPage(m_scrolledWindow, m_mode, true));
@@ -1415,7 +1443,9 @@ void MaxVolumetricSpeedWizard::on_cali_start()
calib_info.params = params;
calib_info.dev_id = curr_obj->dev_id;
if (!selected_filaments.empty()) {
calib_info.select_ams = "[" + std::to_string(selected_filaments.begin()->first) + "]";
int selected_tray_id = 0;
get_tray_ams_and_slot_id(selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
calib_info.filament_prest = selected_filaments.begin()->second;
}
+4 -3
View File
@@ -19,7 +19,7 @@ public:
CalibrationWizardPageStep(CalibrationWizardPage* data) {
page = data;
}
CalibrationWizardPageStep* prev { nullptr };
CalibrationWizardPageStep* next { nullptr };
CalibrationWizardPage* page { nullptr };
@@ -57,7 +57,7 @@ public:
}
virtual void set_cali_method(CalibrationMethod method);
CalibMode get_calibration_mode() { return m_mode; }
bool save_preset(const std::string &old_preset_name, const std::string &new_preset_name, const std::map<std::string, ConfigOption *> &key_values, wxString& message);
@@ -71,6 +71,7 @@ public:
protected:
void on_cali_go_home();
void get_tray_ams_and_slot_id(int in_tray_id, int &ams_id, int &slot_id, int &tray_id);
protected:
/* wx widgets*/
@@ -89,7 +90,7 @@ protected:
CalibrationWizardPageStep* preset_step { nullptr };
CalibrationWizardPageStep* cali_step { nullptr };
CalibrationWizardPageStep* save_step { nullptr };
CalibrationWizardPageStep* cali_coarse_step { nullptr };
CalibrationWizardPageStep* coarse_save_step { nullptr };
CalibrationWizardPageStep* cali_fine_step { nullptr };
+2 -2
View File
@@ -495,8 +495,8 @@ float CalibrationCaliPage::get_selected_calibration_nozzle_dia(MachineObject* ob
return obj->cali_selected_nozzle_dia;
// return default nozzle if nozzle diameter is set
if (obj->nozzle_diameter > 1e-3 && obj->nozzle_diameter < 10.0f)
return obj->nozzle_diameter;
if (obj->m_extder_data.extders[0].current_nozzle_diameter > 1e-3 && obj->m_extder_data.extders[0].current_nozzle_diameter < 10.0f)
return obj->m_extder_data.extders[0].current_nozzle_diameter;
// return 0.4 by default
return 0.4;
+18 -14
View File
@@ -614,12 +614,12 @@ void CalibrationPresetPage::create_filament_list_panel(wxWindow* parent)
auto ams_items_sizer = new wxBoxSizer(wxHORIZONTAL);
for (int i = 0; i < 4; i++) {
AMSinfo temp_info = AMSinfo{ std::to_string(i), std::vector<Caninfo>{} };
auto amsitem = new AMSItem(m_multi_ams_panel, wxID_ANY, temp_info);
auto amsitem = new AMSPreview(m_multi_ams_panel, wxID_ANY, temp_info);
amsitem->Bind(wxEVT_LEFT_DOWN, [this, amsitem](wxMouseEvent& e) {
on_switch_ams(amsitem->m_amsinfo.ams_id);
on_switch_ams(amsitem->get_ams_id());
e.Skip();
});
m_ams_item_list.push_back(amsitem);
m_ams_preview_list.push_back(amsitem);
ams_items_sizer->Add(amsitem, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(6));
}
multi_ams_sizer->Add(ams_items_sizer, 0);
@@ -896,12 +896,11 @@ void CalibrationPresetPage::on_select_tray(wxCommandEvent& event)
void CalibrationPresetPage::on_switch_ams(std::string ams_id)
{
for (auto i = 0; i < m_ams_item_list.size(); i++) {
AMSItem* item = m_ams_item_list[i];
if (item->m_amsinfo.ams_id == ams_id) {
for (auto i = 0; i < m_ams_preview_list.size(); i++) {
AMSPreview *item = m_ams_preview_list[i];
if (item->get_ams_id() == ams_id) {
item->OnSelected();
}
else {
} else {
item->UnSelected();
}
}
@@ -1505,7 +1504,7 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
// set nozzle value from machine
bool nozzle_is_set = false;
for (int i = 0; i < NOZZLE_LIST_COUNT; i++) {
if (abs(obj->nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
if (abs(obj->m_extder_data.extders[0].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
if (m_comboBox_nozzle_dia->GetCount() > i) {
m_comboBox_nozzle_dia->SetSelection(i);
nozzle_is_set = true;
@@ -1556,7 +1555,12 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
{
if (!obj) return;
std::map<int, DynamicPrintConfig> full_filament_ams_list = wxGetApp().sidebar().build_filament_ams_list(obj);
std::map<int, DynamicPrintConfig> old_full_filament_ams_list = wxGetApp().sidebar().build_filament_ams_list(obj);
std::map<int, DynamicPrintConfig> full_filament_ams_list;
for (auto ams_item : old_full_filament_ams_list) {
int key = ams_item.first & 0x0FFFF;
full_filament_ams_list[key] = std::move(ams_item.second);
}
// sync filament_ams_list from obj ams list
filament_ams_list.clear();
@@ -1611,8 +1615,8 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
}
}
for (auto i = 0; i < m_ams_item_list.size(); i++) {
AMSItem* item = m_ams_item_list[i];
for (auto i = 0; i < m_ams_preview_list.size(); i++) {
AMSPreview* item = m_ams_preview_list[i];
if (ams_info.size() > 1) {
if (i < ams_info.size()) {
item->Update(ams_info[i]);
@@ -1780,7 +1784,7 @@ void CalibrationPresetPage::update_filament_combobox(std::string ams_id)
empty_config.set_key_value("filament_colour", new ConfigOptionStrings{ "" });
empty_config.set_key_value("filament_exist", new ConfigOptionBools{ false });
/* update virtual tray combo box*/
// update virtual tray combo box
m_virtual_tray_comboBox->update_from_preset();
auto it = std::find_if(filament_ams_list.begin(), filament_ams_list.end(), [](auto& entry) {
return entry.first == VIRTUAL_TRAY_ID;
@@ -1836,7 +1840,7 @@ Preset* CalibrationPresetPage::get_printer_preset(MachineObject* obj, float nozz
std::string model_id = printer_it->get_current_printer_type(preset_bundle);
std::string printer_type = obj->printer_type;
if (obj->is_support_p1s_plus) { printer_type = "C12"; }
if (obj->is_support_upgrade_kit && obj->installed_upgrade_kit) { printer_type = "C12"; }
if (model_id.compare(printer_type) == 0
&& printer_nozzle_vals
&& abs(printer_nozzle_vals->get_at(0) - nozzle_value) < 1e-3) {
@@ -284,8 +284,8 @@ protected:
FilamentComboBoxList m_filament_comboBox_list;
FilamentComboBox* m_virtual_tray_comboBox;
std::vector<AMSItem*> m_ams_item_list;
std::vector<AMSPreview*> m_ams_preview_list;
// for update filament combobox, key : tray_id
std::map<int, DynamicPrintConfig> filament_ams_list;
+246 -15
View File
@@ -6,6 +6,8 @@
namespace Slic3r { namespace GUI {
#define CALIBRATION_SAVE_AMS_NAME_SIZE wxSize(FromDIP(20), FromDIP(24))
#define CALIBRATION_SAVE_NUMBER_INPUT_SIZE wxSize(FromDIP(100), FromDIP(24))
#define CALIBRATION_SAVE_INPUT_SIZE wxSize(FromDIP(240), FromDIP(24))
#define FLOW_RATE_MAX_VALUE 1.15
@@ -56,7 +58,7 @@ static wxString get_default_name(wxString filament_name, CalibMode mode){
return filament_name;
}
static wxString get_tray_name_by_tray_id(int tray_id)
static wxString get_tray_name_by_tray_id(int tray_id)
{
wxString tray_name;
if (tray_id == VIRTUAL_TRAY_ID) {
@@ -125,14 +127,14 @@ CaliPASaveAutoPanel::CaliPASaveAutoPanel(
const wxPoint& pos,
const wxSize& size,
long style)
: wxPanel(parent, id, pos, size, style)
: wxPanel(parent, id, pos, size, style)
{
SetBackgroundColour(*wxWHITE);
m_top_sizer = new wxBoxSizer(wxVERTICAL);
create_panel(this);
this->SetSizer(m_top_sizer);
m_top_sizer->Fit(this);
}
@@ -200,6 +202,11 @@ std::vector<std::pair<int, std::string>> CaliPASaveAutoPanel::default_naming(std
void CaliPASaveAutoPanel::sync_cali_result(const std::vector<PACalibResult>& cali_result, const std::vector<PACalibResult>& history_result)
{
if (m_obj && m_obj->is_multi_extruders()) {
sync_cali_result_for_multi_extruder(cali_result, history_result);
return;
}
m_history_results = history_result;
m_calib_results.clear();
for (auto& item : cali_result) {
@@ -391,7 +398,7 @@ void CaliPASaveAutoPanel::save_to_result_from_widgets(wxWindow* window, bool* ou
}
m_calib_results[tray_id].name = into_u8(name);
}
auto childern = window->GetChildren();
for (auto child : childern) {
save_to_result_from_widgets(child, out_is_valid, out_msg);
@@ -444,6 +451,230 @@ bool CaliPASaveAutoPanel::get_result(std::vector<PACalibResult>& out_result) {
}
}
void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<PACalibResult>& cali_result, const std::vector<PACalibResult>& history_result)
{
if (!m_obj)
return;
m_is_all_failed = true;
bool part_failed = false;
if (cali_result.empty())
part_failed = true;
m_history_results = history_result;
m_calib_results.clear();
for (auto &item : cali_result) {
if (item.confidence == 0) {
int tray_id = 4 * item.ams_id + item.slot_id;
m_calib_results[tray_id] = item;
}
}
m_grid_panel->DestroyChildren();
auto grid_sizer = new wxBoxSizer(wxHORIZONTAL);
const int COLUMN_GAP = FromDIP(10);
const int ROW_GAP = FromDIP(10);
wxStaticBoxSizer* left_sizer = new wxStaticBoxSizer(wxVERTICAL, m_grid_panel, "Left extruder");
wxStaticBoxSizer* right_sizer = new wxStaticBoxSizer(wxVERTICAL, m_grid_panel, "Right extruder");
grid_sizer->Add(left_sizer);
grid_sizer->AddSpacer(COLUMN_GAP);
grid_sizer->Add(right_sizer);
wxFlexGridSizer *left_grid_sizer = new wxFlexGridSizer(3, COLUMN_GAP, ROW_GAP);
wxFlexGridSizer *right_grid_sizer = new wxFlexGridSizer(3, COLUMN_GAP, ROW_GAP);
left_sizer->Add(left_grid_sizer);
right_sizer->Add(right_grid_sizer);
// main extruder
{
left_grid_sizer->Add(new wxStaticText(m_grid_panel, wxID_ANY, ""), 1, wxEXPAND); // fill empty space
auto brand_title = new Label(m_grid_panel, _L("Name"), 0, CALIBRATION_SAVE_INPUT_SIZE);
brand_title->SetFont(Label::Head_14);
left_grid_sizer->Add(brand_title, 1, wxALIGN_CENTER);
auto k_title = new Label(m_grid_panel, _L("Factor K"), 0, CALIBRATION_SAVE_NUMBER_INPUT_SIZE);
k_title->SetFont(Label::Head_14);
left_grid_sizer->Add(k_title, 1, wxALIGN_CENTER);
}
// deputy extruder
{
right_grid_sizer->Add(new wxStaticText(m_grid_panel, wxID_ANY, ""), 1, wxEXPAND); // fill empty space
auto brand_title = new Label(m_grid_panel, _L("Name"), 0, CALIBRATION_SAVE_INPUT_SIZE);
brand_title->SetFont(Label::Head_14);
right_grid_sizer->Add(brand_title, 1, wxALIGN_CENTER);
auto k_title = new Label(m_grid_panel, _L("Factor K"), 0, CALIBRATION_SAVE_NUMBER_INPUT_SIZE);
k_title->SetFont(Label::Head_14);
right_grid_sizer->Add(k_title, 1, wxALIGN_CENTER);
}
std::vector<std::pair<int, std::string>> preset_names;
for (auto &info : m_obj->selected_cali_preset) {
preset_names.push_back({info.tray_id, info.name});
}
preset_names = default_naming(preset_names);
bool left_first_add_item = true;
bool right_first_add_item = true;
for (auto &item : cali_result) {
bool result_failed = false;
if (item.confidence != 0) {
result_failed = true;
part_failed = true;
} else {
m_is_all_failed = false;
}
//wxBoxSizer *item_data_sizer = new wxBoxSizer(wxHORIZONTAL);
auto tray_title = new Label(m_grid_panel, "", 0, CALIBRATION_SAVE_AMS_NAME_SIZE);
tray_title->SetFont(Label::Head_14);
wxString tray_name = get_tray_name_by_tray_id(item.tray_id);
tray_title->SetLabel(tray_name);
auto k_value = new GridTextInput(m_grid_panel, "", "", CALIBRATION_SAVE_NUMBER_INPUT_SIZE, item.tray_id, GridTextInputType::K);
auto n_value = new GridTextInput(m_grid_panel, "", "", CALIBRATION_SAVE_NUMBER_INPUT_SIZE, item.tray_id, GridTextInputType::N);
k_value->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
n_value->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
auto k_value_failed = new Label(m_grid_panel, _L("Failed"));
auto n_value_failed = new Label(m_grid_panel, _L("Failed"));
auto comboBox_tray_name = new GridComboBox(m_grid_panel, CALIBRATION_SAVE_INPUT_SIZE, item.tray_id);
auto tray_name_failed = new Label(m_grid_panel, " - ");
wxArrayString selections;
static std::vector<PACalibResult> filtered_results;
filtered_results.clear();
for (auto history : history_result) {
if (history.filament_id == item.filament_id
&& history.extruder_id == item.extruder_id
&& history.nozzle_volume_type == item.nozzle_volume_type
&& history.nozzle_diameter == item.nozzle_diameter) {
filtered_results.push_back(history);
selections.push_back(from_u8(history.name));
}
}
comboBox_tray_name->Set(selections);
auto set_edit_mode = [this, k_value, n_value, k_value_failed, n_value_failed, comboBox_tray_name, tray_name_failed](std::string str) {
if (str == "normal") {
comboBox_tray_name->Show();
tray_name_failed->Show(false);
k_value->Show();
n_value->Show();
k_value_failed->Show(false);
n_value_failed->Show(false);
}
if (str == "failed") {
comboBox_tray_name->Show(false);
tray_name_failed->Show();
k_value->Show(false);
n_value->Show(false);
k_value_failed->Show();
n_value_failed->Show();
}
// hide n value
n_value->Hide();
n_value_failed->Hide();
m_grid_panel->Layout();
m_grid_panel->Update();
};
if (!result_failed) {
set_edit_mode("normal");
auto k_str = wxString::Format("%.3f", item.k_value);
auto n_str = wxString::Format("%.3f", item.n_coef);
k_value->GetTextCtrl()->SetValue(k_str);
n_value->GetTextCtrl()->SetValue(n_str);
for (auto &name : preset_names) {
if (item.tray_id == name.first) { comboBox_tray_name->SetValue(from_u8(name.second)); }
}
comboBox_tray_name->Bind(wxEVT_COMBOBOX, [this, comboBox_tray_name, k_value, n_value](auto &e) {
int selection = comboBox_tray_name->GetSelection();
auto history = filtered_results[selection];
});
} else {
set_edit_mode("failed");
}
if ((m_obj->is_main_extruder_on_left() && item.extruder_id == 0)
|| (!m_obj->is_main_extruder_on_left() && item.extruder_id == 1)) {
if (left_first_add_item) {
wxString title_name = left_sizer->GetStaticBox()->GetLabel();
title_name += " - ";
title_name += get_nozzle_volume_type_name(item.nozzle_volume_type);
left_sizer->GetStaticBox()->SetLabel(title_name);
left_first_add_item = false;
}
left_grid_sizer->Add(tray_title, 1, wxEXPAND);
if (comboBox_tray_name->IsShown()) {
left_grid_sizer->Add(comboBox_tray_name, 1, wxEXPAND);
} else {
left_grid_sizer->Add(tray_name_failed, 1, wxEXPAND);
}
if (k_value->IsShown()) {
left_grid_sizer->Add(k_value, 1, wxEXPAND);
} else {
left_grid_sizer->Add(k_value_failed, 1, wxEXPAND);
}
}
else {
if (right_first_add_item) {
wxString title_name = right_sizer->GetStaticBox()->GetLabel();
title_name += " - ";
title_name += get_nozzle_volume_type_name(item.nozzle_volume_type);
right_sizer->GetStaticBox()->SetLabel(title_name);
right_first_add_item = false;
}
right_grid_sizer->Add(tray_title, 1, wxEXPAND);
if (comboBox_tray_name->IsShown()) {
right_grid_sizer->Add(comboBox_tray_name, 1, wxEXPAND);
} else {
right_grid_sizer->Add(tray_name_failed, 1, wxEXPAND);
}
if (k_value->IsShown()) {
right_grid_sizer->Add(k_value, 1, wxEXPAND);
} else {
right_grid_sizer->Add(k_value_failed, 1, wxEXPAND);
}
}
}
if (left_first_add_item)
left_sizer->Show(false);
if (right_first_add_item)
right_sizer->Show(false);
m_grid_panel->SetSizer(grid_sizer, true);
m_grid_panel->Bind(wxEVT_LEFT_DOWN, [this](auto &e) { SetFocusIgnoringChildren(); });
if (part_failed) {
m_part_failed_panel->Show();
m_complete_text_panel->Show();
if (m_is_all_failed) {
m_complete_text_panel->Hide();
}
} else {
m_complete_text_panel->Show();
m_part_failed_panel->Hide();
}
wxGetApp().UpdateDarkUIWin(this);
Layout();
}
CaliPASaveManualPanel::CaliPASaveManualPanel(
wxWindow* parent,
wxWindowID id,
@@ -521,7 +752,7 @@ void CaliPASaveManualPanel::create_panel(wxWindow* parent)
}
void CaliPASaveManualPanel::set_save_img() {
if (wxGetApp().app_config->get_language_code() == "zh-cn") {
if (wxGetApp().app_config->get_language_code() == "zh-cn") {
m_picture_panel->set_bmp(ScalableBitmap(this, "fd_calibration_manual_result_CN", 330));
} else {
m_picture_panel->set_bmp(ScalableBitmap(this, "fd_calibration_manual_result", 330));
@@ -778,19 +1009,19 @@ void CaliSavePresetValuePanel::set_save_name_title(const wxString& title) {
m_save_name_title->SetLabel(title);
}
void CaliSavePresetValuePanel::get_value(double& value)
{
m_input_value->GetTextCtrl()->GetValue().ToDouble(&value);
void CaliSavePresetValuePanel::get_value(double& value)
{
m_input_value->GetTextCtrl()->GetValue().ToDouble(&value);
}
void CaliSavePresetValuePanel::get_save_name(std::string& name)
{
name = into_u8(m_input_name->GetTextCtrl()->GetValue());
{
name = into_u8(m_input_name->GetTextCtrl()->GetValue());
}
void CaliSavePresetValuePanel::set_save_name(const std::string& name)
{
m_input_name->GetTextCtrl()->SetValue(name);
{
m_input_name->GetTextCtrl()->SetValue(name);
}
void CaliSavePresetValuePanel::msw_rescale()
@@ -1307,7 +1538,7 @@ void CalibrationFlowCoarseSavePage::create_page(wxWindow* parent)
}
void CalibrationFlowCoarseSavePage::set_save_img() {
if (wxGetApp().app_config->get_language_code() == "zh-cn") {
if (wxGetApp().app_config->get_language_code() == "zh-cn") {
m_picture_panel->set_bmp(ScalableBitmap(this, "flow_rate_calibration_coarse_result_CN", 350));
} else {
m_picture_panel->set_bmp(ScalableBitmap(this, "flow_rate_calibration_coarse_result", 350));
@@ -1491,7 +1722,7 @@ void CalibrationFlowFineSavePage::create_page(wxWindow* parent)
}
void CalibrationFlowFineSavePage::set_save_img() {
if (wxGetApp().app_config->get_language_code() == "zh-cn") {
if (wxGetApp().app_config->get_language_code() == "zh-cn") {
m_picture_panel->set_bmp(ScalableBitmap(this, "flow_rate_calibration_fine_result_CN", 350));
} else {
m_picture_panel->set_bmp(ScalableBitmap(this, "flow_rate_calibration_fine_result", 350));
+4 -1
View File
@@ -98,6 +98,9 @@ public:
bool get_result(std::vector<PACalibResult>& out_result);
bool is_all_failed() { return m_is_all_failed; }
protected:
void sync_cali_result_for_multi_extruder(const std::vector<PACalibResult> &cali_result, const std::vector<PACalibResult> &history_result);
protected:
wxBoxSizer* m_top_sizer;
wxPanel* m_complete_text_panel;
@@ -218,7 +221,7 @@ public:
bool is_all_failed() { return m_is_all_failed; }
virtual bool Show(bool show = true) override;
void msw_rescale() override;
protected:
@@ -168,9 +168,8 @@ void CalibrationPAStartPage::on_device_connected(MachineObject* obj)
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
}
// is support auto cali
bool is_support_pa_auto = (obj->home_flag >> 16 & 1) == 1;
if (!is_support_pa_auto) {
if (!obj->is_support_pa_calibration) {
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
}
}
@@ -319,8 +318,7 @@ void CalibrationFlowRateStartPage::on_device_connected(MachineObject* obj)
}
//is support auto cali
bool is_support_flow_rate_auto = (obj->home_flag >> 15 & 1) == 1;
if (!is_support_flow_rate_auto) {
if (!obj->is_support_flow_calibration) {
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
}
}
File diff suppressed because it is too large Load Diff
+166 -46
View File
@@ -37,6 +37,9 @@
#define HOLD_COUNT_CAMERA 6
#define GET_VERSION_RETRYS 10
#define RETRY_INTERNAL 2000
#define MAIN_NOZZLE_ID 0
#define VIRTUAL_TRAY_ID 254
#define START_SEQ_ID 20000
#define END_SEQ_ID 30000
@@ -136,6 +139,65 @@ enum ManualPaCaliMethod {
};
struct AmsSlot
{
std::string ams_id;
std::string slot_id;
};
struct Nozzle
{
int id;
NozzleType nozzle_type; // 0-stainless_steel 1-hardened_steel
float diameter = {0.4f}; // 0-0.2mm 1-0.4mm 2-0.6 mm3-0.8mm
int max_temp = 0;
int wear = 0;
};
struct NozzleData
{
int extder_exist; //0- none exist 1-exist
int cut_exist;
int state; //0-idle 1-checking
std::vector<Nozzle> nozzles;
};
struct Extder
{
int id; // 0-right 1-left
int ext_has_filament{0};
int buffer_has_filament{0};
int nozzle_exist{0};
std::vector<int> filam_bak;// the refill filam
int temp{0};
int target_temp{0};
AmsSlot spre; // tray_pre
AmsSlot snow; // tray_now
AmsSlot star; // tray_tar
int ams_stat{0};
int rfid_stat{0};
int nozzle_id; // nozzle id now
int target_nozzle_id; // target nozzle id
//current nozzle
NozzleType current_nozzle_type{NozzleType::ntUndefine}; // 0-hardened_steel 1-stainless_steel
float current_nozzle_diameter = {0.4f}; // 0-0.2mm 1-0.4mm 2-0.6 mm3-0.8mm
};
struct ExtderData
{
int current_extder_id{0};
int target_extder_id{0};
int total_extder_count {0};
std::vector<Extder> extders;
};
struct RatingInfo {
bool request_successful;
int http_code;
@@ -178,6 +240,12 @@ public:
return wxColour(ret[0], ret[1], ret[2], ret[3]);
}
bool operator==(AmsTray const &o) const
{
return id == o.id && type == o.type && filament_setting_id == o.filament_setting_id && color == o.color;
}
bool operator!=(AmsTray const &o) const { return !operator==(o); }
std::string id;
std::string tag_uid; // tag_uid
std::string setting_id; // tray_info_idx
@@ -223,18 +291,29 @@ public:
std::string get_filament_type();
};
#define INVALID_AMS_TEMPERATURE std::numeric_limits<float>::min()
class Ams {
class Ams
{
public:
Ams(std::string ams_id) {
id = ams_id;
Ams(std::string ams_id, int nozzle_id, int type_id)
{
id = ams_id;
nozzle = nozzle_id;
type = type_id;
}
std::string id;
int humidity = 5;
bool startup_read_opt{true};
bool tray_read_opt{false};
bool is_exists{false};
std::map<std::string, AmsTray*> trayList;
std::string id;
int left_dry_time = 0;
int humidity = 5;
int humidity_raw = -1; // the percentage, -1 means invalid. eg. 100 means 100%
float current_temperature = INVALID_AMS_TEMPERATURE; // the temperature
bool startup_read_opt{true};
bool tray_read_opt{false};
bool is_exists{false};
std::map<std::string, AmsTray *> trayList;
int nozzle;
int type{1}; // 0:dummy 1:ams 2:ams-lite 3:n3f 4:n3s
};
enum PrinterFirmwareType {
@@ -369,6 +448,7 @@ public:
{
public:
std::string name;
wxString product_name;
std::string sn;
std::string hw_ver;
std::string sw_ver;
@@ -377,18 +457,25 @@ public:
ModuleVersionInfo() :firmware_status(0) {
};
public:
bool isValid() const { return !sn.empty(); }
bool isAirPump() const { return product_name.Contains("Air Pump"); }
bool isLaszer() const { return product_name.Contains("Laser"); }
bool isCuttingModule() const { return product_name.Contains("Cutting Module"); }
};
enum SdcardState {
NO_SDCARD = 0,
HAS_SDCARD_NORMAL = 1,
HAS_SDCARD_ABNORMAL = 2,
SDCARD_STATE_NUM = 3
HAS_SDCARD_READONLY = 3,
SDCARD_STATE_NUM = 4
};
enum ActiveState {
NotActive,
Active,
NotActive,
Active,
UpdateToDate
};
@@ -419,9 +506,7 @@ public:
std::string dev_id;
bool local_use_ssl_for_mqtt { true };
bool local_use_ssl_for_ftp { true };
float nozzle_diameter { 0.0f };
int subscribe_counter{3};
std::string nozzle_type;
std::string dev_connection_type; /* lan | cloud */
std::string connection_type() { return dev_connection_type; }
std::string dev_connection_name; /* lan | eth */
@@ -453,9 +538,6 @@ public:
std::string product_name; // set by iot service, get /user/print
std::vector<int> filam_bak;
std::string bind_user_name;
std::string bind_user_id;
std::string bind_state; /* free | occupied */
@@ -483,7 +565,6 @@ public:
/* ams properties */
std::map<std::string, Ams*> amsList; // key: ams[id], start with 0
AmsTray vt_tray; // virtual tray
long ams_exist_bits = 0;
long tray_exist_bits = 0;
long tray_is_bbl_bits = 0;
@@ -495,9 +576,7 @@ public:
bool ams_calibrate_remain_flag { false };
bool ams_auto_switch_filament_flag { false };
bool ams_air_print_status { false };
bool ams_support_use_ams { false };
bool ams_support_virtual_tray { true };
int ams_humidity;
int ams_user_setting_hold_count = 0;
AmsStatusMain ams_status_main;
int ams_status_sub;
@@ -535,6 +614,8 @@ public:
// exceed index start with 0
bool is_mapping_exceed_filament(std::vector<FilamentInfo>& result, int &exceed_index);
void reset_mapping_result(std::vector<FilamentInfo>& result);
bool is_main_extruder_on_left() const;
bool is_multi_extruders() const;
/*online*/
bool online_rfid;
@@ -543,8 +624,8 @@ public:
int last_online_version = -1;
/* temperature */
float nozzle_temp;
float nozzle_temp_target;
//float nozzle_temp;
//float nozzle_temp_target;
float bed_temp;
float bed_temp_target;
float chamber_temp;
@@ -586,6 +667,10 @@ public:
std::string ota_new_version_number;
std::string ahb_new_version_number;
int get_version_retry = 0;
ModuleVersionInfo air_pump_version_info;
ModuleVersionInfo laser_version_info;
ModuleVersionInfo cutting_module_version_info;
std::map<std::string, ModuleVersionInfo> module_vers;
std::map<std::string, ModuleVersionInfo> new_ver_list;
std::map<std::string, ExtrusionRatioInfo> extrusion_ratio_map;
@@ -603,6 +688,7 @@ public:
wxString get_upgrade_result_str(int upgrade_err_code);
// key: ams_id start as 0,1,2,3
std::map<int, ModuleVersionInfo> get_ams_version();
void store_version_info(const ModuleVersionInfo& info);
/* printing */
std::string print_type;
@@ -625,6 +711,7 @@ public:
bool is_support_layer_num { false };
bool nozzle_blob_detection_enabled{ false };
int last_cali_version = -1;
int cali_version = -1;
float cali_selected_nozzle_dia { 0.0 };
// 1: record when start calibration in preset page
@@ -637,15 +724,14 @@ public:
ManualPaCaliMethod manual_pa_cali_method = ManualPaCaliMethod::PA_LINE;
bool has_get_pa_calib_tab{ false };
bool request_tab_from_bbs { false };
std::vector<PACalibResult> pa_calib_tab;
float pa_calib_tab_nozzle_dia;
bool get_pa_calib_result { false };
std::vector<PACalibResult> pa_calib_results;
bool get_flow_calib_result { false };
std::vector<FlowRatioCalibResult> flow_ratio_results;
void reset_pa_cali_history_result()
{
pa_calib_tab_nozzle_dia = 0.4f;
has_get_pa_calib_tab = false;
pa_calib_tab.clear();
}
@@ -707,23 +793,23 @@ public:
enum LiveviewLocal {
LVL_None,
LVL_Disable,
LVL_Local,
LVL_Local,
LVL_Rtsps,
LVL_Rtsp
} liveview_local{ LVL_None };
enum LiveviewRemote {
LVR_None,
LVR_Tutk,
LVR_Tutk,
LVR_Agora,
LVR_TutkAgora
} liveview_remote{ LVR_None };
enum FileLocal {
FL_None,
FL_None,
FL_Local
} file_local{ FL_None };
enum FileRemote {
FR_None,
FR_Tutk,
FR_None,
FR_Tutk,
FR_Agora,
FR_TutkAgora
} file_remote{ FR_None };
@@ -752,7 +838,9 @@ public:
bool is_support_ai_monitoring {false};
bool is_support_lidar_calibration {false};
bool is_support_build_plate_marker_detect{false};
bool is_support_pa_calibration{false};
bool is_support_flow_calibration{false};
bool is_support_auto_flow_calibration{false};
bool is_support_print_without_sd{false};
bool is_support_print_all{false};
bool is_support_send_to_sdcard {false};
@@ -775,12 +863,15 @@ public:
bool is_support_motor_noise_cali{false};
bool is_support_wait_sending_finish{false};
bool is_support_user_preset{false};
bool is_support_p1s_plus{false};
//bool is_support_p1s_plus{false};
bool is_support_nozzle_blob_detection{false};
bool is_support_air_print_detection{false};
bool is_support_filament_setting_inprinting{false};
bool is_support_agora{false};
bool is_support_upgrade_kit{false};
bool is_support_command_homing { false };// fun[32]
bool installed_upgrade_kit{false};
int nozzle_max_temperature = -1;
int bed_temperature_limit = -1;
@@ -819,16 +910,18 @@ public:
RatingInfo* rating_info { nullptr };
int request_model_result = 0;
bool get_model_mall_result_need_retry = false;
std::string obj_subtask_id; // subtask_id == 0 for sdcard
std::string subtask_name;
bool is_sdcard_printing();
bool has_sdcard();
bool is_timelapse();
bool is_recording_enable();
bool is_recording();
int get_liveview_remote();
int get_file_remote();
MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip);
~MachineObject();
@@ -854,6 +947,7 @@ public:
int command_xyz_abs();
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_task_abort();
@@ -865,14 +959,13 @@ public:
int command_set_nozzle(int temp);
int command_set_chamber(int temp);
// ams controls
int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
int command_ams_change_filament(int tray_id, int old_temp = 210, int new_temp = 210);
//int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
int command_ams_change_filament(bool load, std::string ams_id, std::string slot_id, int old_temp = 210, int new_temp = 210);
int command_ams_user_settings(int ams_id, bool start_read_opt, bool tray_read_opt, bool remain_flag = false);
int command_ams_user_settings(int ams_id, AmsOptionType op, bool value);
int command_ams_switch_filament(bool switch_filament);
int command_ams_air_print_detect(bool air_print_detect);
int command_ams_calibrate(int ams_id);
int command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max);
int command_ams_filament_settings(int ams_id, int slot_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max);
int command_ams_select_tray(std::string tray_id);
int command_ams_refresh_rfid(std::string tray_id);
int command_ams_control(std::string action);
@@ -908,7 +1001,7 @@ public:
int command_start_pa_calibration(const X1CCalibInfos& pa_data, int mode = 0); // 0: automatic mode; 1: manual mode. default: automatic mode
int command_set_pa_calibration(const std::vector<PACalibResult>& pa_calib_values, bool is_auto_cali);
int command_delete_pa_calibration(const PACalibIndexInfo& pa_calib);
int command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id = "");
int command_get_pa_calibration_tab(const PACalibExtruderInfo& calib_info);
int command_get_pa_calibration_result(float nozzle_diameter);
int commnad_select_pa_calibration(const PACalibIndexInfo& pa_calib_info);
@@ -958,9 +1051,9 @@ public:
/* Msg for display MsgFn */
typedef std::function<void(std::string topic, std::string payload)> MsgFn;
int publish_json(std::string json_str, int qos = 0);
int cloud_publish_json(std::string json_str, int qos = 0);
int local_publish_json(std::string json_str, int qos = 0);
int publish_json(std::string json_str, int qos = 0, int flag = 0);
int cloud_publish_json(std::string json_str, int qos = 0, int flag = 0);
int local_publish_json(std::string json_str, int qos = 0, int flag = 0);
int parse_json(std::string payload, bool key_filed_only = false);
int publish_gcode(std::string gcode_str);
@@ -977,14 +1070,36 @@ public:
bool is_firmware_info_valid();
std::string get_string_from_fantype(FanType type);
/*for more extruder*/
bool is_enable_np{ false };
bool is_enable_ams_np{ false };
ExtderData m_extder_data;
NozzleData m_nozzle_data;
/*vi slot data*/
AmsTray vt_tray; // virtual tray
//std::vector<AmsTray> vt_trays; // virtual tray for new
AmsTray parse_vt_tray(json vtray);
/*for parse new info*/
bool check_enable_np(const json& print) const;
void parse_new_info(json print);
bool is_nozzle_data_invalid();
int get_flag_bits(std::string str, int start, int count = 1) const;
int get_flag_bits(int num, int start, int count = 1, int base = 10) const;
/* Device Filament Check */
std::set<std::string> m_checked_filament;
std::string m_printer_preset_name;
std::map<std::string, std::pair<int, int>> m_filament_list; // filament_id, pair<min temp, max temp>
struct FilamentData
{
std::set<std::string> checked_filament;
std::string printer_preset_name;
std::map<std::string, std::pair<int, int>> filament_list; // filament_id, pair<min temp, max temp>
};
std::map<std::string, FilamentData> m_nozzle_filament_data;
void update_filament_list();
int get_flag_bits(std::string str, int start, int count = 1);
int get_flag_bits(int num, int start, int count = 1);
void update_printer_preset_name(const std::string &nozzle_diameter_str);
void update_printer_preset_name();
void check_ams_filament_valid();
};
class DeviceManager
@@ -1007,6 +1122,11 @@ public:
void keep_alive();
void check_pushing();
static float nozzle_diameter_conver(int diame);
static int nozzle_diameter_conver(float diame);
static std::string nozzle_type_conver(int type);
static int nozzle_type_conver(std::string& type);
MachineObject* get_default_machine();
MachineObject* get_local_selected_machine();
MachineObject* get_local_machine(std::string dev_id);
+12
View File
@@ -0,0 +1,12 @@
# GUI/DeviceTab
# usage -- GUI about device tab for BambuStudio
# date -- 2025.01.01
# status -- Building
list(APPEND SLIC3R_GUI_SOURCES
GUI/DeviceTab/uiAmsHumidityPopup.h
GUI/DeviceTab/uiAmsHumidityPopup.cpp
GUI/DeviceTab/uiDeviceUpdateVersion.h
GUI/DeviceTab/uiDeviceUpdateVersion.cpp
)
set(SLIC3R_GUI_SOURCES ${SLIC3R_GUI_SOURCES} PARENT_SCOPE)
@@ -0,0 +1,238 @@
//**********************************************************/
/* File: uiAmsHumidityPopup.cpp
* Description: The popup with Ams Humidity
*
* \n class uiAmsHumidityPopup
//**********************************************************/
#include "uiAmsHumidityPopup.h"
#include "slic3r/Utils/WxFontUtils.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/Widgets/StateColor.hpp"
#include <wx/dcgraph.h>
namespace Slic3r { namespace GUI {
uiAmsPercentHumidityDryPopup::uiAmsPercentHumidityDryPopup(wxWindow *parent)
: PopupWindow(parent, wxBORDER_NONE)
{
SetSize(wxSize(FromDIP(400), FromDIP(270)));
SetMinSize(wxSize(FromDIP(400), FromDIP(270)));
SetMaxSize(wxSize(FromDIP(400), FromDIP(270)));
idle_img = ScalableBitmap(this, "ams_drying", 16);
drying_img = ScalableBitmap(this, "ams_is_drying", 16);
close_img = ScalableBitmap(this, "hum_popup_close", 24);
Bind(wxEVT_PAINT, &uiAmsPercentHumidityDryPopup::paintEvent, this);
Bind(wxEVT_LEFT_UP, [this](auto &e) {
auto rect = ClientToScreen(wxPoint(0, 0));
auto close_left = rect.x + GetSize().x - close_img.GetBmpWidth() - FromDIP(38);
auto close_right = close_left + close_img.GetBmpWidth();
auto close_top = rect.y + FromDIP(24);
auto close_bottom = close_top + close_img.GetBmpHeight();
auto mouse_pos = ClientToScreen(e.GetPosition());
if (mouse_pos.x > close_left && mouse_pos.y > close_top && mouse_pos.x < close_right && mouse_pos.y < close_bottom) { Dismiss(); }
});
}
void uiAmsPercentHumidityDryPopup::Update(int humidiy_level, int humidity_percent, int left_dry_time, float current_temperature)
{
if (m_humidity_level != humidiy_level || m_humidity_percent != humidity_percent ||
m_left_dry_time != left_dry_time || m_current_temperature != current_temperature)
{
m_humidity_level = humidiy_level;
m_humidity_percent = humidity_percent;
m_left_dry_time = left_dry_time;
m_current_temperature = current_temperature;
Refresh();
}
}
void uiAmsPercentHumidityDryPopup::paintEvent(wxPaintEvent &evt)
{
wxPaintDC dc(this);
render(dc);
}
void uiAmsPercentHumidityDryPopup::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 uiAmsPercentHumidityDryPopup::doRender(wxDC &dc)
{
// background
{
dc.SetBrush(StateColor::darkModeColorFor(*wxWHITE));
dc.DrawRoundedRectangle(0, 0, GetSize().GetWidth(), GetSize().GetHeight(), 0);
}
dc.SetBrush(*wxTRANSPARENT_BRUSH);
wxPoint p;
// Header
{
dc.SetFont(::Label::Head_24);
dc.SetTextForeground(StateColor::darkModeColorFor(*wxBLACK));
//WxFontUtils::get_suitable_font_size(FromDIP(24), dc);
auto extent = dc.GetTextExtent(_L("Current AMS humidity"));
dc.DrawText(_L("Current AMS humidity"), (GetSize().GetWidth() - extent.GetWidth()) / 2, FromDIP(24));
}
// close icon
p.y += FromDIP(24);
dc.DrawBitmap(close_img.bmp(), GetSize().x - close_img.GetBmpWidth() - FromDIP(38), p.y);
// humitidy image
if (0 < m_humidity_level && m_humidity_level < 6)
{
ScalableBitmap humitidy_image;
if (wxGetApp().dark_mode())
{
humitidy_image = ScalableBitmap(this, "hum_level" + std::to_string(m_humidity_level) + "_no_num_light", 64);
}
else
{
humitidy_image = ScalableBitmap(this, "hum_level" + std::to_string(m_humidity_level) + "_no_num_light", 64);
}
p.y += 2 * FromDIP(24);
dc.DrawBitmap(humitidy_image.bmp(), (GetSize().GetWidth() - humitidy_image.GetBmpWidth()) / 2, p.y);
p.y += humitidy_image.GetBmpHeight();
}
// dry state
int spacing = FromDIP(5);
{
p.y += spacing;
if (m_left_dry_time > 0)
{
dc.DrawBitmap(drying_img.bmp(), GetSize().GetWidth() / 2 - drying_img.GetBmpWidth() - spacing, p.y);
}
else
{
dc.DrawBitmap(idle_img.bmp(), GetSize().GetWidth() / 2 - idle_img.GetBmpWidth() - spacing, p.y);
}
dc.SetFont(::Label::Body_14);
//WxFontUtils::get_suitable_font_size(idle_img.GetBmpHeight(), dc);
const wxString &dry_state = (m_left_dry_time > 0) ? _L("Drying") : _L("Idle");
auto dry_state_extent = dc.GetTextExtent(dry_state);
p.y += (idle_img.GetBmpHeight() - dry_state_extent.GetHeight());//align bottom
dc.DrawText(dry_state, GetSize().GetWidth() / 2 + spacing, p.y);
p.y += dry_state_extent.GetHeight();
}
// Grid area
{
p.y += 2 * spacing;
DrawGridArea(dc, p);
}
}
static vector<wxString> grid_header{ L("Humidity"), L("Temperature"), L("Left Time")};
void uiAmsPercentHumidityDryPopup::DrawGridArea(wxDC &dc, wxPoint start_p)
{
const wxColour& gray_clr = StateColor::darkModeColorFor(wxColour(194, 194, 194));
const wxColour& black_clr = StateColor::darkModeColorFor(*wxBLACK);
// Horizontal line
dc.SetPen(gray_clr);
int h_margin = FromDIP(20);
dc.DrawLine(h_margin, start_p.y, GetSize().GetWidth() - h_margin, start_p.y);
start_p.x = h_margin;
start_p.y += h_margin;
// Draw grid area
int toltal_col;
if (m_left_dry_time > 0)
{
toltal_col = 3;
}
else
{
toltal_col = 2;
}
int row_height = FromDIP(30);
int text_height = FromDIP(20);
int distance = (GetSize().GetWidth() - 2 * h_margin)/ toltal_col;
for (int col = 0; col < toltal_col; ++col)
{
const wxString& header = _L(grid_header[col]);
dc.SetFont(::Label::Body_14);
//WxFontUtils::get_suitable_font_size(text_height, dc);
const auto &header_extent = dc.GetTextExtent(header);
int left = start_p.x + (distance - header_extent.GetWidth()) / 2;
dc.SetPen(gray_clr);
dc.DrawText(header, left, start_p.y);
// row content
dc.SetPen(black_clr);
if (header == _L("Humidity"))
{
const wxString &humidity_str = wxString::Format("%d%%", m_humidity_percent);
dc.DrawText(humidity_str, left, start_p.y + row_height);
}
else if (header == _L("Temperature"))
{
const wxString &temp_str = wxString::Format(_L("%.1f \u2103"), m_current_temperature);
dc.DrawText(temp_str, left, start_p.y + row_height);
}
else if (header == _L("Left Time"))
{
const wxString &time_str = wxString::Format(_L("%d : %d"), m_left_dry_time / 60, m_left_dry_time % 60);
dc.DrawText(time_str, left, start_p.y + row_height);
}
start_p.x += distance;
if (col < toltal_col - 1) /*draw splitter*/
{
dc.SetPen(gray_clr);
dc.DrawLine(start_p.x, start_p.y, start_p.x, start_p.y + 2 * row_height);
}
}
}
void uiAmsPercentHumidityDryPopup::msw_rescale()
{
idle_img.msw_rescale();
drying_img.msw_rescale();
close_img.msw_rescale();
Refresh();
}
} // namespace GUI
} // namespace Slic3r
@@ -0,0 +1,76 @@
//**********************************************************/
/* File: uiAmsHumidityPopup.h
* Description: The popup with Ams Humidity
*
* \n class uiAmsHumidityPopup
//**********************************************************/
#pragma once
#include "slic3r/GUI/Widgets/Label.hpp"
#include "slic3r/GUI/Widgets/PopupWindow.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
//Previous defintions
class wxGrid;
namespace Slic3r { namespace GUI {
struct uiAmsHumidityInfo
{
std::string ams_id;
int humidity_level = -1;
int humidity_percent = -1;
float current_temperature;
int left_dry_time = -1;
};
/// </summary>
/// Note: The popup of Ams Humidity with percentage and dry time
/// Author: xin.zhang
/// </summary>
class uiAmsPercentHumidityDryPopup : public PopupWindow
{
public:
uiAmsPercentHumidityDryPopup(wxWindow *parent);
~uiAmsPercentHumidityDryPopup() = default;
public:
void Update(uiAmsHumidityInfo *info) { m_ams_id = info->ams_id; Update(info->humidity_level, info->humidity_percent, info->left_dry_time, info->current_temperature); };
std::string get_owner_ams_id() const { return m_ams_id; }
virtual void OnDismiss() wxOVERRIDE {};
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE { return true;};
void msw_rescale();
private:
void Update(int humidiy_level, int humidity_percent, int left_dry_time, float current_temperature);
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void doRender(wxDC &dc);
void DrawGridArea(wxDC &dc, wxPoint start_p);
private:
/*owner ams id*/
std::string m_ams_id;
int m_humidity_level = 0;
int m_humidity_percent = 0;
int m_left_dry_time = 0;
float m_current_temperature = 0;
// Bitmap
ScalableBitmap close_img;
ScalableBitmap drying_img;
ScalableBitmap idle_img;
// Widgets
wxStaticBitmap* m_humidity_img;
wxGrid* m_grid_area;
};
}} // namespace Slic3r::GUI
@@ -0,0 +1,103 @@
//**********************************************************/
/* File: uiDeviceUpdateVersion.cpp
* Description: The panel with firmware info
*
* \n class uiDeviceUpdateVersion
//**********************************************************/
#include "uiDeviceUpdateVersion.h"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
#include <wx/stattext.h>
#define SERIAL_STR L("Serial:")
#define VERSION_STR L("Version:")
using namespace Slic3r::GUI;
uiDeviceUpdateVersion::uiDeviceUpdateVersion(wxWindow* parent,
wxWindowID id /*= wxID_ANY*/,
const wxPoint& pos /*= wxDefaultPosition*/,
const wxSize& size /*= wxDefaultSize*/,
long style /*= wxTAB_TRAVERSAL*/)
: wxPanel(parent, id, pos, size, style)
{
CreateWidgets();
}
void uiDeviceUpdateVersion::UpdateInfo(const MachineObject::ModuleVersionInfo& info)
{
SetName(I18N::translate(info.product_name));
SetSerial(info.sn);
SetVersion(info.sw_ver, info.sw_new_ver);
}
void uiDeviceUpdateVersion::SetVersion(const wxString& cur_version, const wxString& latest_version)
{
if (cur_version.empty())
{
return;
}
if (!latest_version.empty() && (cur_version != latest_version))
{
const wxString& shown_ver = wxString::Format("%s->%s", cur_version, latest_version);
m_dev_version->SetLabel(shown_ver);
if (!m_dev_upgrade_indicator->IsShown())
{
m_dev_upgrade_indicator->Show(true);
}
}
else
{
const wxString& shown_ver = wxString::Format("%s(%s)", cur_version, _L("Latest version"));
m_dev_version->SetLabel(shown_ver);
if (m_dev_upgrade_indicator->IsShown())
{
m_dev_upgrade_indicator->Hide();
}
}
}
void uiDeviceUpdateVersion::CreateWidgets()
{
m_dev_name = new wxStaticText(this, wxID_ANY, "_");
m_dev_snl = new wxStaticText(this, wxID_ANY, "_");
m_dev_version = new wxStaticText(this, wxID_ANY, "_");
wxStaticText* serial_text = new wxStaticText(this, wxID_ANY, _L(SERIAL_STR));
wxStaticText* version_text = new wxStaticText(this, wxID_ANY, _L(VERSION_STR));
// The main sizer
wxFlexGridSizer* main_sizer = new wxFlexGridSizer(3, 3, 0, 0);
main_sizer->AddGrowableCol(1);
main_sizer->SetFlexibleDirection(wxHORIZONTAL);
main_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
main_sizer->Add(m_dev_name, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
main_sizer->Add(0, 0, wxALL, wxEXPAND);
main_sizer->Add(0, 0, wxALL, wxEXPAND);
main_sizer->Add(serial_text, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
main_sizer->Add(m_dev_snl, 0, wxALIGN_LEFT | wxALL, FromDIP(5));
main_sizer->Add(0, 0, wxALL, wxEXPAND);
m_dev_upgrade_indicator = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(5), FromDIP(5)));
m_dev_upgrade_indicator->SetBitmap(ScalableBitmap(this, "monitor_upgrade_online", 5).bmp());
wxBoxSizer* version_hsizer = new wxBoxSizer(wxHORIZONTAL);
version_hsizer->Add(m_dev_upgrade_indicator, 0, wxALIGN_CENTER_VERTICAL);
version_hsizer->AddSpacer(FromDIP(5));
version_hsizer->Add(version_text, 0);
main_sizer->Add(version_hsizer, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
main_sizer->Add(m_dev_version, 0, wxALIGN_LEFT | wxALL, FromDIP(5));
main_sizer->Add(0, 0, wxALL, wxEXPAND);
// Updating
SetSizer(main_sizer);
Layout();
}
@@ -0,0 +1,47 @@
//**********************************************************/
/* File: uiDeviceUpdateVersion.h
* Description: The panel with firmware info
*
* \n class uiDeviceUpdateVersion
//**********************************************************/
#pragma once
#include <wx/panel.h>
#include "slic3r/GUI/wxExtensions.hpp"
#include "slic3r/GUI/DeviceManager.hpp"
// Previous defintions
class wxStaticText;
class wxStaticBitmap;
namespace Slic3r::GUI
{
// @Class uiDeviceUpdateVersion
// @Note The panel with firmware info
class uiDeviceUpdateVersion : public wxPanel
{
public:
uiDeviceUpdateVersion(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL);
~uiDeviceUpdateVersion() = default;
public:
void UpdateInfo(const MachineObject::ModuleVersionInfo& info);
private:
void CreateWidgets();
void SetName(const wxString& str) { m_dev_name->SetLabel(str); };
void SetSerial(const wxString& str) { m_dev_snl->SetLabel(str); };
void SetVersion(const wxString& cur_version, const wxString& latest_version);
private:
wxStaticText* m_dev_name;
wxStaticText* m_dev_snl;
wxStaticText* m_dev_version;
wxStaticBitmap* m_dev_upgrade_indicator;
};
};// end of namespace Slic3r::GUI
+103 -9
View File
@@ -122,6 +122,13 @@
#include "dark_mode.hpp"
#include "wx/headerctrl.h"
#include "wx/msw/headerctrl.h"
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS2)(
HANDLE hProcess,
USHORT *pProcessMachine,
USHORT *pNativeMachine
);
#endif // _MSW_DARK_MODE
#endif // __WINDOWS__
@@ -1166,7 +1173,7 @@ std::string GUI_App::get_plugin_url(std::string name, std::string country_code)
{
std::string url = get_http_url(country_code);
std::string curr_version = SLIC3R_VERSION;
std::string curr_version = NetworkAgent::use_legacy_network ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : BAMBU_NETWORK_AGENT_VERSION;
std::string using_version = curr_version.substr(0, 9) + "00";
if (name == "cameratools")
using_version = curr_version.substr(0, 6) + "00.00";
@@ -1211,6 +1218,17 @@ int GUI_App::download_plugin(std::string name, std::string package_name, Install
fs::path tmp_path = target_file_path;
tmp_path += format(".%1%%2%", get_current_pid(), ".tmp");
#if defined(__WINDOWS__)
if (is_running_on_arm64() && !NetworkAgent::use_legacy_network) {
//set to arm64 for plugins
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
current_headers["X-BBL-OS-Type"] = "windows_arm";
Slic3r::Http::set_extra_headers(current_headers);
BOOST_LOG_TRIVIAL(info) << boost::format("download_plugin: set X-BBL-OS-Type to windows_arm");
}
#endif
// get_url
std::string url = get_plugin_url(name, app_config->get_country_code());
std::string download_url;
@@ -1268,6 +1286,17 @@ int GUI_App::download_plugin(std::string name, std::string package_name, Install
result = -1;
}).perform_sync();
#if defined(__WINDOWS__)
if (is_running_on_arm64() && !NetworkAgent::use_legacy_network) {
//set back
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
current_headers["X-BBL-OS-Type"] = "windows";
Slic3r::Http::set_extra_headers(current_headers);
BOOST_LOG_TRIVIAL(info) << boost::format("download_plugin: set X-BBL-OS-Type back to windows");
}
#endif
bool cancel = false;
if (result < 0) {
j["result"] = "failed";
@@ -1542,7 +1571,7 @@ bool GUI_App::check_networking_version()
if (!network_ver.empty()) {
BOOST_LOG_TRIVIAL(info) << "get_network_agent_version=" << network_ver;
}
std::string studio_ver = SLIC3R_VERSION;
std::string studio_ver = NetworkAgent::use_legacy_network ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : BAMBU_NETWORK_AGENT_VERSION;
if (network_ver.length() >= 8) {
if (network_ver.substr(0,8) == studio_ver.substr(0,8)) {
m_networking_compatible = true;
@@ -1751,6 +1780,8 @@ void GUI_App::init_networking_callbacks()
CallAfter([this, dev_id, msg] {
if (m_is_closing)
return;
this->process_network_msg(dev_id, msg);
MachineObject* obj = this->m_device_manager->get_user_machine(dev_id);
if (obj) {
obj->is_ams_need_update = false;
@@ -1803,6 +1834,7 @@ void GUI_App::init_networking_callbacks()
if (m_is_closing)
return;
this->process_network_msg(dev_id, msg);
MachineObject* obj = m_device_manager->get_my_machine(dev_id);
if (!obj || !obj->is_lan_mode_printer()) {
obj = m_device_manager->get_local_machine(dev_id);
@@ -2048,7 +2080,11 @@ std::map<std::string, std::string> GUI_App::get_extra_header()
extra_headers.insert(std::make_pair("X-BBL-Client-Name", SLIC3R_APP_NAME));
extra_headers.insert(std::make_pair("X-BBL-Client-Version", VersionInfo::convert_full_version(SLIC3R_VERSION)));
#if defined(__WINDOWS__)
#ifdef _M_X64
extra_headers.insert(std::make_pair("X-BBL-OS-Type", "windows"));
#else
extra_headers.insert(std::make_pair("X-BBL-OS-Type", "windows_arm"));
#endif
#elif defined(__APPLE__)
extra_headers.insert(std::make_pair("X-BBL-OS-Type", "macos"));
#elif defined(__LINUX__)
@@ -2260,6 +2296,33 @@ bool GUI_App::on_init_inner()
#endif
BOOST_LOG_TRIVIAL(info) << boost::format("gui mode, Current OrcaSlicer Version %1%")%SoftFever_VERSION;
#if defined(__WINDOWS__)
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
m_is_arm64 = false;
if (hKernel32) {
auto fnIsWow64Process2 = (LPFN_ISWOW64PROCESS2)GetProcAddress(hKernel32, "IsWow64Process2");
if (fnIsWow64Process2) {
USHORT processMachine = 0;
USHORT nativeMachine = 0;
if (fnIsWow64Process2(GetCurrentProcess(), &processMachine, &nativeMachine)) {
if (nativeMachine == IMAGE_FILE_MACHINE_ARM64) {//IMAGE_FILE_MACHINE_ARM64
m_is_arm64 = true;
}
BOOST_LOG_TRIVIAL(info) << boost::format("processMachine architecture %1%, nativeMachine %2% m_is_arm64 %3%")%(int)(processMachine) %(int) nativeMachine %m_is_arm64;
}
else {
BOOST_LOG_TRIVIAL(info) << boost::format("IsWow64Process2 failed, set m_is_arm64 to %1%") %m_is_arm64;
}
}
else {
BOOST_LOG_TRIVIAL(info) << boost::format("can not find IsWow64Process2, set m_is_arm64 to %1%") %m_is_arm64;
}
}
else {
BOOST_LOG_TRIVIAL(info) << boost::format("can not find kernel32, set m_is_arm64 to %1%") %m_is_arm64;
}
#endif
// Enable this to get the default Win32 COMCTRL32 behavior of static boxes.
// wxSystemOptions::SetOption("msw.staticbox.optimized-paint", 0);
// Enable this to disable Windows Vista themes for all wxNotebooks. The themes seem to lead to terrible
@@ -2516,6 +2579,22 @@ bool GUI_App::on_init_inner()
std::map<std::string, std::string> extra_headers = get_extra_header();
Slic3r::Http::set_extra_headers(extra_headers);
// Orca: select network plugin version
NetworkAgent::use_legacy_network = app_config->get_bool("legacy_networking");
// Force legacy network plugin if debugger attached
// See https://github.com/bambulab/BambuStudio/issues/6726
if (!NetworkAgent::use_legacy_network) {
bool debugger_attached = false;
#if defined(__WINDOWS__)
debugger_attached = IsDebuggerPresent();
#elif defined(__WXOSX__) || defined(__linux__)
debugger_attached = is_debugger_present();
#endif
if (debugger_attached) {
NetworkAgent::use_legacy_network = true;
wxMessageBox("Force using legacy bambu networking plugin because debugger is attached! If the app terminates itself immediately, please delete installed plugin and try again!");
}
}
copy_network_if_available();
on_init_network();
@@ -2768,13 +2847,12 @@ void GUI_App::copy_network_if_available()
bool GUI_App::on_init_network(bool try_backup)
{
bool create_network_agent = false;
auto should_load_networking_plugin = app_config->get_bool("installed_networking");
if(!should_load_networking_plugin) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Don't load plugin as installed_networking is false";
return false;
}
} else {
int load_agent_dll = Slic3r::NetworkAgent::initialize_network_module();
bool create_network_agent = false;
__retry:
if (!load_agent_dll) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll ok";
@@ -2810,6 +2888,7 @@ __retry:
m_networking_need_update = true;
}
}
}
if (create_network_agent) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", create network agent...");
@@ -3662,10 +3741,18 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
wxString GUI_App::transition_tridid(int trid_id)
{
wxString maping_dict[8] = { "A", "B", "C", "D", "E", "F", "G" };
int id_index = ceil(trid_id / 4);
int id_suffix = (trid_id + 1) % 4 == 0 ? 4 : (trid_id + 1) % 4;
return wxString::Format("%s%d", maping_dict[id_index], id_suffix);
wxString maping_dict[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
if (trid_id >= 128 * 4) {
trid_id -= 128 * 4;
int id_index = trid_id / 4;
return wxString::Format("%s", maping_dict[id_index]);
}
else {
int id_index = ceil(trid_id / 4);
int id_suffix = trid_id % 4 + 1;
return wxString::Format("%s%d", maping_dict[id_index], id_suffix);
}
}
//BBS
@@ -4390,6 +4477,13 @@ void GUI_App::check_new_version_sf(bool show_tips, int by_user)
.perform();
}
void GUI_App::process_network_msg(std::string dev_id, std::string msg)
{
if (dev_id.empty()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << msg;
}
}
//BBS pop up a dialog and download files
void GUI_App::request_new_version(int by_user)
{
+8
View File
@@ -238,6 +238,9 @@ private:
#ifdef __linux__
bool m_opengl_initialized{ false };
#endif
#if defined(__WINDOWS__)
bool m_is_arm64{false};
#endif
//#ifdef _WIN32
@@ -474,6 +477,7 @@ public:
void check_update(bool show_tips, int by_user);
void check_new_version(bool show_tips = false, int by_user = 0);
void check_new_version_sf(bool show_tips = false, int by_user = 0);
void process_network_msg(std::string dev_id, std::string msg);
void request_new_version(int by_user);
void enter_force_upgrade();
void set_skip_version(bool skip = true);
@@ -583,6 +587,10 @@ public:
std::string get_download_model_url() {return m_mall_model_download_url;}
std::string get_download_model_name() {return m_mall_model_download_name;}
#if defined(__WINDOWS__)
bool is_running_on_arm64() { return m_is_arm64; }
#endif
void load_url(wxString url);
void open_mall_page_dialog();
void open_publish_page_dialog();
+21
View File
@@ -495,5 +495,26 @@ void fit_in_display(wxTopLevelWindow& window, wxSize desired_size)
window.SetSize(desired_size);
}
#ifdef __linux__
// Detect if the application is running inside a debugger.
// https://stackoverflow.com/a/69842462/3289421
bool is_debugger_present() {
std::ifstream sf("/proc/self/status");
std::string s;
while (sf >> s)
{
if (s == "TracerPid:")
{
int pid;
sf >> pid;
return pid != 0;
}
std::getline(sf, s);
}
return false;
}
#endif
}
}
+4
View File
@@ -500,6 +500,10 @@ void dataview_remove_insets(wxDataViewCtrl* dv);
void staticbox_remove_margin(wxStaticBox* sb);
#endif
#if defined(__WXOSX__) || defined(__linux__)
bool is_debugger_present();
#endif
/// <summary>
/// Make sure the given window fits inside current display
/// </summary>
+36 -1
View File
@@ -1,4 +1,5 @@
#include <unistd.h>
#include <sys/sysctl.h>
#import <wx/osx/cocoa/dataview.h>
#import "GUI_Utils.hpp"
@@ -20,6 +21,40 @@ void staticbox_remove_margin(wxStaticBox* sb) {
[nativeBox setBorderWidth:0];
}
bool is_debugger_present()
// Returns true if the current process is being debugged (either
// running under the debugger or has a debugger attached post facto).
// https://stackoverflow.com/a/2200786/3289421
{
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
// Initialize the flags so that, if sysctl fails for some bizarre
// reason, we get a predictable result.
info.kp_proc.p_flag = 0;
// Initialize mib, which tells sysctl the info we want, in this case
// we're looking for information about a specific process ID.
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
// Call sysctl.
size = sizeof(info);
junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
assert(junk == 0);
// We're being debugged if the P_TRACED flag is set.
return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
}
}
}
+1 -1
View File
@@ -520,7 +520,7 @@ void ImageGrid::render(wxDC& dc)
dc.DrawRectangle({ 0, 0, size.x, size.y });
if (!m_status_msg.IsEmpty()) {
auto si = m_status_icon.GetBmpSize();
auto st = dc.GetTextExtent(m_status_msg);
auto st = dc.GetMultiLineTextExtent(m_status_msg);
auto rect = wxRect{0, 0, max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
dc.DrawBitmap(m_status_icon.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.SetTextForeground(wxColor(0x909090));
+5
View File
@@ -231,11 +231,16 @@ void PrintJob::process(Ctl &ctl)
params.task_layer_inspect = this->task_layer_inspect;
params.task_record_timelapse= this->task_record_timelapse;
params.ams_mapping = this->task_ams_mapping;
params.ams_mapping2 = this->task_ams_mapping2;
params.ams_mapping_info = this->task_ams_mapping_info;
params.nozzles_info = this->task_nozzles_info;
params.connection_type = this->connection_type;
params.task_use_ams = this->task_use_ams;
params.task_bed_type = this->task_bed_type;
params.print_type = this->m_print_type;
params.auto_bed_leveling = this->auto_bed_leveling;
params.auto_flow_cali = this->auto_flow_cali;
params.auto_offset_cali = this->auto_offset_cali;
if (m_print_type == "from_sdcard_view") {
params.dst_file = m_dst_path;
+15 -2
View File
@@ -61,7 +61,9 @@ public:
std::string m_access_code;
std::string task_bed_type;
std::string task_ams_mapping;
std::string task_ams_mapping2;
std::string task_ams_mapping_info;
std::string task_nozzles_info;
std::string connection_type;
std::string m_print_type;
std::string m_dst_path;
@@ -69,7 +71,7 @@ public:
bool m_is_calibration_task = false;
int m_print_from_sdc_plate_idx = 0;
bool m_local_use_ssl_for_mqtt { true };
bool m_local_use_ssl_for_ftp { true };
bool task_bed_leveling;
@@ -81,7 +83,14 @@ public:
bool has_sdcard { false };
bool task_use_ams { true };
void set_print_config(std::string bed_type, bool bed_leveling, bool flow_cali, bool vabration_cali, bool record_timelapse, bool layer_inspect)
int auto_bed_leveling{0};
int auto_flow_cali{0};
int auto_offset_cali{0};
void set_print_config(std::string bed_type, bool bed_leveling, bool flow_cali, bool vabration_cali, bool record_timelapse, bool layer_inspect,
int auto_bed_levelingt,
int auto_flow_calit,
int auto_offset_calit)
{
task_bed_type = bed_type;
task_bed_leveling = bed_leveling;
@@ -89,6 +98,10 @@ public:
task_vibration_cali = vabration_cali;
task_record_timelapse = record_timelapse;
task_layer_inspect = layer_inspect;
auto_bed_leveling = auto_bed_levelingt;
auto_flow_cali = auto_flow_calit;
auto_offset_cali = auto_offset_calit;
}
int status_range() const
+16 -16
View File
@@ -71,7 +71,7 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
// File type
StateColor background(
std::make_pair(0xEEEEEE, (int) StateColor::Checked),
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
std::make_pair(*wxWHITE, (int) StateColor::Normal));
m_type_panel = new ::StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
m_type_panel->SetBackgroundColor(*wxWHITE);
@@ -220,9 +220,9 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_lan_passwd = obj->get_access_code();
m_dev_ver = obj->get_ota_version();
m_device_busy = obj->is_camera_busy_off();
m_sdcard_exist = obj->has_sdcard();
m_sdcard_exist = obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL || obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_READONLY;
m_local_proto = obj->file_local;
m_remote_proto = obj->file_remote;
m_remote_proto = obj->get_file_remote();
m_model_download_support = obj->file_model_download;
} else {
m_lan_mode = false;
@@ -326,7 +326,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
CallAfter([this, m = e.GetString()] {
MessageDialog(this, m, _L("Download failed"), wxOK | wxICON_ERROR).ShowModal();
});
NetworkAgent* agent = wxGetApp().getAgent();
if (result > 1 || result == 0) {
json j;
@@ -518,16 +518,16 @@ void MediaFilePanel::doAction(size_t index, int action)
auto fs = m_image_grid->GetFileSystem();
if (action == 0) {
if (index == -1) {
MessageDialog dlg(this,
MessageDialog dlg(this,
wxString::Format(_L_PLURAL("You are going to delete %u file from printer. Are you sure to continue?",
"You are going to delete %u files from printer. Are you sure to continue?", fs->GetSelectCount()),
fs->GetSelectCount()),
fs->GetSelectCount()),
_L("Delete files"), wxYES_NO | wxICON_WARNING);
if (dlg.ShowModal() != wxID_YES)
return;
} else {
MessageDialog dlg(this,
wxString::Format(_L("Do you want to delete the file '%s' from printer?"), from_u8(fs->GetFile(index).name)),
MessageDialog dlg(this,
wxString::Format(_L("Do you want to delete the file '%s' from printer?"), from_u8(fs->GetFile(index).name)),
_L("Delete file"), wxYES_NO | wxICON_WARNING);
if (dlg.ShowModal() != wxID_YES)
return;
@@ -557,13 +557,13 @@ void MediaFilePanel::doAction(size_t index, int action)
std::istringstream is(data);
if (!Slic3r::load_gcode_3mf_from_stream(is, &config, &model, &plate_data_list, &file_version)
|| plate_data_list.empty()) {
MessageDialog(this,
_L("Failed to parse model information."),
MessageDialog(this,
_L("Failed to parse model information."),
_L("Print"), wxOK).ShowModal();
return;
}
auto &file = fs->GetFile(index);
std::string file_path = file.path;
@@ -581,7 +581,7 @@ void MediaFilePanel::doAction(size_t index, int action)
wxEmptyString, wxICON_WARNING | wxOK);
auto res = dlg.ShowModal();
}
});
return;
}
@@ -591,8 +591,8 @@ void MediaFilePanel::doAction(size_t index, int action)
if (file.IsDownload() && file.DownloadProgress() >= -1) {
if (!file.local_path.empty()) {
if (!fs->DownloadCheckFile(index)) {
MessageDialog(this,
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
MessageDialog(this,
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
_L("Error"), wxOK).ShowModal();
Refresh();
return;
@@ -617,8 +617,8 @@ void MediaFilePanel::doAction(size_t index, int action)
if (file.IsDownload() && file.DownloadProgress() >= -1) {
if (!file.local_path.empty()) {
if (!fs->DownloadCheckFile(index)) {
MessageDialog(this,
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
MessageDialog(this,
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
_L("Error"), wxOK).ShowModal();
Refresh();
return;
+6 -1
View File
@@ -150,11 +150,16 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_dev_ver = obj->get_ota_version();
m_lan_mode = obj->is_lan_mode_printer();
m_lan_proto = obj->liveview_local;
m_remote_proto = obj->liveview_remote;
m_remote_proto = obj->get_liveview_remote();
m_lan_ip = obj->dev_ip;
m_lan_passwd = obj->get_access_code();
m_device_busy = obj->is_camera_busy_off();
m_tutk_state = obj->tutk_state;
if (DeviceManager::get_printer_series(obj->printer_type) == "series_o" && NetworkAgent::use_legacy_network) {
// Legacy plugin cannot support remote play for H2D, force using local mode
m_remote_proto = MachineObject::LVR_None;
}
} else {
m_camera_exists = false;
m_lan_mode = false;
+17 -13
View File
@@ -181,7 +181,7 @@ MonitorPanel::~MonitorPanel()
auto page = m_tabpanel->GetCurrentPage();
if (page == m_media_file_panel) {
auto title = m_tabpanel->GetPageText(m_tabpanel->GetSelection());
m_media_file_panel->SwitchStorage(title == _L("SD Card"));
m_media_file_panel->SwitchStorage(title == _L("Storage"));
}
page->SetFocus();
}, m_tabpanel->GetId());
@@ -191,7 +191,7 @@ MonitorPanel::~MonitorPanel()
m_tabpanel->AddPage(m_status_info_panel, _L("Status"), "", true);
m_media_file_panel = new MediaFilePanel(m_tabpanel);
m_tabpanel->AddPage(m_media_file_panel, _L("SD Card"), "", false);
m_tabpanel->AddPage(m_media_file_panel, _L("Storage"), "", false);
//m_tabpanel->AddPage(m_media_file_panel, _L("Internal Storage"), "", false);
m_upgrade_panel = new UpgradePanel(m_tabpanel);
@@ -297,8 +297,12 @@ void MonitorPanel::on_update_all(wxMouseEvent &event)
update_all();
MachineObject *obj_ = dev->get_selected_machine();
if (obj_)
if (obj_) {
obj_->last_cali_version = -1;
obj_->reset_pa_cali_history_result();
obj_->reset_pa_cali_result();
GUI::wxGetApp().sidebar().load_ams_list(obj_->dev_id, obj_);
}
Layout();
Refresh();
@@ -372,7 +376,7 @@ void MonitorPanel::update_all()
m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj);
m_media_file_panel->SetMachineObject(obj);
m_side_tools->update_status(obj);
if (!obj) {
show_status((int)MONITOR_NO_PRINTER);
m_hms_panel->clear_hms_tag();
@@ -450,7 +454,7 @@ bool MonitorPanel::Show(bool show)
if (obj == nullptr) {
dev->load_last_machine();
obj = dev->get_selected_machine();
if (obj)
if (obj)
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
} else {
obj->reset_update_time();
@@ -499,7 +503,7 @@ void MonitorPanel::show_status(int status)
BOOST_LOG_TRIVIAL(info) << "monitor: show_status = " << status;
#if !BBL_RELEASE_TO_PUBLIC
m_upgrade_panel->update(nullptr);
#endif
@@ -514,15 +518,15 @@ Freeze();
if ((status & (int)MonitorStatus::MONITOR_NO_PRINTER) != 0) {
set_default();
m_tabpanel->Layout();
} else if (((status & (int)MonitorStatus::MONITOR_NORMAL) != 0)
|| ((status & (int)MonitorStatus::MONITOR_DISCONNECTED) != 0)
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0) )
} else if (((status & (int)MonitorStatus::MONITOR_NORMAL) != 0)
|| ((status & (int)MonitorStatus::MONITOR_DISCONNECTED) != 0)
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0) )
{
if (((status & (int) MonitorStatus::MONITOR_DISCONNECTED) != 0)
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0))
if (((status & (int) MonitorStatus::MONITOR_DISCONNECTED) != 0)
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0))
{
set_default();
}
+1 -1
View File
@@ -48,7 +48,7 @@
#include "slic3r/GUI/HMSPanel.hpp"
#include "slic3r/GUI/AmsWidgets.hpp"
#include "Widgets/SideTools.hpp"
#include "SelectMachine.hpp"
#include "SelectMachinePop.hpp"
namespace Slic3r {
namespace GUI {
+1 -2
View File
@@ -2081,7 +2081,6 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
auto& printer_config = preset_bundle->printers.get_edited_preset().config;
const auto& full_config = wxGetApp().preset_bundle->full_config();
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
auto& ams_filament_list = preset_bundle->filament_ams_list;
const std::vector<double>& init_matrix = (project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values;
const std::vector<double>& init_extruders = (project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values;
@@ -7816,7 +7815,7 @@ wxString Plater::priv::get_export_gcode_filename(const wxString& extension, bool
}
} else {
if (only_filename) {
if(m_project_name == _L("Untitled"))
if(!model.objects.empty() && m_project_name == _L("Untitled"))
return wxString(fs::path(model.objects.front()->name).replace_extension().c_str()) + from_u8(plate_index_str) + extension;
if (export_all)
+8
View File
@@ -804,6 +804,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
if (pbool) {
GUI::wxGetApp().CallAfter([] { GUI::wxGetApp().ShowDownNetPluginDlg(); });
}
if (m_legacy_networking_ckeckbox != nullptr) { m_legacy_networking_ckeckbox->Enable(pbool); }
}
#endif // __WXMSW__
@@ -834,6 +835,11 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
//// for debug mode
if (param == "developer_mode") { m_developer_mode_ckeckbox = checkbox; }
if (param == "internal_developer_mode") { m_internal_developer_mode_ckeckbox = checkbox; }
if (param == "legacy_networking") {
m_legacy_networking_ckeckbox = checkbox;
bool pbool = app_config->get_bool("installed_networking");
checkbox->Enable(pbool);
}
checkbox->SetToolTip(tooltip);
@@ -1196,6 +1202,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_stealth_mode = create_item_checkbox(_L("Stealth Mode"), page, _L("This stops the transmission of data to Bambu's cloud services. Users who don't use BBL machines or use LAN mode only can safely turn on this function."), 50, "stealth_mode");
auto item_enable_plugin = create_item_checkbox(_L("Enable network plugin"), page, _L("Enable network plugin"), 50, "installed_networking");
auto item_legacy_network_plugin = create_item_checkbox(_L("Use legacy network plugin (Takes effect after restarting Orca)"), page, _L("Disable to use latest network plugin that supports new BambuLab firmwares."), 50, "legacy_networking");
auto item_check_stable_version_only = create_item_checkbox(_L("Check for stable updates only"), page, _L("Check for stable updates only"), 50, "check_stable_update_only");
std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"};
@@ -1321,6 +1328,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_check_stable_version_only, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_enable_plugin, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_legacy_network_plugin, 0, wxTOP, FromDIP(3));
#ifdef _WIN32
sizer_page->Add(title_associate_file, 0, wxTOP| wxEXPAND, FromDIP(20));
sizer_page->Add(item_associate_3mf, 0, wxTOP, FromDIP(3));
+1
View File
@@ -93,6 +93,7 @@ public:
::CheckBox * m_internal_developer_mode_ckeckbox = {nullptr};
::CheckBox * m_dark_mode_ckeckbox = {nullptr};
::TextInput *m_backup_interval_textinput = {nullptr};
::CheckBox * m_legacy_networking_ckeckbox = {nullptr};
wxString m_developer_mode_def;
wxString m_internal_developer_mode_def;
+83 -89
View File
@@ -427,9 +427,9 @@ void PrintOptionsDialog::update_machine_obj(MachineObject *obj_)
bool PrintOptionsDialog::Show(bool show)
{
if (show) {
if (show) {
wxGetApp().UpdateDlgDarkUI(this);
CentreOnParent();
CentreOnParent();
}
return DPIDialog::Show(show);
}
@@ -437,8 +437,11 @@ bool PrintOptionsDialog::Show(bool show)
PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
: DPIDialog(parent, wxID_ANY, _L("Printer Parts"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
nozzle_type_map[0] = "hardened_steel";
nozzle_type_map[1] = "stainless_steel";
nozzle_type_map[NozzleType::ntHardenedSteel] = _L("Hardened Steel");
nozzle_type_map[NozzleType::ntStainlessSteel] = _L("Stainless Steel");
nozzle_type_selection_map[NozzleType::ntHardenedSteel] = 0;
nozzle_type_selection_map[NozzleType::ntStainlessSteel] = 1;
nozzle_stainless_diameter_map[0] = 0.2;
nozzle_stainless_diameter_map[1] = 0.4;
@@ -464,12 +467,15 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
nozzle_type->SetForegroundColour(STATIC_TEXT_CAPTION_COL);
nozzle_type->Wrap(-1);
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->Append(_L("Stainless Steel"));
nozzle_type_checkbox->Append(_L("Hardened Steel"));
nozzle_type_checkbox->Append(nozzle_type_map[NozzleType::ntHardenedSteel]);
nozzle_type_checkbox->Append(nozzle_type_map[NozzleType::ntStainlessSteel]);
nozzle_type_checkbox->SetSelection(0);
line_sizer_nozzle_type->Add(nozzle_type, 0, wxALIGN_CENTER, 5);
line_sizer_nozzle_type->Add(0, 0, 1, wxEXPAND, 5);
line_sizer_nozzle_type->Add(nozzle_type_checkbox, 0, wxALIGN_CENTER, 5);
@@ -498,65 +504,76 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
sizer->Add(line_sizer_nozzle_diameter, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(18));
sizer->Add(0, 0, 0, wxTOP, FromDIP(24));
nozzle_type_checkbox->Connect( wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_type), NULL, this );
nozzle_diameter_checkbox->Connect( wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_diameter), NULL, this );
SetSizer(sizer);
Layout();
Fit();
wxGetApp().UpdateDlgDarkUI(this);
nozzle_type_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
nozzle_diameter_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
nozzle_type_checkbox->SetId(ID_NOZZLE_TYPE_CHECKBOX_SINGLE);
nozzle_diameter_checkbox->SetId(ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE);
}
PrinterPartsDialog::~PrinterPartsDialog()
{
nozzle_type_checkbox->Disconnect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_type), NULL, this);
nozzle_diameter_checkbox->Disconnect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_diameter), NULL, this);
nozzle_type_checkbox->Disconnect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
nozzle_diameter_checkbox->Disconnect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
}
void PrinterPartsDialog::set_nozzle_type(wxCommandEvent& evt)
void PrinterPartsDialog::set_nozzle_data(wxCommandEvent& evt)
{
auto type = nozzle_type_map[nozzle_type_checkbox->GetSelection()];
ComboBox* current_nozzle_type_combox = nullptr;
ComboBox* current_nozzle_diameter_combox = nullptr;
if (type == last_nozzle_type) {
return;
int nozzle_id = MAIN_NOZZLE_ID;
if (evt.GetId() == ID_NOZZLE_TYPE_CHECKBOX_SINGLE ||
evt.GetId() == ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE) {
current_nozzle_type_combox = nozzle_type_checkbox;
current_nozzle_diameter_combox = nozzle_diameter_checkbox;
nozzle_id = MAIN_NOZZLE_ID;
}
std::map<int, float> diameter_list;
if (type == "hardened_steel") {
diameter_list = nozzle_hard_diameter_map;
}
else if (type == "stainless_steel") {
diameter_list = nozzle_stainless_diameter_map;
}
nozzle_diameter_checkbox->Clear();
for (int i = 0; i < diameter_list.size(); i++)
{
nozzle_diameter_checkbox->Append(wxString::Format("%.1f", diameter_list[i]));
}
nozzle_diameter_checkbox->SetSelection(0);
last_nozzle_type = type;
set_nozzle_diameter(evt);
}
void PrinterPartsDialog::set_nozzle_diameter(wxCommandEvent& evt)
{
if (obj) {
try
{
auto nozzle_type = nozzle_type_map[nozzle_type_checkbox->GetSelection()];
auto nozzle_diameter = std::stof(nozzle_diameter_checkbox->GetStringSelection().ToStdString());
nozzle_diameter = round(nozzle_diameter * 10) / 10;
obj->nozzle_diameter = nozzle_diameter;
obj->nozzle_type = nozzle_type;
try {
auto nozzle_type = NozzleType::ntHardenedSteel;
auto nozzle_diameter = 0.4f;
obj->command_set_printer_nozzle(nozzle_type, nozzle_diameter);
}
catch (...) {}
for (auto sm : nozzle_type_selection_map) {
if (sm.second == current_nozzle_type_combox->GetSelection()) {
nozzle_type = sm.first;
}
}
/*update nozzle diameter*/
if (evt.GetId() == ID_NOZZLE_TYPE_CHECKBOX_SINGLE) {
nozzle_diameter_checkbox->Clear();
std::map<int, float> diameter_map;
if (nozzle_type == NozzleType::ntHardenedSteel) {
diameter_map = nozzle_hard_diameter_map;
} else if (nozzle_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])); }
nozzle_diameter_checkbox->SetSelection(0);
}
nozzle_diameter = std::stof(current_nozzle_diameter_combox->GetStringSelection().ToStdString());
nozzle_diameter = round(nozzle_diameter * 10) / 10;
/*if (!obj->is_enable_np)*/ {
if (current_nozzle_type_combox && current_nozzle_type_combox->IsShown() && current_nozzle_type_combox->GetValue().IsEmpty()) { return; }
if (current_nozzle_diameter_combox && current_nozzle_diameter_combox->IsShown() && current_nozzle_diameter_combox->GetValue().IsEmpty()) { return; }
obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter = nozzle_diameter;
obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type = nozzle_type;
obj->command_set_printer_nozzle(NozzleTypeEumnToStr[nozzle_type], nozzle_diameter);
}
} catch (...) {}
}
}
@@ -576,53 +593,30 @@ bool PrinterPartsDialog::Show(bool show)
wxGetApp().UpdateDlgDarkUI(this);
CentreOnParent();
auto type = obj->nozzle_type;
auto diameter = 0.4f;
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->nozzle_diameter > 0) {
diameter = round(obj->nozzle_diameter * 10) / 10;
}
nozzle_type_checkbox->Clear();
nozzle_diameter_checkbox->Clear();
if (type.empty()) {
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();
}
last_nozzle_type = type;
for (int i=0; i < nozzle_type_map.size(); i++)
{
nozzle_type_checkbox->Append( nozzle_type_map[i] );
if (nozzle_type_map[i] == type) {
nozzle_type_checkbox->SetSelection(i);
} else {
std::map<int, float> diameter_map;
if (type == NozzleType::ntHardenedSteel) {
diameter_map = nozzle_hard_diameter_map;
} else if (type == NozzleType::ntStainlessSteel) {
diameter_map = nozzle_stainless_diameter_map;
}
}
std::map<int, float> diameter_list;
if (type == "hardened_steel") {
diameter_list = nozzle_hard_diameter_map;
}
else if (type == "stainless_steel") {
diameter_list = nozzle_stainless_diameter_map;
}
for (int i = 0; i < diameter_list.size(); i++)
{
nozzle_diameter_checkbox->Append( wxString::Format("%.1f", diameter_list[i]));
if (diameter_list[i] == diameter) {
nozzle_diameter_checkbox->SetSelection(i);
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]);
}
}
return DPIDialog::Show(show);
+7 -3
View File
@@ -21,18 +21,22 @@ namespace Slic3r { namespace GUI {
class PrinterPartsDialog : public DPIDialog
{
protected:
wxWindowID ID_NOZZLE_TYPE_CHECKBOX_SINGLE;
wxWindowID ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE;
MachineObject* obj{ nullptr };
ComboBox* nozzle_type_checkbox;
ComboBox* nozzle_diameter_checkbox;
std::string last_nozzle_type;
std::map<int, std::string> nozzle_type_map;
std::map<NozzleType, wxString> nozzle_type_map;
std::map<NozzleType, int> nozzle_type_selection_map;
std::map<int, float> nozzle_stainless_diameter_map;
std::map<int, float> nozzle_hard_diameter_map;
public:
PrinterPartsDialog(wxWindow* parent);
~PrinterPartsDialog();
void set_nozzle_type(wxCommandEvent& evt);
void set_nozzle_diameter(wxCommandEvent& evt);
void set_nozzle_data(wxCommandEvent& evt);
void on_dpi_changed(const wxRect& suggested_rect) override;
void update_machine_obj(MachineObject* obj_);
bool Show(bool show) override;
File diff suppressed because it is too large Load Diff
+110 -319
View File
@@ -45,255 +45,12 @@
namespace Slic3r { namespace GUI {
enum PrinterState {
OFFLINE,
IDLE,
BUSY,
LOCK,
IN_LAN
};
enum PrinterBindState {
NONE,
ALLOW_BIND,
ALLOW_UNBIND
};
void print_ams_mapping_result(std::vector<FilamentInfo> &result);
enum PrintFromType {
FROM_NORMAL,
FROM_SDCARD_VIEW,
};
static int get_brightness_value(wxImage image) {
wxImage grayImage = image.ConvertToGreyscale();
int width = grayImage.GetWidth();
int height = grayImage.GetHeight();
int totalLuminance = 0;
unsigned char alpha;
int num_none_transparent = 0;
for (int y = 0; y < height; y += 2) {
for (int x = 0; x < width; x += 2) {
alpha = image.GetAlpha(x, y);
if (alpha != 0) {
wxColour pixelColor = grayImage.GetRed(x, y);
totalLuminance += pixelColor.Red();
num_none_transparent = num_none_transparent + 1;
}
}
}
if (totalLuminance <= 0 || num_none_transparent <= 0) {
return 0;
}
return totalLuminance / num_none_transparent;
}
class Material
{
public:
int id;
MaterialItem *item;
};
WX_DECLARE_HASH_MAP(int, Material *, wxIntegerHash, wxIntegerEqual, MaterialHash);
// move to seperate file
class MachineListModel : public wxDataViewVirtualListModel
{
public:
enum {
Col_MachineName = 0,
Col_MachineSN = 1,
Col_MachineBind = 2,
Col_MachinePrintingStatus = 3,
Col_MachineIPAddress = 4,
Col_MachineConnection = 5,
Col_MachineTaskName = 6,
Col_Max = 7
};
MachineListModel();
virtual unsigned int GetColumnCount() const wxOVERRIDE { return Col_Max; }
virtual wxString GetColumnType(unsigned int col) const wxOVERRIDE { return "string"; }
virtual void GetValueByRow(wxVariant &variant, unsigned int row, unsigned int col) const wxOVERRIDE;
virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr &attr) const wxOVERRIDE;
virtual bool SetValueByRow(const wxVariant &variant, unsigned int row, unsigned int col) wxOVERRIDE;
void display_machines(std::map<std::string, MachineObject *> list);
void add_machine(MachineObject *obj, bool reset = true);
int find_row_by_sn(wxString sn);
private:
wxArrayString m_values[Col_Max];
wxArrayString m_nameColValues;
wxArrayString m_snColValues;
wxArrayString m_bindColValues;
wxArrayString m_connectionColValues;
wxArrayString m_printingStatusValues;
wxArrayString m_ipAddressValues;
};
class MachineObjectPanel : public wxPanel
{
private:
bool m_is_my_devices {false};
bool m_show_edit{false};
bool m_show_bind{false};
bool m_hover {false};
bool m_is_macos_special_version{false};
PrinterBindState m_bind_state;
PrinterState m_state;
ScalableBitmap m_unbind_img;
ScalableBitmap m_edit_name_img;
ScalableBitmap m_select_unbind_img;
ScalableBitmap m_printer_status_offline;
ScalableBitmap m_printer_status_busy;
ScalableBitmap m_printer_status_idle;
ScalableBitmap m_printer_status_lock;
ScalableBitmap m_printer_in_lan;
MachineObject *m_info;
protected:
wxStaticBitmap *m_bitmap_info;
wxStaticBitmap *m_bitmap_bind;
public:
MachineObjectPanel(wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxTAB_TRAVERSAL,
const wxString &name = wxEmptyString);
~MachineObjectPanel();
void show_bind_dialog();
void set_printer_state(PrinterState state);
void show_printer_bind(bool show, PrinterBindState state);
void show_edit_printer_name(bool show);
void update_machine_info(MachineObject *info, bool is_my_devices = false);
protected:
void OnPaint(wxPaintEvent &event);
void render(wxDC &dc);
void doRender(wxDC &dc);
void on_mouse_enter(wxMouseEvent &evt);
void on_mouse_leave(wxMouseEvent &evt);
void on_mouse_left_up(wxMouseEvent &evt);
};
#define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(216), FromDIP(364))
#define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(212), FromDIP(360))
#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(190), FromDIP(35))
#define SELECT_MACHINE_GREY900 wxColour(38, 46, 48)
#define SELECT_MACHINE_GREY600 wxColour(144,144,144)
#define SELECT_MACHINE_GREY400 wxColour(206, 206, 206)
#define SELECT_MACHINE_BRAND wxColour(0, 150, 136)
#define SELECT_MACHINE_REMIND wxColour(255,111,0)
#define SELECT_MACHINE_LIGHT_GREEN wxColour(219, 253, 231)
class MachinePanel
{
public:
wxString mIndex;
MachineObjectPanel *mPanel;
};
class PinCodePanel : public wxPanel
{
public:
PinCodePanel(wxWindow* parent,
int type,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
~PinCodePanel() {};
ScalableBitmap m_bitmap;
bool m_hover{false};
int m_type{0};
void OnPaint(wxPaintEvent& event);
void render(wxDC& dc);
void doRender(wxDC& dc);
void on_mouse_enter(wxMouseEvent& evt);
void on_mouse_leave(wxMouseEvent& evt);
void on_mouse_left_up(wxMouseEvent& evt);
};
class ThumbnailPanel;
class SelectMachinePopup : public PopupWindow
{
public:
SelectMachinePopup(wxWindow *parent);
~SelectMachinePopup();
// PopupWindow virtual methods are all overridden to log them
virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE;
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE;
virtual bool Show(bool show = true) wxOVERRIDE;
void update_machine_list(wxCommandEvent &event);
void start_ssdp(bool on_off);
bool was_dismiss() { return m_dismiss; }
private:
int m_my_devices_count{0};
int m_other_devices_count{0};
PinCodePanel* m_panel_ping_code{nullptr};
PinCodePanel* m_panel_direct_connection{nullptr};
wxWindow* m_placeholder_panel{nullptr};
wxHyperlinkCtrl* m_hyperlink{nullptr};
Label* m_ping_code_text{nullptr};
wxStaticBitmap* m_img_ping_code{nullptr};
wxBoxSizer * m_sizer_body{nullptr};
wxBoxSizer * m_sizer_my_devices{nullptr};
wxBoxSizer * m_sizer_other_devices{nullptr};
wxBoxSizer * m_sizer_search_bar{nullptr};
wxSearchCtrl* m_search_bar{nullptr};
wxScrolledWindow * m_scrolledWindow{nullptr};
wxWindow * m_panel_body{nullptr};
wxTimer * m_refresh_timer{nullptr};
std::vector<MachinePanel*> m_user_list_machine_panel;
std::vector<MachinePanel*> m_other_list_machine_panel;
boost::thread* get_print_info_thread{ nullptr };
std::shared_ptr<int> m_token = std::make_shared<int>(0);
std::string m_print_info = "";
bool m_dismiss { false };
std::map<std::string, MachineObject*> m_bind_machine_list;
std::map<std::string, MachineObject*> m_free_machine_list;
private:
void OnLeftUp(wxMouseEvent &event);
void on_timer(wxTimerEvent &event);
void update_other_devices();
void update_user_devices();
bool search_for_printer(MachineObject* obj);
void on_dissmiss_win(wxCommandEvent &event);
wxWindow *create_title_panel(wxString text);
};
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(68), FromDIP(23))
#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(370), FromDIP(64))
enum PrintPageMode {
PrintPageModePrepare = 0,
PrintPageModeSending,
@@ -334,7 +91,80 @@ enum PrintDialogStatus {
PrintStatusTimelapseWarning
};
std::string get_print_status_info(PrintDialogStatus status);
class Material
{
public:
int id;
MaterialItem *item;
};
enum class CloudTaskNozzleId : int
{
NOZZLE_RIGHT = 0,
NOZZLE_LEFT = 1,
};
enum class ConfigNozzleIdx : int
{
NOZZLE_LEFT = 0,
NOZZLE_RIGHT = 1,
};
WX_DECLARE_HASH_MAP(int, Material *, wxIntegerHash, wxIntegerEqual, MaterialHash);
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(68), FromDIP(23))
#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(370), FromDIP(64))
#define LIST_REFRESH_INTERVAL 200
static int get_brightness_value(wxImage image) {
wxImage grayImage = image.ConvertToGreyscale();
int width = grayImage.GetWidth();
int height = grayImage.GetHeight();
int totalLuminance = 0;
unsigned char alpha;
int num_none_transparent = 0;
for (int y = 0; y < height; y += 2) {
for (int x = 0; x < width; x += 2) {
alpha = image.GetAlpha(x, y);
if (alpha != 0) {
wxColour pixelColor = grayImage.GetRed(x, y);
totalLuminance += pixelColor.Red();
num_none_transparent = num_none_transparent + 1;
}
}
}
if (totalLuminance <= 0 || num_none_transparent <= 0) {
return 0;
}
return totalLuminance / num_none_transparent;
}
class ThumbnailPanel : public wxPanel
{
public:
wxBitmap m_bitmap;
wxStaticBitmap *m_staticbitmap{nullptr};
ThumbnailPanel(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~ThumbnailPanel();
void OnPaint(wxPaintEvent &event);
void PaintBackground(wxDC &dc);
void OnEraseBackground(wxEraseEvent &event);
void set_thumbnail(wxImage &img);
void render(wxDC &dc);
private:
ScalableBitmap m_background_bitmap;
wxBitmap bitmap_with_background;
int m_brightness_value{-1};
};
class SelectMachineDialog : public DPIDialog
{
@@ -347,7 +177,6 @@ private:
bool m_is_in_sending_mode{ false };
bool m_ams_mapping_res{ false };
bool m_ams_mapping_valid{ false };
bool m_need_adaptation_screen{ false };
bool m_export_3mf_cancel{ false };
bool m_is_canceled{ false };
bool m_is_rename_mode{ false };
@@ -361,6 +190,7 @@ private:
wxColour m_colour_def_color{wxColour(255, 255, 255)};
wxColour m_colour_bold_color{wxColour(38, 46, 48)};
StateColor m_btn_bg_enable;
Label* m_text_bed_type;
std::shared_ptr<int> m_token = std::make_shared<int>(0);
std::map<std::string, CheckBox *> m_checkbox_list;
@@ -385,18 +215,17 @@ protected:
AmsTutorialPopup m_mapping_tutorial_popup{ nullptr };
MaterialHash m_materialList;
Plater * m_plater{nullptr};
wxWrapSizer* m_sizer_select{ nullptr };
wxBoxSizer* m_sizer_options{ nullptr };
wxBoxSizer* m_sizer_thumbnail{ nullptr };
wxGridSizer* m_sizer_material{ nullptr };
wxBoxSizer* m_sizer_main{ nullptr };
wxBoxSizer* m_sizer_scrollable_view{ nullptr };
wxBoxSizer* m_sizer_scrollable_region{ nullptr };
wxBoxSizer* m_basicl_sizer{ nullptr };
wxBoxSizer* rename_sizer_v{ nullptr };
wxBoxSizer* rename_sizer_h{ nullptr };
wxBoxSizer* m_sizer_backup{ nullptr };
wxBoxSizer* m_sizer_autorefill{ nullptr };
Button* m_button_refresh{ nullptr };
Button* m_button_ensure{ nullptr };
ScalableButton * m_rename_button{nullptr};
wxStaticBitmap * m_rename_button{nullptr};
ComboBox* m_comboBox_printer{ nullptr };
wxStaticBitmap* m_staticbitmap{ nullptr };
wxStaticBitmap* m_bitmap_last_plate{ nullptr };
@@ -408,15 +237,12 @@ protected:
wxWindow* select_timelapse{ nullptr };
wxWindow* select_use_ams{ nullptr };
wxPanel* m_panel_status{ nullptr };
wxPanel* m_scrollable_region;
wxPanel* m_basic_panel;
wxPanel* m_rename_normal_panel{nullptr};
wxPanel* m_line_schedule{nullptr};
wxPanel* m_panel_sending{nullptr};
wxPanel* m_panel_prepare{nullptr};
wxPanel* m_panel_finish{nullptr};
wxPanel* m_line_top{ nullptr };
wxPanel* m_panel_image{ nullptr };
wxPanel* m_line_materia{ nullptr };
Label* m_st_txt_error_code{nullptr};
Label* m_st_txt_error_desc{nullptr};
Label* m_st_txt_extra_info{nullptr};
@@ -425,26 +251,25 @@ protected:
wxSimplebook* m_rename_switch_panel{nullptr};
wxSimplebook* m_simplebook{nullptr};
wxStaticText* m_rename_text{nullptr};
wxStaticText* m_stext_printer_title{nullptr};
wxStaticText* m_stext_time{ nullptr };
wxStaticText* m_stext_weight{ nullptr };
Label* m_stext_printer_title{nullptr};
Label* m_stext_time{ nullptr };
Label* m_stext_weight{ nullptr };
wxStaticText* m_statictext_ams_msg{ nullptr };
wxStaticText* m_statictext_printer_msg{ nullptr };
wxStaticText* m_text_printer_msg{ nullptr };
wxStaticText* m_staticText_bed_title{ nullptr };
wxStaticText* m_stext_sending{ nullptr };
wxStaticText* m_statictext_finish{nullptr};
TextInput* m_rename_input{nullptr};
wxTimer* m_refresh_timer{ nullptr };
wxScrolledWindow* m_scrollable_view;
wxScrolledWindow* m_sw_print_failed_info{nullptr};
wxHyperlinkCtrl* m_hyperlink{nullptr};
ScalableBitmap * ams_editable{nullptr};
ScalableBitmap * ams_editable_light{nullptr};
ScalableBitmap * rename_editable{nullptr};
ScalableBitmap * rename_editable_light{nullptr};
wxStaticBitmap * timeimg{nullptr};
ScalableBitmap * print_time{nullptr};
wxStaticBitmap * weightimg{nullptr};
ScalableBitmap * print_weight{nullptr};
ScalableBitmap * enable_ams_mapping{nullptr};
ScalableBitmap * ams_mapping_help_icon{nullptr};
wxStaticBitmap * img_use_ams_tip{nullptr};
wxStaticBitmap * img_ams_backup{nullptr};
ScalableBitmap * enable_ams{nullptr};
@@ -455,6 +280,19 @@ protected:
std::vector<wxColour> m_cur_colors_in_thumbnail;
std::vector<bool> m_edge_pixels;
wxPanel* m_filament_panel;
wxPanel* m_filament_left_panel;
wxPanel* m_filament_right_panel;
wxBoxSizer* m_filament_panel_sizer;
wxBoxSizer* m_filament_panel_left_sizer;
wxBoxSizer* m_filament_panel_right_sizer;
wxBoxSizer* m_sizer_filament_2extruder;
wxGridSizer* m_sizer_ams_mapping{ nullptr };
wxGridSizer* m_sizer_ams_mapping_left{ nullptr };
wxGridSizer* m_sizer_ams_mapping_right{ nullptr };
public:
SelectMachineDialog(Plater *plater = nullptr);
~SelectMachineDialog();
@@ -478,7 +316,7 @@ public:
void reset_ams_material();
void update_show_status();
void update_ams_check(MachineObject* obj);
void on_rename_click(wxCommandEvent& event);
void on_rename_click(wxMouseEvent& event);
void on_rename_enter();
void update_printer_combobox(wxCommandEvent& event);
void on_cancel(wxCloseEvent& event);
@@ -522,18 +360,21 @@ public:
void update_timelapse_enable_status();
bool is_same_printer_model();
bool is_blocking_printing(MachineObject* obj_);
bool is_same_nozzle_diameters(std::string& tag_nozzle_type, std::string& nozzle_diameter);
bool is_same_nozzle_type(std::string& filament_type, std::string& tag_nozzle_type);
bool is_same_nozzle_diameters(float& tag_nozzle_diameter) const;
bool is_same_nozzle_type(const Extder& extruder, std::string& filament_type) const;
bool has_tips(MachineObject* obj);
bool is_timeout();
int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path);
void set_print_type(PrintFromType type) {m_print_type = type;};
bool Show(bool show);
bool do_ams_mapping(MachineObject* obj_);
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& ams_mapping_info);
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info);
bool build_nozzles_info(std::string& nozzles_info);
std::string get_print_status_info(PrintDialogStatus status);
PrintFromType get_print_type() {return m_print_type;};
wxString format_steel_name(std::string name);
wxString format_steel_name(NozzleType type);
wxString format_text(wxString &m_msg);
wxWindow* create_ams_checkbox(wxString title, wxWindow* parent, wxString tooltip);
wxWindow* create_item_checkbox(wxString title, wxWindow* parent, wxString tooltip, std::string param);
@@ -542,56 +383,6 @@ public:
std::vector<std::string> sort_string(std::vector<std::string> strArray);
};
wxDECLARE_EVENT(EVT_FINISHED_UPDATE_MACHINE_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_REQUEST_BIND_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_WILL_DISMISS_MACHINE_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent);
wxDECLARE_EVENT(EVT_DISSMISS_MACHINE_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_CONNECT_LAN_PRINT, wxCommandEvent);
wxDECLARE_EVENT(EVT_EDIT_PRINT_NAME, wxCommandEvent);
wxDECLARE_EVENT(EVT_UNBIND_MACHINE, wxCommandEvent);
wxDECLARE_EVENT(EVT_BIND_MACHINE, wxCommandEvent);
class EditDevNameDialog : public DPIDialog
{
public:
EditDevNameDialog(Plater *plater = nullptr);
~EditDevNameDialog();
void set_machine_obj(MachineObject *obj);
void on_dpi_changed(const wxRect &suggested_rect) override;
void on_edit_name(wxCommandEvent &e);
Button* m_button_confirm{nullptr};
TextInput* m_textCtr{nullptr};
wxStaticText* m_static_valid{nullptr};
MachineObject* m_info{nullptr};
};
class ThumbnailPanel : public wxPanel
{
public:
wxBitmap m_bitmap;
wxStaticBitmap *m_staticbitmap{nullptr};
ThumbnailPanel(wxWindow * parent,
wxWindowID winid = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize);
~ThumbnailPanel();
void OnPaint(wxPaintEvent &event);
void PaintBackground(wxDC &dc);
void OnEraseBackground(wxEraseEvent &event);
void set_thumbnail(wxImage &img);
void render(wxDC &dc);
private:
ScalableBitmap m_background_bitmap;
wxBitmap bitmap_with_background;
int m_brightness_value{ -1 };
};
}} // namespace Slic3r::GUI
#endif
File diff suppressed because it is too large Load Diff
+233
View File
@@ -0,0 +1,233 @@
#ifndef slic3r_GUI_SelectMachinePop_hpp_
#define slic3r_GUI_SelectMachinePop_hpp_
#include <wx/wx.h>
#include <wx/intl.h>
#include <wx/collpane.h>
#include <wx/dataview.h>
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/dataview.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/hyperlink.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/popupwin.h>
#include <wx/spinctrl.h>
#include <wx/artprov.h>
#include <wx/wrapsizer.h>
#include <wx/srchctrl.h>
#include "ReleaseNote.hpp"
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
#include "DeviceManager.hpp"
#include "Plater.hpp"
#include "BBLStatusBar.hpp"
#include "BBLStatusBarSend.hpp"
#include "Widgets/Label.hpp"
#include "Widgets/Button.hpp"
#include "Widgets/CheckBox.hpp"
#include "Widgets/ComboBox.hpp"
#include "Widgets/ScrolledWindow.hpp"
#include "Widgets/PopupWindow.hpp"
#include <wx/simplebook.h>
#include <wx/hashmap.h>
namespace Slic3r { namespace GUI {
enum PrinterState {
OFFLINE,
IDLE,
BUSY,
LOCK,
IN_LAN
};
enum PrinterBindState {
NONE,
ALLOW_BIND,
ALLOW_UNBIND
};
wxDECLARE_EVENT(EVT_FINISHED_UPDATE_MACHINE_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_WILL_DISMISS_MACHINE_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent);
wxDECLARE_EVENT(EVT_DISSMISS_MACHINE_LIST, wxCommandEvent);
wxDECLARE_EVENT(EVT_CONNECT_LAN_PRINT, wxCommandEvent);
wxDECLARE_EVENT(EVT_EDIT_PRINT_NAME, wxCommandEvent);
wxDECLARE_EVENT(EVT_UNBIND_MACHINE, wxCommandEvent);
wxDECLARE_EVENT(EVT_BIND_MACHINE, wxCommandEvent);
#define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(216), FromDIP(364))
#define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(212), FromDIP(360))
#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(190), FromDIP(35))
#define SELECT_MACHINE_GREY900 wxColour(38, 46, 48)
#define SELECT_MACHINE_GREY600 wxColour(144, 144, 144)
#define SELECT_MACHINE_GREY400 wxColour(206, 206, 206)
#define SELECT_MACHINE_BRAND wxColour(0, 150, 136)
#define SELECT_MACHINE_REMIND wxColour(255, 111, 0)
#define SELECT_MACHINE_LIGHT_GREEN wxColour(219, 253, 231)
class MachineObjectPanel : public wxPanel
{
private:
bool m_is_my_devices {false};
bool m_show_edit{false};
bool m_show_bind{false};
bool m_hover {false};
bool m_is_macos_special_version{false};
PrinterBindState m_bind_state;
PrinterState m_state;
ScalableBitmap m_unbind_img;
ScalableBitmap m_edit_name_img;
ScalableBitmap m_select_unbind_img;
ScalableBitmap m_printer_status_offline;
ScalableBitmap m_printer_status_busy;
ScalableBitmap m_printer_status_idle;
ScalableBitmap m_printer_status_lock;
ScalableBitmap m_printer_in_lan;
MachineObject *m_info;
protected:
wxStaticBitmap *m_bitmap_info;
wxStaticBitmap *m_bitmap_bind;
public:
MachineObjectPanel(wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxTAB_TRAVERSAL,
const wxString &name = wxEmptyString);
~MachineObjectPanel();
void show_bind_dialog();
void set_printer_state(PrinterState state);
void show_printer_bind(bool show, PrinterBindState state);
void show_edit_printer_name(bool show);
void update_machine_info(MachineObject *info, bool is_my_devices = false);
protected:
void OnPaint(wxPaintEvent &event);
void render(wxDC &dc);
void doRender(wxDC &dc);
void on_mouse_enter(wxMouseEvent &evt);
void on_mouse_leave(wxMouseEvent &evt);
void on_mouse_left_up(wxMouseEvent &evt);
};
class MachinePanel
{
public:
wxString mIndex;
MachineObjectPanel *mPanel;
};
class PinCodePanel : public wxPanel
{
public:
PinCodePanel(wxWindow* parent,
int type,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
~PinCodePanel() {};
ScalableBitmap m_bitmap;
bool m_hover{false};
int m_type{0};
void OnPaint(wxPaintEvent& event);
void render(wxDC& dc);
void doRender(wxDC& dc);
void on_mouse_enter(wxMouseEvent& evt);
void on_mouse_leave(wxMouseEvent& evt);
void on_mouse_left_up(wxMouseEvent& evt);
};
class SelectMachinePopup : public PopupWindow
{
public:
SelectMachinePopup(wxWindow *parent);
~SelectMachinePopup();
// PopupWindow virtual methods are all overridden to log them
virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE;
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE;
virtual bool Show(bool show = true) wxOVERRIDE;
void update_machine_list(wxCommandEvent &event);
void start_ssdp(bool on_off);
bool was_dismiss() { return m_dismiss; }
private:
int m_my_devices_count{0};
int m_other_devices_count{0};
PinCodePanel* m_panel_ping_code{nullptr};
PinCodePanel* m_panel_direct_connection{nullptr};
wxWindow* m_placeholder_panel{nullptr};
wxHyperlinkCtrl* m_hyperlink{nullptr};
Label* m_ping_code_text{nullptr};
wxStaticBitmap* m_img_ping_code{nullptr};
wxBoxSizer * m_sizer_body{nullptr};
wxBoxSizer * m_sizer_my_devices{nullptr};
wxBoxSizer * m_sizer_other_devices{nullptr};
wxBoxSizer * m_sizer_search_bar{nullptr};
wxSearchCtrl* m_search_bar{nullptr};
wxScrolledWindow * m_scrolledWindow{nullptr};
wxWindow * m_panel_body{nullptr};
wxTimer * m_refresh_timer{nullptr};
std::vector<MachinePanel*> m_user_list_machine_panel;
std::vector<MachinePanel*> m_other_list_machine_panel;
boost::thread* get_print_info_thread{ nullptr };
std::shared_ptr<int> m_token = std::make_shared<int>(0);
std::string m_print_info = "";
bool m_dismiss { false };
std::map<std::string, MachineObject*> m_bind_machine_list;
std::map<std::string, MachineObject*> m_free_machine_list;
private:
void OnLeftUp(wxMouseEvent &event);
void on_timer(wxTimerEvent &event);
void update_other_devices();
void update_user_devices();
bool search_for_printer(MachineObject* obj);
void on_dissmiss_win(wxCommandEvent &event);
wxWindow *create_title_panel(wxString text);
};
class EditDevNameDialog : public DPIDialog
{
public:
EditDevNameDialog(Plater *plater = nullptr);
~EditDevNameDialog();
void set_machine_obj(MachineObject *obj);
void on_dpi_changed(const wxRect &suggested_rect) override;
void on_edit_name(wxCommandEvent &e);
Button* m_button_confirm{nullptr};
TextInput* m_textCtr{nullptr};
wxStaticText* m_static_valid{nullptr};
MachineObject* m_info{nullptr};
};
}} // namespace Slic3r::GUI
#endif
+1 -1
View File
@@ -565,7 +565,7 @@ BBL::PrintParams SendMultiMachinePage::request_params(MachineObject* obj)
params.comments = "no_ip";
else if (obj->is_support_cloud_print_only)
params.comments = "low_version";
else if (!obj->has_sdcard())
else if (obj->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)
params.comments = "no_sdcard";
else if (params.password.empty())
params.comments = "no_password";
+10 -10
View File
@@ -197,7 +197,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
m_scrollable_region = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL);
m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL);
m_panel_image = new wxPanel(m_scrollable_region, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_panel_image->SetBackgroundColour(m_colour_def_color);
@@ -609,7 +609,7 @@ void SendToPrinterDialog::prepare(int print_plate_idx)
m_print_plate_idx = print_plate_idx;
}
void SendToPrinterDialog::update_priner_status_msg(wxString msg, bool is_warning)
void SendToPrinterDialog::update_priner_status_msg(wxString msg, bool is_warning)
{
auto colour = is_warning ? wxColour(0xFF, 0x6F, 0x00) : wxColour(0x6B, 0x6B, 0x6B);
m_statictext_printer_msg->SetForegroundColour(colour);
@@ -671,7 +671,7 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
m_worker->cancel_all();
this->EndModal(wxID_CANCEL);
}
void SendToPrinterDialog::on_ok(wxCommandEvent &event)
{
BOOST_LOG_TRIVIAL(info) << "print_job: on_ok to send";
@@ -689,7 +689,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
if (!dev) return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) {
m_printer_last_select = "";
m_comboBox_printer->SetTextLabel("");
@@ -760,7 +760,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
fs::path default_output_file_path = boost::filesystem::path(default_output_file.c_str());
file_name = default_output_file_path.filename().string();
}*/
auto m_send_job = std::make_unique<SendJob>(m_printer_last_select);
@@ -778,9 +778,9 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
m_send_job->connection_type = obj_->connection_type();
m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = obj_->has_sdcard();
m_send_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
m_send_job->set_project_name(m_current_project_name.utf8_string());
enable_prepare_mode = false;
m_send_job->on_check_ip_address_fail([this](int result) {
@@ -1285,7 +1285,7 @@ void SendToPrinterDialog::set_default()
m_comboBox_printer->Enable();
// rset status bar
m_status_bar->reset();
NetworkAgent* agent = wxGetApp().getAgent();
if (agent) {
if (agent->is_user_login()) {
@@ -1312,7 +1312,7 @@ void SendToPrinterDialog::set_default()
image = image.Rescale(FromDIP(256), FromDIP(256));
m_thumbnailPanel->set_thumbnail(image);
}
std::vector<std::string> materials;
std::vector<std::string> display_materials;
{
@@ -1334,7 +1334,7 @@ void SendToPrinterDialog::set_default()
Layout();
Fit();
wxSize screenSize = wxGetDisplaySize();
auto dialogSize = this->GetSize();
+132 -96
View File
@@ -828,6 +828,9 @@ StatusBasePanel::StatusBasePanel(wxWindow *parent, wxWindowID id, const wxPoint
: wxScrolledWindow(parent, id, pos, size, wxHSCROLL | wxVSCROLL)
{
this->SetScrollRate(5, 5);
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
obj = dev->get_selected_machine();
init_bitmaps();
@@ -1023,7 +1026,7 @@ wxBoxSizer *StatusBasePanel::create_monitoring_page()
});
m_camera_switch_button->Hide();
m_bitmap_sdcard_img->SetToolTip(_L("SD Card"));
m_bitmap_sdcard_img->SetToolTip(_L("Storage"));
m_bitmap_timelapse_img->SetToolTip(_L("Timelapse"));
m_bitmap_recording_img->SetToolTip(_L("Video"));
m_bitmap_vcamera_img->SetToolTip(_L("Go Live"));
@@ -1632,16 +1635,16 @@ void StatusPanel::update_camera_state(MachineObject* obj)
if (m_last_sdcard != (int)obj->get_sdcard_state()) {
if (obj->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) {
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_no.bmp());
m_bitmap_sdcard_img->SetToolTip(_L("No SD Card"));
m_bitmap_sdcard_img->SetToolTip(_L("No Storage"));
} else if (obj->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL) {
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_normal.bmp());
m_bitmap_sdcard_img->SetToolTip(_L("SD Card"));
m_bitmap_sdcard_img->SetToolTip(_L("Storage"));
} else if (obj->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL) {
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_abnormal.bmp());
m_bitmap_sdcard_img->SetToolTip(_L("SD Card Abnormal"));
m_bitmap_sdcard_img->SetToolTip(_L("Storage Abnormal"));
} else {
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_normal.bmp());
m_bitmap_sdcard_img->SetToolTip(_L("SD Card"));
m_bitmap_sdcard_img->SetToolTip(_L("Storage"));
}
m_last_sdcard = (int)obj->get_sdcard_state();
}
@@ -2375,7 +2378,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj)
m_tempCtrl_bed->SetIconNormal();
}
m_tempCtrl_nozzle->SetCurrTemp((int) obj->nozzle_temp);
m_tempCtrl_nozzle->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);
}
@@ -2386,10 +2389,10 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj)
if (m_temp_nozzle_timeout > 0) {
m_temp_nozzle_timeout--;
} else {
if (!nozzle_temp_input) { m_tempCtrl_nozzle->SetTagTemp((int) obj->nozzle_temp_target); }
if (!nozzle_temp_input) { m_tempCtrl_nozzle->SetTagTemp((int) obj->m_extder_data.extders[0].target_temp); }
}
if ((obj->nozzle_temp_target - obj->nozzle_temp) >= TEMP_THRESHOLD_VAL) {
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();
@@ -2581,9 +2584,13 @@ void StatusPanel::update_ams(MachineObject *obj)
}
if (m_filament_setting_dlg) { m_filament_setting_dlg->obj = obj; }
if (obj->cali_version != -1 && last_cali_version != obj->cali_version) {
if (obj && (obj->last_cali_version != obj->cali_version)) {
last_cali_version = obj->cali_version;
CalibUtils::emit_get_PA_calib_info(obj->nozzle_diameter, "");
PACalibExtruderInfo cali_info;
cali_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter;
cali_info.use_extruder_id = false;
cali_info.use_nozzle_volume_type = false;
CalibUtils::emit_get_PA_calib_infos(cali_info);
}
bool is_support_virtual_tray = obj->ams_support_virtual_tray;
@@ -2591,10 +2598,10 @@ void StatusPanel::update_ams(MachineObject *obj)
AMSModel ams_mode = AMSModel::GENERIC_AMS;
if (obj) {
if (obj->get_printer_ams_type() == "f1") { ams_mode = AMSModel::EXTRA_AMS; }
else if(obj->get_printer_ams_type() == "generic") { ams_mode = AMSModel::GENERIC_AMS; }
if (obj->get_printer_ams_type() == "f1") { ams_mode = AMSModel::AMS_LITE; }
obj->check_ams_filament_valid();
}
if (obj->is_enable_np && obj->amsList.size() > 0) { ams_mode = AMSModel(obj->amsList.begin()->second->type); }
if (!obj
|| !obj->is_connected()
|| obj->amsList.empty()
@@ -2610,7 +2617,7 @@ void StatusPanel::update_ams(MachineObject *obj)
}
m_ams_control->SetAmsModel(AMSModel::NO_AMS, ams_mode);
m_ams_control->SetAmsModel(AMSModel::EXT_AMS, ams_mode);
show_ams_group(false);
m_ams_control->show_auto_refill(false);
@@ -2627,10 +2634,14 @@ void StatusPanel::update_ams(MachineObject *obj)
if (m_filament_setting_dlg) m_filament_setting_dlg->update();
std::vector<AMSinfo> ams_info;
ams_info.clear();
for (auto ams = obj->amsList.begin(); ams != obj->amsList.end(); ams++) {
AMSinfo info;
info.ams_id = ams->first;
if (ams->second->is_exists && info.parse_ams_info(obj, ams->second, obj->ams_calibrate_remain_flag, obj->is_support_ams_humidity)) ams_info.push_back(info);
if (ams->second->is_exists && info.parse_ams_info(obj, ams->second, obj->ams_calibrate_remain_flag, obj->is_support_ams_humidity)) {
if (ams_mode == AMSModel::AMS_LITE) { info.ams_type = AMSModel::AMS_LITE; }
ams_info.push_back(info);
}
}
//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) {
@@ -3303,7 +3314,13 @@ void StatusPanel::on_axis_ctrl_xy(wxCommandEvent &event)
if (event.GetInt() == 5) { obj->command_axis_control("X", 1.0, -1.0f, 3000); }
if (event.GetInt() == 6) { obj->command_axis_control("Y", 1.0, -1.0f, 3000); }
if (event.GetInt() == 7) { obj->command_axis_control("X", 1.0, 1.0f, 3000); }
if (event.GetInt() == 8) { obj->command_go_home(); }
if (event.GetInt() == 8) {
if (obj->is_support_command_homing) {
obj->command_go_home2();
} else {
obj->command_go_home();
}
}
//check is at home
if (event.GetInt() == 1
@@ -3402,7 +3419,7 @@ void StatusPanel::axis_ctrl_e_hint(bool up_down)
void StatusPanel::on_axis_ctrl_e_up_10(wxCommandEvent &event)
{
if (obj) {
if (obj->nozzle_temp >= TEMP_THRESHOLD_ALLOW_E_CTRL || (wxGetApp().app_config->get("not_show_ectrl_hint") == "1"))
if (obj->m_extder_data.extders[0].temp >= TEMP_THRESHOLD_ALLOW_E_CTRL || (wxGetApp().app_config->get("not_show_ectrl_hint") == "1"))
obj->command_axis_control("E", 1.0, -10.0f, 900);
else
axis_ctrl_e_hint(true);
@@ -3412,7 +3429,7 @@ void StatusPanel::on_axis_ctrl_e_up_10(wxCommandEvent &event)
void StatusPanel::on_axis_ctrl_e_down_10(wxCommandEvent &event)
{
if (obj) {
if (obj->nozzle_temp >= TEMP_THRESHOLD_ALLOW_E_CTRL || (wxGetApp().app_config->get("not_show_ectrl_hint") == "1"))
if (obj->m_extder_data.extders[0].temp >= TEMP_THRESHOLD_ALLOW_E_CTRL || (wxGetApp().app_config->get("not_show_ectrl_hint") == "1"))
obj->command_axis_control("E", 1.0, 10.0f, 900);
else
axis_ctrl_e_hint(false);
@@ -3421,7 +3438,7 @@ void StatusPanel::on_axis_ctrl_e_down_10(wxCommandEvent &event)
void StatusPanel::on_start_unload(wxCommandEvent &event)
{
if (obj) obj->command_ams_switch(255);
if (obj) obj->command_ams_change_filament(false, "255", "255");
}
void StatusPanel::on_set_bed_temp()
@@ -3507,10 +3524,11 @@ void StatusPanel::on_ams_load_curr()
std::string curr_ams_id = m_ams_control->GetCurentAms();
std::string curr_can_id = m_ams_control->GetCurrentCan(curr_ams_id);
update_filament_step();
//virtual tray
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0)
{
int old_temp = -1;
int new_temp = -1;
AmsTray* curr_tray = &obj->vt_tray;
@@ -3520,13 +3538,22 @@ void StatusPanel::on_ams_load_curr()
try {
if (!curr_tray->nozzle_temp_max.empty() && !curr_tray->nozzle_temp_min.empty())
old_temp = (atoi(curr_tray->nozzle_temp_min.c_str()) + atoi(curr_tray->nozzle_temp_max.c_str())) / 2;
if (!obj->vt_tray.nozzle_temp_max.empty() && !obj->vt_tray.nozzle_temp_min.empty())
new_temp = (atoi(obj->vt_tray.nozzle_temp_min.c_str()) + atoi(obj->vt_tray.nozzle_temp_max.c_str())) / 2;
if (!curr_tray->nozzle_temp_max.empty() && !curr_tray->nozzle_temp_min.empty())
new_temp = (atoi(curr_tray->nozzle_temp_min.c_str()) + atoi(curr_tray->nozzle_temp_max.c_str())) / 2;
}
catch (...) {
;
}
obj->command_ams_switch(VIRTUAL_TRAY_ID, old_temp, new_temp);
if (obj->is_enable_np || obj->is_enable_ams_np) {
try {
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
obj->command_ams_change_filament(true, curr_ams_id, "0", old_temp, new_temp);
}
} catch (...) {}
} else {
obj->command_ams_change_filament(true, "254", "0", old_temp, new_temp);
}
}
std::map<std::string, Ams*>::iterator it = obj->amsList.find(curr_ams_id);
@@ -3541,24 +3568,32 @@ void StatusPanel::on_ams_load_curr()
}
AmsTray* curr_tray = obj->get_curr_tray();
AmsTray* targ_tray = obj->get_ams_tray(curr_ams_id, curr_can_id);
int old_temp = -1;
int new_temp = -1;
if (curr_tray && targ_tray) {
int old_temp = -1;
int new_temp = -1;
try {
if (!curr_tray->nozzle_temp_max.empty() && !curr_tray->nozzle_temp_min.empty())
old_temp = (atoi(curr_tray->nozzle_temp_min.c_str()) + atoi(curr_tray->nozzle_temp_max.c_str())) / 2;
if (!targ_tray->nozzle_temp_max.empty() && !targ_tray->nozzle_temp_min.empty())
new_temp = (atoi(targ_tray->nozzle_temp_min.c_str()) + atoi(targ_tray->nozzle_temp_max.c_str())) / 2;
}
catch (...) {
} catch (...) {
;
}
int tray_index = atoi(curr_ams_id.c_str()) * 4 + atoi(tray_it->second->id.c_str());
obj->command_ams_switch(tray_index, old_temp, new_temp);
}
else {
int tray_index = atoi(curr_ams_id.c_str()) * 4 + atoi(tray_it->second->id.c_str());
obj->command_ams_switch(tray_index, -1, -1);
int tray_index = atoi(curr_ams_id.c_str()) * 4 + atoi(tray_it->second->id.c_str());
if (obj->is_enable_np) {
try {
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
obj->command_ams_change_filament(true, curr_ams_id, curr_can_id, old_temp, new_temp);
}
}
catch (...){}
} else {
obj->command_ams_change_filament(true, curr_ams_id, curr_can_id, old_temp, new_temp);
}
}
}
@@ -3575,7 +3610,20 @@ void StatusPanel::on_ams_load_vams(wxCommandEvent& event) {
void StatusPanel::on_ams_unload(SimpleEvent &event)
{
if (obj) { obj->command_ams_switch(255); }
if (obj) {
std::string curr_ams_id = m_ams_control->GetCurentAms();
std::string curr_can_id = m_ams_control->GetCurrentCan(curr_ams_id);
if (obj->is_enable_np) {
try {
for (auto ext : obj->m_extder_data.extders) {
if (ext.snow.ams_id == curr_ams_id && ext.snow.slot_id == curr_can_id) { obj->command_ams_change_filament(false, curr_ams_id, "255"); }
}
} catch (...) {}
} else {
obj->command_ams_change_filament(false, curr_ams_id, "255");
}
}
}
void StatusPanel::on_ams_filament_backup(SimpleEvent& event)
@@ -3678,73 +3726,55 @@ void StatusPanel::on_filament_edit(wxCommandEvent &event)
if (obj) {
m_filament_setting_dlg->obj = obj;
std::string ams_id = m_ams_control->GetCurentAms();
int ams_id_int = 0;
int tray_id_int = 0;
if (ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
tray_id_int = VIRTUAL_TRAY_ID;
m_filament_setting_dlg->ams_id = ams_id_int;
m_filament_setting_dlg->tray_id = tray_id_int;
wxString k_val;
wxString n_val;
k_val = wxString::Format("%.3f", obj->vt_tray.k);
n_val = wxString::Format("%.3f", obj->vt_tray.n);
m_filament_setting_dlg->Move(wxPoint(current_position_x, current_position_y));
m_filament_setting_dlg->Popup(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString, k_val, n_val);
} else {
std::string tray_id = event.GetString().ToStdString(); // m_ams_control->GetCurrentCan(ams_id);
try {
ams_id_int = atoi(ams_id.c_str());
tray_id_int = atoi(tray_id.c_str());
m_filament_setting_dlg->ams_id = ams_id_int;
m_filament_setting_dlg->tray_id = tray_id_int;
std::string sn_number;
std::string filament;
std::string temp_max;
std::string temp_min;
wxString k_val;
wxString n_val;
auto it = obj->amsList.find(ams_id);
if (it != obj->amsList.end()) {
auto tray_it = it->second->trayList.find(tray_id);
if (tray_it != it->second->trayList.end()) {
k_val = wxString::Format("%.3f", tray_it->second->k);
n_val = wxString::Format("%.3f", tray_it->second->n);
wxColor color = AmsTray::decode_color(tray_it->second->color);
//m_filament_setting_dlg->set_color(color);
int ams_id = event.GetInt();
int slot_id = event.GetString().IsEmpty() ? 0 : std::stoi(event.GetString().ToStdString());
std::vector<wxColour> cols;
for (auto col : tray_it->second->cols) {
cols.push_back( AmsTray::decode_color(col));
}
m_filament_setting_dlg->set_ctype(tray_it->second->ctype);
m_filament_setting_dlg->ams_filament_id = tray_it->second->setting_id;
try {
m_filament_setting_dlg->ams_id = ams_id;
m_filament_setting_dlg->slot_id = slot_id;
if (m_filament_setting_dlg->ams_filament_id.empty()) {
m_filament_setting_dlg->set_empty_color(color);
}
else {
m_filament_setting_dlg->set_color(color);
m_filament_setting_dlg->set_colors(cols);
}
std::string sn_number;
std::string filament;
std::string temp_max;
std::string temp_min;
wxString k_val;
wxString n_val;
auto it = obj->amsList.find(std::to_string(ams_id));
if (it != obj->amsList.end()) {
auto tray_it = it->second->trayList.find(std::to_string(slot_id));
if (tray_it != it->second->trayList.end()) {
k_val = wxString::Format("%.3f", tray_it->second->k);
n_val = wxString::Format("%.3f", tray_it->second->n);
wxColor color = AmsTray::decode_color(tray_it->second->color);
// m_filament_setting_dlg->set_color(color);
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(tray_it->second->tag_uid);
if (!m_filament_setting_dlg->m_is_third) {
sn_number = tray_it->second->uuid;
filament = tray_it->second->sub_brands;
temp_max = tray_it->second->nozzle_temp_max;
temp_min = tray_it->second->nozzle_temp_min;
}
std::vector<wxColour> cols;
for (auto col : tray_it->second->cols) { cols.push_back(AmsTray::decode_color(col)); }
m_filament_setting_dlg->set_ctype(tray_it->second->ctype);
m_filament_setting_dlg->ams_filament_id = tray_it->second->setting_id;
if (m_filament_setting_dlg->ams_filament_id.empty()) {
m_filament_setting_dlg->set_empty_color(color);
} else {
m_filament_setting_dlg->set_color(color);
m_filament_setting_dlg->set_colors(cols);
}
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(tray_it->second->tag_uid);
if (!m_filament_setting_dlg->m_is_third) {
sn_number = tray_it->second->uuid;
filament = tray_it->second->sub_brands;
temp_max = tray_it->second->nozzle_temp_max;
temp_min = tray_it->second->nozzle_temp_min;
}
}
}
m_filament_setting_dlg->Move(wxPoint(current_position_x, current_position_y));
m_filament_setting_dlg->Popup(filament, sn_number, temp_min, temp_max, k_val, n_val);
}
catch (...) {
;
}
m_filament_setting_dlg->Move(wxPoint(current_position_x, current_position_y));
m_filament_setting_dlg->Popup(filament, sn_number, temp_min, temp_max, k_val, n_val);
} catch (...) {
;
}
}
}
@@ -3761,8 +3791,14 @@ void StatusPanel::on_ext_spool_edit(wxCommandEvent &event)
if (obj) {
m_filament_setting_dlg->obj = obj;
int ams_id = event.GetInt();
int slot_id = event.GetString().IsEmpty() ? 0 : std::stoi(event.GetString().ToStdString());
m_filament_setting_dlg->ams_id = ams_id;
m_filament_setting_dlg->slot_id = slot_id;
try {
m_filament_setting_dlg->tray_id = VIRTUAL_TRAY_ID;
std::string sn_number;
std::string filament;
std::string temp_max;
@@ -3788,7 +3824,7 @@ void StatusPanel::on_ext_spool_edit(wxCommandEvent &event)
m_filament_setting_dlg->set_colors(cols);
}
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(obj->vt_tray.tag_uid);
if (!m_filament_setting_dlg->m_is_third) {
sn_number = obj->vt_tray.uuid;
+1 -1
View File
@@ -435,6 +435,7 @@ public:
~StatusBasePanel();
MachineObject* obj{nullptr};
void init_bitmaps();
wxBoxSizer *create_monitoring_page();
wxBoxSizer *create_machine_control_page(wxWindow *parent);
@@ -640,7 +641,6 @@ public:
STATE_COUNT = 4
};
MachineObject *obj {nullptr};
BBLSubTask * last_subtask{nullptr};
std::string last_profile_id;
std::string last_task_id;
+213 -19
View File
@@ -2,6 +2,8 @@
#include <slic3r/GUI/Widgets/SideTools.hpp>
#include <slic3r/GUI/Widgets/Label.hpp>
#include <slic3r/GUI/I18N.hpp>
#include "slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "libslic3r/Thread.hpp"
@@ -12,6 +14,17 @@ namespace GUI {
static const wxColour TEXT_NORMAL_CLR = wxColour(0, 150, 136);
static const wxColour TEXT_FAILED_CLR = wxColour(255, 111, 0);
static const std::unordered_map<wxString, wxString> ACCESSORY_DISPLAY_STR = {
{"N3F", "AMS 2 PRO"},
{"N3S", "AMS HT"},
{"O2L_PC", L("Air Pump")},
{"O2L_10B", L("Laser 10w")},
{"O2L_40B", L("Laser 40w")},
{"O2L_PCM", L("Cutting Module")},
{"O2L_ACM", "Active Cutting Module"},
{"O2L_UCM", "Ultrasonic Cutting Module"},
};
enum FIRMWARE_STASUS
{
UNKOWN,
@@ -136,16 +149,16 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
m_ams_info_sizer->SetFlexibleDirection(wxHORIZONTAL);
m_ams_info_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
for (auto i = 0; i < 4; i++) {
auto amspanel = new AmsPanel(this, wxID_ANY);
m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5);
amspanel->Hide();
//for (auto i = 0; i < 4; i++) {
// auto amspanel = new AmsPanel(this, wxID_ANY);
// m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5);
// amspanel->Hide();
/*AmsPanelItem item = AmsPanelItem();
item.id = i;
item.item = amspanel;*/
m_amspanel_list.Add(amspanel);
}
// /*AmsPanelItem item = AmsPanelItem();
// item.id = i;
// item.item = amspanel;*/
// m_amspanel_list.Add(amspanel);
//}
m_ams_content_sizer->Add(m_ams_info_sizer, 0, wxEXPAND, 0);
m_ams_sizer->Add(m_ams_content_sizer, 1, wxEXPAND, 0);
@@ -196,7 +209,10 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
m_main_left_sizer->Add(m_ext_sizer, 0, wxEXPAND, 0);
/* cutting module */
createCuttingWidgets(m_main_left_sizer);
createLaserWidgets(m_main_left_sizer);
createAirPumpWidgets(m_main_left_sizer);
m_main_sizer->Add(m_main_left_sizer, 1, wxEXPAND, 0);
@@ -307,6 +323,69 @@ wxPanel *MachineInfoPanel::create_caption_panel(wxWindow *parent)
return caption_panel;
}
void MachineInfoPanel::createAirPumpWidgets(wxBoxSizer* main_left_sizer)
{
m_air_pump_line_above = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
m_air_pump_line_above->SetBackgroundColour(wxColour(206, 206, 206));
main_left_sizer->Add(m_air_pump_line_above, 0, wxEXPAND | wxLEFT, FromDIP(40));
m_air_pump_img = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(200), FromDIP(200)));
m_air_pump_img->SetBitmap(m_img_air_pump.bmp());
wxBoxSizer* content_sizer = new wxBoxSizer(wxVERTICAL);
content_sizer->Add(0, 40, 0, wxEXPAND, FromDIP(5));
m_air_pump_version = new uiDeviceUpdateVersion(this, wxID_ANY);
content_sizer->Add(m_air_pump_version, 0, wxEXPAND, 0);
m_air_pump_sizer = new wxBoxSizer(wxHORIZONTAL);
m_air_pump_sizer->Add(m_air_pump_img, 0, wxALIGN_TOP | wxALL, FromDIP(5));
m_air_pump_sizer->Add(content_sizer, 1, wxEXPAND, 0);
main_left_sizer->Add(m_air_pump_sizer, 0, wxEXPAND, 0);
}
void MachineInfoPanel::createCuttingWidgets(wxBoxSizer* main_left_sizer)
{
m_cutting_line_above = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
m_cutting_line_above->SetBackgroundColour(wxColour(206, 206, 206));
main_left_sizer->Add(m_cutting_line_above, 0, wxEXPAND | wxLEFT, FromDIP(40));
m_cutting_img = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(200), FromDIP(200)));
m_cutting_img->SetBitmap(m_img_cutting.bmp());
wxBoxSizer* content_sizer = new wxBoxSizer(wxVERTICAL);
content_sizer->Add(0, 40, 0, wxEXPAND, FromDIP(5));
m_cutting_version = new uiDeviceUpdateVersion(this, wxID_ANY);
content_sizer->Add(m_cutting_version, 0, wxEXPAND, 0);
m_cutting_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cutting_sizer->Add(m_cutting_img, 0, wxALIGN_TOP | wxALL, FromDIP(5));
m_cutting_sizer->Add(content_sizer, 1, wxEXPAND, 0);
main_left_sizer->Add(m_cutting_sizer, 0, wxEXPAND, 0);
};
void MachineInfoPanel::createLaserWidgets(wxBoxSizer* main_left_sizer)
{
m_laser_line_above = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
m_laser_line_above->SetBackgroundColour(wxColour(206, 206, 206));
main_left_sizer->Add(m_laser_line_above, 0, wxEXPAND | wxLEFT, FromDIP(40));
m_lazer_img = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(200), FromDIP(200)));
m_lazer_img->SetBitmap(m_img_laser.bmp());
wxBoxSizer* content_sizer = new wxBoxSizer(wxVERTICAL);
content_sizer->Add(0, 40, 0, wxEXPAND, FromDIP(5));
m_laser_version = new uiDeviceUpdateVersion(this, wxID_ANY);
content_sizer->Add(m_laser_version, 0, wxEXPAND, 0);
m_laser_sizer = new wxBoxSizer(wxHORIZONTAL);
m_laser_sizer->Add(m_lazer_img, 0, wxALIGN_TOP | wxALL, FromDIP(5));
m_laser_sizer->Add(content_sizer, 1, wxEXPAND, 0);
main_left_sizer->Add(m_laser_sizer, 0, wxEXPAND, 0);
}
void MachineInfoPanel::msw_rescale()
{
rescale_bitmaps();
@@ -329,11 +408,17 @@ void MachineInfoPanel::init_bitmaps()
m_img_monitor_ams = ScalableBitmap(this, "monitor_upgrade_ams", 200);
m_img_ext = ScalableBitmap(this, "monitor_upgrade_ext", 200);
if (wxGetApp().dark_mode()) {
m_img_air_pump = ScalableBitmap(this, "air_pump_dark", 160);
m_img_extra_ams = ScalableBitmap(this, "extra_icon_dark", 160);
}
else {
m_img_air_pump = ScalableBitmap(this, "air_pump", 160);
m_img_extra_ams = ScalableBitmap(this, "extra_icon", 160);
}
m_img_laser = ScalableBitmap(this, "laser", 160);
m_img_cutting = ScalableBitmap(this, "cut", 160);
upgrade_green_icon = ScalableBitmap(this, "monitor_upgrade_online", 5);
upgrade_gray_icon = ScalableBitmap(this, "monitor_upgrade_offline", 5);
upgrade_yellow_icon = ScalableBitmap(this, "monitor_upgrade_busy", 5);
@@ -362,7 +447,7 @@ MachineInfoPanel::~MachineInfoPanel()
delete confirm_dlg;
}
void MachineInfoPanel::Update_printer_img(MachineObject* obj)
void MachineInfoPanel::update_printer_imgs(MachineObject* obj)
{
if (!obj) {return;}
auto img = obj->get_printer_thumbnail_img_str();
@@ -374,6 +459,7 @@ void MachineInfoPanel::Update_printer_img(MachineObject* obj)
m_img_extra_ams = ScalableBitmap(this, "extra_icon", 160);
}
m_img_printer = ScalableBitmap(this, img, 160);
m_printer_img->SetBitmap(m_img_printer.bmp());
m_printer_img->Refresh();
@@ -385,7 +471,7 @@ void MachineInfoPanel::Update_printer_img(MachineObject* obj)
void MachineInfoPanel::update(MachineObject* obj)
{
if (m_obj != obj)
Update_printer_img(obj);
update_printer_imgs(obj);
m_obj = obj;
if (obj) {
@@ -423,6 +509,11 @@ void MachineInfoPanel::update(MachineObject* obj)
// update ams and extension
update_ams_ext(obj);
// update
update_air_pump(obj);
update_cut(obj);
update_laszer(obj);
//update progress
int upgrade_percent = obj->get_upgrade_percent();
if (obj->upgrade_display_state == (int) MachineObject::UpgradingDisplayState::UpgradingInProgress) {
@@ -543,8 +634,10 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
{
bool has_hub_model = false;
bool is_o_series = DeviceManager::get_printer_series(obj->printer_type) == "series_o";
//hub
if (!obj->online_ahb || obj->module_vers.find("ahb") == obj->module_vers.end())
if (!obj->online_ahb || obj->module_vers.find("ahb") == obj->module_vers.end() || is_o_series)
m_ahb_panel->Hide();
else {
has_hub_model = true;
@@ -670,14 +763,29 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
show_ams(true);
std::map<int, MachineObject::ModuleVersionInfo> ver_list = obj->get_ams_version();
AmsPanelHash::iterator iter = m_amspanel_list.begin();
if (obj->amsList.size() != m_amspanel_list.size()) {
int add_count = obj->amsList.size() - m_amspanel_list.size();
if (add_count > 0) {
for (int i = 0; i < add_count; i++) {
auto amspanel = new AmsPanel(this, wxID_ANY);
wxGetApp().UpdateDarkUIWin(amspanel);
m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5);
m_amspanel_list.Add(amspanel);
}
}
if (add_count < 0) {
for (int i = 0; i < -add_count; i++) {
m_amspanel_list.back()->Destroy();
m_amspanel_list.pop_back();
}
}
}
for (auto i = 0; i < m_amspanel_list.GetCount(); i++) {
AmsPanel* amspanel = m_amspanel_list[i];
amspanel->Hide();
}
auto ams_index = 0;
for (std::map<std::string, Ams*>::iterator iter = obj->amsList.begin(); iter != obj->amsList.end(); iter++) {
wxString ams_name;
@@ -688,9 +796,26 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
amspanel->Show();
auto it = ver_list.find(atoi(iter->first.c_str()));
auto ams_id = std::stoi(iter->second->id);
wxString ams_text = wxString::Format("AMS%s", std::to_string(ams_id + 1));
if (it == ver_list.end()) {
continue;
}
auto ams_id = std::stoi(iter->second->id);
ams_id -= ams_id >= 128 ? 128 : 0;
size_t pos = it->second.name.find('/');
wxString ams_device_name = "AMS-%s";
if (pos != std::string::npos) {
wxString result = it->second.name.substr(0, pos);
result.MakeUpper();
if (auto str_it = ACCESSORY_DISPLAY_STR.find(result); str_it != ACCESSORY_DISPLAY_STR.end())
result = str_it->second;
ams_device_name = result + "-%s";
}
wxString ams_text = wxString::Format(ams_device_name, std::to_string(ams_id + 1));
ams_name = ams_text;
if (it == ver_list.end()) {
@@ -825,7 +950,7 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
//ext
auto ext_module = obj->module_vers.find("ext");
if (ext_module == obj->module_vers.end())
if (ext_module == obj->module_vers.end() || is_o_series)
show_ext(false);
else {
wxString sn_text = ext_module->second.sn;
@@ -858,6 +983,45 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
this->Fit();
}
void MachineInfoPanel::update_air_pump(MachineObject* obj)
{
if (obj && obj->air_pump_version_info.isValid())
{
m_air_pump_version->UpdateInfo(obj->air_pump_version_info);
show_air_pump(true);
}
else
{
show_air_pump(false);
}
}
void MachineInfoPanel::update_cut(MachineObject* obj)
{
if (obj && obj->cutting_module_version_info.isValid())
{
m_cutting_version->UpdateInfo(obj->cutting_module_version_info);
show_cut(true);
}
else
{
show_cut(false);
}
}
void MachineInfoPanel::update_laszer(MachineObject* obj)
{
if (obj && obj->laser_version_info.isValid())
{
m_laser_version->UpdateInfo(obj->laser_version_info);
show_laszer(true);
}
else
{
show_laszer(false);
}
}
void MachineInfoPanel::show_status(int status, std::string upgrade_status_str)
{
if (last_status == status && last_status_str == upgrade_status_str) return;
@@ -952,10 +1116,40 @@ void MachineInfoPanel::show_extra_ams(bool show, bool force_update) {
m_last_extra_ams_show = show;
}
void MachineInfoPanel::show_air_pump(bool show)
{
if (m_air_pump_version->IsShown() != show)
{
m_air_pump_img->Show(show);
m_air_pump_line_above->Show(show);
m_air_pump_version->Show(show);
}
}
void MachineInfoPanel::show_cut(bool show)
{
if (m_cutting_version->IsShown() != show)
{
m_cutting_img->Show(show);
m_cutting_line_above->Show(show);
m_cutting_version->Show(show);
}
}
void MachineInfoPanel::show_laszer(bool show)
{
if (m_laser_version->IsShown() != show)
{
m_lazer_img->Show(show);
m_laser_line_above->Show(show);
m_laser_version->Show(show);
}
}
void MachineInfoPanel::on_sys_color_changed()
{
if (m_obj) {
Update_printer_img(m_obj);
update_printer_imgs(m_obj);
}
}
+36 -1
View File
@@ -12,6 +12,9 @@
namespace Slic3r {
namespace GUI {
// Previous definitions
class uiDeviceUpdateVersion;
class ExtensionPanel : public wxPanel
{
public:
@@ -105,6 +108,24 @@ protected:
bool m_last_extra_ams_show = true;
wxBoxSizer* m_extra_ams_sizer;
/* air_pump info*/
wxBoxSizer* m_air_pump_sizer = nullptr;
wxStaticBitmap* m_air_pump_img = nullptr;
wxStaticLine* m_air_pump_line_above = nullptr;;
uiDeviceUpdateVersion* m_air_pump_version = nullptr;
/* cutting module info*/
wxBoxSizer* m_cutting_sizer = nullptr;
wxStaticBitmap* m_cutting_img = nullptr;
wxStaticLine* m_cutting_line_above = nullptr;;
uiDeviceUpdateVersion* m_cutting_version = nullptr;
/* laser info*/
wxBoxSizer* m_laser_sizer = nullptr;
wxStaticBitmap* m_lazer_img = nullptr;
wxStaticLine* m_laser_line_above = nullptr;;
uiDeviceUpdateVersion* m_laser_version = nullptr;
/* upgrade widgets */
wxBoxSizer* m_upgrading_sizer;
wxStaticText * m_staticText_upgrading_info;
@@ -122,6 +143,9 @@ protected:
ScalableBitmap m_img_monitor_ams;
ScalableBitmap m_img_extra_ams;
ScalableBitmap m_img_printer;
ScalableBitmap m_img_air_pump;
ScalableBitmap m_img_cutting;
ScalableBitmap m_img_laser;
ScalableBitmap upgrade_gray_icon;
ScalableBitmap upgrade_green_icon;
ScalableBitmap upgrade_yellow_icon;
@@ -139,7 +163,7 @@ public:
~MachineInfoPanel();
void on_sys_color_changed();
void Update_printer_img(MachineObject* obj);
void update_printer_imgs(MachineObject* obj);
void init_bitmaps();
void rescale_bitmaps();
@@ -151,10 +175,16 @@ public:
void update(MachineObject *obj);
void update_version_text(MachineObject *obj);
void update_ams_ext(MachineObject *obj);
void update_air_pump(MachineObject* obj);
void update_cut(MachineObject* obj);
void update_laszer(MachineObject* obj);
void show_status(int status, std::string upgrade_status_str = "");
void show_ams(bool show = false, bool force_update = false);
void show_ext(bool show = false, bool force_update = false);
void show_extra_ams(bool show = false, bool force_update = false);
void show_air_pump(bool show = true);
void show_cut(bool show = true);
void show_laszer(bool show = true);
void on_upgrade_firmware(wxCommandEvent &event);
void on_consisitency_upgrade_firmware(wxCommandEvent &event);
@@ -171,6 +201,11 @@ public:
ptOtaPanel,
ptAmsPanel,
}panel_type;
private:
void createAirPumpWidgets(wxBoxSizer* main_left_sizer);
void createCuttingWidgets(wxBoxSizer* main_left_sizer);
void createLaserWidgets(wxBoxSizer* main_left_sizer);
};
//enum UpgradeMode {
File diff suppressed because it is too large Load Diff
+23 -571
View File
@@ -5,6 +5,7 @@
#include "StaticBox.hpp"
#include "StepCtrl.hpp"
#include "Button.hpp"
#include "AMSItem.hpp"
#include "../DeviceManager.hpp"
#include "slic3r/GUI/Event.hpp"
#include "slic3r/GUI/AmsMappingPopup.hpp"
@@ -13,546 +14,11 @@
#include <wx/animate.h>
#include <wx/dynarray.h>
#define AMS_CONTROL_BRAND_COLOUR wxColour(0, 150, 136)
#define AMS_CONTROL_GRAY700 wxColour(107, 107, 107)
#define AMS_CONTROL_GRAY800 wxColour(50, 58, 61)
#define AMS_CONTROL_GRAY500 wxColour(172, 172, 172)
#define AMS_CONTROL_DISABLE_COLOUR wxColour(206, 206, 206)
#define AMS_CONTROL_DISABLE_TEXT_COLOUR wxColour(144, 144, 144)
#define AMS_CONTROL_WHITE_COLOUR wxColour(255, 255, 255)
#define AMS_CONTROL_BLACK_COLOUR wxColour(0, 0, 0)
#define AMS_CONTROL_DEF_BLOCK_BK_COLOUR wxColour(238, 238, 238)
#define AMS_CONTROL_DEF_LIB_BK_COLOUR wxColour(248, 248, 248)
#define AMS_EXTRUDER_DEF_COLOUR wxColour(234, 234, 234)
#define AMS_CONTROL_MAX_COUNT 4
#define AMS_CONTRO_CALIBRATION_BUTTON_SIZE wxSize(FromDIP(150), FromDIP(28))
// enum AMSRoadMode{
// AMS_ROAD_MODE_LEFT,
// AMS_ROAD_MODE_LEFT_RIGHT,
// AMS_ROAD_MODE_END,
//};
namespace Slic3r { namespace GUI {
enum AMSModel {
NO_AMS = 0,
GENERIC_AMS = 1,
EXTRA_AMS = 2
};
enum ActionButton {
ACTION_BTN_CALI = 0,
ACTION_BTN_LOAD = 1,
ACTION_BTN_UNLOAD = 2,
ACTION_BTN_COUNT = 3
};
enum class AMSRoadMode : int {
AMS_ROAD_MODE_LEFT,
AMS_ROAD_MODE_LEFT_RIGHT,
AMS_ROAD_MODE_END,
AMS_ROAD_MODE_END_ONLY,
AMS_ROAD_MODE_NONE,
AMS_ROAD_MODE_NONE_ANY_ROAD,
AMS_ROAD_MODE_VIRTUAL_TRAY
};
enum class AMSPassRoadMode : int {
AMS_ROAD_MODE_NONE,
AMS_ROAD_MODE_LEFT,
AMS_ROAD_MODE_LEFT_RIGHT,
AMS_ROAD_MODE_END_TOP,
AMS_ROAD_MODE_END_RIGHT,
AMS_ROAD_MODE_END_BOTTOM,
};
enum class AMSAction : int {
AMS_ACTION_NONE,
AMS_ACTION_LOAD,
AMS_ACTION_UNLOAD,
AMS_ACTION_CALI,
AMS_ACTION_PRINTING,
AMS_ACTION_NORMAL,
AMS_ACTION_NOAMS,
};
enum class AMSPassRoadSTEP : int {
AMS_ROAD_STEP_NONE,
AMS_ROAD_STEP_1, // lib -> extrusion
AMS_ROAD_STEP_2, // extrusion->buffer
AMS_ROAD_STEP_3, // extrusion
AMS_ROAD_STEP_COMBO_LOAD_STEP1,
AMS_ROAD_STEP_COMBO_LOAD_STEP2,
AMS_ROAD_STEP_COMBO_LOAD_STEP3,
};
enum class AMSPassRoadType : int {
AMS_ROAD_TYPE_NONE,
AMS_ROAD_TYPE_LOAD,
AMS_ROAD_TYPE_UNLOAD,
};
enum class AMSCanType : int {
AMS_CAN_TYPE_NONE,
AMS_CAN_TYPE_BRAND,
AMS_CAN_TYPE_THIRDBRAND,
AMS_CAN_TYPE_EMPTY,
AMS_CAN_TYPE_VIRTUAL,
};
enum FilamentStep {
STEP_IDLE,
STEP_HEAT_NOZZLE,
STEP_CUT_FILAMENT,
STEP_PULL_CURR_FILAMENT,
STEP_PUSH_NEW_FILAMENT,
STEP_PURGE_OLD_FILAMENT,
STEP_FEED_FILAMENT,
STEP_CONFIRM_EXTRUDED,
STEP_CHECK_POSITION,
STEP_COUNT,
};
enum FilamentStepType {
STEP_TYPE_LOAD = 0,
STEP_TYPE_UNLOAD = 1,
STEP_TYPE_VT_LOAD = 2,
};
#define AMS_ITEM_CUBE_SIZE wxSize(FromDIP(14), FromDIP(14))
#define AMS_ITEM_SIZE wxSize(FromDIP(82), FromDIP(27))
#define AMS_ITEM_HUMIDITY_SIZE wxSize(FromDIP(120), FromDIP(27))
#define AMS_CAN_LIB_SIZE wxSize(FromDIP(58), FromDIP(80))
#define AMS_CAN_ROAD_SIZE wxSize(FromDIP(66), FromDIP(70))
#define AMS_CAN_ITEM_HEIGHT_SIZE FromDIP(27)
#define AMS_CANS_SIZE wxSize(FromDIP(284), FromDIP(196))
#define AMS_CANS_WINDOW_SIZE wxSize(FromDIP(264), FromDIP(196))
#define AMS_STEP_SIZE wxSize(FromDIP(172), FromDIP(196))
#define AMS_REFRESH_SIZE wxSize(FromDIP(30), FromDIP(30))
#define AMS_EXTRUDER_SIZE wxSize(FromDIP(86), FromDIP(72))
#define AMS_EXTRUDER_BITMAP_SIZE wxSize(FromDIP(36), FromDIP(55))
struct Caninfo
{
std::string can_id;
wxString material_name;
wxColour material_colour = {*wxWHITE};
AMSCanType material_state;
int ctype=0;
int material_remain = 100;
float k = 0.0f;
float n = 0.0f;
std::vector<wxColour> material_cols;
};
struct AMSinfo
{
public:
std::string ams_id;
std::vector<Caninfo> cans;
std::string current_can_id;
AMSPassRoadSTEP current_step;
AMSAction current_action;
int curreent_filamentstep;
int ams_humidity = 0;
bool parse_ams_info(MachineObject* obj, Ams *ams, bool remain_flag = false, bool humidity_flag = false);
};
/*************************************************
Description:AMSrefresh
**************************************************/
#define AMS_REFRESH_PLAY_LOADING_TIMER 100
class AMSrefresh : public wxWindow
{
public:
AMSrefresh();
AMSrefresh(wxWindow *parent, wxString number, Caninfo info, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
AMSrefresh(wxWindow *parent, int number, Caninfo info, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~AMSrefresh();
void PlayLoading();
void StopLoading();
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size);
void on_timer(wxTimerEvent &event);
void OnEnterWindow(wxMouseEvent &evt);
void OnLeaveWindow(wxMouseEvent &evt);
void OnClick(wxMouseEvent &evt);
void post_event(wxCommandEvent &&event);
void paintEvent(wxPaintEvent &evt);
void Update(std::string ams_id, Caninfo info);
void msw_rescale();
void set_disable_mode(bool disable) { m_disable_mode = disable; }
Caninfo m_info;
protected:
wxTimer *m_playing_timer= {nullptr};
int m_rotation_angle = 0;
bool m_play_loading = {false};
bool m_selected = {false};
std::string m_ams_id;
std::string m_can_id;
ScalableBitmap m_bitmap_normal;
ScalableBitmap m_bitmap_selected;
ScalableBitmap m_bitmap_ams_rfid_0;
ScalableBitmap m_bitmap_ams_rfid_1;
ScalableBitmap m_bitmap_ams_rfid_2;
ScalableBitmap m_bitmap_ams_rfid_3;
ScalableBitmap m_bitmap_ams_rfid_4;
ScalableBitmap m_bitmap_ams_rfid_5;
ScalableBitmap m_bitmap_ams_rfid_6;
ScalableBitmap m_bitmap_ams_rfid_7;
std::vector<ScalableBitmap> m_rfid_bitmap_list;
wxString m_refresh_id;
wxBoxSizer * m_size_body;
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
bool m_disable_mode{ false };
};
/*************************************************
Description:AMSextruder
**************************************************/
class AMSextruderImage: public wxWindow
{
public:
void TurnOn(wxColour col);
void TurnOff();
void msw_rescale();
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
bool m_turn_on = {false};
wxColour m_colour;
ScalableBitmap m_ams_extruder;
void doRender(wxDC &dc);
AMSextruderImage(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~AMSextruderImage();
};
class AMSextruder : public wxWindow
{
public:
void TurnOn(wxColour col);
void TurnOff();
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size);
void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void OnAmsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
void msw_rescale();
void has_ams(bool hams) {m_has_vams = hams; Refresh();};
void no_ams_mode(bool mode) {m_none_ams_mode = mode; Refresh();};
bool m_none_ams_mode{true};
bool m_has_vams{false};
bool m_vams_loading{false};
bool m_ams_loading{false};
wxColour m_current_colur;
wxBoxSizer * m_bitmap_sizer{nullptr};
wxPanel * m_bitmap_panel{nullptr};
AMSextruderImage *m_amsSextruder{nullptr};
ScalableBitmap monitor_ams_extruder;
AMSextruder(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~AMSextruder();
};
class AMSVirtualRoad : public wxWindow
{
public:
AMSVirtualRoad(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
~AMSVirtualRoad();
private:
bool m_has_vams{ true };
bool m_vams_loading{ false };
wxColour m_current_color;
public:
void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void SetHasVams(bool hvams) { m_has_vams = hvams; };
void create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
void msw_rescale();
};
/*************************************************
Description:AMSLib
**************************************************/
class AMSLib : public wxWindow
{
public:
AMSLib(wxWindow *parent, Caninfo info);
void create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
public:
wxColour GetLibColour();
Caninfo m_info;
MachineObject* m_obj = {nullptr};
int m_can_index = 0;
AMSModel m_ams_model;
void Update(Caninfo info, bool refresh = true);
void UnableSelected() { m_unable_selected = true; };
void EableSelected() { m_unable_selected = false; };
void OnSelected();
void UnSelected();
bool is_selected() {return m_selected;};
void post_event(wxCommandEvent &&event);
void show_kn_value(bool show) { m_show_kn = show; };
void support_cali(bool sup) { m_support_cali = sup; Refresh(); };
virtual bool Enable(bool enable = true);
void set_disable_mode(bool disable) { m_disable_mode = disable; }
void msw_rescale();
void on_pass_road(bool pass);
protected:
wxStaticBitmap *m_edit_bitmp = {nullptr};
wxStaticBitmap *m_edit_bitmp_light = {nullptr};
ScalableBitmap m_bitmap_editable;
ScalableBitmap m_bitmap_editable_light;
ScalableBitmap m_bitmap_readonly;
ScalableBitmap m_bitmap_readonly_light;
ScalableBitmap m_bitmap_transparent;
ScalableBitmap m_bitmap_extra_tray_left;
ScalableBitmap m_bitmap_extra_tray_right;
ScalableBitmap m_bitmap_extra_tray_left_hover;
ScalableBitmap m_bitmap_extra_tray_right_hover;
ScalableBitmap m_bitmap_extra_tray_left_selected;
ScalableBitmap m_bitmap_extra_tray_right_selected;
bool m_unable_selected = {false};
bool m_enable = {false};
bool m_selected = {false};
bool m_hover = {false};
bool m_show_kn = {false};
bool m_support_cali = {false};
bool transparent_changed = {false};
double m_radius = {4};
wxColour m_border_color;
wxColour m_road_def_color;
wxColour m_lib_color;
bool m_disable_mode{ false };
bool m_pass_road{false};
void on_enter_window(wxMouseEvent &evt);
void on_leave_window(wxMouseEvent &evt);
void on_left_down(wxMouseEvent &evt);
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void render_extra_text(wxDC& dc);
void render_generic_text(wxDC& dc);
void doRender(wxDC& dc);
void render_extra_lib(wxDC& dc);
void render_generic_lib(wxDC& dc);
};
/*************************************************
Description:AMSRoad
**************************************************/
class AMSRoad : public wxWindow
{
public:
AMSRoad();
AMSRoad(wxWindow *parent, wxWindowID id, Caninfo info, int canindex, int maxcan, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
void create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
public:
AMSinfo m_amsinfo;
Caninfo m_info;
int m_canindex = {0};
AMSRoadMode m_rode_mode = {AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT};
std::vector<AMSPassRoadMode> m_pass_rode_mode = {AMSPassRoadMode::AMS_ROAD_MODE_NONE};
bool m_selected = {false};
int m_passroad_width = {6};
double m_radius = {4};
wxColour m_road_def_color;
wxColour m_road_color;
void Update(AMSinfo amsinfo, Caninfo info, int canindex, int maxcan);
std::vector<ScalableBitmap> ams_humidity_img;
int m_humidity = { 0 };
bool m_show_humidity = { false };
bool m_vams_loading{false};
AMSModel m_ams_model;
void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void SetPassRoadColour(wxColour col);
void SetMode(AMSRoadMode mode);
void OnPassRoad(std::vector<AMSPassRoadMode> prord_list);
void UpdatePassRoad(int tag_index, AMSPassRoadType type, AMSPassRoadSTEP step);
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void doRender(wxDC &dc);
};
/*************************************************
Description:AMSItem
**************************************************/
class AMSItem : public wxWindow
{
public:
AMSItem();
AMSItem(wxWindow *parent, wxWindowID id, AMSinfo amsinfo, const wxSize cube_size = wxSize(14, 14), const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
bool m_open = {false};
void Open();
void Close();
void Update(AMSinfo amsinfo);
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size);
void OnEnterWindow(wxMouseEvent &evt);
void OnLeaveWindow(wxMouseEvent &evt);
void OnSelected();
void UnSelected();
virtual bool Enable(bool enable = true);
AMSinfo m_amsinfo;
protected:
wxSize m_cube_size;
wxColour m_background_colour = {AMS_CONTROL_DEF_BLOCK_BK_COLOUR};
int m_padding = {7};
int m_space = {5};
bool m_hover = {false};
bool m_selected = {false};
ScalableBitmap* m_ts_bitmap_cube;
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void doRender(wxDC &dc);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
};
/*************************************************
Description:AmsCans
**************************************************/
class Canrefreshs
{
public:
wxString canID;
AMSrefresh *canrefresh;
};
class CanLibs
{
public:
wxString canID;
AMSLib * canLib;
};
class CanRoads
{
public:
wxString canID;
AMSRoad *canRoad;
};
WX_DEFINE_ARRAY(Canrefreshs *, CanrefreshsHash);
WX_DEFINE_ARRAY(CanLibs *, CanLibsHash);
WX_DEFINE_ARRAY(CanRoads *, CansRoadsHash);
class AmsCans : public wxWindow
{
public:
AmsCans();
AmsCans(wxWindow *parent, AMSinfo info, AMSModel model);
void Update(AMSinfo info);
void create(wxWindow *parent);
void AddCan(Caninfo caninfo, int canindex, int maxcan, wxBoxSizer* sizer);
void SetDefSelectCan();
void SelectCan(std::string canid);
void PlayRridLoading(wxString canid);
void StopRridLoading(wxString canid);
void msw_rescale();
void show_sn_value(bool show);
void SetAmsStepExtra(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step);
void SetAmsStep(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step);
void SetAmsStep(std::string can_id);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
wxColour GetTagColr(wxString canid);
std::string GetCurrentCan();
public:
ScalableBitmap m_bitmap_extra_framework;
int m_canlib_selection = { -1 };
int m_selection = { 0 };
int m_can_count = { 0 };
AMSModel m_ams_model;
std::string m_canlib_id;
std::string m_road_canid;
wxColour m_road_colour;
CanLibsHash m_can_lib_list;
CansRoadsHash m_can_road_list;
CanrefreshsHash m_can_refresh_list;
AMSinfo m_info;
wxBoxSizer * sizer_can = {nullptr};
wxBoxSizer * sizer_can_middle = {nullptr};
wxBoxSizer * sizer_can_left = {nullptr};
wxBoxSizer * sizer_can_right = {nullptr};
AMSPassRoadSTEP m_step = {AMSPassRoadSTEP ::AMS_ROAD_STEP_NONE};
};
/*************************************************
Description:AMSControl
**************************************************/
class AmsCansWindow
{
public:
wxString amsIndex;
AmsCans *amsCans;
bool m_disable_mode{ false };
void set_disable_mode(bool disable) {
m_disable_mode = disable;
for (auto can_lib : amsCans->m_can_lib_list) {
can_lib->canLib->set_disable_mode(disable);
}
for (auto can_refresh : amsCans->m_can_refresh_list) {
can_refresh->canrefresh->set_disable_mode(disable);
}
}
};
class AmsItems
{
public:
wxString amsIndex;
AMSItem *amsItem;
};
class AMSextruders
{
public:
wxString amsIndex;
AMSextruder *amsextruder;
};
WX_DEFINE_ARRAY(AmsCansWindow *, AmsCansHash);
WX_DEFINE_ARRAY(AmsItems *, AmsItemsHash);
WX_DEFINE_ARRAY(AMSextruders *, AMSextrudersHash);
//Previous definitions
class uiAmsPercentHumidityDryPopup;
class AMSControl : public wxSimplebook
{
@@ -566,25 +32,24 @@ protected:
std::string m_current_ams;
std::string m_current_show_ams;
std::map<std::string, int> m_ams_selection;
AmsItemsHash m_ams_item_list;
std::map<std::string, AMSPreview*> m_ams_preview_list;
std::vector<AMSinfo> m_ams_info;
AmsCansHash m_ams_cans_list;
AmsCansHash m_ams_generic_cans_list;
AmsCansHash m_ams_extra_cans_list;
std::map<std::string, AmsItem*> m_ams_item_list;
std::map<std::string, AmsItem*> m_ams_generic_item_list;
std::map<std::string, AmsItem*> m_ams_extra_item_list;
AMSextruder *m_extruder = {nullptr};
AMSextruder *m_extruder{nullptr};
AmsIntroducePopup m_ams_introduce_popup;
wxSimplebook *m_simplebook_right = {nullptr};
wxSimplebook *m_simplebook_calibration = {nullptr};
wxSimplebook *m_simplebook_amsitems = {nullptr};
wxSimplebook *m_simplebook_amsprvs = {nullptr};
wxSimplebook *m_simplebook_ams = {nullptr};
wxSimplebook *m_simplebook_generic_cans= {nullptr};
wxSimplebook *m_simplebook_extra_cans = {nullptr};
wxSimplebook* m_simplebook_generic_ams = {nullptr};
wxSimplebook* m_simplebook_extra_ams = {nullptr};
wxSimplebook *m_simplebook_bottom = {nullptr};
@@ -592,7 +57,7 @@ protected:
Label *m_tip_load_info = {nullptr};
wxStaticText *m_text_calibration_percent = {nullptr};
wxWindow * m_none_ams_panel = {nullptr};
wxWindow * m_panel_top = {nullptr};
wxWindow* m_panel_prv = {nullptr};
wxWindow * m_amswin = {nullptr};
wxBoxSizer* m_vams_sizer = {nullptr};
wxBoxSizer* m_sizer_vams_tips = {nullptr};
@@ -607,7 +72,7 @@ protected:
AMSVirtualRoad* m_vams_extra_road = {nullptr};
StaticBox * m_panel_can = {nullptr};
wxBoxSizer *m_sizer_top = {nullptr};
wxBoxSizer* m_sizer_prv = {nullptr};
wxBoxSizer *m_sizer_cans = {nullptr};
wxBoxSizer *m_sizer_right_tip = {nullptr};
wxBoxSizer* m_sizer_ams_tips = {nullptr};
@@ -631,6 +96,7 @@ protected:
wxHyperlinkCtrl *m_hyperlink = {nullptr};
AmsHumidityTipPopup m_Humidity_tip_popup;
uiAmsPercentHumidityDryPopup* m_percent_humidity_dry_popup;
std::string m_last_ams_id;
std::string m_last_tray_id;
@@ -641,11 +107,12 @@ public:
std::string GetCurrentCan(std::string amsid);
wxColour GetCanColour(std::string amsid, std::string canid);
AMSModel m_ams_model{AMSModel::NO_AMS};
AMSModel m_ext_model{AMSModel::NO_AMS};
AMSModel m_is_none_ams_mode{AMSModel::NO_AMS};
AMSModel m_ams_model{AMSModel::EXT_AMS};
AMSModel m_ext_model{AMSModel::EXT_AMS};
AMSModel m_is_none_ams_mode{AMSModel::EXT_AMS};
void SetAmsModel(AMSModel mode, AMSModel ext_mode) {m_ams_model = mode; m_ext_model = ext_mode;};
void AmsSelectedSwitch(wxCommandEvent& event);
void SetActionState(bool button_status[]);
void EnterNoneAMSMode();
@@ -666,9 +133,11 @@ public:
void UpdateStepCtrl(bool is_extrusion_exist);
void CreateAms();
void CreateAmsSingleNozzle();
void ClearAms();
void UpdateAms(std::vector<AMSinfo> info, bool is_reset = true);
void AddAms(AMSinfo info);
void AddAmsItems(AMSinfo info);
void AddAmsPreview(AMSinfo info);
void AddExtraAms(AMSinfo info);
void SetExtruder(bool on_off, bool is_vams, std::string ams_now, wxColour col);
void SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadType type, AMSPassRoadSTEP step);
@@ -696,26 +165,9 @@ public:
virtual bool Enable(bool enable = true);
public:
std::string m_current_senect;
std::string m_current_select;
};
wxDECLARE_EVENT(EVT_AMS_EXTRUSION_CALI, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_LOAD, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_UNLOAD, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_SETTINGS, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_FILAMENT_BACKUP, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_REFRESH_RFID, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_ON_SELECTED, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_ON_FILAMENT_EDIT, wxCommandEvent);
wxDECLARE_EVENT(EVT_VAMS_ON_FILAMENT_EDIT, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_CLIBRATION_AGAIN, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_CLIBRATION_CANCEL, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_GUIDE_WIKI, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_RETRY, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_SHOW_HUMIDITY_TIPS, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_UNSELETED_VAMS, wxCommandEvent);
wxDECLARE_EVENT(EVT_CLEAR_SPEED_CONTROL, wxCommandEvent);
}} // namespace Slic3r::GUI
#endif // !slic3r_GUI_amscontrol_hpp_
File diff suppressed because it is too large Load Diff
+633
View File
@@ -0,0 +1,633 @@
#ifndef slic3r_GUI_AMSITEM_hpp_
#define slic3r_GUI_AMSITEM_hpp_
#include "../wxExtensions.hpp"
#include "StaticBox.hpp"
#include "StepCtrl.hpp"
#include "Button.hpp"
#include "../DeviceManager.hpp"
#include "slic3r/GUI/Event.hpp"
#include "slic3r/GUI/AmsMappingPopup.hpp"
#include <wx/simplebook.h>
#include <wx/hyperlink.h>
#include <wx/animate.h>
#include <wx/dynarray.h>
#define AMS_CONTROL_BRAND_COLOUR wxColour(0, 150, 136)
#define AMS_CONTROL_GRAY700 wxColour(107, 107, 107)
#define AMS_CONTROL_GRAY800 wxColour(50, 58, 61)
#define AMS_CONTROL_GRAY500 wxColour(172, 172, 172)
#define AMS_CONTROL_DISABLE_COLOUR wxColour(206, 206, 206)
#define AMS_CONTROL_DISABLE_TEXT_COLOUR wxColour(144, 144, 144)
#define AMS_CONTROL_WHITE_COLOUR wxColour(255, 255, 255)
#define AMS_CONTROL_BLACK_COLOUR wxColour(0, 0, 0)
#define AMS_CONTROL_DEF_BLOCK_BK_COLOUR wxColour(238, 238, 238)
#define AMS_CONTROL_DEF_LIB_BK_COLOUR wxColour(248, 248, 248)
#define AMS_EXTRUDER_DEF_COLOUR wxColour(234, 234, 234)
#define AMS_CONTROL_MAX_COUNT 4
#define AMS_CONTRO_CALIBRATION_BUTTON_SIZE wxSize(FromDIP(150), FromDIP(28))
namespace Slic3r { namespace GUI {
enum AMSModel {
EXT_AMS = 0, //ext
GENERIC_AMS = 1,
AMS_LITE = 2, //ams-lite
N3F_AMS = 3,
N3S_AMS = 4 //n3s single_ams
};
enum ActionButton {
ACTION_BTN_CALI = 0,
ACTION_BTN_LOAD = 1,
ACTION_BTN_UNLOAD = 2,
ACTION_BTN_COUNT = 3
};
enum class AMSRoadMode : int {
AMS_ROAD_MODE_LEFT,
AMS_ROAD_MODE_LEFT_RIGHT,
AMS_ROAD_MODE_END,
AMS_ROAD_MODE_END_ONLY,
AMS_ROAD_MODE_NONE,
AMS_ROAD_MODE_NONE_ANY_ROAD,
AMS_ROAD_MODE_VIRTUAL_TRAY
};
enum class AMSPassRoadMode : int {
AMS_ROAD_MODE_NONE,
AMS_ROAD_MODE_LEFT,
AMS_ROAD_MODE_LEFT_RIGHT,
AMS_ROAD_MODE_END_TOP,
AMS_ROAD_MODE_END_RIGHT,
AMS_ROAD_MODE_END_BOTTOM,
};
enum class AMSAction : int {
AMS_ACTION_NONE,
AMS_ACTION_LOAD,
AMS_ACTION_UNLOAD,
AMS_ACTION_CALI,
AMS_ACTION_PRINTING,
AMS_ACTION_NORMAL,
AMS_ACTION_NOAMS,
};
enum class AMSPassRoadSTEP : int {
AMS_ROAD_STEP_NONE,
AMS_ROAD_STEP_1, // lib -> extrusion
AMS_ROAD_STEP_2, // extrusion->buffer
AMS_ROAD_STEP_3, // extrusion
AMS_ROAD_STEP_COMBO_LOAD_STEP1,
AMS_ROAD_STEP_COMBO_LOAD_STEP2,
AMS_ROAD_STEP_COMBO_LOAD_STEP3,
};
enum class AMSPassRoadType : int {
AMS_ROAD_TYPE_NONE,
AMS_ROAD_TYPE_LOAD,
AMS_ROAD_TYPE_UNLOAD,
};
enum class AMSCanType : int {
AMS_CAN_TYPE_NONE,
AMS_CAN_TYPE_BRAND,
AMS_CAN_TYPE_THIRDBRAND,
AMS_CAN_TYPE_EMPTY,
AMS_CAN_TYPE_VIRTUAL,
};
enum FilamentStep {
STEP_IDLE,
STEP_HEAT_NOZZLE,
STEP_CUT_FILAMENT,
STEP_PULL_CURR_FILAMENT,
STEP_PUSH_NEW_FILAMENT,
STEP_PURGE_OLD_FILAMENT,
STEP_FEED_FILAMENT,
STEP_CONFIRM_EXTRUDED,
STEP_CHECK_POSITION,
STEP_COUNT,
};
enum FilamentStepType {
STEP_TYPE_LOAD = 0,
STEP_TYPE_UNLOAD = 1,
STEP_TYPE_VT_LOAD = 2,
};
#define AMS_ITEM_CUBE_SIZE wxSize(FromDIP(14), FromDIP(14))
#define AMS_ITEM_SIZE wxSize(FromDIP(82), FromDIP(27))
#define AMS_ITEM_HUMIDITY_SIZE wxSize(FromDIP(120), FromDIP(27))
#define AMS_CAN_LIB_SIZE wxSize(FromDIP(58), FromDIP(80))
#define AMS_CAN_ROAD_SIZE wxSize(FromDIP(66), FromDIP(70))
#define AMS_CAN_ITEM_HEIGHT_SIZE FromDIP(27)
//#define AMS_CANS_SIZE wxSize(FromDIP(284), FromDIP(196))
//#define AMS_CANS_WINDOW_SIZE wxSize(FromDIP(264), FromDIP(196))
#define AMS_STEP_SIZE wxSize(FromDIP(172), FromDIP(196))
#define AMS_REFRESH_SIZE wxSize(FromDIP(30), FromDIP(30))
#define AMS_EXTRUDER_SIZE wxSize(FromDIP(86), FromDIP(72))
#define AMS_EXTRUDER_BITMAP_SIZE wxSize(FromDIP(36), FromDIP(55))
#define AMS_HUMIDITY_SIZE wxSize(FromDIP(93), FromDIP(26))
#define AMS_HUMIDITY_NO_PERCENT_SIZE wxSize(FromDIP(60), FromDIP(26))
#define AMS_HUMIDITY_DRY_WIDTH FromDIP(35)
#define GENERIC_AMS_SLOT_NUM 4
struct Caninfo
{
std::string can_id;
wxString material_name;
wxColour material_colour = {*wxWHITE};
AMSCanType material_state;
int ctype=0;
int material_remain = 100;
float k = 0.0f;
float n = 0.0f;
std::vector<wxColour> material_cols;
public:
bool operator==(const Caninfo& other) const
{
if (can_id == other.can_id &&
material_name == other.material_name &&
material_colour == other.material_colour &&
material_state == other.material_state &&
ctype == other.ctype &&
material_remain == other.material_remain &&
k == other.k &&
n == other.n &&
material_cols == other.material_cols)
{
return true;
}
return false;
};
};
struct AMSinfo
{
public:
std::string ams_id;
std::vector<Caninfo> cans;
std::string current_can_id;
AMSPassRoadSTEP current_step;
AMSAction current_action;
int curreent_filamentstep;
int ams_humidity = 0;
int humidity_raw = -1;
int left_dray_time = 0;
float current_temperature = INVALID_AMS_TEMPERATURE;
AMSModel ams_type = AMSModel::GENERIC_AMS;
public:
bool operator== (const AMSinfo& other) const
{
if (ams_id == other.ams_id &&
cans == other.cans &&
current_can_id == other.current_can_id &&
current_step == other.current_step &&
current_action == other.current_action &&
curreent_filamentstep == other.curreent_filamentstep &&
ams_humidity == other.ams_humidity &&
left_dray_time == other.left_dray_time &&
current_temperature == other.current_temperature &&
ams_type == other.ams_type)
{
return true;
}
return false;
};
bool operator!=(const AMSinfo &other) const
{
if (operator==(other))
{
return false;
}
return true;
};
bool parse_ams_info(MachineObject* obj, Ams *ams, bool remain_flag = false, bool humidity_flag = false);
bool support_drying() const { return (ams_type == AMSModel::N3S_AMS) || (ams_type == AMSModel::N3F_AMS); };
};
/*************************************************
Description:AMSrefresh
**************************************************/
#define AMS_REFRESH_PLAY_LOADING_TIMER 100
class AMSrefresh : public wxWindow
{
public:
AMSrefresh();
AMSrefresh(wxWindow *parent, wxString number, Caninfo info, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
AMSrefresh(wxWindow *parent, int number, Caninfo info, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~AMSrefresh();
public:
void Update(std::string ams_id, Caninfo info);
std::string GetCanId() const { return m_info.can_id; };
void PlayLoading();
void StopLoading();
void msw_rescale();
protected:
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size);
void on_timer(wxTimerEvent &event);
void OnEnterWindow(wxMouseEvent &evt);
void OnLeaveWindow(wxMouseEvent &evt);
void OnClick(wxMouseEvent &evt);
void post_event(wxCommandEvent &&event);
void paintEvent(wxPaintEvent &evt);
protected:
wxTimer *m_playing_timer= {nullptr};
int m_rotation_angle = 0;
bool m_play_loading = {false};
bool m_selected = {false};
std::string m_ams_id;
std::string m_can_id;
Caninfo m_info;
ScalableBitmap m_bitmap_normal;
ScalableBitmap m_bitmap_selected;
ScalableBitmap m_bitmap_ams_rfid_0;
ScalableBitmap m_bitmap_ams_rfid_1;
ScalableBitmap m_bitmap_ams_rfid_2;
ScalableBitmap m_bitmap_ams_rfid_3;
ScalableBitmap m_bitmap_ams_rfid_4;
ScalableBitmap m_bitmap_ams_rfid_5;
ScalableBitmap m_bitmap_ams_rfid_6;
ScalableBitmap m_bitmap_ams_rfid_7;
std::vector<ScalableBitmap> m_rfid_bitmap_list;
wxString m_refresh_id;
wxBoxSizer * m_size_body;
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
bool m_disable_mode{ false };
};
/*************************************************
Description:AMSextruder
**************************************************/
class AMSextruderImage: public wxWindow
{
public:
void TurnOn(wxColour col);
void TurnOff();
void msw_rescale();
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
bool m_turn_on = {false};
wxColour m_colour;
ScalableBitmap m_ams_extruder;
void doRender(wxDC &dc);
AMSextruderImage(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~AMSextruderImage();
};
class AMSextruder : public wxWindow
{
public:
void TurnOn(wxColour col);
void TurnOff();
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size);
void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void OnAmsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
void msw_rescale();
void has_ams(bool hams) {m_has_vams = hams; Refresh();};
void no_ams_mode(bool mode) {m_none_ams_mode = mode; Refresh();};
bool m_none_ams_mode{true};
bool m_has_vams{false};
bool m_vams_loading{false};
bool m_ams_loading{false};
wxColour m_current_colur;
wxBoxSizer * m_bitmap_sizer{nullptr};
wxPanel * m_bitmap_panel{nullptr};
AMSextruderImage *m_amsSextruder{nullptr};
ScalableBitmap monitor_ams_extruder;
AMSextruder(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
~AMSextruder();
};
class AMSVirtualRoad : public wxWindow
{
public:
AMSVirtualRoad(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
~AMSVirtualRoad();
private:
bool m_has_vams{ true };
bool m_vams_loading{ false };
wxColour m_current_color;
public:
void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void SetHasVams(bool hvams) { m_has_vams = hvams; };
void create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
void msw_rescale();
};
/*************************************************
Description:AMSLib
**************************************************/
class AMSLib : public wxWindow
{
public:
AMSLib(wxWindow *parent, std::string ams_idx, Caninfo info);
~AMSLib();
void create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
public:
wxColour GetLibColour();
Caninfo m_info;
MachineObject* m_obj = { nullptr };
std::string m_ams_id;
std::string m_slot_id;
int m_can_index = 0;
AMSModel m_ams_model;
void Update(Caninfo info, std::string ams_idx, bool refresh = true);
void UnableSelected() { m_unable_selected = true; };
void EableSelected() { m_unable_selected = false; };
void OnSelected();
void UnSelected();
bool is_selected() {return m_selected;};
void post_event(wxCommandEvent &&event);
void show_kn_value(bool show) { m_show_kn = show; };
void support_cali(bool sup) { m_support_cali = sup; Refresh(); };
virtual bool Enable(bool enable = true);
void set_disable_mode(bool disable) { m_disable_mode = disable; }
void msw_rescale();
void on_pass_road(bool pass);
protected:
wxStaticBitmap *m_edit_bitmp = {nullptr};
wxStaticBitmap *m_edit_bitmp_light = {nullptr};
ScalableBitmap m_bitmap_editable;
ScalableBitmap m_bitmap_editable_light;
ScalableBitmap m_bitmap_readonly;
ScalableBitmap m_bitmap_readonly_light;
ScalableBitmap m_bitmap_transparent;
ScalableBitmap m_bitmap_extra_tray_left;
ScalableBitmap m_bitmap_extra_tray_right;
ScalableBitmap m_bitmap_extra_tray_left_hover;
ScalableBitmap m_bitmap_extra_tray_right_hover;
ScalableBitmap m_bitmap_extra_tray_left_selected;
ScalableBitmap m_bitmap_extra_tray_right_selected;
bool m_unable_selected = {false};
bool m_enable = {false};
bool m_selected = {false};
bool m_hover = {false};
bool m_show_kn = {false};
bool m_support_cali = {false};
bool transparent_changed = {false};
double m_radius = {4};
wxColour m_border_color;
wxColour m_road_def_color;
wxColour m_lib_color;
bool m_disable_mode{ false };
bool m_pass_road{false};
void on_enter_window(wxMouseEvent &evt);
void on_leave_window(wxMouseEvent &evt);
void on_left_down(wxMouseEvent &evt);
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void render_lite_text(wxDC& dc);
void render_generic_text(wxDC& dc);
void doRender(wxDC& dc);
void render_lite_lib(wxDC& dc);
void render_generic_lib(wxDC& dc);
};
/*************************************************
Description:AMSRoad
**************************************************/
class AMSRoad : public wxWindow
{
public:
AMSRoad();
AMSRoad(wxWindow *parent, wxWindowID id, Caninfo info, int canindex, int maxcan, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
void create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
public:
AMSinfo m_amsinfo;
Caninfo m_info;
int m_canindex = {0};
AMSRoadMode m_rode_mode = {AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT};
std::vector<AMSPassRoadMode> m_pass_rode_mode = {AMSPassRoadMode::AMS_ROAD_MODE_NONE};
bool m_selected = {false};
int m_passroad_width = {6};
double m_radius = {4};
wxColour m_road_def_color;
wxColour m_road_color;
void Update(AMSinfo amsinfo, Caninfo info, int canindex, int maxcan);
bool m_vams_loading{false};
AMSModel m_ams_model;
void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500);
void SetPassRoadColour(wxColour col);
void SetMode(AMSRoadMode mode);
void OnPassRoad(std::vector<AMSPassRoadMode> prord_list);
void UpdatePassRoad(int tag_index, AMSPassRoadType type, AMSPassRoadSTEP step);
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void doRender(wxDC& dc);
};
/*************************************************
Description:AMSPreview
**************************************************/
class AMSPreview : public wxWindow
{
public:
AMSPreview();
AMSPreview(wxWindow *parent, wxWindowID id, AMSinfo amsinfo, const wxSize cube_size = wxSize(14, 14), const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize);
bool m_open = {false};
void Open();
void Close();
void Update(AMSinfo amsinfo);
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size);
void OnEnterWindow(wxMouseEvent &evt);
void OnLeaveWindow(wxMouseEvent &evt);
void OnSelected();
void UnSelected();
virtual bool Enable(bool enable = true);
std::string get_ams_id() const { return m_amsinfo.ams_id; };
protected:
AMSinfo m_amsinfo;
wxSize m_cube_size;
wxColour m_background_colour = {AMS_CONTROL_DEF_LIB_BK_COLOUR};
int m_padding = {7};
int m_space = {5};
bool m_hover = {false};
bool m_selected = {false};
ScalableBitmap* m_ts_bitmap_cube;
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void doRender(wxDC &dc);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
};
/*************************************************
Description:AMSHumidity
**************************************************/
class AMSHumidity : public wxWindow
{
public:
AMSHumidity();
AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
void create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
public:
AMSinfo m_amsinfo;
void Update(AMSinfo amsinfo);
std::vector<ScalableBitmap> ams_humidity_imgs;
std::vector<ScalableBitmap> ams_humidity_dark_imgs;
std::vector<ScalableBitmap> ams_humidity_no_num_imgs;
std::vector<ScalableBitmap> ams_humidity_no_num_dark_imgs;
ScalableBitmap ams_sun_img;
ScalableBitmap ams_drying_img;
int m_humidity = { 0 };
bool m_show_humidity = { false };
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
void msw_rescale();
private:
void update_size();
};
/*************************************************
Description:AmsItem
**************************************************/
class AmsItem : public wxWindow
{
public:
AmsItem();
AmsItem(wxWindow *parent, AMSinfo info, AMSModel model);
void Update(AMSinfo info);
void create(wxWindow *parent);
void AddCan(Caninfo caninfo, int canindex, int maxcan, wxBoxSizer* sizer);
void SetDefSelectCan();
void SelectCan(std::string canid);
void PlayRridLoading(wxString canid);
void StopRridLoading(wxString canid);
void msw_rescale();
void show_sn_value(bool show);
void SetAmsStepExtra(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step);
void SetAmsStep(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step);
void SetAmsStep(std::string can_id);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
void doRender(wxDC& dc);
void RenderLiteRoad(wxDC& dc, wxSize size);
wxColour GetTagColr(wxString canid);
std::string GetCurrentCan();
public:
AMSinfo get_ams_info() const { return m_info; };
std::string get_ams_id() const { return m_info.ams_id; };
std::map<std::string, AMSLib*> get_can_lib_list() const { return m_can_lib_list; };
int get_selection() const { return m_selection; };
void set_selection(int selection) { m_selection = selection; };
private:
ScalableBitmap m_bitmap_extra_framework;
int m_canlib_selection = { -1 };
int m_selection = { 0 };
int m_can_count = { 0 };
AMSModel m_ams_model;
std::string m_canlib_id;
std::string m_road_canid;
wxColour m_road_colour;
std::map<std::string, AMSLib*> m_can_lib_list;
std::map<std::string, AMSRoad*> m_can_road_list;
std::map<std::string, AMSrefresh*> m_can_refresh_list;
AMSHumidity* m_humidity = { nullptr };
AMSinfo m_info;
wxBoxSizer * sizer_can = {nullptr};
wxBoxSizer * sizer_item = { nullptr };
wxBoxSizer * sizer_can_middle = {nullptr};
wxBoxSizer * sizer_can_left = {nullptr};
wxBoxSizer * sizer_can_right = {nullptr};
AMSPassRoadSTEP m_step = {AMSPassRoadSTEP ::AMS_ROAD_STEP_NONE};
};
wxDECLARE_EVENT(EVT_AMS_EXTRUSION_CALI, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_LOAD, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_UNLOAD, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_SETTINGS, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_FILAMENT_BACKUP, SimpleEvent);
wxDECLARE_EVENT(EVT_AMS_REFRESH_RFID, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_ON_SELECTED, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_ON_FILAMENT_EDIT, wxCommandEvent);
wxDECLARE_EVENT(EVT_VAMS_ON_FILAMENT_EDIT, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_CLIBRATION_AGAIN, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_CLIBRATION_CANCEL, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_GUIDE_WIKI, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_RETRY, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_SHOW_HUMIDITY_TIPS, wxCommandEvent);
wxDECLARE_EVENT(EVT_AMS_UNSELETED_VAMS, wxCommandEvent);
wxDECLARE_EVENT(EVT_CLEAR_SPEED_CONTROL, wxCommandEvent);
}} // namespace Slic3r::GUI
#endif // !slic3r_GUI_amscontrol_hpp_
+3 -3
View File
@@ -254,10 +254,10 @@ wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &m
return dc.GetMultiLineTextExtent(multiline_text);
}
Label::Label(wxWindow *parent, wxString const &text, long style) : Label(parent, Body_14, text, style) {}
Label::Label(wxWindow *parent, wxString const &text, long style, wxSize size) : Label(parent, Body_14, text, style, size) {}
Label::Label(wxWindow *parent, wxFont const &font, wxString const &text, long style)
: wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, style)
Label::Label(wxWindow *parent, wxFont const &font, wxString const &text, long style, wxSize size)
: wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, size, style)
{
this->m_font = font;
this->m_text = text;
+2 -2
View File
@@ -11,9 +11,9 @@
class Label : public wxStaticText
{
public:
Label(wxWindow *parent, wxString const &text = {}, long style = 0);
Label(wxWindow *parent, wxString const &text = {}, long style = 0, wxSize size = wxDefaultSize);
Label(wxWindow *parent, wxFont const &font, wxString const &text = {}, long style = 0);
Label(wxWindow *parent, wxFont const &font, wxString const &text = {}, long style = 0, wxSize size = wxDefaultSize);
void SetLabel(const wxString& label) override;
+1 -1
View File
@@ -97,8 +97,8 @@ void wxMediaCtrl2::Load(wxURI url)
BambuPlayer * player = (BambuPlayer *) m_player;
if (player) {
[player close];
[player open: url.BuildURI().ToUTF8()];
m_error = 0;
m_error = [player open: url.BuildURI().ToUTF8()];
}
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
event.SetId(GetId());
+21 -46
View File
@@ -35,6 +35,16 @@ static std::string MachineBedTypeString[7] = {
};
wxString get_nozzle_volume_type_name(NozzleVolumeType type)
{
if (NozzleVolumeType::nvtNormal == type) {
return _L("Normal");
} else if (NozzleVolumeType::nvtBigTraffic == type) {
return _L("BigTraffic");
}
return wxString();
}
std::string get_calib_mode_name(CalibMode cali_mode, int stage)
{
switch(cali_mode) {
@@ -88,18 +98,14 @@ static bool is_same_nozzle_diameters(const DynamicPrintConfig &full_config, cons
try {
std::string nozzle_type;
const ConfigOptionEnum<NozzleType> * config_nozzle_type = full_config.option<ConfigOptionEnum<NozzleType>>("nozzle_type");
if (config_nozzle_type->value == NozzleType::ntHardenedSteel) {
nozzle_type = "hardened_steel";
} else if (config_nozzle_type->value == NozzleType::ntStainlessSteel) {
nozzle_type = "stainless_steel";
}
nozzle_type = NozzleTypeEumnToStr[config_nozzle_type->value];
auto opt_nozzle_diameters = full_config.option<ConfigOptionFloats>("nozzle_diameter");
if (opt_nozzle_diameters != nullptr) {
float preset_nozzle_diameter = opt_nozzle_diameters->get_at(0);
if (preset_nozzle_diameter != obj->nozzle_diameter) {
if (preset_nozzle_diameter != obj->m_extder_data.extders[0].current_nozzle_diameter) {
wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %s %s"), wxString::Format("%.1f", preset_nozzle_diameter).ToStdString(), to_wstring_name(nozzle_type));
wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj->nozzle_diameter, to_wstring_name(obj->nozzle_type));
wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj->m_extder_data.extders[0].current_nozzle_diameter, to_wstring_name(NozzleTypeEumnToStr[obj->m_extder_data.extders[0].current_nozzle_type]));
error_msg = _L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?") + "\n " + nozzle_in_preset +
"\n " + nozzle_in_printer + "\n";
@@ -117,21 +123,15 @@ static bool is_same_nozzle_type(const DynamicPrintConfig &full_config, const Mac
if (obj == nullptr)
return true;
NozzleType nozzle_type = NozzleType::ntUndefine;
if (obj->nozzle_type == "stainless_steel") {
nozzle_type = NozzleType::ntStainlessSteel;
} else if (obj->nozzle_type == "hardened_steel") {
nozzle_type = NozzleType::ntHardenedSteel;
}
NozzleType nozzle_type = obj->m_extder_data.extders[0].current_nozzle_type;
int printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(nozzle_type);
if (full_config.has("required_nozzle_HRC")) {
int filament_nozzle_hrc = full_config.opt_int("required_nozzle_HRC", 0);
if (abs(filament_nozzle_hrc) > abs(printer_nozzle_hrc)) {
BOOST_LOG_TRIVIAL(info) << "filaments hardness mismatch: printer_nozzle_hrc = " << printer_nozzle_hrc << ", filament_nozzle_hrc = " << filament_nozzle_hrc;
std::string filament_type = full_config.opt_string("filament_type", 0);
error_msg = wxString::Format(_L("*Printing %s material with %s may cause nozzle damage"), filament_type, to_wstring_name(obj->nozzle_type));
error_msg = wxString::Format(_L("*Printing %s material with %s may cause nozzle damage"), filament_type, to_wstring_name(NozzleTypeEumnToStr[obj->m_extder_data.extders[0].current_nozzle_type]));
error_msg += "\n";
MessageDialog msg_dlg(nullptr, error_msg, wxEmptyString, wxICON_WARNING | wxOK | wxCANCEL);
@@ -164,7 +164,7 @@ static bool check_nozzle_diameter_and_type(const DynamicPrintConfig &full_config
}
// P1P/S
if (obj->nozzle_type.empty())
if (obj->m_extder_data.extders[0].current_nozzle_type == NozzleType::ntUndefine)
return true;
if (!is_same_nozzle_diameters(full_config, obj, error_msg))
@@ -373,7 +373,7 @@ bool CalibUtils::get_PA_calib_results(std::vector<PACalibResult>& pa_calib_resul
return pa_calib_results.size() > 0;
}
void CalibUtils::emit_get_PA_calib_infos(float nozzle_diameter)
void CalibUtils::emit_get_PA_calib_infos(const PACalibExtruderInfo &cali_info)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
@@ -383,7 +383,7 @@ void CalibUtils::emit_get_PA_calib_infos(float nozzle_diameter)
if (obj_ == nullptr)
return;
obj_->command_get_pa_calibration_tab(nozzle_diameter);
obj_->command_get_pa_calibration_tab(cali_info);
}
bool CalibUtils::get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos)
@@ -402,31 +402,6 @@ bool CalibUtils::get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos)
return obj_->has_get_pa_calib_tab;
}
void CalibUtils::emit_get_PA_calib_info(float nozzle_diameter, const std::string &filament_id)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) return;
obj_->command_get_pa_calibration_tab(nozzle_diameter, filament_id);
}
bool CalibUtils::get_PA_calib_info(PACalibResult & pa_calib_info) {
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return false;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) return false;
if (!obj_->pa_calib_tab.empty()) {
pa_calib_info = obj_->pa_calib_tab.front();
return true;
}
return false;
}
void CalibUtils::set_PA_calib_result(const std::vector<PACalibResult> &pa_calib_values, bool is_auto_cali)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
@@ -1258,8 +1233,8 @@ void CalibUtils::send_to_print(const CalibInfo &calib_info, wxString &error_mess
print_job->m_project_name = get_calib_mode_name(cali_mode, flow_ratio_mode);
print_job->set_calibration_task(true);
print_job->has_sdcard = obj_->has_sdcard();
print_job->set_print_config(MachineBedTypeString[bed_type], true, false, false, false, true);
print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
print_job->set_print_config(MachineBedTypeString[bed_type], true, false, false, false, true, 0, 0, 0);
print_job->set_print_job_finished_event(wxGetApp().plater()->get_send_calibration_finished_event(), print_job->m_project_name);
{ // after send: record the print job
+7 -6
View File
@@ -16,6 +16,9 @@ extern const float MAX_PA_K_VALUE;
class CalibInfo
{
public:
int extruder_id = 0;
int ams_id = 0;
int slot_id = 0;
Calib_Params params;
Preset* printer_prest;
Preset* filament_prest;
@@ -35,15 +38,12 @@ public:
static CalibMode get_calib_mode_by_name(const std::string name, int &cali_stage);
static void calib_PA(const X1CCalibInfos& calib_infos, int mode, wxString& error_message);
static void emit_get_PA_calib_results(float nozzle_diameter);
static bool get_PA_calib_results(std::vector<PACalibResult> &pa_calib_results);
static void emit_get_PA_calib_infos(float nozzle_diameter);
static bool get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos);
static void emit_get_PA_calib_info(float nozzle_diameter, const std::string &filament_id);
static bool get_PA_calib_info(PACalibResult &pa_calib_info);
static void emit_get_PA_calib_infos(const PACalibExtruderInfo &cali_info);
static bool get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos);
static void set_PA_calib_result(const std::vector<PACalibResult>& pa_calib_values, bool is_auto_cali);
static void select_PA_calib_result(const PACalibIndexInfo &pa_calib_info);
@@ -75,5 +75,6 @@ private:
static void send_to_print(const CalibInfo &calib_info, wxString& error_message, int flow_ratio_mode = 0); // 0: none 1: coarse 2: fine
};
extern wxString get_nozzle_volume_type_name(NozzleVolumeType type);
}
}
+7 -1
View File
@@ -666,7 +666,7 @@ Http& Http::form_add_file(const std::string &name, const fs::path &path, const s
}
#ifdef WIN32
// Tells libcurl to ignore certificate revocation checks in case of missing or offline distribution points for those SSL backends where such behavior is present.
// Tells libcurl to ignore certificate revocation checks in case of missing or offline distribution points for those SSL backends where such behavior is present.
// This option is only supported for Schannel (the native Windows SSL library).
Http& Http::ssl_revoke_best_effort(bool set)
{
@@ -804,6 +804,12 @@ void Http::set_extra_headers(std::map<std::string, std::string> headers)
extra_headers.swap(headers);
}
std::map<std::string, std::string> Http::get_extra_headers()
{
std::lock_guard<std::mutex> l(g_mutex);
return extra_headers;
}
bool Http::ca_file_supported()
{
::CURL *curl = ::curl_easy_init();
+1
View File
@@ -90,6 +90,7 @@ public:
//BBS set global header for each http request
static void set_extra_headers(std::map<std::string, std::string> headers);
static std::map<std::string, std::string> get_extra_headers();
~Http();
+111 -38
View File
@@ -26,6 +26,15 @@ static void* netwoking_module = NULL;
static void* source_module = NULL;
#endif
bool NetworkAgent::use_legacy_network = true;
typedef int (*func_start_print_legacy)(void *agent, PrintParams_Legacy params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
typedef int (*func_start_local_print_with_record_legacy)(void *agent, PrintParams_Legacy params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
typedef int (*func_start_send_gcode_to_sdcard_legacy)(void *agent, PrintParams_Legacy params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
typedef int (*func_start_local_print_legacy)(void *agent, PrintParams_Legacy params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
typedef int (*func_start_sdcard_print_legacy)(void* agent, PrintParams_Legacy params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
typedef int (*func_send_message_legacy)(void* agent, std::string dev_id, std::string json_str, int qos);
typedef int (*func_send_message_to_printer_legacy)(void* agent, std::string dev_id, std::string json_str, int qos);
func_check_debug_consistent NetworkAgent::check_debug_consistent_ptr = nullptr;
func_get_version NetworkAgent::get_version_ptr = nullptr;
@@ -62,6 +71,8 @@ func_send_message NetworkAgent::send_message_ptr = nullptr;
func_connect_printer NetworkAgent::connect_printer_ptr = nullptr;
func_disconnect_printer NetworkAgent::disconnect_printer_ptr = nullptr;
func_send_message_to_printer NetworkAgent::send_message_to_printer_ptr = nullptr;
func_check_cert NetworkAgent::check_cert_ptr = nullptr;
func_install_device_cert NetworkAgent::install_device_cert_ptr = nullptr;
func_start_discovery NetworkAgent::start_discovery_ptr = nullptr;
func_change_user NetworkAgent::change_user_ptr = nullptr;
func_is_user_login NetworkAgent::is_user_login_ptr = nullptr;
@@ -73,7 +84,6 @@ func_get_user_nickanme NetworkAgent::get_user_nickanme_ptr = nullpt
func_build_login_cmd NetworkAgent::build_login_cmd_ptr = nullptr;
func_build_logout_cmd NetworkAgent::build_logout_cmd_ptr = nullptr;
func_build_login_info NetworkAgent::build_login_info_ptr = nullptr;
func_get_model_id_from_desgin_id NetworkAgent::get_model_id_from_desgin_id_ptr = nullptr;
func_ping_bind NetworkAgent::ping_bind_ptr = nullptr;
func_bind_detect NetworkAgent::bind_detect_ptr = nullptr;
func_set_server_callback NetworkAgent::set_server_callback_ptr = nullptr;
@@ -110,7 +120,6 @@ func_modify_printer_name NetworkAgent::modify_printer_name_ptr = null
func_get_camera_url NetworkAgent::get_camera_url_ptr = nullptr;
func_get_design_staffpick NetworkAgent::get_design_staffpick_ptr = nullptr;
func_start_pubilsh NetworkAgent::start_publish_ptr = nullptr;
func_get_profile_3mf NetworkAgent::get_profile_3mf_ptr = nullptr;
func_get_model_publish_url NetworkAgent::get_model_publish_url_ptr = nullptr;
func_get_model_mall_home_url NetworkAgent::get_model_mall_home_url_ptr = nullptr;
func_get_model_mall_detail_url NetworkAgent::get_model_mall_detail_url_ptr = nullptr;
@@ -130,6 +139,47 @@ func_get_model_mall_rating_result NetworkAgent::get_model_mall_rating_result_p
func_get_mw_user_preference NetworkAgent::get_mw_user_preference_ptr = nullptr;
func_get_mw_user_4ulist NetworkAgent::get_mw_user_4ulist_ptr = nullptr;
static PrintParams_Legacy as_legacy(PrintParams& param)
{
PrintParams_Legacy l;
l.dev_id = std::move(param.dev_id);
l.task_name = std::move(param.task_name);
l.project_name = std::move(param.project_name);
l.preset_name = std::move(param.preset_name);
l.filename = std::move(param.filename);
l.config_filename = std::move(param.config_filename);
l.plate_index = param.plate_index;
l.ftp_folder = std::move(param.ftp_folder);
l.ftp_file = std::move(param.ftp_file);
l.ftp_file_md5 = std::move(param.ftp_file_md5);
l.ams_mapping = std::move(param.ams_mapping);
l.ams_mapping_info = std::move(param.ams_mapping_info);
l.connection_type = std::move(param.connection_type);
l.comments = std::move(param.comments);
l.origin_profile_id = param.origin_profile_id;
l.stl_design_id = param.stl_design_id;
l.origin_model_id = std::move(param.origin_model_id);
l.print_type = std::move(param.print_type);
l.dst_file = std::move(param.dst_file);
l.dev_name = std::move(param.dev_name);
l.dev_ip = std::move(param.dev_ip);
l.use_ssl_for_ftp = param.use_ssl_for_ftp;
l.use_ssl_for_mqtt = param.use_ssl_for_mqtt;
l.username = std::move(param.username);
l.password = std::move(param.password);
l.task_bed_leveling = param.task_bed_leveling;
l.task_flow_cali = param.task_flow_cali;
l.task_vibration_cali = param.task_vibration_cali;
l.task_layer_inspect = param.task_layer_inspect;
l.task_record_timelapse = param.task_record_timelapse;
l.task_use_ams = param.task_use_ams;
l.task_bed_type = std::move(param.task_bed_type);
l.extra_options = std::move(param.extra_options);
return l;
}
NetworkAgent::NetworkAgent(std::string log_dir)
{
if (create_agent_ptr) {
@@ -161,7 +211,7 @@ std::string NetworkAgent::get_libpath_in_current_directory(std::string library_n
std::string file_name_string(size_needed, 0);
::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), file_name_string.data(), size_needed, nullptr, nullptr);
std::size_t found = file_name_string.find("bambu-studio.exe");
std::size_t found = file_name_string.find("orca-slicer.exe");
if (found == (file_name_string.size() - 16)) {
lib_path = library_name + ".dll";
lib_path = file_name_string.replace(found, 16, lib_path);
@@ -274,6 +324,8 @@ int NetworkAgent::initialize_network_module(bool using_backup)
connect_printer_ptr = reinterpret_cast<func_connect_printer>(get_network_function("bambu_network_connect_printer"));
disconnect_printer_ptr = reinterpret_cast<func_disconnect_printer>(get_network_function("bambu_network_disconnect_printer"));
send_message_to_printer_ptr = reinterpret_cast<func_send_message_to_printer>(get_network_function("bambu_network_send_message_to_printer"));
check_cert_ptr = reinterpret_cast<func_check_cert>(get_network_function("bambu_network_update_cert"));
install_device_cert_ptr = reinterpret_cast<func_install_device_cert>(get_network_function("bambu_network_install_device_cert"));
start_discovery_ptr = reinterpret_cast<func_start_discovery>(get_network_function("bambu_network_start_discovery"));
change_user_ptr = reinterpret_cast<func_change_user>(get_network_function("bambu_network_change_user"));
is_user_login_ptr = reinterpret_cast<func_is_user_login>(get_network_function("bambu_network_is_user_login"));
@@ -288,7 +340,6 @@ int NetworkAgent::initialize_network_module(bool using_backup)
ping_bind_ptr = reinterpret_cast<func_ping_bind>(get_network_function("bambu_network_ping_bind"));
bind_detect_ptr = reinterpret_cast<func_bind_detect>(get_network_function("bambu_network_bind_detect"));
set_server_callback_ptr = reinterpret_cast<func_set_server_callback>(get_network_function("bambu_network_set_server_callback"));
get_model_id_from_desgin_id_ptr = reinterpret_cast<func_get_model_id_from_desgin_id>(get_network_function("bambu_network_get_model_id_from_desgin_id"));
bind_ptr = reinterpret_cast<func_bind>(get_network_function("bambu_network_bind"));
unbind_ptr = reinterpret_cast<func_unbind>(get_network_function("bambu_network_unbind"));
get_bambulab_host_ptr = reinterpret_cast<func_get_bambulab_host>(get_network_function("bambu_network_get_bambulab_host"));
@@ -322,7 +373,6 @@ int NetworkAgent::initialize_network_module(bool using_backup)
get_camera_url_ptr = reinterpret_cast<func_get_camera_url>(get_network_function("bambu_network_get_camera_url"));
get_design_staffpick_ptr = reinterpret_cast<func_get_design_staffpick>(get_network_function("bambu_network_get_design_staffpick"));
start_publish_ptr = reinterpret_cast<func_start_pubilsh>(get_network_function("bambu_network_start_publish"));
get_profile_3mf_ptr = reinterpret_cast<func_get_profile_3mf>(get_network_function("bambu_network_get_profile_3mf"));
get_model_publish_url_ptr = reinterpret_cast<func_get_model_publish_url>(get_network_function("bambu_network_get_model_publish_url"));
get_subtask_ptr = reinterpret_cast<func_get_subtask>(get_network_function("bambu_network_get_subtask"));
get_model_mall_home_url_ptr = reinterpret_cast<func_get_model_mall_home_url>(get_network_function("bambu_network_get_model_mall_home_url"));
@@ -398,6 +448,7 @@ int NetworkAgent::unload_network_module()
connect_printer_ptr = nullptr;
disconnect_printer_ptr = nullptr;
send_message_to_printer_ptr = nullptr;
check_cert_ptr = nullptr;
start_discovery_ptr = nullptr;
change_user_ptr = nullptr;
is_user_login_ptr = nullptr;
@@ -409,7 +460,6 @@ int NetworkAgent::unload_network_module()
build_login_cmd_ptr = nullptr;
build_logout_cmd_ptr = nullptr;
build_login_info_ptr = nullptr;
get_model_id_from_desgin_id_ptr = nullptr;
ping_bind_ptr = nullptr;
bind_ptr = nullptr;
unbind_ptr = nullptr;
@@ -443,7 +493,6 @@ int NetworkAgent::unload_network_module()
get_camera_url_ptr = nullptr;
get_design_staffpick_ptr = nullptr;
start_publish_ptr = nullptr;
get_profile_3mf_ptr = nullptr;
get_model_publish_url_ptr = nullptr;
get_subtask_ptr = nullptr;
get_model_mall_home_url_ptr = nullptr;
@@ -853,11 +902,15 @@ int NetworkAgent::stop_device_subscribe()
return ret;
}
int NetworkAgent::send_message(std::string dev_id, std::string json_str, int qos)
int NetworkAgent::send_message(std::string dev_id, std::string json_str, int qos, int flag)
{
int ret = 0;
if (network_agent && send_message_ptr) {
ret = send_message_ptr(network_agent, dev_id, json_str, qos);
if (use_legacy_network) {
ret = (reinterpret_cast<func_send_message_legacy>(send_message_ptr))(network_agent, dev_id, json_str, qos);
} else {
ret = send_message_ptr(network_agent, dev_id, json_str, qos, flag);
}
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_id=%3%, json_str=%4%, qos=%5%")%network_agent %ret %dev_id %json_str %qos;
}
@@ -887,11 +940,15 @@ int NetworkAgent::disconnect_printer()
return ret;
}
int NetworkAgent::send_message_to_printer(std::string dev_id, std::string json_str, int qos)
int NetworkAgent::send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag)
{
int ret = 0;
if (network_agent && send_message_to_printer_ptr) {
ret = send_message_to_printer_ptr(network_agent, dev_id, json_str, qos);
if (use_legacy_network) {
ret = (reinterpret_cast<func_send_message_to_printer_legacy>(send_message_to_printer_ptr))(network_agent, dev_id, json_str, qos);
} else {
ret = send_message_to_printer_ptr(network_agent, dev_id, json_str, qos, flag);
}
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_id=%3%, json_str=%4%, qos=%5%")
%network_agent %ret %dev_id %json_str %qos;
@@ -899,6 +956,24 @@ int NetworkAgent::send_message_to_printer(std::string dev_id, std::string json_s
return ret;
}
int NetworkAgent::check_cert()
{
int ret = 0;
if (network_agent && check_cert_ptr) {
ret = check_cert_ptr(network_agent);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
}
return ret;
}
void NetworkAgent::install_device_cert(std::string dev_id, bool lan_only)
{
if (network_agent && install_device_cert_ptr) {
install_device_cert_ptr(network_agent, dev_id, lan_only);
}
}
bool NetworkAgent::start_discovery(bool start, bool sending)
{
bool ret = false;
@@ -1003,18 +1078,6 @@ std::string NetworkAgent::build_login_info()
return ret;
}
int NetworkAgent::get_model_id_from_desgin_id(std::string& desgin_id, std::string& model_id)
{
int ret = 0;
if (network_agent && get_model_id_from_desgin_id_ptr) {
ret = get_model_id_from_desgin_id_ptr(network_agent, desgin_id, model_id);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, pin code=%3%")
% network_agent % ret % desgin_id;
}
return ret;
}
int NetworkAgent::ping_bind(std::string ping_code)
{
int ret = 0;
@@ -1107,7 +1170,11 @@ int NetworkAgent::start_print(PrintParams params, OnUpdateStatusFn update_fn, Wa
{
int ret = 0;
if (network_agent && start_print_ptr) {
ret = start_print_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
if (use_legacy_network) {
ret = (reinterpret_cast<func_start_print_legacy>(start_print_ptr))(network_agent, as_legacy(params), update_fn, cancel_fn, wait_fn);
} else {
ret = start_print_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
%network_agent %ret %params.dev_id %params.task_name %params.project_name;
}
@@ -1118,7 +1185,11 @@ int NetworkAgent::start_local_print_with_record(PrintParams params, OnUpdateStat
{
int ret = 0;
if (network_agent && start_local_print_with_record_ptr) {
ret = start_local_print_with_record_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
if (use_legacy_network) {
ret = (reinterpret_cast<func_start_local_print_with_record_legacy>(start_local_print_with_record_ptr))(network_agent, as_legacy(params), update_fn, cancel_fn, wait_fn);
} else {
ret = start_local_print_with_record_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
%network_agent %ret %params.dev_id %params.task_name %params.project_name;
}
@@ -1129,7 +1200,11 @@ int NetworkAgent::start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusF
{
int ret = 0;
if (network_agent && start_send_gcode_to_sdcard_ptr) {
ret = start_send_gcode_to_sdcard_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
if (use_legacy_network) {
ret = (reinterpret_cast<func_start_send_gcode_to_sdcard_legacy>(start_send_gcode_to_sdcard_ptr))(network_agent, as_legacy(params), update_fn, cancel_fn, wait_fn);
} else {
ret = start_send_gcode_to_sdcard_ptr(network_agent, params, update_fn, cancel_fn, wait_fn);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
% network_agent % ret % params.dev_id % params.task_name % params.project_name;
}
@@ -1140,7 +1215,11 @@ int NetworkAgent::start_local_print(PrintParams params, OnUpdateStatusFn update_
{
int ret = 0;
if (network_agent && start_local_print_ptr) {
ret = start_local_print_ptr(network_agent, params, update_fn, cancel_fn);
if (use_legacy_network) {
ret = (reinterpret_cast<func_start_local_print_legacy>(start_local_print_ptr))(network_agent, as_legacy(params), update_fn, cancel_fn);
} else {
ret = start_local_print_ptr(network_agent, params, update_fn, cancel_fn);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
%network_agent %ret %params.dev_id %params.task_name %params.project_name;
}
@@ -1151,7 +1230,11 @@ int NetworkAgent::start_sdcard_print(PrintParams params, OnUpdateStatusFn update
{
int ret = 0;
if (network_agent && start_sdcard_print_ptr) {
ret = start_sdcard_print_ptr(network_agent, params, update_fn, cancel_fn);
if (use_legacy_network) {
ret = (reinterpret_cast<func_start_sdcard_print_legacy>(start_sdcard_print_ptr))(network_agent, as_legacy(params), update_fn, cancel_fn);
} else {
ret = start_sdcard_print_ptr(network_agent, params, update_fn, cancel_fn);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, task_name=%4%, project_name=%5%")
% network_agent % ret % params.dev_id % params.task_name % params.project_name;
}
@@ -1426,16 +1509,6 @@ int NetworkAgent::start_publish(PublishParams params, OnUpdateStatusFn update_fn
return ret;
}
int NetworkAgent::get_profile_3mf(BBLProfile* profile)
{
int ret = -1;
if (network_agent && get_profile_3mf_ptr) {
ret = get_profile_3mf_ptr(network_agent, profile);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%") % network_agent % ret;
}
return ret;
}
int NetworkAgent::get_model_publish_url(std::string* url)
{
int ret = 0;
+12 -10
View File
@@ -38,10 +38,12 @@ typedef int (*func_del_subscribe)(void *agent, std::vector<std::string> dev_list
typedef void (*func_enable_multi_machine)(void *agent, bool enable);
typedef int (*func_start_device_subscribe)(void* agent);
typedef int (*func_stop_device_subscribe)(void* agent);
typedef int (*func_send_message)(void *agent, std::string dev_id, std::string json_str, int qos);
typedef int (*func_send_message)(void *agent, std::string dev_id, std::string json_str, int qos, int flag);
typedef int (*func_connect_printer)(void *agent, std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl);
typedef int (*func_disconnect_printer)(void *agent);
typedef int (*func_send_message_to_printer)(void *agent, std::string dev_id, std::string json_str, int qos);
typedef int (*func_send_message_to_printer)(void *agent, std::string dev_id, std::string json_str, int qos, int flag);
typedef int (*func_check_cert)(void* agent);
typedef void (*func_install_device_cert)(void* agent, std::string dev_id, bool lan_only);
typedef bool (*func_start_discovery)(void *agent, bool start, bool sending);
typedef int (*func_change_user)(void *agent, std::string user_info);
typedef bool (*func_is_user_login)(void *agent);
@@ -53,7 +55,6 @@ typedef std::string (*func_get_user_nickanme)(void *agent);
typedef std::string (*func_build_login_cmd)(void *agent);
typedef std::string (*func_build_logout_cmd)(void *agent);
typedef std::string (*func_build_login_info)(void *agent);
typedef int (*func_get_model_id_from_desgin_id)(void *agent, std::string& desgin_id, std::string& model_id);
typedef int (*func_ping_bind)(void *agent, std::string ping_code);
typedef int (*func_bind_detect)(void *agent, std::string dev_ip, std::string sec_link, detectResult& detect);
typedef int (*func_set_server_callback)(void *agent, OnServerErrFn fn);
@@ -90,7 +91,6 @@ typedef int (*func_modify_printer_name)(void *agent, std::string dev_id, std::st
typedef int (*func_get_camera_url)(void *agent, std::string dev_id, std::function<void(std::string)> callback);
typedef int (*func_get_design_staffpick)(void *agent, int offset, int limit, std::function<void(std::string)> callback);
typedef int (*func_start_pubilsh)(void *agent, PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
typedef int (*func_get_profile_3mf)(void *agent, BBLProfile* profile);
typedef int (*func_get_model_publish_url)(void *agent, std::string* url);
typedef int (*func_get_subtask)(void *agent, BBLModelTask* task, OnGetSubTaskFn getsub_fn);
typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url);
@@ -112,6 +112,7 @@ typedef int (*func_get_model_mall_rating_result)(void *agent, int job_id, std::s
typedef int (*func_get_mw_user_preference)(void *agent, std::function<void(std::string)> callback);
typedef int (*func_get_mw_user_4ulist)(void *agent, int seed, int limit, std::function<void(std::string)> callback);
//the NetworkAgent class
class NetworkAgent
{
@@ -127,6 +128,7 @@ public:
#endif
static std::string get_version();
static void* get_network_function(const char* name);
static bool use_legacy_network;
NetworkAgent(std::string log_dir);
~NetworkAgent();
@@ -157,10 +159,12 @@ public:
void enable_multi_machine(bool enable);
int start_device_subscribe();
int stop_device_subscribe();
int send_message(std::string dev_id, std::string json_str, int qos);
int send_message(std::string dev_id, std::string json_str, int qos, int flag);
int connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl);
int disconnect_printer();
int send_message_to_printer(std::string dev_id, std::string json_str, int qos);
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag);
int check_cert();
void install_device_cert(std::string dev_id, bool lan_only);
bool start_discovery(bool start, bool sending);
int change_user(std::string user_info);
bool is_user_login();
@@ -172,7 +176,6 @@ public:
std::string build_login_cmd();
std::string build_logout_cmd();
std::string build_login_info();
int get_model_id_from_desgin_id(std::string& desgin_id, std::string& model_id);
int ping_bind(std::string ping_code);
int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect);
int set_server_callback(OnServerErrFn fn);
@@ -209,7 +212,6 @@ public:
int get_camera_url(std::string dev_id, std::function<void(std::string)> callback);
int get_design_staffpick(int offset, int limit, std::function<void(std::string)> callback);
int start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
int get_profile_3mf(BBLProfile* profile);
int get_model_publish_url(std::string* url);
int get_subtask(BBLModelTask* task, OnGetSubTaskFn getsub_fn);
int get_model_mall_home_url(std::string* url);
@@ -270,6 +272,8 @@ private:
static func_connect_printer connect_printer_ptr;
static func_disconnect_printer disconnect_printer_ptr;
static func_send_message_to_printer send_message_to_printer_ptr;
static func_check_cert check_cert_ptr;
static func_install_device_cert install_device_cert_ptr;
static func_start_discovery start_discovery_ptr;
static func_change_user change_user_ptr;
static func_is_user_login is_user_login_ptr;
@@ -281,7 +285,6 @@ private:
static func_build_login_cmd build_login_cmd_ptr;
static func_build_logout_cmd build_logout_cmd_ptr;
static func_build_login_info build_login_info_ptr;
static func_get_model_id_from_desgin_id get_model_id_from_desgin_id_ptr;
static func_ping_bind ping_bind_ptr;
static func_bind_detect bind_detect_ptr;
static func_set_server_callback set_server_callback_ptr;
@@ -318,7 +321,6 @@ private:
static func_get_camera_url get_camera_url_ptr;
static func_get_design_staffpick get_design_staffpick_ptr;
static func_start_pubilsh start_publish_ptr;
static func_get_profile_3mf get_profile_3mf_ptr;
static func_get_model_publish_url get_model_publish_url_ptr;
static func_get_subtask get_subtask_ptr;
static func_get_model_mall_home_url get_model_mall_home_url_ptr;
+21 -1
View File
@@ -849,7 +849,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
BOOST_LOG_TRIVIAL(info) << "non need to sync plugins for there is no plugins currently.";
return;
}
std::string curr_version = SLIC3R_VERSION;
std::string curr_version = NetworkAgent::use_legacy_network ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : BAMBU_NETWORK_AGENT_VERSION;
std::string using_version = curr_version.substr(0, 9) + "00";
std::string cached_version;
@@ -943,6 +943,16 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
}
}
#if defined(__WINDOWS__)
if (GUI::wxGetApp().is_running_on_arm64() && !NetworkAgent::use_legacy_network) {
//set to arm64 for plugins
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
current_headers["X-BBL-OS-Type"] = "windows_arm";
Slic3r::Http::set_extra_headers(current_headers);
BOOST_LOG_TRIVIAL(info) << boost::format("set X-BBL-OS-Type to windows_arm");
}
#endif
try {
std::map<std::string, Resource> resources
{
@@ -953,6 +963,16 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_plugins: %1%", e.what());
}
#if defined(__WINDOWS__)
if (GUI::wxGetApp().is_running_on_arm64() && !NetworkAgent::use_legacy_network) {
//set back
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
current_headers["X-BBL-OS-Type"] = "windows";
Slic3r::Http::set_extra_headers(current_headers);
BOOST_LOG_TRIVIAL(info) << boost::format("set X-BBL-OS-Type back to windows");
}
#endif
bool result = get_cached_plugins_version(cached_version, force_upgrade);
if (result) {
+60 -2
View File
@@ -36,6 +36,7 @@ namespace BBL {
#define BAMBU_NETWORK_ERR_PARSE_CONFIG_FAILED -23
#define BAMBU_NETWORK_ERR_NO_CORRESPONDING_BUCKET -24
#define BAMBU_NETWORK_ERR_GET_INSTANCE_ID_FAILED -25
#define BAMBU_NETWORK_SIGNED_ERROR -26
//bind error
#define BAMBU_NETWORK_ERR_BIND_CREATE_SOCKET_FAILED -1010 //failed to create socket
@@ -78,6 +79,7 @@ namespace BBL {
#define BAMBU_NETWORK_ERR_PRINT_SP_PATCH_PROJECT_FAILED -3110 //failed to patch project
#define BAMBU_NETWORK_ERR_PRINT_SP_POST_TASK_FAILED -3120 //failed to post task
#define BAMBU_NETWORK_ERR_PRINT_SP_WAIT_PRINTER_FAILED -3130 //failed to wait the ack from printer
#define BAMBU_NETOWRK_ERR_PRINT_SP_ENC_FLAG_NOT_READY -3140 //enc parse not ready
//start_local_print error
#define BAMBU_NETWORK_ERR_PRINT_LP_FILE_OVER_SIZE -4010 //the size of the uploaded file cannot exceed 1 GB
@@ -95,7 +97,8 @@ namespace BBL {
#define BAMBU_NETWORK_LIBRARY "bambu_networking"
#define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent"
#define BAMBU_NETWORK_AGENT_VERSION "01.10.01.01"
#define BAMBU_NETWORK_AGENT_VERSION_LEGACY "01.10.01.01"
#define BAMBU_NETWORK_AGENT_VERSION "02.00.02.50"
//iot preset type strings
#define IOT_PRINTER_TYPE_STRING "printer"
@@ -187,7 +190,7 @@ struct detectResult {
};
/* print job*/
struct PrintParams {
struct PrintParams_Legacy {
/* basic info */
std::string dev_id;
std::string task_name;
@@ -228,6 +231,53 @@ struct PrintParams {
std::string extra_options;
};
/* print job*/
struct PrintParams {
/* basic info */
std::string dev_id;
std::string task_name;
std::string project_name;
std::string preset_name;
std::string filename;
std::string config_filename;
int plate_index;
std::string ftp_folder;
std::string ftp_file;
std::string ftp_file_md5;
std::string ams_mapping;
std::string ams_mapping2;
std::string ams_mapping_info;
std::string nozzles_info;
std::string connection_type;
std::string comments;
int origin_profile_id = 0;
int stl_design_id = 0;
std::string origin_model_id;
std::string print_type;
std::string dst_file;
std::string dev_name;
/* access options */
std::string dev_ip;
bool use_ssl_for_ftp;
bool use_ssl_for_mqtt;
std::string username;
std::string password;
/*user options */
bool task_bed_leveling; /* bed leveling of task */
bool task_flow_cali; /* flow calibration of task */
bool task_vibration_cali; /* vibration calibration of task */
bool task_layer_inspect; /* first layer inspection of task */
bool task_record_timelapse; /* record timelapse of task */
bool task_use_ams;
std::string task_bed_type;
std::string extra_options;
int auto_bed_leveling{ 0 };
int auto_flow_cali{ 0 };
int auto_offset_cali{ 0 };
};
struct TaskQueryParams
{
std::string dev_id;
@@ -253,6 +303,14 @@ struct CertificateInformation {
std::string serial_number;
};
enum class MessageFlag : int
{
MSG_FLAG_NONE = 0,
MSG_SIGN = 1 << 0,
MSG_ENCRYPT = 1 << 1,
};
}
#endif