Follow-up of 15bd82edc3 - Fixed detection of out of printbed after arrange

This commit is contained in:
enricoturri1966 2023-05-19 09:42:30 +02:00
parent 2f7f3578d5
commit 0dacdb2061
5 changed files with 16 additions and 16 deletions

View File

@ -1508,15 +1508,15 @@ void GLCanvas3D::reset_volumes()
_set_warning_notification(EWarning::ObjectOutside, false);
}
ModelInstanceEPrintVolumeState GLCanvas3D::check_volumes_outside_state() const
ModelInstanceEPrintVolumeState GLCanvas3D::check_volumes_outside_state(bool selection_only) const
{
ModelInstanceEPrintVolumeState state = ModelInstanceEPrintVolumeState::ModelInstancePVS_Inside;
if (m_initialized && !m_volumes.empty())
check_volumes_outside_state(m_bed.build_volume(), &state);
check_volumes_outside_state(m_bed.build_volume(), &state, selection_only);
return state;
}
bool GLCanvas3D::check_volumes_outside_state(const Slic3r::BuildVolume& build_volume, ModelInstanceEPrintVolumeState* out_state) const
bool GLCanvas3D::check_volumes_outside_state(const Slic3r::BuildVolume& build_volume, ModelInstanceEPrintVolumeState* out_state, bool selection_only) const
{
auto volume_below = [](GLVolume& volume) -> bool
{ return volume.object_idx() != -1 && volume.volume_idx() != -1 && volume.is_below_printbed(); };
@ -1530,9 +1530,9 @@ bool GLCanvas3D::check_volumes_outside_state(const Slic3r::BuildVolume& build_vo
auto volume_convex_mesh = [this, volume_sinking](GLVolume& volume) -> const TriangleMesh&
{ return volume_sinking(volume) ? m_model->objects[volume.object_idx()]->volumes[volume.volume_idx()]->mesh() : *volume.convex_hull(); };
auto volumes_to_process_idxs = [this]() {
auto volumes_to_process_idxs = [this, selection_only]() {
std::vector<unsigned int> ret;
if (m_selection.is_empty()) {
if (!selection_only || m_selection.is_empty()) {
ret = std::vector<unsigned int>(m_volumes.volumes.size());
std::iota(ret.begin(), ret.end(), 0);
}
@ -2603,7 +2603,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
// checks for geometry outside the print volume to render it accordingly
if (!m_volumes.empty()) {
ModelInstanceEPrintVolumeState state;
const bool contained_min_one = check_volumes_outside_state(m_bed.build_volume(), &state);
const bool contained_min_one = check_volumes_outside_state(m_bed.build_volume(), &state, !force_full_scene_refresh);
const bool partlyOut = (state == ModelInstanceEPrintVolumeState::ModelInstancePVS_Partly_Outside);
const bool fullyOut = (state == ModelInstanceEPrintVolumeState::ModelInstancePVS_Fully_Outside);

View File

@ -736,10 +736,10 @@ public:
unsigned int get_volumes_count() const;
const GLVolumeCollection& get_volumes() const { return m_volumes; }
void reset_volumes();
ModelInstanceEPrintVolumeState check_volumes_outside_state() const;
ModelInstanceEPrintVolumeState check_volumes_outside_state(bool selection_only = true) const;
// returns true if all the volumes are completely contained in the print volume
// returns the containment state in the given out_state, if non-null
bool check_volumes_outside_state(const Slic3r::BuildVolume& build_volume, ModelInstanceEPrintVolumeState* out_state) const;
bool check_volumes_outside_state(const Slic3r::BuildVolume& build_volume, ModelInstanceEPrintVolumeState* out_state, bool selection_only = true) const;
void init_gcode_viewer() { m_gcode_viewer.init(); }
void reset_gcode_toolpaths() { m_gcode_viewer.reset(); }

View File

@ -355,7 +355,7 @@ void ArrangeJob::finalize(bool canceled, std::exception_ptr &eptr) {
ap.apply();
}
m_plater->update();
m_plater->update((unsigned int)Plater::UpdateParams::FORCE_FULL_SCREEN_REFRESH);
wxGetApp().obj_manipul()->set_dirty();
if (!m_unarranged.empty()) {

View File

@ -1767,11 +1767,6 @@ struct Plater::priv
void render_project_state_debug_window() const { dirty_state.render_debug_window(); }
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
enum class UpdateParams {
FORCE_FULL_SCREEN_REFRESH = 1,
FORCE_BACKGROUND_PROCESSING_UPDATE = 2,
POSTPONE_VALIDATION_ERROR_MESSAGE = 4,
};
void update(unsigned int flags = 0);
void select_view(const std::string& direction);
void select_view_3D(const std::string& name);
@ -6022,7 +6017,7 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/*
return true;
}
void Plater::update() { p->update(); }
void Plater::update(unsigned int flags) { p->update(flags); }
Worker &Plater::get_ui_job_worker() { return p->m_worker; }

View File

@ -185,7 +185,12 @@ public:
const wxString& get_last_loaded_gcode() const { return m_last_loaded_gcode; }
void update();
enum class UpdateParams {
FORCE_FULL_SCREEN_REFRESH = 1,
FORCE_BACKGROUND_PROCESSING_UPDATE = 2,
POSTPONE_VALIDATION_ERROR_MESSAGE = 4,
};
void update(unsigned int flags = 0);
// Get the worker handling the UI jobs (arrange, fill bed, etc...)
// Here is an example of starting up an ad-hoc job: