OrcaSlicer/src/slic3r/GUI/CalibrationWizardCaliPage.cpp
SoftFever b8172316b8 Merge branch 'v1.7.2-remote'
Signed-off-by: SoftFever <softfeverever@gmail.com>

# Conflicts:
#	deps/ZLIB/ZLIB.cmake
#	localization/i18n/OrcaSlicer.pot
#	localization/i18n/de/OrcaSlicer_de.po
#	localization/i18n/en/OrcaSlicer_en.po
#	localization/i18n/es/OrcaSlicer_es.po
#	localization/i18n/fr/OrcaSlicer_fr.po
#	localization/i18n/hu/OrcaSlicer_hu.po
#	localization/i18n/it/OrcaSlicer_it.po
#	localization/i18n/ja/OrcaSlicer_ja.po
#	localization/i18n/ko/OrcaSlicer_ko.po
#	localization/i18n/list.txt
#	localization/i18n/nl/OrcaSlicer_nl.po
#	localization/i18n/sv/OrcaSlicer_sv.po
#	localization/i18n/zh_cn/OrcaSlicer_zh_CN.po
#	resources/calib/PressureAdvance/pa_pattern.3mf
#	resources/handy_models/Disc.stl
#	resources/i18n/de/BambuStudio.mo
#	resources/i18n/en/BambuStudio.mo
#	resources/i18n/es/BambuStudio.mo
#	resources/i18n/fr/BambuStudio.mo
#	resources/i18n/hu/BambuStudio.mo
#	resources/i18n/it/BambuStudio.mo
#	resources/i18n/ja/BambuStudio.mo
#	resources/i18n/ko/BambuStudio.mo
#	resources/i18n/nl/BambuStudio.mo
#	resources/i18n/sv/BambuStudio.mo
#	resources/i18n/zh_cn/BambuStudio.mo
#	resources/profiles/Anycubic.json
#	resources/profiles/Anycubic/machine/Anycubic Kobra 2 0.4 nozzle.json
#	resources/profiles/BBL.json
#	resources/profiles/BBL/filament/Bambu ASA @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/Bambu ASA @BBL X1C 0.4 nozzle.json
#	resources/profiles/BBL/filament/Bambu ASA @BBL X1C.json
#	resources/profiles/BBL/filament/Bambu PA-CF @base.json
#	resources/profiles/BBL/filament/Bambu PA6-CF @BBL X1C.json
#	resources/profiles/BBL/filament/Bambu PA6-CF @base.json
#	resources/profiles/BBL/filament/Bambu PETG-CF @BBL X1C.json
#	resources/profiles/BBL/filament/Bambu Support W @BBL X1.json
#	resources/profiles/BBL/filament/Bambu TPU 95A @BBL X1.json
#	resources/profiles/BBL/filament/Generic HIPS @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/Generic HIPS @BBL X1C.json
#	resources/profiles/BBL/filament/Generic PA-CF.json
#	resources/profiles/BBL/filament/Generic PC.json
#	resources/profiles/BBL/filament/Generic PETG-CF @BBL X1C.json
#	resources/profiles/BBL/filament/Generic PLA @0.2 nozzle.json
#	resources/profiles/BBL/filament/Generic PLA High Speed @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/Generic PLA High Speed @BBL P1P.json
#	resources/profiles/BBL/filament/Generic PLA High Speed @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/Generic PLA High Speed @BBL X1C.json
#	resources/profiles/BBL/filament/Generic PLA-CF.json
#	resources/profiles/BBL/filament/Generic PLA.json
#	resources/profiles/BBL/filament/Generic TPU.json
#	resources/profiles/BBL/filament/Overture Matte PLA @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/Overture Matte PLA @BBL P1P.json
#	resources/profiles/BBL/filament/Overture Matte PLA @BBL X1.json
#	resources/profiles/BBL/filament/Overture Matte PLA @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/Overture Matte PLA @BBL X1C.json
#	resources/profiles/BBL/filament/Overture Matte PLA @base.json
#	resources/profiles/BBL/filament/Overture PLA @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/Overture PLA @BBL P1P.json
#	resources/profiles/BBL/filament/Overture PLA @BBL X1.json
#	resources/profiles/BBL/filament/Overture PLA @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/Overture PLA @BBL X1C.json
#	resources/profiles/BBL/filament/Overture PLA @base.json
#	resources/profiles/BBL/filament/P1P/Bambu TPU 95A @BBL P1P.json
#	resources/profiles/BBL/filament/P1P/Generic PLA @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/P1P/Generic TPU @BBL P1P.json
#	resources/profiles/BBL/filament/P1P/eSUN PLA+ @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/P1P/eSUN PLA+ @BBL P1P.json
#	resources/profiles/BBL/filament/PolyLite ABS @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/PolyLite ABS @BBL P1P.json
#	resources/profiles/BBL/filament/PolyLite ABS @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/PolyLite ABS @BBL X1C.json
#	resources/profiles/BBL/filament/PolyLite ABS @base.json
#	resources/profiles/BBL/filament/PolyLite ASA @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/PolyLite ASA @BBL P1P.json
#	resources/profiles/BBL/filament/PolyLite ASA @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/PolyLite ASA @BBL X1C.json
#	resources/profiles/BBL/filament/PolyLite ASA @base.json
#	resources/profiles/BBL/filament/PolyLite PETG @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/filament/PolyLite PETG @BBL P1P.json
#	resources/profiles/BBL/filament/PolyLite PETG @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/PolyLite PETG @BBL X1C.json
#	resources/profiles/BBL/filament/PolyLite PETG @base.json
#	resources/profiles/BBL/filament/PolyLite PLA @BBL X1.json
#	resources/profiles/BBL/filament/PolyTerra PLA @BBL X1.json
#	resources/profiles/BBL/filament/eSUN PLA+ @BBL X1.json
#	resources/profiles/BBL/filament/eSUN PLA+ @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/filament/eSUN PLA+ @BBL X1C.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.8 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1S 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1S 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1S 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1S 0.8 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.8 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.8 nozzle.json
#	resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json
#	resources/profiles/BBL/process/0.06mm Standard @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/process/0.08mm Extra Fine @BBL P1P.json
#	resources/profiles/BBL/process/0.08mm Extra Fine @BBL X1C.json
#	resources/profiles/BBL/process/0.08mm Standard @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/process/0.10mm Standard @BBL P1P 0.2 nozzle.json
#	resources/profiles/BBL/process/0.10mm Standard @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/process/0.12mm Fine @BBL P1P.json
#	resources/profiles/BBL/process/0.12mm Fine @BBL X1C.json
#	resources/profiles/BBL/process/0.12mm Standard @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/process/0.14mm Standard @BBL X1C 0.2 nozzle.json
#	resources/profiles/BBL/process/0.16mm Optimal @BBL P1P.json
#	resources/profiles/BBL/process/0.16mm Optimal @BBL X1C.json
#	resources/profiles/BBL/process/0.18mm Standard @BBL X1C 0.6 nozzle.json
#	resources/profiles/BBL/process/0.20mm Standard @BBL P1P.json
#	resources/profiles/BBL/process/0.20mm Standard @BBL X1C.json
#	resources/profiles/BBL/process/0.20mm Strength @BBL P1P.json
#	resources/profiles/BBL/process/0.20mm Strength @BBL X1C.json
#	resources/profiles/BBL/process/0.24mm Draft @BBL P1P.json
#	resources/profiles/BBL/process/0.24mm Draft @BBL X1C.json
#	resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.6 nozzle.json
#	resources/profiles/BBL/process/0.24mm Standard @BBL X1C 0.8 nozzle.json
#	resources/profiles/BBL/process/0.28mm Extra Draft @BBL P1P.json
#	resources/profiles/BBL/process/0.28mm Extra Draft @BBL X1C.json
#	resources/profiles/BBL/process/0.30mm Standard @BBL P1P 0.6 nozzle.json
#	resources/profiles/BBL/process/0.30mm Standard @BBL X1 0.6 nozzle.json
#	resources/profiles/BBL/process/0.30mm Standard @BBL X1C 0.6 nozzle.json
#	resources/profiles/BBL/process/0.30mm Strength @BBL X1C 0.6 nozzle.json
#	resources/profiles/BBL/process/0.32mm Standard @BBL X1C 0.8 nozzle.json
#	resources/profiles/BBL/process/0.36mm Standard @BBL X1C 0.6 nozzle.json
#	resources/profiles/BBL/process/0.40mm Standard @BBL P1P 0.8 nozzle.json
#	resources/profiles/BBL/process/0.40mm Standard @BBL X1 0.8 nozzle.json
#	resources/profiles/BBL/process/0.40mm Standard @BBL X1C 0.8 nozzle.json
#	resources/profiles/BBL/process/0.42mm Standard @BBL X1C 0.6 nozzle.json
#	resources/profiles/BBL/process/0.48mm Standard @BBL X1C 0.8 nozzle.json
#	resources/profiles/BBL/process/0.56mm Standard @BBL X1C 0.8 nozzle.json
#	resources/profiles/BBL/process/fdm_process_bbl_common.json
#	resources/profiles/Creality.json
#	resources/profiles/Creality/machine/Creality CR-10 Max 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-10 V2 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 Max 0.2 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 Max 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 Max 0.6 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 Max 0.8 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 SE 0.2 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 SE 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 SE 0.6 nozzle.json
#	resources/profiles/Creality/machine/Creality CR-6 SE 0.8 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-3 S1 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-3 S1 Pro 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-5 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-5 Plus 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-5 S1 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-5S 0.4 nozzle.json
#	resources/profiles/Creality/machine/Creality Ender-6 0.4 nozzle.json
#	resources/profiles/Elegoo.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 2 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 2D 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 2S 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 3 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 3 Max 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 3 Plus 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune 3 Pro 0.4 nozzle.json
#	resources/profiles/Elegoo/machine/Elegoo Neptune X 0.4 nozzle.json
#	resources/profiles/Prusa.json
#	resources/profiles/Prusa/machine/Prusa MINI 0.4 nozzle.json
#	resources/profiles/Prusa/machine/Prusa MK3S 0.4 nozzle.json
#	resources/profiles/Qidi/machine/Qidi X-CF Pro 0.4 nozzle.json
#	resources/profiles/Qidi/machine/Qidi X-Max 0.4 nozzle.json
#	resources/profiles/Qidi/machine/Qidi X-Max 3 0.4 nozzle.json
#	resources/profiles/Qidi/machine/Qidi X-Plus 0.4 nozzle.json
#	resources/profiles/Qidi/machine/Qidi X-Plus 3 0.4 nozzle.json
#	resources/profiles/Qidi/machine/Qidi X-Smart 3 0.4 nozzle.json
#	resources/profiles/Tronxy.json
#	resources/profiles/Tronxy/machine/Tronxy X5SA 400 0.4 nozzle.json
#	resources/profiles/Tronxy/process/0.08mm Extra Fine @Tronxy.json
#	resources/profiles/Tronxy/process/0.12mm Fine @Tronxy.json
#	resources/profiles/Tronxy/process/0.15mm Optimal @Tronxy.json
#	resources/profiles/Tronxy/process/0.20mm Standard @Tronxy.json
#	resources/profiles/Tronxy/process/0.24mm Draft @Tronxy.json
#	resources/profiles/Tronxy/process/0.28mm Extra Draft @Tronxy.json
#	resources/profiles/Voxelab/machine/Voxelab Aquila X2 0.4 nozzle.json
#	resources/web/data/text.js
#	src/OrcaSlicer.cpp
#	src/libslic3r/GCode.cpp
#	src/libslic3r/GCode/SeamPlacer.cpp
#	src/libslic3r/GCode/SeamPlacer.hpp
#	src/libslic3r/GCodeWriter.cpp
#	src/libslic3r/GCodeWriter.hpp
#	src/libslic3r/Preset.cpp
#	src/libslic3r/PresetBundle.cpp
#	src/libslic3r/Print.cpp
#	src/libslic3r/PrintConfig.cpp
#	src/libslic3r/PrintConfig.hpp
#	src/libslic3r/TreeSupport.cpp
#	src/libslic3r/calib.cpp
#	src/libslic3r/calib.hpp
#	src/slic3r/GUI/BackgroundSlicingProcess.cpp
#	src/slic3r/GUI/BedShapeDialog.cpp
#	src/slic3r/GUI/ConfigManipulation.cpp
#	src/slic3r/GUI/GUI.cpp
#	src/slic3r/GUI/GUI_App.cpp
#	src/slic3r/GUI/GUI_Factories.cpp
#	src/slic3r/GUI/GUI_ObjectList.cpp
#	src/slic3r/GUI/Jobs/ArrangeJob.cpp
#	src/slic3r/GUI/OptionsGroup.cpp
#	src/slic3r/GUI/PartPlate.cpp
#	src/slic3r/GUI/PartPlate.hpp
#	src/slic3r/GUI/Plater.cpp
#	src/slic3r/GUI/StatusPanel.cpp
#	src/slic3r/GUI/Tab.cpp
#	src/slic3r/GUI/Widgets/AMSControl.hpp
#	version.inc
2023-09-29 19:46:49 +08:00

490 lines
20 KiB
C++

#include "CalibrationWizardCaliPage.hpp"
#include "MainFrame.hpp"
#include "I18N.hpp"
#include "Widgets/Label.hpp"
namespace Slic3r { namespace GUI {
static const wxString NA_STR = _L("N/A");
CalibrationCaliPage::CalibrationCaliPage(wxWindow* parent, CalibMode cali_mode, CaliPageType cali_type,
wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: CalibrationWizardPage(parent, id, pos, size, style)
{
m_cali_mode = cali_mode;
m_page_type = cali_type;
m_top_sizer = new wxBoxSizer(wxVERTICAL);
create_page(this);
this->SetSizer(m_top_sizer);
m_top_sizer->Fit(this);
}
CalibrationCaliPage::~CalibrationCaliPage()
{
m_printing_panel->get_pause_resume_button()->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CalibrationCaliPage::on_subtask_pause_resume), NULL, this);
m_printing_panel->get_abort_button()->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CalibrationCaliPage::on_subtask_abort), NULL, this);
}
void CalibrationCaliPage::create_page(wxWindow* parent)
{
m_page_caption = new CaliPageCaption(parent, m_cali_mode);
m_page_caption->show_prev_btn(true);
m_top_sizer->Add(m_page_caption, 0, wxEXPAND, 0);
wxArrayString steps;
steps.Add(_L("Preset"));
steps.Add(_L("Calibration"));
steps.Add(_L("Record Factor"));
m_step_panel = new CaliPageStepGuide(parent, steps);
m_step_panel->set_steps(1);
m_top_sizer->Add(m_step_panel, 0, wxEXPAND, 0);
m_picture_panel = new CaliPagePicture(parent);
m_top_sizer->Add(m_picture_panel, 0, wxEXPAND, 0);
m_top_sizer->AddSpacer(FromDIP(20));
set_cali_img();
m_printing_panel = new PrintingTaskPanel(parent, PrintingTaskType::CALIBRATION);
m_printing_panel->SetDoubleBuffered(true);
m_printing_panel->SetSize({ CALIBRATION_PROGRESSBAR_LENGTH, -1 });
m_printing_panel->SetMinSize({ CALIBRATION_PROGRESSBAR_LENGTH, -1 });
m_printing_panel->enable_pause_resume_button(false, "resume_disable");
m_printing_panel->enable_abort_button(false);
m_top_sizer->Add(m_printing_panel, 0, wxALIGN_CENTER, 0);
m_action_panel = new CaliPageActionPanel(parent, m_cali_mode, CaliPageType::CALI_PAGE_CALI);
m_top_sizer->Add(m_action_panel, 0, wxEXPAND, 0);
m_printing_panel->get_pause_resume_button()->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CalibrationCaliPage::on_subtask_pause_resume), NULL, this);
m_printing_panel->get_abort_button()->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CalibrationCaliPage::on_subtask_abort), NULL, this);
Layout();
}
void CalibrationCaliPage::on_subtask_pause_resume(wxCommandEvent& event)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
MachineObject* obj = dev->get_selected_machine();
if (!obj) return;
if (obj->can_resume())
obj->command_task_resume();
else
obj->command_task_pause();
}
void CalibrationCaliPage::on_subtask_abort(wxCommandEvent& event)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
MachineObject* obj = dev->get_selected_machine();
if (!obj) return;
if (abort_dlg == nullptr) {
abort_dlg = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Cancel print"));
abort_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) {
if (obj) obj->command_task_abort();
});
}
abort_dlg->update_text(_L("Are you sure you want to cancel this print?"));
abort_dlg->on_show();
}
void CalibrationCaliPage::set_cali_img()
{
if (m_cali_mode == CalibMode::Calib_PA_Line) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
m_picture_panel->set_img(create_scaled_bitmap("fd_calibration_manual", nullptr, 400));
}
else if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
m_picture_panel->set_img(create_scaled_bitmap("fd_calibration_auto", nullptr, 400));
}
}
else if (m_cali_mode == CalibMode::Calib_Flow_Rate) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
if (m_page_type == CaliPageType::CALI_PAGE_CALI)
m_picture_panel->set_img(create_scaled_bitmap("flow_rate_calibration_coarse", nullptr, 400));
if (m_page_type == CaliPageType::CALI_PAGE_FINE_CALI)
m_picture_panel->set_img(create_scaled_bitmap("flow_rate_calibration_fine", nullptr, 400));
else
m_picture_panel->set_img(create_scaled_bitmap("flow_rate_calibration_coarse", nullptr, 400));
}
else if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
m_picture_panel->set_img(create_scaled_bitmap("flow_rate_calibration_auto", nullptr, 400));
}
}
else if (m_cali_mode == CalibMode::Calib_Vol_speed_Tower) {
m_picture_panel->set_img(create_scaled_bitmap("max_volumetric_speed_calibration", nullptr, 400));
}
}
void CalibrationCaliPage::set_pa_cali_image(int stage)
{
if (m_cali_mode == CalibMode::Calib_PA_Line && m_cali_method == CALI_METHOD_MANUAL) {
if (stage == 0) {
m_picture_panel->set_img(create_scaled_bitmap("fd_calibration_manual", nullptr, 400));
} else if (stage == 1) {
m_picture_panel->set_img(create_scaled_bitmap("fd_pattern_manual", nullptr, 400));
}
}
}
void CalibrationCaliPage::clear_last_job_status()
{
m_is_between_start_and_running = true;
}
void CalibrationCaliPage::update(MachineObject* obj)
{
if (this->IsShown()) {
if (obj) {
if (obj->print_status != "RUNNING") {
BOOST_LOG_TRIVIAL(info) << "on_show_cali_page - machine object status:"
<< " dev_id = " << obj->dev_id
<< ", print_type = " << obj->printer_type
<< ", printer_status = " << obj->print_status
<< ", is_connected = " << obj->is_connected()
<< ", m_is_between_start_and_running = " << m_is_between_start_and_running
<< ", cali_finished = " << obj->cali_finished
<< ", cali_version = " << obj->cali_version
<< ", cache_flow_ratio = " << obj->cache_flow_ratio
<< ", sub_task_name = " << obj->subtask_name
<< ", gcode_file_name = " << obj->m_gcode_file
<< ", get_pa_calib_result" << obj->get_pa_calib_result
<< ", get_flow_calib_result" << obj->get_flow_calib_result;
}
}
else {
BOOST_LOG_TRIVIAL(info) << "on_show_cali_page - machine object is nullptr";
}
}
static int get_result_count = 0;
// enable calibration when finished
bool enable_cali = false;
if (obj) {
if (obj->print_error > 0) {
StatusPanel* status_panel = Slic3r::GUI::wxGetApp().mainframe->m_monitor->get_status_panel();
status_panel->obj = obj;
status_panel->update_error_message();
}
if (obj->print_status == "RUNNING")
m_is_between_start_and_running = false;
if (obj->is_connecting() || !obj->is_connected() || m_is_between_start_and_running) {
reset_printing_values();
m_action_panel->enable_button(CaliPageActionType::CALI_ACTION_CALI_NEXT, false);
return;
}
if (m_cali_mode == CalibMode::Calib_PA_Line) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
if (get_obj_calibration_mode(obj) == m_cali_mode) {
if (obj->is_printing_finished()) {
if (obj->print_status == "FINISH") {
if (obj->get_pa_calib_result) {
enable_cali = true;
}
else {
// use selected diameter, add a counter to timeout, add a warning tips when get result failed
CalibUtils::emit_get_PA_calib_results(get_selected_calibration_nozzle_dia(obj));
BOOST_LOG_TRIVIAL(trace) << "CalibUtils::emit_get_PA_calib_results, auto count = " << get_result_count++;
enable_cali = false;
}
}
else if (obj->print_status == "FAILED") {
enable_cali = false;
}
}
else {
enable_cali = false;
}
}
} else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
if (get_obj_calibration_mode(obj) == m_cali_mode && obj->is_printing_finished()) {
enable_cali = true;
} else {
enable_cali = false;
}
} else {
assert(false);
}
m_action_panel->enable_button(CaliPageActionType::CALI_ACTION_CALI_NEXT, enable_cali);
} else if (m_cali_mode == CalibMode::Calib_Flow_Rate) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
if (get_obj_calibration_mode(obj) == m_cali_mode) {
if (obj->is_printing_finished()) {
if (obj->print_status == "FINISH") {
if (obj->get_flow_calib_result) {
enable_cali = true;
}
else {
// use selected diameter, add a counter to timeout, add a warning tips when get result failed
CalibUtils::emit_get_flow_ratio_calib_results(get_selected_calibration_nozzle_dia(obj));
enable_cali = false;
}
}
else if (obj->print_status == "FAILED") {
enable_cali = false;
}
}
else {
enable_cali = false;
}
}
} else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
if (get_obj_calibration_mode(obj) == m_cali_mode && obj->is_printing_finished()) {
// use selected diameter, add a counter to timeout, add a warning tips when get result failed
CalibUtils::emit_get_flow_ratio_calib_results(get_selected_calibration_nozzle_dia(obj));
enable_cali = true;
}
else {
enable_cali = false;
}
} else {
assert(false);
}
m_action_panel->enable_button(CaliPageActionType::CALI_ACTION_CALI_NEXT, enable_cali);
}
else if (m_cali_mode == CalibMode::Calib_Vol_speed_Tower) {
if (get_obj_calibration_mode(obj) == m_cali_mode && obj->is_printing_finished()) {
enable_cali = true;
} else {
enable_cali = false;
}
}
else {
assert(false);
}
m_action_panel->enable_button(CaliPageActionType::CALI_ACTION_NEXT, enable_cali);
}
// only display calibration printing status
if (get_obj_calibration_mode(obj) == m_cali_mode) {
update_subtask(obj);
} else {
update_subtask(nullptr);
}
}
void CalibrationCaliPage::update_subtask(MachineObject* obj)
{
if (!obj) return;
if (obj->is_support_layer_num) {
m_printing_panel->update_layers_num(true);
}
else {
m_printing_panel->update_layers_num(false);
}
if (obj->is_system_printing()
|| obj->is_in_calibration()) {
reset_printing_values();
}
else if (obj->is_in_printing() || obj->print_status == "FINISH") {
if (obj->is_in_prepare() || obj->print_status == "SLICING") {
m_printing_panel->get_market_scoring_button()->Hide();
m_printing_panel->enable_abort_button(false);
m_printing_panel->enable_pause_resume_button(false, "pause_disable");
wxString prepare_text;
bool show_percent = true;
if (obj->is_in_prepare()) {
prepare_text = wxString::Format(_L("Downloading..."));
}
else if (obj->print_status == "SLICING") {
if (obj->queue_number <= 0) {
prepare_text = wxString::Format(_L("Cloud Slicing..."));
}
else {
prepare_text = wxString::Format(_L("In Cloud Slicing Queue, there are %s tasks ahead."), std::to_string(obj->queue_number));
show_percent = false;
}
}
else
prepare_text = wxString::Format(_L("Downloading..."));
if (obj->gcode_file_prepare_percent >= 0 && obj->gcode_file_prepare_percent <= 100 && show_percent)
prepare_text += wxString::Format("(%d%%)", obj->gcode_file_prepare_percent);
m_printing_panel->update_stage_value(prepare_text, 0);
m_printing_panel->update_progress_percent(NA_STR, wxEmptyString);
m_printing_panel->update_left_time(NA_STR);
m_printing_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
m_printing_panel->update_subtask_name(wxString::Format("%s", GUI::from_u8(obj->subtask_name)));
if (obj->get_modeltask() && obj->get_modeltask()->design_id > 0) {
m_printing_panel->show_profile_info(true, wxString::FromUTF8(obj->get_modeltask()->profile_name));
}
else {
m_printing_panel->show_profile_info(false);
}
if (obj->slice_info)
update_basic_print_data(false, obj->slice_info->weight, obj->slice_info->prediction);
}
else {
if (obj->can_resume()) {
m_printing_panel->enable_pause_resume_button(true, "resume");
}
else {
m_printing_panel->enable_pause_resume_button(true, "pause");
}
if (obj->print_status == "FINISH") {
m_printing_panel->enable_abort_button(false);
m_printing_panel->enable_pause_resume_button(false, "resume_disable");
bool is_market_task = obj->get_modeltask() && obj->get_modeltask()->design_id > 0;
if (is_market_task) {
m_printing_panel->get_market_scoring_button()->Show();
BOOST_LOG_TRIVIAL(info) << "SHOW_SCORE_BTU: design_id [" << obj->get_modeltask()->design_id << "] print_finish [" << m_print_finish << "]";
if (!m_print_finish && IsShownOnScreen()) {
m_print_finish = true;
}
}
else {
m_printing_panel->get_market_scoring_button()->Hide();
}
}
else {
m_printing_panel->enable_abort_button(true);
m_printing_panel->get_market_scoring_button()->Hide();
if (m_print_finish) {
m_print_finish = false;
}
}
// update printing stage
m_printing_panel->update_left_time(obj->mc_left_time);
if (obj->subtask_) {
m_printing_panel->update_stage_value(obj->get_curr_stage(), obj->subtask_->task_progress);
m_printing_panel->update_progress_percent(wxString::Format("%d", obj->subtask_->task_progress), "%");
m_printing_panel->update_layers_num(true, wxString::Format(_L("Layer: %d/%d"), obj->curr_layer, obj->total_layers));
}
else {
m_printing_panel->update_stage_value(obj->get_curr_stage(), 0);
m_printing_panel->update_progress_percent(NA_STR, wxEmptyString);
m_printing_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
}
}
m_printing_panel->update_subtask_name(wxString::Format("%s", GUI::from_u8(obj->subtask_name)));
if (obj->get_modeltask() && obj->get_modeltask()->design_id > 0) {
m_printing_panel->show_profile_info(true, wxString::FromUTF8(obj->get_modeltask()->profile_name));
}
else {
m_printing_panel->show_profile_info(false);
}
}
else {
reset_printing_values();
}
this->Layout();
}
void CalibrationCaliPage::update_basic_print_data(bool def, float weight, int prediction)
{
if (def) {
wxString str_prediction = wxString::Format("%s", get_bbl_time_dhms(prediction));
wxString str_weight = wxString::Format("%.2fg", weight);
m_printing_panel->show_priting_use_info(true, str_prediction, str_weight);
}
else {
m_printing_panel->show_priting_use_info(false, "0m", "0g");
}
}
void CalibrationCaliPage::reset_printing_values()
{
m_printing_panel->enable_pause_resume_button(false, "pause_disable");
m_printing_panel->enable_abort_button(false);
m_printing_panel->reset_printing_value();
m_printing_panel->update_subtask_name(NA_STR);
m_printing_panel->show_profile_info(false);
m_printing_panel->update_stage_value(wxEmptyString, 0);
m_printing_panel->update_progress_percent(NA_STR, wxEmptyString);
m_printing_panel->get_market_scoring_button()->Hide();
m_printing_panel->update_left_time(NA_STR);
m_printing_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
update_basic_print_data(false);
this->Layout();
}
void CalibrationCaliPage::on_device_connected(MachineObject* obj)
{
;
}
void CalibrationCaliPage::set_cali_method(CalibrationMethod method)
{
m_cali_method = method;
set_cali_img();
wxArrayString auto_steps;
auto_steps.Add(_L("Preset"));
auto_steps.Add(_L("Calibration"));
auto_steps.Add(_L("Record Factor"));
wxArrayString manual_steps;
manual_steps.Add(_L("Preset"));
manual_steps.Add(_L("Calibration1"));
manual_steps.Add(_L("Calibration2"));
manual_steps.Add(_L("Record Factor"));
if (method == CalibrationMethod::CALI_METHOD_AUTO) {
m_step_panel->set_steps_string(auto_steps);
m_step_panel->set_steps(1);
}
else if (method == CalibrationMethod::CALI_METHOD_MANUAL) {
if (m_cali_mode == CalibMode::Calib_PA_Line) {
m_step_panel->set_steps_string(auto_steps);
m_step_panel->set_steps(1);
} else {
m_step_panel->set_steps_string(manual_steps);
if (m_page_type == CaliPageType::CALI_PAGE_CALI)
m_step_panel->set_steps(1);
else if (m_page_type == CaliPageType::CALI_PAGE_FINE_CALI) {
m_step_panel->set_steps(2);
}
else {
m_step_panel->set_steps(1);
}
}
}
else {
assert(false);
}
}
float CalibrationCaliPage::get_selected_calibration_nozzle_dia(MachineObject* obj)
{
// return selected if this is set
if (obj->cali_selected_nozzle_dia > 1e-3 && obj->cali_selected_nozzle_dia < 10.0f)
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;
// return 0.4 by default
return 0.4;
}
}}