NEW: add confirm dialog after check conditions
confirm to check printer model and slice warnings Change-Id: I07a272fda1a5e2ebc0f4e106815fe07da5aaa4df Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
a84cf46699
commit
ee62ffcc7d
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
// slice warnings enum strings
|
||||||
|
#define BED_TEMP_TOO_HIGH_THAN_FILAMENT "bed_temperature_too_high_than_filament"
|
||||||
|
|
||||||
enum class EMoveType : unsigned char
|
enum class EMoveType : unsigned char
|
||||||
{
|
{
|
||||||
Noop,
|
Noop,
|
||||||
|
@ -128,6 +131,14 @@ namespace Slic3r {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SliceWarnings {
|
||||||
|
int level; // 0: normal tips, 1: warning; 2: error
|
||||||
|
std::string msg; // enum string
|
||||||
|
std::vector<std::string> params; // extra msg info
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<SliceWarnings> warnings;
|
||||||
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
std::vector<MoveVertex> moves;
|
std::vector<MoveVertex> moves;
|
||||||
|
|
|
@ -644,6 +644,24 @@ std::string Preset::get_filament_type(std::string &display_filament_type)
|
||||||
return config.get_filament_type(display_filament_type);
|
return config.get_filament_type(display_filament_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Preset::get_printer_type(PresetBundle *preset_bundle)
|
||||||
|
{
|
||||||
|
if (preset_bundle) {
|
||||||
|
auto config = &preset_bundle->printers.get_edited_preset().config;
|
||||||
|
std::string vendor_name;
|
||||||
|
for (auto vendor_profile : preset_bundle->vendors) {
|
||||||
|
for (auto vendor_model : vendor_profile.second.models)
|
||||||
|
if (vendor_model.name == config->opt_string("printer_model"))
|
||||||
|
{
|
||||||
|
vendor_name = vendor_profile.first;
|
||||||
|
return vendor_model.model_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Preset::is_bbl_vendor_preset(PresetBundle *preset_bundle)
|
bool Preset::is_bbl_vendor_preset(PresetBundle *preset_bundle)
|
||||||
{
|
{
|
||||||
bool is_bbl_vendor_preset = true;
|
bool is_bbl_vendor_preset = true;
|
||||||
|
|
|
@ -296,8 +296,9 @@ public:
|
||||||
|
|
||||||
// special for upport G and Support W
|
// special for upport G and Support W
|
||||||
std::string get_filament_type(std::string &display_filament_type);
|
std::string get_filament_type(std::string &display_filament_type);
|
||||||
|
std::string get_printer_type(PresetBundle *preset_bundle);
|
||||||
|
|
||||||
bool is_bbl_vendor_preset(PresetBundle *m_preset_bundle);
|
bool is_bbl_vendor_preset(PresetBundle *preset_bundle);
|
||||||
|
|
||||||
static const std::vector<std::string>& print_options();
|
static const std::vector<std::string>& print_options();
|
||||||
static const std::vector<std::string>& filament_options();
|
static const std::vector<std::string>& filament_options();
|
||||||
|
|
|
@ -104,8 +104,13 @@ void ConfirmHintDialog::render(wxDC& dc) {
|
||||||
auto text_size = dc.GetTextExtent(count_txt);
|
auto text_size = dc.GetTextExtent(count_txt);
|
||||||
if (text_size.x + pos_firm_up_hint.x + FromDIP(25) < wxSize(FromDIP(475), FromDIP(100)).x)
|
if (text_size.x + pos_firm_up_hint.x + FromDIP(25) < wxSize(FromDIP(475), FromDIP(100)).x)
|
||||||
{
|
{
|
||||||
if (firm_up_hint[i] == ' ' || firm_up_hint[i] == '\n')
|
if (firm_up_hint[i] == ' ') {
|
||||||
new_line_pos = i;
|
new_line_pos = i;
|
||||||
|
} else if (firm_up_hint[i] == '\n') {
|
||||||
|
fisrt_line = firm_up_hint.SubString(0, i);
|
||||||
|
remaining_line = firm_up_hint.SubString(i + 1, firm_up_hint.length());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!is_ch) {
|
if (!is_ch) {
|
||||||
|
@ -123,7 +128,6 @@ void ConfirmHintDialog::render(wxDC& dc) {
|
||||||
}
|
}
|
||||||
dc.DrawText(fisrt_line, pos_firm_up_hint);
|
dc.DrawText(fisrt_line, pos_firm_up_hint);
|
||||||
|
|
||||||
|
|
||||||
count_txt = "";
|
count_txt = "";
|
||||||
new_line_pos = 0;
|
new_line_pos = 0;
|
||||||
for (int i = 0; i < remaining_line.length(); i++) {
|
for (int i = 0; i < remaining_line.length(); i++) {
|
||||||
|
@ -167,6 +171,12 @@ void ConfirmHintDialog::on_button_close(wxCommandEvent& event) {
|
||||||
this->Close();
|
this->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfirmHintDialog::Show(bool show)
|
||||||
|
{
|
||||||
|
if (show) { CentreOnParent(); }
|
||||||
|
return DPIDialog::Show(show);
|
||||||
|
}
|
||||||
|
|
||||||
void ConfirmHintDialog::on_dpi_changed(const wxRect& suggested_rect) {
|
void ConfirmHintDialog::on_dpi_changed(const wxRect& suggested_rect) {
|
||||||
m_button_confirm->SetMinSize(wxSize(-1, FromDIP(24)));
|
m_button_confirm->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||||
m_button_confirm->SetCornerRadius(FromDIP(12));
|
m_button_confirm->SetCornerRadius(FromDIP(12));
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
|
|
||||||
void SetHint(const wxString &hint);
|
void SetHint(const wxString &hint);
|
||||||
|
|
||||||
|
bool Show(bool show) override;
|
||||||
|
|
||||||
~ConfirmHintDialog();
|
~ConfirmHintDialog();
|
||||||
};
|
};
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
|
|
@ -347,6 +347,7 @@ public:
|
||||||
Print* fff_print() { return m_print; }
|
Print* fff_print() { return m_print; }
|
||||||
//return the slice result
|
//return the slice result
|
||||||
GCodeProcessorResult* get_slice_result() { return m_gcode_result; }
|
GCodeProcessorResult* get_slice_result() { return m_gcode_result; }
|
||||||
|
|
||||||
std::string get_tmp_gcode_path();
|
std::string get_tmp_gcode_path();
|
||||||
std::string get_temp_config_3mf_path();
|
std::string get_temp_config_3mf_path();
|
||||||
//this API should only be used for command line usage
|
//this API should only be used for command line usage
|
||||||
|
|
|
@ -2540,6 +2540,16 @@ wxColour Plater::get_next_color_for_filament()
|
||||||
return colors[curr_color_filamenet++ % 7];
|
return colors[curr_color_filamenet++ % 7];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString Plater::get_slice_warning_string(GCodeProcessorResult::SliceWarnings& warning)
|
||||||
|
{
|
||||||
|
if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) {
|
||||||
|
return _L("The bed temperature exceeds filament's vitrification temperature. Please open the front door of printer before printing to avoid nozzle clog.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return wxString(warning.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Plater::priv::apply_free_camera_correction(bool apply/* = true*/)
|
void Plater::priv::apply_free_camera_correction(bool apply/* = true*/)
|
||||||
{
|
{
|
||||||
bool use_perspective_camera = get_config("use_perspective_camera").compare("true") == 0;
|
bool use_perspective_camera = get_config("use_perspective_camera").compare("true") == 0;
|
||||||
|
|
|
@ -235,6 +235,7 @@ public:
|
||||||
static void setPrintSpeedTable(Slic3r::GlobalSpeedMap& printSpeedMap);
|
static void setPrintSpeedTable(Slic3r::GlobalSpeedMap& printSpeedMap);
|
||||||
static void setExtruderParams(std::map<size_t, Slic3r::ExtruderParams>& extParas);
|
static void setExtruderParams(std::map<size_t, Slic3r::ExtruderParams>& extParas);
|
||||||
static wxColour get_next_color_for_filament();
|
static wxColour get_next_color_for_filament();
|
||||||
|
static wxString get_slice_warning_string(GCodeProcessorResult::SliceWarnings& warning);
|
||||||
|
|
||||||
// BBS: restore
|
// BBS: restore
|
||||||
std::vector<size_t> load_files(const std::vector<boost::filesystem::path>& input_files, LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig, bool ask_multi = false);
|
std::vector<size_t> load_files(const std::vector<boost::filesystem::path>& input_files, LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig, bool ask_multi = false);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
#include "BitmapCache.hpp"
|
#include "BitmapCache.hpp"
|
||||||
#include "BindDialog.hpp"
|
#include "BindDialog.hpp"
|
||||||
|
#include "ConfirmHintDialog.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
@ -1046,7 +1047,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||||
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(12));
|
||||||
|
|
||||||
m_button_ensure->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_ok, this);
|
m_button_ensure->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_ok_btn, this);
|
||||||
m_sizer_pcont->Add(m_button_ensure, 0, wxEXPAND | wxBOTTOM, FromDIP(10));
|
m_sizer_pcont->Add(m_button_ensure, 0, wxEXPAND | wxBOTTOM, FromDIP(10));
|
||||||
m_sizer_prepare->Add(m_sizer_pcont, 0, wxEXPAND, 0);
|
m_sizer_prepare->Add(m_sizer_pcont, 0, wxEXPAND, 0);
|
||||||
m_panel_prepare->SetSizer(m_sizer_prepare);
|
m_panel_prepare->SetSizer(m_sizer_prepare);
|
||||||
|
@ -1716,7 +1717,67 @@ void SelectMachineDialog::on_cancel(wxCloseEvent &event)
|
||||||
this->EndModal(wxID_CANCEL);
|
this->EndModal(wxID_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectMachineDialog::on_ok(wxCommandEvent &event)
|
bool SelectMachineDialog::is_same_printer_model()
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||||
|
if (!dev) return result;
|
||||||
|
|
||||||
|
MachineObject* obj_ = dev->get_selected_machine();
|
||||||
|
assert(obj_->dev_id == m_printer_last_select);
|
||||||
|
if (obj_ == nullptr) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||||
|
if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) != obj_->printer_type) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "printer_model: target = " << obj_->printer_type;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
|
||||||
|
{
|
||||||
|
wxString confirm_text = _L("Please check the following infomation:\n");
|
||||||
|
|
||||||
|
//Check Printer Model Id
|
||||||
|
bool is_same_printer_type = is_same_printer_model();
|
||||||
|
confirm_text += _L("The printer type used to generate G-code is not the same type as the currently selected physical printer. It is recommend to re-slice by selecting the same printer type.\n");
|
||||||
|
|
||||||
|
//Check slice warnings
|
||||||
|
bool has_slice_warnings = false;
|
||||||
|
PartPlate* plate = m_plater->get_partplate_list().get_curr_plate();
|
||||||
|
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||||
|
if (dev) {
|
||||||
|
MachineObject* obj_ = dev->get_selected_machine();
|
||||||
|
for (auto warning : plate->get_slice_result()->warnings) {
|
||||||
|
if ((obj_->printer_type == "BL-P001" || obj_->printer_type == "BL-P002") && warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) {
|
||||||
|
confirm_text += Plater::get_slice_warning_string(warning) + "\n";
|
||||||
|
} else {
|
||||||
|
has_slice_warnings = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_same_printer_type
|
||||||
|
|| has_slice_warnings
|
||||||
|
) {
|
||||||
|
wxString confirm_title = _L("Confirm");
|
||||||
|
ConfirmHintDialog confirm_dlg(this, wxID_ANY, confirm_title);
|
||||||
|
confirm_dlg.SetHint(confirm_text);
|
||||||
|
confirm_dlg.Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent& e) {
|
||||||
|
this->on_ok();
|
||||||
|
});
|
||||||
|
confirm_dlg.ShowModal();
|
||||||
|
} else {
|
||||||
|
this->on_ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectMachineDialog::on_ok()
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "print_job: on_ok to send";
|
BOOST_LOG_TRIVIAL(info) << "print_job: on_ok to send";
|
||||||
m_is_canceled = false;
|
m_is_canceled = false;
|
||||||
|
|
|
@ -358,6 +358,8 @@ public:
|
||||||
void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>());
|
void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>());
|
||||||
PrintDialogStatus get_status() { return m_print_status; }
|
PrintDialogStatus get_status() { return m_print_status; }
|
||||||
|
|
||||||
|
bool is_same_printer_model();
|
||||||
|
|
||||||
bool Show(bool show);
|
bool Show(bool show);
|
||||||
|
|
||||||
/* model */
|
/* model */
|
||||||
|
@ -393,7 +395,8 @@ protected:
|
||||||
// Virtual event handlers, overide them in your derived class
|
// Virtual event handlers, overide them in your derived class
|
||||||
void update_printer_combobox(wxCommandEvent &event);
|
void update_printer_combobox(wxCommandEvent &event);
|
||||||
void on_cancel(wxCloseEvent &event);
|
void on_cancel(wxCloseEvent &event);
|
||||||
void on_ok(wxCommandEvent &event);
|
void on_ok_btn(wxCommandEvent &event);
|
||||||
|
void on_ok();
|
||||||
void on_refresh(wxCommandEvent &event);
|
void on_refresh(wxCommandEvent &event);
|
||||||
void on_set_finish_mapping(wxCommandEvent &evt);
|
void on_set_finish_mapping(wxCommandEvent &evt);
|
||||||
void on_print_job_cancel(wxCommandEvent &evt);
|
void on_print_job_cancel(wxCommandEvent &evt);
|
||||||
|
|
Loading…
Reference in New Issue