diff --git a/localization/i18n/list.txt b/localization/i18n/list.txt index f922c7878bf..f3792b34535 100644 --- a/localization/i18n/list.txt +++ b/localization/i18n/list.txt @@ -1,3 +1,7 @@ +src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h +src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.cpp +src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h +src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.cpp src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp diff --git a/resources/images/air_pump.svg b/resources/images/air_pump.svg new file mode 100644 index 00000000000..799588ec2e1 --- /dev/null +++ b/resources/images/air_pump.svg @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/air_pump_dark.svg b/resources/images/air_pump_dark.svg new file mode 100644 index 00000000000..2f075c21321 --- /dev/null +++ b/resources/images/air_pump_dark.svg @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/ams_drying.svg b/resources/images/ams_drying.svg new file mode 100644 index 00000000000..e6f9fb9f634 --- /dev/null +++ b/resources/images/ams_drying.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/images/ams_is_drying.svg b/resources/images/ams_is_drying.svg new file mode 100644 index 00000000000..a6c02f1a794 --- /dev/null +++ b/resources/images/ams_is_drying.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/images/cut.svg b/resources/images/cut.svg new file mode 100644 index 00000000000..f04edf7b395 --- /dev/null +++ b/resources/images/cut.svg @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/hum_level1_no_num_dark.svg b/resources/images/hum_level1_no_num_dark.svg new file mode 100644 index 00000000000..865a6c4a7f3 --- /dev/null +++ b/resources/images/hum_level1_no_num_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level1_no_num_light.svg b/resources/images/hum_level1_no_num_light.svg new file mode 100644 index 00000000000..be7c282e144 --- /dev/null +++ b/resources/images/hum_level1_no_num_light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level2_no_num_dark.svg b/resources/images/hum_level2_no_num_dark.svg new file mode 100644 index 00000000000..9b47beef091 --- /dev/null +++ b/resources/images/hum_level2_no_num_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level2_no_num_light.svg b/resources/images/hum_level2_no_num_light.svg new file mode 100644 index 00000000000..b84791da268 --- /dev/null +++ b/resources/images/hum_level2_no_num_light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level3_no_num_dark.svg b/resources/images/hum_level3_no_num_dark.svg new file mode 100644 index 00000000000..b5b08a15050 --- /dev/null +++ b/resources/images/hum_level3_no_num_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level3_no_num_light.svg b/resources/images/hum_level3_no_num_light.svg new file mode 100644 index 00000000000..e1fbd560f77 --- /dev/null +++ b/resources/images/hum_level3_no_num_light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level4_no_num_dark.svg b/resources/images/hum_level4_no_num_dark.svg new file mode 100644 index 00000000000..980ada05d86 --- /dev/null +++ b/resources/images/hum_level4_no_num_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level4_no_num_light.svg b/resources/images/hum_level4_no_num_light.svg new file mode 100644 index 00000000000..4fb5bc7c617 --- /dev/null +++ b/resources/images/hum_level4_no_num_light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level5_no_num_dark.svg b/resources/images/hum_level5_no_num_dark.svg new file mode 100644 index 00000000000..ab55eff332a --- /dev/null +++ b/resources/images/hum_level5_no_num_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/hum_level5_no_num_light.svg b/resources/images/hum_level5_no_num_light.svg new file mode 100644 index 00000000000..c96f344b07a --- /dev/null +++ b/resources/images/hum_level5_no_num_light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/input_access_code_h2d_cn.png b/resources/images/input_access_code_h2d_cn.png new file mode 100644 index 00000000000..1a29777339f Binary files /dev/null and b/resources/images/input_access_code_h2d_cn.png differ diff --git a/resources/images/input_access_code_h2d_en.png b/resources/images/input_access_code_h2d_en.png new file mode 100644 index 00000000000..a5bfc3b1546 Binary files /dev/null and b/resources/images/input_access_code_h2d_en.png differ diff --git a/resources/images/laser.svg b/resources/images/laser.svg new file mode 100644 index 00000000000..7380a6d8064 --- /dev/null +++ b/resources/images/laser.svg @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/printer_thumbnail_h2d.svg b/resources/images/printer_thumbnail_h2d.svg new file mode 100644 index 00000000000..9108233afc1 --- /dev/null +++ b/resources/images/printer_thumbnail_h2d.svg @@ -0,0 +1,531 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/printer_thumbnail_h2d_dark.svg b/resources/images/printer_thumbnail_h2d_dark.svg new file mode 100644 index 00000000000..050c20f449a --- /dev/null +++ b/resources/images/printer_thumbnail_h2d_dark.svg @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/rename_edit.svg b/resources/images/rename_edit.svg new file mode 100644 index 00000000000..03e40f40c7b --- /dev/null +++ b/resources/images/rename_edit.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/printers/C11.json b/resources/printers/C11.json index a2cbbb078a5..83c403b44a1 100644 --- a/resources/printers/C11.json +++ b/resources/printers/C11.json @@ -84,5 +84,10 @@ }, "support_user_preset":true } + }, + "01.07.50.00": { + "print": { + "support_print_all": true + } } } diff --git a/resources/printers/C12.json b/resources/printers/C12.json index 5cc12a1a66f..66f7f3a9745 100644 --- a/resources/printers/C12.json +++ b/resources/printers/C12.json @@ -76,5 +76,10 @@ }, "support_user_preset":true } + }, + "01.07.50.00": { + "print": { + "support_print_all": true + } } } diff --git a/resources/printers/O1D.json b/resources/printers/O1D.json new file mode 100644 index 00000000000..3892481cdd8 --- /dev/null +++ b/resources/printers/O1D.json @@ -0,0 +1,74 @@ +{ + "00.00.00.00": { + "display_name": "Bambu Lab H2D", + "print": { + "2D": { + "laser": { + "power": [ 10, 40 ] + } + }, + "ipcam": { + "resolution_supported": [ "1080p" ], + "virtual_camera": "enabled", + "liveview": { + "remote": "tutk" + }, + "file": { + "local": "local", + "remote": "tutk", + "model_download": "enabled" + } + }, + "nozzle_temp_range": [ 20, 350 ], + "bed_temp_range": [ 20, 120 ], + "support_motor_noise_cali": false, + "support_tunnel_mqtt": true, + "support_mqtt_alive": true, + "support_command_ams_switch": true, + "support_ssl_for_mqtt": true, + "support_cloud_print_only": false, + "support_1080dpi": true, + "support_prompt_sound": false, + "support_ams_humidity": true, + "support_auto_recovery_step_loss": true, + "support_bed_leveling": 2, + "support_update_remain": true, + "support_timelapse": true, + "support_filament_backup": true, + "support_chamber_fan": true, + "support_aux_fan": true, + "support_send_to_sd": true, + "support_print_all": true, + "support_print_without_sd": true, + "support_flow_calibration": true, + "support_auto_flow_calibration": true, + "support_build_plate_marker_detect": true, + "support_build_plate_marker_detect_type": 2, + "support_lidar_calibration": false, + "support_nozzle_offset_calibration": true, + "support_high_tempbed_calibration": true, + "support_ai_monitoring": true, + "support_first_layer_inspect": false, + "support_save_remote_print_file_to_storage": true, + "support_chamber_temp_edit": true, + "support_chamber_temp_edit_range": [ 20, 65 ], + "support_chamber_temp_switch_heating": 40, + "support_extrusion_cali": false, + "support_user_preset": false + }, + "model_id": "O1D", + "printer_modes": [ "fdm", "laser", "cut" ], + "compatible_machine": [], + "printer_type": "O1D", + "printer_thumbnail_image": "printer_thumbnail_h2d", + "printer_connect_help_image": "input_access_code_h2d", + "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_o_right", "ext_image_o_left"], + "use_ams_type": "generic", + "printer_arch": "core_xy", + "printer_series": "series_o", + "has_cali_line": true, + "printer_is_enclosed": true, + "enable_set_nozzle_info": false + } +} \ No newline at end of file diff --git a/resources/profiles/BBL.json b/resources/profiles/BBL.json index 10383cb01e5..f38e7c2a742 100644 --- a/resources/profiles/BBL.json +++ b/resources/profiles/BBL.json @@ -40,92 +40,92 @@ "sub_path": "process/fdm_process_common.json" }, { - "name": "fdm_process_bbl_common", - "sub_path": "process/fdm_process_bbl_common.json" + "name": "fdm_process_single_common", + "sub_path": "process/fdm_process_single_common.json" }, { - "name": "fdm_process_bbl_0.08", - "sub_path": "process/fdm_process_bbl_0.08.json" + "name": "fdm_process_single_0.08", + "sub_path": "process/fdm_process_single_0.08.json" }, { - "name": "fdm_process_bbl_0.10_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.10_nozzle_0.2.json" + "name": "fdm_process_single_0.10_nozzle_0.2", + "sub_path": "process/fdm_process_single_0.10_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.40_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.40_nozzle_0.8.json" + "name": "fdm_process_single_0.40_nozzle_0.8", + "sub_path": "process/fdm_process_single_0.40_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.30_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.30_nozzle_0.6.json" + "name": "fdm_process_single_0.30_nozzle_0.6", + "sub_path": "process/fdm_process_single_0.30_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.12", - "sub_path": "process/fdm_process_bbl_0.12.json" + "name": "fdm_process_single_0.12", + "sub_path": "process/fdm_process_single_0.12.json" }, { - "name": "fdm_process_bbl_0.16", - "sub_path": "process/fdm_process_bbl_0.16.json" + "name": "fdm_process_single_0.16", + "sub_path": "process/fdm_process_single_0.16.json" }, { - "name": "fdm_process_bbl_0.20", - "sub_path": "process/fdm_process_bbl_0.20.json" + "name": "fdm_process_single_0.20", + "sub_path": "process/fdm_process_single_0.20.json" }, { - "name": "fdm_process_bbl_0.24", - "sub_path": "process/fdm_process_bbl_0.24.json" + "name": "fdm_process_single_0.24", + "sub_path": "process/fdm_process_single_0.24.json" }, { - "name": "fdm_process_bbl_0.28", - "sub_path": "process/fdm_process_bbl_0.28.json" + "name": "fdm_process_single_0.28", + "sub_path": "process/fdm_process_single_0.28.json" }, { - "name": "fdm_process_bbl_0.06_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.06_nozzle_0.2.json" + "name": "fdm_process_single_0.06_nozzle_0.2", + "sub_path": "process/fdm_process_single_0.06_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.08_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.08_nozzle_0.2.json" + "name": "fdm_process_single_0.08_nozzle_0.2", + "sub_path": "process/fdm_process_single_0.08_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.12_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.12_nozzle_0.2.json" + "name": "fdm_process_single_0.12_nozzle_0.2", + "sub_path": "process/fdm_process_single_0.12_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.14_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.14_nozzle_0.2.json" + "name": "fdm_process_single_0.14_nozzle_0.2", + "sub_path": "process/fdm_process_single_0.14_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.18_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.18_nozzle_0.6.json" + "name": "fdm_process_single_0.18_nozzle_0.6", + "sub_path": "process/fdm_process_single_0.18_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.24_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.24_nozzle_0.6.json" + "name": "fdm_process_single_0.24_nozzle_0.6", + "sub_path": "process/fdm_process_single_0.24_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.36_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.36_nozzle_0.6.json" + "name": "fdm_process_single_0.36_nozzle_0.6", + "sub_path": "process/fdm_process_single_0.36_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.42_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.42_nozzle_0.6.json" + "name": "fdm_process_single_0.42_nozzle_0.6", + "sub_path": "process/fdm_process_single_0.42_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.24_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.24_nozzle_0.8.json" + "name": "fdm_process_single_0.24_nozzle_0.8", + "sub_path": "process/fdm_process_single_0.24_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.32_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.32_nozzle_0.8.json" + "name": "fdm_process_single_0.32_nozzle_0.8", + "sub_path": "process/fdm_process_single_0.32_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.48_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.48_nozzle_0.8.json" + "name": "fdm_process_single_0.48_nozzle_0.8", + "sub_path": "process/fdm_process_single_0.48_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.56_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.56_nozzle_0.8.json" + "name": "fdm_process_single_0.56_nozzle_0.8", + "sub_path": "process/fdm_process_single_0.56_nozzle_0.8.json" }, { "name": "0.08mm Extra Fine @BBL X1C", diff --git a/resources/profiles/BBL/process/0.06mm Fine @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm Fine @BBL A1 0.2 nozzle.json index a46163008e9..48e6ad9c262 100644 --- a/resources/profiles/BBL/process/0.06mm Fine @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm Fine @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm Fine @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP084", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm Fine @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm Fine @BBL A1M 0.2 nozzle.json index 829e9176753..1ca4fc711f4 100644 --- a/resources/profiles/BBL/process/0.06mm Fine @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm Fine @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm Fine @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP050", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm Fine @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm Fine @BBL P1P 0.2 nozzle.json index d05620a789c..fbbc791445f 100644 --- a/resources/profiles/BBL/process/0.06mm Fine @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm Fine @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm Fine @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP063", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm High Quality @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm High Quality @BBL A1 0.2 nozzle.json index 19c218e4e38..7af52f3efe1 100644 --- a/resources/profiles/BBL/process/0.06mm High Quality @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm High Quality @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm High Quality @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP118", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm High Quality @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm High Quality @BBL A1M 0.2 nozzle.json index 15f97d190e6..2bd36aafe7b 100644 --- a/resources/profiles/BBL/process/0.06mm High Quality @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm High Quality @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm High Quality @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP117", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm High Quality @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm High Quality @BBL P1P 0.2 nozzle.json index da1f6a89c34..a7c62f45221 100644 --- a/resources/profiles/BBL/process/0.06mm High Quality @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm High Quality @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm High Quality @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP116", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm High Quality @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm High Quality @BBL X1C 0.2 nozzle.json index 56388c0b15a..14e6f9474a5 100644 --- a/resources/profiles/BBL/process/0.06mm High Quality @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm High Quality @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm High Quality @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP115", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.06mm Standard @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.06mm Standard @BBL X1C 0.2 nozzle.json index 15ac55524b1..63826577bfe 100644 --- a/resources/profiles/BBL/process/0.06mm Standard @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.06mm Standard @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.06mm Standard @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_single_0.06_nozzle_0.2", "from": "system", "setting_id": "GP024", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1.json b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1.json index a77c85e6310..01cdcd24467 100644 --- a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1.json +++ b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Extra Fine @BBL A1", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP076", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1M.json b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1M.json index b54ff1ac714..cb8b2ee21f3 100644 --- a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1M.json +++ b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Extra Fine @BBL A1M", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP049", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL P1P.json b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL P1P.json index 080e4005ece..45b7282822c 100644 --- a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL P1P.json +++ b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Extra Fine @BBL P1P", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP018", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL X1C.json b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL X1C.json index 22ed2d79544..c7c1a7eb8d8 100644 --- a/resources/profiles/BBL/process/0.08mm Extra Fine @BBL X1C.json +++ b/resources/profiles/BBL/process/0.08mm Extra Fine @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Extra Fine @BBL X1C", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP001", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1 0.2 nozzle.json index 77459773872..6fe64c28c90 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP119", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1.json index 7d7f7be4570..1ec74ae7903 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL A1", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP102", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M 0.2 nozzle.json index 2d181eae1b3..a3e9d1d41fd 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP120", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M.json index 71e2f43b7d6..209ce23d830 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL A1M", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP101", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P 0.2 nozzle.json index 6424eae3c07..937db1fd86c 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP121", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P.json index f135573cf2b..ba9af3803e3 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL P1P", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP100", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C 0.2 nozzle.json index dc0de89bc68..cad7de9e3bb 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP122", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C.json b/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C.json index 778b1b9bef1..7ec94c385c0 100644 --- a/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C.json +++ b/resources/profiles/BBL/process/0.08mm High Quality @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm High Quality @BBL X1C", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_single_0.08", "from": "system", "setting_id": "GP099", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Optimal @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm Optimal @BBL A1 0.2 nozzle.json index 072bfd59b0e..77c8e762e11 100644 --- a/resources/profiles/BBL/process/0.08mm Optimal @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm Optimal @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Optimal @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP085", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Optimal @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm Optimal @BBL A1M 0.2 nozzle.json index 19f85778222..ed91cd49522 100644 --- a/resources/profiles/BBL/process/0.08mm Optimal @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm Optimal @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Optimal @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP051", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Optimal @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm Optimal @BBL P1P 0.2 nozzle.json index 99950575865..690daff8058 100644 --- a/resources/profiles/BBL/process/0.08mm Optimal @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm Optimal @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Optimal @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP064", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.08mm Standard @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.08mm Standard @BBL X1C 0.2 nozzle.json index 905fef5e097..b8bceee19ce 100644 --- a/resources/profiles/BBL/process/0.08mm Standard @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.08mm Standard @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.08mm Standard @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_single_0.08_nozzle_0.2", "from": "system", "setting_id": "GP025", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm High Quality @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm High Quality @BBL A1 0.2 nozzle.json index 23393e37b97..75077880312 100644 --- a/resources/profiles/BBL/process/0.10mm High Quality @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm High Quality @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm High Quality @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP114", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm High Quality @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm High Quality @BBL A1M 0.2 nozzle.json index cb96b785afe..ba7728beea7 100644 --- a/resources/profiles/BBL/process/0.10mm High Quality @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm High Quality @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm High Quality @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP113", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm High Quality @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm High Quality @BBL P1P 0.2 nozzle.json index f463a9e0601..4d15aa5af6f 100644 --- a/resources/profiles/BBL/process/0.10mm High Quality @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm High Quality @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm High Quality @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP112", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm High Quality @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm High Quality @BBL X1C 0.2 nozzle.json index b1ab2d897b2..b89a17a330c 100644 --- a/resources/profiles/BBL/process/0.10mm High Quality @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm High Quality @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm High Quality @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP111", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm Standard @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm Standard @BBL A1 0.2 nozzle.json index 56a9bfacedd..384b4f319a9 100644 --- a/resources/profiles/BBL/process/0.10mm Standard @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm Standard @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm Standard @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP083", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm Standard @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm Standard @BBL P1P 0.2 nozzle.json index 37a2a127773..9e5597170d0 100644 --- a/resources/profiles/BBL/process/0.10mm Standard @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm Standard @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm Standard @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP014", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.10mm Standard @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm Standard @BBL X1C 0.2 nozzle.json index 64f47b93a5a..19291675f5c 100644 --- a/resources/profiles/BBL/process/0.10mm Standard @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm Standard @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.10mm Standard @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_single_0.10_nozzle_0.2", "from": "system", "setting_id": "GP007", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Draft @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.12mm Draft @BBL A1 0.2 nozzle.json index 549a6d7fe59..5adf5539818 100644 --- a/resources/profiles/BBL/process/0.12mm Draft @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.12mm Draft @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Draft @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.12_nozzle_0.2", + "inherits": "fdm_process_single_0.12_nozzle_0.2", "from": "system", "setting_id": "GP086", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Draft @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.12mm Draft @BBL A1M 0.2 nozzle.json index 66a9004da7d..18427473b1e 100644 --- a/resources/profiles/BBL/process/0.12mm Draft @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.12mm Draft @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Draft @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.12_nozzle_0.2", + "inherits": "fdm_process_single_0.12_nozzle_0.2", "from": "system", "setting_id": "GP052", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Draft @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.12mm Draft @BBL P1P 0.2 nozzle.json index 675c21747d5..4ba21cba5a9 100644 --- a/resources/profiles/BBL/process/0.12mm Draft @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.12mm Draft @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Draft @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.12_nozzle_0.2", + "inherits": "fdm_process_single_0.12_nozzle_0.2", "from": "system", "setting_id": "GP065", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Fine @BBL A1.json b/resources/profiles/BBL/process/0.12mm Fine @BBL A1.json index 6cb7369ad2d..4769cf9030d 100644 --- a/resources/profiles/BBL/process/0.12mm Fine @BBL A1.json +++ b/resources/profiles/BBL/process/0.12mm Fine @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Fine @BBL A1", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP077", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Fine @BBL A1M.json b/resources/profiles/BBL/process/0.12mm Fine @BBL A1M.json index 74d30722a0c..d0894a61d3f 100644 --- a/resources/profiles/BBL/process/0.12mm Fine @BBL A1M.json +++ b/resources/profiles/BBL/process/0.12mm Fine @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Fine @BBL A1M", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP044", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Fine @BBL P1P.json b/resources/profiles/BBL/process/0.12mm Fine @BBL P1P.json index 172d506ecaf..2ba69e4d6e1 100644 --- a/resources/profiles/BBL/process/0.12mm Fine @BBL P1P.json +++ b/resources/profiles/BBL/process/0.12mm Fine @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Fine @BBL P1P", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP019", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Fine @BBL X1C.json b/resources/profiles/BBL/process/0.12mm Fine @BBL X1C.json index b51e89eb5b1..603658d686c 100644 --- a/resources/profiles/BBL/process/0.12mm Fine @BBL X1C.json +++ b/resources/profiles/BBL/process/0.12mm Fine @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Fine @BBL X1C", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP002", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm High Quality @BBL A1.json b/resources/profiles/BBL/process/0.12mm High Quality @BBL A1.json index 0a1a283141d..819c415474a 100644 --- a/resources/profiles/BBL/process/0.12mm High Quality @BBL A1.json +++ b/resources/profiles/BBL/process/0.12mm High Quality @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm High Quality @BBL A1", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP106", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm High Quality @BBL A1M.json b/resources/profiles/BBL/process/0.12mm High Quality @BBL A1M.json index dbe1743fbcc..5a4483795f6 100644 --- a/resources/profiles/BBL/process/0.12mm High Quality @BBL A1M.json +++ b/resources/profiles/BBL/process/0.12mm High Quality @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm High Quality @BBL A1M", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP105", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm High Quality @BBL P1P.json b/resources/profiles/BBL/process/0.12mm High Quality @BBL P1P.json index 1acd431c126..c6499205325 100644 --- a/resources/profiles/BBL/process/0.12mm High Quality @BBL P1P.json +++ b/resources/profiles/BBL/process/0.12mm High Quality @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm High Quality @BBL P1P", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP104", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm High Quality @BBL X1C.json b/resources/profiles/BBL/process/0.12mm High Quality @BBL X1C.json index d49e9314854..93f395c1cb6 100644 --- a/resources/profiles/BBL/process/0.12mm High Quality @BBL X1C.json +++ b/resources/profiles/BBL/process/0.12mm High Quality @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm High Quality @BBL X1C", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_single_0.12", "from": "system", "setting_id": "GP103", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.12mm Standard @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.12mm Standard @BBL X1C 0.2 nozzle.json index 703993972e0..d0f25e9a0ab 100644 --- a/resources/profiles/BBL/process/0.12mm Standard @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.12mm Standard @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.12mm Standard @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.12_nozzle_0.2", + "inherits": "fdm_process_single_0.12_nozzle_0.2", "from": "system", "setting_id": "GP026", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1 0.2 nozzle.json b/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1 0.2 nozzle.json index c1ff7b34a38..05ce32c6af1 100644 --- a/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.14mm Extra Draft @BBL A1 0.2 nozzle", - "inherits": "fdm_process_bbl_0.14_nozzle_0.2", + "inherits": "fdm_process_single_0.14_nozzle_0.2", "from": "system", "setting_id": "GP087", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1M 0.2 nozzle.json b/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1M 0.2 nozzle.json index c8b97600b7c..c60278482b2 100644 --- a/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1M 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.14mm Extra Draft @BBL A1M 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.14mm Extra Draft @BBL A1M 0.2 nozzle", - "inherits": "fdm_process_bbl_0.14_nozzle_0.2", + "inherits": "fdm_process_single_0.14_nozzle_0.2", "from": "system", "setting_id": "GP053", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.14mm Extra Draft @BBL P1P 0.2 nozzle.json b/resources/profiles/BBL/process/0.14mm Extra Draft @BBL P1P 0.2 nozzle.json index d19c428cd4a..b5ac82bf571 100644 --- a/resources/profiles/BBL/process/0.14mm Extra Draft @BBL P1P 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.14mm Extra Draft @BBL P1P 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.14mm Extra Draft @BBL P1P 0.2 nozzle", - "inherits": "fdm_process_bbl_0.14_nozzle_0.2", + "inherits": "fdm_process_single_0.14_nozzle_0.2", "from": "system", "setting_id": "GP066", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.14mm Standard @BBL X1C 0.2 nozzle.json b/resources/profiles/BBL/process/0.14mm Standard @BBL X1C 0.2 nozzle.json index be951de13bf..dcec7383643 100644 --- a/resources/profiles/BBL/process/0.14mm Standard @BBL X1C 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.14mm Standard @BBL X1C 0.2 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.14mm Standard @BBL X1C 0.2 nozzle", - "inherits": "fdm_process_bbl_0.14_nozzle_0.2", + "inherits": "fdm_process_single_0.14_nozzle_0.2", "from": "system", "setting_id": "GP027", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm High Quality @BBL A1.json b/resources/profiles/BBL/process/0.16mm High Quality @BBL A1.json index 5632bdbe262..4769751992d 100644 --- a/resources/profiles/BBL/process/0.16mm High Quality @BBL A1.json +++ b/resources/profiles/BBL/process/0.16mm High Quality @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm High Quality @BBL A1", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP110", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm High Quality @BBL A1M.json b/resources/profiles/BBL/process/0.16mm High Quality @BBL A1M.json index fe51c4740f3..97cd71e5cf6 100644 --- a/resources/profiles/BBL/process/0.16mm High Quality @BBL A1M.json +++ b/resources/profiles/BBL/process/0.16mm High Quality @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm High Quality @BBL A1M", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP109", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm High Quality @BBL P1P.json b/resources/profiles/BBL/process/0.16mm High Quality @BBL P1P.json index a3cd2eb87cf..41e8831710f 100644 --- a/resources/profiles/BBL/process/0.16mm High Quality @BBL P1P.json +++ b/resources/profiles/BBL/process/0.16mm High Quality @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm High Quality @BBL P1P", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP108", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm High Quality @BBL X1C.json b/resources/profiles/BBL/process/0.16mm High Quality @BBL X1C.json index 2e8fb3e44a2..9517c6cb273 100644 --- a/resources/profiles/BBL/process/0.16mm High Quality @BBL X1C.json +++ b/resources/profiles/BBL/process/0.16mm High Quality @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm High Quality @BBL X1C", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP107", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm Optimal @BBL A1.json b/resources/profiles/BBL/process/0.16mm Optimal @BBL A1.json index eedbf6577d5..a3d0c291e10 100644 --- a/resources/profiles/BBL/process/0.16mm Optimal @BBL A1.json +++ b/resources/profiles/BBL/process/0.16mm Optimal @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm Optimal @BBL A1", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP078", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm Optimal @BBL A1M.json b/resources/profiles/BBL/process/0.16mm Optimal @BBL A1M.json index 509404f9cd7..10778bcc73b 100644 --- a/resources/profiles/BBL/process/0.16mm Optimal @BBL A1M.json +++ b/resources/profiles/BBL/process/0.16mm Optimal @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm Optimal @BBL A1M", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP045", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm Optimal @BBL P1P.json b/resources/profiles/BBL/process/0.16mm Optimal @BBL P1P.json index 6df7fae3f2e..9c707bbbce5 100644 --- a/resources/profiles/BBL/process/0.16mm Optimal @BBL P1P.json +++ b/resources/profiles/BBL/process/0.16mm Optimal @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm Optimal @BBL P1P", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP020", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.16mm Optimal @BBL X1C.json b/resources/profiles/BBL/process/0.16mm Optimal @BBL X1C.json index 5dc996d120f..39bae7f05a2 100644 --- a/resources/profiles/BBL/process/0.16mm Optimal @BBL X1C.json +++ b/resources/profiles/BBL/process/0.16mm Optimal @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.16mm Optimal @BBL X1C", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_single_0.16", "from": "system", "setting_id": "GP003", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.18mm Fine @BBL A1 0.6 nozzle.json b/resources/profiles/BBL/process/0.18mm Fine @BBL A1 0.6 nozzle.json index f19e70c25f0..ef37b467937 100644 --- a/resources/profiles/BBL/process/0.18mm Fine @BBL A1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.18mm Fine @BBL A1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.18mm Fine @BBL A1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.18_nozzle_0.6", + "inherits": "fdm_process_single_0.18_nozzle_0.6", "from": "system", "setting_id": "GP088", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.18mm Fine @BBL A1M 0.6 nozzle.json b/resources/profiles/BBL/process/0.18mm Fine @BBL A1M 0.6 nozzle.json index 7b1612a79d2..c7ca32e2149 100644 --- a/resources/profiles/BBL/process/0.18mm Fine @BBL A1M 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.18mm Fine @BBL A1M 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.18mm Fine @BBL A1M 0.6 nozzle", - "inherits": "fdm_process_bbl_0.18_nozzle_0.6", + "inherits": "fdm_process_single_0.18_nozzle_0.6", "from": "system", "setting_id": "GP062", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.18mm Fine @BBL P1P 0.6 nozzle.json b/resources/profiles/BBL/process/0.18mm Fine @BBL P1P 0.6 nozzle.json index 53d29a785fb..0fdea76fe9b 100644 --- a/resources/profiles/BBL/process/0.18mm Fine @BBL P1P 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.18mm Fine @BBL P1P 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.18mm Fine @BBL P1P 0.6 nozzle", - "inherits": "fdm_process_bbl_0.18_nozzle_0.6", + "inherits": "fdm_process_single_0.18_nozzle_0.6", "from": "system", "setting_id": "GP072", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.18mm Standard @BBL X1C 0.6 nozzle.json b/resources/profiles/BBL/process/0.18mm Standard @BBL X1C 0.6 nozzle.json index 6395e965b00..3ebf14f69c0 100644 --- a/resources/profiles/BBL/process/0.18mm Standard @BBL X1C 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.18mm Standard @BBL X1C 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.18mm Standard @BBL X1C 0.6 nozzle", - "inherits": "fdm_process_bbl_0.18_nozzle_0.6", + "inherits": "fdm_process_single_0.18_nozzle_0.6", "from": "system", "setting_id": "GP028", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.20mm Bambu Support W @BBL X1C.json b/resources/profiles/BBL/process/0.20mm Bambu Support W @BBL X1C.json index 0a01e92daa1..c7d9745406f 100644 --- a/resources/profiles/BBL/process/0.20mm Bambu Support W @BBL X1C.json +++ b/resources/profiles/BBL/process/0.20mm Bambu Support W @BBL X1C.json @@ -4,7 +4,7 @@ "name": "0.20mm Bambu Support W @BBL X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "enable_support": "1", "support_interface_top_layers": "3", "support_top_z_distance": "0.2", diff --git a/resources/profiles/BBL/process/0.20mm Standard @BBL A1.json b/resources/profiles/BBL/process/0.20mm Standard @BBL A1.json index 91feaa67740..960717592f9 100644 --- a/resources/profiles/BBL/process/0.20mm Standard @BBL A1.json +++ b/resources/profiles/BBL/process/0.20mm Standard @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.20mm Standard @BBL A1", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "from": "system", "setting_id": "GP079", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.20mm Standard @BBL P1P.json b/resources/profiles/BBL/process/0.20mm Standard @BBL P1P.json index cea5a44b6d9..226241d6f3b 100644 --- a/resources/profiles/BBL/process/0.20mm Standard @BBL P1P.json +++ b/resources/profiles/BBL/process/0.20mm Standard @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.20mm Standard @BBL P1P", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "from": "system", "setting_id": "GP015", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.20mm Standard @BBL X1C.json b/resources/profiles/BBL/process/0.20mm Standard @BBL X1C.json index 01133f83ec9..d0df6bc4462 100644 --- a/resources/profiles/BBL/process/0.20mm Standard @BBL X1C.json +++ b/resources/profiles/BBL/process/0.20mm Standard @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.20mm Standard @BBL X1C", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "from": "system", "setting_id": "GP004", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.20mm Strength @BBL A1.json b/resources/profiles/BBL/process/0.20mm Strength @BBL A1.json index 30e9ca38ee8..063459a6fc2 100644 --- a/resources/profiles/BBL/process/0.20mm Strength @BBL A1.json +++ b/resources/profiles/BBL/process/0.20mm Strength @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.20mm Strength @BBL A1", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "from": "system", "setting_id": "GP080", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.20mm Strength @BBL P1P.json b/resources/profiles/BBL/process/0.20mm Strength @BBL P1P.json index 9edb0342ad9..bd131693f4b 100644 --- a/resources/profiles/BBL/process/0.20mm Strength @BBL P1P.json +++ b/resources/profiles/BBL/process/0.20mm Strength @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.20mm Strength @BBL P1P", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "from": "system", "setting_id": "GP021", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.20mm Strength @BBL X1C.json b/resources/profiles/BBL/process/0.20mm Strength @BBL X1C.json index 6635305debd..8700ad327e9 100644 --- a/resources/profiles/BBL/process/0.20mm Strength @BBL X1C.json +++ b/resources/profiles/BBL/process/0.20mm Strength @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.20mm Strength @BBL X1C", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "from": "system", "setting_id": "GP013", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Draft @BBL A1.json b/resources/profiles/BBL/process/0.24mm Draft @BBL A1.json index 20e452f19b0..195a3c7538e 100644 --- a/resources/profiles/BBL/process/0.24mm Draft @BBL A1.json +++ b/resources/profiles/BBL/process/0.24mm Draft @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Draft @BBL A1", - "inherits": "fdm_process_bbl_0.24", + "inherits": "fdm_process_single_0.24", "from": "system", "setting_id": "GP081", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Draft @BBL A1M.json b/resources/profiles/BBL/process/0.24mm Draft @BBL A1M.json index 4c791c46004..82a34774fba 100644 --- a/resources/profiles/BBL/process/0.24mm Draft @BBL A1M.json +++ b/resources/profiles/BBL/process/0.24mm Draft @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Draft @BBL A1M", - "inherits": "fdm_process_bbl_0.24", + "inherits": "fdm_process_single_0.24", "from": "system", "setting_id": "GP047", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Draft @BBL P1P.json b/resources/profiles/BBL/process/0.24mm Draft @BBL P1P.json index ed3bd535f96..d78362d4a69 100644 --- a/resources/profiles/BBL/process/0.24mm Draft @BBL P1P.json +++ b/resources/profiles/BBL/process/0.24mm Draft @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Draft @BBL P1P", - "inherits": "fdm_process_bbl_0.24", + "inherits": "fdm_process_single_0.24", "from": "system", "setting_id": "GP022", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Draft @BBL X1C.json b/resources/profiles/BBL/process/0.24mm Draft @BBL X1C.json index cc2806ac9fc..3c2667ba65c 100644 --- a/resources/profiles/BBL/process/0.24mm Draft @BBL X1C.json +++ b/resources/profiles/BBL/process/0.24mm Draft @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Draft @BBL X1C", - "inherits": "fdm_process_bbl_0.24", + "inherits": "fdm_process_single_0.24", "from": "system", "setting_id": "GP005", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Fine @BBL A1 0.8 nozzle.json b/resources/profiles/BBL/process/0.24mm Fine @BBL A1 0.8 nozzle.json index 629884dc7c9..0a1938f8425 100644 --- a/resources/profiles/BBL/process/0.24mm Fine @BBL A1 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Fine @BBL A1 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Fine @BBL A1 0.8 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.8", + "inherits": "fdm_process_single_0.24_nozzle_0.8", "from": "system", "setting_id": "GP092", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Fine @BBL A1M 0.8 nozzle.json b/resources/profiles/BBL/process/0.24mm Fine @BBL A1M 0.8 nozzle.json index ca2631fb714..4187b5e97d4 100644 --- a/resources/profiles/BBL/process/0.24mm Fine @BBL A1M 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Fine @BBL A1M 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Fine @BBL A1M 0.8 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.8", + "inherits": "fdm_process_single_0.24_nozzle_0.8", "from": "system", "setting_id": "GP057", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Fine @BBL P1P 0.8 nozzle.json b/resources/profiles/BBL/process/0.24mm Fine @BBL P1P 0.8 nozzle.json index 7f7934ad5af..99e6c8558e6 100644 --- a/resources/profiles/BBL/process/0.24mm Fine @BBL P1P 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Fine @BBL P1P 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Fine @BBL P1P 0.8 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.8", + "inherits": "fdm_process_single_0.24_nozzle_0.8", "from": "system", "setting_id": "GP068", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Optimal @BBL A1 0.6 nozzle.json b/resources/profiles/BBL/process/0.24mm Optimal @BBL A1 0.6 nozzle.json index f8388f6262e..ba272780863 100644 --- a/resources/profiles/BBL/process/0.24mm Optimal @BBL A1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Optimal @BBL A1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Optimal @BBL A1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.6", + "inherits": "fdm_process_single_0.24_nozzle_0.6", "from": "system", "setting_id": "GP089", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Optimal @BBL A1M 0.6 nozzle.json b/resources/profiles/BBL/process/0.24mm Optimal @BBL A1M 0.6 nozzle.json index 28082afef5a..eff76ccaeb6 100644 --- a/resources/profiles/BBL/process/0.24mm Optimal @BBL A1M 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Optimal @BBL A1M 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Optimal @BBL A1M 0.6 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.6", + "inherits": "fdm_process_single_0.24_nozzle_0.6", "from": "system", "setting_id": "GP054", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Optimal @BBL P1P 0.6 nozzle.json b/resources/profiles/BBL/process/0.24mm Optimal @BBL P1P 0.6 nozzle.json index a143d7b6357..4a31ef5a0f1 100644 --- a/resources/profiles/BBL/process/0.24mm Optimal @BBL P1P 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Optimal @BBL P1P 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Optimal @BBL P1P 0.6 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.6", + "inherits": "fdm_process_single_0.24_nozzle_0.6", "from": "system", "setting_id": "GP069", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.6 nozzle.json b/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.6 nozzle.json index 2675aaa3739..9b213430a58 100644 --- a/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Standard @BBL X1C 0.6 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.6", + "inherits": "fdm_process_single_0.24_nozzle_0.6", "from": "system", "setting_id": "GP029", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.8 nozzle.json b/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.8 nozzle.json index 9ff95902a77..33d9f252548 100644 --- a/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.24mm Standard @BBL X1C 0.8 nozzle", - "inherits": "fdm_process_bbl_0.24_nozzle_0.8", + "inherits": "fdm_process_single_0.24_nozzle_0.8", "from": "system", "setting_id": "GP032", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1.json b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1.json index 490c0026cd6..e8ec96ac253 100644 --- a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1.json +++ b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.28mm Extra Draft @BBL A1", - "inherits": "fdm_process_bbl_0.28", + "inherits": "fdm_process_single_0.28", "from": "system", "setting_id": "GP082", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1M.json b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1M.json index f1923e0d69e..a0c3058a710 100644 --- a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1M.json +++ b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL A1M.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.28mm Extra Draft @BBL A1M", - "inherits": "fdm_process_bbl_0.28", + "inherits": "fdm_process_single_0.28", "from": "system", "setting_id": "GP048", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL P1P.json b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL P1P.json index 4f9bb7b53ed..a1dbdc67e65 100644 --- a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL P1P.json +++ b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL P1P.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.28mm Extra Draft @BBL P1P", - "inherits": "fdm_process_bbl_0.28", + "inherits": "fdm_process_single_0.28", "from": "system", "setting_id": "GP023", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL X1C.json b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL X1C.json index 4d544e0f97a..0dbb703749d 100644 --- a/resources/profiles/BBL/process/0.28mm Extra Draft @BBL X1C.json +++ b/resources/profiles/BBL/process/0.28mm Extra Draft @BBL X1C.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.28mm Extra Draft @BBL X1C", - "inherits": "fdm_process_bbl_0.28", + "inherits": "fdm_process_single_0.28", "from": "system", "setting_id": "GP006", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Standard @BBL A1 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Standard @BBL A1 0.6 nozzle.json index 26ad6e58061..dce6cbfc307 100644 --- a/resources/profiles/BBL/process/0.30mm Standard @BBL A1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Standard @BBL A1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Standard @BBL A1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP096", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Standard @BBL P1P 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Standard @BBL P1P 0.6 nozzle.json index 164c03866f3..4fffef2b26f 100644 --- a/resources/profiles/BBL/process/0.30mm Standard @BBL P1P 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Standard @BBL P1P 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Standard @BBL P1P 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP016", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Standard @BBL X1 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Standard @BBL X1 0.6 nozzle.json index e501731193c..d622c05abad 100644 --- a/resources/profiles/BBL/process/0.30mm Standard @BBL X1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Standard @BBL X1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Standard @BBL X1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP011", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Standard @BBL X1C 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Standard @BBL X1C 0.6 nozzle.json index 7a629102571..55a49f3888c 100644 --- a/resources/profiles/BBL/process/0.30mm Standard @BBL X1C 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Standard @BBL X1C 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Standard @BBL X1C 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP010", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Strength @BBL A1 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Strength @BBL A1 0.6 nozzle.json index 775523f0d6d..67cf897a41d 100644 --- a/resources/profiles/BBL/process/0.30mm Strength @BBL A1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Strength @BBL A1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Strength @BBL A1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP097", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Strength @BBL A1M 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Strength @BBL A1M 0.6 nozzle.json index 044c7c24cbd..e5c6026fb5a 100644 --- a/resources/profiles/BBL/process/0.30mm Strength @BBL A1M 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Strength @BBL A1M 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Strength @BBL A1M 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP061", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Strength @BBL P1P 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Strength @BBL P1P 0.6 nozzle.json index 284206f4fac..8a711ba4a6d 100644 --- a/resources/profiles/BBL/process/0.30mm Strength @BBL P1P 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Strength @BBL P1P 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Strength @BBL P1P 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP067", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.30mm Strength @BBL X1C 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Strength @BBL X1C 0.6 nozzle.json index 7d39dcfa0c7..dc25f49cb35 100644 --- a/resources/profiles/BBL/process/0.30mm Strength @BBL X1C 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Strength @BBL X1C 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.30mm Strength @BBL X1C 0.6 nozzle", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_single_0.30_nozzle_0.6", "from": "system", "setting_id": "GP036", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.32mm Optimal @BBL A1 0.8 nozzle.json b/resources/profiles/BBL/process/0.32mm Optimal @BBL A1 0.8 nozzle.json index b1e8658fce1..799c9c96c2a 100644 --- a/resources/profiles/BBL/process/0.32mm Optimal @BBL A1 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.32mm Optimal @BBL A1 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.32mm Optimal @BBL A1 0.8 nozzle", - "inherits": "fdm_process_bbl_0.32_nozzle_0.8", + "inherits": "fdm_process_single_0.32_nozzle_0.8", "from": "system", "setting_id": "GP093", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.32mm Optimal @BBL A1M 0.8 nozzle.json b/resources/profiles/BBL/process/0.32mm Optimal @BBL A1M 0.8 nozzle.json index e3778f37093..41209c609db 100644 --- a/resources/profiles/BBL/process/0.32mm Optimal @BBL A1M 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.32mm Optimal @BBL A1M 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.32mm Optimal @BBL A1M 0.8 nozzle", - "inherits": "fdm_process_bbl_0.32_nozzle_0.8", + "inherits": "fdm_process_single_0.32_nozzle_0.8", "from": "system", "setting_id": "GP058", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.32mm Optimal @BBL P1P 0.8 nozzle.json b/resources/profiles/BBL/process/0.32mm Optimal @BBL P1P 0.8 nozzle.json index 7586ed84bfc..8447e73bc21 100644 --- a/resources/profiles/BBL/process/0.32mm Optimal @BBL P1P 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.32mm Optimal @BBL P1P 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.32mm Optimal @BBL P1P 0.8 nozzle", - "inherits": "fdm_process_bbl_0.32_nozzle_0.8", + "inherits": "fdm_process_single_0.32_nozzle_0.8", "from": "system", "setting_id": "GP075", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.32mm Standard @BBL X1C 0.8 nozzle.json b/resources/profiles/BBL/process/0.32mm Standard @BBL X1C 0.8 nozzle.json index 148b39055b5..50219578c6e 100644 --- a/resources/profiles/BBL/process/0.32mm Standard @BBL X1C 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.32mm Standard @BBL X1C 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.32mm Standard @BBL X1C 0.8 nozzle", - "inherits": "fdm_process_bbl_0.32_nozzle_0.8", + "inherits": "fdm_process_single_0.32_nozzle_0.8", "from": "system", "setting_id": "GP033", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.36mm Draft @BBL A1 0.6 nozzle.json b/resources/profiles/BBL/process/0.36mm Draft @BBL A1 0.6 nozzle.json index e5ebbcfe315..230396014fe 100644 --- a/resources/profiles/BBL/process/0.36mm Draft @BBL A1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.36mm Draft @BBL A1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.36mm Draft @BBL A1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.36_nozzle_0.6", + "inherits": "fdm_process_single_0.36_nozzle_0.6", "from": "system", "setting_id": "GP090", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.36mm Draft @BBL A1M 0.6 nozzle.json b/resources/profiles/BBL/process/0.36mm Draft @BBL A1M 0.6 nozzle.json index 0268a0ea0fa..835655d8312 100644 --- a/resources/profiles/BBL/process/0.36mm Draft @BBL A1M 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.36mm Draft @BBL A1M 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.36mm Draft @BBL A1M 0.6 nozzle", - "inherits": "fdm_process_bbl_0.36_nozzle_0.6", + "inherits": "fdm_process_single_0.36_nozzle_0.6", "from": "system", "setting_id": "GP055", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.36mm Draft @BBL P1P 0.6 nozzle.json b/resources/profiles/BBL/process/0.36mm Draft @BBL P1P 0.6 nozzle.json index 51251017b3e..41d988e684f 100644 --- a/resources/profiles/BBL/process/0.36mm Draft @BBL P1P 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.36mm Draft @BBL P1P 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.36mm Draft @BBL P1P 0.6 nozzle", - "inherits": "fdm_process_bbl_0.36_nozzle_0.6", + "inherits": "fdm_process_single_0.36_nozzle_0.6", "from": "system", "setting_id": "GP070", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.36mm Standard @BBL X1C 0.6 nozzle.json b/resources/profiles/BBL/process/0.36mm Standard @BBL X1C 0.6 nozzle.json index d09c89ecb7c..2348de67e44 100644 --- a/resources/profiles/BBL/process/0.36mm Standard @BBL X1C 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.36mm Standard @BBL X1C 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.36mm Standard @BBL X1C 0.6 nozzle", - "inherits": "fdm_process_bbl_0.36_nozzle_0.6", + "inherits": "fdm_process_single_0.36_nozzle_0.6", "from": "system", "setting_id": "GP030", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.40mm Standard @BBL A1 0.8 nozzle.json b/resources/profiles/BBL/process/0.40mm Standard @BBL A1 0.8 nozzle.json index de5ffe19c33..5fa1b108aae 100644 --- a/resources/profiles/BBL/process/0.40mm Standard @BBL A1 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.40mm Standard @BBL A1 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.40mm Standard @BBL A1 0.8 nozzle", - "inherits": "fdm_process_bbl_0.40_nozzle_0.8", + "inherits": "fdm_process_single_0.40_nozzle_0.8", "from": "system", "setting_id": "GP098", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.40mm Standard @BBL P1P 0.8 nozzle.json b/resources/profiles/BBL/process/0.40mm Standard @BBL P1P 0.8 nozzle.json index a647b300b65..57196d2671f 100644 --- a/resources/profiles/BBL/process/0.40mm Standard @BBL P1P 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.40mm Standard @BBL P1P 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.40mm Standard @BBL P1P 0.8 nozzle", - "inherits": "fdm_process_bbl_0.40_nozzle_0.8", + "inherits": "fdm_process_single_0.40_nozzle_0.8", "from": "system", "setting_id": "GP017", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.40mm Standard @BBL X1 0.8 nozzle.json b/resources/profiles/BBL/process/0.40mm Standard @BBL X1 0.8 nozzle.json index f5115f43b79..51339de5254 100644 --- a/resources/profiles/BBL/process/0.40mm Standard @BBL X1 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.40mm Standard @BBL X1 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.40mm Standard @BBL X1 0.8 nozzle", - "inherits": "fdm_process_bbl_0.40_nozzle_0.8", + "inherits": "fdm_process_single_0.40_nozzle_0.8", "from": "system", "setting_id": "GP012", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.40mm Standard @BBL X1C 0.8 nozzle.json b/resources/profiles/BBL/process/0.40mm Standard @BBL X1C 0.8 nozzle.json index 15ba67645d6..0a07b0c26e8 100644 --- a/resources/profiles/BBL/process/0.40mm Standard @BBL X1C 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.40mm Standard @BBL X1C 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.40mm Standard @BBL X1C 0.8 nozzle", - "inherits": "fdm_process_bbl_0.40_nozzle_0.8", + "inherits": "fdm_process_single_0.40_nozzle_0.8", "from": "system", "setting_id": "GP009", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1 0.6 nozzle.json b/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1 0.6 nozzle.json index d6b15c6eba8..2c968b7404f 100644 --- a/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.42mm Extra Draft @BBL A1 0.6 nozzle", - "inherits": "fdm_process_bbl_0.42_nozzle_0.6", + "inherits": "fdm_process_single_0.42_nozzle_0.6", "from": "system", "setting_id": "GP091", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1M 0.6 nozzle.json b/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1M 0.6 nozzle.json index 571ab55f0dc..e13b0b7e7ae 100644 --- a/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1M 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.42mm Extra Draft @BBL A1M 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.42mm Extra Draft @BBL A1M 0.6 nozzle", - "inherits": "fdm_process_bbl_0.42_nozzle_0.6", + "inherits": "fdm_process_single_0.42_nozzle_0.6", "from": "system", "setting_id": "GP056", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.42mm Extra Draft @BBL P1P 0.6 nozzle.json b/resources/profiles/BBL/process/0.42mm Extra Draft @BBL P1P 0.6 nozzle.json index 69578536be0..b0e9ac619ee 100644 --- a/resources/profiles/BBL/process/0.42mm Extra Draft @BBL P1P 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.42mm Extra Draft @BBL P1P 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.42mm Extra Draft @BBL P1P 0.6 nozzle", - "inherits": "fdm_process_bbl_0.42_nozzle_0.6", + "inherits": "fdm_process_single_0.42_nozzle_0.6", "from": "system", "setting_id": "GP073", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.42mm Standard @BBL X1C 0.6 nozzle.json b/resources/profiles/BBL/process/0.42mm Standard @BBL X1C 0.6 nozzle.json index 1005112ff6d..857a50dfbd8 100644 --- a/resources/profiles/BBL/process/0.42mm Standard @BBL X1C 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.42mm Standard @BBL X1C 0.6 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.42mm Standard @BBL X1C 0.6 nozzle", - "inherits": "fdm_process_bbl_0.42_nozzle_0.6", + "inherits": "fdm_process_single_0.42_nozzle_0.6", "from": "system", "setting_id": "GP031", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.48mm Draft @BBL A1 0.8 nozzle.json b/resources/profiles/BBL/process/0.48mm Draft @BBL A1 0.8 nozzle.json index d3e5e0c26ab..a60a7495be1 100644 --- a/resources/profiles/BBL/process/0.48mm Draft @BBL A1 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.48mm Draft @BBL A1 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.48mm Draft @BBL A1 0.8 nozzle", - "inherits": "fdm_process_bbl_0.48_nozzle_0.8", + "inherits": "fdm_process_single_0.48_nozzle_0.8", "from": "system", "setting_id": "GP094", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.48mm Draft @BBL A1M 0.8 nozzle.json b/resources/profiles/BBL/process/0.48mm Draft @BBL A1M 0.8 nozzle.json index dc3159fb7f1..7c619a104c0 100644 --- a/resources/profiles/BBL/process/0.48mm Draft @BBL A1M 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.48mm Draft @BBL A1M 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.48mm Draft @BBL A1M 0.8 nozzle", - "inherits": "fdm_process_bbl_0.48_nozzle_0.8", + "inherits": "fdm_process_single_0.48_nozzle_0.8", "from": "system", "setting_id": "GP059", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.48mm Draft @BBL P1P 0.8 nozzle.json b/resources/profiles/BBL/process/0.48mm Draft @BBL P1P 0.8 nozzle.json index 7a5062a369e..2a056071132 100644 --- a/resources/profiles/BBL/process/0.48mm Draft @BBL P1P 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.48mm Draft @BBL P1P 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.48mm Draft @BBL P1P 0.8 nozzle", - "inherits": "fdm_process_bbl_0.48_nozzle_0.8", + "inherits": "fdm_process_single_0.48_nozzle_0.8", "from": "system", "setting_id": "GP074", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.48mm Standard @BBL X1C 0.8 nozzle.json b/resources/profiles/BBL/process/0.48mm Standard @BBL X1C 0.8 nozzle.json index 40c694d8914..398f8d6f117 100644 --- a/resources/profiles/BBL/process/0.48mm Standard @BBL X1C 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.48mm Standard @BBL X1C 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.48mm Standard @BBL X1C 0.8 nozzle", - "inherits": "fdm_process_bbl_0.48_nozzle_0.8", + "inherits": "fdm_process_single_0.48_nozzle_0.8", "from": "system", "setting_id": "GP034", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1 0.8 nozzle.json b/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1 0.8 nozzle.json index 7669c35cdca..3b8778eaee6 100644 --- a/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.56mm Extra Draft @BBL A1 0.8 nozzle", - "inherits": "fdm_process_bbl_0.56_nozzle_0.8", + "inherits": "fdm_process_single_0.56_nozzle_0.8", "from": "system", "setting_id": "GP095", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1M 0.8 nozzle.json b/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1M 0.8 nozzle.json index 8090a646179..e4719a71d66 100644 --- a/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1M 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.56mm Extra Draft @BBL A1M 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.56mm Extra Draft @BBL A1M 0.8 nozzle", - "inherits": "fdm_process_bbl_0.56_nozzle_0.8", + "inherits": "fdm_process_single_0.56_nozzle_0.8", "from": "system", "setting_id": "GP060", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.56mm Extra Draft @BBL P1P 0.8 nozzle.json b/resources/profiles/BBL/process/0.56mm Extra Draft @BBL P1P 0.8 nozzle.json index fcc8b66b82f..bd77cf1e45f 100644 --- a/resources/profiles/BBL/process/0.56mm Extra Draft @BBL P1P 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.56mm Extra Draft @BBL P1P 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.56mm Extra Draft @BBL P1P 0.8 nozzle", - "inherits": "fdm_process_bbl_0.56_nozzle_0.8", + "inherits": "fdm_process_single_0.56_nozzle_0.8", "from": "system", "setting_id": "GP071", "instantiation": "true", diff --git a/resources/profiles/BBL/process/0.56mm Standard @BBL X1C 0.8 nozzle.json b/resources/profiles/BBL/process/0.56mm Standard @BBL X1C 0.8 nozzle.json index 9b80a1a5dda..fa913af494f 100644 --- a/resources/profiles/BBL/process/0.56mm Standard @BBL X1C 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.56mm Standard @BBL X1C 0.8 nozzle.json @@ -1,7 +1,7 @@ { "type": "process", "name": "0.56mm Standard @BBL X1C 0.8 nozzle", - "inherits": "fdm_process_bbl_0.56_nozzle_0.8", + "inherits": "fdm_process_single_0.56_nozzle_0.8", "from": "system", "setting_id": "GP035", "instantiation": "true", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_common.json b/resources/profiles/BBL/process/fdm_process_bbl_common.json deleted file mode 100644 index d77980a29d8..00000000000 --- a/resources/profiles/BBL/process/fdm_process_bbl_common.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "type": "process", - "name": "fdm_process_bbl_common", - "inherits": "fdm_process_common", - "from": "system", - "instantiation": "false", - "max_travel_detour_distance": "0", - "bottom_surface_pattern": "monotonic", - "bottom_shell_layers": "3", - "bottom_shell_thickness": "0", - "bridge_speed": "50", - "brim_object_gap": "0.1", - "compatible_printers_condition": "", - "draft_shield": "disabled", - "elefant_foot_compensation": "0", - "enable_arc_fitting": "1", - "outer_wall_acceleration": "5000", - "wall_infill_order": "inner wall/outer wall/infill", - "line_width": "0.42", - "internal_bridge_support_thickness": "0.8", - "initial_layer_acceleration": "500", - "initial_layer_line_width": "0.5", - "initial_layer_speed": "30", - "gap_infill_speed": "50", - "sparse_infill_speed": "250", - "ironing_flow": "10%", - "ironing_spacing": "0.15", - "ironing_speed": "30", - "ironing_type": "no ironing", - "layer_height": "0.2", - "reduce_infill_retraction": "1", - "filename_format": "{input_filename_base}_{filament_type[0]}_{print_time}.gcode", - "detect_overhang_wall": "1", - "overhang_1_4_speed": "0", - "overhang_2_4_speed": "50", - "overhang_3_4_speed": "30", - "overhang_4_4_speed": "10", - "only_one_wall_top": "1", - "inner_wall_speed": "150", - "seam_position": "aligned", - "skirt_height": "1", - "skirt_loops": "0", - "minimum_sparse_infill_area": "15", - "internal_solid_infill_line_width": "0.42", - "internal_solid_infill_speed": "150", - "initial_layer_infill_speed": "60", - "resolution": "0.012", - "support_type": "normal(auto)", - "support_style": "default", - "support_top_z_distance": "0.2", - "support_bottom_z_distance": "0.2", - "support_interface_bottom_layers": "2", - "support_interface_spacing": "0.5", - "support_expansion": "0", - "support_base_pattern_spacing": "2.5", - "support_speed": "150", - "support_threshold_angle": "30", - "support_object_xy_distance": "0.35", - "tree_support_branch_diameter": "2", - "tree_support_branch_angle": "45", - "tree_support_wall_count": "0", - "max_bridge_length": "0", - "top_surface_pattern": "monotonicline", - "top_surface_acceleration": "2000", - "top_surface_speed": "200", - "top_shell_layers": "3", - "top_shell_thickness": "0.8", - "travel_speed": "500", - "enable_prime_tower": "1", - "wipe_tower_no_sparse_layers": "0", - "prime_tower_width": "35", - "wall_generator": "classic", - "compatible_printers": [] -} \ No newline at end of file diff --git a/resources/profiles/BBL/process/fdm_process_common.json b/resources/profiles/BBL/process/fdm_process_common.json index 9b99ec1b283..6a8a42a19eb 100644 --- a/resources/profiles/BBL/process/fdm_process_common.json +++ b/resources/profiles/BBL/process/fdm_process_common.json @@ -4,72 +4,104 @@ "from": "system", "instantiation": "false", "adaptive_layer_height": "0", - "reduce_crossing_wall": "0", + "bottom_shell_layers": "3", + "bottom_shell_thickness": "0", + "bottom_surface_pattern": "monotonic", "bridge_flow": "0.95", + "bridge_no_support": "0", "bridge_speed": "25", + "brim_object_gap": "0.1", "brim_width": "5", - "print_sequence": "by layer", + "compatible_printers_condition": "", "default_acceleration": "10000", - "bridge_no_support": "0", - "elefant_foot_compensation": "0.1", - "outer_wall_line_width": "0.42", - "ironing_inset": "0.21", - "outer_wall_speed": "120", - "line_width": "0.45", - "infill_direction": "45", - "sparse_infill_density": "15%", - "sparse_infill_pattern": "crosshatch", - "initial_layer_line_width": "0.42", - "initial_layer_print_height": "0.2", - "initial_layer_speed": "20", + "detect_overhang_wall": "1", + "detect_thin_wall": "0", + "draft_shield": "disabled", + "elefant_foot_compensation": "0", + "enable_arc_fitting": "1", + "enable_prime_tower": "1", + "enable_support": "0", + "filename_format": "{input_filename_base}_{filament_type[0]}_{print_time}.gcode", "gap_infill_speed": "30", "infill_combination": "0", - "sparse_infill_line_width": "0.45", + "infill_direction": "45", "infill_wall_overlap": "15%", - "sparse_infill_speed": "50", - "interface_shells": "0", - "detect_overhang_wall": "0", - "reduce_infill_retraction": "0", - "filename_format": "{input_filename_base}.gcode", - "wall_loops": "2", + "initial_layer_line_width": "0.5", + "initial_layer_print_height": "0.2", + "initial_layer_speed": "20", "inner_wall_line_width": "0.45", "inner_wall_speed": "40", + "interface_shells": "0", + "internal_bridge_support_thickness": "0.8", + "internal_solid_infill_line_width": "0.42", + "internal_solid_infill_speed": "40", + "ironing_flow": "10%", + "ironing_inset": "0.21", + "ironing_spacing": "0.15", + "ironing_speed": "30", + "ironing_type": "no ironing", + "layer_height": "0.2", + "line_width": "0.42", + "max_bridge_length": "0", + "max_travel_detour_distance": "0", + "minimum_sparse_infill_area": "15", + "only_one_wall_top": "1", + "outer_wall_line_width": "0.42", + "outer_wall_speed": "120", + "overhang_totally_speed": "19", + "prime_tower_width": "35", + "print_sequence": "by layer", "print_settings_id": "", "raft_layers": "0", - "seam_position": "nearest", + "reduce_crossing_wall": "0", + "reduce_infill_retraction": "1", + "resolution": "0.012", + "scarf_angle_threshold": "155", + "seam_position": "aligned", "skirt_distance": "2", - "skirt_height": "2", - "minimum_sparse_infill_area": "0", - "internal_solid_infill_line_width": "0.45", - "internal_solid_infill_speed": "40", + "skirt_height": "1", + "skirt_loops": "0", + "smooth_coefficient": "80", + "sparse_infill_density": "15%", + "sparse_infill_line_width": "0.45", + "sparse_infill_pattern": "crosshatch", + "sparse_infill_speed": "50", "spiral_mode": "0", "standby_temperature_delta": "-5", - "enable_support": "0", + "support_base_pattern": "default", + "support_base_pattern_spacing": "2.5", + "support_bottom_z_distance": "0.2", + "support_expansion": "0", "support_filament": "0", - "support_line_width": "0.42", + "support_interface_bottom_layers": "2", "support_interface_filament": "0", - "support_on_build_plate_only": "0", - "support_top_z_distance": "0.15", "support_interface_loop_pattern": "0", - "support_interface_top_layers": "2", - "support_interface_spacing": "0", - "support_interface_speed": "80", "support_interface_pattern": "auto", - "support_base_pattern": "default", - "support_base_pattern_spacing": "2", + "support_interface_spacing": "0.5", + "support_interface_speed": "80", + "support_interface_top_layers": "2", + "support_line_width": "0.42", + "support_object_xy_distance": "0.35", + "support_on_build_plate_only": "0", "support_speed": "40", - "support_threshold_angle": "40", - "support_object_xy_distance": "0.5", - "detect_thin_wall": "0", + "support_style": "default", + "support_threshold_angle": "30", + "support_top_z_distance": "0.2", + "support_type": "normal(auto)", + "top_shell_layers": "3", + "top_shell_thickness": "0.8", "top_surface_line_width": "0.42", + "top_surface_pattern": "monotonicline", "top_surface_speed": "30", "travel_speed": "400", - "enable_prime_tower": "0", - "prime_tower_width": "60", - "xy_hole_compensation": "0", + "tree_support_branch_angle": "45", + "tree_support_branch_diameter": "2", + "tree_support_wall_count": "0", + "wall_generator": "classic", + "wall_infill_order": "inner wall/outer wall/infill", + "wall_loops": "2", + "wipe_tower_no_sparse_layers": "0", "xy_contour_compensation": "0", - "compatible_printers": [], - "smooth_coefficient": "80", - "overhang_totally_speed": "19", - "scarf_angle_threshold": "155" + "xy_hole_compensation": "0", + "compatible_printers": [] } \ No newline at end of file diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.06_nozzle_0.2.json b/resources/profiles/BBL/process/fdm_process_single_0.06_nozzle_0.2.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.06_nozzle_0.2.json rename to resources/profiles/BBL/process/fdm_process_single_0.06_nozzle_0.2.json index 364bcaa1ee4..ea35d93d185 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.06_nozzle_0.2.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.06_nozzle_0.2.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.06_nozzle_0.2", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.06_nozzle_0.2", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.06", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.08.json b/resources/profiles/BBL/process/fdm_process_single_0.08.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.08.json rename to resources/profiles/BBL/process/fdm_process_single_0.08.json index 61897f7a738..e9b651f2826 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.08.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.08.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.08", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.08", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.08", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.08_nozzle_0.2.json b/resources/profiles/BBL/process/fdm_process_single_0.08_nozzle_0.2.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.08_nozzle_0.2.json rename to resources/profiles/BBL/process/fdm_process_single_0.08_nozzle_0.2.json index 52a1749075b..643d8667c2c 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.08_nozzle_0.2.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.08_nozzle_0.2.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.08_nozzle_0.2", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.08_nozzle_0.2", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.08", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.10_nozzle_0.2.json b/resources/profiles/BBL/process/fdm_process_single_0.10_nozzle_0.2.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.10_nozzle_0.2.json rename to resources/profiles/BBL/process/fdm_process_single_0.10_nozzle_0.2.json index 020a3f9cc87..2caa8812d2a 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.10_nozzle_0.2.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.10_nozzle_0.2.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.10_nozzle_0.2", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.10_nozzle_0.2", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.1", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.12.json b/resources/profiles/BBL/process/fdm_process_single_0.12.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.12.json rename to resources/profiles/BBL/process/fdm_process_single_0.12.json index e22593fb300..43878152786 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.12.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.12.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.12", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.12", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.12", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.12_nozzle_0.2.json b/resources/profiles/BBL/process/fdm_process_single_0.12_nozzle_0.2.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.12_nozzle_0.2.json rename to resources/profiles/BBL/process/fdm_process_single_0.12_nozzle_0.2.json index 56aedfd03ed..f2c1662d40a 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.12_nozzle_0.2.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.12_nozzle_0.2.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.12_nozzle_0.2", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.12_nozzle_0.2", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.12", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.14_nozzle_0.2.json b/resources/profiles/BBL/process/fdm_process_single_0.14_nozzle_0.2.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.14_nozzle_0.2.json rename to resources/profiles/BBL/process/fdm_process_single_0.14_nozzle_0.2.json index 7c10c6c6730..0cae00d0307 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.14_nozzle_0.2.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.14_nozzle_0.2.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.14_nozzle_0.2", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.14_nozzle_0.2", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.14", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.16.json b/resources/profiles/BBL/process/fdm_process_single_0.16.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.16.json rename to resources/profiles/BBL/process/fdm_process_single_0.16.json index 3d60b01d8bb..5bcb42994dc 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.16.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.16.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.16", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.16", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.16", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.18_nozzle_0.6.json b/resources/profiles/BBL/process/fdm_process_single_0.18_nozzle_0.6.json similarity index 89% rename from resources/profiles/BBL/process/fdm_process_bbl_0.18_nozzle_0.6.json rename to resources/profiles/BBL/process/fdm_process_single_0.18_nozzle_0.6.json index 31c88af561e..db8428fad79 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.18_nozzle_0.6.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.18_nozzle_0.6.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.18_nozzle_0.6", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.18_nozzle_0.6", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.18", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.20.json b/resources/profiles/BBL/process/fdm_process_single_0.20.json similarity index 84% rename from resources/profiles/BBL/process/fdm_process_bbl_0.20.json rename to resources/profiles/BBL/process/fdm_process_single_0.20.json index 331f77e4e70..a6809f2df2d 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.20.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.20.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.20", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.20", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "elefant_foot_compensation": "0.15", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.24.json b/resources/profiles/BBL/process/fdm_process_single_0.24.json similarity index 86% rename from resources/profiles/BBL/process/fdm_process_bbl_0.24.json rename to resources/profiles/BBL/process/fdm_process_single_0.24.json index 1a0bd76e40d..72d1f540097 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.24.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.24.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.24", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.24", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.24", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.24_nozzle_0.6.json b/resources/profiles/BBL/process/fdm_process_single_0.24_nozzle_0.6.json similarity index 87% rename from resources/profiles/BBL/process/fdm_process_bbl_0.24_nozzle_0.6.json rename to resources/profiles/BBL/process/fdm_process_single_0.24_nozzle_0.6.json index ca621513421..76d6443637d 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.24_nozzle_0.6.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.24_nozzle_0.6.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.24_nozzle_0.6", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.24_nozzle_0.6", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.24", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.24_nozzle_0.8.json b/resources/profiles/BBL/process/fdm_process_single_0.24_nozzle_0.8.json similarity index 88% rename from resources/profiles/BBL/process/fdm_process_bbl_0.24_nozzle_0.8.json rename to resources/profiles/BBL/process/fdm_process_single_0.24_nozzle_0.8.json index 88e1f680758..516aeab7254 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.24_nozzle_0.8.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.24_nozzle_0.8.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.24_nozzle_0.8", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.24_nozzle_0.8", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.24", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.28.json b/resources/profiles/BBL/process/fdm_process_single_0.28.json similarity index 86% rename from resources/profiles/BBL/process/fdm_process_bbl_0.28.json rename to resources/profiles/BBL/process/fdm_process_single_0.28.json index efd2cc4d010..ebaf9c18a17 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.28.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.28.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.28", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.28", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.28", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.30_nozzle_0.6.json b/resources/profiles/BBL/process/fdm_process_single_0.30_nozzle_0.6.json similarity index 87% rename from resources/profiles/BBL/process/fdm_process_bbl_0.30_nozzle_0.6.json rename to resources/profiles/BBL/process/fdm_process_single_0.30_nozzle_0.6.json index 08476dbb784..0fb84521137 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.30_nozzle_0.6.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.30_nozzle_0.6.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.30_nozzle_0.6", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.30_nozzle_0.6", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.3", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.32_nozzle_0.8.json b/resources/profiles/BBL/process/fdm_process_single_0.32_nozzle_0.8.json similarity index 88% rename from resources/profiles/BBL/process/fdm_process_bbl_0.32_nozzle_0.8.json rename to resources/profiles/BBL/process/fdm_process_single_0.32_nozzle_0.8.json index c1622d28f55..4c950cea9f5 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.32_nozzle_0.8.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.32_nozzle_0.8.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.32_nozzle_0.8", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.32_nozzle_0.8", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.32", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.36_nozzle_0.6.json b/resources/profiles/BBL/process/fdm_process_single_0.36_nozzle_0.6.json similarity index 87% rename from resources/profiles/BBL/process/fdm_process_bbl_0.36_nozzle_0.6.json rename to resources/profiles/BBL/process/fdm_process_single_0.36_nozzle_0.6.json index f9c917dfc58..5deb4a3d4b5 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.36_nozzle_0.6.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.36_nozzle_0.6.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.36_nozzle_0.6", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.36_nozzle_0.6", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.36", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.40_nozzle_0.8.json b/resources/profiles/BBL/process/fdm_process_single_0.40_nozzle_0.8.json similarity index 88% rename from resources/profiles/BBL/process/fdm_process_bbl_0.40_nozzle_0.8.json rename to resources/profiles/BBL/process/fdm_process_single_0.40_nozzle_0.8.json index be6eb5944a3..0b8258b96e4 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.40_nozzle_0.8.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.40_nozzle_0.8.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.40_nozzle_0.8", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.40_nozzle_0.8", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.4", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.42_nozzle_0.6.json b/resources/profiles/BBL/process/fdm_process_single_0.42_nozzle_0.6.json similarity index 87% rename from resources/profiles/BBL/process/fdm_process_bbl_0.42_nozzle_0.6.json rename to resources/profiles/BBL/process/fdm_process_single_0.42_nozzle_0.6.json index d879b17b8b0..6923ab22363 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.42_nozzle_0.6.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.42_nozzle_0.6.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.42_nozzle_0.6", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.42_nozzle_0.6", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.42", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.48_nozzle_0.8.json b/resources/profiles/BBL/process/fdm_process_single_0.48_nozzle_0.8.json similarity index 88% rename from resources/profiles/BBL/process/fdm_process_bbl_0.48_nozzle_0.8.json rename to resources/profiles/BBL/process/fdm_process_single_0.48_nozzle_0.8.json index e9955abd55e..f66069668c0 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.48_nozzle_0.8.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.48_nozzle_0.8.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.48_nozzle_0.8", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.48_nozzle_0.8", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.48", diff --git a/resources/profiles/BBL/process/fdm_process_bbl_0.56_nozzle_0.8.json b/resources/profiles/BBL/process/fdm_process_single_0.56_nozzle_0.8.json similarity index 88% rename from resources/profiles/BBL/process/fdm_process_bbl_0.56_nozzle_0.8.json rename to resources/profiles/BBL/process/fdm_process_single_0.56_nozzle_0.8.json index 99fb6bf6e7d..41e489443b7 100644 --- a/resources/profiles/BBL/process/fdm_process_bbl_0.56_nozzle_0.8.json +++ b/resources/profiles/BBL/process/fdm_process_single_0.56_nozzle_0.8.json @@ -1,7 +1,7 @@ { "type": "process", - "name": "fdm_process_bbl_0.56_nozzle_0.8", - "inherits": "fdm_process_bbl_common", + "name": "fdm_process_single_0.56_nozzle_0.8", + "inherits": "fdm_process_single_common", "from": "system", "instantiation": "false", "layer_height": "0.56", diff --git a/resources/profiles/BBL/process/fdm_process_single_common.json b/resources/profiles/BBL/process/fdm_process_single_common.json new file mode 100644 index 00000000000..9edabd17ec6 --- /dev/null +++ b/resources/profiles/BBL/process/fdm_process_single_common.json @@ -0,0 +1,25 @@ +{ + "type": "process", + "name": "fdm_process_single_common", + "inherits": "fdm_process_common", + "from": "system", + "instantiation": "false", + "bridge_speed": "50", + "gap_infill_speed": "50", + "initial_layer_acceleration": "500", + "initial_layer_infill_speed": "60", + "initial_layer_speed": "30", + "inner_wall_speed": "150", + "internal_solid_infill_speed": "150", + "outer_wall_acceleration": "5000", + "overhang_1_4_speed": "0", + "overhang_2_4_speed": "50", + "overhang_3_4_speed": "30", + "overhang_4_4_speed": "10", + "sparse_infill_speed": "250", + "support_speed": "150", + "top_surface_acceleration": "2000", + "top_surface_speed": "200", + "travel_speed": "500", + "compatible_printers": [] +} \ No newline at end of file diff --git a/resources/profiles/OrcaArena.json b/resources/profiles/OrcaArena.json index d218006bee6..6f10184faf0 100644 --- a/resources/profiles/OrcaArena.json +++ b/resources/profiles/OrcaArena.json @@ -16,44 +16,44 @@ "sub_path": "process/fdm_process_common.json" }, { - "name": "fdm_process_bbl_common", - "sub_path": "process/fdm_process_bbl_common.json" + "name": "fdm_process_arena_common", + "sub_path": "process/fdm_process_arena_common.json" }, { - "name": "fdm_process_bbl_0.08", - "sub_path": "process/fdm_process_bbl_0.08.json" + "name": "fdm_process_arena_0.08", + "sub_path": "process/fdm_process_arena_0.08.json" }, { - "name": "fdm_process_bbl_0.10_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.10_nozzle_0.2.json" + "name": "fdm_process_arena_0.10_nozzle_0.2", + "sub_path": "process/fdm_process_arena_0.10_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.40_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.40_nozzle_0.8.json" + "name": "fdm_process_arena_0.40_nozzle_0.8", + "sub_path": "process/fdm_process_arena_0.40_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.30_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.30_nozzle_0.6.json" + "name": "fdm_process_arena_0.30_nozzle_0.6", + "sub_path": "process/fdm_process_arena_0.30_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.12", - "sub_path": "process/fdm_process_bbl_0.12.json" + "name": "fdm_process_arena_0.12", + "sub_path": "process/fdm_process_arena_0.12.json" }, { - "name": "fdm_process_bbl_0.16", - "sub_path": "process/fdm_process_bbl_0.16.json" + "name": "fdm_process_arena_0.16", + "sub_path": "process/fdm_process_arena_0.16.json" }, { - "name": "fdm_process_bbl_0.20", - "sub_path": "process/fdm_process_bbl_0.20.json" + "name": "fdm_process_arena_0.20", + "sub_path": "process/fdm_process_arena_0.20.json" }, { - "name": "fdm_process_bbl_0.24", - "sub_path": "process/fdm_process_bbl_0.24.json" + "name": "fdm_process_arena_0.24", + "sub_path": "process/fdm_process_arena_0.24.json" }, { - "name": "fdm_process_bbl_0.28", - "sub_path": "process/fdm_process_bbl_0.28.json" + "name": "fdm_process_arena_0.28", + "sub_path": "process/fdm_process_arena_0.28.json" }, { "name": "0.08mm Extra Fine @Arena X1C", @@ -96,20 +96,20 @@ "sub_path": "process/0.40mm Standard @Arena X1C 0.8 nozzle.json" }, { - "name": "fdm_process_bbl_0.06_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.06_nozzle_0.2.json" + "name": "fdm_process_arena_0.06_nozzle_0.2", + "sub_path": "process/fdm_process_arena_0.06_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.08_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.08_nozzle_0.2.json" + "name": "fdm_process_arena_0.08_nozzle_0.2", + "sub_path": "process/fdm_process_arena_0.08_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.12_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.12_nozzle_0.2.json" + "name": "fdm_process_arena_0.12_nozzle_0.2", + "sub_path": "process/fdm_process_arena_0.12_nozzle_0.2.json" }, { - "name": "fdm_process_bbl_0.14_nozzle_0.2", - "sub_path": "process/fdm_process_bbl_0.14_nozzle_0.2.json" + "name": "fdm_process_arena_0.14_nozzle_0.2", + "sub_path": "process/fdm_process_arena_0.14_nozzle_0.2.json" }, { "name": "0.06mm Standard @Arena X1C 0.2 nozzle", @@ -128,20 +128,20 @@ "sub_path": "process/0.14mm Standard @Arena X1C 0.2 nozzle.json" }, { - "name": "fdm_process_bbl_0.18_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.18_nozzle_0.6.json" + "name": "fdm_process_arena_0.18_nozzle_0.6", + "sub_path": "process/fdm_process_arena_0.18_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.24_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.24_nozzle_0.6.json" + "name": "fdm_process_arena_0.24_nozzle_0.6", + "sub_path": "process/fdm_process_arena_0.24_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.36_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.36_nozzle_0.6.json" + "name": "fdm_process_arena_0.36_nozzle_0.6", + "sub_path": "process/fdm_process_arena_0.36_nozzle_0.6.json" }, { - "name": "fdm_process_bbl_0.42_nozzle_0.6", - "sub_path": "process/fdm_process_bbl_0.42_nozzle_0.6.json" + "name": "fdm_process_arena_0.42_nozzle_0.6", + "sub_path": "process/fdm_process_arena_0.42_nozzle_0.6.json" }, { "name": "0.18mm Standard @Arena X1C 0.6 nozzle", @@ -160,20 +160,20 @@ "sub_path": "process/0.42mm Standard @Arena X1C 0.6 nozzle.json" }, { - "name": "fdm_process_bbl_0.24_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.24_nozzle_0.8.json" + "name": "fdm_process_arena_0.24_nozzle_0.8", + "sub_path": "process/fdm_process_arena_0.24_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.32_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.32_nozzle_0.8.json" + "name": "fdm_process_arena_0.32_nozzle_0.8", + "sub_path": "process/fdm_process_arena_0.32_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.48_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.48_nozzle_0.8.json" + "name": "fdm_process_arena_0.48_nozzle_0.8", + "sub_path": "process/fdm_process_arena_0.48_nozzle_0.8.json" }, { - "name": "fdm_process_bbl_0.56_nozzle_0.8", - "sub_path": "process/fdm_process_bbl_0.56_nozzle_0.8.json" + "name": "fdm_process_arena_0.56_nozzle_0.8", + "sub_path": "process/fdm_process_arena_0.56_nozzle_0.8.json" }, { "name": "0.24mm Standard @Arena X1C 0.8 nozzle", diff --git a/resources/profiles/OrcaArena/process/0.06mm Standard @Arena X1C 0.2 nozzle.json b/resources/profiles/OrcaArena/process/0.06mm Standard @Arena X1C 0.2 nozzle.json index fb227626fd0..c11c22991ad 100644 --- a/resources/profiles/OrcaArena/process/0.06mm Standard @Arena X1C 0.2 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.06mm Standard @Arena X1C 0.2 nozzle.json @@ -4,7 +4,7 @@ "name": "0.06mm Standard @Arena X1C 0.2 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.06_nozzle_0.2", + "inherits": "fdm_process_arena_0.06_nozzle_0.2", "compatible_printers": [ "Orca Arena X1 Carbon 0.2 nozzle", "Orca Arena X1 0.2 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.08mm Extra Fine @Arena X1C.json b/resources/profiles/OrcaArena/process/0.08mm Extra Fine @Arena X1C.json index 3f92bb8b6fd..a21add8f871 100644 --- a/resources/profiles/OrcaArena/process/0.08mm Extra Fine @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.08mm Extra Fine @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.08mm Extra Fine @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.08", + "inherits": "fdm_process_arena_0.08", "compatible_printers": [ "Orca Arena X1 Carbon 0.4 nozzle", "Orca Arena X1 0.4 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.08mm Standard @Arena X1C 0.2 nozzle.json b/resources/profiles/OrcaArena/process/0.08mm Standard @Arena X1C 0.2 nozzle.json index b2fe7cb3bb9..99c3bae3852 100644 --- a/resources/profiles/OrcaArena/process/0.08mm Standard @Arena X1C 0.2 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.08mm Standard @Arena X1C 0.2 nozzle.json @@ -4,7 +4,7 @@ "name": "0.08mm Standard @Arena X1C 0.2 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.08_nozzle_0.2", + "inherits": "fdm_process_arena_0.08_nozzle_0.2", "compatible_printers": [ "Orca Arena X1 Carbon 0.2 nozzle", "Orca Arena X1 0.2 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.10mm Standard @Arena X1C 0.2 nozzle.json b/resources/profiles/OrcaArena/process/0.10mm Standard @Arena X1C 0.2 nozzle.json index 89a48d31bbf..c392d0ee9c6 100644 --- a/resources/profiles/OrcaArena/process/0.10mm Standard @Arena X1C 0.2 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.10mm Standard @Arena X1C 0.2 nozzle.json @@ -4,7 +4,7 @@ "name": "0.10mm Standard @Arena X1C 0.2 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.10_nozzle_0.2", + "inherits": "fdm_process_arena_0.10_nozzle_0.2", "compatible_printers": [ "Orca Arena X1 Carbon 0.2 nozzle", "Orca Arena X1 0.2 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.12mm Fine @Arena X1C.json b/resources/profiles/OrcaArena/process/0.12mm Fine @Arena X1C.json index 140f6e7331d..e5c28d36eb2 100644 --- a/resources/profiles/OrcaArena/process/0.12mm Fine @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.12mm Fine @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.12mm Fine @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.12", + "inherits": "fdm_process_arena_0.12", "compatible_printers": [ "Orca Arena X1 Carbon 0.4 nozzle", "Orca Arena X1 0.4 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.12mm Standard @Arena X1C 0.2 nozzle.json b/resources/profiles/OrcaArena/process/0.12mm Standard @Arena X1C 0.2 nozzle.json index c63dffe1a47..bc0686ffb87 100644 --- a/resources/profiles/OrcaArena/process/0.12mm Standard @Arena X1C 0.2 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.12mm Standard @Arena X1C 0.2 nozzle.json @@ -4,7 +4,7 @@ "name": "0.12mm Standard @Arena X1C 0.2 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.12_nozzle_0.2", + "inherits": "fdm_process_arena_0.12_nozzle_0.2", "compatible_printers": [ "Orca Arena X1 Carbon 0.2 nozzle", "Orca Arena X1 0.2 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.14mm Standard @Arena X1C 0.2 nozzle.json b/resources/profiles/OrcaArena/process/0.14mm Standard @Arena X1C 0.2 nozzle.json index 2d299244745..37809dbca96 100644 --- a/resources/profiles/OrcaArena/process/0.14mm Standard @Arena X1C 0.2 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.14mm Standard @Arena X1C 0.2 nozzle.json @@ -4,7 +4,7 @@ "name": "0.14mm Standard @Arena X1C 0.2 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.14_nozzle_0.2", + "inherits": "fdm_process_arena_0.14_nozzle_0.2", "compatible_printers": [ "Orca Arena X1 Carbon 0.2 nozzle", "Orca Arena X1 0.2 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.16mm Optimal @Arena X1C.json b/resources/profiles/OrcaArena/process/0.16mm Optimal @Arena X1C.json index 6c41ea8e3f1..a4eae17d26e 100644 --- a/resources/profiles/OrcaArena/process/0.16mm Optimal @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.16mm Optimal @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.16mm Optimal @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.16", + "inherits": "fdm_process_arena_0.16", "compatible_printers": [ "Orca Arena X1 Carbon 0.4 nozzle", "Orca Arena X1 0.4 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.18mm Standard @Arena X1C 0.6 nozzle.json b/resources/profiles/OrcaArena/process/0.18mm Standard @Arena X1C 0.6 nozzle.json index 23e5a273408..66371f83394 100644 --- a/resources/profiles/OrcaArena/process/0.18mm Standard @Arena X1C 0.6 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.18mm Standard @Arena X1C 0.6 nozzle.json @@ -4,7 +4,7 @@ "name": "0.18mm Standard @Arena X1C 0.6 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.18_nozzle_0.6", + "inherits": "fdm_process_arena_0.18_nozzle_0.6", "compatible_printers": [ "Orca Arena X1 Carbon 0.6 nozzle", "Orca Arena X1 0.6 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.20mm Bambu Support W @Arena X1C.json b/resources/profiles/OrcaArena/process/0.20mm Bambu Support W @Arena X1C.json index b31526453e0..ed49f5d0e96 100644 --- a/resources/profiles/OrcaArena/process/0.20mm Bambu Support W @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.20mm Bambu Support W @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.20mm Arena Support W @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_arena_0.20", "enable_support": "1", "support_interface_top_layers": "3", "support_top_z_distance": "0.2", diff --git a/resources/profiles/OrcaArena/process/0.20mm Standard @Arena X1C.json b/resources/profiles/OrcaArena/process/0.20mm Standard @Arena X1C.json index 7c29054e32c..dbc599a13c7 100644 --- a/resources/profiles/OrcaArena/process/0.20mm Standard @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.20mm Standard @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.20mm Standard @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_arena_0.20", "compatible_printers": [ "Orca Arena X1 Carbon 0.4 nozzle", "Orca Arena X1 0.4 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.20mm Strength @Arena X1C.json b/resources/profiles/OrcaArena/process/0.20mm Strength @Arena X1C.json index aee1feb20f7..70284b77199 100644 --- a/resources/profiles/OrcaArena/process/0.20mm Strength @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.20mm Strength @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.20mm Strength @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_arena_0.20", "outer_wall_speed": "60", "wall_loops": "6", "sparse_infill_density": "25%", diff --git a/resources/profiles/OrcaArena/process/0.24mm Draft @Arena X1C.json b/resources/profiles/OrcaArena/process/0.24mm Draft @Arena X1C.json index 3493d123c87..b1a5683ad9b 100644 --- a/resources/profiles/OrcaArena/process/0.24mm Draft @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.24mm Draft @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.24mm Draft @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.24", + "inherits": "fdm_process_arena_0.24", "compatible_printers": [ "Orca Arena X1 Carbon 0.4 nozzle", "Orca Arena X1 0.4 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.6 nozzle.json b/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.6 nozzle.json index 0b68f55207f..2468e03eb30 100644 --- a/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.6 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.6 nozzle.json @@ -4,7 +4,7 @@ "name": "0.24mm Standard @Arena X1C 0.6 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.24_nozzle_0.6", + "inherits": "fdm_process_arena_0.24_nozzle_0.6", "compatible_printers": [ "Orca Arena X1 Carbon 0.6 nozzle", "Orca Arena X1 0.6 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.8 nozzle.json b/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.8 nozzle.json index d41f42e7059..2b699eef159 100644 --- a/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.8 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.24mm Standard @Arena X1C 0.8 nozzle.json @@ -4,7 +4,7 @@ "name": "0.24mm Standard @Arena X1C 0.8 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.24_nozzle_0.8", + "inherits": "fdm_process_arena_0.24_nozzle_0.8", "compatible_printers": [ "Orca Arena X1 Carbon 0.8 nozzle", "Orca Arena X1 0.8 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.28mm Extra Draft @Arena X1C.json b/resources/profiles/OrcaArena/process/0.28mm Extra Draft @Arena X1C.json index 0f7399c0ffe..3f0ce712d23 100644 --- a/resources/profiles/OrcaArena/process/0.28mm Extra Draft @Arena X1C.json +++ b/resources/profiles/OrcaArena/process/0.28mm Extra Draft @Arena X1C.json @@ -4,7 +4,7 @@ "name": "0.28mm Extra Draft @Arena X1C", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.28", + "inherits": "fdm_process_arena_0.28", "compatible_printers": [ "Orca Arena X1 Carbon 0.4 nozzle", "Orca Arena X1 0.4 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.30mm Standard @Arena X1C 0.6 nozzle.json b/resources/profiles/OrcaArena/process/0.30mm Standard @Arena X1C 0.6 nozzle.json index 7b4a4d159dc..72862163d2f 100644 --- a/resources/profiles/OrcaArena/process/0.30mm Standard @Arena X1C 0.6 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.30mm Standard @Arena X1C 0.6 nozzle.json @@ -4,7 +4,7 @@ "name": "0.30mm Standard @Arena X1C 0.6 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_arena_0.30_nozzle_0.6", "compatible_printers": [ "Orca Arena X1 Carbon 0.6 nozzle" ] diff --git a/resources/profiles/OrcaArena/process/0.30mm Strength @Arena X1C 0.6 nozzle.json b/resources/profiles/OrcaArena/process/0.30mm Strength @Arena X1C 0.6 nozzle.json index 4703c9bd976..22e7ceab3b0 100644 --- a/resources/profiles/OrcaArena/process/0.30mm Strength @Arena X1C 0.6 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.30mm Strength @Arena X1C 0.6 nozzle.json @@ -4,7 +4,7 @@ "name": "0.30mm Strength @Arena X1C 0.6 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.30_nozzle_0.6", + "inherits": "fdm_process_arena_0.30_nozzle_0.6", "wall_loops": "4", "sparse_infill_density":"25%", "compatible_printers": [ diff --git a/resources/profiles/OrcaArena/process/0.32mm Standard @Arena X1C 0.8 nozzle.json b/resources/profiles/OrcaArena/process/0.32mm Standard @Arena X1C 0.8 nozzle.json index 46495ffd045..187a24d811e 100644 --- a/resources/profiles/OrcaArena/process/0.32mm Standard @Arena X1C 0.8 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.32mm Standard @Arena X1C 0.8 nozzle.json @@ -4,7 +4,7 @@ "name": "0.32mm Standard @Arena X1C 0.8 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.32_nozzle_0.8", + "inherits": "fdm_process_arena_0.32_nozzle_0.8", "compatible_printers": [ "Orca Arena X1 Carbon 0.8 nozzle", "Orca Arena X1 0.8 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.36mm Standard @Arena X1C 0.6 nozzle.json b/resources/profiles/OrcaArena/process/0.36mm Standard @Arena X1C 0.6 nozzle.json index 73188a627a3..51c677d51f3 100644 --- a/resources/profiles/OrcaArena/process/0.36mm Standard @Arena X1C 0.6 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.36mm Standard @Arena X1C 0.6 nozzle.json @@ -4,7 +4,7 @@ "name": "0.36mm Standard @Arena X1C 0.6 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.36_nozzle_0.6", + "inherits": "fdm_process_arena_0.36_nozzle_0.6", "compatible_printers": [ "Orca Arena X1 Carbon 0.6 nozzle", "Orca Arena X1 0.6 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.40mm Standard @Arena X1C 0.8 nozzle.json b/resources/profiles/OrcaArena/process/0.40mm Standard @Arena X1C 0.8 nozzle.json index c89228221ae..69f766b0a59 100644 --- a/resources/profiles/OrcaArena/process/0.40mm Standard @Arena X1C 0.8 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.40mm Standard @Arena X1C 0.8 nozzle.json @@ -4,7 +4,7 @@ "name": "0.40mm Standard @Arena X1C 0.8 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.40_nozzle_0.8", + "inherits": "fdm_process_arena_0.40_nozzle_0.8", "compatible_printers": [ "Orca Arena X1 Carbon 0.8 nozzle" ] diff --git a/resources/profiles/OrcaArena/process/0.42mm Standard @Arena X1C 0.6 nozzle.json b/resources/profiles/OrcaArena/process/0.42mm Standard @Arena X1C 0.6 nozzle.json index 0dd4f8e8299..de38bf2726f 100644 --- a/resources/profiles/OrcaArena/process/0.42mm Standard @Arena X1C 0.6 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.42mm Standard @Arena X1C 0.6 nozzle.json @@ -4,7 +4,7 @@ "name": "0.42mm Standard @Arena X1C 0.6 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.42_nozzle_0.6", + "inherits": "fdm_process_arena_0.42_nozzle_0.6", "compatible_printers": [ "Orca Arena X1 Carbon 0.6 nozzle", "Orca Arena X1 0.6 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.48mm Standard @Arena X1C 0.8 nozzle.json b/resources/profiles/OrcaArena/process/0.48mm Standard @Arena X1C 0.8 nozzle.json index d745f58ddad..86d937870f3 100644 --- a/resources/profiles/OrcaArena/process/0.48mm Standard @Arena X1C 0.8 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.48mm Standard @Arena X1C 0.8 nozzle.json @@ -4,7 +4,7 @@ "name": "0.48mm Standard @Arena X1C 0.8 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.48_nozzle_0.8", + "inherits": "fdm_process_arena_0.48_nozzle_0.8", "compatible_printers": [ "Orca Arena X1 Carbon 0.8 nozzle", "Orca Arena X1 0.8 nozzle" diff --git a/resources/profiles/OrcaArena/process/0.56mm Standard @Arena X1C 0.8 nozzle.json b/resources/profiles/OrcaArena/process/0.56mm Standard @Arena X1C 0.8 nozzle.json index 15fade29642..62e578beb8b 100644 --- a/resources/profiles/OrcaArena/process/0.56mm Standard @Arena X1C 0.8 nozzle.json +++ b/resources/profiles/OrcaArena/process/0.56mm Standard @Arena X1C 0.8 nozzle.json @@ -4,7 +4,7 @@ "name": "0.56mm Standard @Arena X1C 0.8 nozzle", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.56_nozzle_0.8", + "inherits": "fdm_process_arena_0.56_nozzle_0.8", "compatible_printers": [ "Orca Arena X1 Carbon 0.8 nozzle", "Orca Arena X1 0.8 nozzle" diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.06_nozzle_0.2.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.06_nozzle_0.2.json similarity index 87% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.06_nozzle_0.2.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.06_nozzle_0.2.json index 35257823ae7..e842267f207 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.06_nozzle_0.2.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.06_nozzle_0.2.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.06_nozzle_0.2", + "name": "fdm_process_arena_0.06_nozzle_0.2", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.06", "initial_layer_print_height": "0.1", "wall_loops": "4", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.08.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.08.json similarity index 89% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.08.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.08.json index 6a3bd6f05db..891e3e65279 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.08.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.08.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.08", + "name": "fdm_process_arena_0.08", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.08", "elefant_foot_compensation": "0.15", "bottom_shell_layers": "7", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.08_nozzle_0.2.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.08_nozzle_0.2.json similarity index 87% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.08_nozzle_0.2.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.08_nozzle_0.2.json index 90fae21397b..e19a49279b9 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.08_nozzle_0.2.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.08_nozzle_0.2.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.08_nozzle_0.2", + "name": "fdm_process_arena_0.08_nozzle_0.2", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.08", "initial_layer_print_height": "0.1", "wall_loops": "4", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.10_nozzle_0.2.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.10_nozzle_0.2.json similarity index 88% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.10_nozzle_0.2.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.10_nozzle_0.2.json index a53df8b5a9f..2a87fdde762 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.10_nozzle_0.2.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.10_nozzle_0.2.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.10_nozzle_0.2", + "name": "fdm_process_arena_0.10_nozzle_0.2", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.1", "initial_layer_print_height": "0.1", "wall_loops": "4", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.12.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.12.json similarity index 89% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.12.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.12.json index 3890b18a5c3..b31a0b012a7 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.12.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.12.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.12", + "name": "fdm_process_arena_0.12", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.12", "bottom_shell_layers": "5", "elefant_foot_compensation": "0.15", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.12_nozzle_0.2.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.12_nozzle_0.2.json similarity index 87% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.12_nozzle_0.2.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.12_nozzle_0.2.json index 8a76d4c7cb2..432d530d207 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.12_nozzle_0.2.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.12_nozzle_0.2.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.12_nozzle_0.2", + "name": "fdm_process_arena_0.12_nozzle_0.2", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.12", "initial_layer_print_height": "0.1", "wall_loops": "4", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.14_nozzle_0.2.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.14_nozzle_0.2.json similarity index 87% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.14_nozzle_0.2.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.14_nozzle_0.2.json index 81bd28b30c3..ec826048d7c 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.14_nozzle_0.2.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.14_nozzle_0.2.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.14_nozzle_0.2", + "name": "fdm_process_arena_0.14_nozzle_0.2", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.14", "initial_layer_print_height": "0.1", "wall_loops": "4", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.16.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.16.json similarity index 89% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.16.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.16.json index 98523a0fa66..016a2a1a016 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.16.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.16.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.16", + "name": "fdm_process_arena_0.16", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.16", "elefant_foot_compensation": "0.15", "bottom_shell_layers": "4", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.18_nozzle_0.6.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.18_nozzle_0.6.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.18_nozzle_0.6.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.18_nozzle_0.6.json index 1a9120fdb98..9fb9a8582fa 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.18_nozzle_0.6.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.18_nozzle_0.6.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.18_nozzle_0.6", + "name": "fdm_process_arena_0.18_nozzle_0.6", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.18", "initial_layer_print_height": "0.3", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.20.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.20.json similarity index 86% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.20.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.20.json index 12fe82dd123..a03d7a0e750 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.20.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.20.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.20", + "name": "fdm_process_arena_0.20", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.2", "elefant_foot_compensation": "0.15", "bottom_shell_layers": "3", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.24.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.24.json similarity index 88% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.24.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.24.json index bb43494a56e..ff5cbbbdd46 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.24.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.24.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.24", + "name": "fdm_process_arena_0.24", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.24", "elefant_foot_compensation": "0.15", "top_surface_line_width": "0.45", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.24_nozzle_0.6.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.24_nozzle_0.6.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.24_nozzle_0.6.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.24_nozzle_0.6.json index aec643962c1..b2d86d7f21e 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.24_nozzle_0.6.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.24_nozzle_0.6.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.24_nozzle_0.6", + "name": "fdm_process_arena_0.24_nozzle_0.6", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.24", "initial_layer_print_height": "0.3", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.24_nozzle_0.8.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.24_nozzle_0.8.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.24_nozzle_0.8.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.24_nozzle_0.8.json index 55d9be4407f..a271c409896 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.24_nozzle_0.8.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.24_nozzle_0.8.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.24_nozzle_0.8", + "name": "fdm_process_arena_0.24_nozzle_0.8", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.24", "initial_layer_print_height": "0.4", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.28.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.28.json similarity index 88% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.28.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.28.json index aeb45ebe562..fc2ea3c5d81 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.28.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.28.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.28", + "name": "fdm_process_arena_0.28", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.28", "elefant_foot_compensation": "0.15", "top_surface_line_width": "0.45", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.30_nozzle_0.6.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.30_nozzle_0.6.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.30_nozzle_0.6.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.30_nozzle_0.6.json index 37decfe4dad..0834bbf0d64 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.30_nozzle_0.6.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.30_nozzle_0.6.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.30_nozzle_0.6", + "name": "fdm_process_arena_0.30_nozzle_0.6", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.3", "initial_layer_print_height": "0.3", "wall_loops": "3", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.32_nozzle_0.8.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.32_nozzle_0.8.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.32_nozzle_0.8.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.32_nozzle_0.8.json index 6172f32e94e..4519ea607d9 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.32_nozzle_0.8.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.32_nozzle_0.8.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.32_nozzle_0.8", + "name": "fdm_process_arena_0.32_nozzle_0.8", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.32", "initial_layer_print_height": "0.3", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.36_nozzle_0.6.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.36_nozzle_0.6.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.36_nozzle_0.6.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.36_nozzle_0.6.json index a8a8a1387a6..4c2316f806d 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.36_nozzle_0.6.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.36_nozzle_0.6.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.36_nozzle_0.6", + "name": "fdm_process_arena_0.36_nozzle_0.6", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.36", "initial_layer_print_height": "0.3", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.40_nozzle_0.8.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.40_nozzle_0.8.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.40_nozzle_0.8.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.40_nozzle_0.8.json index aa514e6f044..d643b852b74 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.40_nozzle_0.8.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.40_nozzle_0.8.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.40_nozzle_0.8", + "name": "fdm_process_arena_0.40_nozzle_0.8", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.4", "initial_layer_print_height": "0.4", "wall_loops": "3", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.42_nozzle_0.6.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.42_nozzle_0.6.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.42_nozzle_0.6.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.42_nozzle_0.6.json index 7d9309c1b1c..35e8b4a7b9e 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.42_nozzle_0.6.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.42_nozzle_0.6.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.42_nozzle_0.6", + "name": "fdm_process_arena_0.42_nozzle_0.6", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.42", "initial_layer_print_height": "0.3", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.48_nozzle_0.8.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.48_nozzle_0.8.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.48_nozzle_0.8.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.48_nozzle_0.8.json index d026bdc7469..92b4378781a 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.48_nozzle_0.8.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.48_nozzle_0.8.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.48_nozzle_0.8", + "name": "fdm_process_arena_0.48_nozzle_0.8", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.48", "initial_layer_print_height": "0.4", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.56_nozzle_0.8.json b/resources/profiles/OrcaArena/process/fdm_process_arena_0.56_nozzle_0.8.json similarity index 91% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_0.56_nozzle_0.8.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_0.56_nozzle_0.8.json index f43ab7e2e5f..8039c670211 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_0.56_nozzle_0.8.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_0.56_nozzle_0.8.json @@ -1,9 +1,9 @@ { "type": "process", - "name": "fdm_process_bbl_0.56_nozzle_0.8", + "name": "fdm_process_arena_0.56_nozzle_0.8", "from": "system", "instantiation": "false", - "inherits": "fdm_process_bbl_common", + "inherits": "fdm_process_arena_common", "layer_height": "0.56", "initial_layer_print_height": "0.4", "wall_loops": "2", diff --git a/resources/profiles/OrcaArena/process/fdm_process_bbl_common.json b/resources/profiles/OrcaArena/process/fdm_process_arena_common.json similarity index 98% rename from resources/profiles/OrcaArena/process/fdm_process_bbl_common.json rename to resources/profiles/OrcaArena/process/fdm_process_arena_common.json index 0f484cdbedf..09e687514ca 100644 --- a/resources/profiles/OrcaArena/process/fdm_process_bbl_common.json +++ b/resources/profiles/OrcaArena/process/fdm_process_arena_common.json @@ -1,6 +1,6 @@ { "type": "process", - "name": "fdm_process_bbl_common", + "name": "fdm_process_arena_common", "from": "system", "instantiation": "false", "inherits": "fdm_process_common", diff --git a/resources/profiles/Ratrig/process/0.20mm Bambu Support W @RatRig.json b/resources/profiles/Ratrig/process/0.20mm Bambu Support W @RatRig.json index 3e4b2431bbc..9e6363d6e20 100644 --- a/resources/profiles/Ratrig/process/0.20mm Bambu Support W @RatRig.json +++ b/resources/profiles/Ratrig/process/0.20mm Bambu Support W @RatRig.json @@ -4,7 +4,7 @@ "name": "0.20mm Bambu Support W @RatRig", "from": "system", "instantiation": "true", - "inherits": "fdm_process_bbl_0.20", + "inherits": "fdm_process_single_0.20", "enable_support": "1", "support_interface_top_layers": "3", "support_top_z_distance": "0.2", diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 588d1e0c0a1..4cb3c79207c 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -254,6 +254,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); diff --git a/src/libslic3r/Format/bbs_3mf.cpp b/src/libslic3r/Format/bbs_3mf.cpp index 72c6d54ca7c..00c588283d4 100644 --- a/src/libslic3r/Format/bbs_3mf.cpp +++ b/src/libslic3r/Format/bbs_3mf.cpp @@ -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 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(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(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; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 95540005b45..d0566a0b5b2 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -299,6 +299,13 @@ static std::unordered_mapNozzleTypeEumnToStr = { {NozzleType::ntBrass, "brass"} }; +static std::unordered_mapNozzleTypeStrToEumn = { + {"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, diff --git a/src/libslic3r/ProjectTask.hpp b/src/libslic3r/ProjectTask.hpp index 05f39f9b2c9..ef2033eefdc 100644 --- a/src/libslic3r/ProjectTask.hpp +++ b/src/libslic3r/ProjectTask.hpp @@ -49,6 +49,10 @@ struct FilamentInfo int ctype = 0; std::vector colors = std::vector(); int mapping_result = 0; + + /*for new ams mapping*/ + std::string ams_id; + std::string slot_id; }; class BBLSliceInfo { diff --git a/src/libslic3r/calib.hpp b/src/libslic3r/calib.hpp index c9a950d8860..d7db10fd81b 100644 --- a/src/libslic3r/calib.hpp +++ b/src/libslic3r/calib.hpp @@ -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 @@ class PACalibResult 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 @@ class PACalibResult 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: diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index baf7b56e893..9bf82826f33 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -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 @@ -580,8 +584,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 diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 9b6149d6622..db04cf5065d 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -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 - 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); + 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; + } } - 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 (obj) { + 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 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 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(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 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 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(); } diff --git a/src/slic3r/GUI/AMSMaterialsSetting.hpp b/src/slic3r/GUI/AMSMaterialsSetting.hpp index c058ac769f4..3c8743b6347 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.hpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.hpp @@ -118,7 +118,7 @@ class AMSMaterialsSetting : public DPIDialog 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; diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index 5a8852600fb..ed0abec8846 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -328,7 +328,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); diff --git a/src/slic3r/GUI/AmsMappingPopup.cpp b/src/slic3r/GUI/AmsMappingPopup.cpp index 86610594524..f02543313c1 100644 --- a/src/slic3r/GUI/AmsMappingPopup.cpp +++ b/src/slic3r/GUI/AmsMappingPopup.cpp @@ -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 amsList) { - m_has_unmatch_filament = false; - //m_mapping_item_list.clear(); + std::map::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(); } + m_amsmapping_container_list.clear(); + m_amsmapping_container_sizer_list.clear(); + m_mapping_item_list.clear(); - for (wxWindow *mitem : m_mapping_item_list) { - mitem->Destroy(); - mitem = nullptr; - } - m_mapping_item_list.clear(); + for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) { - if (m_amsmapping_container_sizer_list.size() > 0) { - for (wxBoxSizer *siz : m_amsmapping_container_sizer_list) { - siz->Clear(true); - } - } - - std::map::iterator ams_iter; + int ams_indx = atoi(ams_iter->first.c_str()); + int ams_type = ams_iter->second->type; + int nozzle_id = ams_iter->second->nozzle; - BOOST_LOG_TRIVIAL(trace) << "ams_mapping total count " << amsList.size(); - int m_amsmapping_container_list_index = 0; + if (ams_type >=1 || ams_type <= 3) { //1:ams 2:ams-lite 3:n3f - 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 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; - auto ams_indx = atoi(ams_iter->first.c_str()); - Ams *ams_group = ams_iter->second; - std::vector tray_datas; - std::map::iterator tray_iter; + BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str(); - for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) { - AmsTray *tray_data = tray_iter->second; - TrayData td; + Ams* ams_group = ams_iter->second; + std::vector tray_datas; + std::map::iterator tray_iter; - td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str()); + for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) { + AmsTray* tray_data = tray_iter->second; + TrayData td; - 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.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_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_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_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 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); @@ -1389,7 +1407,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 group_info; diff --git a/src/slic3r/GUI/AmsMappingPopup.hpp b/src/slic3r/GUI/AmsMappingPopup.hpp index 75f274ba0bd..7c64cba2f2e 100644 --- a/src/slic3r/GUI/AmsMappingPopup.hpp +++ b/src/slic3r/GUI/AmsMappingPopup.hpp @@ -60,6 +60,9 @@ struct TrayData std::string filament_type; wxColour colour; std::vector material_cols = std::vector(); + + int ams_id = 0; + int slot_id = 0; }; class MaterialItem: public wxPanel @@ -116,6 +119,9 @@ class MappingItem : public wxPanel 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 @@ class AmsMapingPopup : public PopupWindow 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}; diff --git a/src/slic3r/GUI/CaliHistoryDialog.cpp b/src/slic3r/GUI/CaliHistoryDialog.cpp index 7224ec34e2f..3d5bbcd646e 100644 --- a/src/slic3r/GUI/CaliHistoryDialog.cpp +++ b/src/slic3r/GUI/CaliHistoryDialog.cpp @@ -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 filament_id_set; std::set 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 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; diff --git a/src/slic3r/GUI/CaliHistoryDialog.hpp b/src/slic3r/GUI/CaliHistoryDialog.hpp index 8f7b49a25a6..b8ef7666e30 100644 --- a/src/slic3r/GUI/CaliHistoryDialog.hpp +++ b/src/slic3r/GUI/CaliHistoryDialog.hpp @@ -36,7 +36,6 @@ class HistoryWindow : public DPIDialog { bool& m_show_history_dialog; std::vector m_calib_results_history; MachineObject* curr_obj { nullptr }; - int history_version = -1; }; class EditCalibrationHistoryDialog : public DPIDialog diff --git a/src/slic3r/GUI/CalibrationPanel.cpp b/src/slic3r/GUI/CalibrationPanel.cpp index 9a16c133222..8fa07b924fc 100644 --- a/src/slic3r/GUI/CalibrationPanel.cpp +++ b/src/slic3r/GUI/CalibrationPanel.cpp @@ -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 diff --git a/src/slic3r/GUI/CalibrationPanel.hpp b/src/slic3r/GUI/CalibrationPanel.hpp index a993ff28869..eafb380c79a 100644 --- a/src/slic3r/GUI/CalibrationPanel.hpp +++ b/src/slic3r/GUI/CalibrationPanel.hpp @@ -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 diff --git a/src/slic3r/GUI/CalibrationWizard.cpp b/src/slic3r/GUI/CalibrationWizard.cpp index 17fccc060e0..7e8ff01de0d 100644 --- a/src/slic3r/GUI/CalibrationWizard.cpp +++ b/src/slic3r/GUI/CalibrationWizard.cpp @@ -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 get_cached_selected_filament(MachineObject* obj) { std::map 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; } diff --git a/src/slic3r/GUI/CalibrationWizard.hpp b/src/slic3r/GUI/CalibrationWizard.hpp index 34550b4b7fa..28bf9376926 100644 --- a/src/slic3r/GUI/CalibrationWizard.hpp +++ b/src/slic3r/GUI/CalibrationWizard.hpp @@ -19,7 +19,7 @@ class CalibrationWizardPageStep CalibrationWizardPageStep(CalibrationWizardPage* data) { page = data; } - + CalibrationWizardPageStep* prev { nullptr }; CalibrationWizardPageStep* next { nullptr }; CalibrationWizardPage* page { nullptr }; @@ -57,7 +57,7 @@ class CalibrationWizard : public wxPanel { } 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 &key_values, wxString& message); @@ -71,6 +71,7 @@ class CalibrationWizard : public wxPanel { 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 @@ class CalibrationWizard : public wxPanel { 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 }; diff --git a/src/slic3r/GUI/CalibrationWizardCaliPage.cpp b/src/slic3r/GUI/CalibrationWizardCaliPage.cpp index cd63eaf38ab..927285c149c 100644 --- a/src/slic3r/GUI/CalibrationWizardCaliPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardCaliPage.cpp @@ -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; diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index f4b268347fb..badb4a69452 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -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{} }; - 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 full_filament_ams_list = wxGetApp().sidebar().build_filament_ams_list(obj); + std::map old_full_filament_ams_list = wxGetApp().sidebar().build_filament_ams_list(obj); + std::map 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) { diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.hpp b/src/slic3r/GUI/CalibrationWizardPresetPage.hpp index 4adcd858f3a..176006994c1 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.hpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.hpp @@ -284,8 +284,8 @@ class CalibrationPresetPage : public CalibrationWizardPage FilamentComboBoxList m_filament_comboBox_list; FilamentComboBox* m_virtual_tray_comboBox; - - std::vector m_ams_item_list; + + std::vector m_ams_preview_list; // for update filament combobox, key : tray_id std::map filament_ams_list; diff --git a/src/slic3r/GUI/CalibrationWizardSavePage.cpp b/src/slic3r/GUI/CalibrationWizardSavePage.cpp index 738bd033a5d..6eb43e7172f 100644 --- a/src/slic3r/GUI/CalibrationWizardSavePage.cpp +++ b/src/slic3r/GUI/CalibrationWizardSavePage.cpp @@ -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> CaliPASaveAutoPanel::default_naming(std void CaliPASaveAutoPanel::sync_cali_result(const std::vector& cali_result, const std::vector& 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& out_result) { } } +void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector& cali_result, const std::vector& 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> 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 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)); diff --git a/src/slic3r/GUI/CalibrationWizardSavePage.hpp b/src/slic3r/GUI/CalibrationWizardSavePage.hpp index 6b76b22acb3..aa63a75a187 100644 --- a/src/slic3r/GUI/CalibrationWizardSavePage.hpp +++ b/src/slic3r/GUI/CalibrationWizardSavePage.hpp @@ -98,6 +98,9 @@ class CaliPASaveAutoPanel : public wxPanel bool get_result(std::vector& out_result); bool is_all_failed() { return m_is_all_failed; } +protected: + void sync_cali_result_for_multi_extruder(const std::vector &cali_result, const std::vector &history_result); + protected: wxBoxSizer* m_top_sizer; wxPanel* m_complete_text_panel; @@ -218,7 +221,7 @@ class CalibrationFlowX1SavePage : public CalibrationCommonSavePage bool is_all_failed() { return m_is_all_failed; } virtual bool Show(bool show = true) override; - + void msw_rescale() override; protected: diff --git a/src/slic3r/GUI/CalibrationWizardStartPage.cpp b/src/slic3r/GUI/CalibrationWizardStartPage.cpp index c4b0c83cba8..49d0483d8de 100644 --- a/src/slic3r/GUI/CalibrationWizardStartPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardStartPage.cpp @@ -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); } } diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index cd94ab183aa..bf9d3cd62fd 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -24,6 +24,8 @@ #define MINUTE_30 1800000 //ms #define TIME_OUT 5000 //ms +#define ORCA_NETWORK_DEBUG + namespace pt = boost::property_tree; float string_to_float(const std::string& str_value) { @@ -32,50 +34,6 @@ float string_to_float(const std::string& str_value) { return value; } -const int PRINTING_STAGE_COUNT = 36; -std::string PRINTING_STAGE_STR[PRINTING_STAGE_COUNT] = { - "printing", - "bed_leveling", - "heatbed_preheating", - "xy_mech_mode_sweep", - "change_material", - "m400_pause", - "filament_runout_pause", - "hotend_heating", - "extrude_compensation_scan", - "bed_scan", - "first_layer_scan", - "be_surface_typt_idetification", - "scanner_extrinsic_para_cali", - "toohead_homing", - "nozzle_tip_cleaning", - "extruder_temp_protect_cali", - "user_pause", - "toolhead_shell_off_pause", - "scanner_laser_para_cali", - "extruder_absolute_flow_cali", - "hotend_temperature_error_pause", // 20 - "heated_bed_temperature_error_pause", - "filament_unloading", - "skip_step_pause", - "filament_loading", - "motor_noise_calibration", - "ams_lost_pause", - "heat_break_fan_pause", - "chamber_temperature_control_error_pause", - "chamber_cooling", - "user_insert_gcode_pause", - "motor_noise_showoff", - "nozzle_filament_covered_detected_pause", - "cutter_error_pause", - "first_layer_error_pause", - "nozzle_clog_pause" - }; - - - - - wxString get_stage_string(int stage) { switch(stage) { @@ -176,6 +134,57 @@ std::string to_string_nozzle_diameter(float nozzle_diameter) return "0"; } +void sanitizeToUtf8(std::string& str) { + std::string result; + size_t i = 0; + + while (i < str.size()) { + unsigned char c = str[i]; + size_t remainingBytes = 0; + bool valid = true; + + if ((c & 0x80) == 0x00) { // 1-byte character (ASCII) + remainingBytes = 0; + } + else if ((c & 0xE0) == 0xC0) { // 2-byte character + remainingBytes = 1; + } + else if ((c & 0xF0) == 0xE0) { // 3-byte character + remainingBytes = 2; + } + else if ((c & 0xF8) == 0xF0) { // 4-byte character + remainingBytes = 3; + } + else { + valid = false; // Invalid first byte + } + + if (valid && i + remainingBytes < str.size()) { + for (size_t j = 1; j <= remainingBytes; ++j) { + if ((str[i + j] & 0xC0) != 0x80) { + valid = false; // Invalid continuation byte + break; + } + } + } + else { + valid = false; // Truncated character + } + + if (valid) { + // Append valid UTF-8 character + result.append(str, i, remainingBytes + 1); + i += remainingBytes + 1; + } + else { + // Replace invalid character with space + result += ' '; + ++i; // Skip the invalid byte + } + } + str = std::move(result); +} + namespace Slic3r { /* Common Functions */ @@ -194,6 +203,43 @@ void split_string(std::string s, std::vector& v) { v.push_back(t); } +wxString generate_nozzle_id(NozzleVolumeType nozzle_type, const std::string& diameter) +{ + // HS00-0.4 + std::string nozzle_id = "H"; + switch (nozzle_type) { + case NozzleVolumeType::nvtNormal: { + nozzle_id += "S"; + break; + } + case NozzleVolumeType::nvtBigTraffic: { + nozzle_id += "H"; + break; + } + default: + nozzle_id += "H"; + break; + } + nozzle_id += "00"; + nozzle_id += "-"; + nozzle_id += diameter; + return nozzle_id; +} + +NozzleVolumeType convert_to_nozzle_type(const std::string &str) +{ + if (str.size() < 8) { + assert(false); + return NozzleVolumeType::nvtNormal; + } + NozzleVolumeType res = NozzleVolumeType::nvtNormal; + if (str[1] == 'S') + res = NozzleVolumeType::nvtNormal; + else if (str[1] == 'H') + res = NozzleVolumeType::nvtBigTraffic; + return res; +} + PrinterArch get_printer_arch_by_str(std::string arch_str) { if (arch_str == "i3") { @@ -492,7 +538,7 @@ bool MachineObject::is_lan_mode_printer() const PrinterSeries MachineObject::get_printer_series() const { std::string series = DeviceManager::get_printer_series(printer_type); - if (series == "series_x1") + if (series == "series_x1" || series == "series_o") return PrinterSeries::SERIES_X1; else if (series == "series_p1p") return PrinterSeries::SERIES_P1P; @@ -536,8 +582,6 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string reset(); /* temprature fields */ - nozzle_temp = 0.0f; - nozzle_temp_target = 0.0f; bed_temp = 0.0f; bed_temp_target = 0.0f; chamber_temp = 0.0f; @@ -552,9 +596,7 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string is_ams_need_update = false; ams_insert_flag = false; ams_power_on_flag = false; - ams_support_use_ams = false; ams_calibrate_remain_flag = false; - ams_humidity = 5; /* signals */ wifi_signal = ""; @@ -584,6 +626,15 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string printing_speed_lvl = PrintingSpeedLevel::SPEED_LEVEL_INVALID; has_ipcam = true; // default true + + m_extder_data.current_extder_id = MAIN_NOZZLE_ID; + m_extder_data.target_extder_id = MAIN_NOZZLE_ID; + m_extder_data.total_extder_count = 1; + Extder nozzle; + nozzle.id = MAIN_NOZZLE_ID; + nozzle.nozzle_id = MAIN_NOZZLE_ID; + nozzle.target_nozzle_id = MAIN_NOZZLE_ID; + m_extder_data.extders.push_back(nozzle); } MachineObject::~MachineObject() @@ -662,7 +713,7 @@ bool MachineObject::is_extrusion_cali_finished() if (diff.count() < EXTRUSION_OMIT_TIME) { return false; } - + if (boost::contains(m_gcode_file, "extrusion_cali") && this->mc_print_percent == 100) return true; @@ -672,24 +723,44 @@ bool MachineObject::is_extrusion_cali_finished() void MachineObject::_parse_tray_now(std::string tray_now) { - m_tray_now = tray_now; if (tray_now.empty()) { return; } else { try { int tray_now_int = atoi(tray_now.c_str()); - if (tray_now_int >= 0 && tray_now_int < 16) { - m_ams_id = std::to_string(tray_now_int >> 2); - m_tray_id = std::to_string(tray_now_int & 0x3); - } - else if (tray_now_int == 255) { + + if (tray_now_int == 255) { m_ams_id = "0"; m_tray_id = "0"; + m_extder_data.extders[MAIN_NOZZLE_ID].snow.ams_id = ""; + m_extder_data.extders[MAIN_NOZZLE_ID].snow.slot_id = ""; + + if (m_tray_now == std::to_string(255)) { + m_extder_data.extders[MAIN_NOZZLE_ID].snow.ams_id = std::to_string(255); + m_extder_data.extders[MAIN_NOZZLE_ID].snow.slot_id = "0"; + } + } + else if (tray_now_int == 254) { + m_extder_data.extders[MAIN_NOZZLE_ID].snow.ams_id = std::to_string(254); + m_extder_data.extders[MAIN_NOZZLE_ID].snow.slot_id = "0"; + } + else { + if (tray_now_int >= 0x80 && tray_now_int <= 0x87) { + m_ams_id = std::to_string(tray_now_int); + } else { + m_ams_id = std::to_string(tray_now_int >> 2); + } + + m_tray_id = std::to_string(tray_now_int & 0x3); + m_extder_data.extders[MAIN_NOZZLE_ID].snow.ams_id = m_ams_id; + m_extder_data.extders[MAIN_NOZZLE_ID].snow.slot_id = m_tray_id; } } catch(...) { } } + + m_tray_now = tray_now; } Ams *MachineObject::get_curr_Ams() @@ -810,6 +881,9 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std // tray_index : tray_color std::map tray_filaments; for (auto ams = amsList.begin(); ams != amsList.end(); ams++) { + + std::string ams_id = ams->second->id; + for (auto tray = ams->second->trayList.begin(); tray != ams->second->trayList.end(); tray++) { int ams_id = atoi(ams->first.c_str()); int tray_id = atoi(tray->first.c_str()); @@ -828,6 +902,11 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std info.filament_id = tray->second->setting_id; info.ctype = tray->second->ctype; info.colors = tray->second->cols; + + /*for new ams mapping*/ + info.ams_id = ams->first.c_str(); + info.slot_id = tray->first.c_str(); + tray_filaments.emplace(std::make_pair(tray_index, info)); } } @@ -835,27 +914,29 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std // tray info list std::vector tray_info_list; - for (auto it = amsList.begin(); it != amsList.end(); it++) { - for (int i = 0; i < 4; i++) { + int flament_index_id = 0; + for (auto ams = amsList.begin(); ams != amsList.end(); ams++) { + for (auto tray = ams->second->trayList.begin(); tray != ams->second->trayList.end(); tray++) { + FilamentInfo info; - auto tray_it = it->second->trayList.find(std::to_string(i)); - if (tray_it != it->second->trayList.end()) { - info.id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4; - info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4; - info.color = tray_it->second->color; - info.type = tray_it->second->get_filament_type(); - info.ctype = tray_it->second->ctype; - info.colors = tray_it->second->cols; - } - else { - info.id = -1; - info.tray_id = -1; - } + info.id = flament_index_id; + info.tray_id = flament_index_id; + info.color = tray->second->color; + info.type = tray->second->get_filament_type(); + info.ctype = tray->second->ctype; + info.colors = tray->second->cols; + + + /*for new ams mapping*/ + info.ams_id = ams->second->id; + info.slot_id = tray->second->id; + tray_info_list.push_back(info); + flament_index_id++; } } - + // is_support_ams_mapping if (!is_support_ams_mapping()) { BOOST_LOG_TRIVIAL(info) << "ams_mapping: do not support, use order mapping"; @@ -960,7 +1041,7 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std } continue; } - + if (distance_map[i][j].is_same_color && distance_map[i][j].is_type_match) { if (min_val > distance_map[i][j].distance) { @@ -968,7 +1049,7 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std min_val = distance_map[i][j].distance; picked_src_idx = i; picked_tar_idx = j; - } + } else if (min_val == distance_map[i][j].distance&& filaments[picked_src_idx].filament_id!= tray_filaments[picked_tar_idx].filament_id && filaments[i].filament_id == tray_filaments[j].filament_id) { picked_src_idx = i; @@ -987,6 +1068,11 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std result[picked_src_idx].filament_id = tray->second.filament_id; result[picked_src_idx].ctype = tray->second.ctype; result[picked_src_idx].colors = tray->second.colors; + + + /*for new ams mapping*/ + result[picked_src_idx].ams_id = tray->second.ams_id; + result[picked_src_idx].slot_id = tray->second.slot_id; } else { FilamentInfo info; @@ -1028,6 +1114,10 @@ int MachineObject::ams_filament_mapping(std::vector filaments, std result[i].type = tray_info_list[i].type; result[i].ctype = tray_info_list[i].ctype; result[i].colors = tray_info_list[i].colors; + + /*for new ams mapping*/ + result[i].ams_id = tray_info_list[i].ams_id; + result[i].slot_id = tray_info_list[i].slot_id; } } } @@ -1117,6 +1207,17 @@ void MachineObject::reset_mapping_result(std::vector& result) } } +bool MachineObject::is_main_extruder_on_left() const +{ + // only means the extruder is on the left hand when extruder id is 0 + return false; +} + +bool MachineObject::is_multi_extruders() const +{ + return m_extder_data.total_extder_count > 1; +} + bool MachineObject::is_bbl_filament(std::string tag_uid) { if (tag_uid.empty()) @@ -1255,9 +1356,25 @@ wxString MachineObject::get_upgrade_result_str(int err_code) std::map MachineObject::get_ams_version() { + std::vector multi_tray_ams_type = {"ams", "n3f"}; std::map result; - for (int i = 0; i < 4; i++) { - std::string ams_id = "ams/" + std::to_string(i); + for (int i = 0; i < 8; i++) { + std::string ams_id; + for (auto type : multi_tray_ams_type) + { + ams_id = type + "/" + std::to_string(i); + auto it = module_vers.find(ams_id); + if (it != module_vers.end()) { + result.emplace(std::pair(i, it->second)); + } + } + } + + std::string single_tray_ams_type = "n3s"; + int n3s_start_id = 128; + for (int i = n3s_start_id; i < n3s_start_id + 8; i++) { + std::string ams_id; + ams_id = single_tray_ams_type + "/" + std::to_string(i); auto it = module_vers.find(ams_id); if (it != module_vers.end()) { result.emplace(std::pair(i, it->second)); @@ -1266,6 +1383,24 @@ std::map MachineObject::get_ams_version() return result; } +void MachineObject::store_version_info(const ModuleVersionInfo& info) +{ + if (info.isAirPump()) + { + air_pump_version_info = info; + } + else if (info.isLaszer()) + { + laser_version_info = info; + } + else if (info.isCuttingModule()) + { + cutting_module_version_info = info; + } + + module_vers.emplace(info.name, info); +} + bool MachineObject::is_system_printing() { if (is_in_calibration() && is_in_printing_status(print_status)) @@ -1375,7 +1510,7 @@ void MachineObject::parse_state_changed_event() void MachineObject::parse_status(int flag) { - is_220V_voltage = ((flag >> 3) & 0x1) != 0; + is_220V_voltage = ((flag >> 3) & 0x1) != 0; if (xcam_auto_recovery_hold_count > 0) xcam_auto_recovery_hold_count--; else { @@ -1385,41 +1520,46 @@ void MachineObject::parse_status(int flag) camera_recording = ((flag >> 5) & 0x1) != 0; ams_calibrate_remain_flag = ((flag >> 7) & 0x1) != 0; + sdcard_state = MachineObject::SdcardState(get_flag_bits(flag, 8, 2)); + if (ams_print_option_count > 0) ams_print_option_count--; else { ams_auto_switch_filament_flag = ((flag >> 10) & 0x1) != 0; } + is_support_flow_calibration = ((flag >> 15) & 0x1) != 0; + is_support_pa_calibration = ((flag >> 16) & 0x1) != 0; + if (xcam_prompt_sound_hold_count > 0) xcam_prompt_sound_hold_count--; else { xcam_allow_prompt_sound = ((flag >> 17) & 0x1) != 0; } - if (((flag >> 18) & 0x1) != 0) { - is_support_prompt_sound = true; - } - + is_support_prompt_sound = ((flag >> 18) & 0x1) != 0; is_support_filament_tangle_detect = ((flag >> 19) & 0x1) != 0; - is_support_user_preset = ((flag >> 22) & 0x1) != 0; + if (xcam_filament_tangle_detect_count > 0) xcam_filament_tangle_detect_count--; else { xcam_filament_tangle_detect = ((flag >> 20) & 0x1) != 0; } - if(!is_support_motor_noise_cali){ + /*if(!is_support_motor_noise_cali){ is_support_motor_noise_cali = ((flag >> 21) & 0x1) != 0; - } + }*/ + is_support_motor_noise_cali = ((flag >> 21) & 0x1) != 0; + + is_support_user_preset = ((flag >> 22) & 0x1) != 0; is_support_nozzle_blob_detection = ((flag >> 25) & 0x1) != 0; nozzle_blob_detection_enabled = ((flag >> 24) & 0x1) != 0; is_support_air_print_detection = ((flag >> 29) & 0x1) != 0; ams_air_print_status = ((flag >> 28) & 0x1) != 0; - - if (!is_support_p1s_plus) { + + /*if (!is_support_p1s_plus) { auto supported_plus = ((flag >> 27) & 0x1) != 0; auto installed_plus = ((flag >> 26) & 0x1) != 0; @@ -1429,9 +1569,10 @@ void MachineObject::parse_status(int flag) else { is_support_p1s_plus = false; } - } + }*/ - sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11); + is_support_upgrade_kit = ((flag >> 27) & 0x1) != 0; + installed_upgrade_kit = ((flag >> 26) & 0x1) != 0; is_support_agora = ((flag >> 30) & 0x1) != 0; if (is_support_agora) @@ -1481,11 +1622,6 @@ bool MachineObject::is_sdcard_printing() return false; } -bool MachineObject::has_sdcard() -{ - return (sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL); -} - MachineObject::SdcardState MachineObject::get_sdcard_state() { return sdcard_state; @@ -1506,6 +1642,21 @@ bool MachineObject::is_recording() return camera_recording; } +int MachineObject::get_liveview_remote() +{ + if (is_support_agora) { + return liveview_remote == LVR_None ? LVR_Agora : liveview_remote == LVR_Tutk ? LVR_TutkAgora : liveview_remote; + } + return liveview_remote; +} + +int MachineObject::get_file_remote() +{ + if (is_support_agora) + file_remote = file_remote == FR_None ? FR_Agora : file_remote == FR_Tutk ? FR_TutkAgora : file_remote; + return file_remote; +} + std::string MachineObject::parse_version() { auto ota_version = module_vers.find("ota"); @@ -1549,7 +1700,7 @@ int MachineObject::command_get_access_code() { json j; j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["system"]["command"] = "get_access_code"; - + return this->publish_json(j.dump()); } @@ -1680,6 +1831,15 @@ int MachineObject::command_go_home() return this->publish_gcode("G28 \n"); } +int MachineObject::command_go_home2() +{ + BOOST_LOG_TRIVIAL(info) << "New protocol of command_go_home2"; + json j; + j["print"]["command"] = "back_to_center"; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + return this->publish_json(j.dump()); +} + int MachineObject::command_control_fan(FanType fan_type, bool on_off) { std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (on_off ? 255 : 0)).str(); @@ -1751,52 +1911,78 @@ int MachineObject::command_set_nozzle(int temp) int MachineObject::command_set_chamber(int temp) { json j; - j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["command"] = "set_ctt"; j["print"]["ctt_val"] = temp; return this->publish_json(j.dump(), 1); } -int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp) +//int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp) +//{ +// BOOST_LOG_TRIVIAL(trace) << "ams_switch to " << tray_index << " with temp: " << old_temp << ", " << new_temp; +// if (old_temp < 0) old_temp = FILAMENT_DEF_TEMP; +// if (new_temp < 0) new_temp = FILAMENT_DEF_TEMP; +// +// std::string gcode = ""; +// int result = 0; +// +// //command +// if (is_support_command_ams_switch) { +// command_ams_change_filament(tray_index, old_temp, new_temp); +// } +// else { +// std::string gcode = ""; +// if (tray_index == 255) { +// gcode = DeviceManager::load_gcode(printer_type, "ams_unload.gcode"); +// } +// else { +// // include VIRTUAL_TRAY_ID +// gcode = DeviceManager::load_gcode(printer_type, "ams_load.gcode"); +// boost::replace_all(gcode, "[next_extruder]", std::to_string(tray_index)); +// boost::replace_all(gcode, "[new_filament_temp]", std::to_string(new_temp)); +// } +// +// result = this->publish_gcode(gcode); +// } +// +// return result; +//} + +int MachineObject::command_ams_change_filament(bool load, std::string ams_id, std::string slot_id, int old_temp, int new_temp) { - BOOST_LOG_TRIVIAL(trace) << "ams_switch to " << tray_index << " with temp: " << old_temp << ", " << new_temp; - if (old_temp < 0) old_temp = FILAMENT_DEF_TEMP; - if (new_temp < 0) new_temp = FILAMENT_DEF_TEMP; + json j; + try { + auto tray_id = 0; + if (ams_id < "16") { + tray_id = atoi(ams_id.c_str()) * 4 + atoi(slot_id.c_str()); + } + // TODO: Orca hack + if (ams_id == "254") + ams_id = "255"; - std::string gcode = ""; - int result = 0; - //command - if (is_support_command_ams_switch) { - command_ams_change_filament(tray_index, old_temp, new_temp); - } - else { - std::string gcode = ""; - if (tray_index == 255) { - gcode = DeviceManager::load_gcode(printer_type, "ams_unload.gcode"); - } - else { - // include VIRTUAL_TRAY_ID - gcode = DeviceManager::load_gcode(printer_type, "ams_load.gcode"); - boost::replace_all(gcode, "[next_extruder]", std::to_string(tray_index)); - boost::replace_all(gcode, "[new_filament_temp]", std::to_string(new_temp)); - } + j["print"]["command"] = "ams_change_filament"; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + j["print"]["curr_temp"] = old_temp; + j["print"]["tar_temp"] = new_temp; + j["print"]["ams_id"] = atoi(ams_id.c_str()); - result = this->publish_gcode(gcode); - } + if (!load) { + j["print"]["target"] = 255; + j["print"]["slot_id"] = 255; // the new protocol to mark unload - return result; -} + } else { + if (tray_id == 0) { + j["print"]["target"] = atoi(ams_id.c_str()); + } else { + j["print"]["target"] = tray_id; + } + + j["print"]["slot_id"] = atoi(slot_id.c_str()); + } + } catch (const std::exception &) {} -int MachineObject::command_ams_change_filament(int tray_id, int old_temp, int new_temp) -{ - json j; - j["print"]["command"] = "ams_change_filament"; - j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); - j["print"]["target"] = tray_id; - j["print"]["curr_temp"] = old_temp; - j["print"]["tar_temp"] = new_temp; return this->publish_json(j.dump()); } @@ -1818,28 +2004,6 @@ int MachineObject::command_ams_user_settings(int ams_id, bool start_read_opt, bo return this->publish_json(j.dump()); } -int MachineObject::command_ams_user_settings(int ams_id, AmsOptionType op, bool value) -{ - json j; - j["print"]["command"] = "ams_user_setting"; - j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); - j["print"]["ams_id"] = ams_id; - if (op == AmsOptionType::AMS_OP_STARTUP_READ) { - j["print"]["startup_read_option"] = value; - ams_power_on_flag = value; - } else if (op == AmsOptionType::AMS_OP_TRAY_READ) { - j["print"]["tray_read_option"] = value; - ams_insert_flag = value; - } else if (op == AmsOptionType::AMS_OP_CALIBRATE_REMAIN) { - j["print"]["calibrate_remain_flag"] = value; - ams_calibrate_remain_flag = value; - } else { - return -1; - } - ams_user_setting_hold_count = HOLD_COUNT_MAX; - return this->publish_json(j.dump()); -} - int MachineObject::command_ams_calibrate(int ams_id) { std::string gcode_cmd = (boost::format("M620 C%1% \n") % ams_id).str(); @@ -1847,16 +2011,29 @@ int MachineObject::command_ams_calibrate(int ams_id) return this->publish_gcode(gcode_cmd); } -int MachineObject::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 MachineObject::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) { - BOOST_LOG_TRIVIAL(info) << "command_ams_filament_settings, ams_id = " << ams_id << ", tray_id = " << tray_id << ", tray_color = " << tray_color + int tag_tray_id = 0; + int tag_ams_id = ams_id; + int tag_slot_id = slot_id; + + if (tag_ams_id == VIRTUAL_TRAY_ID) { + tag_tray_id = VIRTUAL_TRAY_ID; + tag_ams_id = 255; // TODO: Orca hack + } else { + tag_tray_id = tag_slot_id; + } + + + BOOST_LOG_TRIVIAL(info) << "command_ams_filament_settings, ams_id = " << tag_ams_id << ", slot_id = " << tag_slot_id << ", tray_id = " << tag_tray_id << ", tray_color = " << tray_color << ", tray_type = " << tray_type << ", filament_id = " << filament_id << ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max; json j; j["print"]["command"] = "ams_filament_setting"; j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); - j["print"]["ams_id"] = ams_id; - j["print"]["tray_id"] = tray_id; + j["print"]["ams_id"] = tag_ams_id; + j["print"]["slot_id"] = tag_slot_id; + j["print"]["tray_id"] = tag_tray_id; j["print"]["tray_info_idx"] = filament_id; j["print"]["setting_id"] = setting_id; // format "FFFFFFFF" RGBA @@ -2147,17 +2324,22 @@ int MachineObject::command_start_pa_calibration(const X1CCalibInfos &pa_data, in std::string filament_ids; for (int i = 0; i < pa_data.calib_datas.size(); ++i) { j["print"]["filaments"][i]["tray_id"] = pa_data.calib_datas[i].tray_id; + j["print"]["filaments"][i]["extruder_id"] = pa_data.calib_datas[i].extruder_id; j["print"]["filaments"][i]["bed_temp"] = pa_data.calib_datas[i].bed_temp; j["print"]["filaments"][i]["filament_id"] = pa_data.calib_datas[i].filament_id; j["print"]["filaments"][i]["setting_id"] = pa_data.calib_datas[i].setting_id; j["print"]["filaments"][i]["nozzle_temp"] = pa_data.calib_datas[i].nozzle_temp; + j["print"]["filaments"][i]["ams_id"] = pa_data.calib_datas[i].ams_id; + j["print"]["filaments"][i]["slot_id"] = pa_data.calib_datas[i].slot_id; + j["print"]["filaments"][i]["nozzle_id"] = generate_nozzle_id(pa_data.calib_datas[i].nozzle_volume_type,to_string_nozzle_diameter(pa_data.calib_datas[i].nozzle_diameter)).ToStdString(); + j["print"]["filaments"][i]["nozzle_diameter"] = to_string_nozzle_diameter(pa_data.calib_datas[i].nozzle_diameter); j["print"]["filaments"][i]["max_volumetric_speed"] = std::to_string(pa_data.calib_datas[i].max_volumetric_speed); if (i > 0) filament_ids += ","; filament_ids += pa_data.calib_datas[i].filament_id; } - BOOST_LOG_TRIVIAL(trace) << "extrusion_cali: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "extrusion_cali: " << j.dump(); try { json js; @@ -2188,6 +2370,11 @@ int MachineObject::command_set_pa_calibration(const std::vector & if (pa_calib_values[i].cali_idx >= 0) j["print"]["filaments"][i]["cali_idx"] = pa_calib_values[i].cali_idx; j["print"]["filaments"][i]["tray_id"] = pa_calib_values[i].tray_id; + j["print"]["filaments"][i]["extruder_id"] = pa_calib_values[i].extruder_id; + j["print"]["filaments"][i]["nozzle_id"] = generate_nozzle_id(pa_calib_values[i].nozzle_volume_type, to_string_nozzle_diameter(pa_calib_values[i].nozzle_diameter)).ToStdString(); + j["print"]["filaments"][i]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib_values[i].nozzle_diameter); + j["print"]["filaments"][i]["ams_id"] = pa_calib_values[i].ams_id; + j["print"]["filaments"][i]["slot_id"] = pa_calib_values[i].slot_id; j["print"]["filaments"][i]["filament_id"] = pa_calib_values[i].filament_id; j["print"]["filaments"][i]["setting_id"] = pa_calib_values[i].setting_id; j["print"]["filaments"][i]["name"] = pa_calib_values[i].name; @@ -2198,7 +2385,7 @@ int MachineObject::command_set_pa_calibration(const std::vector & j["print"]["filaments"][i]["n_coef"] = "0.0"; } - BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_set: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "extrusion_cali_set: " << j.dump(); return this->publish_json(j.dump()); } @@ -2210,25 +2397,32 @@ int MachineObject::command_delete_pa_calibration(const PACalibIndexInfo& pa_cali json j; j["print"]["command"] = "extrusion_cali_del"; j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + j["print"]["extruder_id"] = pa_calib.extruder_id; + j["print"]["nozzle_id"] = generate_nozzle_id(pa_calib.nozzle_volume_type, to_string_nozzle_diameter(pa_calib.nozzle_diameter)).ToStdString(); j["print"]["filament_id"] = pa_calib.filament_id; j["print"]["cali_idx"] = pa_calib.cali_idx; j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib.nozzle_diameter); - BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_del: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "extrusion_cali_del: " << j.dump(); return this->publish_json(j.dump()); } -int MachineObject::command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id) +int MachineObject::command_get_pa_calibration_tab(const PACalibExtruderInfo &calib_info) { reset_pa_cali_history_result(); json j; j["print"]["command"] = "extrusion_cali_get"; j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); - j["print"]["filament_id"] = filament_id; - j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter); - - BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump(); + j["print"]["filament_id"] = calib_info.filament_id; + if (calib_info.use_extruder_id) + j["print"]["extruder_id"] = calib_info.extruder_id; + if (calib_info.use_nozzle_volume_type) + j["print"]["nozzle_id"] = generate_nozzle_id(calib_info.nozzle_volume_type, to_string_nozzle_diameter(calib_info.nozzle_diameter)).ToStdString(); + j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(calib_info.nozzle_diameter); + + BOOST_LOG_TRIVIAL(info) << "extrusion_cali_get: " << j.dump(); + request_tab_from_bbs = true; return this->publish_json(j.dump()); } @@ -2239,7 +2433,7 @@ int MachineObject::command_get_pa_calibration_result(float nozzle_diameter) j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter); - BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get_result: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "extrusion_cali_get_result: " << j.dump(); return this->publish_json(j.dump()); } @@ -2249,11 +2443,13 @@ int MachineObject::commnad_select_pa_calibration(const PACalibIndexInfo& pa_cali j["print"]["command"] = "extrusion_cali_sel"; j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["tray_id"] = pa_calib_info.tray_id; + j["print"]["ams_id"] = pa_calib_info.ams_id; + j["print"]["slot_id"] = pa_calib_info.slot_id; j["print"]["cali_idx"] = pa_calib_info.cali_idx; j["print"]["filament_id"] = pa_calib_info.filament_id; j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib_info.nozzle_diameter); - BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_sel: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "extrusion_cali_sel: " << j.dump(); return this->publish_json(j.dump()); } @@ -2283,7 +2479,7 @@ int MachineObject::command_start_flow_ratio_calibration(const X1CCalibInfos& cal filament_ids += calib_data.calib_datas[i].filament_id; } - BOOST_LOG_TRIVIAL(trace) << "flowrate_cali: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "flowrate_cali: " << j.dump(); return this->publish_json(j.dump()); } return -1; @@ -2296,7 +2492,7 @@ int MachineObject::command_get_flow_ratio_calibration_result(float nozzle_diamet j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter); - BOOST_LOG_TRIVIAL(trace) << "flowrate_get_result: " << j.dump(); + BOOST_LOG_TRIVIAL(info) << "flowrate_get_result: " << j.dump(); return this->publish_json(j.dump()); } @@ -2514,7 +2710,6 @@ void MachineObject::reset() last_mc_print_stage = -1; m_new_ver_list_exist = false; extruder_axis_status = LOAD; - nozzle_diameter = 0.0f; network_wired = false; dev_connection_name = ""; subscribe_counter = 3; @@ -2623,29 +2818,38 @@ bool MachineObject::is_camera_busy_off() return false; } -int MachineObject::publish_json(std::string json_str, int qos) +int MachineObject::publish_json(std::string json_str, int qos, int flag) { + int rtn = 0; if (is_lan_mode_printer()) { - return local_publish_json(json_str, qos); + rtn = local_publish_json(json_str, qos, flag); } else { - return cloud_publish_json(json_str, qos); + rtn = cloud_publish_json(json_str, qos, flag); } + + if (rtn == 0) { + BOOST_LOG_TRIVIAL(info) << "publish_json: " << json_str << " code: " << rtn; + } else { + BOOST_LOG_TRIVIAL(error) << "publish_json: " << json_str << " code: " << rtn; + } + + return rtn; } -int MachineObject::cloud_publish_json(std::string json_str, int qos) +int MachineObject::cloud_publish_json(std::string json_str, int qos, int flag) { int result = -1; if (m_agent) - result = m_agent->send_message(dev_id, json_str, qos); + result = m_agent->send_message(dev_id, json_str, qos, flag); return result; } -int MachineObject::local_publish_json(std::string json_str, int qos) +int MachineObject::local_publish_json(std::string json_str, int qos, int flag) { int result = -1; if (m_agent) { - result = m_agent->send_message_to_printer(dev_id, json_str, qos); + result = m_agent->send_message_to_printer(dev_id, json_str, qos, flag); } return result; } @@ -2683,6 +2887,11 @@ static ENUM enum_index_of(char const *key, char const **enum_names, int enum_cou int MachineObject::parse_json(std::string payload, bool key_field_only) { +#ifdef ORCA_NETWORK_DEBUG + BOOST_LOG_TRIVIAL(info) << "parse_json: payload = " << payload; + flush_logs(); +#endif + parse_msg_count++; std::chrono::system_clock::time_point clock_start = std::chrono::system_clock::now(); this->set_online_state(true); @@ -2693,10 +2902,24 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) /* update last received time */ last_update_time = std::chrono::system_clock::now(); + json j_pre; + bool parse_ok = false; + try { + j_pre = json::parse(payload); + parse_ok = true; + } + catch(...) { + parse_ok = false; + /* post process payload */ + sanitizeToUtf8(payload); + BOOST_LOG_TRIVIAL(info) << "parse_json: sanitize to utf8"; + } + try { bool restored_json = false; json j; - json j_pre = json::parse(payload); + if (!parse_ok) + j_pre = json::parse(payload); CNumericLocalesSetter locales_setter; if (j_pre.empty()) { return 0; @@ -2734,7 +2957,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) else { if (!printer_type.empty() && connection_type() == "lan") print_json.load_compatible_settings(printer_type, ""); - print_json.diff2all_base_reset(j_pre); + print_json.diff2all_base_reset(j_pre); } } } @@ -2844,15 +3067,20 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) for (auto it = j_module.begin(); it != j_module.end(); it++) { ModuleVersionInfo ver_info; ver_info.name = (*it)["name"].get(); + if ((*it).contains("product_name")) + ver_info.product_name = wxString::FromUTF8((*it)["product_name"].get()); if ((*it).contains("sw_ver")) ver_info.sw_ver = (*it)["sw_ver"].get(); + if ((*it).contains("sw_new_ver")) + ver_info.sw_new_ver = (*it)["sw_new_ver"].get(); if ((*it).contains("sn")) ver_info.sn = (*it)["sn"].get(); if ((*it).contains("hw_ver")) ver_info.hw_ver = (*it)["hw_ver"].get(); if((*it).contains("flag")) ver_info.firmware_status= (*it)["flag"].get(); - module_vers.emplace(ver_info.name, ver_info); + + store_version_info(ver_info); if (ver_info.name == "ota") { NetworkAgent* agent = GUI::wxGetApp().getAgent(); if (agent) { @@ -2953,7 +3181,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj.contains("support_flow_calibration")) { if (jj["support_flow_calibration"].is_boolean()) { - is_support_flow_calibration = jj["support_flow_calibration"].get(); + is_support_auto_flow_calibration = jj["support_flow_calibration"].get(); } } @@ -3022,11 +3250,11 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } - //if (jj.contains("support_filament_tangle_detect")) { - // if (jj["support_filament_tangle_detect"].is_boolean()) { - // is_support_filament_tangle_detect = jj["support_filament_tangle_detect"].get(); - // } - //} + if (jj.contains("support_filament_tangle_detect")) { + if (jj["support_filament_tangle_detect"].is_boolean()) { + is_support_filament_tangle_detect = jj["support_filament_tangle_detect"].get(); + } + } if (jj.contains("support_1080dpi")) { if (jj["support_1080dpi"].is_boolean()) { @@ -3157,13 +3385,26 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj["print_error"].is_number()) print_error = jj["print_error"].get(); } + + if (jj.contains("sdcard")) { + if (jj["sdcard"].get()) + sdcard_state = MachineObject::SdcardState::HAS_SDCARD_NORMAL; + else + sdcard_state = MachineObject::SdcardState::NO_SDCARD; + } else { + sdcard_state = MachineObject::SdcardState::NO_SDCARD; + } + if (!key_field_only) { if (jj.contains("home_flag")) { home_flag = jj["home_flag"].get(); parse_status(home_flag); } + + /*the param is invalid in np for Yeshu*/ if (jj.contains("hw_switch_state")) { hw_switch_state = jj["hw_switch_state"].get(); + m_extder_data.extders[MAIN_NOZZLE_ID].ext_has_filament = hw_switch_state; } if (jj.contains("mc_print_line_number")) { if (jj["mc_print_line_number"].is_string() && !jj["mc_print_line_number"].is_null()) @@ -3174,6 +3415,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj.contains("flag3")) { int flag3 = jj["flag3"].get(); is_support_filament_setting_inprinting = get_flag_bits(flag3, 3); + is_enable_ams_np = get_flag_bits(flag3, 9); } } if (!key_field_only) { @@ -3309,7 +3551,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) curr_task->task_progress = mc_print_percent; curr_task->printing_status = print_status; curr_task->task_id = jj["subtask_id"].get(); - } } @@ -3335,12 +3576,16 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } if (jj.contains("nozzle_temper")) { if (jj["nozzle_temper"].is_number()) { - nozzle_temp = jj["nozzle_temper"].get(); + if (m_extder_data.extders.size() == 1) { + m_extder_data.extders[MAIN_NOZZLE_ID].temp = jj["nozzle_temper"].get(); + } } } if (jj.contains("nozzle_target_temper")) { if (jj["nozzle_target_temper"].is_number()) { - nozzle_temp_target = jj["nozzle_target_temper"].get(); + if (m_extder_data.extders.size() == 1) { + m_extder_data.extders[MAIN_NOZZLE_ID].target_temp = jj["nozzle_target_temper"].get(); + } } } if (jj.contains("chamber_temper")) { @@ -3397,7 +3642,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj.contains("heatbreak_fan_speed")) { heatbreak_fan_speed = stoi(jj["heatbreak_fan_speed"].get()); } - + /* parse speed */ try { if (jj.contains("spd_lvl")) { @@ -3437,12 +3682,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (!key_field_only) { /*get filam_bak*/ try { + m_extder_data.extders[MAIN_NOZZLE_ID].filam_bak.clear(); + if (jj.contains("filam_bak")) { is_support_show_filament_backup = true; - filam_bak.clear(); if (jj["filam_bak"].is_array()) { for (auto it = jj["filam_bak"].begin(); it != jj["filam_bak"].end(); it++) { - filam_bak.push_back(it.value().get()); + const auto& filam_bak_val = it.value().get(); + m_extder_data.extders[MAIN_NOZZLE_ID].filam_bak.push_back(filam_bak_val); } } } @@ -3493,21 +3740,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) catch (...) { ; } - // media - try { - if (jj.contains("sdcard")) { - if (jj["sdcard"].get()) - sdcard_state = MachineObject::SdcardState::HAS_SDCARD_NORMAL; - else - sdcard_state = MachineObject::SdcardState::NO_SDCARD; - } else { - //do not check sdcard if no sdcard field - sdcard_state = MachineObject::SdcardState::NO_SDCARD; - } - } - catch (...) { - ; - } } #pragma endregion if (!key_field_only) { @@ -3516,15 +3748,17 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (nozzle_setting_hold_count > 0) { nozzle_setting_hold_count--; } else { + float nozzle_diameter = 0.0f; if (jj["nozzle_diameter"].is_number_float()) { nozzle_diameter = jj["nozzle_diameter"].get(); } else if (jj["nozzle_diameter"].is_string()) { nozzle_diameter = string_to_float(jj["nozzle_diameter"].get()); } - } - + if (nozzle_diameter == 0.0f) {m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter = 0.0f;} + else { m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter = round(nozzle_diameter * 10) / 10;} + } } } catch(...) { @@ -3539,13 +3773,16 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } else { if (jj["nozzle_type"].is_string()) { - nozzle_type = jj["nozzle_type"].get(); + auto nozzle_type = jj["nozzle_type"].get(); + if (nozzle_type.empty()) { + m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type = NozzleType::ntUndefine; + } + else { + m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type = NozzleTypeStrToEumn[nozzle_type]; + } } } } - else { - nozzle_type = ""; - } } catch (...) { ; @@ -3561,7 +3798,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) upgrade_progress = jj["upgrade_state"]["progress"].get(); } if (jj["upgrade_state"].contains("new_version_state")) upgrade_new_version = jj["upgrade_state"]["new_version_state"].get() == 1 ? true : false; - if (jj["upgrade_state"].contains("ams_new_version_number")) + if (!check_enable_np(jj) && jj["upgrade_state"].contains("ams_new_version_number"))/* is not used in new np, by AP*/ ams_new_version_number = jj["upgrade_state"]["ams_new_version_number"].get(); if (jj["upgrade_state"].contains("ota_new_version_number")) ota_new_version_number = jj["upgrade_state"]["ota_new_version_number"].get(); @@ -3706,22 +3943,18 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) liveview_local = enum_index_of(ipcam["liveview"].value("local", "none").c_str(), local_protos, 5, LiveviewLocal::LVL_None); char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"}; liveview_remote = enum_index_of(ipcam["liveview"].value("remote", "none").c_str(), remote_protos, 4, LiveviewRemote::LVR_None); - if (is_support_agora) - liveview_remote = liveview_remote == LVR_None ? LVR_Agora : liveview_remote == LVR_Tutk ? LVR_TutkAgora : liveview_remote; } if (ipcam.contains("file")) { char const *local_protos[] = {"none", "local"}; file_local = enum_index_of(ipcam["file"].value("local", "none").c_str(), local_protos, 2, FileLocal::FL_None); char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"}; file_remote = enum_index_of(ipcam["file"].value("remote", "none").c_str(), remote_protos, 4, FileRemote::FR_None); - if (is_support_agora) - file_remote = file_remote == FR_None ? FR_Agora : file_remote == FR_Tutk ? FR_TutkAgora : file_remote; file_model_download = ipcam["file"].value("model_download", "disabled") == "enabled"; } virtual_camera = ipcam.value("virtual_camera", "disabled") == "enabled"; if (ipcam.contains("rtsp_url")) { local_rtsp_url = ipcam["rtsp_url"].get(); - liveview_local = local_rtsp_url.empty() ? LVL_None : local_rtsp_url == "disable" + liveview_local = local_rtsp_url.empty() ? LVL_None : local_rtsp_url == "disable" ? LVL_Disable : boost::algorithm::starts_with(local_rtsp_url, "rtsps") ? LVL_Rtsps : LVL_Rtsp; } if (ipcam.contains("tutk_server")) { @@ -3827,14 +4060,8 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) catch (...) { ; } - PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; - std::ostringstream stream; - stream << std::fixed << std::setprecision(1) << nozzle_diameter; - std::string nozzle_diameter_str = stream.str(); - if (m_printer_preset_name.find(nozzle_diameter_str + " nozzle") == std::string::npos) - update_printer_preset_name(nozzle_diameter_str); + update_printer_preset_name(); update_filament_list(); - std::set need_checked_filament_id; if (jj.contains("ams")) { if (jj["ams"].contains("ams")) { long int last_ams_exist_bits = ams_exist_bits; @@ -3854,7 +4081,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } if (jj["ams"].contains("tray_reading_bits")) { tray_reading_bits = stol(jj["ams"]["tray_reading_bits"].get(), nullptr, 16); - ams_support_use_ams = true; } if (jj["ams"].contains("tray_is_bbl_bits")) { tray_is_bbl_bits = stol(jj["ams"]["tray_is_bbl_bits"].get(), nullptr, 16); @@ -3871,16 +4097,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } if (jj["ams"].contains("ams_rfid_status")) ams_rfid_status = jj["ams"]["ams_rfid_status"].get(); - if (jj["ams"].contains("humidity")) { - if (jj["ams"]["humidity"].is_string()) { - std::string humidity_str = jj["ams"]["humidity"].get(); - try { - ams_humidity = atoi(humidity_str.c_str()); - } catch (...) { - ; - } - } - } if (jj["ams"].contains("insert_flag") || jj["ams"].contains("power_on_flag") || jj["ams"].contains("calibrate_remain_flag")) { @@ -3915,23 +4131,31 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) for (auto it = amsList.begin(); it != amsList.end(); it++) { ams_id_set.insert(it->first); } + for (auto it = j_ams.begin(); it != j_ams.end(); it++) { if (!it->contains("id")) continue; std::string ams_id = (*it)["id"].get(); + + int nozzle_id = MAIN_NOZZLE_ID; // Default nozzle id + int type_id = 1; // 0:dummy 1:ams 2:ams-lite 3:n3f 4:n3s + + /*ams info*/ + if (it->contains("info")) { + std::string info = (*it)["info"].get(); + type_id = get_flag_bits(info, 0, 4); + nozzle_id = get_flag_bits(info, 8, 4); + } + + /*AMS without initialization*/ + if (nozzle_id == 0xE) { + continue; + } + ams_id_set.erase(ams_id); Ams* curr_ams = nullptr; auto ams_it = amsList.find(ams_id); if (ams_it == amsList.end()) { - Ams* new_ams = new Ams(ams_id); - try { - if (!ams_id.empty()) { - int ams_id_int = atoi(ams_id.c_str()); - new_ams->is_exists = (ams_exist_bits & (1 << ams_id_int)) != 0 ? true : false; - } - } - catch (...) { - ; - } + Ams* new_ams = new Ams(ams_id, nozzle_id, type_id); amsList.insert(std::make_pair(ams_id, new_ams)); // new ams added event curr_ams = new_ams; @@ -3940,6 +4164,30 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } if (!curr_ams) continue; + /*set ams type flag*/ + curr_ams->type = type_id; + + + /*set ams exist flag*/ + try { + if (!ams_id.empty()) { + int ams_id_int = atoi(ams_id.c_str()); + + if (type_id < 4) { + curr_ams->is_exists = (ams_exist_bits & (1 << ams_id_int)) != 0 ? true : false; + } else { + curr_ams->is_exists = get_flag_bits(ams_exist_bits, 4 + (ams_id_int - 128)); + } + } + } catch (...) { + ; + } + + if (it->contains("dry_time") && (*it)["dry_time"].is_number()) + { + curr_ams->left_dry_time = (*it)["dry_time"].get(); + } + if (it->contains("humidity")) { std::string humidity = (*it)["humidity"].get(); @@ -3950,7 +4198,55 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) ; } } - + + if (it->contains("humidity_raw")) + { + std::string humidity_raw = (*it)["humidity_raw"].get(); + + try { + curr_ams->humidity_raw = atoi(humidity_raw.c_str()); + } catch (...) { + ; + } + + if (curr_ams->humidity_raw != -1) + { + if (curr_ams->humidity_raw < 20) + { + curr_ams->humidity = 5; + } + else if (curr_ams->humidity_raw < 40) + { + curr_ams->humidity = 4; + } + else if (curr_ams->humidity_raw < 60) + { + curr_ams->humidity = 3; + } + else if (curr_ams->humidity_raw < 80) + { + curr_ams->humidity = 2; + } + else + { + curr_ams->humidity = 1; + } + } + } + + + if (it->contains("temp")) + { + std::string temp = (*it)["temp"].get(); + try + { + curr_ams->current_temperature = string_to_float(temp); + } + catch (...) + { + curr_ams->current_temperature = INVALID_AMS_TEMPERATURE; + } + } if (it->contains("tray")) { std::set tray_id_set; @@ -3996,26 +4292,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } else { curr_tray->type = type; } - // settings_id is not exist in filament_list - if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && - m_filament_list.find(curr_tray->setting_id) == m_filament_list.end()) { - if (m_checked_filament.find(curr_tray->setting_id) == m_checked_filament.end()) { - need_checked_filament_id.insert(curr_tray->setting_id); - wxColour color = *wxWHITE; - char col_buf[10]; - sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); - try { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ - << " ams settings_id is not exist in filament_list and reset, ams_id: " << ams_id - << " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id; - this->command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), "", "", std::string(col_buf), "", 0, 0); - continue; - } catch (...) { - BOOST_LOG_TRIVIAL(info) - << __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id; - } - } - } } else { curr_tray->setting_id = ""; curr_tray->type = ""; @@ -4063,29 +4339,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) curr_tray->nozzle_temp_min = (*tray_it)["nozzle_temp_min"].get(); else curr_tray->nozzle_temp_min = ""; - if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") { - if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) { - need_checked_filament_id.insert(vt_tray.setting_id); - try { - std::string preset_setting_id; - bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray( - MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id, - curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id); - if (!is_equation) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ - << " ams filament is not match min max temp and reset, ams_id: " << ams_id - << " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id; - command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id, - curr_tray->color, curr_tray->type, - std::stoi(curr_tray->nozzle_temp_min), - std::stoi(curr_tray->nozzle_temp_max)); - } - continue; - } catch (...) { - BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id"<contains("xcam_info")) curr_tray->xcam_info = (*tray_it)["xcam_info"].get(); else @@ -4107,7 +4360,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } } - + if (tray_it->contains("remain")) { curr_tray->remain = (*tray_it)["remain"].get(); } else { @@ -4119,7 +4372,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (!ams_id.empty() && !curr_tray->id.empty()) { ams_id_int = atoi(ams_id.c_str()); tray_id_int = atoi(curr_tray->id.c_str()); - curr_tray->is_exists = (tray_exist_bits & (1 << (ams_id_int * 4 + tray_id_int))) != 0 ? true : false; + + if (type_id < 4) { + curr_tray->is_exists = (tray_exist_bits & (1 << (ams_id_int * 4 + tray_id_int))) != 0 ? true : false; + } + else { + curr_tray->is_exists = get_flag_bits(tray_exist_bits, 16 + (ams_id_int - 128)); + } + } } catch (...) { @@ -4174,149 +4434,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (!key_field_only) { try { if (jj.contains("vt_tray")) { - if (jj["vt_tray"].contains("id")) - vt_tray.id = jj["vt_tray"]["id"].get(); - auto curr_time = std::chrono::system_clock::now(); - auto diff = std::chrono::duration_cast(curr_time - extrusion_cali_set_hold_start); - if (diff.count() > HOLD_TIMEOUT || diff.count() < 0 - || extrusion_cali_set_tray_id != VIRTUAL_TRAY_ID) { - if (jj["vt_tray"].contains("k")) - vt_tray.k = jj["vt_tray"]["k"].get(); - if (jj["vt_tray"].contains("n")) - vt_tray.n = jj["vt_tray"]["n"].get(); - } - ams_support_virtual_tray = true; - - if (vt_tray.hold_count > 0) { - vt_tray.hold_count--; - } else { - if (jj["vt_tray"].contains("tag_uid")) - vt_tray.tag_uid = jj["vt_tray"]["tag_uid"].get(); - else - vt_tray.tag_uid = "0"; - if (jj["vt_tray"].contains("tray_info_idx") && jj["vt_tray"].contains("tray_type")) { - vt_tray.setting_id = jj["vt_tray"]["tray_info_idx"].get(); - //std::string type = jj["vt_tray"]["tray_type"].get(); - std::string type = setting_id_to_type(vt_tray.setting_id, jj["vt_tray"]["tray_type"].get()); - if (vt_tray.setting_id == "GFS00") { - vt_tray.type = "PLA-S"; - } - else if (vt_tray.setting_id == "GFS01") { - vt_tray.type = "PA-S"; - } - else { - vt_tray.type = type; - } - if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && - m_filament_list.find(vt_tray.setting_id) == m_filament_list.end()) { - if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) { - need_checked_filament_id.insert(vt_tray.setting_id); - wxColour color = *wxWHITE; - char col_buf[10]; - sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); - try { - BOOST_LOG_TRIVIAL(info) << "vt_tray.setting_id is not exist in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id; - this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0); - } catch (...) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id; - } - } - } - } - else { - vt_tray.setting_id = ""; - vt_tray.type = ""; - } - if (jj["vt_tray"].contains("tray_sub_brands")) - vt_tray.sub_brands = jj["vt_tray"]["tray_sub_brands"].get(); - else - vt_tray.sub_brands = ""; - if (jj["vt_tray"].contains("tray_weight")) - vt_tray.weight = jj["vt_tray"]["tray_weight"].get(); - else - vt_tray.weight = ""; - if (jj["vt_tray"].contains("tray_diameter")) - vt_tray.diameter = jj["vt_tray"]["tray_diameter"].get(); - else - vt_tray.diameter = ""; - if (jj["vt_tray"].contains("tray_temp")) - vt_tray.temp = jj["vt_tray"]["tray_temp"].get(); - else - vt_tray.temp = ""; - if (jj["vt_tray"].contains("tray_time")) - vt_tray.time = jj["vt_tray"]["tray_time"].get(); - else - vt_tray.time = ""; - if (jj["vt_tray"].contains("bed_temp_type")) - vt_tray.bed_temp_type = jj["vt_tray"]["bed_temp_type"].get(); - else - vt_tray.bed_temp_type = ""; - if (jj["vt_tray"].contains("bed_temp")) - vt_tray.bed_temp = jj["vt_tray"]["bed_temp"].get(); - else - vt_tray.bed_temp = ""; - if (jj["vt_tray"].contains("tray_color")) { - auto color = jj["vt_tray"]["tray_color"].get(); - vt_tray.update_color_from_str(color); - } else { - vt_tray.color = ""; - } - if (jj["vt_tray"].contains("nozzle_temp_max")) - vt_tray.nozzle_temp_max = jj["vt_tray"]["nozzle_temp_max"].get(); - else - vt_tray.nozzle_temp_max = ""; - if (jj["vt_tray"].contains("nozzle_temp_min")) - vt_tray.nozzle_temp_min = jj["vt_tray"]["nozzle_temp_min"].get(); - else - vt_tray.nozzle_temp_min = ""; - if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") { - if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) { - need_checked_filament_id.insert(vt_tray.setting_id); - try { - std::string preset_setting_id; - bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray( - MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid, - vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id); - if (!is_equation) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " vt_tray filament is not match min max temp and reset, filament_id: " << vt_tray.setting_id; - command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type, - std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max)); - } - } catch (...) { - BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id; - } - } - } - if (jj["vt_tray"].contains("xcam_info")) - vt_tray.xcam_info = jj["vt_tray"]["xcam_info"].get(); - else - vt_tray.xcam_info = ""; - if (jj["vt_tray"].contains("tray_uuid")) - vt_tray.uuid = jj["vt_tray"]["tray_uuid"].get(); - else - vt_tray.uuid = "0"; + auto main_slot = parse_vt_tray(jj["vt_tray"].get()); + main_slot.id = std::to_string(VIRTUAL_TRAY_ID); - if (jj["vt_tray"].contains("cali_idx")) - vt_tray.cali_idx = jj["vt_tray"]["cali_idx"].get(); - else - vt_tray.cali_idx = -1; - vt_tray.cols.clear(); - if (jj["vt_tray"].contains("cols")) { - if (jj["vt_tray"].is_array()) { - for (auto it = jj["vt_tray"].begin(); it != jj["vt_tray"].end(); it++) { - vt_tray.cols.push_back(it.value().get()); - } - } - } - - if (jj["vt_tray"].contains("remain")) { - vt_tray.remain = jj["vt_tray"]["remain"].get(); - } - else { - vt_tray.remain = -1; - } - } - } else { + is_ams_need_update |= vt_tray != main_slot; + vt_tray = main_slot; + } + else { ams_support_virtual_tray = false; is_support_extrusion_cali = false; } @@ -4325,8 +4449,11 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) ; } } - for (auto &filament_id : need_checked_filament_id) - m_checked_filament.insert(filament_id); + + /*parse new print data*/ + try { + parse_new_info(jj); + } catch (...) {} #pragma endregion } else if (jj["command"].get() == "gcode_line") { //ack of gcode_line @@ -4354,8 +4481,10 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } else if (jj["command"].get() == "ams_filament_setting" && !key_field_only) { if (jj.contains("result") && jj.contains("reason")) { if (jj["result"].get() == "fail") { - auto err_code = jj["err_code"].get(); - print_error = err_code; + if (jj.contains("err_code")) { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } } } @@ -4489,14 +4618,16 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) info = reason; } GUI::wxGetApp().push_notification(info, _L("Calibration error"), UserNotificationStyle::UNS_WARNING_CONFIRM); - BOOST_LOG_TRIVIAL(trace) << cali_mode << " result fail, reason = " << reason; + BOOST_LOG_TRIVIAL(info) << cali_mode << " result fail, reason = " << reason; } } } else if (jj["command"].get() == "extrusion_cali_set") { if (jj.contains("result") && jj.contains("reason")) { if (jj["result"].get() == "fail") { - auto err_code = jj["err_code"].get(); - print_error = err_code; + if (jj.contains("err_code")) { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } } } #ifdef CALI_DEBUG @@ -4545,8 +4676,10 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) else if (jj["command"].get() == "extrusion_cali_sel") { if (jj.contains("result") && jj.contains("reason")) { if (jj["result"].get() == "fail") { - auto err_code = jj["err_code"].get(); - print_error = err_code; + if (jj.contains("err_code")) { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } } } @@ -4589,100 +4722,110 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } } - } + } else if (jj["command"].get() == "extrusion_cali_get") { - if (jj.contains("result") && jj.contains("reason")) { - if (jj["result"].get() == "fail") { - auto err_code = jj["err_code"].get(); - print_error = err_code; + std::string str = jj.dump(); + if (request_tab_from_bbs) { + BOOST_LOG_TRIVIAL(info) << "bbs extrusion_cali_get: " << str; + request_tab_from_bbs = false; + reset_pa_cali_history_result(); + bool is_succeed = true; + if (jj.contains("result") && jj.contains("reason")) { + if (jj["result"].get() == "fail") { + if (jj.contains("err_code")) { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } + is_succeed = false; + } } - } - reset_pa_cali_history_result(); - has_get_pa_calib_tab = true; - - if (jj.contains("nozzle_diameter")) { - if (jj["nozzle_diameter"].is_number_float()) { - pa_calib_tab_nozzle_dia = jj["nozzle_diameter"].get(); - } - else if (jj["nozzle_diameter"].is_string()) { - pa_calib_tab_nozzle_dia = string_to_float(jj["nozzle_diameter"].get()); - } - else { - assert(false); + if (is_succeed) { + last_cali_version = cali_version; + has_get_pa_calib_tab = true; } - } - else { - assert(false); - } - if (jj.contains("filaments") && jj["filaments"].is_array()) { - try { -#ifdef CALI_DEBUG - std::string str = jj.dump(); - BOOST_LOG_TRIVIAL(info) << "extrusion_cali_get: " << str; -#endif + if (jj.contains("filaments") && jj["filaments"].is_array()) { + try { + for (auto it = jj["filaments"].begin(); it != jj["filaments"].end(); it++) { + PACalibResult pa_calib_result; + pa_calib_result.filament_id = (*it)["filament_id"].get(); + pa_calib_result.name = (*it)["name"].get(); + pa_calib_result.cali_idx = (*it)["cali_idx"].get(); + + if ((*it).contains("setting_id")) { + pa_calib_result.setting_id = (*it)["setting_id"].get(); + } - for (auto it = jj["filaments"].begin(); it != jj["filaments"].end(); it++) { - PACalibResult pa_calib_result; - pa_calib_result.filament_id = (*it)["filament_id"].get(); - pa_calib_result.setting_id = (*it)["setting_id"].get(); - pa_calib_result.name = (*it)["name"].get(); - pa_calib_result.cali_idx = (*it)["cali_idx"].get(); + if ((*it).contains("extruder_id")) { + pa_calib_result.extruder_id = (*it)["extruder_id"].get(); + } - if (jj["nozzle_diameter"].is_number_float()) { - pa_calib_result.nozzle_diameter = jj["nozzle_diameter"].get(); - } else if (jj["nozzle_diameter"].is_string()) { - pa_calib_result.nozzle_diameter = string_to_float(jj["nozzle_diameter"].get()); - } + if ((*it).contains("nozzle_id")) { + pa_calib_result.nozzle_volume_type = convert_to_nozzle_type((*it)["nozzle_id"].get()); + } - if ((*it)["k_value"].is_number_float()) - pa_calib_result.k_value = (*it)["k_value"].get(); - else if ((*it)["k_value"].is_string()) - pa_calib_result.k_value = string_to_float((*it)["k_value"].get()); + if (jj["nozzle_diameter"].is_number_float()) { + pa_calib_result.nozzle_diameter = jj["nozzle_diameter"].get(); + } else if (jj["nozzle_diameter"].is_string()) { + pa_calib_result.nozzle_diameter = string_to_float(jj["nozzle_diameter"].get()); + } - if ((*it)["n_coef"].is_number_float()) - pa_calib_result.n_coef = (*it)["n_coef"].get(); - else if ((*it)["n_coef"].is_string()) - pa_calib_result.n_coef = string_to_float((*it)["n_coef"].get()); + if ((*it)["k_value"].is_number_float()) + pa_calib_result.k_value = (*it)["k_value"].get(); + else if ((*it)["k_value"].is_string()) + pa_calib_result.k_value = string_to_float((*it)["k_value"].get()); - if (check_pa_result_validation(pa_calib_result)) - pa_calib_tab.push_back(pa_calib_result); - else { - BOOST_LOG_TRIVIAL(info) << "pa result is invalid"; + if ((*it)["n_coef"].is_number_float()) + pa_calib_result.n_coef = (*it)["n_coef"].get(); + else if ((*it)["n_coef"].is_string()) + pa_calib_result.n_coef = string_to_float((*it)["n_coef"].get()); + + if (check_pa_result_validation(pa_calib_result)) + pa_calib_tab.push_back(pa_calib_result); + else { + BOOST_LOG_TRIVIAL(info) << "pa result is invalid"; + } } - } - } - catch (...) { + } + catch (...) { + } } + // notify cali history to update + } else { + BOOST_LOG_TRIVIAL(info) << "printer extrusion_cali_get: " << str; } - // notify cali history to update } else if (jj["command"].get() == "extrusion_cali_get_result") { + std::string str = jj.dump(); + BOOST_LOG_TRIVIAL(info) << "extrusion_cali_get_result: " << str; + reset_pa_cali_result(); + bool is_succeed = true; if (jj.contains("result") && jj.contains("reason")) { if (jj["result"].get() == "fail") { - auto err_code = jj["err_code"].get(); - print_error = err_code; + if (jj.contains("err_code")) { + auto err_code = jj["err_code"].get(); + print_error = err_code; + is_succeed = false; + } } } - reset_pa_cali_result(); - get_pa_calib_result = true; + if (is_succeed) + get_pa_calib_result = true; if (jj.contains("filaments") && jj["filaments"].is_array()) { try { -#ifdef CALI_DEBUG - std::string str = jj.dump(); - BOOST_LOG_TRIVIAL(info) << "extrusion_cali_get_result: " << str; -#endif - for (auto it = jj["filaments"].begin(); it != jj["filaments"].end(); it++) { PACalibResult pa_calib_result; pa_calib_result.tray_id = (*it)["tray_id"].get(); pa_calib_result.filament_id = (*it)["filament_id"].get(); - pa_calib_result.setting_id = (*it)["setting_id"].get(); + + if ((*it).contains("setting_id")) { + pa_calib_result.setting_id = (*it)["setting_id"].get(); + } if (jj["nozzle_diameter"].is_number_float()) { pa_calib_result.nozzle_diameter = jj["nozzle_diameter"].get(); @@ -4690,6 +4833,30 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) pa_calib_result.nozzle_diameter = string_to_float(jj["nozzle_diameter"].get()); } + if (it->contains("ams_id")) { + pa_calib_result.ams_id = (*it)["ams_id"].get(); + } else { + pa_calib_result.ams_id = 0; + } + + if (it->contains("slot_id")) { + pa_calib_result.slot_id = (*it)["slot_id"].get(); + } else { + pa_calib_result.slot_id = 0; + } + + if (it->contains("extruder_id")) { + pa_calib_result.extruder_id = (*it)["extruder_id"].get(); + } else { + pa_calib_result.extruder_id = -1; + } + + if (it->contains("nozzle_id")) { + pa_calib_result.nozzle_volume_type = convert_to_nozzle_type((*it)["nozzle_id"].get()); + } else { + pa_calib_result.nozzle_volume_type = NozzleVolumeType::nvtNormal; + } + if ((*it)["k_value"].is_number_float()) pa_calib_result.k_value = (*it)["k_value"].get(); else if ((*it)["k_value"].is_string()) @@ -4739,7 +4906,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (it->contains("confidence")) { flow_ratio_calib_result.confidence = (*it)["confidence"].get(); } else { - flow_ratio_calib_result.confidence = 0; + flow_ratio_calib_result.confidence = 0; } flow_ratio_results.push_back(flow_ratio_calib_result); @@ -4750,6 +4917,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } } + if (!key_field_only) { try { if (j.contains("camera")) { @@ -5176,18 +5344,462 @@ std::string MachineObject::get_string_from_fantype(FanType type) return ""; } +AmsTray MachineObject::parse_vt_tray(json vtray) +{ + auto vt_tray = AmsTray(std::to_string(VIRTUAL_TRAY_ID)); + + if (vtray.contains("id")) + vt_tray.id = vtray["id"].get(); + auto curr_time = std::chrono::system_clock::now(); + auto diff = std::chrono::duration_cast(curr_time - extrusion_cali_set_hold_start); + if (diff.count() > HOLD_TIMEOUT || diff.count() < 0 + || extrusion_cali_set_tray_id != VIRTUAL_TRAY_ID) { + if (vtray.contains("k")) + vt_tray.k = vtray["k"].get(); + if (vtray.contains("n")) + vt_tray.n = vtray["n"].get(); + } + ams_support_virtual_tray = true; + + if (vt_tray.hold_count > 0) { + vt_tray.hold_count--; + } + else { + if (vtray.contains("tag_uid")) + vt_tray.tag_uid = vtray["tag_uid"].get(); + else + vt_tray.tag_uid = "0"; + if (vtray.contains("tray_info_idx") && vtray.contains("tray_type")) { + vt_tray.setting_id = vtray["tray_info_idx"].get(); + //std::string type = vtray["tray_type"].get(); + std::string type = setting_id_to_type(vt_tray.setting_id, vtray["tray_type"].get()); + if (vt_tray.setting_id == "GFS00") { + vt_tray.type = "PLA-S"; + } + else if (vt_tray.setting_id == "GFS01") { + vt_tray.type = "PA-S"; + } + else { + vt_tray.type = type; + } + } + else { + vt_tray.setting_id = ""; + vt_tray.type = ""; + } + if (vtray.contains("tray_sub_brands")) + vt_tray.sub_brands = vtray["tray_sub_brands"].get(); + else + vt_tray.sub_brands = ""; + if (vtray.contains("tray_weight")) + vt_tray.weight = vtray["tray_weight"].get(); + else + vt_tray.weight = ""; + if (vtray.contains("tray_diameter")) + vt_tray.diameter = vtray["tray_diameter"].get(); + else + vt_tray.diameter = ""; + if (vtray.contains("tray_temp")) + vt_tray.temp = vtray["tray_temp"].get(); + else + vt_tray.temp = ""; + if (vtray.contains("tray_time")) + vt_tray.time = vtray["tray_time"].get(); + else + vt_tray.time = ""; + if (vtray.contains("bed_temp_type")) + vt_tray.bed_temp_type = vtray["bed_temp_type"].get(); + else + vt_tray.bed_temp_type = ""; + if (vtray.contains("bed_temp")) + vt_tray.bed_temp = vtray["bed_temp"].get(); + else + vt_tray.bed_temp = ""; + if (vtray.contains("tray_color")) { + auto color = vtray["tray_color"].get(); + vt_tray.update_color_from_str(color); + } + else { + vt_tray.color = ""; + } + if (vtray.contains("nozzle_temp_max")) + vt_tray.nozzle_temp_max = vtray["nozzle_temp_max"].get(); + else + vt_tray.nozzle_temp_max = ""; + if (vtray.contains("nozzle_temp_min")) + vt_tray.nozzle_temp_min = vtray["nozzle_temp_min"].get(); + else + vt_tray.nozzle_temp_min = ""; + if (vtray.contains("xcam_info")) + vt_tray.xcam_info = vtray["xcam_info"].get(); + else + vt_tray.xcam_info = ""; + if (vtray.contains("tray_uuid")) + vt_tray.uuid = vtray["tray_uuid"].get(); + else + vt_tray.uuid = "0"; + + if (vtray.contains("cali_idx")) + vt_tray.cali_idx = vtray["cali_idx"].get(); + else + vt_tray.cali_idx = -1; + vt_tray.cols.clear(); + if (vtray.contains("cols")) { + if (vtray.is_array()) { + for (auto it = vtray.begin(); it != vtray.end(); it++) { + vt_tray.cols.push_back(it.value().get()); + } + } + } + + if (vtray.contains("remain")) { + vt_tray.remain = vtray["remain"].get(); + } + else { + vt_tray.remain = -1; + } + } + + return vt_tray; +} + +bool MachineObject::check_enable_np(const json& print) const +{ + if (print.contains("cfg") && print.contains("fun") && print.contains("aux") && print.contains("stat")) + { + return true; + } + + return false; +} + +void MachineObject::parse_new_info(json print) +{ + is_enable_np = check_enable_np(print); + if (!is_enable_np) + { + return; + } + + BOOST_LOG_TRIVIAL(info) << "using new print data for parsing"; + + /*cfg*/ + std::string cfg = print["cfg"].get(); + + BOOST_LOG_TRIVIAL(info) << "new print data cfg = " << cfg; + + if(!cfg.empty()){ + if (ams_user_setting_hold_count > 0) ams_user_setting_hold_count--; + if (camera_recording_hold_count > 0) camera_recording_hold_count--; + if (camera_resolution_hold_count > 0) camera_resolution_hold_count--; + if (camera_timelapse_hold_count > 0) camera_timelapse_hold_count--; + //if (xcam_buildplate_marker_hold_count > 0) xcam_buildplate_marker_hold_count--;first_layer_inspector + if (xcam_first_layer_hold_count > 0) xcam_first_layer_hold_count--; + if (xcam_ai_monitoring_hold_count > 0) xcam_ai_monitoring_hold_count--; + if (xcam_auto_recovery_hold_count > 0) xcam_auto_recovery_hold_count--; + if (ams_print_option_count > 0) ams_print_option_count--; + if (xcam_prompt_sound_hold_count > 0) xcam_prompt_sound_hold_count--; + if (xcam_filament_tangle_detect_count > 0)xcam_filament_tangle_detect_count--; + if (nozzle_setting_hold_count > 0)nozzle_setting_hold_count--; + + + + ams_insert_flag = get_flag_bits(cfg, 0); + ams_power_on_flag = get_flag_bits(cfg, 1); + upgrade_force_upgrade = get_flag_bits(cfg, 2); + camera_recording_when_printing = get_flag_bits(cfg, 3); + camera_resolution = get_flag_bits(cfg, 4) == 0 ? "720p" : "1080p"; + camera_timelapse = get_flag_bits(cfg, 5); + tutk_state = get_flag_bits(cfg, 6) == 1 ? "disable" : ""; + chamber_light = get_flag_bits(cfg, 7) == 1 ? LIGHT_EFFECT::LIGHT_EFFECT_ON : LIGHT_EFFECT::LIGHT_EFFECT_OFF; + printing_speed_lvl = (PrintingSpeedLevel)get_flag_bits(cfg, 8, 3); + //is_support_build_plate_marker_detect = get_flag_bits(cfg, 12); todo yangcong + + xcam_first_layer_inspector = get_flag_bits(cfg, 13); + + switch (get_flag_bits(cfg, 14, 2)) + { + case 0: + xcam_ai_monitoring_sensitivity = "never_halt"; + break; + case 1: + xcam_ai_monitoring_sensitivity = "low"; + break; + case 2: + xcam_ai_monitoring_sensitivity = "medium"; + break; + case 3: + xcam_ai_monitoring_sensitivity = "high"; + break; + } + + xcam_ai_monitoring = get_flag_bits(cfg, 16); + xcam_auto_recovery_step_loss = get_flag_bits(cfg, 17); + ams_calibrate_remain_flag = get_flag_bits(cfg, 18); + ams_auto_switch_filament_flag = get_flag_bits(cfg, 19); + xcam_allow_prompt_sound = get_flag_bits(cfg, 23); + xcam_filament_tangle_detect = get_flag_bits(cfg, 24); + nozzle_blob_detection_enabled = get_flag_bits(cfg, 25); + installed_upgrade_kit = get_flag_bits(cfg, 26); + } + + /*fun*/ + std::string fun = print["fun"].get(); + BOOST_LOG_TRIVIAL(info) << "new print data fun = " << fun; + + if (!fun.empty()) { + + is_support_agora = get_flag_bits(fun, 1); + if (is_support_agora) is_support_tunnel_mqtt = false; + + is_220V_voltage = get_flag_bits(fun, 3) == 0?false:true; + is_support_flow_calibration = get_flag_bits(fun, 6); + is_support_pa_calibration = get_flag_bits(fun, 7); + is_support_prompt_sound = get_flag_bits(fun, 8); + is_support_filament_tangle_detect = get_flag_bits(fun, 9); + is_support_motor_noise_cali = get_flag_bits(fun, 10); + is_support_user_preset = get_flag_bits(fun, 11); + is_support_nozzle_blob_detection = get_flag_bits(fun, 13); + is_support_upgrade_kit = get_flag_bits(cfg, 14); + is_support_command_homing = get_flag_bits(fun, 32); + } + + /*aux*/ + std::string aux = print["aux"].get(); + + BOOST_LOG_TRIVIAL(info) << "new print data aux = " << aux; + + if (!aux.empty()) { + sdcard_state = MachineObject::SdcardState(get_flag_bits(aux, 12, 2)); + } + + /*stat*/ + std::string stat = print["stat"].get(); + + BOOST_LOG_TRIVIAL(info) << "new print data stat = " << stat; + + if (!stat.empty()) { + camera_recording = get_flag_bits(stat, 7); + } + + /*device*/ + if (print.contains("device")) { + json const& device = print["device"]; + + if (device.contains("type")) { + int type = device["type"]; //FDM:1<<0 Laser:1<< Cut:1<<2 + } + + if (device.contains("bed_temp")) { + bed_temp = get_flag_bits(device["bed_temp"].get(), 0, 16); + bed_temp_target = get_flag_bits(device["bed_temp"].get(), 16, 16); + } + + if (device.contains("cham_temp")) { + chamber_temp = get_flag_bits(device["cham_temp"].get(), 0, 16); + chamber_temp_target = get_flag_bits(device["cham_temp"].get(), 16, 16); + } + + if (device.contains("fan")) { + big_fan1_speed = get_flag_bits(device["fan"].get(), 0, 3); + big_fan2_speed = get_flag_bits(device["fan"].get(), 4, 3); + cooling_fan_speed = get_flag_bits(device["fan"].get(), 8, 3); + heatbreak_fan_speed = get_flag_bits(device["fan"].get(), 12, 3); + } + + if (device.contains("nozzle")) { + json const &nozzle = device["nozzle"]; + + m_nozzle_data = NozzleData(); + + m_nozzle_data.extder_exist = get_flag_bits(nozzle["exist"].get(), 0, 16); + m_nozzle_data.cut_exist = get_flag_bits(nozzle["exist"].get(), 16, 16); + m_nozzle_data.state = get_flag_bits(nozzle["state"].get(), 0, 4); + + for (auto it = nozzle["info"].begin(); it != nozzle["info"].end(); it++) { + Nozzle nozzle_obj; + auto njon = it.value(); + std::string type = njon["type"].get(); + nozzle_obj.id = njon["id"].get(); + + if (type.length() >= 4) { + if (type.substr(2, 2) == std::string("00")) { + nozzle_obj.nozzle_type = NozzleType::ntStainlessSteel; + } else if (type.substr(2, 2) == std::string("01")) { + nozzle_obj.nozzle_type = NozzleType::ntHardenedSteel; + } + } else { + nozzle_obj.nozzle_type = NozzleType::ntUndefine; + } + + nozzle_obj.diameter = njon["diameter"].get(); + nozzle_obj.max_temp = njon["tm"].get(); + nozzle_obj.wear = njon["wear"].get(); + if (nozzle_obj.diameter == 0.0f) {nozzle_obj.diameter = 0.4f;} + m_nozzle_data.nozzles.push_back(nozzle_obj); + } + } + + if (device.contains("extruder")) { + json const& extruder = device["extruder"]; + + auto extder_data = ExtderData(); + extder_data.total_extder_count = get_flag_bits(extruder["state"].get(), 0, 4); + + + extder_data.current_extder_id = get_flag_bits(extruder["state"].get(), 4, 4); + extder_data.target_extder_id = get_flag_bits(extruder["state"].get(), 8, 4); + + for (auto it = extruder["info"].begin(); it != extruder["info"].end(); it++) { + + Extder extder_obj; + auto njon = it.value(); + + extder_obj.id = njon["id"].get(); + + extder_obj.filam_bak.clear(); + is_support_show_filament_backup = njon.contains("filam_bak"); + if (is_support_show_filament_backup) + { + const json& filam_bak_items = njon["filam_bak"]; + for (const auto& filam_bak_item : filam_bak_items) + { + const auto& filam_bak_val = filam_bak_item.get(); + extder_obj.filam_bak.emplace_back(filam_bak_val); + } + } + + extder_obj.ext_has_filament = get_flag_bits(njon["info"].get(), 1); + extder_obj.buffer_has_filament = get_flag_bits(njon["info"].get(), 2); + extder_obj.nozzle_exist = get_flag_bits(njon["info"].get(), 3); + extder_obj.temp = get_flag_bits(njon["temp"].get(), 0, 16); + extder_obj.target_temp = get_flag_bits(njon["temp"].get(), 16, 16); + + AmsSlot spre; + spre.slot_id = std::to_string(get_flag_bits(njon["spre"].get(), 0, 8)); + spre.ams_id = std::to_string(get_flag_bits(njon["spre"].get(), 8, 8)); + + AmsSlot snow; + snow.slot_id = std::to_string(get_flag_bits(njon["snow"].get(), 0, 8)); + snow.ams_id = std::to_string(get_flag_bits(njon["snow"].get(), 8, 8)); + + AmsSlot star; + star.slot_id = std::to_string(get_flag_bits(njon["star"].get(), 0, 8)); + star.ams_id = std::to_string(get_flag_bits(njon["star"].get(), 8, 8)); + + extder_obj.nozzle_id = njon["hnow"].get(); + extder_obj.target_nozzle_id = njon["htar"].get(); + + extder_obj.spre = spre; + extder_obj.snow = snow; + extder_obj.star = star; + extder_obj.ams_stat = get_flag_bits(njon["stat"].get(), 0, 16); + extder_obj.rfid_stat = get_flag_bits(njon["stat"].get(), 16, 16); + + //current nozzle info + if (extder_obj.nozzle_id == 0xff) { + extder_obj.current_nozzle_type = NozzleType::ntUndefine; + extder_obj.current_nozzle_diameter = 0.4f; + } else { + for (auto i = 0; i < m_nozzle_data.nozzles.size(); i++) { + if (m_nozzle_data.nozzles[i].id == extder_obj.nozzle_id) { + extder_obj.current_nozzle_type = m_nozzle_data.nozzles[i].nozzle_type; + extder_obj.current_nozzle_diameter = m_nozzle_data.nozzles[i].diameter; + } + } + } + extder_data.extders.push_back(extder_obj); + } + + if (extder_data.extders.size() <= 0) { + // def data + extder_data.current_extder_id = 0; + extder_data.target_extder_id = 0; + extder_data.total_extder_count = 1; + Extder nozzle; + extder_data.extders.push_back(nozzle); + } + + m_extder_data = extder_data; + } + + if (device.contains("ctc")) { + json const& ctc = device["ctc"]; + int state = get_flag_bits(ctc["state"].get(), 0, 4); + + if (ctc.contains("info")) { + json const &info = ctc["info"]; + chamber_temp = get_flag_bits(info["temp"].get(), 0, 16); + chamber_temp_target = get_flag_bits(info["temp"].get(), 16, 16); + } + + + } + } +} + +bool MachineObject::is_nozzle_data_invalid() +{ + for (const auto &ext : m_extder_data.extders) + { + if (ext.current_nozzle_type == NozzleType::ntUndefine || + ext.current_nozzle_diameter <= 0.0f) { + return true; + } + } + + return false; +} + +int MachineObject::get_flag_bits(std::string str, int start, int count) const +{ + try { + unsigned long long decimal_value = std::stoull(str, nullptr, 16); + unsigned long long mask = (1ULL << count) - 1; + int flag = (decimal_value >> start) & mask; + return flag; + } catch (...) { + return 0; + } +} + +int MachineObject::get_flag_bits(int num, int start, int count, int base) const +{ + try { + unsigned long long mask = (1ULL << count) - 1; + unsigned long long value; + if (base == 10) { + value = static_cast(num); + } else if (base == 16) { + value = static_cast(std::stoul(std::to_string(num), nullptr, 16)); + } else { + throw std::invalid_argument("Unsupported base"); + } + + int flag = (value >> start) & mask; + return flag; + } catch (...) { + return 0; + } +} + void MachineObject::update_filament_list() { PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; // custom filament - std::map> filament_list; + typedef std::map> map_pair; + std::map map_list; + for (auto &pair : m_nozzle_filament_data) { + map_list[pair.second.printer_preset_name] = map_pair{}; + } for (auto &preset : preset_bundle->filaments()) { if (preset.is_user() && preset.inherits() == "") { - ConfigOption * printer_opt = const_cast(preset).config.option("compatible_printers"); + ConfigOption * printer_opt = const_cast(preset).config.option("compatible_printers"); ConfigOptionStrings *printer_strs = dynamic_cast(printer_opt); for (const std::string &printer_str : printer_strs->values) { - if (printer_str == m_printer_preset_name) { + if (map_list.find(printer_str) != map_list.end()) { + auto & filament_list = map_list[printer_str]; ConfigOption *opt_min = const_cast(preset).config.option("nozzle_temperature_range_low"); int min_temp = -1; if (opt_min) { @@ -5207,65 +5819,215 @@ void MachineObject::update_filament_list() } } - for (auto it = filament_list.begin(); it != filament_list.end(); it++) { - if (m_filament_list.find(it->first) != m_filament_list.end()) { - assert(it->first.size() == 8 && it->first[0] == 'P'); + for (auto& pair : m_nozzle_filament_data) { + auto & m_printer_preset_name = pair.second.printer_preset_name; + auto & m_filament_list = pair.second.filament_list; + auto & m_checked_filament = pair.second.checked_filament; + auto & filament_list = map_list[m_printer_preset_name]; - if (it->second.first != m_filament_list[it->first].first) { - BOOST_LOG_TRIVIAL(info) << "old min temp is not equal to new min temp and filament id: " << it->first; - continue; - } + for (auto it = filament_list.begin(); it != filament_list.end(); it++) { + if (m_filament_list.find(it->first) != m_filament_list.end()) { + assert(it->first.size() == 8 && it->first[0] == 'P'); - if (it->second.second != m_filament_list[it->first].second) { - BOOST_LOG_TRIVIAL(info) << "old max temp is not equal to new max temp and filament id: " << it->first; - continue; - } + if (it->second.first != m_filament_list[it->first].first) { + BOOST_LOG_TRIVIAL(info) << "old min temp is not equal to new min temp and filament id: " << it->first; + continue; + } + + if (it->second.second != m_filament_list[it->first].second) { + BOOST_LOG_TRIVIAL(info) << "old max temp is not equal to new max temp and filament id: " << it->first; + continue; + } - m_filament_list.erase(it->first); + m_filament_list.erase(it->first); + } } - } - for (auto it = m_filament_list.begin(); it != m_filament_list.end(); it++) { - m_checked_filament.erase(it->first); - } + for (auto it = m_filament_list.begin(); it != m_filament_list.end(); it++) { m_checked_filament.erase(it->first); } - m_filament_list = filament_list; + m_filament_list = filament_list; + } } -int MachineObject::get_flag_bits(std::string str, int start, int count) +void MachineObject::update_printer_preset_name() { - int decimal_value = std::stoi(str, nullptr, 16); - int mask = 0; - for (int i = 0; i < count; i++) { mask += 1 << (start + i); } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "start update preset_name"; + PresetBundle * preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; + if (!preset_bundle) return; + auto printer_model = MachineObject::get_preset_printer_model_name(this->printer_type); + std::set diameter_set; + for (auto &nozzle : m_extder_data.extders) { + float diameter = nozzle.current_nozzle_diameter; + std::ostringstream stream; + stream << std::fixed << std::setprecision(1) << diameter; + std::string nozzle_diameter_str = stream.str(); + diameter_set.insert(nozzle_diameter_str); + if (m_nozzle_filament_data.find(nozzle_diameter_str) != m_nozzle_filament_data.end()) continue; + auto data = FilamentData(); + auto printer_set = preset_bundle->get_printer_names_by_printer_type_and_nozzle(printer_model, nozzle_diameter_str); + if (printer_set.size() > 0) { + data.printer_preset_name = *printer_set.begin(); + m_nozzle_filament_data[nozzle_diameter_str] = data; + } + else + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " update printer preset name failed: "<< "printer_type: " << printer_type << "nozzle_diameter_str" << nozzle_diameter_str; + } - int flag = (decimal_value & (mask)) >> start; - return flag; + for (auto iter = m_nozzle_filament_data.begin(); iter != m_nozzle_filament_data.end();) + { + if (diameter_set.find(iter->first) == diameter_set.end()) + { + iter = m_nozzle_filament_data.erase(iter); + } + else + { + ++iter; + } + } } -int MachineObject::get_flag_bits(int num, int start, int count) +void MachineObject::check_ams_filament_valid() { - int decimal_value = num; - int mask = 0; - for (int i = 0; i < count; i++) { mask += 1 << (start + i); } + PresetBundle * preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; + auto printer_model = MachineObject::get_preset_printer_model_name(this->printer_type); + std::map> need_checked_filament_id; + for (auto &ams_pair : amsList) { + auto ams_id = ams_pair.first; + auto &ams = ams_pair.second; + std::ostringstream stream; + if (ams->nozzle < 0 || ams->nozzle >= m_extder_data.extders.size()) { + return; + } + stream << std::fixed << std::setprecision(1) << m_extder_data.extders[ams->nozzle].current_nozzle_diameter; + std::string nozzle_diameter_str = stream.str(); + assert(nozzle_diameter_str.size() == 3); + if (m_nozzle_filament_data.find(nozzle_diameter_str) == m_nozzle_filament_data.end()) { + //assert(false); + continue; + } + auto &data = m_nozzle_filament_data[nozzle_diameter_str]; + auto &filament_list = data.filament_list; + auto &checked_filament = data.checked_filament; + for (const auto &[slot_id, curr_tray] : ams->trayList) { + + if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && filament_list.find(curr_tray->setting_id) == filament_list.end()) { + if (checked_filament.find(curr_tray->setting_id) == checked_filament.end()) { + need_checked_filament_id[nozzle_diameter_str].insert(curr_tray->setting_id); + wxColour color = *wxWHITE; + char col_buf[10]; + sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); + try { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " ams settings_id is not exist in filament_list and reset, ams_id: " << ams_id << " tray_id" + << slot_id << "filament_id: " << curr_tray->setting_id; - int flag = (decimal_value & (mask)) >> start; - return flag; -} + command_ams_filament_settings(std::stoi(ams_id), std::stoi(slot_id), "", "", std::string(col_buf), "", 0, 0); + continue; + } catch (...) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << slot_id; + } + } + } + if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") { + if (checked_filament.find(curr_tray->setting_id) == checked_filament.end()) { + need_checked_filament_id[nozzle_diameter_str].insert(curr_tray->setting_id); + try { + std::string preset_setting_id; + bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(printer_model, nozzle_diameter_str, + curr_tray->setting_id, curr_tray->tag_uid, + curr_tray->nozzle_temp_min, + curr_tray->nozzle_temp_max, preset_setting_id); + if (!is_equation) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " ams filament is not match min max temp and reset, ams_id: " << ams_id << " tray_id" + << slot_id << "filament_id: " << curr_tray->setting_id; + + + command_ams_filament_settings(std::stoi(ams_id), std::stoi(slot_id), curr_tray->setting_id, preset_setting_id, curr_tray->color, curr_tray->type, + std::stoi(curr_tray->nozzle_temp_min), std::stoi(curr_tray->nozzle_temp_max)); + } + continue; + } catch (...) { + BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id" << slot_id; + } + } + } + } + } -void MachineObject::update_printer_preset_name(const std::string &nozzle_diameter_str) -{ - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "start update preset_name"; - auto preset_boundle = Slic3r::GUI::wxGetApp().preset_bundle; - auto printer_set = preset_boundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str); - if (printer_set.size() > 0) - m_printer_preset_name = *printer_set.begin(); - else - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " update printer preset name failed "; + /*for (auto vt_tray : vt_slot)*/ do{ + int vt_id = std::stoi(vt_tray.id); + int index = 255 - vt_id; + if (index >= m_extder_data.total_extder_count) { + BOOST_LOG_TRIVIAL(error) << " vt_tray id map for nozzle id is not exist, index is: " << index << " nozzle count" << m_extder_data.total_extder_count; + continue; + } + auto diameter = m_extder_data.extders[index].current_nozzle_diameter; + std::ostringstream stream; + stream << std::fixed << std::setprecision(1) << diameter; + std::string nozzle_diameter_str = stream.str(); + if (m_nozzle_filament_data.find(nozzle_diameter_str) == m_nozzle_filament_data.end()) { + continue; + } + auto &data = m_nozzle_filament_data[nozzle_diameter_str]; + auto &checked_filament = data.checked_filament; + auto &filament_list = data.filament_list; + if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && filament_list.find(vt_tray.setting_id) == filament_list.end()) { + if (checked_filament.find(vt_tray.setting_id) == checked_filament.end()) { + need_checked_filament_id[nozzle_diameter_str].insert(vt_tray.setting_id); + wxColour color = *wxWHITE; + char col_buf[10]; + sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); + try { + BOOST_LOG_TRIVIAL(info) << "vt_tray.setting_id is not exist in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id; + command_ams_filament_settings(vt_id, 0, "", "", std::string(col_buf), "", 0, 0); + continue; + } catch (...) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id; + } + } + } + if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") { + if (checked_filament.find(vt_tray.setting_id) == checked_filament.end()) { + need_checked_filament_id[nozzle_diameter_str].insert(vt_tray.setting_id); + try { + std::string preset_setting_id; + PresetBundle * preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; + std::ostringstream stream; + stream << std::fixed << std::setprecision(1) << m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter; + std::string nozzle_diameter_str = stream.str(); + bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(MachineObject::get_preset_printer_model_name( + this->printer_type), + nozzle_diameter_str, vt_tray.setting_id, + vt_tray.tag_uid, vt_tray.nozzle_temp_min, + vt_tray.nozzle_temp_max, preset_setting_id); + if (!is_equation) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ + << " vt_tray filament is not match min max temp and reset, filament_id: " << vt_tray.setting_id; + command_ams_filament_settings(vt_id, 0, vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type, std::stoi(vt_tray.nozzle_temp_min), + std::stoi(vt_tray.nozzle_temp_max)); + + } + } catch (...) { + BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id; + } + } + } + } while (0); + + for (auto &diameter_pair : m_nozzle_filament_data) { + auto &diameter = diameter_pair.first; + auto &data = diameter_pair.second; + for (auto &filament_id : need_checked_filament_id[diameter]) { + data.checked_filament.insert(filament_id); + } + } } bool DeviceManager::EnableMultiMachine = false; bool DeviceManager::key_field_only = false; +std::vector nozzle_diameter_list{ 0.2f,0.4f,0.6f,0.8f }; +std::vector nozzle_type_list{ "hardened_steel", "stainless_steel" }; + DeviceManager::DeviceManager(NetworkAgent* agent) { m_agent = agent; @@ -5333,6 +6095,45 @@ DeviceManager::~DeviceManager() userMachineList.clear(); } + +float DeviceManager::nozzle_diameter_conver(int diame) +{ + if (diame < nozzle_diameter_list.size() && diame >= 0) { + return nozzle_diameter_list[diame]; + } + return 0.4f; +} + +int DeviceManager::nozzle_diameter_conver(float diame) +{ + int index = -1; + for (int i = 0; i < nozzle_diameter_list.size(); i++) { + if (nozzle_diameter_list[i] == diame) { + index = i; + } + } + return index; +} + +std::string DeviceManager::nozzle_type_conver(int type) +{ + if (type < nozzle_type_list.size() && type >= 0) { + return nozzle_type_list[type]; + } + return ""; +} + +int DeviceManager::nozzle_type_conver(std::string& type) +{ + int index = -1; + for (int i = 0; i < nozzle_type_list.size(); i++) { + if (nozzle_type_list[i] == type) { + index = i; + } + } + return index; +} + void DeviceManager::set_agent(NetworkAgent* agent) { m_agent = agent; @@ -5438,7 +6239,7 @@ void DeviceManager::on_machine_alive(std::string json_str) if(obj->dev_connection_name.empty()){obj->dev_connection_name = connection_name;} obj->dev_ip = dev_ip; } - + } /* ip changed reconnect mqtt */ } @@ -5707,18 +6508,20 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec } } else { BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = empty"; - m_agent->set_user_selected_machine(""); it->second->reset(); #if !BBL_RELEASE_TO_PUBLIC it->second->connect(false, Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false); #else it->second->connect(false, it->second->local_use_ssl_for_mqtt); #endif + m_agent->set_user_selected_machine(dev_id); it->second->set_lan_mode_connection_state(true); } } } - it->second->m_checked_filament.clear(); + for (auto& data : it->second->m_nozzle_filament_data) { + data.second.checked_filament.clear(); + } } selected_machine = dev_id; return true; @@ -6080,6 +6883,8 @@ boost::bimaps::bimap DeviceManager::get_all_model_id_w } for (wxString file : m_files) { + if (!file.Lower().ends_with(".json")) continue; + std::string config_file = Slic3r::resources_dir() + "/printers/" + file.ToStdString(); boost::nowide::ifstream json_file(config_file.c_str()); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 0d86d3e2658..85263899e81 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -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 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 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 extders; +}; + struct RatingInfo { bool request_successful; int http_code; @@ -178,6 +240,12 @@ class AmsTray { 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 @@ class AmsTray { std::string get_filament_type(); }; +#define INVALID_AMS_TEMPERATURE std::numeric_limits::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 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 trayList; + + int nozzle; + int type{1}; // 0:dummy 1:ams 2:ams-lite 3:n3f 4:n3s }; enum PrinterFirmwareType { @@ -369,6 +448,7 @@ class MachineObject { public: std::string name; + wxString product_name; std::string sn; std::string hw_ver; std::string sw_ver; @@ -377,18 +457,25 @@ class MachineObject 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 @@ class MachineObject 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 @@ class MachineObject std::string product_name; // set by iot service, get /user/print - std::vector filam_bak; - - std::string bind_user_name; std::string bind_user_id; std::string bind_state; /* free | occupied */ @@ -483,7 +565,6 @@ class MachineObject /* ams properties */ std::map 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 @@ class MachineObject 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 @@ class MachineObject // exceed index start with 0 bool is_mapping_exceed_filament(std::vector& result, int &exceed_index); void reset_mapping_result(std::vector& result); + bool is_main_extruder_on_left() const; + bool is_multi_extruders() const; /*online*/ bool online_rfid; @@ -543,8 +624,8 @@ class MachineObject 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 @@ class MachineObject 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 module_vers; std::map new_ver_list; std::map extrusion_ratio_map; @@ -603,6 +688,7 @@ class MachineObject wxString get_upgrade_result_str(int upgrade_err_code); // key: ams_id start as 0,1,2,3 std::map get_ams_version(); + void store_version_info(const ModuleVersionInfo& info); /* printing */ std::string print_type; @@ -625,6 +711,7 @@ class MachineObject 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 @@ class MachineObject ManualPaCaliMethod manual_pa_cali_method = ManualPaCaliMethod::PA_LINE; bool has_get_pa_calib_tab{ false }; + bool request_tab_from_bbs { false }; std::vector pa_calib_tab; - float pa_calib_tab_nozzle_dia; bool get_pa_calib_result { false }; std::vector pa_calib_results; bool get_flow_calib_result { false }; std::vector 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 @@ class MachineObject 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 @@ class MachineObject 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 @@ class MachineObject 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 @@ class MachineObject 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 @@ class MachineObject 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 @@ class MachineObject 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 @@ class MachineObject 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& 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 @@ class MachineObject /* Msg for display MsgFn */ typedef std::function 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 @@ class MachineObject 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 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 m_checked_filament; - std::string m_printer_preset_name; - std::map> m_filament_list; // filament_id, pair + struct FilamentData + { + std::set checked_filament; + std::string printer_preset_name; + std::map> filament_list; // filament_id, pair + }; + std::map 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 @@ class DeviceManager 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); diff --git a/src/slic3r/GUI/DeviceTab/CMakeLists.txt b/src/slic3r/GUI/DeviceTab/CMakeLists.txt new file mode 100644 index 00000000000..2d62d59a0d6 --- /dev/null +++ b/src/slic3r/GUI/DeviceTab/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.cpp b/src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.cpp new file mode 100644 index 00000000000..a28733f9487 --- /dev/null +++ b/src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.cpp @@ -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 + +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 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 \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h b/src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h new file mode 100644 index 00000000000..99237c0eda7 --- /dev/null +++ b/src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h @@ -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; +}; + +/// +/// Note: The popup of Ams Humidity with percentage and dry time +/// Author: xin.zhang +/// +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 \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.cpp b/src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.cpp new file mode 100644 index 00000000000..3d0feac7401 --- /dev/null +++ b/src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.cpp @@ -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 + +#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(); +} \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h b/src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h new file mode 100644 index 00000000000..a4ffc52bb59 --- /dev/null +++ b/src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h @@ -0,0 +1,47 @@ +//**********************************************************/ +/* File: uiDeviceUpdateVersion.h +* Description: The panel with firmware info +* +* \n class uiDeviceUpdateVersion +//**********************************************************/ + +#pragma once +#include +#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 \ No newline at end of file diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index da946343186..fa128a7d275 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -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 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 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 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 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 @@ bool GUI_App::on_init_network(bool try_backup) 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) { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index fb334568efe..7f390d1f66c 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -238,6 +238,9 @@ class GUI_App : public wxApp #ifdef __linux__ bool m_opengl_initialized{ false }; #endif +#if defined(__WINDOWS__) + bool m_is_arm64{false}; +#endif //#ifdef _WIN32 @@ -474,6 +477,7 @@ class GUI_App : public wxApp 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 @@ class GUI_App : public wxApp 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(); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index 0cbadc8e8c2..d9d4c8143ce 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -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 + } } diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 35e44a06830..6f4949adf33 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -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 + /// /// Make sure the given window fits inside current display /// diff --git a/src/slic3r/GUI/GUI_UtilsMac.mm b/src/slic3r/GUI/GUI_UtilsMac.mm index 6df6786eb32..01501f62655 100644 --- a/src/slic3r/GUI/GUI_UtilsMac.mm +++ b/src/slic3r/GUI/GUI_UtilsMac.mm @@ -1,4 +1,5 @@ - +#include +#include #import #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 ); +} + } } diff --git a/src/slic3r/GUI/ImageGrid.cpp b/src/slic3r/GUI/ImageGrid.cpp index ee3d531b2ac..77fd7b132ea 100644 --- a/src/slic3r/GUI/ImageGrid.cpp +++ b/src/slic3r/GUI/ImageGrid.cpp @@ -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)); diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index ec1b03a5ecd..0928dd3e78b 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -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; diff --git a/src/slic3r/GUI/Jobs/PrintJob.hpp b/src/slic3r/GUI/Jobs/PrintJob.hpp index 7806a8623b5..3d7421898cd 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.hpp +++ b/src/slic3r/GUI/Jobs/PrintJob.hpp @@ -61,7 +61,9 @@ class PrintJob : public Job 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 @@ class PrintJob : public Job 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 @@ class PrintJob : public Job 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 @@ class PrintJob : public Job 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 diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index c62307dbb5c..6ac7f89308c 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -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; diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index dc399ef5bc0..047c057d127 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -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; diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index 333f4d3de00..c1d04744ddf 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -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(); } diff --git a/src/slic3r/GUI/Monitor.hpp b/src/slic3r/GUI/Monitor.hpp index 8da56ddc3b8..75cf204ac0c 100644 --- a/src/slic3r/GUI/Monitor.hpp +++ b/src/slic3r/GUI/Monitor.hpp @@ -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 { diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 0993d1635a2..fc95c11100b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2080,7 +2080,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& init_matrix = (project_config.option("flush_volumes_matrix"))->values; const std::vector& init_extruders = (project_config.option("flush_volumes_vector"))->values; @@ -7813,7 +7812,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) diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index c275ac72617..c06e412ef33 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -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); @@ -1199,6 +1205,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 Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"}; @@ -1322,6 +1329,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)); diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index 5977397e168..e65ae52d35a 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -93,6 +93,7 @@ class PreferencesDialog : public DPIDialog ::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; diff --git a/src/slic3r/GUI/PrintOptionsDialog.cpp b/src/slic3r/GUI/PrintOptionsDialog.cpp index ca3bc40f12b..13d085468f8 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.cpp +++ b/src/slic3r/GUI/PrintOptionsDialog.cpp @@ -429,9 +429,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); } @@ -439,8 +439,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; @@ -466,12 +469,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); @@ -500,65 +506,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; - std::map diameter_list; - if (type == "hardened_steel") { - diameter_list = nozzle_hard_diameter_map; - } - else if (type == "stainless_steel") { - diameter_list = nozzle_stainless_diameter_map; + 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; } - 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); + if (obj) { + try { + auto nozzle_type = NozzleType::ntHardenedSteel; + auto nozzle_diameter = 0.4f; + + for (auto sm : nozzle_type_selection_map) { + if (sm.second == current_nozzle_type_combox->GetSelection()) { + nozzle_type = sm.first; + } + } - last_nozzle_type = type; - set_nozzle_diameter(evt); -} + /*update nozzle diameter*/ + if (evt.GetId() == ID_NOZZLE_TYPE_CHECKBOX_SINGLE) { + nozzle_diameter_checkbox->Clear(); + std::map 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; + } -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()); + 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; - - obj->nozzle_diameter = nozzle_diameter; - obj->nozzle_type = nozzle_type; - obj->command_set_printer_nozzle(nozzle_type, nozzle_diameter); - } - catch (...) {} + /*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 (...) {} } } @@ -578,53 +595,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 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 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); diff --git a/src/slic3r/GUI/PrintOptionsDialog.hpp b/src/slic3r/GUI/PrintOptionsDialog.hpp index db55d12dccd..7450933a431 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.hpp +++ b/src/slic3r/GUI/PrintOptionsDialog.hpp @@ -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 nozzle_type_map; + std::map nozzle_type_map; + std::map nozzle_type_selection_map; std::map nozzle_stainless_diameter_map; std::map 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; diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index fd93b42e907..f0627712a26 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -30,881 +30,18 @@ namespace Slic3r { namespace GUI { -wxDEFINE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent); -wxDEFINE_EVENT(EVT_FINISHED_UPDATE_MACHINE_LIST, wxCommandEvent); wxDEFINE_EVENT(EVT_UPDATE_USER_MACHINE_LIST, wxCommandEvent); wxDEFINE_EVENT(EVT_PRINT_JOB_CANCEL, wxCommandEvent); -wxDEFINE_EVENT(EVT_BIND_MACHINE, wxCommandEvent); -wxDEFINE_EVENT(EVT_UNBIND_MACHINE, wxCommandEvent); -wxDEFINE_EVENT(EVT_DISSMISS_MACHINE_LIST, wxCommandEvent); -wxDEFINE_EVENT(EVT_CONNECT_LAN_PRINT, wxCommandEvent); -wxDEFINE_EVENT(EVT_EDIT_PRINT_NAME, wxCommandEvent); wxDEFINE_EVENT(EVT_CLEAR_IPADDRESS, wxCommandEvent); #define INITIAL_NUMBER_OF_MACHINES 0 -#define LIST_REFRESH_INTERVAL 200 + #define MACHINE_LIST_REFRESH_INTERVAL 2000 #define WRAP_GAP FromDIP(2) static wxString task_canceled_text = _L("Task canceled"); - -std::string get_print_status_info(PrintDialogStatus status) -{ - switch(status) { - case PrintStatusInit: - return "PrintStatusInit"; - case PrintStatusNoUserLogin: - return "PrintStatusNoUserLogin"; - case PrintStatusInvalidPrinter: - return "PrintStatusInvalidPrinter"; - case PrintStatusConnectingServer: - return "PrintStatusConnectingServer"; - case PrintStatusReading: - return "PrintStatusReading"; - case PrintStatusReadingFinished: - return "PrintStatusReadingFinished"; - case PrintStatusReadingTimeout: - return "PrintStatusReadingTimeout"; - case PrintStatusInUpgrading: - return "PrintStatusInUpgrading"; - case PrintStatusNeedUpgradingAms: - return "PrintStatusNeedUpgradingAms"; - case PrintStatusInSystemPrinting: - return "PrintStatusInSystemPrinting"; - case PrintStatusInPrinting: - return "PrintStatusInPrinting"; - case PrintStatusDisableAms: - return "PrintStatusDisableAms"; - case PrintStatusAmsMappingSuccess: - return "PrintStatusAmsMappingSuccess"; - case PrintStatusAmsMappingInvalid: - return "PrintStatusAmsMappingInvalid"; - case PrintStatusAmsMappingU0Invalid: - return "PrintStatusAmsMappingU0Invalid"; - case PrintStatusAmsMappingValid: - return "PrintStatusAmsMappingValid"; - case PrintStatusAmsMappingByOrder: - return "PrintStatusAmsMappingByOrder"; - case PrintStatusRefreshingMachineList: - return "PrintStatusRefreshingMachineList"; - case PrintStatusSending: - return "PrintStatusSending"; - case PrintStatusSendingCanceled: - return "PrintStatusSendingCanceled"; - case PrintStatusLanModeNoSdcard: - return "PrintStatusLanModeNoSdcard"; - case PrintStatusNoSdcard: - return "PrintStatusNoSdcard"; - case PrintStatusUnsupportedPrinter: - return "PrintStatusUnsupportedPrinter"; - case PrintStatusTimelapseNoSdcard: - return "PrintStatusTimelapseNoSdcard"; - case PrintStatusNotSupportedPrintAll: - return "PrintStatusNotSupportedPrintAll"; - } - return "unknown"; -} - -MachineObjectPanel::MachineObjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name) -{ - wxPanel::Create(parent, id, pos, SELECT_MACHINE_ITEM_SIZE, style, name); - Bind(wxEVT_PAINT, &MachineObjectPanel::OnPaint, this); - - SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); - - m_unbind_img = ScalableBitmap(this, "unbind", 18); - m_edit_name_img = ScalableBitmap(this, "edit_button", 18); - m_select_unbind_img = ScalableBitmap(this, "unbind_selected", 18); - - m_printer_status_offline = ScalableBitmap(this, "printer_status_offline", 12); - m_printer_status_busy = ScalableBitmap(this, "printer_status_busy", 12); - m_printer_status_idle = ScalableBitmap(this, "printer_status_idle", 12); - m_printer_status_lock = ScalableBitmap(this, "printer_status_lock", 16); - m_printer_in_lan = ScalableBitmap(this, "printer_in_lan", 16); - - this->Bind(wxEVT_ENTER_WINDOW, &MachineObjectPanel::on_mouse_enter, this); - this->Bind(wxEVT_LEAVE_WINDOW, &MachineObjectPanel::on_mouse_leave, this); - this->Bind(wxEVT_LEFT_UP, &MachineObjectPanel::on_mouse_left_up, this); - -#ifdef __APPLE__ - wxPlatformInfo platformInfo; - auto major = platformInfo.GetOSMajorVersion(); - auto minor = platformInfo.GetOSMinorVersion(); - auto micro = platformInfo.GetOSMicroVersion(); - - //macos 13.1.0 - if (major >= 13 && minor >= 1 && micro >= 0) { - m_is_macos_special_version = true; - } -#endif - -} - - -MachineObjectPanel::~MachineObjectPanel() {} - -void MachineObjectPanel::show_bind_dialog() -{ - if (wxGetApp().is_user_login()) { - BindMachineDialog dlg; - dlg.update_machine_info(m_info); - dlg.ShowModal(); - } -} - -void MachineObjectPanel::set_printer_state(PrinterState state) -{ - m_state = state; - Refresh(); -} - -void MachineObjectPanel::show_edit_printer_name(bool show) -{ - m_show_edit = show; - Refresh(); -} - -void MachineObjectPanel::show_printer_bind(bool show, PrinterBindState state) -{ - m_show_bind = show; - m_bind_state = state; - Refresh(); -} - -void MachineObjectPanel::OnPaint(wxPaintEvent &event) -{ - wxPaintDC dc(this); - doRender(dc); -} - -void MachineObjectPanel::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 MachineObjectPanel::doRender(wxDC &dc) -{ - auto left = 10; - wxSize size = GetSize(); - dc.SetPen(*wxTRANSPARENT_PEN); - - auto dwbitmap = m_printer_status_offline; - if (m_state == PrinterState::IDLE) { dwbitmap = m_printer_status_idle; } - if (m_state == PrinterState::BUSY) { dwbitmap = m_printer_status_busy; } - if (m_state == PrinterState::OFFLINE) { dwbitmap = m_printer_status_offline; } - if (m_state == PrinterState::LOCK) { dwbitmap = m_printer_status_lock; } - if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; } - - // dc.DrawCircle(left, size.y / 2, 3); - dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2)); - - left += dwbitmap.GetBmpSize().x + 8; - dc.SetFont(Label::Body_13); - dc.SetBackgroundMode(wxTRANSPARENT); - dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900)); - wxString dev_name = ""; - if (m_info) { - dev_name = from_u8(m_info->dev_name); - - if (m_state == PrinterState::IN_LAN) { - dev_name += _L("(LAN)"); - } - } - auto sizet = dc.GetTextExtent(dev_name); - auto text_end = 0; - - if (m_show_edit) { - text_end = size.x - m_unbind_img.GetBmpSize().x - 30; - } - else { - text_end = size.x - m_unbind_img.GetBmpSize().x; - } - - wxString finally_name = dev_name; - if (sizet.x > (text_end - left)) { - auto limit_width = text_end - left - dc.GetTextExtent("...").x - 15; - for (auto i = 0; i < dev_name.length(); i++) { - auto curr_width = dc.GetTextExtent(dev_name.substr(0, i)); - if (curr_width.x >= limit_width) { - finally_name = dev_name.substr(0, i) + "..."; - break; - } - } - } - - dc.DrawText(finally_name, wxPoint(left, (size.y - sizet.y) / 2)); - - - if (m_hover || m_is_macos_special_version) { - - if (m_hover && !m_is_macos_special_version) { - dc.SetPen(SELECT_MACHINE_BRAND); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(0, 0, size.x, size.y); - } - - if (m_show_bind) { - if (m_bind_state == ALLOW_UNBIND) { - left = size.x - m_unbind_img.GetBmpSize().x - 6; - dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2); - } - } - - if (m_show_edit) { - left = size.x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6; - dc.DrawBitmap(m_edit_name_img.bmp(), left, (size.y - m_edit_name_img.GetBmpSize().y) / 2); - } - } - -} - -void MachineObjectPanel::update_machine_info(MachineObject *info, bool is_my_devices) -{ - m_info = info; - m_is_my_devices = is_my_devices; - Refresh(); -} - -void MachineObjectPanel::on_mouse_enter(wxMouseEvent &evt) -{ - m_hover = true; - Refresh(); -} - -void MachineObjectPanel::on_mouse_leave(wxMouseEvent &evt) -{ - m_hover = false; - Refresh(); -} - -void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt) -{ - if (m_is_my_devices) { - // show edit - if (m_show_edit) { - auto edit_left = GetSize().x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6; - auto edit_right = edit_left + m_edit_name_img.GetBmpSize().x; - auto edit_top = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2; - auto edit_bottom = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2 + m_edit_name_img.GetBmpSize().y; - if ((evt.GetPosition().x >= edit_left && evt.GetPosition().x <= edit_right) && evt.GetPosition().y >= edit_top && evt.GetPosition().y <= edit_bottom) { - wxCommandEvent event(EVT_EDIT_PRINT_NAME); - event.SetEventObject(this); - wxPostEvent(this, event); - return; - } - } - if (m_show_bind) { - auto left = GetSize().x - m_unbind_img.GetBmpSize().x - 6; - auto right = left + m_unbind_img.GetBmpSize().x; - auto top = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2; - auto bottom = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2 + m_unbind_img.GetBmpSize().y; - - if ((evt.GetPosition().x >= left && evt.GetPosition().x <= right) && evt.GetPosition().y >= top && evt.GetPosition().y <= bottom) { - wxCommandEvent event(EVT_UNBIND_MACHINE, GetId()); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); - } else { - if (m_info) { - wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); - } - //wxGetApp().mainframe->SetFocus(); - wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST); - event.SetEventObject(this->GetParent()); - wxPostEvent(this->GetParent(), event); - } - return; - } - if (m_info && m_info->is_lan_mode_printer()) { - if (m_info->has_access_right() && m_info->is_avaliable()) { - wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); - } else { - wxCommandEvent event(EVT_CONNECT_LAN_PRINT); - event.SetEventObject(this); - wxPostEvent(this, event); - } - } else { - wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); - } - } else { - if (m_info && m_info->is_lan_mode_printer()) { - wxCommandEvent event(EVT_CONNECT_LAN_PRINT); - event.SetEventObject(this); - wxPostEvent(this, event); - } else { - wxCommandEvent event(EVT_BIND_MACHINE); - event.SetEventObject(this); - wxPostEvent(this, event); - } - } - -} - -SelectMachinePopup::SelectMachinePopup(wxWindow *parent) - : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_dismiss(false) -{ -#ifdef __WINDOWS__ - SetDoubleBuffered(true); -#endif //__WINDOWS__ - - - SetSize(SELECT_MACHINE_POPUP_SIZE); - SetMinSize(SELECT_MACHINE_POPUP_SIZE); - SetMaxSize(SELECT_MACHINE_POPUP_SIZE); - - Freeze(); - wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL); - SetBackgroundColour(SELECT_MACHINE_GREY400); - - - - m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_LIST_SIZE, wxHSCROLL | wxVSCROLL); - m_scrolledWindow->SetBackgroundColour(*wxWHITE); - m_scrolledWindow->SetMinSize(SELECT_MACHINE_LIST_SIZE); - m_scrolledWindow->SetScrollRate(0, 5); - auto m_sizxer_scrolledWindow = new wxBoxSizer(wxVERTICAL); - m_scrolledWindow->SetSizer(m_sizxer_scrolledWindow); - m_scrolledWindow->Layout(); - m_sizxer_scrolledWindow->Fit(m_scrolledWindow); - -#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) - m_sizer_search_bar = new wxBoxSizer(wxVERTICAL); - m_search_bar = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_search_bar->SetDescriptiveText(_L("Search")); - m_search_bar->ShowSearchButton( true ); - m_search_bar->ShowCancelButton( false ); - m_sizer_search_bar->Add( m_search_bar, 1, wxALL| wxEXPAND, 1 ); - m_sizer_main->Add(m_sizer_search_bar, 0, wxALL | wxEXPAND, FromDIP(2)); - m_search_bar->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SelectMachinePopup::update_machine_list, this ); -#endif - auto own_title = create_title_panel(_L("My Device")); - m_sizer_my_devices = new wxBoxSizer(wxVERTICAL); - auto other_title = create_title_panel(_L("Other Device")); - m_sizer_other_devices = new wxBoxSizer(wxVERTICAL); - - - m_panel_ping_code = new PinCodePanel(m_scrolledWindow, 0, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); - m_panel_direct_connection = new PinCodePanel(m_scrolledWindow, 1, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); - - m_sizxer_scrolledWindow->Add(own_title, 0, wxEXPAND | wxLEFT, FromDIP(15)); - m_sizxer_scrolledWindow->Add(m_sizer_my_devices, 0, wxEXPAND, 0); - m_sizxer_scrolledWindow->Add(m_panel_ping_code, 0, wxEXPAND, 0); - m_sizxer_scrolledWindow->Add(m_panel_direct_connection, 0, wxEXPAND, 0); - m_sizxer_scrolledWindow->Add(other_title, 0, wxEXPAND | wxLEFT, FromDIP(15)); - m_sizxer_scrolledWindow->Add(m_sizer_other_devices, 0, wxEXPAND, 0); - - m_sizer_main->Add(m_scrolledWindow, 0, wxALL | wxEXPAND, FromDIP(2)); - - SetSizer(m_sizer_main); - Layout(); - Thaw(); - - #ifdef __APPLE__ - m_scrolledWindow->Bind(wxEVT_LEFT_UP, &SelectMachinePopup::OnLeftUp, this); - #endif // __APPLE__ - - m_refresh_timer = new wxTimer(); - m_refresh_timer->SetOwner(this); - Bind(EVT_UPDATE_USER_MACHINE_LIST, &SelectMachinePopup::update_machine_list, this); - Bind(wxEVT_TIMER, &SelectMachinePopup::on_timer, this); - Bind(EVT_DISSMISS_MACHINE_LIST, &SelectMachinePopup::on_dissmiss_win, this); -} - -SelectMachinePopup::~SelectMachinePopup() { delete m_refresh_timer;} - -void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus)) -{ - BOOST_LOG_TRIVIAL(trace) << "get_print_info: start"; - start_ssdp(true); - if (m_refresh_timer) { - m_refresh_timer->Stop(); - m_refresh_timer->Start(MACHINE_LIST_REFRESH_INTERVAL); - } - - if (wxGetApp().is_user_login()) { - if (!get_print_info_thread) { - get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] { - NetworkAgent* agent = wxGetApp().getAgent(); - unsigned int http_code; - std::string body; - int result = agent->get_user_print_info(&http_code, &body); - CallAfter([token, this, result, body]() { - if (token.expired()) {return;} - if (result == 0) { - m_print_info = body; - } - else { - m_print_info = ""; - } - wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); - event.SetEventObject(this); - wxPostEvent(this, event); - }); - })); - } - } - - wxPostEvent(this, wxTimerEvent()); - PopupWindow::Popup(); -} - -void SelectMachinePopup::OnDismiss() -{ - BOOST_LOG_TRIVIAL(trace) << "get_print_info: dismiss"; - start_ssdp(false); - m_dismiss = true; - - if (m_refresh_timer) { - m_refresh_timer->Stop(); - } - if (get_print_info_thread) { - if (get_print_info_thread->joinable()) { - get_print_info_thread->join(); - delete get_print_info_thread; - get_print_info_thread = nullptr; - } - } - - wxCommandEvent event(EVT_FINISHED_UPDATE_MACHINE_LIST); - event.SetEventObject(this); - wxPostEvent(this, event); -} - -bool SelectMachinePopup::ProcessLeftDown(wxMouseEvent &event) { - return PopupWindow::ProcessLeftDown(event); -} - -bool SelectMachinePopup::Show(bool show) { - if (show) { - for (int i = 0; i < m_user_list_machine_panel.size(); i++) { - m_user_list_machine_panel[i]->mPanel->update_machine_info(nullptr); - m_user_list_machine_panel[i]->mPanel->Hide(); - } - - for (int j = 0; j < m_other_list_machine_panel.size(); j++) { - m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr); - m_other_list_machine_panel[j]->mPanel->Hide(); - } - } - return PopupWindow::Show(show); -} - -wxWindow *SelectMachinePopup::create_title_panel(wxString text) -{ - auto m_panel_title_own = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE, wxTAB_TRAVERSAL); - m_panel_title_own->SetBackgroundColour(*wxWHITE); - - wxBoxSizer *m_sizer_title_own = new wxBoxSizer(wxHORIZONTAL); - - auto m_title_own = new wxStaticText(m_panel_title_own, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, 0); - m_title_own->Wrap(-1); - m_sizer_title_own->Add(m_title_own, 0, wxALIGN_CENTER, 0); - - wxBoxSizer *m_sizer_line_own = new wxBoxSizer(wxHORIZONTAL); - - auto m_panel_line_own = new wxPanel(m_panel_title_own, wxID_ANY, wxDefaultPosition, wxSize(SELECT_MACHINE_ITEM_SIZE.x, FromDIP(1)), wxTAB_TRAVERSAL); - m_panel_line_own->SetBackgroundColour(SELECT_MACHINE_GREY400); - - m_sizer_line_own->Add(m_panel_line_own, 0, wxALIGN_CENTER, 0); - m_sizer_title_own->Add(0, 0, 0, wxLEFT, FromDIP(10)); - m_sizer_title_own->Add(m_sizer_line_own, 1, wxEXPAND | wxRIGHT, FromDIP(10)); - - m_panel_title_own->SetSizer(m_sizer_title_own); - m_panel_title_own->Layout(); - return m_panel_title_own; -} - -void SelectMachinePopup::on_timer(wxTimerEvent &event) -{ - BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup on_timer"; - wxGetApp().reset_to_active(); - wxCommandEvent user_event(EVT_UPDATE_USER_MACHINE_LIST); - user_event.SetEventObject(this); - wxPostEvent(this, user_event); -} - -void SelectMachinePopup::update_other_devices() -{ - DeviceManager* dev = wxGetApp().getDeviceManager(); - if (!dev) return; - m_free_machine_list = dev->get_local_machine_list(); - - BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices start"; - this->Freeze(); - m_scrolledWindow->Freeze(); - int i = 0; - - for (auto &elem : m_free_machine_list) { - MachineObject * mobj = elem.second; - /* do not show printer bind state is empty */ - if (!mobj->is_avaliable()) continue; - - if (!wxGetApp().is_user_login() && !mobj->is_lan_mode_printer()) - continue; - - /* do not show printer in my list */ - auto it = m_bind_machine_list.find(mobj->dev_id); - if (it != m_bind_machine_list.end()) - continue; - - MachineObjectPanel* op = nullptr; - if (i < m_other_list_machine_panel.size()) { - op = m_other_list_machine_panel[i]->mPanel; - } else { - op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY); - MachinePanel* mpanel = new MachinePanel(); - mpanel->mIndex = wxString::Format("%d", i); - mpanel->mPanel = op; - m_other_list_machine_panel.push_back(mpanel); - m_sizer_other_devices->Add(op, 0, wxEXPAND, 0); - } -#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) - if (!search_for_printer(mobj)) { - op->Hide(); - } - else { - op->Show(); - } -#else - op->Show(); -#endif - i++; - - op->update_machine_info(mobj); - - if (mobj->is_lan_mode_printer()) { - if (mobj->has_access_right()) { - op->set_printer_state(PrinterState::IN_LAN); - } else { - op->set_printer_state(PrinterState::LOCK); - } - } else { - op->show_edit_printer_name(false); - op->show_printer_bind(true, PrinterBindState::ALLOW_BIND); - if (mobj->is_in_printing()) { - op->set_printer_state(PrinterState::BUSY); - } else { - op->SetToolTip(_L("Online")); - op->set_printer_state(IDLE); - } - } - - op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) { - if (mobj) { - if (mobj->is_lan_mode_printer()) { - ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); - dlg.set_machine_object(mobj); - if (dlg.ShowModal() == wxID_OK) { - wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); - } - } - } - }); - - op->Bind(EVT_BIND_MACHINE, [this, mobj](wxCommandEvent &e) { - BindMachineDialog dlg; - dlg.update_machine_info(mobj); - int dlg_result = wxID_CANCEL; - dlg_result = dlg.ShowModal(); - if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); } - }); - } - - for (int j = i; j < m_other_list_machine_panel.size(); j++) { - m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr); - m_other_list_machine_panel[j]->mPanel->Hide(); - } - - if (m_placeholder_panel != nullptr) { - m_scrolledWindow->RemoveChild(m_placeholder_panel); - m_placeholder_panel->Destroy(); - m_placeholder_panel = nullptr; - } - - m_placeholder_panel = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(-1,FromDIP(26))); - wxBoxSizer* placeholder_sizer = new wxBoxSizer(wxVERTICAL); - - m_hyperlink = new wxHyperlinkCtrl(m_placeholder_panel, wxID_ANY, _L("Can't find my devices?"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); - m_hyperlink->SetNormalColour(StateColor::darkModeColorFor("#009789")); - placeholder_sizer->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5); - - - m_placeholder_panel->SetSizer(placeholder_sizer); - m_placeholder_panel->Layout(); - placeholder_sizer->Fit(m_placeholder_panel); - - m_placeholder_panel->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); - m_sizer_other_devices->Add(m_placeholder_panel, 0, wxEXPAND, 0); - - //m_sizer_other_devices->Layout(); - if(m_other_devices_count != i) { - m_scrolledWindow->Fit(); - } - m_scrolledWindow->Layout(); - m_scrolledWindow->Thaw(); - Layout(); - Fit(); - this->Thaw(); - m_other_devices_count = i; - BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices end"; -} - -void SelectMachinePopup::update_user_devices() -{ - Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (!dev) return; - - if (!m_print_info.empty()) { - dev->parse_user_print_info(m_print_info); - m_print_info = ""; - } - - m_bind_machine_list.clear(); - m_bind_machine_list = dev->get_my_machine_list(); - - //sort list - std::vector> user_machine_list; - for (auto& it: m_bind_machine_list) { - user_machine_list.push_back(it); - } - - std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto&b) { - if (a.second && b.second) { - return a.second->dev_name.compare(b.second->dev_name) < 0; - } - return false; - }); - - BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_machine_list start"; - this->Freeze(); - m_scrolledWindow->Freeze(); - int i = 0; - - for (auto& elem : user_machine_list) { - MachineObject* mobj = elem.second; - MachineObjectPanel* op = nullptr; - if (i < m_user_list_machine_panel.size()) { - op = m_user_list_machine_panel[i]->mPanel; -#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) - if (!search_for_printer(mobj)) { - op->Hide(); - } else { - op->Show(); - } -#else - op->Show(); -#endif - } else { - op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY); - MachinePanel* mpanel = new MachinePanel(); - mpanel->mIndex = wxString::Format("%d", i); - mpanel->mPanel = op; - m_user_list_machine_panel.push_back(mpanel); - m_sizer_my_devices->Add(op, 0, wxEXPAND, 0); - } - i++; - op->update_machine_info(mobj, true); - //set in lan - if (mobj->is_lan_mode_printer()) { - if (!mobj->is_online()) { - continue; - } - else { - op->show_printer_bind(false, PrinterBindState::NONE); - op->show_edit_printer_name(false); - if (mobj->has_access_right() && mobj->is_avaliable()) { - op->set_printer_state(PrinterState::IN_LAN); - op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND); - op->SetToolTip(_L("Online")); - } - else { - op->set_printer_state(PrinterState::LOCK); - } - } - op->Bind(EVT_UNBIND_MACHINE, [this, dev, mobj](wxCommandEvent& e) { - dev->set_selected_machine(""); - if (mobj) { - AppConfig* config = wxGetApp().app_config; - if (config) { - config->erase_local_machine(mobj->dev_id); - } - - mobj->set_access_code(""); - mobj->erase_user_access_code(); - } - - MessageDialog msg_wingow(nullptr, _L("Log out successful."), "", wxAPPLY | wxOK); - if (msg_wingow.ShowModal() == wxOK) { return; } - }); - } - else { - op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND); - op->Bind(EVT_UNBIND_MACHINE, [this, mobj, dev](wxCommandEvent& e) { - // show_unbind_dialog - UnBindMachineDialog dlg; - dlg.update_machine_info(mobj); - if (dlg.ShowModal() == wxID_OK) { - dev->set_selected_machine(""); - } - }); - - if (!mobj->is_online()) { - op->SetToolTip(_L("Offline")); - op->set_printer_state(PrinterState::OFFLINE); - } - else { - op->show_edit_printer_name(true); - op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND); - if (mobj->is_in_printing()) { - op->SetToolTip(_L("Busy")); - op->set_printer_state(PrinterState::BUSY); - } - else { - op->SetToolTip(_L("Online")); - op->set_printer_state(PrinterState::IDLE); - } - } - } - - op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) { - if (mobj) { - if (mobj->is_lan_mode_printer()) { - ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); - dlg.set_machine_object(mobj); - if (dlg.ShowModal() == wxID_OK) { - wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); - } - } - } - }); - - op->Bind(EVT_EDIT_PRINT_NAME, [this, mobj](wxCommandEvent &e) { - EditDevNameDialog dlg; - dlg.set_machine_obj(mobj); - dlg.ShowModal(); - }); - } - - for (int j = i; j < m_user_list_machine_panel.size(); j++) { - m_user_list_machine_panel[j]->mPanel->update_machine_info(nullptr); - m_user_list_machine_panel[j]->mPanel->Hide(); - } - //m_sizer_my_devices->Layout(); - - if (m_my_devices_count != i) { - m_scrolledWindow->Fit(); - } - m_scrolledWindow->Layout(); - m_scrolledWindow->Thaw(); - Layout(); - Fit(); - this->Thaw(); - m_my_devices_count = i; -} - -bool SelectMachinePopup::search_for_printer(MachineObject* obj) -{ - std::string search_text = std::string((m_search_bar->GetValue()).mb_str()); - if (search_text.empty()) { - return true; - } - auto name = obj->dev_name; - auto ip = obj->dev_ip; - auto name_it = name.find(search_text); - auto ip_it = ip.find(search_text); - if ((name_it != std::string::npos)||(ip_it != std::string::npos)) { - return true; - } - - return false; -} - -void SelectMachinePopup::on_dissmiss_win(wxCommandEvent &event) -{ - Dismiss(); -} - -void SelectMachinePopup::update_machine_list(wxCommandEvent &event) -{ - update_user_devices(); - update_other_devices(); - BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_machine_list end"; -} - -void SelectMachinePopup::start_ssdp(bool start) -{ - return; - //if (wxGetApp().getAgent()) { wxGetApp().getAgent()->start_discovery(true, start); } -} - -void SelectMachinePopup::OnLeftUp(wxMouseEvent &event) -{ - auto mouse_pos = ClientToScreen(event.GetPosition()); - auto wxscroll_win_pos = m_scrolledWindow->ClientToScreen(wxPoint(0, 0)); - - if (mouse_pos.x > wxscroll_win_pos.x && mouse_pos.y > wxscroll_win_pos.y && mouse_pos.x < (wxscroll_win_pos.x + m_scrolledWindow->GetSize().x) && - mouse_pos.y < (wxscroll_win_pos.y + m_scrolledWindow->GetSize().y)) { - - for (MachinePanel* p : m_user_list_machine_panel) { - auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0)); - if (mouse_pos.x > p_rect.x && mouse_pos.y > p_rect.y && mouse_pos.x < (p_rect.x + p->mPanel->GetSize().x) && mouse_pos.y < (p_rect.y + p->mPanel->GetSize().y)) { - wxMouseEvent event(wxEVT_LEFT_UP); - auto tag_pos = p->mPanel->ScreenToClient(mouse_pos); - event.SetPosition(tag_pos); - event.SetEventObject(p->mPanel); - wxPostEvent(p->mPanel, event); - } - } - - for (MachinePanel* p : m_other_list_machine_panel) { - auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0)); - if (mouse_pos.x > p_rect.x && mouse_pos.y > p_rect.y && mouse_pos.x < (p_rect.x + p->mPanel->GetSize().x) && mouse_pos.y < (p_rect.y + p->mPanel->GetSize().y)) { - wxMouseEvent event(wxEVT_LEFT_UP); - auto tag_pos = p->mPanel->ScreenToClient(mouse_pos); - event.SetPosition(tag_pos); - event.SetEventObject(p->mPanel); - wxPostEvent(p->mPanel, event); - } - } - - //pin code - auto pc_rect = m_panel_ping_code->ClientToScreen(wxPoint(0, 0)); - if (mouse_pos.x > pc_rect.x && mouse_pos.y > pc_rect.y && mouse_pos.x < (pc_rect.x + m_panel_ping_code->GetSize().x) && mouse_pos.y < (pc_rect.y + m_panel_ping_code->GetSize().y)) { - wxGetApp().popup_ping_bind_dialog(); - } - - //bind with access code - auto dc_rect = m_panel_direct_connection->ClientToScreen(wxPoint(0, 0)); - if (mouse_pos.x > dc_rect.x && mouse_pos.y > dc_rect.y && mouse_pos.x < (dc_rect.x + m_panel_direct_connection->GetSize().x) && mouse_pos.y < (dc_rect.y + m_panel_direct_connection->GetSize().y)) { - InputIpAddressDialog dlgo; - dlgo.ShowModal(); - } - - //hyper link - auto h_rect = m_hyperlink->ClientToScreen(wxPoint(0, 0)); - if (mouse_pos.x > h_rect.x && mouse_pos.y > h_rect.y && mouse_pos.x < (h_rect.x + m_hyperlink->GetSize().x) && mouse_pos.y < (h_rect.y + m_hyperlink->GetSize().y)) { - wxLaunchDefaultBrowser(wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer")); - } - } -} - static wxString MACHINE_BED_TYPE_STRING[BED_TYPE_COUNT] = { //_L("Auto"), _L("Bambu Cool Plate") + " / " + _L("PLA Plate"), @@ -912,14 +49,6 @@ static wxString MACHINE_BED_TYPE_STRING[BED_TYPE_COUNT] = { _L("Bambu Smooth PEI Plate") + "/" + _L("High temperature Plate"), _L("Bambu Textured PEI Plate")}; -static std::string MachineBedTypeString[BED_TYPE_COUNT] = { - //"auto", - "pc", - "pe", - "pei", - "pte", -}; - void SelectMachineDialog::stripWhiteSpace(std::string& str) { if (str == "") { return; } @@ -937,6 +66,14 @@ void SelectMachineDialog::stripWhiteSpace(std::string& str) } } +static std::string MachineBedTypeString[BED_TYPE_COUNT] = { + //"auto", + "pc", + "pe", + "pei", + "pte", +}; + wxString SelectMachineDialog::format_text(wxString &m_msg) { if (wxGetApp().app_config->get("language") != "zh_CN") {return m_msg; } @@ -956,7 +93,6 @@ wxString SelectMachineDialog::format_text(wxString &m_msg) } return out_txt; } - SelectMachineDialog::SelectMachineDialog(Plater *plater) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Send print job to"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) , m_plater(plater), m_export_3mf_cancel(false) @@ -968,6 +104,9 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) SetDoubleBuffered(true); #endif //__WINDOWS__ + SetMinSize(wxSize(FromDIP(688), -1)); + SetMaxSize(wxSize(FromDIP(688), -1)); + // bind Bind(wxEVT_CLOSE_WINDOW, &SelectMachineDialog::on_cancel, this); @@ -984,54 +123,76 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) SetBackgroundColour(m_colour_def_color); m_sizer_main = new wxBoxSizer(wxVERTICAL); - - m_sizer_main->SetMinSize(wxSize(0, -1)); m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); - m_scrollable_view = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); - m_sizer_scrollable_view = new wxBoxSizer(wxVERTICAL); - m_scrollable_region = new wxPanel(m_scrollable_view, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL); + m_basic_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_basic_panel->SetBackgroundColour(*wxWHITE); + m_basicl_sizer = new wxBoxSizer(wxHORIZONTAL); + + /*basic info*/ + /*thumbnail*/ + auto m_sizer_thumbnail_area = new wxBoxSizer(wxHORIZONTAL); + + auto m_panel_image = new wxPanel(m_basic_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_panel_image->SetBackgroundColour(m_colour_def_color); + m_sizer_thumbnail = new wxBoxSizer(wxHORIZONTAL); + m_thumbnailPanel = new ThumbnailPanel(m_panel_image); + m_thumbnailPanel->SetSize(wxSize(FromDIP(198), FromDIP(198))); + m_thumbnailPanel->SetMinSize(wxSize(FromDIP(198), FromDIP(198))); + m_thumbnailPanel->SetMaxSize(wxSize(FromDIP(198), FromDIP(198))); + m_thumbnailPanel->SetBackgroundColour(*wxWHITE); + m_sizer_thumbnail->Add(m_thumbnailPanel, 0, wxALIGN_CENTER, 0); + m_panel_image->SetSizer(m_sizer_thumbnail); + m_panel_image->Layout(); + + m_sizer_thumbnail_area->Add(m_panel_image, 0, wxALIGN_CENTER, 0); + m_sizer_thumbnail_area->Layout(); + + /*basic info right*/ + auto sizer_basic_right_info = new wxBoxSizer(wxVERTICAL); + /*rename*/ + auto sizer_rename = new wxBoxSizer(wxHORIZONTAL); - //rename normal - m_rename_switch_panel = new wxSimplebook(m_scrollable_region); - m_rename_switch_panel->SetSize(wxSize(FromDIP(420), FromDIP(25))); - m_rename_switch_panel->SetMinSize(wxSize(FromDIP(420), FromDIP(25))); - m_rename_switch_panel->SetMaxSize(wxSize(FromDIP(420), FromDIP(25))); + m_rename_switch_panel = new wxSimplebook(m_basic_panel); + m_rename_switch_panel->SetBackgroundColour(*wxWHITE); + m_rename_switch_panel->SetSize(wxSize(FromDIP(360), FromDIP(25))); + m_rename_switch_panel->SetMinSize(wxSize(FromDIP(360), FromDIP(25))); + m_rename_switch_panel->SetMaxSize(wxSize(FromDIP(360), FromDIP(25))); m_rename_normal_panel = new wxPanel(m_rename_switch_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_rename_normal_panel->SetBackgroundColour(*wxWHITE); rename_sizer_v = new wxBoxSizer(wxVERTICAL); rename_sizer_h = new wxBoxSizer(wxHORIZONTAL); - m_rename_text = new wxStaticText(m_rename_normal_panel, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); + m_rename_text = new wxStaticText(m_rename_normal_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); m_rename_text->SetFont(::Label::Body_13); - m_rename_text->SetMaxSize(wxSize(FromDIP(390), -1)); - m_rename_button = new ScalableButton(m_rename_normal_panel, wxID_ANY, "ams_editable"); - ams_editable = new ScalableBitmap(this, "ams_editable", 13); - ams_editable_light = new ScalableBitmap(this, "ams_editable_light", 13); - m_rename_button->SetBackgroundColour(*wxWHITE); - - rename_sizer_h->Add(m_rename_text, 0, wxALIGN_CENTER, 0); + m_rename_text->SetBackgroundColour(*wxWHITE); + m_rename_text->SetMaxSize(wxSize(FromDIP(340), -1)); + rename_editable = new ScalableBitmap(this, "rename_edit", 20); + rename_editable_light = new ScalableBitmap(this, "rename_edit", 20); + m_rename_button = new wxStaticBitmap(m_rename_normal_panel, wxID_ANY, rename_editable->bmp(), wxDefaultPosition, wxSize(FromDIP(20), FromDIP(20)), 0); + m_rename_button->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); + m_rename_button->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); + + rename_sizer_h->Add(m_rename_text, 0, wxALIGN_CENTER|wxTOP, FromDIP(2)); rename_sizer_h->Add(m_rename_button, 0, wxALIGN_CENTER, 0); - rename_sizer_v->Add(rename_sizer_h, 1, wxALIGN_CENTER, 0); + rename_sizer_v->Add(rename_sizer_h, 1, wxTOP, 0); m_rename_normal_panel->SetSizer(rename_sizer_v); m_rename_normal_panel->Layout(); rename_sizer_v->Fit(m_rename_normal_panel); - //rename edit auto m_rename_edit_panel = new wxPanel(m_rename_switch_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_rename_edit_panel->SetBackgroundColour(*wxWHITE); auto rename_edit_sizer_v = new wxBoxSizer(wxVERTICAL); m_rename_input = new ::TextInput(m_rename_edit_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); m_rename_input->GetTextCtrl()->SetFont(::Label::Body_13); - m_rename_input->SetSize(wxSize(FromDIP(380), FromDIP(24))); - m_rename_input->SetMinSize(wxSize(FromDIP(380), FromDIP(24))); - m_rename_input->SetMaxSize(wxSize(FromDIP(380), FromDIP(24))); + m_rename_input->SetSize(wxSize(FromDIP(360), FromDIP(24))); + m_rename_input->SetMinSize(wxSize(FromDIP(360), FromDIP(24))); + m_rename_input->SetMaxSize(wxSize(FromDIP(360), FromDIP(24))); m_rename_input->Bind(wxEVT_TEXT_ENTER, [this](auto& e) {on_rename_enter();}); m_rename_input->Bind(wxEVT_KILL_FOCUS, [this](auto& e) { if (!m_rename_input->HasFocus() && !m_rename_text->HasFocus()) @@ -1045,7 +206,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_rename_edit_panel->Layout(); rename_edit_sizer_v->Fit(m_rename_edit_panel); - m_rename_button->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_rename_click, this); + m_rename_button->Bind(wxEVT_LEFT_DOWN, &SelectMachineDialog::on_rename_click, this); m_rename_switch_panel->AddPage(m_rename_normal_panel, wxEmptyString, true); m_rename_switch_panel->AddPage(m_rename_edit_panel, wxEmptyString, false); @@ -1065,91 +226,124 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) } }); - auto m_sizer_thumbnail_area = new wxBoxSizer(wxHORIZONTAL); - auto last_plate_panel = new wxWindow(m_scrollable_region, wxID_ANY); - last_plate_panel->SetBackgroundColour(*wxWHITE); + /*weight & time*/ + wxBoxSizer *m_sizer_basic_weight_time = new wxBoxSizer(wxHORIZONTAL); + + print_time = new ScalableBitmap(this, "print-time", 18); + timeimg = new wxStaticBitmap(m_basic_panel, wxID_ANY, print_time->bmp(), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0); + m_stext_time = new Label(m_basic_panel, wxEmptyString); + m_stext_time->SetFont(Label::Body_13); + + print_weight = new ScalableBitmap(this, "print-weight", 18); + weightimg = new wxStaticBitmap(m_basic_panel, wxID_ANY, print_weight->bmp(), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0); + m_stext_weight = new Label(m_basic_panel, wxEmptyString); + m_stext_weight->SetFont(Label::Body_13); + + m_sizer_basic_weight_time->Add(timeimg, 0, wxALIGN_CENTER, 0); + m_sizer_basic_weight_time->Add(m_stext_time, 0, wxALIGN_CENTER|wxLEFT, FromDIP(6)); + m_sizer_basic_weight_time->Add(weightimg, 0, wxALIGN_CENTER|wxLEFT, FromDIP(30)); + m_sizer_basic_weight_time->Add(m_stext_weight, 0, wxALIGN_CENTER|wxLEFT, FromDIP(6)); + + /*bed type*/ + m_text_bed_type = new Label(m_basic_panel); + m_text_bed_type->SetFont(Label::Body_13); + + /*last & next page*/ auto last_plate_sizer = new wxBoxSizer(wxVERTICAL); - last_plate_panel->SetMinSize(wxSize(FromDIP(32), FromDIP(32))); - m_bitmap_last_plate = new wxStaticBitmap(last_plate_panel, wxID_ANY, create_scaled_bitmap("go_last_plate", this, 32), wxDefaultPosition, wxSize(FromDIP(32), FromDIP(32)), 0); + m_bitmap_last_plate = new wxStaticBitmap(m_basic_panel, wxID_ANY, create_scaled_bitmap("go_last_plate", this, 25), wxDefaultPosition, wxSize(FromDIP(25), FromDIP(25)), 0); + m_bitmap_last_plate->Hide(); last_plate_sizer->Add(m_bitmap_last_plate, 0, wxALIGN_CENTER, 0); - last_plate_panel->SetSizer(last_plate_sizer); - - m_panel_image = new wxPanel(m_scrollable_region, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - m_panel_image->SetBackgroundColour(m_colour_def_color); - m_sizer_thumbnail = new wxBoxSizer(wxHORIZONTAL); - m_thumbnailPanel = new ThumbnailPanel(m_panel_image); - m_thumbnailPanel->SetSize(wxSize(FromDIP(256), FromDIP(256))); - m_thumbnailPanel->SetMinSize(wxSize(FromDIP(256), FromDIP(256))); - m_thumbnailPanel->SetMaxSize(wxSize(FromDIP(256), FromDIP(256))); - m_thumbnailPanel->SetBackgroundColour(*wxRED); - m_sizer_thumbnail->Add(m_thumbnailPanel, 0, wxALIGN_CENTER, 0); - m_panel_image->SetSizer(m_sizer_thumbnail); - m_panel_image->Layout(); - auto next_plate_panel = new wxWindow(m_scrollable_region, wxID_ANY); - next_plate_panel->SetBackgroundColour(*wxWHITE); auto next_plate_sizer = new wxBoxSizer(wxVERTICAL); - next_plate_panel->SetMinSize(wxSize(FromDIP(32), FromDIP(32))); - m_bitmap_next_plate = new wxStaticBitmap(next_plate_panel, wxID_ANY, create_scaled_bitmap("go_next_plate", this, 32), wxDefaultPosition, wxSize(FromDIP(32), FromDIP(32)), 0); + m_bitmap_next_plate = new wxStaticBitmap(m_basic_panel, wxID_ANY, create_scaled_bitmap("go_next_plate", this, 25), wxDefaultPosition, wxSize(FromDIP(25), FromDIP(25)), 0); + m_bitmap_next_plate->Hide(); next_plate_sizer->Add(m_bitmap_next_plate, 0, wxALIGN_CENTER, 0); - next_plate_panel->SetSizer(next_plate_sizer); - m_sizer_thumbnail_area->Add(last_plate_panel, 0, wxALIGN_CENTER, 0); - m_sizer_thumbnail_area->Add(m_panel_image, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(24)); - m_sizer_thumbnail_area->Add(next_plate_panel, 0, wxALIGN_CENTER, 0); + sizer_rename->Add(m_rename_switch_panel, 0, wxALIGN_CENTER, 0); + sizer_rename->Add(0, 0, 0, wxEXPAND, 0); + sizer_rename->Add(m_bitmap_last_plate, 0, wxALIGN_CENTER, 0); + sizer_rename->Add(m_bitmap_next_plate, 0, wxALIGN_CENTER, 0); + + /*printer combobox*/ + wxBoxSizer* m_sizer_printer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer* sizer_split_printer = new wxBoxSizer(wxHORIZONTAL); + m_stext_printer_title = new Label(m_basic_panel, _L("Printer")); + m_stext_printer_title->SetFont(::Label::Body_14); + m_stext_printer_title->SetForegroundColour(0x909090); + auto m_split_line = new wxPanel(m_basic_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_split_line->SetBackgroundColour(0xeeeeee); + m_split_line->SetMinSize(wxSize(-1, 1)); + m_split_line->SetMaxSize(wxSize(-1, 1)); + sizer_split_printer->Add(0, 0, 0, wxEXPAND, 0); + sizer_split_printer->Add(m_stext_printer_title, 0, wxALIGN_CENTER, 0); + sizer_split_printer->Add(m_split_line, 1, wxALIGN_CENTER_VERTICAL, 0); + + + m_comboBox_printer = new ::ComboBox(m_basic_panel, wxID_ANY, "", wxDefaultPosition, wxSize(FromDIP(300), -1), 0, nullptr, wxCB_READONLY); + m_comboBox_printer->SetMinSize(wxSize(FromDIP(300), -1)); + m_comboBox_printer->SetMaxSize(wxSize(FromDIP(300), -1)); + m_comboBox_printer->Bind(wxEVT_COMBOBOX, &SelectMachineDialog::on_selection_changed, this); - wxBoxSizer *m_sizer_basic = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer *m_sizer_basic_weight = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer *m_sizer_basic_time = new wxBoxSizer(wxHORIZONTAL); - print_time = new ScalableBitmap(this, "print-time", 18); - timeimg = new wxStaticBitmap(m_scrollable_region, wxID_ANY, print_time->bmp(), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0); - m_sizer_basic_weight->Add(timeimg, 1, wxEXPAND | wxALL, FromDIP(5)); - m_stext_time = new wxStaticText(m_scrollable_region, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); - m_sizer_basic_weight->Add(m_stext_time, 0, wxALL, FromDIP(5)); - m_sizer_basic->Add(m_sizer_basic_weight, 0, wxALIGN_CENTER, 0); - m_sizer_basic->Add(0, 0, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); + m_btn_bg_enable = StateColor(std::pair(wxColour(0, 137, 123), StateColor::Pressed), std::pair(wxColour(38, 166, 154), StateColor::Hovered), + std::pair(wxColour(0, 150, 136), StateColor::Normal)); - print_weight = new ScalableBitmap(this, "print-weight", 18); - weightimg = new wxStaticBitmap(m_scrollable_region, wxID_ANY, print_weight->bmp(), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0); - m_sizer_basic_time->Add(weightimg, 1, wxEXPAND | wxALL, FromDIP(5)); - m_stext_weight = new wxStaticText(m_scrollable_region, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - m_sizer_basic_time->Add(m_stext_weight, 0, wxALL, FromDIP(5)); - m_sizer_basic->Add(m_sizer_basic_time, 0, wxALIGN_CENTER, 0); - - wxBoxSizer* m_sizer_material_area = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* m_sizer_material_tips = new wxBoxSizer(wxHORIZONTAL); - - enable_ams_mapping = new ScalableBitmap(this, "enable_ams", 16); - img_amsmapping_tip = new wxStaticBitmap(m_scrollable_region, wxID_ANY, enable_ams_mapping->bmp(), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0); - m_sizer_material_tips->Add(img_amsmapping_tip, 0, wxALIGN_CENTER | wxLEFT, FromDIP(5)); - - img_amsmapping_tip->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { - wxPoint img_pos = img_amsmapping_tip->ClientToScreen(wxPoint(0, 0)); - wxPoint popup_pos(img_pos.x, img_pos.y + img_amsmapping_tip->GetRect().height); - m_mapping_tutorial_popup.Position(popup_pos, wxSize(0, 0)); - m_mapping_tutorial_popup.Popup(); - - if (m_mapping_tutorial_popup.ClientToScreen(wxPoint(0, 0)).y < img_pos.y) { - m_mapping_tutorial_popup.Dismiss(); - popup_pos = wxPoint(img_pos.x, img_pos.y - m_mapping_tutorial_popup.GetRect().height); - m_mapping_tutorial_popup.Position(popup_pos, wxSize(0, 0)); - m_mapping_tutorial_popup.Popup(); - } - }); + m_button_refresh = new Button(m_basic_panel, _L("Refresh")); + m_button_refresh->SetBackgroundColor(m_btn_bg_enable); + m_button_refresh->SetBorderColor(m_btn_bg_enable); + m_button_refresh->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); + m_button_refresh->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); + m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); + m_button_refresh->SetCornerRadius(FromDIP(10)); + m_button_refresh->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_refresh, this); + + m_sizer_printer->Add(m_comboBox_printer, 0, wxEXPAND, 0); + m_sizer_printer->Add(m_button_refresh, 0, wxALL | wxLEFT, FromDIP(5)); + + m_text_printer_msg = new wxStaticText(m_basic_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + m_text_printer_msg->SetMinSize(wxSize(FromDIP(420), -1)); + m_text_printer_msg->SetMaxSize(wxSize(FromDIP(420), -1)); + m_text_printer_msg->SetFont(::Label::Body_13); + m_text_printer_msg->Hide(); + + + sizer_basic_right_info->Add(sizer_rename, 0, wxTOP, 0); + sizer_basic_right_info->Add(0, 0, 0, wxTOP, FromDIP(5)); + sizer_basic_right_info->Add(m_sizer_basic_weight_time, 0, wxTOP, 0); + sizer_basic_right_info->Add(0, 0, 0, wxTOP, FromDIP(10)); + sizer_basic_right_info->Add(m_text_bed_type, 0, wxTOP, 0); + sizer_basic_right_info->Add(0, 0, 0, wxTOP, FromDIP(15)); + sizer_basic_right_info->Add(sizer_split_printer, 1, wxEXPAND, 0); + sizer_basic_right_info->Add(0, 0, 0, wxTOP, FromDIP(8)); + sizer_basic_right_info->Add(m_sizer_printer, 0, wxTOP, 0); + sizer_basic_right_info->Add(0, 0, 0, wxTOP, FromDIP(4)); + sizer_basic_right_info->Add(m_text_printer_msg, 0, wxLEFT, 0); + + + m_basicl_sizer->Add(m_sizer_thumbnail_area, 0, wxLEFT, 0); + m_basicl_sizer->Add(0, 0, 0, wxLEFT, FromDIP(8)); + m_basicl_sizer->Add(sizer_basic_right_info, 0, wxLEFT, 0); - img_amsmapping_tip->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { - m_mapping_tutorial_popup.Dismiss(); - }); - m_sizer_material = new wxGridSizer(0, 4, 0, FromDIP(5)); + m_basic_panel->SetSizer(m_basicl_sizer); + m_basic_panel->Layout(); - m_sizer_material_area->Add(m_sizer_material_tips, 0, wxALIGN_CENTER|wxLEFT, FromDIP(8)); - m_sizer_material_area->Add(m_sizer_material, 0, wxLEFT, FromDIP(15)); - m_sizer_backup = new wxBoxSizer(wxHORIZONTAL); + /*filaments info*/ + wxBoxSizer* sizer_split_filament = new wxBoxSizer(wxHORIZONTAL); + + auto m_stext_filament_title = new Label(this, _L("Filament")); + m_stext_filament_title->SetFont(::Label::Body_14); + m_stext_filament_title->SetForegroundColour(0x909090); + + auto m_split_line_filament = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); + m_split_line_filament->SetBackgroundColour(0xeeeeee); + m_split_line_filament->SetMinSize(wxSize(-1, 1)); + m_split_line_filament->SetMaxSize(wxSize(-1, 1)); + + m_sizer_autorefill = new wxBoxSizer(wxHORIZONTAL); m_ams_backup_tip = new Label(this, _L("Auto Refill")); m_ams_backup_tip->SetFont(::Label::Head_12); m_ams_backup_tip->SetForegroundColour(wxColour(0x009688)); @@ -1157,9 +351,9 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) img_ams_backup = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("automatic_material_renewal", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0); img_ams_backup->SetBackgroundColour(*wxWHITE); - m_sizer_backup->Add(0, 0, 1, wxEXPAND, 0); - m_sizer_backup->Add(img_ams_backup, 0, wxALL, FromDIP(3)); - m_sizer_backup->Add(m_ams_backup_tip, 0, wxTOP, FromDIP(5)); + m_sizer_autorefill->Add(0, 0, 1, wxEXPAND, 0); + m_sizer_autorefill->Add(img_ams_backup, 0, wxALL, FromDIP(3)); + m_sizer_autorefill->Add(m_ams_backup_tip, 0, wxTOP, FromDIP(5)); m_ams_backup_tip->Hide(); img_ams_backup->Hide(); @@ -1170,71 +364,104 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_ams_backup_tip->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); img_ams_backup->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); - m_ams_backup_tip->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { if (!m_is_in_sending_mode) {popup_filament_backup(); on_rename_enter();} }); - img_ams_backup->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {if (!m_is_in_sending_mode) popup_filament_backup();on_rename_enter(); }); + m_ams_backup_tip->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { if (!m_is_in_sending_mode) { popup_filament_backup(); on_rename_enter(); } }); + img_ams_backup->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {if (!m_is_in_sending_mode) popup_filament_backup(); on_rename_enter(); }); + + sizer_split_filament->Add(0, 0, 0, wxEXPAND, 0); + sizer_split_filament->Add(m_stext_filament_title, 0, wxALIGN_CENTER, 0); + sizer_split_filament->Add(m_split_line_filament, 1, wxALIGN_CENTER_VERTICAL, 0); + sizer_split_filament->Add(m_sizer_autorefill, 0, wxALIGN_CENTER, 0); + + /*filament area*/ + /*1 extruder*/ + m_filament_panel = new wxPanel(this, wxID_ANY); + m_filament_panel->SetBackgroundColour(wxColour(0xf8f8f8)); + m_filament_panel->SetMinSize(wxSize(FromDIP(637), -1)); + m_filament_panel->SetMaxSize(wxSize(FromDIP(637), -1)); + m_filament_panel_sizer = new wxBoxSizer(wxVERTICAL); + + m_sizer_ams_mapping = new wxGridSizer(0, 10, FromDIP(7), FromDIP(7)); + m_filament_panel_sizer->Add(m_sizer_ams_mapping, 0, wxEXPAND|wxALL, FromDIP(10)); + m_filament_panel->SetSizer(m_filament_panel_sizer); + m_filament_panel->Layout(); + m_filament_panel->Fit(); + + /*left & right extruder*/ + m_sizer_filament_2extruder = new wxBoxSizer(wxHORIZONTAL); + m_filament_left_panel = new wxPanel(this, wxID_ANY); + m_filament_right_panel = new wxPanel(this, wxID_ANY); + m_filament_left_panel->SetBackgroundColour(wxColour(0xf8f8f8)); + m_filament_right_panel->SetBackgroundColour(wxColour(0xf8f8f8)); + m_filament_left_panel->SetMinSize(wxSize(FromDIP(315), 180)); + m_filament_left_panel->SetMaxSize(wxSize(FromDIP(315), 180)); + m_filament_right_panel->SetMinSize(wxSize(FromDIP(315), 180)); + m_filament_right_panel->SetMaxSize(wxSize(FromDIP(315), 180)); + + m_filament_panel_left_sizer = new wxBoxSizer(wxVERTICAL); + m_sizer_ams_mapping_left = new wxGridSizer(0, 5, FromDIP(7), FromDIP(7)); + m_filament_panel_left_sizer->Add(m_sizer_ams_mapping_left, 0, wxEXPAND | wxALL, FromDIP(10)); + m_filament_left_panel->SetSizer(m_filament_panel_left_sizer); + m_filament_left_panel->Layout(); + m_filament_left_panel->Fit(); + + m_filament_panel_right_sizer = new wxBoxSizer(wxVERTICAL); + m_sizer_ams_mapping_right = new wxGridSizer(0, 5, FromDIP(7), FromDIP(7)); + m_filament_panel_right_sizer->Add(m_sizer_ams_mapping_right, 0, wxEXPAND | wxALL, FromDIP(10)); + m_filament_right_panel->SetSizer(m_filament_panel_right_sizer); + m_filament_right_panel->Layout(); + m_filament_right_panel->Fit(); + + m_sizer_filament_2extruder->Add(m_filament_left_panel, 0, wxALIGN_CENTER, 0); + m_sizer_filament_2extruder->Add(0, 0, 0, wxLEFT, FromDIP(7)); + m_sizer_filament_2extruder->Add(m_filament_right_panel, 0, wxALIGN_CENTER, 0); + m_sizer_filament_2extruder->Layout(); + + m_filament_left_panel->Hide(); + m_filament_right_panel->Hide(); - m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); - m_statictext_ams_msg->SetFont(::Label::Body_13); - m_statictext_ams_msg->Hide(); - m_line_materia = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); - m_line_materia->SetForegroundColour(wxColour(238, 238, 238)); - m_line_materia->SetBackgroundColour(wxColour(238, 238, 238)); - wxBoxSizer *m_sizer_printer = new wxBoxSizer(wxHORIZONTAL); - m_stext_printer_title = new wxStaticText(this, wxID_ANY, _L("Printer"), wxDefaultPosition, wxSize(-1, -1), 0); - m_stext_printer_title->SetFont(::Label::Head_14); - m_stext_printer_title->Wrap(-1); - m_stext_printer_title->SetForegroundColour(m_colour_bold_color); - m_stext_printer_title->SetBackgroundColour(m_colour_def_color); - m_sizer_printer->Add(m_stext_printer_title, 0, wxALL | wxLEFT, FromDIP(5)); - m_sizer_printer->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(12)); + m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); + m_statictext_ams_msg->SetFont(::Label::Body_13); + m_statictext_ams_msg->Hide(); - m_comboBox_printer = new ::ComboBox(this, wxID_ANY, "", wxDefaultPosition, wxSize(FromDIP(250), -1), 0, nullptr, wxCB_READONLY); - m_comboBox_printer->Bind(wxEVT_COMBOBOX, &SelectMachineDialog::on_selection_changed, this); - m_sizer_printer->Add(m_comboBox_printer, 1, wxEXPAND | wxRIGHT, FromDIP(5)); - m_btn_bg_enable = StateColor(std::pair(wxColour(0, 137, 123), StateColor::Pressed), std::pair(wxColour(38, 166, 154), StateColor::Hovered), - std::pair(wxColour(0, 150, 136), StateColor::Normal)); - m_button_refresh = new Button(this, _L("Refresh")); - m_button_refresh->SetBackgroundColor(m_btn_bg_enable); - m_button_refresh->SetBorderColor(m_btn_bg_enable); - m_button_refresh->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); - m_button_refresh->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_refresh->SetCornerRadius(FromDIP(10)); - m_button_refresh->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_refresh, this); - m_sizer_printer->Add(m_button_refresh, 0, wxALL | wxLEFT, FromDIP(5)); + /*options*/ + wxBoxSizer* sizer_split_options = new wxBoxSizer(wxHORIZONTAL); + auto m_stext_options_title = new Label(this, _L("Print Options")); + m_stext_options_title->SetFont(::Label::Body_14); + m_stext_options_title->SetForegroundColour(0x909090); + auto m_split_options_line = new wxPanel(this, wxID_ANY); + m_split_options_line->SetBackgroundColour(0xeeeeee); + m_split_options_line->SetSize(wxSize(-1, FromDIP(1))); + m_split_options_line->SetMinSize(wxSize(-1, FromDIP(1))); + m_split_options_line->SetMaxSize(wxSize(-1, FromDIP(1))); + sizer_split_options->Add(0, 0, 0, wxEXPAND, 0); + sizer_split_options->Add(m_stext_options_title, 0, wxALIGN_CENTER, 0); + sizer_split_options->Add(m_split_options_line, 1, wxALIGN_CENTER_VERTICAL, 0); - m_statictext_printer_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); - m_statictext_printer_msg->SetFont(::Label::Body_13); - m_statictext_printer_msg->Hide(); - //m_sizer_select = new wxGridSizer(0, 2, 0, 0); - m_sizer_select = new wxWrapSizer(); + m_sizer_options = new wxBoxSizer(wxHORIZONTAL); select_bed = create_item_checkbox(_L("Bed Leveling"), this, _L("Bed Leveling"), "bed_leveling"); select_flow = create_item_checkbox(_L("Flow Dynamics Calibration"), this, _L("Flow Dynamics Calibration"), "flow_cali"); select_timelapse = create_item_checkbox(_L("Timelapse"), this, _L("Timelapse"), "timelapse"); select_use_ams = create_ams_checkbox(_L("Enable AMS"), this, _L("Enable AMS")); - m_sizer_select->Add(select_bed, 0, wxLEFT | wxRIGHT, WRAP_GAP); - m_sizer_select->Add(select_flow, 0, wxLEFT | wxRIGHT, WRAP_GAP); - m_sizer_select->Add(select_timelapse, 0, wxLEFT | wxRIGHT, WRAP_GAP); - m_sizer_select->Add(select_use_ams, 0, wxLEFT | wxRIGHT, WRAP_GAP); + m_sizer_options->Add(select_bed, 0, wxLEFT | wxRIGHT, WRAP_GAP); + m_sizer_options->Add(select_flow, 0, wxLEFT | wxRIGHT, WRAP_GAP); + m_sizer_options->Add(select_timelapse, 0, wxLEFT | wxRIGHT, WRAP_GAP); + m_sizer_options->Add(select_use_ams, 0, wxLEFT | wxRIGHT, WRAP_GAP); select_bed->Show(false); select_flow->Show(false); select_timelapse->Show(false); select_use_ams->Show(false); - m_sizer_select->Layout(); + m_sizer_options->Layout(); - // line schedule - m_line_schedule = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); - m_line_schedule->SetBackgroundColour(wxColour(238, 238, 238)); m_simplebook = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_DIALOG_SIMBOOK_SIZE, 0); @@ -1259,7 +486,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_button_ensure->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_ensure->SetCornerRadius(FromDIP(12)); + m_button_ensure->SetCornerRadius(FromDIP(5)); m_button_ensure->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_ok_btn, this); m_sizer_pcont->Add(0, 0, 1, wxEXPAND, 0); @@ -1384,37 +611,20 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) sizer_print_failed_info->Add(0, 0, 0, wxTOP, FromDIP(3)); sizer_print_failed_info->Add(sizer_extra_info, 0, wxLEFT, 5); - m_sizer_scrollable_region->Add(m_rename_switch_panel, 0, wxALIGN_CENTER_HORIZONTAL, 0); - m_sizer_scrollable_region->Add(0, 0, 0, wxTOP, FromDIP(8)); - m_sizer_scrollable_region->Add(m_sizer_thumbnail_area, 0, wxALIGN_CENTER_HORIZONTAL, 0); - m_sizer_scrollable_region->Add(0, 0, 0, wxTOP, FromDIP(10)); - m_sizer_scrollable_region->Add(m_sizer_basic, 0, wxALIGN_CENTER_HORIZONTAL, 0); - //m_sizer_scrollable_region->Add(m_sizer_material, 0, wxALIGN_CENTER_HORIZONTAL, 0); - m_sizer_scrollable_region->Add(m_sizer_material_area, 0, wxLEFT, FromDIP(10)); - - m_scrollable_region->SetSizer(m_sizer_scrollable_region); - m_scrollable_region->Layout(); - - m_scrollable_view->SetSizer(m_sizer_scrollable_view); - m_scrollable_view->Layout(); - m_sizer_scrollable_view->Add(m_scrollable_region, 0, wxEXPAND, 0); m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0); - m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(13)); - m_sizer_main->Add(m_scrollable_view, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, FromDIP(25)); - m_sizer_main->Add(m_sizer_backup, 0, wxALIGN_CENTER_HORIZONTAL, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(12)); + m_sizer_main->Add(m_basic_panel, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15)); + m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14)); + m_sizer_main->Add(sizer_split_filament, 1, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15)); + m_sizer_main->Add(m_filament_panel, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(15)); + m_sizer_main->Add(m_sizer_filament_2extruder, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(15)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6)); - m_sizer_main->Add(m_statictext_ams_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0); - m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6)); - m_sizer_main->Add(m_line_materia, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); - m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(12)); - m_sizer_main->Add(m_sizer_printer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); - m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(11)); - m_sizer_main->Add(m_statictext_printer_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0); - m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(16)); - m_sizer_main->Add(m_sizer_select, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(30)); - m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(10)); - m_sizer_main->Add(m_line_schedule, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); + m_sizer_main->Add(m_statictext_ams_msg, 0, wxLEFT, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(16)); + m_sizer_main->Add(sizer_split_options, 1, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15)); + m_sizer_main->Add(m_sizer_options, 0, wxLEFT|wxRIGHT, FromDIP(15)); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10)); m_sizer_main->Add(m_simplebook, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_sw_print_failed_info, 0, wxALIGN_CENTER, 0); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(18)); @@ -1442,7 +652,7 @@ void SelectMachineDialog::init_bind() Bind(EVT_SET_FINISH_MAPPING, &SelectMachineDialog::on_set_finish_mapping, this); Bind(wxEVT_LEFT_DOWN, [this](auto& e) {check_fcous_state(this);e.Skip();}); m_panel_prepare->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {check_fcous_state(this);e.Skip();}); - m_scrollable_region->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {check_fcous_state(this);e.Skip();}); + m_basic_panel->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {check_fcous_state(this);e.Skip();}); m_bitmap_last_plate->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); m_bitmap_last_plate->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); m_bitmap_next_plate->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); @@ -1676,7 +886,7 @@ wxWindow *SelectMachineDialog::create_item_checkbox(wxString title, wxWindow *pa void SelectMachineDialog::update_select_layout(MachineObject *obj) { - if (obj && obj->is_support_flow_calibration) { + if (obj && obj->is_support_auto_flow_calibration) { select_flow->Show(); } else { select_flow->Hide(); @@ -1695,7 +905,7 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj) select_timelapse->Hide(); } - m_sizer_select->Layout(); + m_sizer_options->Layout(); Layout(); Fit(); } @@ -1840,14 +1050,17 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_) if (result == 0) { print_ams_mapping_result(m_ams_mapping_result); std::string ams_array; + std::string ams_array2; std::string mapping_info; - get_ams_mapping_result(ams_array, mapping_info); + get_ams_mapping_result(ams_array, ams_array2, mapping_info); if (ams_array.empty()) { reset_ams_material(); BOOST_LOG_TRIVIAL(info) << "ams_mapping_array=[]"; } else { sync_ams_mapping_result(m_ams_mapping_result); BOOST_LOG_TRIVIAL(info) << "ams_mapping_array=" << ams_array; + BOOST_LOG_TRIVIAL(info) << "ams_mapping_array2=" << ams_array2; + BOOST_LOG_TRIVIAL(info) << "ams_mapping_info=" << mapping_info; } return obj_->is_valid_mapping_result(m_ams_mapping_result); } else { @@ -1861,13 +1074,13 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_) } } sync_ams_mapping_result(m_ams_mapping_result); - return is_valid; + return is_valid; } return true; } -bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str, std::string &ams_mapping_info) +bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str, std::string& mapping_array_str2, std::string &ams_mapping_info) { if (m_ams_mapping_result.empty()) return false; @@ -1884,17 +1097,28 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str, if (invalid_count == m_ams_mapping_result.size()) { return false; } else { - json j = json::array(); - json mapping_info_json = json::array(); + + json mapping_v0_json = json::array(); + json mapping_v1_json = json::array(); + + json mapping_info_json = json::array(); for (int i = 0; i < wxGetApp().preset_bundle->filament_presets.size(); i++) { + int tray_id = -1; + + json mapping_item_v1; + mapping_item_v1["ams_id"] = 0xff; + mapping_item_v1["slot_id"] = 0xff; + json mapping_item; mapping_item["ams"] = tray_id; mapping_item["targetColor"] = ""; mapping_item["filamentId"] = ""; mapping_item["filamentType"] = ""; + + for (int k = 0; k < m_ams_mapping_result.size(); k++) { if (m_ams_mapping_result[k].id == i) { tray_id = m_ams_mapping_result[k].tray_id; @@ -1907,18 +1131,91 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str, //convert #RRGGBB to RRGGBBAA mapping_item["sourceColor"] = m_filaments[k].color; mapping_item["targetColor"] = m_ams_mapping_result[k].color; + + + /*new ams mapping data*/ + + try + { + if (m_ams_mapping_result[k].ams_id.empty() || m_ams_mapping_result[k].slot_id.empty()) { // invalid case + mapping_item_v1["ams_id"] = 255; // TODO: Orca hack + mapping_item_v1["slot_id"] = 255; + } + else { + mapping_item_v1["ams_id"] = std::stoi(m_ams_mapping_result[k].ams_id); + mapping_item_v1["slot_id"] = std::stoi(m_ams_mapping_result[k].slot_id); + } + } + catch (...) + { + } } } - j.push_back(tray_id); + mapping_v0_json.push_back(tray_id); + mapping_v1_json.push_back(mapping_item_v1); mapping_info_json.push_back(mapping_item); } - mapping_array_str = j.dump(); + + + mapping_array_str = mapping_v0_json.dump(); + mapping_array_str2 = mapping_v1_json.dump(); + ams_mapping_info = mapping_info_json.dump(); return valid_mapping_result; } return true; } +bool SelectMachineDialog::build_nozzles_info(std::string& nozzles_info) +{ + /* init nozzles info */ + json nozzle_info_json = json::array(); + nozzles_info = nozzle_info_json.dump(); + + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + if (!preset_bundle) + return false; + auto opt_nozzle_diameters = preset_bundle->printers.get_edited_preset().config.option("nozzle_diameter"); + if (opt_nozzle_diameters == nullptr) { + BOOST_LOG_TRIVIAL(error) << "build_nozzles_info, opt_nozzle_diameters is nullptr"; + return false; + } + //auto opt_nozzle_volume_type = preset_bundle->project_config.option("nozzle_volume_type"); + //if (opt_nozzle_volume_type == nullptr) { + // BOOST_LOG_TRIVIAL(error) << "build_nozzles_info, opt_nozzle_volume_type is nullptr"; + // return false; + //} + json nozzle_item; + /* only o1d two nozzles has build_nozzles info now */ + if (opt_nozzle_diameters->size() != 2) { + return false; + } + for (size_t i = 0; i < opt_nozzle_diameters->size(); i++) { + if (i == (size_t)ConfigNozzleIdx::NOZZLE_LEFT) { + nozzle_item["id"] = CloudTaskNozzleId::NOZZLE_LEFT; + } + else if (i == (size_t)ConfigNozzleIdx::NOZZLE_RIGHT) { + nozzle_item["id"] = CloudTaskNozzleId::NOZZLE_RIGHT; + } + else { + /* unknown ConfigNozzleIdx */ + BOOST_LOG_TRIVIAL(error) << "build_nozzles_info, unknown ConfigNozzleIdx = " << i; + assert(false); + continue; + } + nozzle_item["type"] = nullptr; + //if (i >= 0 && i < opt_nozzle_volume_type->size()) { + nozzle_item["flowSize"] = "standard_flow"; // TODO: Orca hack + //} + if (i >= 0 && i < opt_nozzle_diameters->size()) { + nozzle_item["diameter"] = opt_nozzle_diameters->get_at(i); + } + nozzle_info_json.push_back(nozzle_item); + } + nozzles_info = nozzle_info_json.dump(); + return true; +} + void SelectMachineDialog::prepare(int print_plate_idx) { m_print_plate_idx = print_plate_idx; @@ -1962,12 +1259,12 @@ void SelectMachineDialog::update_ams_status_msg(wxString msg, bool is_warning) void SelectMachineDialog::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); + m_text_printer_msg->SetForegroundColour(colour); if (msg.empty()) { - if (!m_statictext_printer_msg->GetLabel().empty()) { - m_statictext_printer_msg->SetLabel(wxEmptyString); - m_statictext_printer_msg->Hide(); + if (!m_text_printer_msg->GetLabel().empty()) { + m_text_printer_msg->SetLabel(wxEmptyString); + m_text_printer_msg->Hide(); Layout(); Fit(); } @@ -1977,16 +1274,16 @@ void SelectMachineDialog::update_priner_status_msg(wxString msg, bool is_warning auto str_new = msg.utf8_string(); stripWhiteSpace(str_new); - auto str_old = m_statictext_printer_msg->GetLabel().utf8_string(); + auto str_old = m_text_printer_msg->GetLabel().utf8_string(); stripWhiteSpace(str_old); if (str_new != str_old) { - if (m_statictext_printer_msg->GetLabel() != msg) { - m_statictext_printer_msg->SetLabel(msg); - m_statictext_printer_msg->SetMinSize(wxSize(FromDIP(400), -1)); - m_statictext_printer_msg->SetMaxSize(wxSize(FromDIP(400), -1)); - m_statictext_printer_msg->Wrap(FromDIP(400)); - m_statictext_printer_msg->Show(); + if (m_text_printer_msg->GetLabel() != msg) { + m_text_printer_msg->SetLabel(msg); + m_text_printer_msg->SetMinSize(wxSize(FromDIP(420), -1)); + m_text_printer_msg->SetMaxSize(wxSize(FromDIP(420), -1)); + m_text_printer_msg->Wrap(FromDIP(420)); + m_text_printer_msg->Show(); Layout(); Fit(); } @@ -2262,8 +1559,8 @@ bool SelectMachineDialog::is_blocking_printing(MachineObject* obj_) if (m_print_type == PrintFromType::FROM_NORMAL) { PresetBundle* preset_bundle = wxGetApp().preset_bundle; source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); - - + + }else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) { if (m_required_data_plate_data_list.size() > 0) { source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id; @@ -2281,81 +1578,52 @@ bool SelectMachineDialog::is_blocking_printing(MachineObject* obj_) return false; } -bool SelectMachineDialog::is_same_nozzle_diameters(std::string& tag_nozzle_type, std::string& nozzle_diameter) -{ - bool is_same_nozzle_diameters = true; - - float preset_nozzle_diameters; - std::string preset_nozzle_type; +/**************************************************************//* + * @param tag_nozzle_type -- return the mismatch nozzle type + * @param tag_nozzle_diameter -- return the target nozzle_diameter but mismatch + * @return is same or not +/*************************************************************/ +bool SelectMachineDialog::is_same_nozzle_diameters(float &tag_nozzle_diameter) const +{ DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (!dev) return true; + if (!dev) return false; MachineObject* obj_ = dev->get_selected_machine(); - if (obj_ == nullptr) return true; + if (obj_ == nullptr) return false; - try + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + auto opt_nozzle_diameters = preset_bundle->printers.get_edited_preset().config.option("nozzle_diameter"); + if (!opt_nozzle_diameters) { - PresetBundle* preset_bundle = wxGetApp().preset_bundle; - auto opt_nozzle_diameters = preset_bundle->printers.get_edited_preset().config.option("nozzle_diameter"); - - const ConfigOptionEnum* nozzle_type = preset_bundle->printers.get_edited_preset().config.option>("nozzle_type"); - - if (nozzle_type->value == NozzleType::ntHardenedSteel) { - preset_nozzle_type = "hardened_steel"; - } - else if (nozzle_type->value == NozzleType::ntStainlessSteel) { - preset_nozzle_type = "stainless_steel"; - } - - tag_nozzle_type = obj_->nozzle_type; + return false; + } - auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders(); - if (opt_nozzle_diameters != nullptr) { - for (auto i = 0; i < extruders.size(); i++) { - auto extruder = extruders[i] - 1; - preset_nozzle_diameters = float(opt_nozzle_diameters->get_at(extruder)); - if (preset_nozzle_diameters != obj_->nozzle_diameter) { - is_same_nozzle_diameters = false; - } + try + { + auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders(); + for (auto i = 0; i < extruders.size(); i++) { + auto extruder = extruders[i] - 1; + tag_nozzle_diameter = float(opt_nozzle_diameters->get_at(extruder)); + if (tag_nozzle_diameter != obj_->m_extder_data.extders[0].current_nozzle_diameter) { + return false; } } - } - catch (...) + catch (const std::exception&) { + return false; } - //nozzle_type = preset_nozzle_type; - nozzle_diameter = wxString::Format("%.2f", preset_nozzle_diameters).ToStdString(); - - return is_same_nozzle_diameters; + return true; } -bool SelectMachineDialog::is_same_nozzle_type(std::string& filament_type, std::string& tag_nozzle_type) +bool SelectMachineDialog::is_same_nozzle_type(const Extder& extruder, std::string& filament_type) const { - bool is_same_nozzle_type = true; - - DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (!dev) return true; - - MachineObject* obj_ = dev->get_selected_machine(); - 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; - } - - auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(nozzle_type); + auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(extruder.current_nozzle_type); auto preset_bundle = wxGetApp().preset_bundle; - MaterialHash::iterator iter = m_materialList.begin(); + MaterialHash::const_iterator iter = m_materialList.begin(); while (iter != m_materialList.end()) { Material* item = iter->second; MaterialItem* m = item->item; @@ -2364,18 +1632,13 @@ bool SelectMachineDialog::is_same_nozzle_type(std::string& filament_type, std::s if (abs(filament_nozzle_hrc) > abs(printer_nozzle_hrc)) { filament_type = m->m_material_name.ToStdString(); BOOST_LOG_TRIVIAL(info) << "filaments hardness mismatch: filament = " << filament_type << " printer_nozzle_hrc = " << printer_nozzle_hrc; - is_same_nozzle_type = false; - tag_nozzle_type = "hardened_steel"; - return is_same_nozzle_type; - } - else { - tag_nozzle_type = obj_->nozzle_type; + return false; } iter++; } - return is_same_nozzle_type; + return true; } bool SelectMachineDialog::is_same_printer_model() @@ -2398,7 +1661,7 @@ bool SelectMachineDialog::is_same_printer_model() // Orca: ignore P1P -> P1S if (source_model != target_model) { if ((source_model == "C12" && target_model == "C11") || (source_model == "C11" && target_model == "C12") || - (obj_->is_support_p1s_plus && (source_model == "C12"))) { + ((obj_->is_support_upgrade_kit && obj_->installed_upgrade_kit) && (source_model == "C12"))) { return true; } @@ -2407,7 +1670,7 @@ bool SelectMachineDialog::is_same_printer_model() return false; } - if (obj_->is_support_p1s_plus) { + if (obj_->is_support_upgrade_kit && obj_->installed_upgrade_kit) { BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << source_model; BOOST_LOG_TRIVIAL(info) << "printer_model: target = " << obj_->printer_type << " (plus)"; return false; @@ -2495,7 +1758,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) wxString error_info = Plater::get_slice_warning_string(warning); if (error_info.IsEmpty()) { error_info = wxString::Format("%s\n", warning.msg); - } + } confirm_text.push_back(ConfirmBeforeSendInfo(error_info)); has_slice_warnings = true; @@ -2558,17 +1821,16 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) confirm_text.push_back(ConfirmBeforeSendInfo(_L("There are some unknown filaments in the AMS mappings. Please check whether they are the required filaments. If they are okay, press \"Confirm\" to start printing."))); } - std::string nozzle_diameter; - std::string filament_type; - std::string tag_nozzle_type; - - if (!obj_->nozzle_type.empty() && (m_print_type == PrintFromType::FROM_NORMAL)) { - if (!is_same_nozzle_diameters(tag_nozzle_type, nozzle_diameter)) { + if (!obj_->m_extder_data.extders[0].current_nozzle_type != ntUndefine && (m_print_type == PrintFromType::FROM_NORMAL)) + { + float nozzle_diameter = 0; + if (!is_same_nozzle_diameters(nozzle_diameter)) + { has_slice_warnings = true; // is_printing_block = true; # Removed to allow nozzle overrides (to support non-standard nozzles) - wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %s %s"),nozzle_diameter, ""); - wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.2f %s"), obj_->nozzle_diameter, ""); + wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %.1f %s"),nozzle_diameter, ""); + wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj_->m_extder_data.extders[0].current_nozzle_diameter, ""); confirm_text.push_back(ConfirmBeforeSendInfo(_L("Your nozzle diameter in sliced file is not consistent with memorized nozzle. If you changed your nozzle lately, please go to Device > Printer Parts to change settings.") + "\n " + nozzle_in_preset @@ -2576,12 +1838,13 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) + "\n", ConfirmBeforeSendInfo::InfoLevel::Warning)); } - if (!is_same_nozzle_type(filament_type, tag_nozzle_type)){ + std::string filament_type; + if (!is_same_nozzle_type(obj_->m_extder_data.extders[0], filament_type)) + { has_slice_warnings = true; is_printing_block = true; - nozzle_diameter = wxString::Format("%.1f", obj_->nozzle_diameter).ToStdString(); - wxString nozzle_in_preset = wxString::Format(_L("Printing high temperature material (%s material) with %s may cause nozzle damage"), filament_type, format_steel_name(obj_->nozzle_type)); + wxString nozzle_in_preset = wxString::Format(_L("Printing high temperature material (%s material) with %s may cause nozzle damage"), filament_type, format_steel_name(obj_->m_extder_data.extders[0].current_nozzle_type)); confirm_text.push_back(ConfirmBeforeSendInfo(nozzle_in_preset, ConfirmBeforeSendInfo::InfoLevel::Warning)); } } @@ -2650,18 +1913,19 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) } } -wxString SelectMachineDialog::format_steel_name(std::string name) +wxString SelectMachineDialog::format_steel_name(NozzleType type) { - if (name == "hardened_steel") { + if (type == NozzleType::ntHardenedSteel) { return _L("Hardened Steel"); } - else if (name == "stainless_steel") { + else if (type == NozzleType::ntStainlessSteel) { return _L("Stainless Steel"); } - return wxEmptyString; + return _L("Unknown"); } + void SelectMachineDialog::Enable_Auto_Refill(bool enable) { if (enable) { @@ -2745,9 +2009,10 @@ void SelectMachineDialog::on_send_print() // get ams_mapping_result std::string ams_mapping_array; + std::string ams_mapping_array2; std::string ams_mapping_info; if (m_checkbox_list["use_ams"]->GetValue()) - get_ams_mapping_result(ams_mapping_array, ams_mapping_info); + get_ams_mapping_result(ams_mapping_array,ams_mapping_array2, ams_mapping_info); else { json mapping_info_json = json::array(); json item; @@ -2840,13 +2105,20 @@ void SelectMachineDialog::on_send_print() if (obj_->is_support_ams_mapping()) { m_print_job->task_ams_mapping = ams_mapping_array; + m_print_job->task_ams_mapping2= ams_mapping_array2; m_print_job->task_ams_mapping_info = ams_mapping_info; } else { m_print_job->task_ams_mapping = ""; + m_print_job->task_ams_mapping2 = ""; m_print_job->task_ams_mapping_info = ""; } - m_print_job->has_sdcard = obj_->has_sdcard(); + /* build nozzles info for multi extruders printers */ + if (build_nozzles_info(m_print_job->task_nozzles_info)) { + BOOST_LOG_TRIVIAL(error) << "build_nozzle_info errors"; + } + + m_print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL; bool timelapse_option = select_timelapse->IsShown() ? m_checkbox_list["timelapse"]->GetValue() : true; @@ -2857,7 +2129,10 @@ void SelectMachineDialog::on_send_print() m_checkbox_list["flow_cali"]->GetValue(), false, timelapse_option, - true); + true, + 0, // TODO: Orca hack + 0, + 0); if (obj_->has_ams()) { m_print_job->task_use_ams = m_checkbox_list["use_ams"]->GetValue(); @@ -2936,7 +2211,7 @@ void SelectMachineDialog::on_set_finish_mapping(wxCommandEvent &evt) BOOST_LOG_TRIVIAL(info) << "The ams mapping selection result: data is " << selection_data; - if (selection_data_arr.size() == 6) { + if (selection_data_arr.size() == 8) { auto ams_colour = wxColour(wxAtoi(selection_data_arr[0]), wxAtoi(selection_data_arr[1]), wxAtoi(selection_data_arr[2]), wxAtoi(selection_data_arr[3])); int old_filament_id = (int) wxAtoi(selection_data_arr[5]); if (m_print_type == PrintFromType::FROM_NORMAL) {//todo:support sd card @@ -2968,6 +2243,9 @@ void SelectMachineDialog::on_set_finish_mapping(wxCommandEvent &evt) m_ams_mapping_result[i].color = color.ToStdString(); m_ams_mapping_result[i].ctype = ctype; m_ams_mapping_result[i].colors = tray_cols; + + m_ams_mapping_result[i].ams_id = selection_data_arr[6].ToStdString(); + m_ams_mapping_result[i].slot_id = selection_data_arr[7].ToStdString(); } BOOST_LOG_TRIVIAL(trace) << "The ams mapping result: id is " << m_ams_mapping_result[i].id << "tray_id is " << m_ams_mapping_result[i].tray_id; } @@ -2975,7 +2253,7 @@ void SelectMachineDialog::on_set_finish_mapping(wxCommandEvent &evt) MaterialHash::iterator iter = m_materialList.begin(); while (iter != m_materialList.end()) { Material* item = iter->second; - MaterialItem *m = item->item; + MaterialItem *m = item->item; if (item->id == m_current_filament_id) { auto ams_colour = wxColour(wxAtoi(selection_data_arr[0]), wxAtoi(selection_data_arr[1]), wxAtoi(selection_data_arr[2]), wxAtoi(selection_data_arr[3])); m->set_ams_info(ams_colour, selection_data_arr[4], ctype, material_cols); @@ -3155,7 +2433,7 @@ void SelectMachineDialog::update_user_printer() BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "for send task, current printer id = " << m_printer_last_select << std::endl; } -void SelectMachineDialog::on_rename_click(wxCommandEvent& event) +void SelectMachineDialog::on_rename_click(wxMouseEvent& event) { m_is_rename_mode = true; m_rename_input->GetTextCtrl()->SetValue(m_current_project_name); @@ -3365,7 +2643,7 @@ void SelectMachineDialog::update_flow_cali_check(MachineObject* obj) void SelectMachineDialog::update_ams_check(MachineObject* obj) { - if (obj && obj->ams_support_use_ams && obj->has_ams()) { + if (obj && obj->has_ams()) { select_use_ams->Show(); if (obj->get_printer_ams_type() == "generic") { img_use_ams_tip->Show(); @@ -3447,7 +2725,6 @@ void SelectMachineDialog::update_show_status() } reset_timeout(); - //update_ams_check(obj_); if (!obj_->is_support_print_all && m_print_plate_idx == PLATE_ALL_IDX) { show_status(PrintDialogStatus::PrintStatusNotSupportedPrintAll); @@ -3457,13 +2734,11 @@ void SelectMachineDialog::update_show_status() // do ams mapping if no ams result bool clean_ams_mapping = false; - if (obj_->has_ams() && m_ams_mapping_result.empty()) { - if (obj_->ams_support_use_ams) { - if (m_checkbox_list["use_ams"]->GetValue()) { - do_ams_mapping(obj_); - } else { - clean_ams_mapping = true; - } + if (m_ams_mapping_result.empty()) { + if (m_checkbox_list["use_ams"]->GetValue()) { + do_ams_mapping(obj_); + } else { + clean_ams_mapping = true; } } @@ -3531,20 +2806,17 @@ void SelectMachineDialog::update_show_status() return; } - if (obj_->ams_support_use_ams) { - if (!m_checkbox_list["use_ams"]->GetValue()) { - m_ams_mapping_result.clear(); - sync_ams_mapping_result(m_ams_mapping_result); - - if (has_timelapse_warning()) { - show_status(PrintDialogStatus::PrintStatusTimelapseWarning); - } - else { - show_status(PrintDialogStatus::PrintStatusDisableAms); - } + if (!m_checkbox_list["use_ams"]->GetValue()) { + m_ams_mapping_result.clear(); + sync_ams_mapping_result(m_ams_mapping_result); - return; + if (has_timelapse_warning()) { + show_status(PrintDialogStatus::PrintStatusTimelapseWarning); + } else { + show_status(PrintDialogStatus::PrintStatusDisableAms); } + + return; } @@ -3624,7 +2896,7 @@ bool SelectMachineDialog::has_timelapse_warning() return true; } } - + return false; } @@ -3742,11 +3014,10 @@ void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect) timeimg->SetBitmap(print_time->bmp()); print_weight->msw_rescale(); weightimg->SetBitmap(print_weight->bmp()); - m_rename_button->msw_rescale(); - ams_editable->msw_rescale(); - ams_editable_light->msw_rescale(); - enable_ams_mapping->msw_rescale(); - img_amsmapping_tip->SetBitmap(enable_ams_mapping->bmp()); + rename_editable->msw_rescale(); + rename_editable_light->msw_rescale(); + ams_mapping_help_icon->msw_rescale(); + img_amsmapping_tip->SetBitmap(ams_mapping_help_icon->bmp()); enable_ams->msw_rescale(); img_use_ams_tip->SetBitmap(enable_ams->bmp()); @@ -3928,8 +3199,7 @@ void SelectMachineDialog::set_default() set_default_normal(m_plater->get_partplate_list().get_curr_plate()->thumbnail_data); } else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) { - //todo:unify_deal_thumbnail_data(input_data, no_light_data);this include m_print_type = PrintFromType::FROM_SDCARD_VIEW - //and notice update_page_turn_state(true) + update_page_turn_state(true); set_default_from_sdcard(); } @@ -3980,8 +3250,8 @@ void SelectMachineDialog::reset_and_sync_ams_list() delete item; iter++; } - - m_sizer_material->Clear(); + + m_sizer_ams_mapping->Clear(); m_materialList.clear(); m_filaments.clear(); @@ -3994,8 +3264,8 @@ void SelectMachineDialog::reset_and_sync_ams_list() auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2], (int) rgb[3]); if (extruder >= materials.size() || extruder < 0 || extruder >= display_materials.size()) continue; - MaterialItem *item = new MaterialItem(m_scrollable_region, colour_rgb, _L(display_materials[extruder])); - m_sizer_material->Add(item, 0, wxALL, FromDIP(4)); + MaterialItem *item = new MaterialItem(m_filament_panel, colour_rgb, _L(display_materials[extruder])); + m_sizer_ams_mapping->Add(item, 0, wxALL, FromDIP(5)); item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {}); item->Bind(wxEVT_LEFT_DOWN, [this, item, materials, extruder](wxMouseEvent &e) { @@ -4052,12 +3322,16 @@ void SelectMachineDialog::reset_and_sync_ams_list() } } - if (extruders.size() <= 4) { - m_sizer_material->SetCols(extruders.size()); - } else { - m_sizer_material->SetCols(4); + /*if (extruders.size() <= 10) { + m_sizer_ams_mapping->SetCols(extruders.size()); } + else { + m_sizer_ams_mapping->SetCols(10); + }*/ + m_sizer_ams_mapping->SetCols(8); + m_sizer_ams_mapping->Layout(); + m_filament_panel_sizer->Layout(); // reset_ams_material();//show "-" } @@ -4323,47 +3597,33 @@ void SelectMachineDialog::set_default_normal(const ThumbnailData &data) for (unsigned int r = 0; r < data.height; ++r) { unsigned int rr = (data.height - 1 - r) * data.width; for (unsigned int c = 0; c < data.width; ++c) { - unsigned char* px = (unsigned char*)data.pixels.data() + 4 * (rr + c); - image.SetRGB((int)c, (int)r, px[0], px[1], px[2]); - image.SetAlpha((int)c, (int)r, px[3]); + unsigned char *px = (unsigned char *) data.pixels.data() + 4 * (rr + c); + image.SetRGB((int) c, (int) r, px[0], px[1], px[2]); + image.SetAlpha((int) c, (int) r, px[3]); } } - image = image.Rescale(FromDIP(256), FromDIP(256)); + image = image.Rescale(FromDIP(198), FromDIP(198)); m_thumbnailPanel->set_thumbnail(image); } - m_scrollable_region->Layout(); - m_scrollable_region->Fit(); + m_basic_panel->Layout(); + m_basic_panel->Fit(); - m_scrollable_view->SetSize(m_scrollable_region->GetSize()); - m_scrollable_view->SetMinSize(m_scrollable_region->GetSize()); - m_scrollable_view->SetMaxSize(m_scrollable_region->GetSize()); - - //disable pei bed - DeviceManager* dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager(); + // disable pei bed + DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager(); if (!dev_manager) return; - MachineObject* obj_ = dev_manager->get_selected_machine(); + MachineObject *obj_ = dev_manager->get_selected_machine(); update_flow_cali_check(obj_); - - wxSize screenSize = wxGetDisplaySize(); - auto dialogSize = this->GetSize(); + wxSize screenSize = wxGetDisplaySize(); + auto dialogSize = this->GetSize(); #ifdef __WINDOWS__ - if (screenSize.GetHeight() < dialogSize.GetHeight()) { - m_need_adaptation_screen = true; - m_scrollable_view->SetScrollRate(0, 5); - m_scrollable_view->SetSize(wxSize(-1, FromDIP(220))); - m_scrollable_view->SetMinSize(wxSize(-1, FromDIP(220))); - m_scrollable_view->SetMaxSize(wxSize(-1, FromDIP(220))); - } - else { - m_scrollable_view->SetScrollRate(0, 0); - } + #endif // __WXOSX_MAC__ // basic info auto aprint_stats = m_plater->get_partplate_list().get_current_fff_print().print_statistics(); wxString time; - PartPlate* plate = m_plater->get_partplate_list().get_curr_plate(); + PartPlate *plate = m_plater->get_partplate_list().get_curr_plate(); if (plate) { if (plate->get_slice_result()) { time = wxString::Format("%s", short_time(get_time_dhms(plate->get_slice_result()->print_statistics.modes[0].time))); } } @@ -4371,8 +3631,7 @@ void SelectMachineDialog::set_default_normal(const ThumbnailData &data) char weight[64]; if (wxGetApp().app_config->get("use_inches") == "1") { ::sprintf(weight, " %.2f oz", aprint_stats.total_weight * 0.035274); - } - else { + } else { ::sprintf(weight, " %.2f g", aprint_stats.total_weight); } @@ -4390,10 +3649,10 @@ void SelectMachineDialog::set_default_from_sdcard() if (data.pixels.size() > 0) { wxMemoryInputStream mis((unsigned char*)data.pixels.data(), data.pixels.size()); wxImage image = wxImage(mis); - image = image.Rescale(FromDIP(256), FromDIP(256)); + image = image.Rescale(FromDIP(198), FromDIP(198)); m_thumbnailPanel->set_thumbnail(image); } - + //for black list std::vector materials; std::vector brands; @@ -4417,16 +3676,15 @@ void SelectMachineDialog::set_default_from_sdcard() } m_ams_mapping_result.clear(); - m_sizer_material->Clear(); + m_sizer_ams_mapping->Clear(); m_materialList.clear(); m_filaments.clear(); - for (auto i = 0; i < m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info.size(); i++) { FilamentInfo fo = m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info[i]; - MaterialItem* item = new MaterialItem(m_scrollable_region, wxColour(fo.color), fo.type); - m_sizer_material->Add(item, 0, wxALL, FromDIP(4)); + MaterialItem* item = new MaterialItem(m_filament_panel, wxColour(fo.color), fo.type); + m_sizer_ams_mapping->Add(item, 0, wxALL, FromDIP(5)); item->Bind(wxEVT_LEFT_UP, [this, item, materials](wxMouseEvent& e) {}); item->Bind(wxEVT_LEFT_DOWN, [this, item, materials, fo](wxMouseEvent& e) { @@ -4483,38 +3741,21 @@ void SelectMachineDialog::set_default_from_sdcard() } if (m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info.size() <= 4) { - m_sizer_material->SetCols(m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info.size()); + m_sizer_ams_mapping->SetCols(m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info.size()); } else { - m_sizer_material->SetCols(4); + m_sizer_ams_mapping->SetCols(4); } - m_scrollable_region->Layout(); - m_scrollable_region->Fit(); + m_basic_panel->Layout(); + m_basic_panel->Fit(); - m_scrollable_view->SetSize(m_scrollable_region->GetSize()); - m_scrollable_view->SetMinSize(m_scrollable_region->GetSize()); - m_scrollable_view->SetMaxSize(m_scrollable_region->GetSize()); set_flow_calibration_state(true); wxSize screenSize = wxGetDisplaySize(); auto dialogSize = this->GetSize(); -#ifdef __WINDOWS__ - if (screenSize.GetHeight() < dialogSize.GetHeight()) { - m_need_adaptation_screen = true; - m_scrollable_view->SetScrollRate(0, 5); - m_scrollable_view->SetSize(wxSize(-1, FromDIP(220))); - m_scrollable_view->SetMinSize(wxSize(-1, FromDIP(220))); - m_scrollable_view->SetMaxSize(wxSize(-1, FromDIP(220))); - } - else { - m_scrollable_view->SetScrollRate(0, 0); - } -#endif // __WXOSX_MAC__ - - reset_ams_material(); // basic info @@ -4533,64 +3774,85 @@ void SelectMachineDialog::set_default_from_sdcard() void SelectMachineDialog::update_page_turn_state(bool show) { - m_bitmap_last_plate->Show(show); - m_bitmap_next_plate->Show(show); + m_bitmap_last_plate->Show(show); + m_bitmap_next_plate->Show(show); - if (show) { - if (m_print_plate_idx <= 0) { m_bitmap_last_plate->Hide(); } - else { m_bitmap_last_plate->Show(); } + if (show) { + if (m_print_plate_idx <= 0) { m_bitmap_last_plate->Disable(); } + else { m_bitmap_last_plate->Enable(); } - if ((m_print_plate_idx + 1) >= m_print_plate_total) { m_bitmap_next_plate->Hide(); } - else { m_bitmap_next_plate->Show(); } + if ((m_print_plate_idx + 1) >= m_print_plate_total) { m_bitmap_next_plate->Disable(); } + else { m_bitmap_next_plate->Enable(); } - if (m_print_plate_total == 1) { - m_bitmap_last_plate->Show(false); - m_bitmap_next_plate->Show(false); - } - } + if (m_print_plate_total == 1) { + m_bitmap_last_plate->Show(false); + m_bitmap_next_plate->Show(false); + } + } } void SelectMachineDialog::sys_color_changed() { if (wxGetApp(). dark_mode()) { //rename_button->SetIcon("ams_editable_light"); - m_rename_button->SetBitmap(ams_editable_light->bmp()); + m_rename_button->SetBitmap(rename_editable_light->bmp()); } else { - m_rename_button->SetBitmap(ams_editable->bmp()); + m_rename_button->SetBitmap(rename_editable->bmp()); } m_rename_button->Refresh(); } bool SelectMachineDialog::Show(bool show) { - // set default value when show this dialog if (show) { m_refresh_timer->Start(LIST_REFRESH_INTERVAL); - show_status(PrintDialogStatus::PrintStatusInit); - wxGetApp().UpdateDlgDarkUI(this); - wxGetApp().reset_to_active(); - set_default(); - update_user_machine_list(); - - Layout(); - Fit(); - CenterOnParent(); - } - else { + } else { m_refresh_timer->Stop(); - DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + + DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (dev) { - MachineObject* obj_ = dev->get_selected_machine(); + MachineObject *obj_ = dev->get_selected_machine(); if (obj_ && obj_->connection_type() == "cloud" /*&& m_print_type == FROM_SDCARD_VIEW*/) { - if (obj_->is_connected()) { - obj_->disconnect(); - } - + if (obj_->is_connected()) { obj_->disconnect(); } } } + + return DPIDialog::Show(false); + } + + show_status(PrintDialogStatus::PrintStatusInit); + + PresetBundle& preset_bundle = *wxGetApp().preset_bundle; + const auto& project_config = preset_bundle.project_config; + + const t_config_enum_values &enum_keys_map = ConfigOptionEnum::get_enum_values(); + const ConfigOptionEnum* bed_type=project_config.option>("curr_bed_type"); + std::string plate_name; + for (auto& elem : enum_keys_map) { + if (elem.second == bed_type->value) + plate_name = elem.first; + } + + if (plate_name.empty()) { + m_text_bed_type->Hide(); } + else { + plate_name = "Plate: " + plate_name; + m_text_bed_type->SetLabelText(plate_name); + m_text_bed_type->Show(); + } + + // set default value when show this dialog + wxGetApp().UpdateDlgDarkUI(this); + wxGetApp().reset_to_active(); + set_default(); + update_user_machine_list(); + + Layout(); + Fit(); + CenterOnParent(); return DPIDialog::Show(show); } @@ -4614,170 +3876,50 @@ void SelectMachineDialog::update_lan_machine_list() if (!mobj->is_avaliable()) continue; if (!mobj->is_online()) continue; if (!mobj->is_lan_mode_printer()) continue; - /*if (mobj->is_in_printing()) {op->set_printer_state(PrinterState::BUSY);}*/ - if (mobj->has_access_right()) { - auto b = mobj->dev_name; - - // clear machine list - - //m_comboBox_printer->Clear(); - std::vector machine_list; - wxArrayString machine_list_name; - std::map option_list; - - // same machine only appear once - - /* machine_list = sort_string(machine_list); - for (auto tt = machine_list.begin(); tt != machine_list.end(); tt++) { - for (auto it = option_list.begin(); it != option_list.end(); it++) { - if (it->second->dev_name == *tt) { - m_list.push_back(it->second); - wxString dev_name_text = from_u8(it->second->dev_name); - if (it->second->is_lan_mode_printer()) { - dev_name_text += "(LAN)"; - } - machine_list_name.Add(dev_name_text); - break; - } - } - } - - m_comboBox_printer->Set(machine_list_name); - - MachineObject* obj = dev->get_selected_machine(); - if (obj) { - m_printer_last_select = obj->dev_id; - } - else { - m_printer_last_select = ""; - }*/ - //op->set_printer_state(PrinterState::LOCK); - } + std::vector machine_list; + wxArrayString machine_list_name; + std::map option_list; + } } - - - BOOST_LOG_TRIVIAL(trace) << "SelectMachineDialog update_lan_devices end"; } -EditDevNameDialog::EditDevNameDialog(Plater *plater /*= nullptr*/) - : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Modifying the device name"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) -{ - std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str(); - SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); - - SetBackgroundColour(*wxWHITE); - wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL); - auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); - m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); - m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0); - m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(38)); - m_textCtr = new ::TextInput(this, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(260), FromDIP(40)), wxTE_PROCESS_ENTER); - m_textCtr->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(22))); - m_textCtr->SetMinSize(wxSize(FromDIP(260), FromDIP(40))); - m_sizer_main->Add(m_textCtr, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(40)); - - m_static_valid = new wxStaticText(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0); - m_static_valid->Wrap(-1); - m_static_valid->SetFont(::Label::Body_13); - m_static_valid->SetForegroundColour(wxColour(255, 111, 0)); - m_sizer_main->Add(m_static_valid, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxLEFT | wxRIGHT, FromDIP(10)); - - - m_button_confirm = new Button(this, _L("Confirm")); - StateColor btn_bg_green(std::pair(wxColour(0, 137, 123), StateColor::Pressed), std::pair(wxColour(0, 150, 136), StateColor::Normal)); - m_button_confirm->SetBackgroundColor(btn_bg_green); - m_button_confirm->SetBorderColor(wxColour(0, 150, 136)); - m_button_confirm->SetTextColor(wxColour(255, 255, 255)); - m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24))); - m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24))); - m_button_confirm->SetCornerRadius(FromDIP(12)); - m_button_confirm->Bind(wxEVT_BUTTON, &EditDevNameDialog::on_edit_name, this); - - m_sizer_main->Add(m_button_confirm, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(10)); - m_sizer_main->Add(0, 0, 0, wxBOTTOM, FromDIP(38)); - - SetSizer(m_sizer_main); - Layout(); - Fit(); - Centre(wxBOTH); - wxGetApp().UpdateDlgDarkUI(this); -} - -EditDevNameDialog::~EditDevNameDialog() {} - -void EditDevNameDialog::set_machine_obj(MachineObject *obj) -{ - m_info = obj; - if (m_info) - m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name)); -} - -void EditDevNameDialog::on_dpi_changed(const wxRect &suggested_rect) -{ - m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24))); - m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24))); -} - -void EditDevNameDialog::on_edit_name(wxCommandEvent &e) -{ - m_static_valid->SetLabel(wxEmptyString); - auto m_valid_type = Valid; - wxString info_line; - auto new_dev_name = m_textCtr->GetTextCtrl()->GetValue(); - - const char * unusable_symbols = "<>[]:/\\|?*\""; - const std::string unusable_suffix = PresetCollection::get_suffix_modified(); - - for (size_t i = 0; i < std::strlen(unusable_symbols); i++) { - if (new_dev_name.find_first_of(unusable_symbols[i]) != std::string::npos) { - info_line = _L("Name is invalid;") + _L("illegal characters:") + " " + unusable_symbols; - m_valid_type = NoValid; - break; - } - } - - if (m_valid_type == Valid && new_dev_name.find(unusable_suffix) != std::string::npos) { - info_line = _L("Name is invalid;") + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified()); - m_valid_type = NoValid; - } - - if (m_valid_type == Valid && new_dev_name.empty()) { - info_line = _L("The name is not allowed to be empty."); - m_valid_type = NoValid; - } - - if (m_valid_type == Valid && new_dev_name.find_first_of(' ') == 0) { - info_line = _L("The name is not allowed to start with space character."); - m_valid_type = NoValid; - } - - if (m_valid_type == Valid && new_dev_name.find_last_of(' ') == new_dev_name.length() - 1) { - info_line = _L("The name is not allowed to end with space character."); - m_valid_type = NoValid; - } - - if (m_valid_type == NoValid) { - m_static_valid->SetLabel(info_line); - Layout(); - } - - if (m_valid_type == Valid) { - m_static_valid->SetLabel(wxEmptyString); - DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (dev) { - auto utf8_str = new_dev_name.ToUTF8(); - auto name = std::string(utf8_str.data(), utf8_str.length()); - if (m_info) - dev->modify_device_name(m_info->dev_id, name); - } - DPIDialog::EndModal(wxID_CLOSE); +std::string SelectMachineDialog::get_print_status_info(PrintDialogStatus status) +{ + switch (status) { + case PrintStatusInit: return "PrintStatusInit"; + case PrintStatusNoUserLogin: return "PrintStatusNoUserLogin"; + case PrintStatusInvalidPrinter: return "PrintStatusInvalidPrinter"; + case PrintStatusConnectingServer: return "PrintStatusConnectingServer"; + case PrintStatusReading: return "PrintStatusReading"; + case PrintStatusReadingFinished: return "PrintStatusReadingFinished"; + case PrintStatusReadingTimeout: return "PrintStatusReadingTimeout"; + case PrintStatusInUpgrading: return "PrintStatusInUpgrading"; + case PrintStatusNeedUpgradingAms: return "PrintStatusNeedUpgradingAms"; + case PrintStatusInSystemPrinting: return "PrintStatusInSystemPrinting"; + case PrintStatusInPrinting: return "PrintStatusInPrinting"; + case PrintStatusDisableAms: return "PrintStatusDisableAms"; + case PrintStatusAmsMappingSuccess: return "PrintStatusAmsMappingSuccess"; + case PrintStatusAmsMappingInvalid: return "PrintStatusAmsMappingInvalid"; + case PrintStatusAmsMappingU0Invalid: return "PrintStatusAmsMappingU0Invalid"; + case PrintStatusAmsMappingValid: return "PrintStatusAmsMappingValid"; + case PrintStatusAmsMappingByOrder: return "PrintStatusAmsMappingByOrder"; + case PrintStatusRefreshingMachineList: return "PrintStatusRefreshingMachineList"; + case PrintStatusSending: return "PrintStatusSending"; + case PrintStatusSendingCanceled: return "PrintStatusSendingCanceled"; + case PrintStatusLanModeNoSdcard: return "PrintStatusLanModeNoSdcard"; + case PrintStatusNoSdcard: return "PrintStatusNoSdcard"; + case PrintStatusUnsupportedPrinter: return "PrintStatusUnsupportedPrinter"; + case PrintStatusTimelapseNoSdcard: return "PrintStatusTimelapseNoSdcard"; + case PrintStatusNotSupportedPrintAll: return "PrintStatusNotSupportedPrintAll"; } + return "unknown"; } + ThumbnailPanel::ThumbnailPanel(wxWindow *parent, wxWindowID winid, const wxPoint &pos, const wxSize &size) : wxPanel(parent, winid, pos, size) { @@ -4817,7 +3959,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) } void ThumbnailPanel::render(wxDC& dc) { - + if (wxGetApp().dark_mode() && m_brightness_value < SHOW_BACKGROUND_BITMAP_PIXEL_THRESHOLD) { #ifdef __WXMSW__ wxMemoryDC memdc; @@ -4831,95 +3973,11 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) } else dc.DrawBitmap(m_bitmap, 0, 0); - - } - - ThumbnailPanel::~ThumbnailPanel() {} - - PinCodePanel::PinCodePanel(wxWindow* parent, int type, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/) - { - wxPanel::Create(parent, winid, pos, SELECT_MACHINE_ITEM_SIZE); - Bind(wxEVT_PAINT, &PinCodePanel::OnPaint, this); - SetSize(SELECT_MACHINE_ITEM_SIZE); - SetMaxSize(SELECT_MACHINE_ITEM_SIZE); - SetMinSize(SELECT_MACHINE_ITEM_SIZE); - - m_type = type; - m_bitmap = ScalableBitmap(this, "bind_device_ping_code",10); - - this->Bind(wxEVT_ENTER_WINDOW, &PinCodePanel::on_mouse_enter, this); - this->Bind(wxEVT_LEAVE_WINDOW, &PinCodePanel::on_mouse_leave, this); - this->Bind(wxEVT_LEFT_UP, &PinCodePanel::on_mouse_left_up, this); - } - - void PinCodePanel::OnPaint(wxPaintEvent& event) - { - wxPaintDC dc(this); - render(dc); - } - - void PinCodePanel::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 PinCodePanel::doRender(wxDC& dc) - { - auto size = GetSize(); - dc.DrawBitmap(m_bitmap.bmp(), wxPoint(FromDIP(12), (size.y - m_bitmap.GetBmpSize().y) / 2)); - dc.SetFont(::Label::Head_13); - dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#262E30"))); // ORCA fix text not visible on dark theme - wxString txt; - if (m_type == 0) { txt = _L("Bind with Pin Code"); } - else if (m_type == 1) { txt = _L("Bind with Access Code"); } - - auto txt_size = dc.GetTextExtent(txt); - dc.DrawText(txt, wxPoint(FromDIP(28), (size.y - txt_size.y) / 2)); - - if (m_hover) { - dc.SetPen(SELECT_MACHINE_BRAND); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(0, 0, size.x, size.y); - } } - void PinCodePanel::on_mouse_enter(wxMouseEvent& evt) - { - m_hover = true; - Refresh(); - } + ThumbnailPanel::~ThumbnailPanel() {} - void PinCodePanel::on_mouse_leave(wxMouseEvent& evt) - { - m_hover = false; - Refresh(); - } - void PinCodePanel::on_mouse_left_up(wxMouseEvent& evt) - { - if (m_type == 0) { - wxGetApp().popup_ping_bind_dialog(); - } - else if (m_type == 1) { - InputIpAddressDialog dlgo; - dlgo.ShowModal(); - } - } }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 6752e2a8691..0c22c4c4885 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -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 &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 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 m_user_list_machine_panel; - std::vector m_other_list_machine_panel; - boost::thread* get_print_info_thread{ nullptr }; - std::shared_ptr m_token = std::make_shared(0); - std::string m_print_info = ""; - bool m_dismiss { false }; - - std::map m_bind_machine_list; - std::map 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 @@ class SelectMachineDialog : public DPIDialog 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 @@ class SelectMachineDialog : public DPIDialog 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 m_token = std::make_shared(0); std::map m_checkbox_list; @@ -385,18 +215,17 @@ class SelectMachineDialog : public DPIDialog 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 @@ class SelectMachineDialog : public DPIDialog 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 @@ class SelectMachineDialog : public DPIDialog 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 @@ class SelectMachineDialog : public DPIDialog std::vector m_cur_colors_in_thumbnail; std::vector 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 @@ class SelectMachineDialog : public DPIDialog 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 @@ class SelectMachineDialog : public DPIDialog 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 @@ class SelectMachineDialog : public DPIDialog std::vector sort_string(std::vector 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 diff --git a/src/slic3r/GUI/SelectMachinePop.cpp b/src/slic3r/GUI/SelectMachinePop.cpp new file mode 100644 index 00000000000..320df171849 --- /dev/null +++ b/src/slic3r/GUI/SelectMachinePop.cpp @@ -0,0 +1,1054 @@ +#include "SelectMachinePop.hpp" +#include "I18N.hpp" + +#include "libslic3r/Utils.hpp" +#include "libslic3r/Thread.hpp" + +#include "slic3r/Utils/WxFontUtils.hpp" + +#include "GUI.hpp" +#include "GUI_App.hpp" +#include "GUI_Preview.hpp" +#include "MainFrame.hpp" +#include "format.hpp" +#include "Widgets/ProgressDialog.hpp" +#include "Widgets/RoundedRectangle.hpp" +#include "Widgets/StaticBox.hpp" +#include "ConnectPrinter.hpp" + + +#include +#include +#include +#include +#include +#include +#include "Plater.hpp" +#include "Notebook.hpp" +#include "BitmapCache.hpp" +#include "BindDialog.hpp" + +namespace Slic3r { namespace GUI { + +wxDEFINE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent); +wxDEFINE_EVENT(EVT_FINISHED_UPDATE_MACHINE_LIST, wxCommandEvent); +wxDEFINE_EVENT(EVT_UPDATE_USER_MACHINE_LIST, wxCommandEvent); +wxDEFINE_EVENT(EVT_BIND_MACHINE, wxCommandEvent); +wxDEFINE_EVENT(EVT_UNBIND_MACHINE, wxCommandEvent); +wxDEFINE_EVENT(EVT_DISSMISS_MACHINE_LIST, wxCommandEvent); +wxDEFINE_EVENT(EVT_CONNECT_LAN_PRINT, wxCommandEvent); +wxDEFINE_EVENT(EVT_EDIT_PRINT_NAME, wxCommandEvent); +wxDEFINE_EVENT(EVT_CLEAR_IPADDRESS, wxCommandEvent); + + +#define INITIAL_NUMBER_OF_MACHINES 0 +#define LIST_REFRESH_INTERVAL 200 +#define MACHINE_LIST_REFRESH_INTERVAL 2000 + +#define WRAP_GAP FromDIP(2) + +MachineObjectPanel::MachineObjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name) +{ + wxPanel::Create(parent, id, pos, wxDefaultSize, style, name); + + SetSize(SELECT_MACHINE_ITEM_SIZE); + SetMinSize(SELECT_MACHINE_ITEM_SIZE); + SetMaxSize(SELECT_MACHINE_ITEM_SIZE); + + Bind(wxEVT_PAINT, &MachineObjectPanel::OnPaint, this); + + SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); + + m_unbind_img = ScalableBitmap(this, "unbind", 18); + m_edit_name_img = ScalableBitmap(this, "edit_button", 18); + m_select_unbind_img = ScalableBitmap(this, "unbind_selected", 18); + + m_printer_status_offline = ScalableBitmap(this, "printer_status_offline", 12); + m_printer_status_busy = ScalableBitmap(this, "printer_status_busy", 12); + m_printer_status_idle = ScalableBitmap(this, "printer_status_idle", 12); + m_printer_status_lock = ScalableBitmap(this, "printer_status_lock", 16); + m_printer_in_lan = ScalableBitmap(this, "printer_in_lan", 16); + + this->Bind(wxEVT_ENTER_WINDOW, &MachineObjectPanel::on_mouse_enter, this); + this->Bind(wxEVT_LEAVE_WINDOW, &MachineObjectPanel::on_mouse_leave, this); + this->Bind(wxEVT_LEFT_UP, &MachineObjectPanel::on_mouse_left_up, this); + +#ifdef __APPLE__ + wxPlatformInfo platformInfo; + auto major = platformInfo.GetOSMajorVersion(); + auto minor = platformInfo.GetOSMinorVersion(); + auto micro = platformInfo.GetOSMicroVersion(); + + //macos 13.1.0 + if (major >= 13 && minor >= 1 && micro >= 0) { + m_is_macos_special_version = true; + } +#endif + +} + + +MachineObjectPanel::~MachineObjectPanel() {} + +void MachineObjectPanel::show_bind_dialog() +{ + if (wxGetApp().is_user_login()) { + BindMachineDialog dlg; + dlg.update_machine_info(m_info); + dlg.ShowModal(); + } +} + +void MachineObjectPanel::set_printer_state(PrinterState state) +{ + m_state = state; + Refresh(); +} + +void MachineObjectPanel::show_edit_printer_name(bool show) +{ + m_show_edit = show; + Refresh(); +} + +void MachineObjectPanel::show_printer_bind(bool show, PrinterBindState state) +{ + m_show_bind = show; + m_bind_state = state; + Refresh(); +} + +void MachineObjectPanel::OnPaint(wxPaintEvent &event) +{ + wxPaintDC dc(this); + doRender(dc); +} + +void MachineObjectPanel::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 MachineObjectPanel::doRender(wxDC &dc) +{ + auto left = 10; + wxSize size = GetSize(); + dc.SetPen(*wxTRANSPARENT_PEN); + + auto dwbitmap = m_printer_status_offline; + if (m_state == PrinterState::IDLE) { dwbitmap = m_printer_status_idle; } + if (m_state == PrinterState::BUSY) { dwbitmap = m_printer_status_busy; } + if (m_state == PrinterState::OFFLINE) { dwbitmap = m_printer_status_offline; } + if (m_state == PrinterState::LOCK) { dwbitmap = m_printer_status_lock; } + if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; } + + // dc.DrawCircle(left, size.y / 2, 3); + dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2)); + + left += dwbitmap.GetBmpSize().x + 8; + dc.SetFont(Label::Body_13); + dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900)); + wxString dev_name = ""; + if (m_info) { + dev_name = from_u8(m_info->dev_name); + + if (m_state == PrinterState::IN_LAN) { + dev_name += _L("(LAN)"); + } + } + auto sizet = dc.GetTextExtent(dev_name); + auto text_end = 0; + + if (m_show_edit) { + text_end = size.x - m_unbind_img.GetBmpSize().x - 30; + } + else { + text_end = size.x - m_unbind_img.GetBmpSize().x; + } + + wxString finally_name = dev_name; + if (sizet.x > (text_end - left)) { + auto limit_width = text_end - left - dc.GetTextExtent("...").x - 15; + for (auto i = 0; i < dev_name.length(); i++) { + auto curr_width = dc.GetTextExtent(dev_name.substr(0, i)); + if (curr_width.x >= limit_width) { + finally_name = dev_name.substr(0, i) + "..."; + break; + } + } + } + + dc.DrawText(finally_name, wxPoint(left, (size.y - sizet.y) / 2)); + + + if (m_hover || m_is_macos_special_version) { + + if (m_hover && !m_is_macos_special_version) { + dc.SetPen(SELECT_MACHINE_BRAND); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(0, 0, size.x, size.y); + } + + if (m_show_bind) { + if (m_bind_state == ALLOW_UNBIND) { + left = size.x - m_unbind_img.GetBmpSize().x - 6; + dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2); + } + } + + if (m_show_edit) { + left = size.x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6; + dc.DrawBitmap(m_edit_name_img.bmp(), left, (size.y - m_edit_name_img.GetBmpSize().y) / 2); + } + } + +} + +void MachineObjectPanel::update_machine_info(MachineObject *info, bool is_my_devices) +{ + m_info = info; + m_is_my_devices = is_my_devices; + Refresh(); +} + +void MachineObjectPanel::on_mouse_enter(wxMouseEvent &evt) +{ + m_hover = true; + Refresh(); +} + +void MachineObjectPanel::on_mouse_leave(wxMouseEvent &evt) +{ + m_hover = false; + Refresh(); +} + +void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt) +{ + if (m_is_my_devices) { + // show edit + if (m_show_edit) { + auto edit_left = GetSize().x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6; + auto edit_right = edit_left + m_edit_name_img.GetBmpSize().x; + auto edit_top = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2; + auto edit_bottom = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2 + m_edit_name_img.GetBmpSize().y; + if ((evt.GetPosition().x >= edit_left && evt.GetPosition().x <= edit_right) && evt.GetPosition().y >= edit_top && evt.GetPosition().y <= edit_bottom) { + wxCommandEvent event(EVT_EDIT_PRINT_NAME); + event.SetEventObject(this); + wxPostEvent(this, event); + return; + } + } + if (m_show_bind) { + auto left = GetSize().x - m_unbind_img.GetBmpSize().x - 6; + auto right = left + m_unbind_img.GetBmpSize().x; + auto top = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2; + auto bottom = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2 + m_unbind_img.GetBmpSize().y; + + if ((evt.GetPosition().x >= left && evt.GetPosition().x <= right) && evt.GetPosition().y >= top && evt.GetPosition().y <= bottom) { + wxCommandEvent event(EVT_UNBIND_MACHINE, GetId()); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } else { + if (m_info) { + wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); + } + //wxGetApp().mainframe->SetFocus(); + wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST); + event.SetEventObject(this->GetParent()); + wxPostEvent(this->GetParent(), event); + } + return; + } + if (m_info && m_info->is_lan_mode_printer()) { + if (m_info->has_access_right() && m_info->is_avaliable()) { + wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); + } else { + wxCommandEvent event(EVT_CONNECT_LAN_PRINT); + event.SetEventObject(this); + wxPostEvent(this, event); + } + } else { + wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); + } + } else { + if (m_info && m_info->is_lan_mode_printer()) { + wxCommandEvent event(EVT_CONNECT_LAN_PRINT); + event.SetEventObject(this); + wxPostEvent(this, event); + } else { + wxCommandEvent event(EVT_BIND_MACHINE); + event.SetEventObject(this); + wxPostEvent(this, event); + } + } + +} + +SelectMachinePopup::SelectMachinePopup(wxWindow *parent) + : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_dismiss(false) +{ +#ifdef __WINDOWS__ + SetDoubleBuffered(true); +#endif //__WINDOWS__ + + + SetSize(SELECT_MACHINE_POPUP_SIZE); + SetMinSize(SELECT_MACHINE_POPUP_SIZE); + SetMaxSize(SELECT_MACHINE_POPUP_SIZE); + + Freeze(); + wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL); + SetBackgroundColour(SELECT_MACHINE_GREY400); + + + + m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_LIST_SIZE, wxHSCROLL | wxVSCROLL); + m_scrolledWindow->SetBackgroundColour(*wxWHITE); + m_scrolledWindow->SetMinSize(SELECT_MACHINE_LIST_SIZE); + m_scrolledWindow->SetScrollRate(0, 5); + auto m_sizxer_scrolledWindow = new wxBoxSizer(wxVERTICAL); + m_scrolledWindow->SetSizer(m_sizxer_scrolledWindow); + m_scrolledWindow->Layout(); + m_sizxer_scrolledWindow->Fit(m_scrolledWindow); + +#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) + m_sizer_search_bar = new wxBoxSizer(wxVERTICAL); + m_search_bar = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_search_bar->SetDescriptiveText(_L("Search")); + m_search_bar->ShowSearchButton( true ); + m_search_bar->ShowCancelButton( false ); + m_sizer_search_bar->Add( m_search_bar, 1, wxALL| wxEXPAND, 1 ); + m_sizer_main->Add(m_sizer_search_bar, 0, wxALL | wxEXPAND, FromDIP(2)); + m_search_bar->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SelectMachinePopup::update_machine_list, this ); +#endif + auto own_title = create_title_panel(_L("My Device")); + m_sizer_my_devices = new wxBoxSizer(wxVERTICAL); + auto other_title = create_title_panel(_L("Other Device")); + m_sizer_other_devices = new wxBoxSizer(wxVERTICAL); + + + m_panel_ping_code = new PinCodePanel(m_scrolledWindow, 0, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); + m_panel_direct_connection = new PinCodePanel(m_scrolledWindow, 1, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); + + m_sizxer_scrolledWindow->Add(own_title, 0, wxEXPAND | wxLEFT, FromDIP(15)); + m_sizxer_scrolledWindow->Add(m_sizer_my_devices, 0, wxEXPAND, 0); + m_sizxer_scrolledWindow->Add(m_panel_ping_code, 0, wxEXPAND, 0); + m_sizxer_scrolledWindow->Add(m_panel_direct_connection, 0, wxEXPAND, 0); + m_sizxer_scrolledWindow->Add(other_title, 0, wxEXPAND | wxLEFT, FromDIP(15)); + m_sizxer_scrolledWindow->Add(m_sizer_other_devices, 0, wxEXPAND, 0); + + m_sizer_main->Add(m_scrolledWindow, 0, wxALL | wxEXPAND, FromDIP(2)); + + SetSizer(m_sizer_main); + Layout(); + Thaw(); + + #ifdef __APPLE__ + m_scrolledWindow->Bind(wxEVT_LEFT_UP, &SelectMachinePopup::OnLeftUp, this); + #endif // __APPLE__ + + m_refresh_timer = new wxTimer(); + m_refresh_timer->SetOwner(this); + Bind(EVT_UPDATE_USER_MACHINE_LIST, &SelectMachinePopup::update_machine_list, this); + Bind(wxEVT_TIMER, &SelectMachinePopup::on_timer, this); + Bind(EVT_DISSMISS_MACHINE_LIST, &SelectMachinePopup::on_dissmiss_win, this); +} + +SelectMachinePopup::~SelectMachinePopup() { delete m_refresh_timer;} + +void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus)) +{ + BOOST_LOG_TRIVIAL(trace) << "get_print_info: start"; + start_ssdp(true); + if (m_refresh_timer) { + m_refresh_timer->Stop(); + m_refresh_timer->Start(MACHINE_LIST_REFRESH_INTERVAL); + } + + if (wxGetApp().is_user_login()) { + if (!get_print_info_thread) { + get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] { + NetworkAgent* agent = wxGetApp().getAgent(); + unsigned int http_code; + std::string body; + int result = agent->get_user_print_info(&http_code, &body); + CallAfter([token, this, result, body]() { + if (token.expired()) {return;} + if (result == 0) { + m_print_info = body; + } + else { + m_print_info = ""; + } + wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); + event.SetEventObject(this); + wxPostEvent(this, event); + }); + })); + } + } + + wxPostEvent(this, wxTimerEvent()); + PopupWindow::Popup(); +} + +void SelectMachinePopup::OnDismiss() +{ + BOOST_LOG_TRIVIAL(trace) << "get_print_info: dismiss"; + start_ssdp(false); + m_dismiss = true; + + if (m_refresh_timer) { + m_refresh_timer->Stop(); + } + if (get_print_info_thread) { + if (get_print_info_thread->joinable()) { + get_print_info_thread->join(); + delete get_print_info_thread; + get_print_info_thread = nullptr; + } + } + + wxCommandEvent event(EVT_FINISHED_UPDATE_MACHINE_LIST); + event.SetEventObject(this); + wxPostEvent(this, event); +} + +bool SelectMachinePopup::ProcessLeftDown(wxMouseEvent &event) { + return PopupWindow::ProcessLeftDown(event); +} + +bool SelectMachinePopup::Show(bool show) { + if (show) { + for (int i = 0; i < m_user_list_machine_panel.size(); i++) { + m_user_list_machine_panel[i]->mPanel->update_machine_info(nullptr); + m_user_list_machine_panel[i]->mPanel->Hide(); + } + + for (int j = 0; j < m_other_list_machine_panel.size(); j++) { + m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr); + m_other_list_machine_panel[j]->mPanel->Hide(); + } + } + return PopupWindow::Show(show); +} + +wxWindow *SelectMachinePopup::create_title_panel(wxString text) +{ + auto m_panel_title_own = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE, wxTAB_TRAVERSAL); + m_panel_title_own->SetBackgroundColour(*wxWHITE); + + wxBoxSizer *m_sizer_title_own = new wxBoxSizer(wxHORIZONTAL); + + auto m_title_own = new wxStaticText(m_panel_title_own, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, 0); + m_title_own->Wrap(-1); + m_sizer_title_own->Add(m_title_own, 0, wxALIGN_CENTER, 0); + + wxBoxSizer *m_sizer_line_own = new wxBoxSizer(wxHORIZONTAL); + + auto m_panel_line_own = new wxPanel(m_panel_title_own, wxID_ANY, wxDefaultPosition, wxSize(SELECT_MACHINE_ITEM_SIZE.x, FromDIP(1)), wxTAB_TRAVERSAL); + m_panel_line_own->SetBackgroundColour(SELECT_MACHINE_GREY400); + + m_sizer_line_own->Add(m_panel_line_own, 0, wxALIGN_CENTER, 0); + m_sizer_title_own->Add(0, 0, 0, wxLEFT, FromDIP(10)); + m_sizer_title_own->Add(m_sizer_line_own, 1, wxEXPAND | wxRIGHT, FromDIP(10)); + + m_panel_title_own->SetSizer(m_sizer_title_own); + m_panel_title_own->Layout(); + return m_panel_title_own; +} + +void SelectMachinePopup::on_timer(wxTimerEvent &event) +{ + BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup on_timer"; + wxGetApp().reset_to_active(); + wxCommandEvent user_event(EVT_UPDATE_USER_MACHINE_LIST); + user_event.SetEventObject(this); + wxPostEvent(this, user_event); +} + +void SelectMachinePopup::update_other_devices() +{ + DeviceManager* dev = wxGetApp().getDeviceManager(); + if (!dev) return; + m_free_machine_list = dev->get_local_machine_list(); + + BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices start"; + this->Freeze(); + m_scrolledWindow->Freeze(); + int i = 0; + + for (auto &elem : m_free_machine_list) { + MachineObject * mobj = elem.second; + /* do not show printer bind state is empty */ + if (!mobj->is_avaliable()) continue; + + if (!wxGetApp().is_user_login() && !mobj->is_lan_mode_printer()) + continue; + + /* do not show printer in my list */ + auto it = m_bind_machine_list.find(mobj->dev_id); + if (it != m_bind_machine_list.end()) + continue; + + MachineObjectPanel* op = nullptr; + if (i < m_other_list_machine_panel.size()) { + op = m_other_list_machine_panel[i]->mPanel; + } else { + op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY); + MachinePanel* mpanel = new MachinePanel(); + mpanel->mIndex = wxString::Format("%d", i); + mpanel->mPanel = op; + m_other_list_machine_panel.push_back(mpanel); + m_sizer_other_devices->Add(op, 0, wxEXPAND, 0); + } +#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) + if (!search_for_printer(mobj)) { + op->Hide(); + } + else { + op->Show(); + } +#else + op->Show(); +#endif + i++; + + op->update_machine_info(mobj); + + if (mobj->is_lan_mode_printer()) { + if (mobj->has_access_right()) { + op->set_printer_state(PrinterState::IN_LAN); + } else { + op->set_printer_state(PrinterState::LOCK); + } + } else { + op->show_edit_printer_name(false); + op->show_printer_bind(true, PrinterBindState::ALLOW_BIND); + if (mobj->is_in_printing()) { + op->set_printer_state(PrinterState::BUSY); + } else { + op->SetToolTip(_L("Online")); + op->set_printer_state(IDLE); + } + } + + op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) { + if (mobj) { + if (mobj->is_lan_mode_printer()) { + ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); + dlg.set_machine_object(mobj); + if (dlg.ShowModal() == wxID_OK) { + wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); + } + } + } + }); + + op->Bind(EVT_BIND_MACHINE, [this, mobj](wxCommandEvent &e) { + BindMachineDialog dlg; + dlg.update_machine_info(mobj); + int dlg_result = wxID_CANCEL; + dlg_result = dlg.ShowModal(); + if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); } + }); + } + + for (int j = i; j < m_other_list_machine_panel.size(); j++) { + m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr); + m_other_list_machine_panel[j]->mPanel->Hide(); + } + + if (m_placeholder_panel != nullptr) { + m_scrolledWindow->RemoveChild(m_placeholder_panel); + m_placeholder_panel->Destroy(); + m_placeholder_panel = nullptr; + } + + m_placeholder_panel = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(-1,FromDIP(26))); + wxBoxSizer* placeholder_sizer = new wxBoxSizer(wxVERTICAL); + + m_hyperlink = new wxHyperlinkCtrl(m_placeholder_panel, wxID_ANY, _L("Can't find my devices?"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + m_hyperlink->SetNormalColour(StateColor::darkModeColorFor("#009789")); + placeholder_sizer->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5); + + + m_placeholder_panel->SetSizer(placeholder_sizer); + m_placeholder_panel->Layout(); + placeholder_sizer->Fit(m_placeholder_panel); + + m_placeholder_panel->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); + m_sizer_other_devices->Add(m_placeholder_panel, 0, wxEXPAND, 0); + + //m_sizer_other_devices->Layout(); + if(m_other_devices_count != i) { + m_scrolledWindow->Fit(); + } + m_scrolledWindow->Layout(); + m_scrolledWindow->Thaw(); + Layout(); + Fit(); + this->Thaw(); + m_other_devices_count = i; + BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices end"; +} + +void SelectMachinePopup::update_user_devices() +{ + Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) return; + + if (!m_print_info.empty()) { + dev->parse_user_print_info(m_print_info); + m_print_info = ""; + } + + m_bind_machine_list.clear(); + m_bind_machine_list = dev->get_my_machine_list(); + + //sort list + std::vector> user_machine_list; + for (auto& it: m_bind_machine_list) { + user_machine_list.push_back(it); + } + + std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto&b) { + if (a.second && b.second) { + return a.second->dev_name.compare(b.second->dev_name) < 0; + } + return false; + }); + + BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_machine_list start"; + this->Freeze(); + m_scrolledWindow->Freeze(); + int i = 0; + + for (auto& elem : user_machine_list) { + MachineObject* mobj = elem.second; + MachineObjectPanel* op = nullptr; + if (i < m_user_list_machine_panel.size()) { + op = m_user_list_machine_panel[i]->mPanel; +#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) + if (!search_for_printer(mobj)) { + op->Hide(); + } else { + op->Show(); + } +#else + op->Show(); +#endif + } else { + op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY); + MachinePanel* mpanel = new MachinePanel(); + mpanel->mIndex = wxString::Format("%d", i); + mpanel->mPanel = op; + m_user_list_machine_panel.push_back(mpanel); + m_sizer_my_devices->Add(op, 0, wxEXPAND, 0); + } + i++; + op->update_machine_info(mobj, true); + //set in lan + if (mobj->is_lan_mode_printer()) { + if (!mobj->is_online()) { + continue; + } + else { + op->show_printer_bind(false, PrinterBindState::NONE); + op->show_edit_printer_name(false); + if (mobj->has_access_right() && mobj->is_avaliable()) { + op->set_printer_state(PrinterState::IN_LAN); + op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND); + op->SetToolTip(_L("Online")); + } + else { + op->set_printer_state(PrinterState::LOCK); + } + } + op->Bind(EVT_UNBIND_MACHINE, [this, dev, mobj](wxCommandEvent& e) { + dev->set_selected_machine(""); + if (mobj) { + AppConfig* config = wxGetApp().app_config; + if (config) { + config->erase_local_machine(mobj->dev_id); + } + + mobj->set_access_code(""); + mobj->erase_user_access_code(); + } + + MessageDialog msg_wingow(nullptr, _L("Log out successful."), "", wxAPPLY | wxOK); + if (msg_wingow.ShowModal() == wxOK) { return; } + }); + } + else { + op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND); + op->Bind(EVT_UNBIND_MACHINE, [this, mobj, dev](wxCommandEvent& e) { + // show_unbind_dialog + UnBindMachineDialog dlg; + dlg.update_machine_info(mobj); + if (dlg.ShowModal() == wxID_OK) { + dev->set_selected_machine(""); + } + }); + + if (!mobj->is_online()) { + op->SetToolTip(_L("Offline")); + op->set_printer_state(PrinterState::OFFLINE); + } + else { + op->show_edit_printer_name(true); + op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND); + if (mobj->is_in_printing()) { + op->SetToolTip(_L("Busy")); + op->set_printer_state(PrinterState::BUSY); + } + else { + op->SetToolTip(_L("Online")); + op->set_printer_state(PrinterState::IDLE); + } + } + } + + op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) { + if (mobj) { + if (mobj->is_lan_mode_printer()) { + ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); + dlg.set_machine_object(mobj); + if (dlg.ShowModal() == wxID_OK) { + wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); + } + } + } + }); + + op->Bind(EVT_EDIT_PRINT_NAME, [this, mobj](wxCommandEvent &e) { + EditDevNameDialog dlg; + dlg.set_machine_obj(mobj); + dlg.ShowModal(); + }); + } + + for (int j = i; j < m_user_list_machine_panel.size(); j++) { + m_user_list_machine_panel[j]->mPanel->update_machine_info(nullptr); + m_user_list_machine_panel[j]->mPanel->Hide(); + } + //m_sizer_my_devices->Layout(); + + if (m_my_devices_count != i) { + m_scrolledWindow->Fit(); + } + m_scrolledWindow->Layout(); + m_scrolledWindow->Thaw(); + Layout(); + Fit(); + this->Thaw(); + m_my_devices_count = i; +} + +bool SelectMachinePopup::search_for_printer(MachineObject* obj) +{ + std::string search_text = std::string((m_search_bar->GetValue()).mb_str()); + if (search_text.empty()) { + return true; + } + auto name = obj->dev_name; + auto ip = obj->dev_ip; + auto name_it = name.find(search_text); + auto ip_it = ip.find(search_text); + if ((name_it != std::string::npos)||(ip_it != std::string::npos)) { + return true; + } + + return false; +} + +void SelectMachinePopup::on_dissmiss_win(wxCommandEvent &event) +{ + Dismiss(); +} + +void SelectMachinePopup::update_machine_list(wxCommandEvent &event) +{ + update_user_devices(); + update_other_devices(); + BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_machine_list end"; +} + +void SelectMachinePopup::start_ssdp(bool start) +{ + return; + //if (wxGetApp().getAgent()) { wxGetApp().getAgent()->start_discovery(true, start); } +} + +void SelectMachinePopup::OnLeftUp(wxMouseEvent &event) +{ + auto mouse_pos = ClientToScreen(event.GetPosition()); + auto wxscroll_win_pos = m_scrolledWindow->ClientToScreen(wxPoint(0, 0)); + + if (mouse_pos.x > wxscroll_win_pos.x && mouse_pos.y > wxscroll_win_pos.y && mouse_pos.x < (wxscroll_win_pos.x + m_scrolledWindow->GetSize().x) && + mouse_pos.y < (wxscroll_win_pos.y + m_scrolledWindow->GetSize().y)) { + + for (MachinePanel* p : m_user_list_machine_panel) { + auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0)); + if (mouse_pos.x > p_rect.x && mouse_pos.y > p_rect.y && mouse_pos.x < (p_rect.x + p->mPanel->GetSize().x) && mouse_pos.y < (p_rect.y + p->mPanel->GetSize().y)) { + wxMouseEvent event(wxEVT_LEFT_UP); + auto tag_pos = p->mPanel->ScreenToClient(mouse_pos); + event.SetPosition(tag_pos); + event.SetEventObject(p->mPanel); + wxPostEvent(p->mPanel, event); + } + } + + for (MachinePanel* p : m_other_list_machine_panel) { + auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0)); + if (mouse_pos.x > p_rect.x && mouse_pos.y > p_rect.y && mouse_pos.x < (p_rect.x + p->mPanel->GetSize().x) && mouse_pos.y < (p_rect.y + p->mPanel->GetSize().y)) { + wxMouseEvent event(wxEVT_LEFT_UP); + auto tag_pos = p->mPanel->ScreenToClient(mouse_pos); + event.SetPosition(tag_pos); + event.SetEventObject(p->mPanel); + wxPostEvent(p->mPanel, event); + } + } + + //pin code + auto pc_rect = m_panel_ping_code->ClientToScreen(wxPoint(0, 0)); + if (mouse_pos.x > pc_rect.x && mouse_pos.y > pc_rect.y && mouse_pos.x < (pc_rect.x + m_panel_ping_code->GetSize().x) && mouse_pos.y < (pc_rect.y + m_panel_ping_code->GetSize().y)) { + wxGetApp().popup_ping_bind_dialog(); + } + + //bind with access code + auto dc_rect = m_panel_direct_connection->ClientToScreen(wxPoint(0, 0)); + if (mouse_pos.x > dc_rect.x && mouse_pos.y > dc_rect.y && mouse_pos.x < (dc_rect.x + m_panel_direct_connection->GetSize().x) && mouse_pos.y < (dc_rect.y + m_panel_direct_connection->GetSize().y)) { + InputIpAddressDialog dlgo; + dlgo.ShowModal(); + } + + //hyper link + auto h_rect = m_hyperlink->ClientToScreen(wxPoint(0, 0)); + if (mouse_pos.x > h_rect.x && mouse_pos.y > h_rect.y && mouse_pos.x < (h_rect.x + m_hyperlink->GetSize().x) && mouse_pos.y < (h_rect.y + m_hyperlink->GetSize().y)) { + wxLaunchDefaultBrowser(wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer")); + } + } +} + +EditDevNameDialog::EditDevNameDialog(Plater *plater /*= nullptr*/) + : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Modifying the device name"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) +{ + std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str(); + SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); + + SetBackgroundColour(*wxWHITE); + wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL); + auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); + m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); + m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(38)); + m_textCtr = new ::TextInput(this, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(260), FromDIP(40)), wxTE_PROCESS_ENTER); + m_textCtr->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(22))); + m_textCtr->SetMinSize(wxSize(FromDIP(260), FromDIP(40))); + m_sizer_main->Add(m_textCtr, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, FromDIP(40)); + + m_static_valid = new wxStaticText(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0); + m_static_valid->Wrap(-1); + m_static_valid->SetFont(::Label::Body_13); + m_static_valid->SetForegroundColour(wxColour(255, 111, 0)); + m_sizer_main->Add(m_static_valid, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxLEFT | wxRIGHT, FromDIP(10)); + + + m_button_confirm = new Button(this, _L("Confirm")); + StateColor btn_bg_green(std::pair(wxColour(0, 137, 123), StateColor::Pressed), std::pair(wxColour(0, 150, 136), StateColor::Normal)); + m_button_confirm->SetBackgroundColor(btn_bg_green); + m_button_confirm->SetBorderColor(wxColour(0, 150, 136)); + m_button_confirm->SetTextColor(wxColour(255, 255, 255)); + m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24))); + m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24))); + m_button_confirm->SetCornerRadius(FromDIP(12)); + m_button_confirm->Bind(wxEVT_BUTTON, &EditDevNameDialog::on_edit_name, this); + + m_sizer_main->Add(m_button_confirm, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(10)); + m_sizer_main->Add(0, 0, 0, wxBOTTOM, FromDIP(38)); + + SetSizer(m_sizer_main); + Layout(); + Fit(); + Centre(wxBOTH); + wxGetApp().UpdateDlgDarkUI(this); +} + +EditDevNameDialog::~EditDevNameDialog() {} + +void EditDevNameDialog::set_machine_obj(MachineObject *obj) +{ + m_info = obj; + if (m_info) + m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name)); +} + +void EditDevNameDialog::on_dpi_changed(const wxRect &suggested_rect) +{ + m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24))); + m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24))); +} + +void EditDevNameDialog::on_edit_name(wxCommandEvent &e) +{ + m_static_valid->SetLabel(wxEmptyString); + auto m_valid_type = Valid; + wxString info_line; + auto new_dev_name = m_textCtr->GetTextCtrl()->GetValue(); + + const char * unusable_symbols = "<>[]:/\\|?*\""; + const std::string unusable_suffix = PresetCollection::get_suffix_modified(); + + for (size_t i = 0; i < std::strlen(unusable_symbols); i++) { + if (new_dev_name.find_first_of(unusable_symbols[i]) != std::string::npos) { + info_line = _L("Name is invalid;") + _L("illegal characters:") + " " + unusable_symbols; + m_valid_type = NoValid; + break; + } + } + + if (m_valid_type == Valid && new_dev_name.find(unusable_suffix) != std::string::npos) { + info_line = _L("Name is invalid;") + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified()); + m_valid_type = NoValid; + } + + if (m_valid_type == Valid && new_dev_name.empty()) { + info_line = _L("The name is not allowed to be empty."); + m_valid_type = NoValid; + } + + if (m_valid_type == Valid && new_dev_name.find_first_of(' ') == 0) { + info_line = _L("The name is not allowed to start with space character."); + m_valid_type = NoValid; + } + + if (m_valid_type == Valid && new_dev_name.find_last_of(' ') == new_dev_name.length() - 1) { + info_line = _L("The name is not allowed to end with space character."); + m_valid_type = NoValid; + } + + if (m_valid_type == NoValid) { + m_static_valid->SetLabel(info_line); + Layout(); + } + + if (m_valid_type == Valid) { + m_static_valid->SetLabel(wxEmptyString); + DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (dev) { + auto utf8_str = new_dev_name.ToUTF8(); + auto name = std::string(utf8_str.data(), utf8_str.length()); + if (m_info) + dev->modify_device_name(m_info->dev_id, name); + } + DPIDialog::EndModal(wxID_CLOSE); + } +} + +PinCodePanel::PinCodePanel(wxWindow* parent, int type, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/) + { + wxPanel::Create(parent, winid, pos); + Bind(wxEVT_PAINT, &PinCodePanel::OnPaint, this); + SetSize(SELECT_MACHINE_ITEM_SIZE); + SetMaxSize(SELECT_MACHINE_ITEM_SIZE); + SetMinSize(SELECT_MACHINE_ITEM_SIZE); + + m_type = type; + m_bitmap = ScalableBitmap(this, "bind_device_ping_code",10); + + this->Bind(wxEVT_ENTER_WINDOW, &PinCodePanel::on_mouse_enter, this); + this->Bind(wxEVT_LEAVE_WINDOW, &PinCodePanel::on_mouse_leave, this); + this->Bind(wxEVT_LEFT_UP, &PinCodePanel::on_mouse_left_up, this); + } + + void PinCodePanel::OnPaint(wxPaintEvent& event) + { + wxPaintDC dc(this); + render(dc); + } + + void PinCodePanel::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 PinCodePanel::doRender(wxDC& dc) + { + auto size = GetSize(); + dc.DrawBitmap(m_bitmap.bmp(), wxPoint(FromDIP(12), (size.y - m_bitmap.GetBmpSize().y) / 2)); + dc.SetFont(::Label::Head_13); + dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#262E30"))); // ORCA fix text not visible on dark theme + wxString txt; + if (m_type == 0) {txt = _L("Bind with Pin Code");} + else if (m_type == 1) {txt = _L("Bind with Access Code");} + + auto txt_size = dc.GetTextExtent(txt); + dc.DrawText(txt, wxPoint(FromDIP(28), (size.y - txt_size.y) / 2)); + + if (m_hover) { + dc.SetPen(SELECT_MACHINE_BRAND); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(0, 0, size.x, size.y); + } + } + + void PinCodePanel::on_mouse_enter(wxMouseEvent& evt) + { + m_hover = true; + Refresh(); + } + + void PinCodePanel::on_mouse_leave(wxMouseEvent& evt) + { + m_hover = false; + Refresh(); + } + + void PinCodePanel::on_mouse_left_up(wxMouseEvent& evt) + { + if (m_type == 0) { + wxGetApp().popup_ping_bind_dialog(); + } + else if (m_type == 1) { + InputIpAddressDialog dlgo; + dlgo.ShowModal(); + } + } + + }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/SelectMachinePop.hpp b/src/slic3r/GUI/SelectMachinePop.hpp new file mode 100644 index 00000000000..d1a34f9b3a4 --- /dev/null +++ b/src/slic3r/GUI/SelectMachinePop.hpp @@ -0,0 +1,233 @@ +#ifndef slic3r_GUI_SelectMachinePop_hpp_ +#define slic3r_GUI_SelectMachinePop_hpp_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 +#include + +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 m_user_list_machine_panel; + std::vector m_other_list_machine_panel; + boost::thread* get_print_info_thread{ nullptr }; + std::shared_ptr m_token = std::make_shared(0); + std::string m_print_info = ""; + bool m_dismiss { false }; + + std::map m_bind_machine_list; + std::map 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 diff --git a/src/slic3r/GUI/SendMultiMachinePage.cpp b/src/slic3r/GUI/SendMultiMachinePage.cpp index 3efbbcbfab4..dd31e6ad1a8 100644 --- a/src/slic3r/GUI/SendMultiMachinePage.cpp +++ b/src/slic3r/GUI/SendMultiMachinePage.cpp @@ -568,7 +568,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"; diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 7d0fb5663cd..180a7e8beed 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -201,7 +201,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); @@ -613,7 +613,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); @@ -675,7 +675,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"; @@ -693,7 +693,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(""); @@ -764,7 +764,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(m_printer_last_select); @@ -782,9 +782,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) { @@ -1289,7 +1289,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()) { @@ -1316,7 +1316,7 @@ void SendToPrinterDialog::set_default() image = image.Rescale(FromDIP(256), FromDIP(256)); m_thumbnailPanel->set_thumbnail(image); } - + std::vector materials; std::vector display_materials; { @@ -1338,7 +1338,7 @@ void SendToPrinterDialog::set_default() Layout(); Fit(); - + wxSize screenSize = wxGetDisplaySize(); auto dialogSize = this->GetSize(); diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index a73bcbea8f5..2b8185bb3e7 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -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 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::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); - - std::vector 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); - } + int ams_id = event.GetInt(); + int slot_id = event.GetString().IsEmpty() ? 0 : std::stoi(event.GetString().ToStdString()); - 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; - } + try { + m_filament_setting_dlg->ams_id = ams_id; + m_filament_setting_dlg->slot_id = slot_id; + + 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); + + std::vector 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->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->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 (...) { + ; } } } @@ -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; diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index e34bf908aad..287858de9a6 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -435,6 +435,7 @@ class StatusBasePanel : public wxScrolledWindow ~StatusBasePanel(); + MachineObject* obj{nullptr}; void init_bitmaps(); wxBoxSizer *create_monitoring_page(); wxBoxSizer *create_machine_control_page(wxWindow *parent); @@ -640,7 +641,6 @@ class StatusPanel : public StatusBasePanel STATE_COUNT = 4 }; - MachineObject *obj {nullptr}; BBLSubTask * last_subtask{nullptr}; std::string last_profile_id; std::string last_task_id; diff --git a/src/slic3r/GUI/UpgradePanel.cpp b/src/slic3r/GUI/UpgradePanel.cpp index 23d3b8ace3e..71b4b313021 100644 --- a/src/slic3r/GUI/UpgradePanel.cpp +++ b/src/slic3r/GUI/UpgradePanel.cpp @@ -2,6 +2,8 @@ #include #include #include +#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 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 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::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())); + + if (it == ver_list.end()) { + continue; + } + auto ams_id = std::stoi(iter->second->id); + ams_id -= ams_id >= 128 ? 128 : 0; - wxString ams_text = wxString::Format("AMS%s", std::to_string(ams_id + 1)); + 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); } } diff --git a/src/slic3r/GUI/UpgradePanel.hpp b/src/slic3r/GUI/UpgradePanel.hpp index 8e0a9ad0d9d..7e9c84c8010 100644 --- a/src/slic3r/GUI/UpgradePanel.hpp +++ b/src/slic3r/GUI/UpgradePanel.hpp @@ -12,6 +12,9 @@ namespace Slic3r { namespace GUI { +// Previous definitions +class uiDeviceUpdateVersion; + class ExtensionPanel : public wxPanel { public: @@ -105,6 +108,24 @@ class MachineInfoPanel : public wxPanel 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 @@ class MachineInfoPanel : public wxPanel 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 @@ class MachineInfoPanel : public wxPanel ~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 @@ class MachineInfoPanel : public wxPanel 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 @@ class MachineInfoPanel : public wxPanel 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 { diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index 1d8b592050b..047adbeaeb6 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -4,2379 +4,26 @@ #include "../I18N.hpp" #include "../GUI_App.hpp" -#include - -#include -#include -#include "CalibUtils.hpp" - -namespace Slic3r { namespace GUI { - -static const wxColour AMS_TRAY_DEFAULT_COL = wxColour(255, 255, 255); - -wxDEFINE_EVENT(EVT_AMS_EXTRUSION_CALI, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_LOAD, SimpleEvent); -wxDEFINE_EVENT(EVT_AMS_UNLOAD, SimpleEvent); -wxDEFINE_EVENT(EVT_AMS_SETTINGS, SimpleEvent); -wxDEFINE_EVENT(EVT_AMS_FILAMENT_BACKUP, SimpleEvent); -wxDEFINE_EVENT(EVT_AMS_REFRESH_RFID, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_ON_SELECTED, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_ON_FILAMENT_EDIT, wxCommandEvent); -wxDEFINE_EVENT(EVT_VAMS_ON_FILAMENT_EDIT, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_CLIBRATION_AGAIN, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_CLIBRATION_CANCEL, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_GUIDE_WIKI, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_RETRY, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_SHOW_HUMIDITY_TIPS, wxCommandEvent); -wxDEFINE_EVENT(EVT_AMS_UNSELETED_VAMS, wxCommandEvent); -wxDEFINE_EVENT(EVT_CLEAR_SPEED_CONTROL, wxCommandEvent); - -bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, bool humidity_flag) -{ - if (!ams) return false; - this->ams_id = ams->id; - - if (humidity_flag) { - this->ams_humidity = ams->humidity; - } - else { - this->ams_humidity = -1; - } - - cans.clear(); - for (int i = 0; i < 4; i++) { - auto it = ams->trayList.find(std::to_string(i)); - Caninfo info; - // tray is exists - if (it != ams->trayList.end() && it->second->is_exists) { - if (it->second->is_tray_info_ready()) { - info.can_id = it->second->id; - info.ctype = it->second->ctype; - info.material_name = it->second->get_display_filament_type(); - if (!it->second->color.empty()) { - info.material_colour = AmsTray::decode_color(it->second->color); - } else { - // set to white by default - info.material_colour = AMS_TRAY_DEFAULT_COL; - } - - for (std::string cols:it->second->cols) { - info.material_cols.push_back(AmsTray::decode_color(cols)); - } - - if (MachineObject::is_bbl_filament(it->second->tag_uid)) { - info.material_state = AMSCanType::AMS_CAN_TYPE_BRAND; - } else { - info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND; - } - - if (!MachineObject::is_bbl_filament(it->second->tag_uid) || !remain_flag) { - info.material_remain = 100; - } else { - info.material_remain = it->second->remain < 0 ? 0 : it->second->remain; - info.material_remain = it->second->remain > 100 ? 100 : info.material_remain; - } - - - } else { - info.can_id = it->second->id; - info.material_name = ""; - info.ctype = 0; - info.material_colour = AMS_TRAY_DEFAULT_COL; - info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND; - wxColour(255, 255, 255); - } - - if (it->second->is_tray_info_ready() && obj->cali_version >= 0) { - CalibUtils::get_pa_k_n_value_by_cali_idx(obj, it->second->cali_idx, info.k, info.n); - } - else { - info.k = it->second->k; - info.n = it->second->n; - } - } else { - info.can_id = i; - info.material_state = AMSCanType::AMS_CAN_TYPE_EMPTY; - } - cans.push_back(info); - } - return true; -} - -/************************************************* -Description:AMSrefresh -**************************************************/ - -AMSrefresh::AMSrefresh() { SetFont(Label::Body_10);} - -AMSrefresh::AMSrefresh(wxWindow *parent, wxString number, Caninfo info, const wxPoint &pos, const wxSize &size) : AMSrefresh() -{ - m_info = info; - m_can_id = number.ToStdString(); - create(parent, wxID_ANY, pos, size); -} - -AMSrefresh::AMSrefresh(wxWindow *parent, int number, Caninfo info, const wxPoint &pos, const wxSize &size) : AMSrefresh() -{ - m_info = info; - m_can_id = wxString::Format("%d", number).ToStdString(); - create(parent, wxID_ANY, pos, size); -} - - AMSrefresh::~AMSrefresh() - { - if (m_playing_timer) { - m_playing_timer->Stop(); - delete m_playing_timer; - m_playing_timer = nullptr; - } - } - -void AMSrefresh::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) -{ - wxWindow::Create(parent, id, pos, size, wxBORDER_NONE); - SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); - - Bind(wxEVT_TIMER, &AMSrefresh::on_timer, this); - Bind(wxEVT_PAINT, &AMSrefresh::paintEvent, this); - Bind(wxEVT_ENTER_WINDOW, &AMSrefresh::OnEnterWindow, this); - Bind(wxEVT_LEAVE_WINDOW, &AMSrefresh::OnLeaveWindow, this); - Bind(wxEVT_LEFT_DOWN, &AMSrefresh::OnClick, this); - - m_bitmap_normal = ScalableBitmap(this, "ams_refresh_normal", 30); - m_bitmap_selected = ScalableBitmap(this, "ams_refresh_selected", 30); - - m_bitmap_ams_rfid_0 = ScalableBitmap(this, "ams_rfid_0", 30); - m_bitmap_ams_rfid_1 = ScalableBitmap(this, "ams_rfid_1", 30); - m_bitmap_ams_rfid_2 = ScalableBitmap(this, "ams_rfid_2", 30); - m_bitmap_ams_rfid_3 = ScalableBitmap(this, "ams_rfid_3", 30); - m_bitmap_ams_rfid_4 = ScalableBitmap(this, "ams_rfid_4", 30); - m_bitmap_ams_rfid_5 = ScalableBitmap(this, "ams_rfid_5", 30); - m_bitmap_ams_rfid_6 = ScalableBitmap(this, "ams_rfid_6", 30); - m_bitmap_ams_rfid_7 = ScalableBitmap(this, "ams_rfid_7", 30); - - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_0); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_1); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_2); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_3); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_4); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_5); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_6); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_7); - - m_playing_timer = new wxTimer(); - m_playing_timer->SetOwner(this); - wxPostEvent(this, wxTimerEvent()); - - SetSize(AMS_REFRESH_SIZE); - SetMinSize(AMS_REFRESH_SIZE); - SetMaxSize(AMS_REFRESH_SIZE); -} - -void AMSrefresh::on_timer(wxTimerEvent &event) -{ - //if (m_rotation_angle >= m_rfid_bitmap_list.size()) { - // m_rotation_angle = 0; - //} else { - // m_rotation_angle++; - //} - Refresh(); -} - -void AMSrefresh::PlayLoading() -{ - if (m_play_loading | m_disable_mode) return; - m_play_loading = true; - //m_rotation_angle = 0; - m_playing_timer->Start(AMS_REFRESH_PLAY_LOADING_TIMER); - Refresh(); -} - -void AMSrefresh::StopLoading() -{ - if (!m_play_loading | m_disable_mode) return; - m_playing_timer->Stop(); - m_play_loading = false; - Refresh(); -} - -void AMSrefresh::OnEnterWindow(wxMouseEvent &evt) -{ - m_selected = true; - Refresh(); -} - -void AMSrefresh::OnLeaveWindow(wxMouseEvent &evt) -{ - m_selected = false; - Refresh(); -} - -void AMSrefresh::OnClick(wxMouseEvent &evt) { - post_event(wxCommandEvent(EVT_AMS_REFRESH_RFID)); -} - -void AMSrefresh::post_event(wxCommandEvent &&event) -{ - if (m_disable_mode) - return; - event.SetString(m_info.can_id); - event.SetEventObject(m_parent); - wxPostEvent(m_parent, event); - event.Skip(); -} - -void AMSrefresh::paintEvent(wxPaintEvent &evt) -{ - wxSize size = GetSize(); - wxPaintDC dc(this); - - auto colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY700); - if (!wxWindow::IsEnabled()) { colour = AMS_CONTROL_GRAY500; } - - auto pot = wxPoint((size.x - m_bitmap_selected.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2); - - if (!m_disable_mode) { - if (!m_play_loading) { - dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot); - } - else { - /* m_bitmap_rotation = ScalableBitmap(this, "ams_refresh_normal", 30); - auto image = m_bitmap_rotation.bmp().ConvertToImage(); - wxPoint offset; - auto loading_img = image.Rotate(m_rotation_angle, wxPoint(image.GetWidth() / 2, image.GetHeight() / 2), true, &offset); - ScalableBitmap loading_bitmap; - loading_bitmap.bmp() = wxBitmap(loading_img); - dc.DrawBitmap(loading_bitmap.bmp(), offset.x , offset.y);*/ - m_rotation_angle++; - if (m_rotation_angle >= m_rfid_bitmap_list.size()) { - m_rotation_angle = 0; - } - if (m_rfid_bitmap_list.size() <= 0)return; - dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].bmp(), pot); - } - } - - dc.SetPen(wxPen(colour)); - dc.SetBrush(wxBrush(colour)); - dc.SetFont(Label::Body_11); - dc.SetTextForeground(colour); - auto tsize = dc.GetTextExtent(m_refresh_id); - pot = wxPoint((size.x - tsize.x) / 2, (size.y - tsize.y) / 2); - dc.DrawText(m_refresh_id, pot); -} - -void AMSrefresh::Update(std::string ams_id, Caninfo info) -{ - m_ams_id = ams_id; - m_info = info; - - if (!m_ams_id.empty() && !m_can_id.empty()) { - auto aid = atoi(m_ams_id.c_str()); - auto tid = atoi(m_can_id.c_str()); - auto tray_id = aid * 4 + tid; - m_refresh_id = wxGetApp().transition_tridid(tray_id); - } - StopLoading(); -} - -void AMSrefresh::msw_rescale() { - m_bitmap_normal = ScalableBitmap(this, "ams_refresh_normal", 30); - m_bitmap_selected = ScalableBitmap(this, "ams_refresh_selected", 30); - m_bitmap_ams_rfid_0 = ScalableBitmap(this, "ams_rfid_0", 30); - m_bitmap_ams_rfid_1 = ScalableBitmap(this, "ams_rfid_1", 30); - m_bitmap_ams_rfid_2 = ScalableBitmap(this, "ams_rfid_2", 30); - m_bitmap_ams_rfid_3 = ScalableBitmap(this, "ams_rfid_3", 30); - m_bitmap_ams_rfid_4 = ScalableBitmap(this, "ams_rfid_4", 30); - m_bitmap_ams_rfid_5 = ScalableBitmap(this, "ams_rfid_5", 30); - m_bitmap_ams_rfid_6 = ScalableBitmap(this, "ams_rfid_6", 30); - m_bitmap_ams_rfid_7 = ScalableBitmap(this, "ams_rfid_7", 30); - - m_rfid_bitmap_list.clear(); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_0); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_1); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_2); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_3); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_4); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_5); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_6); - m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_7); -} - -void AMSrefresh::DoSetSize(int x, int y, int width, int height, int sizeFlags) -{ - wxWindow::DoSetSize(x, y, width, height, sizeFlags); -} - -/************************************************* -Description:AMSextruder -**************************************************/ -void AMSextruderImage::TurnOn(wxColour col) -{ - m_colour = col; - Refresh(); -} - -void AMSextruderImage::TurnOff() -{ - m_colour = AMS_EXTRUDER_DEF_COLOUR; - Refresh(); -} - -void AMSextruderImage::msw_rescale() -{ - //m_ams_extruder.SetSize(AMS_EXTRUDER_BITMAP_SIZE); - //auto image = m_ams_extruder.ConvertToImage(); - m_ams_extruder = ScalableBitmap(this, "monitor_ams_extruder", 55); - Refresh(); -} - -void AMSextruderImage::paintEvent(wxPaintEvent &evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSextruderImage::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 AMSextruderImage::doRender(wxDC &dc) -{ - auto size = GetSize(); - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(m_colour); - dc.DrawRectangle(0, FromDIP(18), size.x, size.y - FromDIP(18) - FromDIP(5)); - dc.DrawBitmap(m_ams_extruder.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2)); -} - - -AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) -{ - wxWindow::Create(parent, id, pos, AMS_EXTRUDER_BITMAP_SIZE); - SetBackgroundColour(*wxWHITE); - - m_ams_extruder = ScalableBitmap(this, "monitor_ams_extruder",55); - SetSize(AMS_EXTRUDER_BITMAP_SIZE); - SetMinSize(AMS_EXTRUDER_BITMAP_SIZE); - SetMaxSize(AMS_EXTRUDER_BITMAP_SIZE); - - - Bind(wxEVT_PAINT, &AMSextruderImage::paintEvent, this); -} - -AMSextruderImage::~AMSextruderImage() {} - - - -AMSextruder::AMSextruder(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) { create(parent, id, pos, size); } - - AMSextruder::~AMSextruder() {} - -void AMSextruder::TurnOn(wxColour col) -{ - m_amsSextruder->TurnOn(col); -} - -void AMSextruder::TurnOff() -{ - m_amsSextruder->TurnOff(); -} - -void AMSextruder::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) -{ - wxWindow::Create(parent, id, pos, AMS_EXTRUDER_SIZE, wxBORDER_NONE); - SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR); - - wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL); - - m_bitmap_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_BITMAP_SIZE, wxTAB_TRAVERSAL); - m_bitmap_panel->SetBackgroundColour(AMS_EXTRUDER_DEF_COLOUR); - m_bitmap_panel->SetDoubleBuffered(true); - m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL); - - m_amsSextruder = new AMSextruderImage(m_bitmap_panel, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_BITMAP_SIZE); - m_bitmap_sizer->Add(m_amsSextruder, 0, wxALIGN_CENTER, 0); - - m_bitmap_panel->SetSizer(m_bitmap_sizer); - m_bitmap_panel->Layout(); - m_sizer_body->Add( 0, 0, 1, wxEXPAND, 0 ); - m_sizer_body->Add(m_bitmap_panel, 0, wxALIGN_CENTER, 0); - - SetSizer(m_sizer_body); - - Bind(wxEVT_PAINT, &AMSextruder::paintEvent, this); - Layout(); -} - -void AMSextruder::OnVamsLoading(bool load, wxColour col) -{ - m_vams_loading = load; - if (load)m_current_colur = col; - Refresh(); -} - -void AMSextruder::OnAmsLoading(bool load, wxColour col /*= AMS_CONTROL_GRAY500*/) -{ - m_ams_loading = load; - if (load)m_current_colur = col; - Refresh(); -} - -void AMSextruder::paintEvent(wxPaintEvent& evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSextruder::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 AMSextruder::doRender(wxDC& dc) -{ - //m_current_colur = - wxSize size = GetSize(); - dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - - if (!m_none_ams_mode) { - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - } - - if (m_has_vams) { - dc.DrawRoundedRectangle(-size.x / 2, size.y * 0.1, size.x, size.y, 4); - - if (m_vams_loading) { - - if (m_current_colur.Alpha() == 0) { dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID)); } - else { dc.SetPen(wxPen(m_current_colur, 6, wxPENSTYLE_SOLID)); } - dc.DrawRoundedRectangle(-size.x / 2, size.y * 0.1, size.x, size.y, 4); - - if ((m_current_colur == *wxWHITE || m_current_colur.Alpha() == 0) && !wxGetApp().dark_mode()) { - dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); - dc.DrawRoundedRectangle(-size.x / 2 - FromDIP(3), size.y * 0.1 + FromDIP(3), size.x, size.y, 3); - dc.DrawRoundedRectangle(-size.x / 2 + FromDIP(3), size.y * 0.1 - FromDIP(3), size.x, size.y, 5); - } - } - - if (m_ams_loading && !m_none_ams_mode) { - if (m_current_colur.Alpha() == 0) {dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID));} - else {dc.SetPen(wxPen(m_current_colur, 6, wxPENSTYLE_SOLID));} - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - - if ((m_current_colur == *wxWHITE || m_current_colur.Alpha() == 0) && !wxGetApp().dark_mode()) { - dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); - dc.DrawLine(size.x / 2 - FromDIP(4), -1, size.x / 2 - FromDIP(3), size.y * 0.6 - 1); - dc.DrawLine(size.x / 2 + FromDIP(3), -1, size.x / 2 + FromDIP(3), size.y * 0.6 - 1); - } - } - } - else { - if (m_ams_loading) { - if (m_current_colur.Alpha() == 0) { dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID)); } - else { dc.SetPen(wxPen(m_current_colur, 6, wxPENSTYLE_SOLID)); } - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - - if ((m_current_colur == *wxWHITE || m_current_colur.Alpha() == 0) && !wxGetApp().dark_mode()) { - dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); - dc.DrawLine(size.x / 2 - FromDIP(4), -1, size.x / 2 - FromDIP(3), size.y * 0.6 - 1); - dc.DrawLine(size.x / 2 + FromDIP(3), -1, size.x / 2 + FromDIP(3), size.y * 0.6 - 1); - } - } - } - -} - -void AMSextruder::msw_rescale() -{ - m_amsSextruder->msw_rescale(); - Layout(); - Update(); - Refresh(); -} - -/************************************************* -Description:AMSVirtualRoad -**************************************************/ - -AMSVirtualRoad::AMSVirtualRoad(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) { create(parent, id, pos, size); } - -AMSVirtualRoad::~AMSVirtualRoad() {} - -void AMSVirtualRoad::OnVamsLoading(bool load, wxColour col) -{ - m_vams_loading = load; - if (load)m_current_color = col; - Refresh(); -} - -void AMSVirtualRoad::create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) -{ - wxWindow::Create(parent, id, pos, wxDefaultSize, wxBORDER_NONE); - SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR); - Layout(); - Bind(wxEVT_PAINT, &AMSVirtualRoad::paintEvent, this); -} - -void AMSVirtualRoad::paintEvent(wxPaintEvent& evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSVirtualRoad::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 AMSVirtualRoad::doRender(wxDC& dc) -{ - if (!m_has_vams) return; - - wxSize size = GetSize(); - if (m_vams_loading) { - if (m_current_color.Alpha() == 0) { dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID)); } - else { dc.SetPen(wxPen(m_current_color, 6, wxPENSTYLE_SOLID)); } - } - else { - dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); - } - - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - dc.DrawRoundedRectangle(size.x / 2, -size.y / 1.1 + FromDIP(1), size.x, size.y, 4); - - if ((m_current_color == *wxWHITE || m_current_color.Alpha() == 0) && !wxGetApp().dark_mode()) { - dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); - dc.DrawRoundedRectangle(size.x / 2 - FromDIP(3), -size.y / 1.1 + FromDIP(4), size.x, size.y, 5); - dc.DrawRoundedRectangle(size.x / 2 + FromDIP(3), -size.y / 1.1 - FromDIP(2), size.x, size.y, 3); - } -} - - -void AMSVirtualRoad::msw_rescale() -{ - Layout(); - Update(); - Refresh(); -} - - -/************************************************* -Description:AMSLib -**************************************************/ -AMSLib::AMSLib(wxWindow *parent, Caninfo info) -{ - m_border_color = (wxColour(130, 130, 128)); - m_road_def_color = AMS_CONTROL_GRAY500; - wxWindow::SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); - create(parent); - - Bind(wxEVT_PAINT, &AMSLib::paintEvent, this); - Bind(wxEVT_ENTER_WINDOW, &AMSLib::on_enter_window, this); - Bind(wxEVT_LEAVE_WINDOW, &AMSLib::on_leave_window, this); - Bind(wxEVT_LEFT_DOWN, &AMSLib::on_left_down, this); - - Update(info, false); -} - -void AMSLib::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) -{ - wxWindow::Create(parent, id, pos, size); - - SetSize(AMS_CAN_LIB_SIZE); - SetMinSize(AMS_CAN_LIB_SIZE); - SetMaxSize(AMS_CAN_LIB_SIZE); - - auto m_sizer_body = new wxBoxSizer(wxVERTICAL); - - wxBoxSizer *m_sizer_edit = new wxBoxSizer(wxHORIZONTAL); - - m_bitmap_editable = ScalableBitmap(this, "ams_editable", 14); - m_bitmap_editable_light = ScalableBitmap(this, "ams_editable_light", 14); - m_bitmap_readonly = ScalableBitmap(this, "ams_readonly", 14); - m_bitmap_readonly_light = ScalableBitmap(this, "ams_readonly_light", 14); - m_bitmap_transparent = ScalableBitmap(this, "transparent_ams_lib", 68); - - m_bitmap_extra_tray_left = ScalableBitmap(this, "extra_ams_tray_left", 80); - m_bitmap_extra_tray_right = ScalableBitmap(this, "extra_ams_tray_right", 80); - - m_bitmap_extra_tray_left_hover = ScalableBitmap(this, "extra_ams_tray_left_hover", 80); - m_bitmap_extra_tray_right_hover = ScalableBitmap(this, "extra_ams_tray_right_hover", 80); - - m_bitmap_extra_tray_left_selected = ScalableBitmap(this, "extra_ams_tray_left_selected", 80); - m_bitmap_extra_tray_right_selected = ScalableBitmap(this, "extra_ams_tray_right_selected", 80); - - - m_sizer_body->Add(0, 0, 1, wxEXPAND, 0); - m_sizer_body->Add(m_sizer_edit, 0, wxALIGN_CENTER, 0); - m_sizer_body->Add(0, 0, 0, wxBOTTOM, GetSize().y * 0.12); - SetSizer(m_sizer_body); - Layout(); -} - -void AMSLib::on_enter_window(wxMouseEvent &evt) -{ - m_hover = true; - Refresh(); -} - -void AMSLib::on_leave_window(wxMouseEvent &evt) -{ - m_hover = false; - Refresh(); -} - -void AMSLib::on_left_down(wxMouseEvent &evt) -{ - if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE) { - auto size = GetSize(); - auto pos = evt.GetPosition(); - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND || - m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { - - auto left = FromDIP(10); - auto right = size.x - FromDIP(10); - auto top = 0; - auto bottom = 0; - - if (m_ams_model == AMSModel::GENERIC_AMS) { - top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetBmpSize().y); - bottom = size.y - FromDIP(15); - } - else if (m_ams_model == AMSModel::EXTRA_AMS) { - top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y); - bottom = size.y - FromDIP(20); - } - - if (pos.x >= left && pos.x <= right && pos.y >= top && top <= bottom) { - if (m_selected) { - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { - post_event(wxCommandEvent(EVT_VAMS_ON_FILAMENT_EDIT)); - } - else { - post_event(wxCommandEvent(EVT_AMS_ON_FILAMENT_EDIT)); - } - } else { - BOOST_LOG_TRIVIAL(trace) << "current amslib is not selected"; - } - } - } - } -} - - -void AMSLib::paintEvent(wxPaintEvent &evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSLib::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 - - // text - if (m_ams_model == AMSModel::GENERIC_AMS) { - render_generic_text(dc); - } - else if (m_ams_model == AMSModel::EXTRA_AMS) { - render_extra_text(dc); - } -} - -void AMSLib::render_extra_text(wxDC& dc) -{ - auto tmp_lib_colour = m_info.material_colour; - - change_the_opacity(tmp_lib_colour); - auto temp_text_colour = AMS_CONTROL_GRAY800; - - if (tmp_lib_colour.GetLuminance() < 0.6) { - temp_text_colour = AMS_CONTROL_WHITE_COLOUR; - } - else { - temp_text_colour = AMS_CONTROL_GRAY800; - } - - if (m_info.material_remain < 50) { - temp_text_colour = AMS_CONTROL_GRAY800; - } - - if (tmp_lib_colour.Alpha() == 0) { - temp_text_colour = AMS_CONTROL_GRAY800; - } - - dc.SetFont(::Label::Body_13); - dc.SetTextForeground(temp_text_colour); - - auto libsize = GetSize(); - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND - || m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND - || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { - - if (m_info.material_name.empty()) { - auto tsize = dc.GetMultiLineTextExtent("?"); - auto pot = wxPoint(0, 0); - pot = wxPoint((libsize.x - tsize.x) / 2 + FromDIP(2), (libsize.y - tsize.y) / 2 - FromDIP(5)); - dc.DrawText("?", pot); - } - else { - auto tsize = dc.GetMultiLineTextExtent(m_info.material_name); - std::vector split_char_arr = { " ", "-" }; - bool has_split = false; - std::string has_split_char = " "; - - for (std::string split_char : split_char_arr) { - if (m_info.material_name.find(split_char) != std::string::npos) { - has_split = true; - has_split_char = split_char; - } - } - - - if (has_split) { - dc.SetFont(::Label::Body_10); - auto line_top = m_info.material_name.substr(0, m_info.material_name.find(has_split_char)); - auto line_bottom = m_info.material_name.substr(m_info.material_name.find(has_split_char)); - - auto line_top_tsize = dc.GetMultiLineTextExtent(line_top); - auto line_bottom_tsize = dc.GetMultiLineTextExtent(line_bottom); - - auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2 + FromDIP(3), (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y); - dc.DrawText(line_top, pot_top); - - auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2 + FromDIP(3), (libsize.y - line_bottom_tsize.y) / 2); - dc.DrawText(line_bottom, pot_bottom); - - - } - else { - dc.SetFont(::Label::Body_10); - auto pot = wxPoint(0, 0); - if (m_obj ) { - pot = wxPoint((libsize.x - tsize.x) / 2 + FromDIP(6), (libsize.y - tsize.y) / 2 - FromDIP(5)); - } - dc.DrawText(m_info.material_name, pot); - } - } - } - - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_EMPTY) { - auto tsize = dc.GetMultiLineTextExtent("/"); - auto pot = wxPoint((libsize.x - tsize.x) / 2 + FromDIP(2), (libsize.y - tsize.y) / 2 + FromDIP(3)); - dc.DrawText("/", pot); - } -} - -void AMSLib::render_generic_text(wxDC &dc) -{ - bool show_k_value = true; - if (m_obj && (m_obj->cali_version >= 0) && (abs(m_info.k - 0) < 1e-3)) { - show_k_value = false; - } - - auto tmp_lib_colour = m_info.material_colour; - change_the_opacity(tmp_lib_colour); - - auto temp_text_colour = AMS_CONTROL_GRAY800; - - if (tmp_lib_colour.GetLuminance() < 0.6) { - temp_text_colour = AMS_CONTROL_WHITE_COLOUR; - } - else { - temp_text_colour = AMS_CONTROL_GRAY800; - } - - if (m_info.material_remain < 50) { - temp_text_colour = AMS_CONTROL_GRAY800; - } - - if (tmp_lib_colour.Alpha() == 0) { - temp_text_colour = AMS_CONTROL_GRAY800; - } - - dc.SetFont(::Label::Body_13); - dc.SetTextForeground(temp_text_colour); - auto alpha = m_info.material_colour.Alpha(); - if (alpha != 0 && alpha != 255 && alpha != 254) { - dc.SetTextForeground(*wxBLACK); - } - - auto libsize = GetSize(); - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND - || m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND - || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { - - if (m_info.material_name.empty() /*&& m_info.material_state != AMSCanType::AMS_CAN_TYPE_VIRTUAL*/) { - auto tsize = dc.GetMultiLineTextExtent("?"); - auto pot = wxPoint(0, 0); - - if (m_obj && show_k_value) { - pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9)); - } - else { - pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 + FromDIP(3)); - } - dc.DrawText("?", pot); - - } - else { - auto tsize = dc.GetMultiLineTextExtent(m_info.material_name); - std::vector split_char_arr = { " ", "-" }; - bool has_split = false; - std::string has_split_char = " "; - - for (std::string split_char : split_char_arr) { - if (m_info.material_name.find(split_char) != std::string::npos) { - has_split = true; - has_split_char = split_char; - } - } - - - if (has_split) { - dc.SetFont(::Label::Body_12); - - auto line_top = m_info.material_name.substr(0, m_info.material_name.find(has_split_char)); - auto line_bottom = m_info.material_name.substr(m_info.material_name.find(has_split_char)); - - auto line_top_tsize = dc.GetMultiLineTextExtent(line_top); - auto line_bottom_tsize = dc.GetMultiLineTextExtent(line_bottom); - - if (!m_show_kn) { - auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2, (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y + FromDIP(6)); - dc.DrawText(line_top, pot_top); - - - auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2, (libsize.y - line_bottom_tsize.y) / 2 + FromDIP(4)); - dc.DrawText(line_bottom, pot_bottom); - } - else { - auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2, (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y - FromDIP(6)); - dc.DrawText(line_top, pot_top); - - auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2, (libsize.y - line_bottom_tsize.y) / 2 - FromDIP(8)); - dc.DrawText(line_bottom, pot_bottom); - } - - - } - else { - auto pot = wxPoint(0, 0); - if (m_obj && show_k_value) { - pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9)); - } else { - pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 + FromDIP(3)); - } - dc.DrawText(m_info.material_name, pot); - } - } - - //draw k&n - if (m_obj && show_k_value) { - if (m_show_kn) { - wxString str_k = wxString::Format("K %1.3f", m_info.k); - wxString str_n = wxString::Format("N %1.3f", m_info.n); - dc.SetFont(::Label::Body_11); - auto tsize = dc.GetMultiLineTextExtent(str_k); - auto pot_k = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9) + tsize.y); - dc.DrawText(str_k, pot_k); - } - } - } - - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_EMPTY) { - auto tsize = dc.GetMultiLineTextExtent(_L("Empty")); - auto pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 + FromDIP(3)); - dc.DrawText(_L("Empty"), pot); - } -} - -void AMSLib::doRender(wxDC &dc) -{ - if (m_ams_model == AMSModel::GENERIC_AMS) { - render_generic_lib(dc); - } - else if (m_ams_model == AMSModel::EXTRA_AMS) { - render_extra_lib(dc); - } -} - -void AMSLib::render_extra_lib(wxDC& dc) -{ - wxSize size = GetSize(); - - ScalableBitmap tray_bitmap = m_can_index <= 1 ? m_bitmap_extra_tray_left : m_bitmap_extra_tray_right; - ScalableBitmap tray_bitmap_hover = m_can_index <= 1 ? m_bitmap_extra_tray_left_hover : m_bitmap_extra_tray_right_hover; - ScalableBitmap tray_bitmap_selected = m_can_index <= 1 ? m_bitmap_extra_tray_left_selected : m_bitmap_extra_tray_right_selected; - - - auto tmp_lib_colour = m_info.material_colour; - change_the_opacity(tmp_lib_colour); - - auto temp_bitmap_third = m_bitmap_editable_light; - auto temp_bitmap_brand = m_bitmap_readonly_light; - - //draw road - - - dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - - if (m_pass_road) { - dc.SetPen(wxPen(m_info.material_colour, 6, wxPENSTYLE_SOLID)); - } - - if (m_can_index == 0 || m_can_index == 3) { - dc.DrawLine(size.x / 2, size.y / 2, size.x / 2, size.y); - } - else { - dc.DrawLine(size.x / 2, size.y / 2, size.x / 2, 0); - } - - - //draw def background - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(AMS_CONTROL_DEF_LIB_BK_COLOUR)); - dc.DrawRoundedRectangle(FromDIP(10), FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20), 0); - - if (tmp_lib_colour.GetLuminance() < 0.6) { - temp_bitmap_third = m_bitmap_editable_light; - temp_bitmap_brand = m_bitmap_readonly_light; - } - else { - temp_bitmap_third = m_bitmap_editable; - temp_bitmap_brand = m_bitmap_readonly; - } - - if (m_info.material_remain < 50) { - temp_bitmap_third = m_bitmap_editable; - temp_bitmap_brand = m_bitmap_readonly; - } - - if (tmp_lib_colour.Alpha() == 0) { - temp_bitmap_third = m_bitmap_editable; - temp_bitmap_brand = m_bitmap_readonly; - } - - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - if (m_info.material_cols.size() > 1) { - int left = FromDIP(10); - int gwidth = std::round(size.x / (m_info.material_cols.size() - 1)); - //gradient - if (m_info.ctype == 0) { - for (int i = 0; i < m_info.material_cols.size() - 1; i++) { - auto rect = wxRect(left, FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20)); - dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i + 1], wxEAST); - left += gwidth; - } - } - else { - int cols_size = m_info.material_cols.size(); - for (int i = 0; i < cols_size; i++) { - dc.SetBrush(wxBrush(m_info.material_cols[i])); - float x = FromDIP(10) + ((float)size.x - FromDIP(20)) * i / cols_size; - dc.DrawRoundedRectangle(x, FromDIP(10), ((float)size.x - FromDIP(20)) / cols_size, size.y - FromDIP(20), 0); - } - dc.SetBrush(wxBrush(tmp_lib_colour)); - } - } - else { - dc.SetBrush(wxBrush(tmp_lib_colour)); - dc.DrawRoundedRectangle(FromDIP(10), FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20), 0); - } - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(tmp_lib_colour)); - if (!m_disable_mode) { - // edit icon - if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE) - { - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) - dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y)); - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND) - dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetBmpSize().y)); - } - } - - // selected & hover - if (m_selected) { - dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2); - } - else if (!m_selected && m_hover) { - dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2); - } - else { - dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2); - } -} - - -void AMSLib::render_generic_lib(wxDC &dc) -{ - wxSize size = GetSize(); - auto tmp_lib_colour = m_info.material_colour; - change_the_opacity(tmp_lib_colour); - - auto temp_bitmap_third = m_bitmap_editable_light; - auto temp_bitmap_brand = m_bitmap_readonly_light; - - //draw def background - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(AMS_CONTROL_DEF_LIB_BK_COLOUR)); - dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4), size.x - FromDIP(8), size.y - FromDIP(8), m_radius); - - if (tmp_lib_colour.GetLuminance() < 0.6) { - temp_bitmap_third = m_bitmap_editable_light; - temp_bitmap_brand = m_bitmap_readonly_light; - } - else { - temp_bitmap_third = m_bitmap_editable; - temp_bitmap_brand = m_bitmap_readonly; - } - - if (m_info.material_remain < 50) { - temp_bitmap_third = m_bitmap_editable; - temp_bitmap_brand = m_bitmap_readonly; - } - - if (tmp_lib_colour.Alpha() == 0) { - temp_bitmap_third = m_bitmap_editable; - temp_bitmap_brand = m_bitmap_readonly; - } - - // selected - if (m_selected) { - dc.SetPen(wxPen(tmp_lib_colour, 2, wxPENSTYLE_SOLID)); - if (tmp_lib_colour.Alpha() == 0) { - dc.SetPen(wxPen(wxColour(tmp_lib_colour.Red(), tmp_lib_colour.Green(),tmp_lib_colour.Blue(),128), 2, wxPENSTYLE_SOLID)); - } - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - if (m_radius == 0) { - dc.DrawRectangle(0, 0, size.x, size.y); - } - else { - dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(1), size.y - FromDIP(1), m_radius); - } - - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(tmp_lib_colour)); - } - - if (!m_selected && m_hover) { - dc.SetPen(wxPen(AMS_CONTROL_BRAND_COLOUR, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - if (m_radius == 0) { - dc.DrawRectangle(0, 0, size.x, size.y); - } - else { - dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(1), size.y - FromDIP(1), m_radius); - } - - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(tmp_lib_colour)); - } - else { - dc.SetPen(wxPen(tmp_lib_colour, 1, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(tmp_lib_colour)); - } - - //draw remain - auto alpha = m_info.material_colour.Alpha(); - int height = size.y - FromDIP(8); - int curr_height = height * float(m_info.material_remain * 1.0 / 100.0); - dc.SetFont(::Label::Body_13); - - int top = height - curr_height; - - if (curr_height >= FromDIP(6)) { - - //transparent - - if (alpha == 0) { - dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4)); - } - else if (alpha != 255 && alpha != 254) { - if (transparent_changed) { - std::string rgb = (tmp_lib_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString(); - if (rgb.size() == 9) { - //delete alpha value - rgb = rgb.substr(0, rgb.size() - 2); - } - float alpha_f = 0.7 * tmp_lib_colour.Alpha() / 255.0; - std::vector replace; - replace.push_back(rgb); - std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f); - replace.push_back(fill_replace); - m_bitmap_transparent = ScalableBitmap(this, "transparent_ams_lib", 68, false, false, true, replace); - transparent_changed = false; - - } - dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4)); - } - //gradient - if (m_info.material_cols.size() > 1) { - int left = FromDIP(4); - float total_width = size.x - FromDIP(8); - int gwidth = std::round(total_width / (m_info.material_cols.size() - 1)); - //gradient - if (m_info.ctype == 0) { - for (int i = 0; i < m_info.material_cols.size() - 1; i++) { - - if ((left + gwidth) > (size.x - FromDIP(8))) { - gwidth = (size.x - FromDIP(4)) - left; - } - - auto rect = wxRect(left, height - curr_height + FromDIP(4), gwidth, curr_height); - dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i + 1], wxEAST); - left += gwidth; - } - } - else { - //multicolour - gwidth = std::round(total_width / m_info.material_cols.size()); - for (int i = 0; i < m_info.material_cols.size(); i++) { - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(m_info.material_cols[i])); - if (i == 0 || i == m_info.material_cols.size() - 1) { -#ifdef __APPLE__ - dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height, m_radius); -#else - dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height, m_radius - 1); -#endif - //add rectangle - int dr_gwidth = std::round(gwidth * 0.6); - if (i == 0) { - dc.DrawRectangle(left + gwidth - dr_gwidth, height - curr_height + FromDIP(4), dr_gwidth, curr_height); - } - else { - dc.DrawRectangle(left + gwidth*i, height - curr_height + FromDIP(4), dr_gwidth, curr_height); - } - } - else { - dc.DrawRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height); - } - } - //reset pen and brush - if (m_selected || m_hover) { - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - dc.SetBrush(wxBrush(tmp_lib_colour)); - } - else { - dc.SetPen(wxPen(tmp_lib_colour, 1, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(tmp_lib_colour)); - } - } - } - else { - auto brush = dc.GetBrush(); - if (alpha != 0 && alpha != 255 && alpha != 254) dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); -#ifdef __APPLE__ - dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius); -#else - dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius - 1); -#endif - dc.SetBrush(brush); - } - } - - if (top > 2) { - if (curr_height >= FromDIP(6)) { - dc.DrawRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), FromDIP(2)); - if (alpha != 255 && alpha != 254) { - dc.SetPen(wxPen(*wxWHITE)); - dc.SetBrush(wxBrush(*wxWHITE)); -#ifdef __APPLE__ - dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) , size.x - FromDIP(8), top, m_radius); -#else - dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) , size.x - FromDIP(8), top, m_radius - 1); -#endif - } - if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) { - dc.SetPen(wxPen(wxColour(130, 129, 128), 1, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - dc.DrawLine(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(4), FromDIP(4) + top); - } - } - else { - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) { - dc.SetPen(wxPen(wxColour(130, 129, 128), 2, wxPENSTYLE_SOLID)); - } - else { - dc.SetPen(wxPen(tmp_lib_colour, 2, wxPENSTYLE_SOLID)); - } - -#ifdef __APPLE__ - dc.DrawLine(FromDIP(5), FromDIP(4) + height - FromDIP(2), size.x - FromDIP(5), FromDIP(4) + height - FromDIP(2)); - dc.DrawLine(FromDIP(6), FromDIP(4) + height - FromDIP(1), size.x - FromDIP(6), FromDIP(4) + height - FromDIP(1)); -#else - dc.DrawLine(FromDIP(4), FromDIP(4) + height - FromDIP(2), size.x - FromDIP(4), FromDIP(4) + height - FromDIP(2)); - dc.DrawLine(FromDIP(5), FromDIP(4) + height - FromDIP(1), size.x - FromDIP(5), FromDIP(4) + height - FromDIP(1)); -#endif - } - } - - //border - dc.SetPen(wxPen(wxColour(130, 130, 128), 1, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); -#ifdef __APPLE__ - dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4), size.x - FromDIP(7), size.y - FromDIP(7), m_radius); -#else - dc.DrawRoundedRectangle(FromDIP(3), FromDIP(3), size.x - FromDIP(6), size.y - FromDIP(6), m_radius); -#endif - - if (!m_disable_mode) { - // edit icon - if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE) - { - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) - dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y)); - if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND) - dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y)); - } - } -} - -void AMSLib::on_pass_road(bool pass) -{ - if (m_pass_road != pass) { - m_pass_road = pass; - Refresh(); - } -} - -void AMSLib::Update(Caninfo info, bool refresh) -{ - DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (!dev) return; - if (dev->get_selected_machine() && dev->get_selected_machine() != m_obj) { - m_obj = dev->get_selected_machine(); - } - if (info.material_colour.Alpha() != 0 && info.material_colour.Alpha() != 255 && info.material_colour.Alpha() != 254 && m_info.material_colour != info.material_colour) { - transparent_changed = true; - } - m_info = info; - Layout(); - if (refresh) Refresh(); -} - -wxColour AMSLib::GetLibColour() { return m_info.material_colour; } - -void AMSLib::OnSelected() -{ - if (!wxWindow::IsEnabled()) return; - if (m_unable_selected) return; - - post_event(wxCommandEvent(EVT_AMS_ON_SELECTED)); - m_selected = true; - Refresh(); -} - -void AMSLib::post_event(wxCommandEvent &&event) -{ - event.SetString(m_info.can_id); - event.SetEventObject(m_parent); - wxPostEvent(m_parent, event); - event.Skip(); -} - -void AMSLib::UnSelected() -{ - m_selected = false; - Refresh(); -} - -bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); } - -void AMSLib::msw_rescale() -{ - m_bitmap_transparent.msw_rescale(); -} - -/************************************************* -Description:AMSRoad -**************************************************/ -AMSRoad::AMSRoad() : m_road_def_color(AMS_CONTROL_GRAY500), m_road_color(AMS_CONTROL_GRAY500) {} -AMSRoad::AMSRoad(wxWindow *parent, wxWindowID id, Caninfo info, int canindex, int maxcan, const wxPoint &pos, const wxSize &size) - : AMSRoad() -{ - m_info = info; - m_canindex = canindex; - // road type - auto mode = AMSRoadMode::AMS_ROAD_MODE_END; - if (m_canindex == 0 && maxcan == 1) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_NONE; - } else if (m_canindex == 0 && maxcan > 1) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_END; - } else if (m_canindex < (maxcan - 1)) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT; - } else if (m_canindex == (maxcan - 1)) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT; - } else if (m_canindex == -1 && maxcan == -1) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY; - } - else { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_NONE_ANY_ROAD; - } - - for (int i = 1; i <= 5; i++) { - ams_humidity_img.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_light", 32)); - } - - for (int i = 1; i <= 5; i++) { - ams_humidity_img.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_dark", 32)); - } - if (m_rode_mode != AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY) { - create(parent, id, pos, size); - } - else { - wxSize virtual_size(size.x - 1, size.y + 2); - create(parent, id, pos, virtual_size); - - } - - Bind(wxEVT_PAINT, &AMSRoad::paintEvent, this); - wxWindow::SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); - - Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& e) { - if (m_canindex == 3 && m_show_humidity) { - auto mouse_pos = ClientToScreen(e.GetPosition()); - auto rect = ClientToScreen(wxPoint(0, 0)); - - if (mouse_pos.x > rect.x + GetSize().x - FromDIP(40) && - mouse_pos.y > rect.y + GetSize().y - FromDIP(40)) { - wxCommandEvent show_event(EVT_AMS_SHOW_HUMIDITY_TIPS); - wxPostEvent(GetParent()->GetParent(), show_event); - -#ifdef __WXMSW__ - wxCommandEvent close_event(EVT_CLEAR_SPEED_CONTROL); - wxPostEvent(GetParent()->GetParent(), close_event); -#endif // __WXMSW__ - - } - } - }); -} - -void AMSRoad::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) { wxWindow::Create(parent, id, pos, size); } - -void AMSRoad::Update(AMSinfo amsinfo, Caninfo info, int canindex, int maxcan) -{ - m_amsinfo = amsinfo; - m_info = info; - m_canindex = canindex; - if (m_canindex == 0 && maxcan == 1) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_END_ONLY; - } else if (m_canindex == 0 && maxcan > 1) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_END; - } else if (m_canindex < (maxcan - 1)) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT; - } else if (m_canindex == (maxcan - 1)) { - m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT; - } - m_pass_rode_mode.push_back(AMSPassRoadMode::AMS_ROAD_MODE_NONE); - Refresh(); -} - -void AMSRoad::OnVamsLoading(bool load, wxColour col /*= AMS_CONTROL_GRAY500*/) -{ - m_vams_loading = load; - if(load)m_road_color = col; - Refresh(); -} - -void AMSRoad::SetPassRoadColour(wxColour col) { m_road_color = col; } - -void AMSRoad::SetMode(AMSRoadMode mode) -{ - m_rode_mode = mode; - Refresh(); -} - -void AMSRoad::paintEvent(wxPaintEvent &evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSRoad::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 AMSRoad::doRender(wxDC &dc) -{ - wxSize size = GetSize(); - - dc.SetPen(wxPen(m_road_def_color, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - // left mode - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT) { dc.DrawRoundedRectangle(-10, -10, size.x / 2 + 10, size.y * 0.6 + 10, 4); } - - // left right mode - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT) { - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - dc.DrawLine(0, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); - } - - // end mode - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END) { - dc.SetBrush(wxBrush(m_road_def_color)); - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); - dc.DrawLine(size.x / 2, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); - } - - // end mode only - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END_ONLY) { - dc.SetBrush(wxBrush(m_road_def_color)); - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); - } - - // end none - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_NONE) { - dc.SetBrush(wxBrush(m_road_def_color)); - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); - dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); - // dc.DrawLine(size.x / 2, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); - } - - //virtual road - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY) { - dc.SetBrush(wxBrush(m_road_def_color)); - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y - 1); - } - - // mode none - // if (m_pass_rode_mode.size() == 1 && m_pass_rode_mode[0] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) return; - - if (m_road_color.Alpha() == 0) {dc.SetPen(wxPen(*wxWHITE, m_passroad_width, wxPENSTYLE_SOLID));} - else {dc.SetPen(wxPen(m_road_color, m_passroad_width, wxPENSTYLE_SOLID));} - - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - - // left pass mode - for (auto pass_mode : m_pass_rode_mode) { - switch (pass_mode) { - case AMSPassRoadMode::AMS_ROAD_MODE_LEFT: dc.DrawRoundedRectangle(-10, -10, size.x / 2 + 10, size.y * 0.6 + 10, 4); break; - - case AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT: dc.DrawLine(0, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); break; - - case AMSPassRoadMode::AMS_ROAD_MODE_END_TOP: dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); break; - - case AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM: dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); break; - - case AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT: dc.DrawLine(size.x / 2, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); break; - - default: break; - } - } - - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY && m_vams_loading) { - dc.DrawLine(size.x / 2, -1, size.x / 2, size.y - 1); - } - - // end mode - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END || m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END_ONLY) { - dc.SetPen(wxPen(m_road_def_color, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(m_road_def_color)); - dc.DrawRoundedRectangle(size.x * 0.37 / 2, size.y * 0.6 - size.y / 6, size.x * 0.63, size.y / 3, m_radius); - } - - if (m_canindex == 3) { - - if (m_amsinfo.ams_humidity >= 1 && m_amsinfo.ams_humidity <= 5) {m_show_humidity = true;} - else {m_show_humidity = false;} - - if (m_amsinfo.ams_humidity >= 1 && m_amsinfo.ams_humidity <= 5) { - - int hum_index = m_amsinfo.ams_humidity - 1; - if (wxGetApp().dark_mode()) { - hum_index += 5; - } - - if (hum_index >= 0) { - dc.DrawBitmap(ams_humidity_img[hum_index].bmp(), wxPoint(size.x - FromDIP(33), size.y - FromDIP(33))); - } - } - else { - //to do ... - } - } -} - -void AMSRoad::UpdatePassRoad(int tag_index, AMSPassRoadType type, AMSPassRoadSTEP step) {} - -void AMSRoad::OnPassRoad(std::vector prord_list) -{ - // AMS_ROAD_MODE_NONE, AMS_ROAD_MODE_LEFT, AMS_ROAD_MODE_LEFT_RIGHT, AMS_ROAD_MODE_END_TOP, AMS_ROAD_MODE_END_BOTTOM, AMS_ROAD_MODE_END_RIGHT, - // AMS_ROAD_MODE_LEFT, AMS_ROAD_MODE_LEFT_RIGHT, AMS_ROAD_MODE_END, - - m_pass_rode_mode.clear(); - auto left_types = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE, AMSPassRoadMode::AMS_ROAD_MODE_LEFT}; - auto left_right_types = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE, AMSPassRoadMode::AMS_ROAD_MODE_LEFT, AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT}; - auto end_types = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE, AMSPassRoadMode::AMS_ROAD_MODE_END_TOP, AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM, - AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT}; - - // left - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT) { - for (auto i = 0; i < prord_list.size(); i++) { - std::vector::iterator iter = std::find(left_types.begin(), left_types.end(), prord_list[i]); - if (iter != left_types.end()) m_pass_rode_mode.push_back(prord_list[i]); - - if (prord_list[i] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) { - m_pass_rode_mode = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE}; - break; - } - } - } - - // left right - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT) { - for (auto i = 0; i < prord_list.size(); i++) { - std::vector::iterator iter = std::find(left_right_types.begin(), left_right_types.end(), prord_list[i]); - if (iter != left_right_types.end()) m_pass_rode_mode.push_back(prord_list[i]); - - if (prord_list[i] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) { - m_pass_rode_mode = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE}; - break; - } - } - } - - // left end - if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END || m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END_ONLY) { - for (auto i = 0; i < prord_list.size(); i++) { - std::vector::iterator iter = std::find(end_types.begin(), end_types.end(), prord_list[i]); - if (iter != end_types.end()) m_pass_rode_mode.push_back(prord_list[i]); - - if (prord_list[i] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) { - m_pass_rode_mode = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE}; - break; - } - } - } -} - -/************************************************* -Description:AMSControl -**************************************************/ -AMSItem::AMSItem() {} - -AMSItem::AMSItem(wxWindow *parent, wxWindowID id, AMSinfo amsinfo, const wxSize cube_size, const wxPoint &pos, const wxSize &size) : AMSItem() -{ - m_amsinfo = amsinfo; - m_cube_size = cube_size; - create(parent, id, pos, AMS_ITEM_SIZE); - Bind(wxEVT_PAINT, &AMSItem::paintEvent, this); - Bind(wxEVT_ENTER_WINDOW, &AMSItem::OnEnterWindow, this); - Bind(wxEVT_LEAVE_WINDOW, &AMSItem::OnLeaveWindow, this); -} - -void AMSItem::Open() -{ - m_open = true; - Show(); -} - -void AMSItem::Close() -{ - m_open = false; - Hide(); -} - -void AMSItem::Update(AMSinfo amsinfo) -{ - m_amsinfo = amsinfo; -} - -void AMSItem::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) -{ - m_ts_bitmap_cube = new ScalableBitmap(this, "ts_bitmap_cube", 14); - wxWindow::Create(parent, id, pos, size); - SetMinSize(AMS_ITEM_SIZE); - SetMaxSize(AMS_ITEM_SIZE); - SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR); - Refresh(); -} - -void AMSItem::OnEnterWindow(wxMouseEvent &evt) -{ - // m_hover = true; - // Refresh(); -} - -void AMSItem::OnLeaveWindow(wxMouseEvent &evt) -{ - // m_hover = false; - // Refresh(); -} - -void AMSItem::OnSelected() -{ - if (!wxWindow::IsEnabled()) { return; } - m_selected = true; - Refresh(); -} - -void AMSItem::UnSelected() -{ - m_selected = false; - Refresh(); -} - -bool AMSItem::Enable(bool enable) { return wxWindow::Enable(enable); } - -void AMSItem::paintEvent(wxPaintEvent &evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSItem::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 AMSItem::doRender(wxDC &dc) -{ - wxSize size = GetSize(); - dc.SetPen(wxPen(StateColor::darkModeColorFor(m_background_colour))); - dc.SetBrush(wxBrush(StateColor::darkModeColorFor(m_background_colour))); - dc.DrawRoundedRectangle(0, 0, size.x, size.y, 3); - - auto left = m_padding; - for (std::vector::iterator iter = m_amsinfo.cans.begin(); iter != m_amsinfo.cans.end(); iter++) { - dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); - - if (wxWindow::IsEnabled()) { - wxColour color = iter->material_colour; - change_the_opacity(color); - dc.SetBrush(wxBrush(color)); - } else { - dc.SetBrush(AMS_CONTROL_DISABLE_COLOUR); - } - - if (iter->material_cols.size() > 1) { - int fleft = left; - float total_width = AMS_ITEM_CUBE_SIZE.x; - int gwidth = std::round(total_width / (iter->material_cols.size() - 1)); - if (iter->ctype == 0) { - for (int i = 0; i < iter->material_cols.size() - 1; i++) { - - if ((fleft + gwidth) > (AMS_ITEM_CUBE_SIZE.x)) { - gwidth = (fleft + AMS_ITEM_CUBE_SIZE.x) - fleft; - } - - auto rect = wxRect(fleft, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, gwidth, AMS_ITEM_CUBE_SIZE.y); - dc.GradientFillLinear(rect, iter->material_cols[i], iter->material_cols[i + 1], wxEAST); - fleft += gwidth; - } - } else { - int cols_size = iter->material_cols.size(); - for (int i = 0; i < cols_size; i++) { - dc.SetBrush(wxBrush(iter->material_cols[i])); - float x = left + total_width * i / cols_size; - dc.DrawRoundedRectangle(x, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, total_width / cols_size, AMS_ITEM_CUBE_SIZE.y , 0); - } - } - - dc.SetPen(wxPen(StateColor::darkModeColorFor(m_background_colour))); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRoundedRectangle(left - 1, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2 - 1, AMS_ITEM_CUBE_SIZE.x + 2, AMS_ITEM_CUBE_SIZE.y + 2, 2); - - }else { - if (iter->material_colour.Alpha() == 0) { - dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2); - } - else { - wxRect rect(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y); - if(iter->material_state==AMSCanType::AMS_CAN_TYPE_EMPTY){ - dc.SetPen(wxPen(wxColor(0, 0, 0))); - dc.DrawRoundedRectangle(rect, 2); - - dc.DrawLine(rect.GetRight()-1, rect.GetTop()+1, rect.GetLeft()+1, rect.GetBottom()-1); - } - else { - dc.DrawRoundedRectangle(rect, 2); - } - } - - } - - - left += AMS_ITEM_CUBE_SIZE.x; - left += m_space; - } - - auto border_colour = AMS_CONTROL_BRAND_COLOUR; - if (!wxWindow::IsEnabled()) { border_colour = AMS_CONTROL_DISABLE_COLOUR; } - - if (m_hover) { - dc.SetPen(wxPen(border_colour, 2)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - dc.DrawRoundedRectangle(1, 1, size.x - 1, size.y - 1, 3); - - } - - if (m_selected) { - dc.SetPen(wxPen(border_colour, 2)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - dc.DrawRoundedRectangle(1, 1, size.x-1, size.y-1, 3); - } -} - -void AMSItem::DoSetSize(int x, int y, int width, int height, int sizeFlags /*= wxSIZE_AUTO*/) { wxWindow::DoSetSize(x, y, width, height, sizeFlags); } - -/************************************************* -Description:AmsCan -**************************************************/ - -AmsCans::AmsCans() {} - -AmsCans::AmsCans(wxWindow *parent,AMSinfo info, AMSModel model) : AmsCans() -{ - m_bitmap_extra_framework = ScalableBitmap(this, "ams_extra_framework_mid", 140); - - SetDoubleBuffered(true); - m_ams_model = model; - m_info = info; - - wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE); - create(parent); - Bind(wxEVT_PAINT, &AmsCans::paintEvent, this); -} - -void AmsCans::create(wxWindow *parent) -{ - Freeze(); - SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); - - if (m_ams_model == AMSModel::GENERIC_AMS) { - sizer_can = new wxBoxSizer(wxHORIZONTAL); - for (auto it = m_info.cans.begin(); it != m_info.cans.end(); it++) { - AddCan(*it, m_can_count, m_info.cans.size(), sizer_can); - m_can_count++; - } - SetSizer(sizer_can); - } - else if(m_ams_model == AMSModel::EXTRA_AMS) { - sizer_can = new wxBoxSizer(wxVERTICAL); - sizer_can_middle = new wxBoxSizer(wxHORIZONTAL); - sizer_can_left = new wxBoxSizer(wxVERTICAL); - sizer_can_right = new wxBoxSizer(wxVERTICAL); - - sizer_can_left->Add(0,0,0,wxTOP,FromDIP(8)); - - for (auto it = m_info.cans.begin(); it != m_info.cans.end(); it++) { - if (m_can_count <= 1) { - AddCan(*it, m_can_count, m_info.cans.size(), sizer_can_left); - if (m_can_count == 0) { - sizer_can_left->Add(0,0,0,wxTOP,FromDIP(20)); - } - } - else { - AddCan(*it, m_can_count, m_info.cans.size(), sizer_can_right); - if (m_can_count == 2) { - sizer_can_right->Prepend(0, 0, 0, wxTOP, FromDIP(20)); - } - } - - m_can_count++; - } - - sizer_can_right->Prepend(0,0,0,wxTOP,FromDIP(8)); - sizer_can_middle->Add(0, 0, 0, wxLEFT, FromDIP(8)); - sizer_can_middle->Add(sizer_can_left, 0, wxALL, 0); - sizer_can_middle->Add( 0, 0, 0, wxLEFT, FromDIP(20) ); - sizer_can_middle->Add(sizer_can_right, 0, wxALL, 0); - sizer_can->Add(sizer_can_middle, 1, wxALIGN_CENTER, 0); - SetSizer(sizer_can); - } - - Layout(); - Fit(); - Thaw(); -} - -void AmsCans::AddCan(Caninfo caninfo, int canindex, int maxcan, wxBoxSizer* sizer) -{ - - auto amscan = new wxWindow(this, wxID_ANY); - amscan->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); - - wxBoxSizer* m_sizer_ams = new wxBoxSizer(wxVERTICAL); - - - auto m_panel_refresh = new AMSrefresh(amscan, m_can_count, caninfo); - auto m_panel_lib = new AMSLib(amscan, caninfo); - - m_panel_lib->Bind(wxEVT_LEFT_DOWN, [this, canindex](wxMouseEvent& ev) { - m_canlib_selection = canindex; - // m_canlib_id = caninfo.can_id; - - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs* lib = m_can_lib_list[i]; - if (lib->canLib->m_can_index == m_canlib_selection) { - wxCommandEvent evt(EVT_AMS_UNSELETED_VAMS); - evt.SetString(m_info.ams_id); - wxPostEvent(GetParent()->GetParent(), evt); - lib->canLib->OnSelected(); - } - else { - lib->canLib->UnSelected(); - } - } - ev.Skip(); - }); - - - m_panel_lib->m_ams_model = m_ams_model; - m_panel_lib->m_info.can_id = caninfo.can_id; - m_panel_lib->m_can_index = canindex; - - - auto m_panel_road = new AMSRoad(amscan, wxID_ANY, caninfo, canindex, maxcan, wxDefaultPosition, AMS_CAN_ROAD_SIZE); - - if (m_ams_model == AMSModel::GENERIC_AMS) { - m_sizer_ams->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14)); - m_sizer_ams->Add(m_panel_refresh, 0, wxALIGN_CENTER_HORIZONTAL, 0); - m_sizer_ams->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(2)); - m_sizer_ams->Add(m_panel_lib, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(3)); - m_sizer_ams->Add(m_panel_road, 0, wxALL, 0); - } - else if (m_ams_model == AMSModel::EXTRA_AMS) - { - m_sizer_ams = new wxBoxSizer(wxHORIZONTAL); - m_panel_road->Hide(); - - if (canindex <= 1) { - m_sizer_ams->Add(m_panel_refresh, 0, wxALIGN_CENTER, 0); - m_sizer_ams->Add(m_panel_lib, 0, wxALIGN_CENTER, 0); - } - else { - m_sizer_ams->Add(m_panel_lib, 0, wxALIGN_CENTER, 0); - m_sizer_ams->Add(m_panel_refresh, 0, wxALIGN_CENTER, 0); - } - } - - - amscan->SetSizer(m_sizer_ams); - amscan->Layout(); - amscan->Fit(); - - if (m_ams_model == AMSModel::GENERIC_AMS) { - sizer->Add(amscan, 0, wxALL, 0); - } - else if (m_ams_model == AMSModel::EXTRA_AMS) - { - if (canindex > 1) { - sizer->Prepend(amscan, 0, wxALL, 0); - } - else { - sizer->Add(amscan, 0, wxALL, 0); - } - } - - Canrefreshs* canrefresh = new Canrefreshs; - canrefresh->canID = caninfo.can_id; - canrefresh->canrefresh = m_panel_refresh; - m_can_refresh_list.Add(canrefresh); - - CanLibs* canlib = new CanLibs; - canlib->canID = caninfo.can_id; - canlib->canLib = m_panel_lib; - m_can_lib_list.Add(canlib); - - CanRoads* canroad = new CanRoads; - canroad->canID = caninfo.can_id; - canroad->canRoad = m_panel_road; - m_can_road_list.Add(canroad); -} - -void AmsCans::Update(AMSinfo info) -{ - m_info = info; - m_can_count = info.cans.size(); - - for (auto i = 0; i < m_can_refresh_list.GetCount(); i++) { - Canrefreshs *refresh = m_can_refresh_list[i]; - if (i < m_can_count) { - refresh->canrefresh->Update(info.ams_id, info.cans[i]); - refresh->canrefresh->Show(); - } else { - refresh->canrefresh->Hide(); - } - } - - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs *lib = m_can_lib_list[i]; - if (i < m_can_count) { - lib->canLib->Update(info.cans[i]); - lib->canLib->Show(); - } else { - lib->canLib->Hide(); - } - } - - if (m_ams_model == AMSModel::GENERIC_AMS) { - for (auto i = 0; i < m_can_road_list.GetCount(); i++) { - CanRoads* road = m_can_road_list[i]; - if (i < m_can_count) { - road->canRoad->Update(m_info, info.cans[i], i, m_can_count); - road->canRoad->Show(); - } - else { - road->canRoad->Hide(); - } - } - } - Layout(); -} - -void AmsCans::SetDefSelectCan() -{ - if (m_can_lib_list.GetCount() > 0) { - CanLibs* lib = m_can_lib_list[0]; - m_canlib_selection =lib->canLib->m_can_index; - m_canlib_id = lib->canLib->m_info.can_id; - SelectCan(m_canlib_id); - } -} - - -void AmsCans::SelectCan(std::string canid) -{ - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs *lib = m_can_lib_list[i]; - if (lib->canLib->m_info.can_id == canid) { - m_canlib_selection = lib->canLib->m_can_index; - } - } - - m_canlib_id = canid; - - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs *lib = m_can_lib_list[i]; - if (lib->canLib->m_info.can_id == m_canlib_id) { - wxCommandEvent evt(EVT_AMS_UNSELETED_VAMS); - evt.SetString(m_info.ams_id); - wxPostEvent(GetParent()->GetParent(), evt); - lib->canLib->OnSelected(); - } else { - lib->canLib->UnSelected(); - } - } -} - -wxColour AmsCans::GetTagColr(wxString canid) -{ - auto tag_colour = *wxWHITE; - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs* lib = m_can_lib_list[i]; - if (canid == lib->canLib->m_info.can_id) tag_colour = lib->canLib->GetLibColour(); - } - return tag_colour; -} - -void AmsCans::SetAmsStepExtra(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step) -{ - if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP1) { - SetAmsStep(canid.ToStdString()); - }else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP2) { - SetAmsStep(canid.ToStdString()); - }else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP3) { - SetAmsStep(canid.ToStdString()); - }else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) { - SetAmsStep(""); - } -} - -void AmsCans::SetAmsStep(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step) -{ - - if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) { - for (auto i = 0; i < m_can_road_list.GetCount(); i++) { - CanRoads *road = m_can_road_list[i]; - auto pr = std::vector{}; - pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_NONE); - road->canRoad->OnPassRoad(pr); - } - - return; - } - - - auto tag_can_index = -1; - for (auto i = 0; i < m_can_road_list.GetCount(); i++) { - CanRoads *road = m_can_road_list[i]; - if (canid == road->canRoad->m_info.can_id) { tag_can_index = road->canRoad->m_canindex; } - } - if (tag_can_index == -1) return; - - // get colour - auto tag_colour = *wxWHITE; - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs *lib = m_can_lib_list[i]; - if (canid == lib->canLib->m_info.can_id) tag_colour = lib->canLib->GetLibColour(); - } - - // unload - if (type == AMSPassRoadType::AMS_ROAD_TYPE_UNLOAD) { - for (auto i = 0; i < m_can_road_list.GetCount(); i++) { - CanRoads *road = m_can_road_list[i]; - - auto index = road->canRoad->m_canindex; - auto pr = std::vector{}; - - pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM); - if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_2) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM); } - - if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_3) { - if (index == tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT); } - if (index < tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT); } - if (index == 0 && tag_can_index == index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_TOP); } - if (index == 0 && tag_can_index > index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT); } - } - - road->canRoad->SetPassRoadColour(tag_colour); - road->canRoad->OnPassRoad(pr); - } - } - - // load - if (type == AMSPassRoadType::AMS_ROAD_TYPE_LOAD) { - for (auto i = 0; i < m_can_road_list.GetCount(); i++) { - CanRoads *road = m_can_road_list[i]; - - auto index = road->canRoad->m_canindex; - auto pr = std::vector{}; - - if (index == tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT); } - if (index < tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT); } - if (index == 0 && tag_can_index == index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_TOP); } - if (index == 0 && tag_can_index > index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT); } - - if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_2) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM); } - - road->canRoad->SetPassRoadColour(tag_colour); - road->canRoad->OnPassRoad(pr); - } - } -} - -void AmsCans::SetAmsStep(std::string can_id) -{ - if (m_road_canid != can_id) { - m_road_canid = can_id; - Refresh(); - } -} - -void AmsCans::PlayRridLoading(wxString canid) -{ - for (auto i = 0; i < m_can_refresh_list.GetCount(); i++) { - Canrefreshs *refresh = m_can_refresh_list[i]; - if (refresh->canrefresh->m_info.can_id == canid) { refresh->canrefresh->PlayLoading(); } - } -} - -std::string AmsCans::GetCurrentCan() -{ - if (m_canlib_selection < 0) - return ""; - - return wxString::Format("%d", m_canlib_selection).ToStdString(); -} - -void AmsCans::paintEvent(wxPaintEvent& evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AmsCans::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 AmsCans::doRender(wxDC& dc) -{ - wxSize size = GetSize(); - dc.DrawBitmap(m_bitmap_extra_framework.bmp(), (size.x - m_bitmap_extra_framework.GetBmpSize().x) / 2, (size.y - m_bitmap_extra_framework.GetBmpSize().y) / 2); - - //road for extra - if (m_ams_model == AMSModel::EXTRA_AMS) { - - auto end_top = size.x / 2 - FromDIP(99); - auto passroad_width = 6; - - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs* lib = m_can_lib_list[i]; +#include "slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h" - if (m_road_canid.empty()) { - lib->canLib->on_pass_road(false); - } - else { - if (lib->canLib->m_info.can_id == m_road_canid) { - m_road_colour = lib->canLib->m_info.material_colour; - lib->canLib->on_pass_road(true); - } - } - } - - - // A1 - dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - - try - { - auto a1_top = size.y / 2 - FromDIP(4); - auto a1_left = m_can_lib_list[0]->canLib->GetScreenPosition().x + m_can_lib_list[0]->canLib->GetSize().x / 2; - auto local_pos1 = GetScreenPosition().x + GetSize().x / 2; - a1_left = size.x / 2 + (a1_left - local_pos1); - dc.DrawLine(a1_left, FromDIP(30), a1_left, a1_top); - dc.DrawLine(a1_left, a1_top, end_top, a1_top); - - - // A2 - auto a2_top = size.y / 2 + FromDIP(8); - auto a2_left = m_can_lib_list[1]->canLib->GetScreenPosition().x + m_can_lib_list[1]->canLib->GetSize().x / 2; - auto local_pos2 = GetScreenPosition().x + GetSize().x / 2; - a2_left = size.x / 2 + (a2_left - local_pos2); - dc.DrawLine(a2_left, FromDIP(160), a2_left, a2_top); - dc.DrawLine(a2_left, a2_top, end_top, a2_top); - - // A3 - auto a3_top = size.y / 2 + FromDIP(4); - auto a3_left = m_can_lib_list[2]->canLib->GetScreenPosition().x + m_can_lib_list[2]->canLib->GetSize().x / 2; - auto local_pos3 = GetScreenPosition().x + GetSize().x / 2; - a3_left = size.x / 2 + (a3_left - local_pos3); - dc.DrawLine(a3_left, FromDIP(160), a3_left, a3_top); - dc.DrawLine(a3_left, a3_top, end_top, a3_top); - - - // A4 - auto a4_top = size.y / 2; - auto a4_left = m_can_lib_list[3]->canLib->GetScreenPosition().x + m_can_lib_list[3]->canLib->GetSize().x / 2; - auto local_pos4 = GetScreenPosition().x + GetSize().x / 2; - a4_left = size.x / 2 + (a4_left - local_pos4); - dc.DrawLine(a4_left, FromDIP(30), a4_left, a4_top); - dc.DrawLine(a4_left, a4_top, end_top, a4_top); - - - if (!m_road_canid.empty()) { - if (m_road_canid == "0") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(a1_left, FromDIP(30), a1_left, a1_top); - dc.DrawLine(a1_left, a1_top, end_top, a1_top); - } - - if (m_road_canid == "1") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(a2_left, FromDIP(160), a2_left, a2_top); - dc.DrawLine(a2_left, a2_top, end_top, a2_top); - } - - if (m_road_canid == "2") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(a3_left, FromDIP(160), a3_left, a3_top); - dc.DrawLine(a3_left, a3_top, end_top, a3_top); - } - - if (m_road_canid == "3") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(a4_left, FromDIP(30), a4_left, a4_top); - dc.DrawLine(a4_left, a4_top, end_top, a4_top); - } - } - - //to Extruder - dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); - - dc.DrawLine(end_top, a1_top, end_top, size.y); - - if (!m_road_canid.empty()) { - if (!m_road_canid.empty()) { - if (m_road_canid == "0") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(end_top, a1_top, end_top, size.y); - } - else if (m_road_canid == "1") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(end_top, a2_top, end_top, size.y); - } - else if (m_road_canid == "2") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(end_top, a3_top, end_top, size.y); - } - else if (m_road_canid == "3") { - dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); - dc.DrawLine(end_top, a4_top, end_top, size.y); - } - } - } - } - catch (...){} - } -} +#include +#include -void AmsCans::StopRridLoading(wxString canid) -{ - for (auto i = 0; i < m_can_refresh_list.GetCount(); i++) { - Canrefreshs *refresh = m_can_refresh_list[i]; - if (refresh->canrefresh->m_info.can_id == canid) { refresh->canrefresh->StopLoading(); } - } -} +#include -void AmsCans::msw_rescale() -{ - for (auto i = 0; i < m_can_refresh_list.GetCount(); i++) { - Canrefreshs *refresh = m_can_refresh_list[i]; - refresh->canrefresh->msw_rescale(); - } +#include "CalibUtils.hpp" - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs* lib = m_can_lib_list[i]; - lib->canLib->msw_rescale(); - } -} +namespace Slic3r { namespace GUI { -void AmsCans::show_sn_value(bool show) -{ - for (auto i = 0; i < m_can_lib_list.GetCount(); i++) { - CanLibs* lib = m_can_lib_list[i]; - lib->canLib->show_kn_value(show); - } -} +#define AMS_CANS_SIZE wxSize(FromDIP(284), FromDIP(196)) +#define AMS_CANS_WINDOW_SIZE wxSize(FromDIP(264), FromDIP(196)) +#define IS_GENERIC_AMS(model) (model != AMSModel::AMS_LITE && model != AMSModel::EXT_AMS) -/************************************************* -Description:AMSControl -**************************************************/ -// WX_DEFINE_OBJARRAY(AmsItemsHash); -AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) : wxSimplebook(parent, wxID_ANY, pos, size) , m_Humidity_tip_popup(AmsHumidityTipPopup(this)) + , m_percent_humidity_dry_popup(new uiAmsPercentHumidityDryPopup(this)) , m_ams_introduce_popup(AmsIntroducePopup(this)) { SetBackgroundColour(*wxWHITE); @@ -2387,28 +34,28 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons m_amswin->SetBackgroundColour(*wxWHITE); // top - ams tag - m_simplebook_amsitems = new wxSimplebook(m_amswin, wxID_ANY); - m_simplebook_amsitems->SetSize(wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); - m_simplebook_amsitems->SetMinSize(wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); - auto m_sizer_amsitems = new wxBoxSizer(wxHORIZONTAL); - m_simplebook_amsitems->SetSizer(m_sizer_amsitems); - m_simplebook_amsitems->Layout(); - m_sizer_amsitems->Fit(m_simplebook_amsitems); + m_simplebook_amsprvs = new wxSimplebook(m_amswin, wxID_ANY); + m_simplebook_amsprvs->SetSize(wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); + m_simplebook_amsprvs->SetMinSize(wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); + auto m_sizer_amspreviews = new wxBoxSizer(wxHORIZONTAL); + m_simplebook_amsprvs->SetSizer(m_sizer_amspreviews); + m_simplebook_amsprvs->Layout(); + m_sizer_amspreviews->Fit(m_simplebook_amsprvs); - m_panel_top = new wxPanel(m_simplebook_amsitems, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); - m_sizer_top = new wxBoxSizer(wxHORIZONTAL); - m_panel_top->SetSizer(m_sizer_top); - m_panel_top->Layout(); - m_sizer_top->Fit(m_panel_top); + m_panel_prv = new wxPanel(m_simplebook_amsprvs, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); + m_sizer_prv = new wxBoxSizer(wxHORIZONTAL); + m_panel_prv->SetSizer(m_sizer_prv); + m_panel_prv->Layout(); + m_sizer_prv->Fit(m_panel_prv); - auto m_panel_top_empty = new wxPanel(m_simplebook_amsitems, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); + auto m_panel_top_empty = new wxPanel(m_simplebook_amsprvs, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE)); auto m_sizer_top_empty = new wxBoxSizer(wxHORIZONTAL); m_panel_top_empty->SetSizer(m_sizer_top_empty); m_panel_top_empty->Layout(); m_sizer_top_empty->Fit(m_panel_top_empty); - m_simplebook_amsitems->AddPage(m_panel_top_empty, wxEmptyString, false); - m_simplebook_amsitems->AddPage(m_panel_top, wxEmptyString, false); + m_simplebook_amsprvs->AddPage(m_panel_top_empty, wxEmptyString, false); + m_simplebook_amsprvs->AddPage(m_panel_prv, wxEmptyString, false); wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL); @@ -2468,21 +115,21 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons m_panel_can = new StaticBox(m_amswin, wxID_ANY, wxDefaultPosition, AMS_CANS_SIZE, wxBORDER_NONE); m_panel_can->SetMinSize(AMS_CANS_SIZE); m_panel_can->SetCornerRadius(FromDIP(10)); - m_panel_can->SetBackgroundColor(StateColor(std::pair(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, StateColor::Normal))); + m_panel_can->SetBackgroundColor(StateColor(std::pair(AMS_CONTROL_DEF_LIB_BK_COLOUR, StateColor::Normal))); m_sizer_cans = new wxBoxSizer(wxHORIZONTAL); m_simplebook_ams = new wxSimplebook(m_panel_can, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE, 0); - m_simplebook_ams->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); + m_simplebook_ams->SetBackgroundColour(AMS_CONTROL_DEF_LIB_BK_COLOUR); m_sizer_cans->Add(m_simplebook_ams, 0, wxLEFT | wxLEFT, FromDIP(10)); // ams mode - m_simplebook_generic_cans = new wxSimplebook(m_simplebook_ams, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE, 0); - m_simplebook_generic_cans->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); + m_simplebook_generic_ams = new wxSimplebook(m_simplebook_ams, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE, 0); + m_simplebook_generic_ams->SetBackgroundColour(AMS_CONTROL_DEF_LIB_BK_COLOUR); // none ams mode m_none_ams_panel = new wxPanel(m_simplebook_ams, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE, 0); - m_none_ams_panel->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); + m_none_ams_panel->SetBackgroundColour(AMS_CONTROL_DEF_LIB_BK_COLOUR); auto m_tip_none_ams = new wxStaticText(m_none_ams_panel, wxID_ANY, _L("AMS not connected"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); m_tip_none_ams->SetMinSize(wxSize(AMS_CANS_SIZE.x - FromDIP(20), -1)); @@ -2499,12 +146,12 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons m_none_ams_panel->Layout(); //extra ams mode - m_simplebook_extra_cans = new wxSimplebook(m_simplebook_ams, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE, 0); - m_simplebook_extra_cans->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); + m_simplebook_extra_ams = new wxSimplebook(m_simplebook_ams, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE, 0); + m_simplebook_extra_ams->SetBackgroundColour(AMS_CONTROL_DEF_LIB_BK_COLOUR); m_simplebook_ams->AddPage(m_none_ams_panel, wxEmptyString, false); - m_simplebook_ams->AddPage(m_simplebook_generic_cans, wxEmptyString, false); - m_simplebook_ams->AddPage(m_simplebook_extra_cans, wxEmptyString, false); + m_simplebook_ams->AddPage(m_simplebook_generic_ams, wxEmptyString, false); + m_simplebook_ams->AddPage(m_simplebook_extra_ams, wxEmptyString, false); m_panel_can->SetSizer(m_sizer_cans); m_panel_can->Layout(); @@ -2608,7 +255,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons //virtual ams m_panel_virtual = new StaticBox(m_amswin, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); - m_panel_virtual->SetBackgroundColor(StateColor(std::pair(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, StateColor::Normal))); + m_panel_virtual->SetBackgroundColor(StateColor(std::pair(AMS_CONTROL_DEF_LIB_BK_COLOUR, StateColor::Normal))); m_panel_virtual->SetMinSize(wxSize(AMS_CAN_LIB_SIZE.x + FromDIP(16), AMS_CANS_SIZE.y)); m_panel_virtual->SetMaxSize(wxSize(AMS_CAN_LIB_SIZE.x + FromDIP(16), AMS_CANS_SIZE.y)); @@ -2616,24 +263,25 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons m_vams_info.can_id = wxString::Format("%d", VIRTUAL_TRAY_ID).ToStdString(); auto vams_panel = new wxWindow(m_panel_virtual, wxID_ANY); - vams_panel->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR); + vams_panel->SetBackgroundColour(AMS_CONTROL_DEF_LIB_BK_COLOUR); - m_vams_lib = new AMSLib(vams_panel, m_vams_info); + m_vams_lib = new AMSLib(vams_panel, m_vams_info.can_id, m_vams_info); + m_vams_lib->m_slot_id = m_vams_info.can_id; m_vams_road = new AMSRoad(vams_panel, wxID_ANY, m_vams_info, -1, -1, wxDefaultPosition, AMS_CAN_ROAD_SIZE); - m_vams_lib->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { + m_vams_lib->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { //clear all selected m_current_ams = m_vams_info.can_id; m_vams_lib->OnSelected(); SwitchAms(m_current_ams); - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow* cans = m_ams_cans_list[i]; - cans->amsCans->SelectCan(m_current_ams); + for (auto ams_item : m_ams_item_list) { + AmsItem* item = ams_item.second; + item->SelectCan(m_current_ams); } e.Skip(); - }); + }); Bind(EVT_AMS_UNSELETED_VAMS, [this](wxCommandEvent& e) { /*if (m_current_ams == e.GetString().ToStdString()) { @@ -2808,7 +456,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons m_sizer_bottom->Add(0, 0, 0, wxLEFT, FromDIP(15)); m_sizer_bottom->Add(m_sizer_right, 0, wxEXPAND, FromDIP(0)); - m_sizer_body->Add(m_simplebook_amsitems, 0, wxEXPAND, 0); + m_sizer_body->Add(m_simplebook_amsprvs, 0, wxEXPAND, 0); m_sizer_body->Add(0, 0, 1, wxEXPAND | wxTOP, FromDIP(18)); m_sizer_body->Add(m_sizer_bottom, 0, wxEXPAND | wxLEFT, FromDIP(6)); @@ -2912,21 +560,33 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons }); Bind(EVT_AMS_SHOW_HUMIDITY_TIPS, [this](wxCommandEvent& evt) { - - wxPoint img_pos = ClientToScreen(wxPoint(0, 0)); - wxPoint popup_pos(img_pos.x - m_Humidity_tip_popup.GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80)); - m_Humidity_tip_popup.Position(popup_pos, wxSize(0, 0)); - if (m_ams_info.size() > 0) { - for (auto i = 0; i < m_ams_info.size(); i++) { - if (m_ams_info[i].ams_id == m_current_show_ams) { - m_Humidity_tip_popup.set_humidity_level(m_ams_info[i].ams_humidity); - } + uiAmsHumidityInfo *info = (uiAmsHumidityInfo *) evt.GetClientData(); + if (info) + { + if (info->humidity_percent >= 0) + { + m_percent_humidity_dry_popup->Update(info); + + wxPoint img_pos = ClientToScreen(wxPoint(0, 0)); + wxPoint popup_pos(img_pos.x - m_percent_humidity_dry_popup->GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80)); + m_percent_humidity_dry_popup->Position(popup_pos, wxSize(0, 0)); + m_percent_humidity_dry_popup->Popup(); + } + else + { + wxPoint img_pos = ClientToScreen(wxPoint(0, 0)); + wxPoint popup_pos(img_pos.x - m_Humidity_tip_popup.GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80)); + m_Humidity_tip_popup.Position(popup_pos, wxSize(0, 0)); + + int humidity_value = info->humidity_level; + if (humidity_value > 0 && humidity_value <= 5) { m_Humidity_tip_popup.set_humidity_level(humidity_value); } + m_Humidity_tip_popup.Popup(); } - } - m_Humidity_tip_popup.Popup(); + + delete info; }); - + Bind(EVT_AMS_ON_SELECTED, &AMSControl::AmsSelectedSwitch, this); m_button_guide->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) { post_event(wxCommandEvent(EVT_AMS_GUIDE_WIKI)); @@ -2935,8 +595,6 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons post_event(wxCommandEvent(EVT_AMS_RETRY)); }); - CreateAms(); - SetSelection(0); EnterNoneAMSMode(); } @@ -2953,29 +611,56 @@ void AMSControl::init_scaled_buttons() m_button_extruder_back->SetCornerRadius(FromDIP(12)); } -std::string AMSControl::GetCurentAms() { return m_current_ams; } -std::string AMSControl::GetCurentShowAms() { return m_current_show_ams; } +std::string AMSControl::GetCurentAms() { + return m_current_ams; +} +std::string AMSControl::GetCurentShowAms() { + return m_current_show_ams; +} std::string AMSControl::GetCurrentCan(std::string amsid) { std::string current_can; - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *ams = m_ams_cans_list[i]; - if (ams->amsCans->m_info.ams_id == amsid) { - current_can = ams->amsCans->GetCurrentCan(); + for (auto ams_item : m_ams_item_list) { + AmsItem* item = ams_item.second; + if (item == nullptr){ + continue; + } + if (item->get_ams_id() == amsid) { + current_can = item->GetCurrentCan(); return current_can; } } return current_can; } -wxColour AMSControl::GetCanColour(std::string amsid, std::string canid) +void AMSControl::AmsSelectedSwitch(wxCommandEvent& event) { + std::string ams_id_selected = std::to_string(event.GetInt()); + if (m_current_ams != ams_id_selected){ + m_current_ams = ams_id_selected; + } + if (m_current_show_ams != ams_id_selected && m_current_show_ams != "") { + auto iter = m_ams_item_list.find(m_current_show_ams); + if (iter == m_ams_item_list.end()) return; + try{ + const auto& can_lib_list = iter->second->get_can_lib_list(); + for (auto can : can_lib_list) { + can.second->UnSelected(); + } + } + catch (...){ + ; + } + } +} + +wxColour AMSControl::GetCanColour(std::string amsid, std::string canid) { wxColour col = *wxWHITE; for (auto i = 0; i < m_ams_info.size(); i++) { - if (m_ams_info[i].ams_id == amsid) { + if (m_ams_info[i].ams_id == amsid) { for (auto o = 0; o < m_ams_info[i].cans.size(); o++) { - if (m_ams_info[i].cans[o].can_id == canid) { + if (m_ams_info[i].cans[o].can_id == canid) { col = m_ams_info[i].cans[o].material_colour; } } @@ -2996,10 +681,10 @@ void AMSControl::SetActionState(bool button_status[]) void AMSControl::EnterNoneAMSMode() { m_vams_lib->m_ams_model = m_ext_model; - if(m_is_none_ams_mode == AMSModel::NO_AMS) return; - m_panel_top->Hide(); - m_simplebook_amsitems->Hide(); - m_simplebook_amsitems->SetSelection(0); + if(m_is_none_ams_mode == AMSModel::EXT_AMS) return; + m_panel_prv->Hide(); + m_simplebook_amsprvs->Hide(); + m_simplebook_amsprvs->SetSelection(0); m_simplebook_ams->SetSelection(0); m_extruder->no_ams_mode(true); @@ -3012,16 +697,16 @@ void AMSControl::EnterNoneAMSMode() m_amswin->Layout(); m_amswin->Fit(); Layout(); - m_is_none_ams_mode = AMSModel::NO_AMS; + m_is_none_ams_mode = AMSModel::EXT_AMS; } void AMSControl::EnterGenericAMSMode() { m_vams_lib->m_ams_model = m_ext_model; if(m_is_none_ams_mode == AMSModel::GENERIC_AMS) return; - m_panel_top->Show(); - m_simplebook_amsitems->Show(); - m_simplebook_amsitems->SetSelection(1); + m_panel_prv->Show(); + m_simplebook_amsprvs->Show(); + m_simplebook_amsprvs->SetSelection(1); m_vams_lib->m_ams_model = AMSModel::GENERIC_AMS; m_ams_tip->SetLabel(_L("AMS")); @@ -3047,13 +732,13 @@ void AMSControl::EnterGenericAMSMode() void AMSControl::EnterExtraAMSMode() { m_vams_lib->m_ams_model = m_ext_model; - if(m_is_none_ams_mode == AMSModel::EXTRA_AMS) return; - m_panel_top->Hide(); - m_simplebook_amsitems->Show(); - m_simplebook_amsitems->SetSelection(1); + if(m_is_none_ams_mode == AMSModel::AMS_LITE) return; + m_panel_prv->Hide(); + m_simplebook_amsprvs->Show(); + m_simplebook_amsprvs->SetSelection(1); - m_vams_lib->m_ams_model = AMSModel::EXTRA_AMS; + m_vams_lib->m_ams_model = AMSModel::AMS_LITE; m_ams_tip->SetLabel(wxEmptyString); m_img_vams_tip->SetBitmap(create_scaled_bitmap("enable_ams_disable", this, 16)); m_img_vams_tip->Disable(); @@ -3072,7 +757,7 @@ void AMSControl::EnterExtraAMSMode() m_amswin->Fit(); Layout(); Refresh(true); - m_is_none_ams_mode = AMSModel::EXTRA_AMS; + m_is_none_ams_mode = AMSModel::AMS_LITE; } @@ -3099,25 +784,21 @@ void AMSControl::SetClibrationLink(wxString link) void AMSControl::PlayRridLoading(wxString amsid, wxString canid) { - AmsCansHash::iterator iter = m_ams_cans_list.begin(); - auto count_item_index = 0; + auto iter = m_ams_item_list.find(amsid.ToStdString()); - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *cans = m_ams_cans_list[i]; - if (cans->amsCans->m_info.ams_id == amsid) { cans->amsCans->PlayRridLoading(canid); } - iter++; + if (iter != m_ams_item_list.end()) { + AmsItem* cans = iter->second; + cans->PlayRridLoading(canid); } } void AMSControl::StopRridLoading(wxString amsid, wxString canid) { - AmsCansHash::iterator iter = m_ams_cans_list.begin(); - auto count_item_index = 0; + auto iter = m_ams_item_list.find(amsid.ToStdString()); - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *cans = m_ams_cans_list[i]; - if (cans->amsCans->m_info.ams_id == amsid) { cans->amsCans->StopRridLoading(canid); } - iter++; + if (iter != m_ams_item_list.end()) { + AmsItem* cans = iter->second; + cans->StopRridLoading(canid); } } @@ -3138,9 +819,15 @@ void AMSControl::msw_rescale() m_button_retry->SetMinSize(wxSize(-1, FromDIP(24))); m_vams_lib->msw_rescale(); - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *cans = m_ams_cans_list[i]; - cans->amsCans->msw_rescale(); + for (auto ams_item : m_ams_item_list) { + if (ams_item.second){ + ams_item.second->msw_rescale(); + } + } + + + if (m_percent_humidity_dry_popup){ + m_percent_humidity_dry_popup->msw_rescale(); } Layout(); @@ -3165,7 +852,7 @@ void AMSControl::UpdateStepCtrl(bool is_extrusion) m_filament_unload_step->DeleteAllItems(); m_filament_vt_load_step->DeleteAllItems(); - if (m_ams_model == AMSModel::GENERIC_AMS || m_ext_model == AMSModel::GENERIC_AMS) { + if (IS_GENERIC_AMS(m_ams_model) || IS_GENERIC_AMS(m_ext_model)) { if (is_extrusion) { m_filament_load_step->AppendItem(FILAMENT_CHANGE_STEP_STRING[FilamentStep::STEP_HEAT_NOZZLE]); m_filament_load_step->AppendItem(FILAMENT_CHANGE_STEP_STRING[FilamentStep::STEP_CUT_FILAMENT]); @@ -3190,7 +877,7 @@ void AMSControl::UpdateStepCtrl(bool is_extrusion) } - if (m_ams_model == AMSModel::EXTRA_AMS || m_ext_model == AMSModel::EXTRA_AMS) { + if (m_ams_model == AMSModel::AMS_LITE || m_ext_model == AMSModel::AMS_LITE) { m_filament_load_step->AppendItem(FILAMENT_CHANGE_STEP_STRING[FilamentStep::STEP_HEAT_NOZZLE]); m_filament_load_step->AppendItem(FILAMENT_CHANGE_STEP_STRING[FilamentStep::STEP_CHECK_POSITION]); m_filament_load_step->AppendItem(FILAMENT_CHANGE_STEP_STRING[FilamentStep::STEP_CUT_FILAMENT]); @@ -3227,34 +914,64 @@ void AMSControl::CreateAms() std::vector::iterator it; Freeze(); for (it = ams_info.begin(); it != ams_info.end(); it++) { - AddAmsItems(*it); + AddAmsPreview(*it); AddAms(*it); AddExtraAms(*it); m_ams_info.push_back(*it); } - m_sizer_top->Layout(); + m_sizer_prv->Layout(); Thaw(); } -void AMSControl::Reset() + +void AMSControl::ClearAms() { + m_simplebook_generic_ams->DeleteAllPages(); + m_simplebook_extra_ams->DeleteAllPages(); + m_simplebook_generic_ams->DestroyChildren(); + m_simplebook_extra_ams->DestroyChildren(); + m_simplebook_generic_ams->Layout(); + m_simplebook_extra_ams->Layout(); + m_simplebook_generic_ams->Refresh(); + m_simplebook_extra_ams->Refresh(); + + for (auto it : m_ams_preview_list) { + delete it.second; + } + m_ams_preview_list.clear(); + + m_current_show_ams = ""; + m_current_ams = ""; + m_current_select = ""; + + m_ams_generic_item_list.clear(); + m_ams_extra_item_list.clear(); + m_ams_item_list.clear(); + m_sizer_prv->Clear(); +} + +void AMSControl::CreateAmsSingleNozzle() { - auto caninfo0_0 = Caninfo{"0", "", *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE}; - auto caninfo0_1 = Caninfo{"1", "", *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE}; - auto caninfo0_2 = Caninfo{"2", "", *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE}; - auto caninfo0_3 = Caninfo{"3", "", *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE}; + //add ams data + for (auto ams_info = m_ams_info.begin(); ams_info != m_ams_info.end(); ams_info++) { + if (ams_info->cans.size() == GENERIC_AMS_SLOT_NUM) { + AddAmsPreview(*ams_info); + AddAms(*ams_info); + AddExtraAms(*ams_info); + } + else if (ams_info->cans.size() == 1) { + AddAmsPreview(*ams_info); + AddAms(*ams_info); + } + } +} - AMSinfo ams1 = AMSinfo{"0", std::vector{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}}; - AMSinfo ams2 = AMSinfo{"1", std::vector{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}}; - AMSinfo ams3 = AMSinfo{"2", std::vector{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}}; - AMSinfo ams4 = AMSinfo{"3", std::vector{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}}; +void AMSControl::Reset() +{ + m_ams_info.clear(); + ClearAms(); - std::vector ams_info{ams1, ams2, ams3, ams4}; - std::vector::iterator it; - UpdateAms(ams_info, true); - m_current_show_ams = ""; - m_current_ams = ""; - m_current_senect = ""; + Layout(); } void AMSControl::show_noams_mode() @@ -3262,11 +979,11 @@ void AMSControl::show_noams_mode() show_vams(true); m_sizer_ams_tips->Show(true); - if (m_ams_model == AMSModel::NO_AMS) { + if (m_ams_model == AMSModel::EXT_AMS) { EnterNoneAMSMode(); - } else if(m_ams_model == AMSModel::GENERIC_AMS){ + } else if (IS_GENERIC_AMS(m_ams_model)){ EnterGenericAMSMode(); - } else if (m_ams_model == AMSModel::EXTRA_AMS) { + } else if (m_ams_model == AMSModel::AMS_LITE) { EnterExtraAMSMode(); } } @@ -3339,111 +1056,146 @@ void AMSControl::reset_vams() } -void AMSControl::UpdateAms(std::vector info, bool is_reset) +void AMSControl::UpdateAms(std::vector ams_info, bool is_reset) { - std::string curr_ams_id = GetCurentAms(); - std::string curr_can_id = GetCurrentCan(curr_ams_id); - m_button_area->Layout(); - m_button_area->Fit(); + m_button_area->Fit(); - // update item - m_ams_info = info; - if (m_ams_model == AMSModel::GENERIC_AMS){ - m_ams_cans_list = m_ams_generic_cans_list; - } - else if (m_ams_model == AMSModel::EXTRA_AMS) { - m_ams_cans_list = m_ams_extra_cans_list; - } + /*if (!test)*/{ + // update item + bool fresh = false; - if (info.size() > 1) { - m_simplebook_amsitems->Show(); - m_amswin->Layout(); - m_amswin->Fit(); - SetSize(m_amswin->GetSize()); - SetMinSize(m_amswin->GetSize()); - } else { - m_simplebook_amsitems->Hide(); - m_amswin->Layout(); - m_amswin->Fit(); - SetSize(m_amswin->GetSize()); - SetMinSize(m_amswin->GetSize()); - } + // basic check + if (m_ams_info.size() == ams_info.size() ) { + for (int i = 0; i < m_ams_info.size(); i++){ + if (m_ams_info[i].ams_id != ams_info[i].ams_id){ + fresh = true; + } + } + } + else{ + fresh = true; + } + + m_ams_info.clear(); + m_ams_info = ams_info; + if (fresh){ + ClearAms(); + //if (m_extder_data.total_extder_count >= 2){ + // CreateAmsDoubleNozzle(series_name, printer_type); + //}else{ + CreateAmsSingleNozzle(); + //} + SetSize(wxSize(FromDIP(578), -1)); + SetMinSize(wxSize(FromDIP(578), -1)); + Layout(); + } + + if (IS_GENERIC_AMS(m_ams_model)) { + m_ams_item_list = m_ams_generic_item_list; + } + else if (m_ams_model == AMSModel::AMS_LITE) { + m_ams_item_list = m_ams_extra_item_list; + } - for (auto i = 0; i < m_ams_item_list.GetCount(); i++) { - AmsItems *item = m_ams_item_list[i]; - if (i < info.size() && info.size() > 1) { - item->amsItem->Update(m_ams_info[i]); - item->amsItem->Open(); + if (ams_info.size() > 1) { + m_simplebook_amsprvs->Show(); + m_amswin->Layout(); + m_amswin->Fit(); + SetSize(m_amswin->GetSize()); + SetMinSize(m_amswin->GetSize()); } else { - item->amsItem->Close(); + m_simplebook_amsprvs->Hide(); + m_amswin->Layout(); + m_amswin->Fit(); + SetSize(m_amswin->GetSize()); + SetMinSize(m_amswin->GetSize()); } - } - // update cans - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *cans = m_ams_cans_list[i]; + // update cans - for (auto ifo : m_ams_info) { - if (ifo.ams_id == cans->amsIndex) { - cans->amsCans->m_info = ifo; - cans->amsCans->Update(ifo); - cans->amsCans->show_sn_value(m_ams_model == AMSModel::EXTRA_AMS?false:true); + for (auto ams_item : m_ams_item_list) { + if (ams_item.second == nullptr){ + continue; + } + std::string ams_id = ams_item.second->get_ams_id(); + AmsItem* cans = ams_item.second; + for (auto ifo : m_ams_info) { + if (ifo.ams_id == ams_id) { + cans->Update(ifo); + cans->show_sn_value(m_ams_model == AMSModel::AMS_LITE?false:true); + } } } - } - if ( m_current_show_ams.empty() && !is_reset ) { - if (info.size() > 0) { - SwitchAms(info[0].ams_id); + for (auto ams_prv : m_ams_preview_list) { + std::string id = ams_prv.second->get_ams_id(); + auto item = m_ams_item_list.find(id); + if (item != m_ams_item_list.end()) + { ams_prv.second->Update(item->second->get_ams_info()); + } + } + + if ( m_current_show_ams.empty() && !is_reset ) { + if (ams_info.size() > 0) { + SwitchAms(ams_info[0].ams_id); + } + } + + if (m_ams_model == AMSModel::EXT_AMS && !m_vams_lib->is_selected()) { + m_vams_lib->OnSelected(); } } - if (m_ams_model == AMSModel::NO_AMS && !m_vams_lib->is_selected()) { - m_vams_lib->OnSelected(); + /*update humidity popup*/ + if (m_percent_humidity_dry_popup->IsShown()) + { + string target_id = m_percent_humidity_dry_popup->get_owner_ams_id(); + for (const auto& the_info : ams_info) + { + if (target_id == the_info.ams_id) + { + uiAmsHumidityInfo humidity_info; + humidity_info.ams_id = the_info.ams_id; + humidity_info.humidity_level = the_info.ams_humidity; + humidity_info.humidity_percent = the_info.humidity_raw; + humidity_info.left_dry_time = the_info.left_dray_time; + humidity_info.current_temperature = the_info.current_temperature; + m_percent_humidity_dry_popup->Update(&humidity_info); + break; + } + } } } -void AMSControl::AddAmsItems(AMSinfo info) +void AMSControl::AddAmsPreview(AMSinfo info) { - auto amsitem = new AMSItem(m_panel_top, wxID_ANY, info); - amsitem->Bind(wxEVT_LEFT_DOWN, [this, amsitem](wxMouseEvent& e) { - SwitchAms(amsitem->m_amsinfo.ams_id); + auto ams_prv = new AMSPreview(m_panel_prv, wxID_ANY, info); + m_sizer_prv->Add(ams_prv, 0, wxALIGN_CENTER | wxRIGHT, 6); + + ams_prv->Bind(wxEVT_LEFT_DOWN, [this, ams_prv](wxMouseEvent& e) { + SwitchAms(ams_prv->get_ams_id()); e.Skip(); }); - - AmsItems* item = new AmsItems(); - item->amsIndex = info.ams_id; - item->amsItem = amsitem; - - m_ams_item_list.Add(item); - m_sizer_top->Add(amsitem, 0, wxALIGN_CENTER | wxRIGHT, 6); + m_ams_preview_list[info.ams_id] = ams_prv; } void AMSControl::AddAms(AMSinfo info) { - AmsCansWindow* canswin = new AmsCansWindow(); - auto amscans = new AmsCans(m_simplebook_generic_cans, info, AMSModel::GENERIC_AMS); - - canswin->amsIndex = info.ams_id; - canswin->amsCans = amscans; - m_ams_generic_cans_list.Add(canswin); + auto ams_item = new AmsItem(m_simplebook_generic_ams, info, AMSModel::GENERIC_AMS); + m_simplebook_generic_ams->AddPage(ams_item, wxEmptyString, false); + ams_item->set_selection(m_simplebook_generic_ams->GetPageCount() - 1); - m_simplebook_generic_cans->AddPage(amscans, wxEmptyString, false); - amscans->m_selection = m_simplebook_generic_cans->GetPageCount() - 1; + m_ams_generic_item_list[info.ams_id] = ams_item; } void AMSControl::AddExtraAms(AMSinfo info) { - AmsCansWindow* canswin = new AmsCansWindow(); - auto amscans = new AmsCans(m_simplebook_extra_cans, info, AMSModel::EXTRA_AMS); + auto ams_item = new AmsItem(m_simplebook_extra_ams, info, AMSModel::AMS_LITE); + m_simplebook_extra_ams->AddPage(ams_item, wxEmptyString, false); + ams_item->set_selection(m_simplebook_extra_ams->GetPageCount() - 1); - canswin->amsIndex = info.ams_id; - canswin->amsCans = amscans; - m_ams_extra_cans_list.Add(canswin); - - m_simplebook_extra_cans->AddPage(amscans, wxEmptyString, false); - amscans->m_selection = m_simplebook_extra_cans->GetPageCount() - 1; + m_ams_extra_item_list[info.ams_id] = ams_item; } void AMSControl::SwitchAms(std::string ams_id) @@ -3457,30 +1209,19 @@ void AMSControl::SwitchAms(std::string ams_id) } } - for (auto i = 0; i < m_ams_item_list.GetCount(); i++) { - AmsItems *item = m_ams_item_list[i]; - if (item->amsItem->m_amsinfo.ams_id == m_current_show_ams) { - item->amsItem->OnSelected(); - m_current_senect = ams_id; - - //bool ready_selected = false; - //for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - // AmsCansWindow* ams = m_ams_cans_list[i]; - // if (ams->amsCans->m_info.ams_id == ams_id) { - // //ams->amsCans->SetDefSelectCan(); - // //m_vams_lib->OnSelected(); - // if () { - - // } - // } - //} + for (auto prv_it : m_ams_preview_list) { + AMSPreview* prv = prv_it.second; + if (prv->get_ams_id() == m_current_show_ams) { + prv->OnSelected(); + m_current_select = ams_id; bool ready_selected = false; - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow* ams = m_ams_cans_list[i]; - if (ams->amsCans->m_info.ams_id == ams_id) { - for (auto lib : ams->amsCans->m_can_lib_list) { - if (lib->canLib->is_selected()) { + for (auto item_it : m_ams_item_list) { + AmsItem* item = item_it.second; + if (item->get_ams_id() == ams_id) { + for (auto lib_it : item->get_can_lib_list()) { + AMSLib* lib = lib_it.second; + if (lib->is_selected()) { ready_selected = true; } } @@ -3497,21 +1238,21 @@ void AMSControl::SwitchAms(std::string ams_id) } } else { - item->amsItem->UnSelected(); + prv->UnSelected(); } - m_sizer_top->Layout(); - m_panel_top->Fit(); + m_sizer_prv->Layout(); + m_panel_prv->Fit(); } - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *cans = m_ams_cans_list[i]; - if (cans->amsCans->m_info.ams_id == ams_id) { + for (auto ams_item : m_ams_item_list) { + AmsItem* item = ams_item.second; + if (item->get_ams_id() == ams_id) { - if (m_ams_model == AMSModel::GENERIC_AMS) { - m_simplebook_generic_cans->SetSelection(cans->amsCans->m_selection); + if (IS_GENERIC_AMS(m_ams_model)) { + m_simplebook_generic_ams->SetSelection(item->get_selection()); } - else if (m_ams_model == AMSModel::EXTRA_AMS) { - m_simplebook_extra_cans->SetSelection(cans->amsCans->m_selection); + else if (m_ams_model == AMSModel::AMS_LITE) { + m_simplebook_extra_ams->SetSelection(item->get_selection()); } } } @@ -3617,7 +1358,7 @@ void AMSControl::ShowFilamentTip(bool hasams) m_tip_right_top->Hide(); m_tip_load_info->SetLabelText(wxEmptyString); } - + m_tip_load_info->SetMinSize(AMS_STEP_SIZE); m_tip_load_info->Wrap(AMS_STEP_SIZE.x - FromDIP(5)); m_sizer_right_tip->Layout(); @@ -3625,14 +1366,14 @@ void AMSControl::ShowFilamentTip(bool hasams) bool AMSControl::Enable(bool enable) { - for (auto i = 0; i < m_ams_item_list.GetCount(); i++) { - AmsItems *item = m_ams_item_list[i]; - item->amsItem->Enable(enable); + for (auto prv_it : m_ams_preview_list) { + AMSPreview* prv = prv_it.second; + prv->Enable(enable); } - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - AmsCansWindow *cans = m_ams_cans_list[i]; - cans->amsCans->Enable(enable); + for (auto item_it : m_ams_item_list) { + AmsItem* item = item_it.second; + item->Enable(enable); } m_button_extruder_feed->Enable(enable); @@ -3645,7 +1386,7 @@ bool AMSControl::Enable(bool enable) void AMSControl::SetExtruder(bool on_off, bool is_vams, std::string ams_now, wxColour col) { - if (m_ams_model == AMSModel::GENERIC_AMS || m_ext_model == AMSModel::GENERIC_AMS ) { + if (IS_GENERIC_AMS(m_ams_model) || IS_GENERIC_AMS(m_ext_model)) { if (!on_off) { m_extruder->TurnOff(); m_vams_extra_road->OnVamsLoading(false); @@ -3675,7 +1416,7 @@ void AMSControl::SetExtruder(bool on_off, bool is_vams, std::string ams_now, wxC m_vams_road->OnVamsLoading(false); } } - else if (m_ams_model == AMSModel::EXTRA_AMS || m_ext_model == AMSModel::EXTRA_AMS) { + else if (m_ams_model == AMSModel::AMS_LITE || m_ext_model == AMSModel::AMS_LITE) { if (!is_vams && !on_off) { m_extruder->TurnOff(); m_extruder->OnVamsLoading(false); @@ -3701,17 +1442,8 @@ void AMSControl::SetExtruder(bool on_off, bool is_vams, std::string ams_now, wxC void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadType type, AMSPassRoadSTEP step) { - AmsCansWindow *cans = nullptr; - bool notfound = true; - - for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) { - cans = m_ams_cans_list[i]; - if (cans->amsCans->m_info.ams_id == ams_id) { - notfound = false; - break; - } - } - + AmsItem* ams = nullptr; + auto amsit = m_ams_item_list.find(ams_id); if (ams_id != m_last_ams_id || m_last_tray_id != canid) { SetAmsStep(m_last_ams_id, m_last_tray_id, AMSPassRoadType::AMS_ROAD_TYPE_UNLOAD, AMSPassRoadSTEP::AMS_ROAD_STEP_NONE); @@ -3720,44 +1452,44 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy m_vams_road->OnVamsLoading(false); } - if (notfound) return; - if (cans == nullptr) return; - + if (amsit != m_ams_item_list.end()) {ams = amsit->second;} + else {return;} + if (ams == nullptr) return; m_last_ams_id = ams_id; m_last_tray_id = canid; - if (m_ams_model == AMSModel::GENERIC_AMS) { + if (IS_GENERIC_AMS(m_ams_model)) { if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) { - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_NONE); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_NONE); m_extruder->OnAmsLoading(false); } if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP1) { - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1); m_extruder->OnAmsLoading(false); } if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP2) { - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1); - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2); if (m_current_show_ams == ams_id) { - m_extruder->OnAmsLoading(true, cans->amsCans->GetTagColr(canid)); + m_extruder->OnAmsLoading(true, ams->GetTagColr(canid)); } } if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP3) { - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1); - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2); - cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_3); - m_extruder->OnAmsLoading(true, cans->amsCans->GetTagColr(canid)); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2); + ams->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_3); + m_extruder->OnAmsLoading(true, ams->GetTagColr(canid)); } } - else if (m_ams_model == AMSModel::EXTRA_AMS) { - cans->amsCans->SetAmsStepExtra(canid, type, step); + else if (m_ams_model == AMSModel::AMS_LITE) { + ams->SetAmsStepExtra(canid, type, step); if (step != AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) { - m_extruder->OnAmsLoading(true, cans->amsCans->GetTagColr(canid)); + m_extruder->OnAmsLoading(true, ams->GetTagColr(canid)); } else { m_extruder->OnAmsLoading(false); diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index afcee66365d..c6ca606558f 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -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 #include -#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 material_cols; -}; - -struct AMSinfo -{ -public: - std::string ams_id; - std::vector 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 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 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 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 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 @@ class AMSControl : public wxSimplebook std::string m_current_ams; std::string m_current_show_ams; std::map m_ams_selection; - - AmsItemsHash m_ams_item_list; + + std::map m_ams_preview_list; std::vector m_ams_info; - AmsCansHash m_ams_cans_list; - AmsCansHash m_ams_generic_cans_list; - AmsCansHash m_ams_extra_cans_list; + std::map m_ams_item_list; + std::map m_ams_generic_item_list; + std::map 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 @@ class AMSControl : public wxSimplebook 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 @@ class AMSControl : public wxSimplebook 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 @@ class AMSControl : public wxSimplebook 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 @@ class AMSControl : public wxSimplebook 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 @@ class AMSControl : public wxSimplebook void UpdateStepCtrl(bool is_extrusion_exist); void CreateAms(); + void CreateAmsSingleNozzle(); + void ClearAms(); void UpdateAms(std::vector 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 @@ class AMSControl : public wxSimplebook 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_ diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp new file mode 100644 index 00000000000..54dfbce4539 --- /dev/null +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -0,0 +1,2553 @@ +#include "AMSItem.hpp" +#include "Label.hpp" +#include "../BitmapCache.hpp" +#include "../I18N.hpp" +#include "../GUI_App.hpp" +#include "../Utils/WxFontUtils.hpp" + +#include "slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h" + +#include +#include + +#include + +#include "CalibUtils.hpp" + + + +namespace Slic3r { namespace GUI { + + static const wxColour AMS_TRAY_DEFAULT_COL = wxColour(255, 255, 255); + wxDEFINE_EVENT(EVT_AMS_EXTRUSION_CALI, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_LOAD, SimpleEvent); + wxDEFINE_EVENT(EVT_AMS_UNLOAD, SimpleEvent); + wxDEFINE_EVENT(EVT_AMS_SETTINGS, SimpleEvent); + wxDEFINE_EVENT(EVT_AMS_FILAMENT_BACKUP, SimpleEvent); + wxDEFINE_EVENT(EVT_AMS_REFRESH_RFID, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_ON_SELECTED, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_ON_FILAMENT_EDIT, wxCommandEvent); + wxDEFINE_EVENT(EVT_VAMS_ON_FILAMENT_EDIT, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_CLIBRATION_AGAIN, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_CLIBRATION_CANCEL, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_GUIDE_WIKI, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_RETRY, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_SHOW_HUMIDITY_TIPS, wxCommandEvent); + wxDEFINE_EVENT(EVT_AMS_UNSELETED_VAMS, wxCommandEvent); + wxDEFINE_EVENT(EVT_CLEAR_SPEED_CONTROL, wxCommandEvent); + + +#define AMS_CANS_WINDOW_SIZE wxSize(FromDIP(264), FromDIP(196)) +bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, bool humidity_flag) +{ + if (!ams) return false; + this->ams_id = ams->id; + + if (ams->type == 1 || ams->type == 3 || ams->type == N3S_AMS) { + this->ams_humidity = ams->humidity; + } + else{ + this->ams_humidity = -1; + } + + this->humidity_raw = ams->humidity_raw; + this->left_dray_time = ams->left_dry_time; + this->current_temperature = ams->current_temperature; + this->ams_type = AMSModel(ams->type); + + cans.clear(); + for (int i = 0; i < ams->trayList.size(); i++) { + auto it = ams->trayList.find(std::to_string(i)); + Caninfo info; + // tray is exists + if (it != ams->trayList.end() && it->second->is_exists) { + if (it->second->is_tray_info_ready()) { + info.can_id = it->second->id; + info.ctype = it->second->ctype; + info.material_name = it->second->get_display_filament_type(); + if (!it->second->color.empty()) { + info.material_colour = AmsTray::decode_color(it->second->color); + } else { + // set to white by default + info.material_colour = AMS_TRAY_DEFAULT_COL; + } + + for (std::string cols:it->second->cols) { + info.material_cols.push_back(AmsTray::decode_color(cols)); + } + + if (MachineObject::is_bbl_filament(it->second->tag_uid)) { + info.material_state = AMSCanType::AMS_CAN_TYPE_BRAND; + } else { + info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND; + } + + if (!MachineObject::is_bbl_filament(it->second->tag_uid) || !remain_flag) { + info.material_remain = 100; + } else { + if(it->second->remain < 0 || it->second->remain > 100) { + info.material_remain = 100;/*ignore the invalid data*/ + } else { + info.material_remain = it->second->remain; + } + } + + + } else { + info.can_id = it->second->id; + info.material_name = ""; + info.ctype = 0; + info.material_colour = AMS_TRAY_DEFAULT_COL; + info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND; + wxColour(255, 255, 255); + } + + if (it->second->is_tray_info_ready() && obj->cali_version >= 0) { + CalibUtils::get_pa_k_n_value_by_cali_idx(obj, it->second->cali_idx, info.k, info.n); + } + else { + info.k = it->second->k; + info.n = it->second->n; + } + } else { + //info.can_id = i; + info.can_id = std::to_string(i); + info.material_state = AMSCanType::AMS_CAN_TYPE_EMPTY; + } + cans.push_back(info); + } + return true; +} + +/************************************************* +Description:AMSrefresh +**************************************************/ + +AMSrefresh::AMSrefresh() { SetFont(Label::Body_10);} + +AMSrefresh::AMSrefresh(wxWindow *parent, wxString number, Caninfo info, const wxPoint &pos, const wxSize &size) : AMSrefresh() +{ + m_info = info; + m_can_id = number.ToStdString(); + create(parent, wxID_ANY, pos, size); +} + +AMSrefresh::AMSrefresh(wxWindow *parent, int number, Caninfo info, const wxPoint &pos, const wxSize &size) : AMSrefresh() +{ + m_info = info; + m_can_id = wxString::Format("%d", number).ToStdString(); + create(parent, wxID_ANY, pos, size); +} + + AMSrefresh::~AMSrefresh() + { + if (m_playing_timer) { + m_playing_timer->Stop(); + delete m_playing_timer; + m_playing_timer = nullptr; + } + } + +void AMSrefresh::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +{ + wxWindow::Create(parent, id, pos, size, wxBORDER_NONE); + SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); + + Bind(wxEVT_TIMER, &AMSrefresh::on_timer, this); + Bind(wxEVT_PAINT, &AMSrefresh::paintEvent, this); + Bind(wxEVT_ENTER_WINDOW, &AMSrefresh::OnEnterWindow, this); + Bind(wxEVT_LEAVE_WINDOW, &AMSrefresh::OnLeaveWindow, this); + Bind(wxEVT_LEFT_DOWN, &AMSrefresh::OnClick, this); + + m_bitmap_normal = ScalableBitmap(this, "ams_refresh_normal", 30); + m_bitmap_selected = ScalableBitmap(this, "ams_refresh_selected", 30); + + m_bitmap_ams_rfid_0 = ScalableBitmap(this, "ams_rfid_0", 30); + m_bitmap_ams_rfid_1 = ScalableBitmap(this, "ams_rfid_1", 30); + m_bitmap_ams_rfid_2 = ScalableBitmap(this, "ams_rfid_2", 30); + m_bitmap_ams_rfid_3 = ScalableBitmap(this, "ams_rfid_3", 30); + m_bitmap_ams_rfid_4 = ScalableBitmap(this, "ams_rfid_4", 30); + m_bitmap_ams_rfid_5 = ScalableBitmap(this, "ams_rfid_5", 30); + m_bitmap_ams_rfid_6 = ScalableBitmap(this, "ams_rfid_6", 30); + m_bitmap_ams_rfid_7 = ScalableBitmap(this, "ams_rfid_7", 30); + + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_0); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_1); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_2); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_3); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_4); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_5); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_6); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_7); + + m_playing_timer = new wxTimer(); + m_playing_timer->SetOwner(this); + wxPostEvent(this, wxTimerEvent()); + + SetSize(AMS_REFRESH_SIZE); + SetMinSize(AMS_REFRESH_SIZE); + SetMaxSize(AMS_REFRESH_SIZE); +} + +void AMSrefresh::on_timer(wxTimerEvent &event) +{ + //if (m_rotation_angle >= m_rfid_bitmap_list.size()) { + // m_rotation_angle = 0; + //} else { + // m_rotation_angle++; + //} + Refresh(); +} + +void AMSrefresh::PlayLoading() +{ + if (m_play_loading || m_disable_mode) return; + + m_play_loading = true; + m_playing_timer->Start(AMS_REFRESH_PLAY_LOADING_TIMER); + Refresh(); +} + +void AMSrefresh::StopLoading() +{ + if (!m_play_loading || m_disable_mode) return; + + m_playing_timer->Stop(); + m_play_loading = false; + Refresh(); +} + +void AMSrefresh::OnEnterWindow(wxMouseEvent &evt) +{ + m_selected = true; + Refresh(); +} + +void AMSrefresh::OnLeaveWindow(wxMouseEvent &evt) +{ + m_selected = false; + Refresh(); +} + +void AMSrefresh::OnClick(wxMouseEvent &evt) { + post_event(wxCommandEvent(EVT_AMS_REFRESH_RFID)); +} + +void AMSrefresh::post_event(wxCommandEvent &&event) +{ + if (m_disable_mode) + return; + event.SetString(m_info.can_id); + event.SetEventObject(m_parent); + wxPostEvent(m_parent, event); + event.Skip(); +} + +void AMSrefresh::paintEvent(wxPaintEvent &evt) +{ + wxSize size = GetSize(); + wxPaintDC dc(this); + + auto colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY700); + if (!wxWindow::IsEnabled()) { colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY500); } + + auto pot = wxPoint((size.x - m_bitmap_selected.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2); + + if (!m_disable_mode) { + if (!m_play_loading) { + dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot); + } + else { + /* m_bitmap_rotation = ScalableBitmap(this, "ams_refresh_normal", 30); + auto image = m_bitmap_rotation.bmp().ConvertToImage(); + wxPoint offset; + auto loading_img = image.Rotate(m_rotation_angle, wxPoint(image.GetWidth() / 2, image.GetHeight() / 2), true, &offset); + ScalableBitmap loading_bitmap; + loading_bitmap.bmp() = wxBitmap(loading_img); + dc.DrawBitmap(loading_bitmap.bmp(), offset.x , offset.y);*/ + m_rotation_angle++; + if (m_rotation_angle >= m_rfid_bitmap_list.size()) { + m_rotation_angle = 0; + } + if (m_rfid_bitmap_list.size() <= 0)return; + dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].bmp(), pot); + } + } + + dc.SetPen(wxPen(colour)); + dc.SetBrush(wxBrush(colour)); + dc.SetFont(Label::Body_11); + //dc.SetTextForeground(StateColor::darkModeColorFor(AMS_CONTROL_BLACK_COLOUR)); + dc.SetTextForeground(colour); + auto tsize = dc.GetTextExtent(m_refresh_id); + pot = wxPoint((size.x - tsize.x) / 2, (size.y - tsize.y) / 2); + dc.DrawText(m_refresh_id, pot); +} + +void AMSrefresh::Update(std::string ams_id, Caninfo info) +{ + m_ams_id = ams_id; + m_info = info; + + if (!m_ams_id.empty() && !m_can_id.empty()) { + auto aid = atoi(m_ams_id.c_str()); + auto tid = atoi(m_can_id.c_str()); + auto tray_id = aid * 4 + tid; + m_refresh_id = wxGetApp().transition_tridid(tray_id); + } + StopLoading(); +} + +void AMSrefresh::msw_rescale() { + m_bitmap_normal = ScalableBitmap(this, "ams_refresh_normal", 30); + m_bitmap_selected = ScalableBitmap(this, "ams_refresh_selected", 30); + m_bitmap_ams_rfid_0 = ScalableBitmap(this, "ams_rfid_0", 30); + m_bitmap_ams_rfid_1 = ScalableBitmap(this, "ams_rfid_1", 30); + m_bitmap_ams_rfid_2 = ScalableBitmap(this, "ams_rfid_2", 30); + m_bitmap_ams_rfid_3 = ScalableBitmap(this, "ams_rfid_3", 30); + m_bitmap_ams_rfid_4 = ScalableBitmap(this, "ams_rfid_4", 30); + m_bitmap_ams_rfid_5 = ScalableBitmap(this, "ams_rfid_5", 30); + m_bitmap_ams_rfid_6 = ScalableBitmap(this, "ams_rfid_6", 30); + m_bitmap_ams_rfid_7 = ScalableBitmap(this, "ams_rfid_7", 30); + + m_rfid_bitmap_list.clear(); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_0); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_1); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_2); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_3); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_4); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_5); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_6); + m_rfid_bitmap_list.push_back(m_bitmap_ams_rfid_7); +} + +void AMSrefresh::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ + wxWindow::DoSetSize(x, y, width, height, sizeFlags); +} + +/************************************************* +Description:AMSextruder +**************************************************/ +void AMSextruderImage::TurnOn(wxColour col) +{ + m_colour = col; + Refresh(); +} + +void AMSextruderImage::TurnOff() +{ + m_colour = AMS_EXTRUDER_DEF_COLOUR; + Refresh(); +} + +void AMSextruderImage::msw_rescale() +{ + //m_ams_extruder.SetSize(AMS_EXTRUDER_BITMAP_SIZE); + //auto image = m_ams_extruder.ConvertToImage(); + m_ams_extruder = ScalableBitmap(this, "monitor_ams_extruder", 55); + Refresh(); +} + +void AMSextruderImage::paintEvent(wxPaintEvent &evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSextruderImage::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 AMSextruderImage::doRender(wxDC &dc) +{ + auto size = GetSize(); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(m_colour); + dc.DrawRectangle(0, FromDIP(18), size.x, size.y - FromDIP(18) - FromDIP(5)); + dc.DrawBitmap(m_ams_extruder.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2)); +} + + +AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +{ + wxWindow::Create(parent, id, pos, AMS_EXTRUDER_BITMAP_SIZE); + SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); + + m_ams_extruder = ScalableBitmap(this, "monitor_ams_extruder",55); + SetSize(AMS_EXTRUDER_BITMAP_SIZE); + SetMinSize(AMS_EXTRUDER_BITMAP_SIZE); + SetMaxSize(AMS_EXTRUDER_BITMAP_SIZE); + + + Bind(wxEVT_PAINT, &AMSextruderImage::paintEvent, this); +} + +AMSextruderImage::~AMSextruderImage() {} + + + + +//Ams Extruder +AMSextruder::AMSextruder(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) { create(parent, id, pos, size); } + + AMSextruder::~AMSextruder() {} + +void AMSextruder::TurnOn(wxColour col) +{ + m_amsSextruder->TurnOn(col); +} + +void AMSextruder::TurnOff() +{ + m_amsSextruder->TurnOff(); +} + +void AMSextruder::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +{ + wxWindow::Create(parent, id, pos, AMS_EXTRUDER_SIZE, wxBORDER_NONE); + SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR); + + wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL); + + m_bitmap_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_BITMAP_SIZE, wxTAB_TRAVERSAL); + m_bitmap_panel->SetBackgroundColour(AMS_EXTRUDER_DEF_COLOUR); + m_bitmap_panel->SetDoubleBuffered(true); + m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL); + + m_amsSextruder = new AMSextruderImage(m_bitmap_panel, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_BITMAP_SIZE); + m_bitmap_sizer->Add(m_amsSextruder, 0, wxALIGN_CENTER, 0); + + m_bitmap_panel->SetSizer(m_bitmap_sizer); + m_bitmap_panel->Layout(); + m_sizer_body->Add( 0, 0, 1, wxEXPAND, 0 ); + m_sizer_body->Add(m_bitmap_panel, 0, wxALIGN_CENTER, 0); + + SetSizer(m_sizer_body); + + Bind(wxEVT_PAINT, &AMSextruder::paintEvent, this); + Layout(); +} + +void AMSextruder::OnVamsLoading(bool load, wxColour col) +{ + m_vams_loading = load; + if (load)m_current_colur = col; + Refresh(); +} + +void AMSextruder::OnAmsLoading(bool load, wxColour col /*= AMS_CONTROL_GRAY500*/) +{ + m_ams_loading = load; + if (load)m_current_colur = col; + Refresh(); +} + +void AMSextruder::paintEvent(wxPaintEvent& evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSextruder::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 AMSextruder::doRender(wxDC& dc) +{ + //m_current_colur = + wxSize size = GetSize(); + dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + + if (!m_none_ams_mode) { + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + } + + if (m_has_vams) { + dc.DrawRoundedRectangle(-size.x / 2, size.y * 0.1, size.x, size.y, 4); + + if (m_vams_loading) { + + if (m_current_colur.Alpha() == 0) { dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID)); } + else { dc.SetPen(wxPen(m_current_colur, 6, wxPENSTYLE_SOLID)); } + dc.DrawRoundedRectangle(-size.x / 2, size.y * 0.1, size.x, size.y, 4); + + if ((m_current_colur == *wxWHITE || m_current_colur.Alpha() == 0) && !wxGetApp().dark_mode()) { + dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); + dc.DrawRoundedRectangle(-size.x / 2 - FromDIP(3), size.y * 0.1 + FromDIP(3), size.x, size.y, 3); + dc.DrawRoundedRectangle(-size.x / 2 + FromDIP(3), size.y * 0.1 - FromDIP(3), size.x, size.y, 5); + } + } + + if (m_ams_loading && !m_none_ams_mode) { + if (m_current_colur.Alpha() == 0) {dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID));} + else {dc.SetPen(wxPen(m_current_colur, 6, wxPENSTYLE_SOLID));} + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + + if ((m_current_colur == *wxWHITE || m_current_colur.Alpha() == 0) && !wxGetApp().dark_mode()) { + dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); + dc.DrawLine(size.x / 2 - FromDIP(4), -1, size.x / 2 - FromDIP(3), size.y * 0.6 - 1); + dc.DrawLine(size.x / 2 + FromDIP(3), -1, size.x / 2 + FromDIP(3), size.y * 0.6 - 1); + } + } + } + else { + if (m_ams_loading) { + if (m_current_colur.Alpha() == 0) { dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID)); } + else { dc.SetPen(wxPen(m_current_colur, 6, wxPENSTYLE_SOLID)); } + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + + if ((m_current_colur == *wxWHITE || m_current_colur.Alpha() == 0) && !wxGetApp().dark_mode()) { + dc.SetPen(wxPen(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, 1, wxPENSTYLE_SOLID)); + dc.DrawLine(size.x / 2 - FromDIP(4), -1, size.x / 2 - FromDIP(3), size.y * 0.6 - 1); + dc.DrawLine(size.x / 2 + FromDIP(3), -1, size.x / 2 + FromDIP(3), size.y * 0.6 - 1); + } + } + } + +} + +void AMSextruder::msw_rescale() +{ + m_amsSextruder->msw_rescale(); + Layout(); + Update(); + Refresh(); +} + +/************************************************* +Description:AMSVirtualRoad +**************************************************/ + +AMSVirtualRoad::AMSVirtualRoad(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) { create(parent, id, pos, size); } + +AMSVirtualRoad::~AMSVirtualRoad() {} + +void AMSVirtualRoad::OnVamsLoading(bool load, wxColour col) +{ + m_vams_loading = load; + if (load)m_current_color = col; + Refresh(); +} + +void AMSVirtualRoad::create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) +{ + wxWindow::Create(parent, id, pos, wxDefaultSize, wxBORDER_NONE); + SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_WHITE_COLOUR)); + Layout(); + Bind(wxEVT_PAINT, &AMSVirtualRoad::paintEvent, this); +} + +void AMSVirtualRoad::paintEvent(wxPaintEvent& evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSVirtualRoad::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 AMSVirtualRoad::doRender(wxDC& dc) +{ + if (!m_has_vams) return; + + wxSize size = GetSize(); + if (m_vams_loading) { + if (m_current_color.Alpha() == 0) { dc.SetPen(wxPen(*wxWHITE, 6, wxPENSTYLE_SOLID)); } + else { dc.SetPen(wxPen(m_current_color, 6, wxPENSTYLE_SOLID)); } + } + else { + dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); + } + + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + dc.DrawRoundedRectangle(size.x / 2, -size.y / 1.1 + FromDIP(1), size.x, size.y, 4); + + if ((m_current_color == *wxWHITE || m_current_color.Alpha() == 0) && !wxGetApp().dark_mode()) { + dc.SetPen(wxPen(AMS_CONTROL_DEF_LIB_BK_COLOUR, 1, wxPENSTYLE_SOLID)); + dc.DrawRoundedRectangle(size.x / 2 - FromDIP(3), -size.y / 1.1 + FromDIP(4), size.x, size.y, 5); + dc.DrawRoundedRectangle(size.x / 2 + FromDIP(3), -size.y / 1.1 - FromDIP(2), size.x, size.y, 3); + } +} + + +void AMSVirtualRoad::msw_rescale() +{ + Layout(); + Update(); + Refresh(); +} + +/************************************************* +Description:AMSLib +**************************************************/ +AMSLib::AMSLib(wxWindow *parent, std::string ams_idx, Caninfo info) +{ + m_border_color = (wxColour(130, 130, 128)); + m_road_def_color = AMS_CONTROL_GRAY500; + wxWindow::SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); + create(parent); + + Bind(wxEVT_PAINT, &AMSLib::paintEvent, this); + Bind(wxEVT_ENTER_WINDOW, &AMSLib::on_enter_window, this); + Bind(wxEVT_LEAVE_WINDOW, &AMSLib::on_leave_window, this); + Bind(wxEVT_LEFT_DOWN, &AMSLib::on_left_down, this); + + Update(info, ams_idx, false); +} + +AMSLib::~AMSLib() +{ +} + +void AMSLib::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +{ + wxWindow::Create(parent, id, pos, size); + + SetSize(AMS_CAN_LIB_SIZE); + SetMinSize(AMS_CAN_LIB_SIZE); + SetMaxSize(AMS_CAN_LIB_SIZE); + auto m_sizer_body = new wxBoxSizer(wxVERTICAL); + + wxBoxSizer *m_sizer_edit = new wxBoxSizer(wxHORIZONTAL); + + m_bitmap_editable = ScalableBitmap(this, "ams_editable", 14); + m_bitmap_editable_light = ScalableBitmap(this, "ams_editable_light", 14); + m_bitmap_readonly = ScalableBitmap(this, "ams_readonly", 14); + m_bitmap_readonly_light = ScalableBitmap(this, "ams_readonly_light", 14); + m_bitmap_transparent = ScalableBitmap(this, "transparent_ams_lib", 68); + + m_bitmap_extra_tray_left = ScalableBitmap(this, "extra_ams_tray_left", 80); + m_bitmap_extra_tray_right = ScalableBitmap(this, "extra_ams_tray_right", 80); + + m_bitmap_extra_tray_left_hover = ScalableBitmap(this, "extra_ams_tray_left_hover", 80); + m_bitmap_extra_tray_right_hover = ScalableBitmap(this, "extra_ams_tray_right_hover", 80); + + m_bitmap_extra_tray_left_selected = ScalableBitmap(this, "extra_ams_tray_left_selected", 80); + m_bitmap_extra_tray_right_selected = ScalableBitmap(this, "extra_ams_tray_right_selected", 80); + + + m_sizer_body->Add(0, 0, 1, wxEXPAND, 0); + m_sizer_body->Add(m_sizer_edit, 0, wxALIGN_CENTER, 0); + m_sizer_body->Add(0, 0, 0, wxBOTTOM, GetSize().y * 0.12); + SetSizer(m_sizer_body); + Layout(); +} + +void AMSLib::on_enter_window(wxMouseEvent &evt) +{ + m_hover = true; + Refresh(); +} + +void AMSLib::on_leave_window(wxMouseEvent &evt) +{ + m_hover = false; + Refresh(); +} + +void AMSLib::on_left_down(wxMouseEvent &evt) +{ + if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE) { + auto size = GetSize(); + auto pos = evt.GetPosition(); + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND || + m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { + + auto left = FromDIP(10); + auto right = size.x - FromDIP(10); + auto top = 0; + auto bottom = 0; + + if (m_ams_model == AMSModel::GENERIC_AMS || m_ams_model == AMSModel::N3F_AMS || m_ams_model == AMSModel::N3S_AMS || m_ams_model == AMSModel::EXT_AMS) { + top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetBmpSize().y); + bottom = size.y - FromDIP(15); + } + else if (m_ams_model == AMSModel::AMS_LITE) { + top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y); + bottom = size.y - FromDIP(20); + } + + if (pos.x >= left && pos.x <= right && pos.y >= top && top <= bottom) { + if (m_selected) { + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { + post_event(wxCommandEvent(EVT_VAMS_ON_FILAMENT_EDIT)); + } + else { + post_event(wxCommandEvent(EVT_AMS_ON_FILAMENT_EDIT)); + } + } else { + BOOST_LOG_TRIVIAL(trace) << "current amslib is not selected"; + } + } + } + } +} + + +void AMSLib::paintEvent(wxPaintEvent &evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSLib::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 + + // text + if (m_ams_model == AMSModel::AMS_LITE) { + render_lite_text(dc); + } + else{ + render_generic_text(dc); + } +} + +void AMSLib::render_lite_text(wxDC& dc) +{ + auto tmp_lib_colour = m_info.material_colour; + + change_the_opacity(tmp_lib_colour); + auto temp_text_colour = AMS_CONTROL_GRAY800; + + if (tmp_lib_colour.GetLuminance() < 0.6) { + temp_text_colour = AMS_CONTROL_WHITE_COLOUR; + } + else { + temp_text_colour = AMS_CONTROL_GRAY800; + } + + if (m_info.material_remain < 50) { + temp_text_colour = AMS_CONTROL_GRAY800; + } + + if (tmp_lib_colour.Alpha() == 0) { + temp_text_colour = AMS_CONTROL_GRAY800; + } + + dc.SetFont(::Label::Body_13); + dc.SetTextForeground(temp_text_colour); + + auto libsize = GetSize(); + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND + || m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND + || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { + + if (m_info.material_name.empty()) { + auto tsize = dc.GetMultiLineTextExtent("?"); + auto pot = wxPoint(0, 0); + pot = wxPoint((libsize.x - tsize.x) / 2 + FromDIP(2), (libsize.y - tsize.y) / 2 - FromDIP(5)); + dc.DrawText("?", pot); + } + else { + auto tsize = dc.GetMultiLineTextExtent(m_info.material_name); + std::vector split_char_arr = { " ", "-" }; + bool has_split = false; + std::string has_split_char = " "; + + for (std::string split_char : split_char_arr) { + if (m_info.material_name.find(split_char) != std::string::npos) { + has_split = true; + has_split_char = split_char; + } + } + + if (has_split) { + dc.SetFont(::Label::Body_10); + auto line_top = m_info.material_name.substr(0, m_info.material_name.find(has_split_char)); + auto line_bottom = m_info.material_name.substr(m_info.material_name.find(has_split_char)); + + auto line_top_tsize = dc.GetMultiLineTextExtent(line_top); + auto line_bottom_tsize = dc.GetMultiLineTextExtent(line_bottom); + + auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2 + FromDIP(3), (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y); + dc.DrawText(line_top, pot_top); + + auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2 + FromDIP(3), (libsize.y - line_bottom_tsize.y) / 2); + dc.DrawText(line_bottom, pot_bottom); + + + } + else { + dc.SetFont(::Label::Body_10); + auto pot = wxPoint(0, 0); + if (m_obj ) { + pot = wxPoint((libsize.x - tsize.x) / 2 + FromDIP(6), (libsize.y - tsize.y) / 2 - FromDIP(5)); + } + dc.DrawText(m_info.material_name, pot); + } + } + } + + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_EMPTY) { + auto tsize = dc.GetMultiLineTextExtent("/"); + auto pot = wxPoint((libsize.x - tsize.x) / 2 + FromDIP(2), (libsize.y - tsize.y) / 2 + FromDIP(3)); + dc.DrawText("/", pot); + } +} + +void AMSLib::render_generic_text(wxDC &dc) +{ + bool show_k_value = true; + if (m_obj && (m_obj->cali_version >= 0) && (abs(m_info.k - 0) < 1e-3)) { + show_k_value = false; + } + + auto tmp_lib_colour = m_info.material_colour; + change_the_opacity(tmp_lib_colour); + + auto temp_text_colour = AMS_CONTROL_GRAY800; + + if (tmp_lib_colour.GetLuminance() < 0.6) { + temp_text_colour = AMS_CONTROL_WHITE_COLOUR; + } + else { + temp_text_colour = AMS_CONTROL_GRAY800; + } + + if (m_info.material_remain < 50) { + temp_text_colour = AMS_CONTROL_GRAY800; + } + + if (tmp_lib_colour.Alpha() == 0) { + temp_text_colour = AMS_CONTROL_GRAY800; + } + + dc.SetFont(::Label::Body_13); + dc.SetTextForeground(temp_text_colour); + auto alpha = m_info.material_colour.Alpha(); + if (alpha != 0 && alpha != 255 && alpha != 254) { + dc.SetTextForeground(*wxBLACK); + } + + auto libsize = GetSize(); + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND + || m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND + || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) { + + if (m_info.material_name.empty() /*&& m_info.material_state != AMSCanType::AMS_CAN_TYPE_VIRTUAL*/) { + auto tsize = dc.GetMultiLineTextExtent("?"); + auto pot = wxPoint(0, 0); + + if (m_obj && show_k_value) { + pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9)); + } + else { + pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 + FromDIP(3)); + } + dc.DrawText("?", pot); + + } + else { + auto tsize = dc.GetMultiLineTextExtent(m_info.material_name); + std::vector split_char_arr = { " ", "-" }; + bool has_split = false; + std::string has_split_char = " "; + + for (std::string split_char : split_char_arr) { + if (m_info.material_name.find(split_char) != std::string::npos) { + has_split = true; + has_split_char = split_char; + } + } + + + if (has_split) { + dc.SetFont(::Label::Body_12); + + auto line_top = m_info.material_name.substr(0, m_info.material_name.find(has_split_char)); + auto line_bottom = m_info.material_name.substr(m_info.material_name.find(has_split_char)); + + auto line_top_tsize = dc.GetMultiLineTextExtent(line_top); + auto line_bottom_tsize = dc.GetMultiLineTextExtent(line_bottom); + + if (!m_show_kn) { + auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2, (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y + FromDIP(6)); + dc.DrawText(line_top, pot_top); + + + auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2, (libsize.y - line_bottom_tsize.y) / 2 + FromDIP(4)); + dc.DrawText(line_bottom, pot_bottom); + } + else { + auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2, (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y - FromDIP(6)); + dc.DrawText(line_top, pot_top); + + auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2, (libsize.y - line_bottom_tsize.y) / 2 - FromDIP(8)); + dc.DrawText(line_bottom, pot_bottom); + } + + + } + else { + auto pot = wxPoint(0, 0); + if (m_obj && show_k_value) { + pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9)); + } else { + pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 + FromDIP(3)); + } + dc.DrawText(m_info.material_name, pot); + } + } + + //draw k&n + if (m_obj && show_k_value) { + if (m_show_kn) { + wxString str_k = wxString::Format("K %1.3f", m_info.k); + wxString str_n = wxString::Format("N %1.3f", m_info.n); + dc.SetFont(::Label::Body_11); + auto tsize = dc.GetMultiLineTextExtent(str_k); + auto pot_k = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9) + tsize.y); + dc.DrawText(str_k, pot_k); + } + } + } + + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_EMPTY) { + auto tsize = dc.GetMultiLineTextExtent(_L("Empty")); + auto pot = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 + FromDIP(3)); + dc.DrawText(_L("Empty"), pot); + } +} + +void AMSLib::doRender(wxDC &dc) +{ + if (m_ams_model == AMSModel::AMS_LITE) { + render_lite_lib(dc); + } + else { + render_generic_lib(dc); + } +} + +void AMSLib::render_lite_lib(wxDC& dc) +{ + wxSize size = GetSize(); + + ScalableBitmap tray_bitmap = m_can_index <= 1 ? m_bitmap_extra_tray_left : m_bitmap_extra_tray_right; + ScalableBitmap tray_bitmap_hover = m_can_index <= 1 ? m_bitmap_extra_tray_left_hover : m_bitmap_extra_tray_right_hover; + ScalableBitmap tray_bitmap_selected = m_can_index <= 1 ? m_bitmap_extra_tray_left_selected : m_bitmap_extra_tray_right_selected; + + + auto tmp_lib_colour = m_info.material_colour; + change_the_opacity(tmp_lib_colour); + + auto temp_bitmap_third = m_bitmap_editable_light; + auto temp_bitmap_brand = m_bitmap_readonly_light; + + //draw road + + + dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + + if (m_pass_road) { + dc.SetPen(wxPen(m_info.material_colour, 6, wxPENSTYLE_SOLID)); + } + + if (m_can_index == 0 || m_can_index == 3) { + dc.DrawLine(size.x / 2, size.y / 2, size.x / 2, size.y); + } + else { + dc.DrawLine(size.x / 2, size.y / 2, size.x / 2, 0); + } + + //draw def background + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR))); + dc.DrawRoundedRectangle(FromDIP(10), FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20), 0); + + if (tmp_lib_colour.GetLuminance() < 0.6) { + temp_bitmap_third = m_bitmap_editable_light; + temp_bitmap_brand = m_bitmap_readonly_light; + } + else { + temp_bitmap_third = m_bitmap_editable; + temp_bitmap_brand = m_bitmap_readonly; + } + + if (m_info.material_remain < 50) { + temp_bitmap_third = m_bitmap_editable; + temp_bitmap_brand = m_bitmap_readonly; + } + + if (tmp_lib_colour.Alpha() == 0) { + temp_bitmap_third = m_bitmap_editable; + temp_bitmap_brand = m_bitmap_readonly; + } + + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + if (m_info.material_cols.size() > 1) { + int left = FromDIP(10); + int gwidth = std::round(size.x / (m_info.material_cols.size() - 1)); + //gradient + if (m_info.ctype == 0) { + for (int i = 0; i < m_info.material_cols.size() - 1; i++) { + auto rect = wxRect(left, FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20)); + dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i + 1], wxEAST); + left += gwidth; + } + } + else { + int cols_size = m_info.material_cols.size(); + for (int i = 0; i < cols_size; i++) { + dc.SetBrush(wxBrush(m_info.material_cols[i])); + float x = FromDIP(10) + ((float)size.x - FromDIP(20)) * i / cols_size; + dc.DrawRoundedRectangle(x, FromDIP(10), ((float)size.x - FromDIP(20)) / cols_size, size.y - FromDIP(20), 0); + } + dc.SetBrush(wxBrush(tmp_lib_colour)); + } + } + else { + dc.SetBrush(wxBrush(tmp_lib_colour)); + dc.DrawRoundedRectangle(FromDIP(10), FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20), 0); + } + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(tmp_lib_colour)); + if (!m_disable_mode) { + // edit icon + if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE) + { + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) + dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y)); + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND) + dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetBmpSize().y)); + } + } + + // selected & hover + if (m_selected) { + dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2); + } + else if (!m_selected && m_hover) { + dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2); + } + else { + dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2); + } +} + + +void AMSLib::render_generic_lib(wxDC &dc) +{ + wxSize size = GetSize(); + auto tmp_lib_colour = m_info.material_colour; + change_the_opacity(tmp_lib_colour); + + auto temp_bitmap_third = m_bitmap_editable_light; + auto temp_bitmap_brand = m_bitmap_readonly_light; + + //draw def background + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(AMS_CONTROL_DEF_LIB_BK_COLOUR)); + dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4), size.x - FromDIP(8), size.y - FromDIP(8), m_radius); + + if (tmp_lib_colour.GetLuminance() < 0.6) { + temp_bitmap_third = m_bitmap_editable_light; + temp_bitmap_brand = m_bitmap_readonly_light; + } + else { + temp_bitmap_third = m_bitmap_editable; + temp_bitmap_brand = m_bitmap_readonly; + } + + if (m_info.material_remain < 50) { + temp_bitmap_third = m_bitmap_editable; + temp_bitmap_brand = m_bitmap_readonly; + } + + if (tmp_lib_colour.Alpha() == 0) { + temp_bitmap_third = m_bitmap_editable; + temp_bitmap_brand = m_bitmap_readonly; + } + + // selected + if (m_selected) { + dc.SetPen(wxPen(tmp_lib_colour, 2, wxPENSTYLE_SOLID)); + if (tmp_lib_colour.Alpha() == 0) { + dc.SetPen(wxPen(wxColour(tmp_lib_colour.Red(), tmp_lib_colour.Green(),tmp_lib_colour.Blue(),128), 2, wxPENSTYLE_SOLID)); + } + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + if (m_radius == 0) { + dc.DrawRectangle(0, 0, size.x, size.y); + } + else { + dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(1), size.y - FromDIP(1), m_radius); + } + + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(tmp_lib_colour)); + } + + if (!m_selected && m_hover) { + dc.SetPen(wxPen(AMS_CONTROL_BRAND_COLOUR, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + if (m_radius == 0) { + dc.DrawRectangle(0, 0, size.x, size.y); + } + else { + dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(1), size.y - FromDIP(1), m_radius); + } + + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(tmp_lib_colour)); + } + else { + dc.SetPen(wxPen(tmp_lib_colour, 1, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(tmp_lib_colour)); + } + + //draw remain + auto alpha = m_info.material_colour.Alpha(); + int height = size.y - FromDIP(8); + int curr_height = height * float(m_info.material_remain * 1.0 / 100.0); + dc.SetFont(::Label::Body_13); + + int top = height - curr_height; + + if (curr_height >= FromDIP(6)) { + + //transparent + + if (alpha == 0) { + dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4)); + } + else if (alpha != 255 && alpha != 254) { + if (transparent_changed) { + std::string rgb = (tmp_lib_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString(); + if (rgb.size() == 9) { + //delete alpha value + rgb = rgb.substr(0, rgb.size() - 2); + } + float alpha_f = 0.7 * tmp_lib_colour.Alpha() / 255.0; + std::vector replace; + replace.push_back(rgb); + std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f); + replace.push_back(fill_replace); + m_bitmap_transparent = ScalableBitmap(this, "transparent_ams_lib", 68, false, false, true, replace); + transparent_changed = false; + + } + dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4)); + } + //gradient + if (m_info.material_cols.size() > 1) { + int left = FromDIP(4); + float total_width = size.x - FromDIP(8); + int gwidth = std::round(total_width / (m_info.material_cols.size() - 1)); + //gradient + if (m_info.ctype == 0) { + for (int i = 0; i < m_info.material_cols.size() - 1; i++) { + + if ((left + gwidth) > (size.x - FromDIP(8))) { + gwidth = (size.x - FromDIP(4)) - left; + } + + auto rect = wxRect(left, height - curr_height + FromDIP(4), gwidth, curr_height); + dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i + 1], wxEAST); + left += gwidth; + } + } + else { + //multicolour + gwidth = std::round(total_width / m_info.material_cols.size()); + for (int i = 0; i < m_info.material_cols.size(); i++) { + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(m_info.material_cols[i])); + if (i == 0 || i == m_info.material_cols.size() - 1) { +#ifdef __APPLE__ + dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height, m_radius); +#else + dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height, m_radius - 1); +#endif + //add rectangle + int dr_gwidth = std::round(gwidth * 0.6); + if (i == 0) { + dc.DrawRectangle(left + gwidth - dr_gwidth, height - curr_height + FromDIP(4), dr_gwidth, curr_height); + } + else { + dc.DrawRectangle(left + gwidth*i, height - curr_height + FromDIP(4), dr_gwidth, curr_height); + } + } + else { + dc.DrawRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height); + } + } + //reset pen and brush + if (m_selected || m_hover) { + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(tmp_lib_colour)); + } + else { + dc.SetPen(wxPen(tmp_lib_colour, 1, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(tmp_lib_colour)); + } + } + } + else { + auto brush = dc.GetBrush(); + if (alpha != 0 && alpha != 255 && alpha != 254) dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); +#ifdef __APPLE__ + dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius); +#else + dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius - 1); +#endif + dc.SetBrush(brush); + } + } + + if (top > 2) { + if (curr_height >= FromDIP(6)) { + dc.DrawRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), FromDIP(2)); + if (alpha != 255 && alpha != 254) { + dc.SetPen(wxPen(*wxWHITE)); + dc.SetBrush(wxBrush(*wxWHITE)); +#ifdef __APPLE__ + dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) , size.x - FromDIP(8), top, m_radius); +#else + dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) , size.x - FromDIP(8), top, m_radius - 1); +#endif + } + if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) { + dc.SetPen(wxPen(wxColour(130, 129, 128), 1, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + dc.DrawLine(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(4), FromDIP(4) + top); + } + } + else { + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) { + dc.SetPen(wxPen(wxColour(130, 129, 128), 2, wxPENSTYLE_SOLID)); + } + else { + dc.SetPen(wxPen(tmp_lib_colour, 2, wxPENSTYLE_SOLID)); + } + +#ifdef __APPLE__ + dc.DrawLine(FromDIP(5), FromDIP(4) + height - FromDIP(2), size.x - FromDIP(5), FromDIP(4) + height - FromDIP(2)); + dc.DrawLine(FromDIP(6), FromDIP(4) + height - FromDIP(1), size.x - FromDIP(6), FromDIP(4) + height - FromDIP(1)); +#else + dc.DrawLine(FromDIP(4), FromDIP(4) + height - FromDIP(2), size.x - FromDIP(4), FromDIP(4) + height - FromDIP(2)); + dc.DrawLine(FromDIP(5), FromDIP(4) + height - FromDIP(1), size.x - FromDIP(5), FromDIP(4) + height - FromDIP(1)); +#endif + } + } + + //border + dc.SetPen(wxPen(wxColour(130, 130, 128), 1, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); +#ifdef __APPLE__ + dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4), size.x - FromDIP(7), size.y - FromDIP(7), m_radius); +#else + dc.DrawRoundedRectangle(FromDIP(3), FromDIP(3), size.x - FromDIP(6), size.y - FromDIP(6), m_radius); +#endif + + if (!m_disable_mode) { + // edit icon + if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE) + { + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL) + dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y)); + if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND) + dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y)); + } + } +} + +void AMSLib::on_pass_road(bool pass) +{ + if (m_pass_road != pass) { + m_pass_road = pass; + Refresh(); + } +} + +void AMSLib::Update(Caninfo info, std::string ams_idx, bool refresh) +{ + DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) return; + if (dev->get_selected_machine() && dev->get_selected_machine() != m_obj) { + m_obj = dev->get_selected_machine(); + } + if (info.material_colour.Alpha() != 0 && info.material_colour.Alpha() != 255 && info.material_colour.Alpha() != 254 && m_info.material_colour != info.material_colour) { + transparent_changed = true; + } + + m_info = info; + m_ams_id = ams_idx; + m_slot_id = info.can_id; + if (refresh) Refresh(); +} + +wxColour AMSLib::GetLibColour() { return m_info.material_colour; } + +void AMSLib::OnSelected() +{ + if (!wxWindow::IsEnabled()) return; + if (m_unable_selected) return; + + post_event(wxCommandEvent(EVT_AMS_ON_SELECTED)); + m_selected = true; + Refresh(); +} + +void AMSLib::post_event(wxCommandEvent &&event) +{ + //int tray_id = atoi(m_ams_id.c_str()) * 4 + atoi(m_info.can_id.c_str()); + //event.SetString(m_info.can_id); + event.SetString(m_slot_id); + event.SetInt(std::stoi(m_ams_id)); + event.SetEventObject(m_parent); + wxPostEvent(m_parent, event); + event.Skip(); +} + +void AMSLib::UnSelected() +{ + m_selected = false; + Refresh(); +} + +bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); } + +void AMSLib::msw_rescale() +{ + m_bitmap_transparent.msw_rescale(); +} + +/************************************************* +Description:AMSRoad +**************************************************/ +AMSRoad::AMSRoad() : m_road_def_color(AMS_CONTROL_GRAY500), m_road_color(AMS_CONTROL_GRAY500) {} +AMSRoad::AMSRoad(wxWindow *parent, wxWindowID id, Caninfo info, int canindex, int maxcan, const wxPoint &pos, const wxSize &size) + : AMSRoad() +{ + m_info = info; + m_canindex = canindex; + // road type + auto mode = AMSRoadMode::AMS_ROAD_MODE_END; + if (m_canindex == 0 && maxcan == 1) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_NONE; + } else if (m_canindex == 0 && maxcan > 1) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_END; + } else if (m_canindex < (maxcan - 1)) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT; + } else if (m_canindex == (maxcan - 1)) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT; + } else if (m_canindex == -1 && maxcan == -1) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY; + } + else { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_NONE_ANY_ROAD; + } + + if (m_rode_mode != AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY) { + create(parent, id, pos, size); + } + else { + wxSize virtual_size(size.x - 1, size.y + 2); + create(parent, id, pos, virtual_size); + + } + + Bind(wxEVT_PAINT, &AMSRoad::paintEvent, this); + wxWindow::SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); +} + +void AMSRoad::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) { wxWindow::Create(parent, id, pos, size); } + +void AMSRoad::Update(AMSinfo amsinfo, Caninfo info, int canindex, int maxcan) +{ + m_amsinfo = amsinfo; + m_info = info; + m_canindex = canindex; + if (m_canindex == 0 && maxcan == 1) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_END_ONLY; + } else if (m_canindex == 0 && maxcan > 1) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_END; + } else if (m_canindex < (maxcan - 1)) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT; + } else if (m_canindex == (maxcan - 1)) { + m_rode_mode = AMSRoadMode::AMS_ROAD_MODE_LEFT; + } + m_pass_rode_mode.push_back(AMSPassRoadMode::AMS_ROAD_MODE_NONE); + Refresh(); +} + +void AMSRoad::OnVamsLoading(bool load, wxColour col /*= AMS_CONTROL_GRAY500*/) +{ + m_vams_loading = load; + if(load)m_road_color = col; + Refresh(); +} + +void AMSRoad::SetPassRoadColour(wxColour col) { m_road_color = col; } + +void AMSRoad::SetMode(AMSRoadMode mode) +{ + m_rode_mode = mode; + Refresh(); +} + +void AMSRoad::paintEvent(wxPaintEvent &evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSRoad::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 AMSRoad::doRender(wxDC &dc) +{ + wxSize size = GetSize(); + + dc.SetPen(wxPen(m_road_def_color, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + // left mode + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT) { dc.DrawRoundedRectangle(-10, -10, size.x / 2 + 10, size.y * 0.6 + 10, 4); } + + // left right mode + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT) { + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + dc.DrawLine(0, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); + } + + // end mode + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END) { + dc.SetBrush(wxBrush(m_road_def_color)); + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); + dc.DrawLine(size.x / 2, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); + } + + // end mode only + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END_ONLY) { + dc.SetBrush(wxBrush(m_road_def_color)); + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); + } + + // end none + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_NONE) { + dc.SetBrush(wxBrush(m_road_def_color)); + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); + dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); + // dc.DrawLine(size.x / 2, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); + } + + //virtual road + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY) { + dc.SetBrush(wxBrush(m_road_def_color)); + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y - 1); + } + + // mode none + // if (m_pass_rode_mode.size() == 1 && m_pass_rode_mode[0] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) return; + + if (m_road_color.Alpha() == 0) {dc.SetPen(wxPen(*wxWHITE, m_passroad_width, wxPENSTYLE_SOLID));} + else {dc.SetPen(wxPen(m_road_color, m_passroad_width, wxPENSTYLE_SOLID));} + + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + + // left pass mode + for (auto pass_mode : m_pass_rode_mode) { + switch (pass_mode) { + case AMSPassRoadMode::AMS_ROAD_MODE_LEFT: dc.DrawRoundedRectangle(-10, -10, size.x / 2 + 10, size.y * 0.6 + 10, 4); break; + + case AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT: dc.DrawLine(0, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); break; + + case AMSPassRoadMode::AMS_ROAD_MODE_END_TOP: dc.DrawLine(size.x / 2, -1, size.x / 2, size.y * 0.6 - 1); break; + + case AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM: dc.DrawLine(size.x / 2, size.y * 0.6, size.x / 2, size.y); break; + + case AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT: dc.DrawLine(size.x / 2, size.y * 0.6 - 1, size.x, size.y * 0.6 - 1); break; + + default: break; + } + } + + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_VIRTUAL_TRAY && m_vams_loading) { + dc.DrawLine(size.x / 2, -1, size.x / 2, size.y - 1); + } + + // end mode + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END) { + dc.SetPen(wxPen(m_road_def_color, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(m_road_def_color)); + dc.DrawRoundedRectangle(size.x * 0.37 / 2, size.y * 0.6 - size.y / 6, size.x * 0.63, size.y / 3, m_radius); + } +} + +void AMSRoad::UpdatePassRoad(int tag_index, AMSPassRoadType type, AMSPassRoadSTEP step) {} + +void AMSRoad::OnPassRoad(std::vector prord_list) +{ + // AMS_ROAD_MODE_NONE, AMS_ROAD_MODE_LEFT, AMS_ROAD_MODE_LEFT_RIGHT, AMS_ROAD_MODE_END_TOP, AMS_ROAD_MODE_END_BOTTOM, AMS_ROAD_MODE_END_RIGHT, + // AMS_ROAD_MODE_LEFT, AMS_ROAD_MODE_LEFT_RIGHT, AMS_ROAD_MODE_END, + + m_pass_rode_mode.clear(); + auto left_types = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE, AMSPassRoadMode::AMS_ROAD_MODE_LEFT}; + auto left_right_types = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE, AMSPassRoadMode::AMS_ROAD_MODE_LEFT, AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT}; + auto end_types = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE, AMSPassRoadMode::AMS_ROAD_MODE_END_TOP, AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM, + AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT}; + + // left + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT) { + for (auto i = 0; i < prord_list.size(); i++) { + std::vector::iterator iter = std::find(left_types.begin(), left_types.end(), prord_list[i]); + if (iter != left_types.end()) m_pass_rode_mode.push_back(prord_list[i]); + + if (prord_list[i] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) { + m_pass_rode_mode = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE}; + break; + } + } + } + + // left right + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_LEFT_RIGHT) { + for (auto i = 0; i < prord_list.size(); i++) { + std::vector::iterator iter = std::find(left_right_types.begin(), left_right_types.end(), prord_list[i]); + if (iter != left_right_types.end()) m_pass_rode_mode.push_back(prord_list[i]); + + if (prord_list[i] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) { + m_pass_rode_mode = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE}; + break; + } + } + } + + // left end + if (m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END || m_rode_mode == AMSRoadMode::AMS_ROAD_MODE_END_ONLY) { + for (auto i = 0; i < prord_list.size(); i++) { + std::vector::iterator iter = std::find(end_types.begin(), end_types.end(), prord_list[i]); + if (iter != end_types.end()) m_pass_rode_mode.push_back(prord_list[i]); + + if (prord_list[i] == AMSPassRoadMode::AMS_ROAD_MODE_NONE) { + m_pass_rode_mode = std::vector{AMSPassRoadMode::AMS_ROAD_MODE_NONE}; + break; + } + } + } +} + + +/************************************************* +Description:AMSPreview +**************************************************/ +AMSPreview::AMSPreview() {} + +AMSPreview::AMSPreview(wxWindow *parent, wxWindowID id, AMSinfo amsinfo, const wxSize cube_size, const wxPoint &pos, const wxSize &size) : AMSPreview() +{ + create(parent, id, pos, AMS_ITEM_SIZE); + m_amsinfo = amsinfo; + m_cube_size = cube_size; + Bind(wxEVT_PAINT, &AMSPreview::paintEvent, this); + Bind(wxEVT_ENTER_WINDOW, &AMSPreview::OnEnterWindow, this); + Bind(wxEVT_LEAVE_WINDOW, &AMSPreview::OnLeaveWindow, this); +} + +void AMSPreview::Open() +{ + m_open = true; + Show(); +} + +void AMSPreview::Close() +{ + m_open = false; + Hide(); +} + +void AMSPreview::Update(AMSinfo amsinfo) +{ + m_amsinfo = amsinfo; +} + +void AMSPreview::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +{ + m_ts_bitmap_cube = new ScalableBitmap(this, "ts_bitmap_cube", 14); + wxWindow::Create(parent, id, pos, size); + SetMinSize(AMS_ITEM_SIZE); + SetMaxSize(AMS_ITEM_SIZE); + SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_WHITE_COLOUR)); + Refresh(); +} + +void AMSPreview::OnEnterWindow(wxMouseEvent &evt) +{ + // m_hover = true; + // Refresh(); +} + +void AMSPreview::OnLeaveWindow(wxMouseEvent &evt) +{ + // m_hover = false; + // Refresh(); +} + +void AMSPreview::OnSelected() +{ + if (!wxWindow::IsEnabled()) { return; } + m_selected = true; + Refresh(); +} + +void AMSPreview::UnSelected() +{ + m_selected = false; + Refresh(); +} + +bool AMSPreview::Enable(bool enable) { return wxWindow::Enable(enable); } + +void AMSPreview::paintEvent(wxPaintEvent &evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSPreview::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 AMSPreview::doRender(wxDC &dc) +{ + wxSize size = GetSize(); + dc.SetPen(wxPen(StateColor::darkModeColorFor(m_background_colour))); + dc.SetBrush(wxBrush(StateColor::darkModeColorFor(m_background_colour))); + dc.DrawRoundedRectangle(0, 0, size.x, size.y, 3); + + auto left = m_padding; + for (std::vector::iterator iter = m_amsinfo.cans.begin(); iter != m_amsinfo.cans.end(); iter++) { + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + + if (wxWindow::IsEnabled()) { + wxColour color = iter->material_colour; + change_the_opacity(color); + dc.SetBrush(wxBrush(color)); + } else { + dc.SetBrush(AMS_CONTROL_DISABLE_COLOUR); + } + + if (iter->material_cols.size() > 1) { + int fleft = left; + float total_width = AMS_ITEM_CUBE_SIZE.x; + int gwidth = std::round(total_width / (iter->material_cols.size() - 1)); + if (iter->ctype == 0) { + for (int i = 0; i < iter->material_cols.size() - 1; i++) { + + if ((fleft + gwidth) > (AMS_ITEM_CUBE_SIZE.x)) { + gwidth = (fleft + AMS_ITEM_CUBE_SIZE.x) - fleft; + } + + auto rect = wxRect(fleft, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, gwidth, AMS_ITEM_CUBE_SIZE.y); + dc.GradientFillLinear(rect, iter->material_cols[i], iter->material_cols[i + 1], wxEAST); + fleft += gwidth; + } + } else { + int cols_size = iter->material_cols.size(); + for (int i = 0; i < cols_size; i++) { + dc.SetBrush(wxBrush(iter->material_cols[i])); + float x = left + total_width * i / cols_size; + dc.DrawRoundedRectangle(x, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, total_width / cols_size, AMS_ITEM_CUBE_SIZE.y , 0); + } + } + + dc.SetPen(wxPen(StateColor::darkModeColorFor(m_background_colour))); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRoundedRectangle(left - 1, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2 - 1, AMS_ITEM_CUBE_SIZE.x + 2, AMS_ITEM_CUBE_SIZE.y + 2, 2); + + }else { + if (iter->material_colour.Alpha() == 0) { + dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2); + } + else { + wxRect rect(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y); + if(iter->material_state==AMSCanType::AMS_CAN_TYPE_EMPTY){ + dc.SetPen(wxPen(wxColor(0, 0, 0))); + dc.DrawRoundedRectangle(rect, 2); + + dc.DrawLine(rect.GetRight()-1, rect.GetTop()+1, rect.GetLeft()+1, rect.GetBottom()-1); + } + else { + dc.DrawRoundedRectangle(rect, 2); + } + } + + } + + + left += AMS_ITEM_CUBE_SIZE.x; + left += m_space; + } + + auto border_colour = AMS_CONTROL_BRAND_COLOUR; + if (!wxWindow::IsEnabled()) { border_colour = AMS_CONTROL_DISABLE_COLOUR; } + + if (m_hover) { + dc.SetPen(wxPen(border_colour, 2)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + dc.DrawRoundedRectangle(1, 1, size.x - 1, size.y - 1, 3); + + } + + if (m_selected) { + dc.SetPen(wxPen(border_colour, 2)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + dc.DrawRoundedRectangle(1, 1, size.x-1, size.y-1, 3); + } +} + +void AMSPreview::DoSetSize(int x, int y, int width, int height, int sizeFlags /*= wxSIZE_AUTO*/) { wxWindow::DoSetSize(x, y, width, height, sizeFlags); } + +/************************************************* +Description:AMSHumidity +**************************************************/ + +AMSHumidity::AMSHumidity() {} +AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wxPoint& pos, const wxSize& size) + : AMSHumidity() +{ + create(parent, id, pos, wxDefaultSize); + + for (int i = 1; i <= 5; i++) { ams_humidity_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_light", 16));} + for (int i = 1; i <= 5; i++) { ams_humidity_dark_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_dark", 16));} + for (int i = 1; i <= 5; i++) { ams_humidity_no_num_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_no_num_light", 16)); } + for (int i = 1; i <= 5; i++) { ams_humidity_no_num_dark_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_no_num_dark", 16)); } + + ams_sun_img = ScalableBitmap(this, "ams_drying", 16); + ams_drying_img = ScalableBitmap(this, "ams_is_drying", 16); + + Bind(wxEVT_PAINT, &AMSHumidity::paintEvent, this); + //wxWindow::SetBackgroundColour(AMS_CONTROL_DEF_HUMIDITY_BK_COLOUR); + + Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& e) { + if (m_show_humidity) { + auto mouse_pos = ClientToScreen(e.GetPosition()); + auto rect = ClientToScreen(wxPoint(0, 0)); + + if (mouse_pos.x > rect.x && + mouse_pos.y > rect.y) { + wxCommandEvent show_event(EVT_AMS_SHOW_HUMIDITY_TIPS); + + uiAmsHumidityInfo *info = new uiAmsHumidityInfo; + info->ams_id = m_amsinfo.ams_id; + info->humidity_level = m_amsinfo.ams_humidity; + info->humidity_percent = m_amsinfo.humidity_raw; + info->left_dry_time = m_amsinfo.left_dray_time; + info->current_temperature = m_amsinfo.current_temperature; + show_event.SetClientData(info); + wxPostEvent(GetParent()->GetParent(), show_event); + +#ifdef __WXMSW__ + wxCommandEvent close_event(EVT_CLEAR_SPEED_CONTROL); + wxPostEvent(GetParent()->GetParent(), close_event); +#endif // __WXMSW__ + + } + } + }); + + Update(info); +} + +void AMSHumidity::create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) { + wxWindow::Create(parent, id, pos, size); + SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); +} + + +void AMSHumidity::Update(AMSinfo amsinfo) +{ + if (m_amsinfo != amsinfo) + { + m_amsinfo = amsinfo; + update_size(); + Refresh(); + } +} + +void AMSHumidity::update_size() +{ + wxSize size; + if (m_amsinfo.humidity_raw != -1) { + size = AMS_HUMIDITY_SIZE; + } else { + size = AMS_HUMIDITY_NO_PERCENT_SIZE; + } + + if (!m_amsinfo.support_drying()) { size.x -= AMS_HUMIDITY_DRY_WIDTH; } + + SetMaxSize(size); + SetMinSize(size); + SetSize(size); +} + + +void AMSHumidity::paintEvent(wxPaintEvent& evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AMSHumidity::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 AMSHumidity::doRender(wxDC& dc) +{ + wxSize size = GetSize(); + + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(StateColor::darkModeColorFor(AMS_CONTROL_DEF_BLOCK_BK_COLOUR))); + // left mode + if (m_amsinfo.ams_humidity >= 1 && m_amsinfo.ams_humidity <= 5) { m_show_humidity = true; } + else { m_show_humidity = false; } + + if (m_show_humidity) { + //background + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetBrush(wxBrush(StateColor::darkModeColorFor(AMS_CONTROL_DEF_BLOCK_BK_COLOUR))); + dc.DrawRoundedRectangle(0, 0, (size.x), (size.y), (size.y / 2)); + + wxPoint pot; + if (m_amsinfo.humidity_raw != -1) /*image with no number + percentage*/ + { + // hum image + ScalableBitmap hum_img; + if (!wxGetApp().dark_mode()) { + hum_img = ams_humidity_no_num_imgs[m_amsinfo.ams_humidity - 1]; + } else { + hum_img = ams_humidity_no_num_dark_imgs[m_amsinfo.ams_humidity - 1]; + } + + pot = wxPoint(FromDIP(5), ((size.y - hum_img.GetBmpSize().y) / 2)); + dc.DrawBitmap(hum_img.bmp(), pot); + pot.x += hum_img.GetBmpSize().x + FromDIP(3); + + // percentage + wxString hum_percentage(std::to_string(m_amsinfo.humidity_raw)); + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + dc.SetFont(Label::Body_14); + dc.SetTextForeground(StateColor::darkModeColorFor(AMS_CONTROL_BLACK_COLOUR)); + + //WxFontUtils::get_suitable_font_size(0.7 * size.GetHeight(), dc); + auto tsize1 = dc.GetMultiLineTextExtent(hum_percentage); + pot.y = (size.y - tsize1.y) / 2; + dc.DrawText(hum_percentage, pot); + pot.x += (tsize1.x + FromDIP(3)); + + // percentage sign + dc.SetFont(Label::Body_12); + //WxFontUtils::get_suitable_font_size(0.5 * size.GetHeight(), dc); + auto tsize2 = dc.GetMultiLineTextExtent(_L("%")); + pot.y = pot.y + ((tsize1.y - tsize2.y) / 2) + FromDIP(2); + dc.DrawText(_L("%"), pot); + + pot.x += tsize2.x; + } + else /*image with number*/ + { + // hum image + ScalableBitmap hum_img; + if (!wxGetApp().dark_mode()) { + hum_img = ams_humidity_imgs[m_amsinfo.ams_humidity - 1]; + } else { + hum_img = ams_humidity_dark_imgs[m_amsinfo.ams_humidity - 1]; + } + + pot = wxPoint(FromDIP(5), ((size.y - hum_img.GetBmpSize().y) / 2)); + dc.DrawBitmap(hum_img.bmp(), pot); + pot.x = pot.x + hum_img.GetBmpSize().x; + } + + if (m_amsinfo.support_drying()) + { + pot.x += FromDIP(2);// spacing + + // vertical line + dc.SetPen(wxPen(wxColour(194, 194, 194))); + dc.SetBrush(wxBrush(wxColour(194, 194, 194))); + dc.DrawLine(pot.x, GetSize().y / 2 - FromDIP(10), pot.x, GetSize().y / 2 + FromDIP(10)); + + // sun image + dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); + pot.x += ((size.GetWidth() - pot.x) - ams_drying_img.GetBmpWidth()) / 2;// spacing + if (m_amsinfo.left_dray_time > 0) { + pot.y = (size.y - ams_drying_img.GetBmpHeight()) / 2; + dc.DrawBitmap(ams_drying_img.bmp(), pot); + } else { + pot.y = (size.y - ams_sun_img.GetBmpHeight()) / 2; + dc.DrawBitmap(ams_sun_img.bmp(), pot); + } + } + } + else { + //to do ... + } +} + +void AMSHumidity::msw_rescale() { + for (auto& img : ams_humidity_imgs) { img.msw_rescale();} + for (auto& img : ams_humidity_dark_imgs) { img.msw_rescale(); } + for (auto &img : ams_humidity_no_num_imgs) { img.msw_rescale(); } + for (auto &img : ams_humidity_no_num_dark_imgs) { img.msw_rescale(); } + ams_sun_img.msw_rescale(); + ams_drying_img.msw_rescale(); + + Layout(); + Refresh(); +} + + +/************************************************* +Description:AmsItem +**************************************************/ + +AmsItem::AmsItem() {} + +AmsItem::AmsItem(wxWindow *parent,AMSinfo info, AMSModel model) : AmsItem() +{ + m_bitmap_extra_framework = ScalableBitmap(this, "ams_extra_framework_mid", 140); + + SetDoubleBuffered(true); + m_ams_model = model; + m_info = info; + + wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, AMS_CANS_WINDOW_SIZE); + + create(parent); + + SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); + Bind(wxEVT_PAINT, &AmsItem::paintEvent, this); +} + +void AmsItem::create(wxWindow *parent) +{ + Freeze(); + if (m_ams_model == AMSModel::GENERIC_AMS || m_ams_model == AMSModel::N3F_AMS || m_ams_model == AMSModel::N3S_AMS) { + sizer_can = new wxBoxSizer(wxHORIZONTAL); + sizer_item = new wxBoxSizer(wxVERTICAL); + for (auto it = m_info.cans.begin(); it != m_info.cans.end(); it++) { + AddCan(*it, m_can_count, m_info.cans.size(), sizer_can); + m_can_count++; + } + m_humidity = new AMSHumidity(this, wxID_ANY, m_info); + sizer_item->Add(m_humidity, 0, wxALIGN_CENTER_HORIZONTAL, 0); + sizer_item->Add(sizer_can, 0, wxALIGN_LEFT, 0); + SetSizer(sizer_item); + } + else if(m_ams_model == AMSModel::AMS_LITE) { + sizer_can = new wxBoxSizer(wxVERTICAL); + sizer_can_middle = new wxBoxSizer(wxHORIZONTAL); + sizer_can_left = new wxBoxSizer(wxVERTICAL); + sizer_can_right = new wxBoxSizer(wxVERTICAL); + + sizer_can_left->Add(0,0,0,wxTOP,FromDIP(8)); + + for (auto it = m_info.cans.begin(); it != m_info.cans.end(); it++) { + if (m_can_count <= 1) { + AddCan(*it, m_can_count, m_info.cans.size(), sizer_can_left); + if (m_can_count == 0) { + sizer_can_left->Add(0,0,0,wxTOP,FromDIP(20)); + } + } + else { + AddCan(*it, m_can_count, m_info.cans.size(), sizer_can_right); + if (m_can_count == 2) { + sizer_can_right->Prepend(0, 0, 0, wxTOP, FromDIP(20)); + } + } + + m_can_count++; + } + + sizer_can_right->Prepend(0,0,0,wxTOP,FromDIP(8)); + sizer_can_middle->Add(0, 0, 0, wxLEFT, FromDIP(8)); + sizer_can_middle->Add(sizer_can_left, 0, wxALL, 0); + sizer_can_middle->Add( 0, 0, 0, wxLEFT, FromDIP(20) ); + sizer_can_middle->Add(sizer_can_right, 0, wxALL, 0); + sizer_can->Add(sizer_can_middle, 1, wxALIGN_CENTER, 0); + SetSizer(sizer_can); + } + + + Layout(); + Fit(); + Thaw(); +} + +void AmsItem::AddCan(Caninfo caninfo, int canindex, int maxcan, wxBoxSizer* sizer) +{ + auto amscan = new wxWindow(this, wxID_ANY); + + amscan->SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); + + wxBoxSizer* m_sizer_ams = new wxBoxSizer(wxVERTICAL); + + + auto m_panel_refresh = new AMSrefresh(amscan, m_can_count, caninfo); + m_can_refresh_list[caninfo.can_id] = m_panel_refresh; + + auto m_panel_lib = new AMSLib(amscan, m_info.ams_id, caninfo); + + m_panel_lib->Bind(wxEVT_LEFT_DOWN, [this, canindex](wxMouseEvent& ev) { + m_canlib_selection = canindex; + // m_canlib_id = caninfo.can_id; + + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (lib->m_can_index == m_canlib_selection) { + wxCommandEvent evt(EVT_AMS_UNSELETED_VAMS); + evt.SetString(m_info.ams_id); + wxPostEvent(GetParent()->GetParent(), evt); + lib->OnSelected(); + } + else { + lib->UnSelected(); + } + } + ev.Skip(); + }); + + m_panel_lib->m_ams_model = m_ams_model; + m_panel_lib->m_ams_id = m_info.ams_id; + m_panel_lib->m_slot_id = caninfo.can_id; + m_panel_lib->m_info.can_id = caninfo.can_id; + m_panel_lib->m_can_index = canindex; + + auto m_panel_road = new AMSRoad(amscan, wxID_ANY, caninfo, canindex, maxcan, wxDefaultPosition, AMS_CAN_ROAD_SIZE); + + if (m_ams_model != AMSModel::AMS_LITE && m_ams_model != AMSModel::EXT_AMS) { + //m_sizer_ams->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(2)); + m_sizer_ams->Add(m_panel_refresh, 0, wxALIGN_CENTER_HORIZONTAL, 0); + //m_sizer_ams->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(2)); + m_sizer_ams->Add(m_panel_lib, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(3)); + m_sizer_ams->Add(m_panel_road, 0, wxALL, 0); + } + else if (m_ams_model == AMSModel::AMS_LITE) + { + m_sizer_ams = new wxBoxSizer(wxHORIZONTAL); + m_panel_road->Hide(); + + if (canindex <= 1) { + m_sizer_ams->Add(m_panel_refresh, 0, wxALIGN_CENTER, 0); + m_sizer_ams->Add(m_panel_lib, 0, wxALIGN_CENTER, 0); + } + else { + m_sizer_ams->Add(m_panel_lib, 0, wxALIGN_CENTER, 0); + m_sizer_ams->Add(m_panel_refresh, 0, wxALIGN_CENTER, 0); + } + } + amscan->SetSizer(m_sizer_ams); + amscan->Layout(); + amscan->Fit(); + + if (m_ams_model != AMSModel::AMS_LITE && m_ams_model != AMSModel::EXT_AMS) { + sizer->Add(amscan, 0, wxALL, 0); + } + else if (m_ams_model == AMSModel::AMS_LITE) + { + if (canindex > 1) { + sizer->Prepend(amscan, 0, wxALL, 0); + } + else { + sizer->Add(amscan, 0, wxALL, 0); + } + } + + m_can_lib_list[caninfo.can_id] = m_panel_lib; + m_can_road_list[caninfo.can_id] = m_panel_road; +} + +void AmsItem::Update(AMSinfo info) +{ + m_info = info; + m_can_count = info.cans.size(); + + if (m_humidity) + { + m_humidity->Update(m_info); + } + + for (int i = 0; i < m_can_count; i++) { + auto it = m_can_refresh_list.find(std::to_string(i)); + if (it == m_can_refresh_list.end()) break; + + auto refresh = it->second; + if (refresh != nullptr){ + refresh->Update(info.ams_id, info.cans[i]); + refresh->Show(); + } + } + + for (int i = 0; i < m_can_lib_list.size(); i++) { + AMSLib* lib = m_can_lib_list[std::to_string(i)]; + if (lib != nullptr){ + if (i < m_can_count){ + lib->Update(info.cans[i], info.ams_id); + lib->Show(); + } + else{ + lib->Hide(); + } + } + } + + if (m_ams_model != AMSModel::AMS_LITE) { + for (auto i = 0; i < m_can_road_list.size(); i++) { + AMSRoad* road = m_can_road_list[std::to_string(i)]; + if (road != nullptr) { + if (i < m_can_count) { + road->Update(m_info, info.cans[i], i, m_can_count); + road->Show(); + } else { + road->Hide(); + } + } + } + } + + Layout(); +} + +void AmsItem::SetDefSelectCan() +{ + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + m_canlib_selection =lib->m_can_index; + m_canlib_id = lib->m_info.can_id; + SelectCan(m_canlib_id); + break; + } +} + + +void AmsItem::SelectCan(std::string canid) +{ + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (lib->m_info.can_id == canid) { + m_canlib_selection = lib->m_can_index; + } + } + + m_canlib_id = canid; + + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (lib->m_info.can_id == m_canlib_id) { + wxCommandEvent evt(EVT_AMS_UNSELETED_VAMS); + evt.SetString(m_info.ams_id); + wxPostEvent(GetParent()->GetParent(), evt); + lib->OnSelected(); + } else { + lib->UnSelected(); + } + } +} + +wxColour AmsItem::GetTagColr(wxString canid) +{ + auto tag_colour = *wxWHITE; + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (canid == lib->m_info.can_id) tag_colour = lib->GetLibColour(); + } + return tag_colour; +} + +void AmsItem::SetAmsStepExtra(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step) +{ + if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP1) { + SetAmsStep(canid.ToStdString()); + }else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP2) { + SetAmsStep(canid.ToStdString()); + }else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP3) { + SetAmsStep(canid.ToStdString()); + }else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) { + SetAmsStep(""); + } +} + +void AmsItem::SetAmsStep(wxString canid, AMSPassRoadType type, AMSPassRoadSTEP step) +{ + if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) { + for (auto road_it : m_can_road_list) { + AMSRoad* road = road_it.second; + auto pr = std::vector{}; + pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_NONE); + road->OnPassRoad(pr); + } + + return; + } + + + auto tag_can_index = -1; + for (auto road_it : m_can_road_list) { + AMSRoad* road = road_it.second; + if (canid == road->m_info.can_id) { tag_can_index = road->m_canindex; } + } + if (tag_can_index == -1) return; + + // get colour + auto tag_colour = *wxWHITE; + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (canid == lib->m_info.can_id) tag_colour = lib->GetLibColour(); + } + + // unload + if (type == AMSPassRoadType::AMS_ROAD_TYPE_UNLOAD) { + for (auto road_it : m_can_road_list) { + AMSRoad* road = road_it.second; + + auto index = road->m_canindex; + auto pr = std::vector{}; + + pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM); + if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_2) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM); } + + if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_3) { + if (index == tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT); } + if (index < tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT); } + if (index == 0 && tag_can_index == index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_TOP); } + if (index == 0 && tag_can_index > index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT); } + } + + road->SetPassRoadColour(tag_colour); + road->OnPassRoad(pr); + } + } + + // load + if (type == AMSPassRoadType::AMS_ROAD_TYPE_LOAD) { + for (auto road_it : m_can_road_list) { + AMSRoad* road = road_it.second; + + auto index = road->m_canindex; + auto pr = std::vector{}; + + if (index == tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT); } + if (index < tag_can_index && index > 0) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_LEFT_RIGHT); } + if (index == 0 && tag_can_index == index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_TOP); } + if (index == 0 && tag_can_index > index) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_RIGHT); } + + if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_2) { pr.push_back(AMSPassRoadMode::AMS_ROAD_MODE_END_BOTTOM); } + + road->SetPassRoadColour(tag_colour); + road->OnPassRoad(pr); + } + } +} + +void AmsItem::SetAmsStep(std::string can_id) +{ + if (m_road_canid != can_id) { + m_road_canid = can_id; + Refresh(); + } + for (auto lib : m_can_lib_list){ + if (lib.second->m_info.can_id == can_id){ + lib.second->on_pass_road(true); + } + else{ + lib.second->on_pass_road(false); + } + } +} + +void AmsItem::PlayRridLoading(wxString canid) +{ + for (auto refresh_it : m_can_refresh_list) { + AMSrefresh* refresh = refresh_it.second; + if (refresh->GetCanId() == canid) { refresh->PlayLoading(); } + } +} + +std::string AmsItem::GetCurrentCan() +{ + if (m_canlib_selection < 0) + return ""; + + return wxString::Format("%d", m_canlib_selection).ToStdString(); +} + +void AmsItem::paintEvent(wxPaintEvent& evt) +{ + wxPaintDC dc(this); + render(dc); +} + +void AmsItem::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 AmsItem::doRender(wxDC& dc) +{ + wxSize size = GetSize(); + + //road for extra + if (m_ams_model == AMSModel::AMS_LITE) { + dc.DrawBitmap(m_bitmap_extra_framework.bmp(), (size.x - m_bitmap_extra_framework.GetBmpSize().x) / 2, (size.y - m_bitmap_extra_framework.GetBmpSize().y) / 2); + + // A1 + dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + RenderLiteRoad(dc, size); + } +} + +void AmsItem::RenderLiteRoad(wxDC& dc, wxSize size) { + auto end_top = size.x / 2 - FromDIP(99); + auto passroad_width = 6; + auto a1_top = size.y / 2 - FromDIP(4); + auto a2_top = size.y / 2 + FromDIP(8); + auto a3_top = size.y / 2 + FromDIP(4); + auto a4_top = size.y / 2; + + try + { + auto a1_left = m_can_lib_list["0"]->GetScreenPosition().x + m_can_lib_list["0"]->GetSize().x / 2; + auto local_pos1 = GetScreenPosition().x + GetSize().x / 2; + a1_left = size.x / 2 + (a1_left - local_pos1); + dc.DrawLine(a1_left, FromDIP(30), a1_left, a1_top); + dc.DrawLine(a1_left, a1_top, end_top, a1_top); + + // A2 + auto a2_left = m_can_lib_list["1"]->GetScreenPosition().x + m_can_lib_list["1"]->GetSize().x / 2; + auto local_pos2 = GetScreenPosition().x + GetSize().x / 2; + a2_left = size.x / 2 + (a2_left - local_pos2); + dc.DrawLine(a2_left, FromDIP(160), a2_left, a2_top); + dc.DrawLine(a2_left, a2_top, end_top, a2_top); + + // A3 + auto a3_left = m_can_lib_list["2"]->GetScreenPosition().x + m_can_lib_list["2"]->GetSize().x / 2; + auto local_pos3 = GetScreenPosition().x + GetSize().x / 2; + a3_left = size.x / 2 + (a3_left - local_pos3); + dc.DrawLine(a3_left, FromDIP(160), a3_left, a3_top); + dc.DrawLine(a3_left, a3_top, end_top, a3_top); + + + //// A4 + auto a4_left = m_can_lib_list["3"]->GetScreenPosition().x + m_can_lib_list["3"]->GetSize().x / 2; + auto local_pos4 = GetScreenPosition().x + GetSize().x / 2; + a4_left = size.x / 2 + (a4_left - local_pos4); + dc.DrawLine(a4_left, FromDIP(30), a4_left, a4_top); + dc.DrawLine(a4_left, a4_top, end_top, a4_top); + + //to Extruder + dc.SetPen(wxPen(AMS_CONTROL_GRAY500, 2, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH)); + dc.DrawLine(end_top, a1_top, end_top, size.y); + + + if (!m_road_canid.empty()) { + int can_idx = atoi(m_road_canid.c_str()); + if (can_idx < 0 || can_idx >= m_info.cans.size()) { + return; + } + m_road_colour = m_info.cans[can_idx].material_colour; + dc.SetPen(wxPen(m_road_colour, passroad_width, wxPENSTYLE_SOLID)); + if (m_road_canid == "0") { + dc.DrawLine(a1_left, FromDIP(30), a1_left, a1_top); + dc.DrawLine(a1_left, a1_top, end_top, a1_top); + dc.DrawLine(end_top, a1_top, end_top, size.y); + } + + if (m_road_canid == "1") { + dc.DrawLine(a2_left, FromDIP(160), a2_left, a2_top); + dc.DrawLine(a2_left, a2_top, end_top, a2_top); + dc.DrawLine(end_top, a2_top, end_top, size.y); + } + + if (m_road_canid == "2") { + dc.DrawLine(a3_left, FromDIP(160), a3_left, a3_top); + dc.DrawLine(a3_left, a3_top, end_top, a3_top); + dc.DrawLine(end_top, a3_top, end_top, size.y); + } + + if (m_road_canid == "3") { + dc.DrawLine(a4_left, FromDIP(30), a4_left, a4_top); + dc.DrawLine(a4_left, a4_top, end_top, a4_top); + dc.DrawLine(end_top, a4_top, end_top, size.y); + } + } + } + catch (...) {} +} + +void AmsItem::StopRridLoading(wxString canid) +{ + for (auto refresh_it : m_can_refresh_list) { + AMSrefresh* refresh = refresh_it.second; + if (refresh->GetCanId() == canid) { refresh->StopLoading(); } + } +} + +void AmsItem::msw_rescale() +{ + for (auto refresh_it : m_can_refresh_list) { + AMSrefresh* refresh = refresh_it.second; + if(refresh) refresh->msw_rescale(); + } + + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (lib) lib->msw_rescale(); + } + if (m_humidity != nullptr) m_humidity->msw_rescale(); +} + +void AmsItem::show_sn_value(bool show) +{ + for (auto lib_it : m_can_lib_list) { + AMSLib* lib = lib_it.second; + if (lib) lib->show_kn_value(show); + } +} + +}} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/Widgets/AMSItem.hpp b/src/slic3r/GUI/Widgets/AMSItem.hpp new file mode 100644 index 00000000000..52a82fc04b9 --- /dev/null +++ b/src/slic3r/GUI/Widgets/AMSItem.hpp @@ -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 +#include +#include +#include + + +#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 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 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 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 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 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 ams_humidity_imgs; + std::vector ams_humidity_dark_imgs; + + std::vector ams_humidity_no_num_imgs; + std::vector 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 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 m_can_lib_list; + std::map m_can_road_list; + std::map 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_ diff --git a/src/slic3r/GUI/Widgets/Label.cpp b/src/slic3r/GUI/Widgets/Label.cpp index 7482f3c6187..5171c257ab1 100644 --- a/src/slic3r/GUI/Widgets/Label.cpp +++ b/src/slic3r/GUI/Widgets/Label.cpp @@ -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; diff --git a/src/slic3r/GUI/Widgets/Label.hpp b/src/slic3r/GUI/Widgets/Label.hpp index ea15128ec77..6c7809fea6a 100644 --- a/src/slic3r/GUI/Widgets/Label.hpp +++ b/src/slic3r/GUI/Widgets/Label.hpp @@ -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; diff --git a/src/slic3r/GUI/wxMediaCtrl2.mm b/src/slic3r/GUI/wxMediaCtrl2.mm index ca2ccf6ea19..063472eccc7 100644 --- a/src/slic3r/GUI/wxMediaCtrl2.mm +++ b/src/slic3r/GUI/wxMediaCtrl2.mm @@ -97,8 +97,8 @@ 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()); diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index 2cd3581af72..1f74c536306 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -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 * config_nozzle_type = full_config.option>("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("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& 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 &pa_calib_infos) @@ -402,31 +402,6 @@ bool CalibUtils::get_PA_calib_tab(std::vector &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 &pa_calib_values, bool is_auto_cali) { DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); @@ -1257,8 +1232,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 diff --git a/src/slic3r/Utils/CalibUtils.hpp b/src/slic3r/Utils/CalibUtils.hpp index 2fd42a2547d..d6b774ee9e6 100644 --- a/src/slic3r/Utils/CalibUtils.hpp +++ b/src/slic3r/Utils/CalibUtils.hpp @@ -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 @@ class CalibUtils 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 &pa_calib_results); - - static void emit_get_PA_calib_infos(float nozzle_diameter); - static bool get_PA_calib_tab(std::vector &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 &pa_calib_infos); static void set_PA_calib_result(const std::vector& pa_calib_values, bool is_auto_cali); static void select_PA_calib_result(const PACalibIndexInfo &pa_calib_info); @@ -75,5 +75,6 @@ class CalibUtils 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); } } \ No newline at end of file diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index 4127d3fd292..bcb9dda915e 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -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 headers) extra_headers.swap(headers); } +std::map Http::get_extra_headers() +{ + std::lock_guard l(g_mutex); + return extra_headers; +} + bool Http::ca_file_supported() { ::CURL *curl = ::curl_easy_init(); diff --git a/src/slic3r/Utils/Http.hpp b/src/slic3r/Utils/Http.hpp index fbded8eab27..d8eabb6dfd4 100644 --- a/src/slic3r/Utils/Http.hpp +++ b/src/slic3r/Utils/Http.hpp @@ -90,6 +90,7 @@ class Http : public std::enable_shared_from_this { //BBS set global header for each http request static void set_extra_headers(std::map headers); + static std::map get_extra_headers(); ~Http(); diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 47c3a7068e5..eb80e952177 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -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(get_network_function("bambu_network_connect_printer")); disconnect_printer_ptr = reinterpret_cast(get_network_function("bambu_network_disconnect_printer")); send_message_to_printer_ptr = reinterpret_cast(get_network_function("bambu_network_send_message_to_printer")); + check_cert_ptr = reinterpret_cast(get_network_function("bambu_network_update_cert")); + install_device_cert_ptr = reinterpret_cast(get_network_function("bambu_network_install_device_cert")); start_discovery_ptr = reinterpret_cast(get_network_function("bambu_network_start_discovery")); change_user_ptr = reinterpret_cast(get_network_function("bambu_network_change_user")); is_user_login_ptr = reinterpret_cast(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(get_network_function("bambu_network_ping_bind")); bind_detect_ptr = reinterpret_cast(get_network_function("bambu_network_bind_detect")); set_server_callback_ptr = reinterpret_cast(get_network_function("bambu_network_set_server_callback")); - get_model_id_from_desgin_id_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_id_from_desgin_id")); bind_ptr = reinterpret_cast(get_network_function("bambu_network_bind")); unbind_ptr = reinterpret_cast(get_network_function("bambu_network_unbind")); get_bambulab_host_ptr = reinterpret_cast(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(get_network_function("bambu_network_get_camera_url")); get_design_staffpick_ptr = reinterpret_cast(get_network_function("bambu_network_get_design_staffpick")); start_publish_ptr = reinterpret_cast(get_network_function("bambu_network_start_publish")); - get_profile_3mf_ptr = reinterpret_cast(get_network_function("bambu_network_get_profile_3mf")); get_model_publish_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_publish_url")); get_subtask_ptr = reinterpret_cast(get_network_function("bambu_network_get_subtask")); get_model_mall_home_url_ptr = reinterpret_cast(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(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(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(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(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(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(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(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; diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index fc006c8e093..fe5d155e7be 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -38,10 +38,12 @@ typedef int (*func_del_subscribe)(void *agent, std::vector 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 callback); typedef int (*func_get_design_staffpick)(void *agent, int offset, int limit, std::function 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 callback); typedef int (*func_get_mw_user_4ulist)(void *agent, int seed, int limit, std::function callback); + //the NetworkAgent class class NetworkAgent { @@ -127,6 +128,7 @@ class NetworkAgent #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 @@ class NetworkAgent 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 @@ class NetworkAgent 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 @@ class NetworkAgent int get_camera_url(std::string dev_id, std::function callback); int get_design_staffpick(int offset, int limit, std::function 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 @@ class NetworkAgent 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 @@ class NetworkAgent 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 @@ class NetworkAgent 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; diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index d09f69b6630..0af6cd459f2 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -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 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 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 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) { diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 0c7b4fddb12..1ccf786bbc0 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -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" @@ -186,6 +189,48 @@ struct detectResult { std::string connect_type; }; +/* print job*/ +struct PrintParams_Legacy { + /* 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_mapping_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; +}; + /* print job*/ struct PrintParams { /* basic info */ @@ -200,7 +245,9 @@ struct PrintParams { 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; @@ -226,6 +273,9 @@ struct PrintParams { 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 @@ -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