FIX: fix serveral issues under multiple plate slicing

1. preview result not correct when switch from invalid to valid
2. slice_all button not correct after loading gcode
3. slice_all button always set to enable with normal model(not gcode and exported files)
4. thumbnail missing issue after mmu paint

Change-Id: I9873a035acc277b790d46d705c4a794c09bbd889
This commit is contained in:
lane.wei 2022-11-17 20:02:39 +08:00 committed by Lane.Wei
parent 276989a878
commit aac34a5411
3 changed files with 31 additions and 17 deletions

View file

@ -697,7 +697,9 @@ void GLGizmoMmuSegmentation::update_model_object()
if (updated) {
const ModelObjectPtrs &mos = wxGetApp().model().objects;
wxGetApp().obj_list()->update_info_items(std::find(mos.begin(), mos.end(), mo) - mos.begin());
size_t obj_idx = std::find(mos.begin(), mos.end(), mo) - mos.begin();
wxGetApp().obj_list()->update_info_items(obj_idx);
wxGetApp().plater()->get_partplate_list().notify_instance_update(obj_idx, 0);
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
}
}

View file

@ -526,8 +526,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
if (evt.CmdDown() && evt.GetKeyCode() == 'J') { m_printhost_queue_dlg->Show(); return; }
if (evt.CmdDown() && evt.GetKeyCode() == 'N') { m_plater->new_project(); return;}
if (evt.CmdDown() && evt.GetKeyCode() == 'O') { m_plater->load_project(); return;}
if (evt.CmdDown() && evt.ShiftDown() && evt.GetKeyCode() == 'S') { if (m_plater) m_plater->save_project(true); return;}
else if (evt.CmdDown() && evt.GetKeyCode() == 'S') { if (m_plater) m_plater->save_project(); return;}
if (evt.CmdDown() && evt.ShiftDown() && evt.GetKeyCode() == 'S') { if (can_save_as()) m_plater->save_project(true); return;}
else if (evt.CmdDown() && evt.GetKeyCode() == 'S') { if (can_save()) m_plater->save_project(); return;}
#ifdef __APPLE__
if (evt.CmdDown() && evt.GetKeyCode() == ',')
@ -1083,13 +1083,13 @@ bool MainFrame::can_save() const
{
return (m_plater != nullptr) &&
!m_plater->get_view3D_canvas3D()->get_gizmos_manager().is_in_editing_mode(false) &&
m_plater->is_project_dirty();
m_plater->is_project_dirty() && !m_plater->using_exported_file() && !m_plater->only_gcode_mode();
}
bool MainFrame::can_save_as() const
{
return (m_plater != nullptr) &&
!m_plater->get_view3D_canvas3D()->get_gizmos_manager().is_in_editing_mode(false);
!m_plater->get_view3D_canvas3D()->get_gizmos_manager().is_in_editing_mode(false) && !m_plater->using_exported_file() && !m_plater->only_gcode_mode();
}
void MainFrame::save_project()
@ -1512,20 +1512,26 @@ bool MainFrame::get_enable_slice_status()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": on slicing, return false directly!");
return false;
}
else if (m_plater->only_gcode_mode() || m_plater->using_exported_file()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": in gcode/exported 3mf mode, return false directly!");
return false;
}
PartPlateList &part_plate_list = m_plater->get_partplate_list();
PartPlate *current_plate = part_plate_list.get_curr_plate();
if (m_slice_select == eSliceAll)
{
if (part_plate_list.is_all_slice_results_valid())
/*if (part_plate_list.is_all_slice_results_valid())
{
enable = false;
}
else if (!part_plate_list.is_all_plates_ready_for_slice())
{
enable = false;
}
}*/
//always enable slice_all button
enable = true;
}
else if (m_slice_select == eSlicePlate)
{
@ -2150,13 +2156,13 @@ void MainFrame::init_menubar_as_editor()
// BBS
//publish menu
if (m_plater) {
publishMenu = new wxMenu();
add_common_publish_menu_items(publishMenu, this);
publishMenu->AppendSeparator();
}
// View menu
wxMenu* viewMenu = nullptr;
if (m_plater) {

View file

@ -9068,7 +9068,12 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
if (!(strategy & SaveStrategy::Backup)) {
for (int i = 0; i < p->partplate_list.get_plate_count(); i++) {
ThumbnailData* thumbnail_data = &p->partplate_list.get_plate(i)->thumbnail_data;
if (!p->partplate_list.get_plate(i)->thumbnail_data.is_valid()) {
if (p->partplate_list.get_plate(i)->thumbnail_data.is_valid() && using_exported_file()) {
//no need to generate thumbnail
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": non need to re-generate thumbnail for gcode/exported mode of plate %1%")%i;
}
else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": re-generate thumbnail for plate %1%") % i;
const ThumbnailsParams thumbnail_params = { {}, false, true, true, true, i };
p->generate_thumbnail(p->partplate_list.get_plate(i)->thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, thumbnail_params, Camera::EType::Ortho);
}
@ -9270,6 +9275,14 @@ void Plater::reslice()
//BBS: jusdge the result
bool result = this->p->restart_background_process(state | priv::UPDATE_BACKGROUND_PROCESS_FORCE_RESTART);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: restart background,state=%2%, result=%3%")%__LINE__%state %result;
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) != 0)
{
//BBS: add logs
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": state %1% is UPDATE_BACKGROUND_PROCESS_INVALID, can not slice") % state;
p->update_fff_scene_only_shells();
return;
}
if ((!result) && p->m_slice_all && (p->m_cur_slice_plate < (p->partplate_list.get_plate_count() - 1)))
{
//slice next
@ -9290,13 +9303,6 @@ void Plater::reslice()
this->SetDropTarget(nullptr);
}
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) != 0)
{
//BBS: add logs
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": state %1% is UPDATE_BACKGROUND_PROCESS_INVALID, can not slice") % state ;
return;
}
bool clean_gcode_toolpaths = true;
// BBS
if (p->background_process.running())