FIX: add ams status check before print
jira: none Change-Id: I5fd03ec596ddddd1b568325c509914cd9aec0f61
This commit is contained in:
parent
563e4ca8cf
commit
8fca76aac9
|
@ -1595,6 +1595,10 @@ wxBoxSizer* MainFrame::create_side_tools()
|
|||
|
||||
m_slice_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event)
|
||||
{
|
||||
m_plater->reset_check_status();
|
||||
if (!m_plater->check_ams_status())
|
||||
return;
|
||||
|
||||
//this->m_plater->select_view_3D("Preview");
|
||||
m_plater->exit_gizmo();
|
||||
m_plater->update(true, true);
|
||||
|
@ -2055,11 +2059,16 @@ void MainFrame::update_slice_print_status(SlicePrintEventType event, bool can_sl
|
|||
enable_slice = get_enable_slice_status();
|
||||
}
|
||||
|
||||
bool old_slice_status = m_slice_btn->IsEnabled();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" m_slice_select %1%: can_slice= %2%, can_print %3%, enable_slice %4%, enable_print %5% ")%m_slice_select % can_slice %can_print %enable_slice %enable_print;
|
||||
m_print_btn->Enable(enable_print);
|
||||
m_slice_btn->Enable(enable_slice);
|
||||
m_slice_enable = enable_slice;
|
||||
m_print_enable = enable_print;
|
||||
|
||||
if (!old_slice_status && enable_slice)
|
||||
m_plater->reset_check_status();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2767,6 +2767,7 @@ struct Plater::priv
|
|||
GLCanvas3D* get_current_canvas3D(bool exclude_preview = false);
|
||||
void unbind_canvas_event_handlers();
|
||||
void reset_canvas_volumes();
|
||||
bool check_ams_status_impl(); // Check whether the printer and ams status are consistent, for grouping algorithm
|
||||
|
||||
// BBS
|
||||
bool init_collapse_toolbar();
|
||||
|
@ -3707,6 +3708,9 @@ void Plater::priv::select_view_3D(const std::string& name, bool no_slice)
|
|||
set_current_panel(view3D, no_slice);
|
||||
}
|
||||
else if (name == "Preview") {
|
||||
if (!q->check_ams_status())
|
||||
return;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "select preview";
|
||||
//BBS update extruder params and speed table before slicing
|
||||
const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
|
||||
|
@ -7599,6 +7603,9 @@ void Plater::priv::on_action_open_project(SimpleEvent&)
|
|||
void Plater::priv::on_action_slice_plate(SimpleEvent&)
|
||||
{
|
||||
if (q != nullptr) {
|
||||
if (!q->check_ams_status())
|
||||
return;
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice plate event\n" ;
|
||||
//BBS update extruder params and speed table before slicing
|
||||
const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
|
||||
|
@ -8410,6 +8417,66 @@ void Plater::priv::reset_canvas_volumes()
|
|||
preview->get_canvas3d()->reset_volumes();
|
||||
}
|
||||
|
||||
bool Plater::priv::check_ams_status_impl()
|
||||
{
|
||||
Slic3r::DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev)
|
||||
return true;
|
||||
|
||||
MachineObject* obj = dev->get_selected_machine();
|
||||
if (!obj || !obj->is_multi_extruders())
|
||||
return true;
|
||||
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == obj->printer_type) {
|
||||
std::vector<std::map<int, int>> ams_count_info;
|
||||
ams_count_info.resize(2);
|
||||
int deputy_4 = 0, main_4 = 0, deputy_1 = 0, main_1 = 0;
|
||||
for (auto ams : obj->amsList) {
|
||||
// Main (first) extruder at right
|
||||
if (ams.second->nozzle == 0) {
|
||||
if (ams.second->type == 4) // N3S
|
||||
++main_1;
|
||||
else
|
||||
++main_4;
|
||||
} else if (ams.second->nozzle == 1) {
|
||||
if (ams.second->type == 4) // N3S
|
||||
++deputy_1;
|
||||
else
|
||||
++deputy_4;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_same_as_printer = preset_bundle->extruder_ams_counts[0][4] == main_4
|
||||
&& preset_bundle->extruder_ams_counts[0][1] == main_1
|
||||
&& preset_bundle->extruder_ams_counts[1][4] == deputy_4
|
||||
&& preset_bundle->extruder_ams_counts[1][1] == deputy_1;
|
||||
|
||||
if (!is_same_as_printer) {
|
||||
struct SyncInfoDialog : MessageDialog
|
||||
{
|
||||
SyncInfoDialog(wxWindow *parent)
|
||||
: MessageDialog(parent,
|
||||
_L("It is detected that you have not synchronized the nozzle and AMS information.\n"
|
||||
"If you synchronize it before slicing, the filament arrangement will be more reasonable.\n"
|
||||
"Do you need to synchronize it ?"),
|
||||
_L("Warning"), 0)
|
||||
{
|
||||
add_button(wxID_YES, true, _L("Sync now"));
|
||||
add_button(wxID_NO, true, _L("Out of sync"));
|
||||
}
|
||||
} dlg(q);
|
||||
dlg.Fit();
|
||||
if (dlg.ShowModal() == wxID_YES) {
|
||||
GUI::wxGetApp().sidebar().sync_extruder_list();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Plater::priv::init_collapse_toolbar()
|
||||
{
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
|
@ -14951,6 +15018,21 @@ void Plater::post_process_string_object_exception(StringObjectException &err)
|
|||
return;
|
||||
}
|
||||
|
||||
bool Plater::check_ams_status()
|
||||
{
|
||||
if (m_check_status == 0) {
|
||||
if (!p->check_ams_status_impl()) {
|
||||
m_check_status = 0;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
m_check_status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
void Plater::init_environment_texture()
|
||||
{
|
||||
|
|
|
@ -590,6 +590,8 @@ public:
|
|||
//BBS: post process string object exception strings by warning types
|
||||
void post_process_string_object_exception(StringObjectException &err);
|
||||
|
||||
bool check_ams_status();
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
void init_environment_texture();
|
||||
unsigned int get_environment_texture_id() const;
|
||||
|
@ -760,6 +762,7 @@ public:
|
|||
return m_arrange_running.compare_exchange_strong(prevRunning, true);
|
||||
};
|
||||
std::atomic<bool> m_arrange_running{false};
|
||||
void reset_check_status() { m_check_status = 0; }
|
||||
|
||||
private:
|
||||
struct priv;
|
||||
|
@ -779,6 +782,7 @@ private:
|
|||
bool m_loading_project {false };
|
||||
std::string m_preview_only_filename;
|
||||
int m_valid_plates_count { 0 };
|
||||
int m_check_status = 0; // 0 not check, 1 check success, 2 check failed
|
||||
|
||||
void suppress_snapshots();
|
||||
void allow_snapshots();
|
||||
|
|
Loading…
Reference in New Issue