Fix for deleted object after preview
This commit is contained in:
parent
95fc054590
commit
84f8ba9fb4
@ -53,11 +53,12 @@ void GLGizmoSimplify::on_render_for_picking() {}
|
|||||||
void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limit)
|
void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limit)
|
||||||
{
|
{
|
||||||
create_gui_cfg();
|
create_gui_cfg();
|
||||||
const Selection &selection = m_parent.get_selection();
|
int obj_index;
|
||||||
int object_idx = selection.get_object_idx();
|
ModelVolume *act_volume = get_selected_volume(&obj_index);
|
||||||
if (!is_selected_object(&object_idx)) return;
|
if (act_volume == nullptr) {
|
||||||
ModelObject *obj = wxGetApp().plater()->model().objects[object_idx];
|
close();
|
||||||
ModelVolume *act_volume = obj->volumes.front();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check selection of new volume
|
// Check selection of new volume
|
||||||
// Do not reselect object when processing
|
// Do not reselect object when processing
|
||||||
@ -68,7 +69,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||||||
set_its(*m_original_its);
|
set_its(*m_original_its);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_obj_index = object_idx; // to remember correct object
|
m_obj_index = obj_index; // to remember correct object
|
||||||
m_volume = act_volume;
|
m_volume = act_volume;
|
||||||
m_original_its = {};
|
m_original_its = {};
|
||||||
m_configuration.decimate_ratio = 50.; // default value
|
m_configuration.decimate_ratio = 50.; // default value
|
||||||
@ -329,9 +330,10 @@ void GLGizmoSimplify::on_set_state()
|
|||||||
{
|
{
|
||||||
// Closing gizmo. e.g. selecting another one
|
// Closing gizmo. e.g. selecting another one
|
||||||
if (GLGizmoBase::m_state == GLGizmoBase::Off) {
|
if (GLGizmoBase::m_state == GLGizmoBase::Off) {
|
||||||
|
bool exist_selected_object = is_selected_object();
|
||||||
// refuse outgoing during simlification
|
// refuse outgoing during simlification
|
||||||
// object is not selected when it is deleted(cancel and close gizmo)
|
// object is not selected when it is deleted(cancel and close gizmo)
|
||||||
if (m_state != State::settings && is_selected_object()) {
|
if (m_state != State::settings && exist_selected_object) {
|
||||||
GLGizmoBase::m_state = GLGizmoBase::On;
|
GLGizmoBase::m_state = GLGizmoBase::On;
|
||||||
auto notification_manager = wxGetApp().plater()->get_notification_manager();
|
auto notification_manager = wxGetApp().plater()->get_notification_manager();
|
||||||
notification_manager->push_notification(
|
notification_manager->push_notification(
|
||||||
@ -342,7 +344,7 @@ void GLGizmoSimplify::on_set_state()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// revert preview
|
// revert preview
|
||||||
if (m_exist_preview) {
|
if (m_exist_preview && exist_selected_object) {
|
||||||
set_its(*m_original_its);
|
set_its(*m_original_its);
|
||||||
m_parent.reload_scene(true);
|
m_parent.reload_scene(true);
|
||||||
m_need_reload = false;
|
m_need_reload = false;
|
||||||
@ -399,4 +401,17 @@ bool GLGizmoSimplify::is_selected_object(int *object_idx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelVolume *GLGizmoSimplify::get_selected_volume(int *object_idx_ptr)
|
||||||
|
{
|
||||||
|
const Selection &selection = m_parent.get_selection();
|
||||||
|
int object_idx = selection.get_object_idx();
|
||||||
|
if (object_idx_ptr != nullptr) *object_idx_ptr = object_idx;
|
||||||
|
if (!is_selected_object(&object_idx)) return nullptr;
|
||||||
|
ModelObjectPtrs &objs = wxGetApp().plater()->model().objects;
|
||||||
|
if (objs.size() <= object_idx) return nullptr;
|
||||||
|
ModelObject *obj = objs[object_idx];
|
||||||
|
if (obj->volumes.empty()) return nullptr;
|
||||||
|
return obj->volumes.front();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Slic3r::GUI
|
} // namespace Slic3r::GUI
|
||||||
|
@ -38,13 +38,14 @@ private:
|
|||||||
void set_its(indexed_triangle_set &its);
|
void set_its(indexed_triangle_set &its);
|
||||||
void create_gui_cfg();
|
void create_gui_cfg();
|
||||||
void request_rerender();
|
void request_rerender();
|
||||||
bool is_selected_object(int *object_idx = nullptr);
|
bool is_selected_object(int *object_idx_ptr = nullptr);
|
||||||
|
ModelVolume *get_selected_volume(int *object_idx = nullptr);
|
||||||
|
|
||||||
std::atomic_bool m_is_valid_result; // differ what to do in apply
|
std::atomic_bool m_is_valid_result; // differ what to do in apply
|
||||||
std::atomic_bool m_exist_preview; // set when process end
|
std::atomic_bool m_exist_preview; // set when process end
|
||||||
|
|
||||||
volatile int m_progress; // percent of done work
|
volatile int m_progress; // percent of done work
|
||||||
ModelVolume *m_volume; //
|
ModelVolume *m_volume; // keep pointer to actual working volume
|
||||||
size_t m_obj_index;
|
size_t m_obj_index;
|
||||||
|
|
||||||
std::optional<indexed_triangle_set> m_original_its;
|
std::optional<indexed_triangle_set> m_original_its;
|
||||||
|
Loading…
Reference in New Issue
Block a user