NEW: display bitmap when calibrating

Jira: STUDIO-4661

Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com>
Change-Id: I60cf4f9769feca74699012418880e93fcfe34432
(cherry picked from commit 1213aea816694405311dc0c1061655a4c2a1d067)
This commit is contained in:
wenjie.guo 2023-12-04 17:19:05 +08:00 committed by Lane.Wei
parent c9ac1cc04f
commit 57a9e676a4
3 changed files with 80 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

View File

@ -1840,7 +1840,7 @@ void StatusPanel::on_subtask_abort(wxCommandEvent &event)
if (abort_dlg == nullptr) {
abort_dlg = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Cancel print"));
abort_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent &e) {
if (obj) {
if (obj) {
BOOST_LOG_TRIVIAL(info) << "monitor: stop current print task dev_id =" << obj->dev_id;
obj->command_task_abort();
}
@ -1871,10 +1871,12 @@ void StatusPanel::on_webrequest_state(wxWebRequestEvent &evt)
BOOST_LOG_TRIVIAL(trace) << "monitor: monitor_panel web request state = " << evt.GetState();
switch (evt.GetState()) {
case wxWebRequest::State_Completed: {
wxImage img(*evt.GetResponse().GetStream());
img_list.insert(std::make_pair(m_request_url, img));
wxImage resize_img = img.Scale(m_project_task_panel->get_bitmap_thumbnail()->GetSize().x, m_project_task_panel->get_bitmap_thumbnail()->GetSize().y, wxIMAGE_QUALITY_HIGH);
m_project_task_panel->set_thumbnail_img(resize_img);
if (m_current_print_mode != PrintingTaskType::CALIBRATION ||(m_calib_mode == CalibMode::Calib_Flow_Rate && m_calib_method == CalibrationMethod::CALI_METHOD_MANUAL)) {
wxImage img(*evt.GetResponse().GetStream());
img_list.insert(std::make_pair(m_request_url, img));
wxImage resize_img = img.Scale(m_project_task_panel->get_bitmap_thumbnail()->GetSize().x, m_project_task_panel->get_bitmap_thumbnail()->GetSize().y, wxIMAGE_QUALITY_HIGH);
m_project_task_panel->set_thumbnail_img(resize_img);
}
if (obj) {
m_project_task_panel->set_plate_index(obj->m_plate_index);
} else {
@ -1937,7 +1939,6 @@ bool StatusPanel::is_task_changed(MachineObject* obj)
void StatusPanel::update(MachineObject *obj)
{
if (!obj) return;
m_project_task_panel->Freeze();
update_subtask(obj);
m_project_task_panel->Thaw();
@ -2753,6 +2754,14 @@ void StatusPanel::update_cali(MachineObject *obj)
}
}
void StatusPanel::update_calib_bitmap() {
m_current_print_mode = PrintingTaskType::NOT_CLEAR; //printing task might be changed when updating.
if (calib_bitmap != nullptr) {
delete calib_bitmap;
calib_bitmap = nullptr;
}
}
void StatusPanel::update_basic_print_data(bool def)
{
if (def) {
@ -2798,7 +2807,52 @@ void StatusPanel::update_model_info()
void StatusPanel::update_subtask(MachineObject *obj)
{
if (!obj) return;
if (m_current_print_mode != PRINGINT) {
if (calib_bitmap == nullptr) {
m_calib_mode = get_obj_calibration_mode(obj, m_calib_method, cali_stage);
if (m_calib_mode == CalibMode::Calib_None)
m_current_print_mode = PRINGINT;
// the printing task is calibrattion, not normal printing.
else if (m_calib_mode != CalibMode::Calib_None) {
m_current_print_mode = CALIBRATION;
auto get_bitmap = [](wxString& png_path, int width, int height) {
wxImage image(width, height);
image.LoadFile(png_path, wxBITMAP_TYPE_PNG);
image = image.Scale(width, height, wxIMAGE_QUALITY_NORMAL);
return wxBitmap(image);
};
wxString png_path = "";
int width = m_project_task_panel->get_bitmap_thumbnail()->GetSize().x;
int height = m_project_task_panel->get_bitmap_thumbnail()->GetSize().y;
if (m_calib_method == CALI_METHOD_AUTO) {
if (m_calib_mode == CalibMode::Calib_PA_Line) {
png_path = (boost::format("%1%/images/fd_calibration_auto.png") % resources_dir()).str();
}
else if (m_calib_mode == CalibMode::Calib_Flow_Rate) {
png_path = (boost::format("%1%/images/flow_rate_calibration_auto.png") % resources_dir()).str();
}
}
else if (m_calib_method == CALI_METHOD_MANUAL) {
if (m_calib_mode== CalibMode::Calib_PA_Line) {
if (cali_stage == 0) { // Line mode
png_path = (boost::format("%1%/images/fd_calibration_manual.png") % resources_dir()).str();
}
else if (cali_stage == 1) { // Pattern mode
png_path = (boost::format("%1%/images/fd_pattern_manual_device.png") % resources_dir()).str();
}
}
}
if (png_path != "") {
calib_bitmap = new wxBitmap;
*calib_bitmap = get_bitmap(png_path, width, height);
}
}
}
if (calib_bitmap != nullptr)
m_project_task_panel->set_thumbnail_img(*calib_bitmap);
}
if (obj->is_support_layer_num) {
m_project_task_panel->update_layers_num(true);
}
@ -2956,15 +3010,18 @@ void StatusPanel::update_cloud_subtask(MachineObject *obj)
}
if (m_start_loading_thumbnail) {
update_calib_bitmap();
if (obj->slice_info) {
m_request_url = wxString(obj->slice_info->thumbnail_url);
if (!m_request_url.IsEmpty()) {
wxImage img;
std::map<wxString, wxImage>::iterator it = img_list.find(m_request_url);
if (it != img_list.end()) {
img = it->second;
wxImage resize_img = img.Scale(m_project_task_panel->get_bitmap_thumbnail()->GetSize().x, m_project_task_panel->get_bitmap_thumbnail()->GetSize().y);
m_project_task_panel->set_thumbnail_img(resize_img);
if (m_current_print_mode != PrintingTaskType::CALIBRATION ||(m_calib_mode == CalibMode::Calib_Flow_Rate && m_calib_method == CalibrationMethod::CALI_METHOD_MANUAL)) {
img = it->second;
wxImage resize_img = img.Scale(m_project_task_panel->get_bitmap_thumbnail()->GetSize().x, m_project_task_panel->get_bitmap_thumbnail()->GetSize().y);
m_project_task_panel->set_thumbnail_img(resize_img);
}
if (this->obj) {
m_project_task_panel->set_plate_index(obj->m_plate_index);
} else {
@ -2988,7 +3045,10 @@ void StatusPanel::update_sdcard_subtask(MachineObject *obj)
if (!obj) return;
if (!m_load_sdcard_thumbnail) {
m_project_task_panel->get_bitmap_thumbnail()->SetBitmap(m_thumbnail_sdcard.bmp());
update_calib_bitmap();
if (m_current_print_mode != PrintingTaskType::CALIBRATION) {
m_project_task_panel->get_bitmap_thumbnail()->SetBitmap(m_thumbnail_sdcard.bmp());
}
task_thumbnail_state = ThumbnailState::SDCARD_THUMBNAIL;
m_load_sdcard_thumbnail = true;
}
@ -3009,7 +3069,7 @@ void StatusPanel::reset_printing_values()
update_basic_print_data(false);
m_project_task_panel->update_left_time(NA_STR);
m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
update_calib_bitmap();
task_thumbnail_state = ThumbnailState::PLACE_HOLDER;
m_start_loading_thumbnail = false;

View File

@ -17,6 +17,7 @@
#include "MediaPlayCtrl.h"
#include "AMSSetting.hpp"
#include "Calibration.hpp"
#include "CalibrationWizardPage.hpp"
#include "PrintOptionsDialog.hpp"
#include "AMSMaterialsSetting.hpp"
#include "ExtrusionCalibration.hpp"
@ -58,6 +59,7 @@ enum CameraTimelapseStatus {
enum PrintingTaskType {
PRINGINT,
CALIBRATION,
NOT_CLEAR
};
struct ScoreData
@ -210,7 +212,7 @@ public:
void show_error_msg(wxString msg);
void reset_printing_value();
void msw_rescale();
public:
void enable_pause_resume_button(bool enable, std::string type);
void enable_abort_button(bool enable);
@ -492,6 +494,11 @@ protected:
std::vector<Button *> m_buttons;
int last_status;
ScoreData *m_score_data;
wxBitmap* calib_bitmap = nullptr;
CalibMode m_calib_mode;
CalibrationMethod m_calib_method;
int cali_stage;
PrintingTaskType m_current_print_mode = PrintingTaskType::NOT_CLEAR;
void init_scaled_buttons();
void create_tasklist_info();
@ -582,6 +589,7 @@ protected:
void update_extruder_status(MachineObject* obj);
void update_ams_control_state(bool is_curr_tray_selected);
void update_cali(MachineObject* obj);
void update_calib_bitmap();
void reset_printing_values();
void on_webrequest_state(wxWebRequestEvent &evt);