Add restriction for simplification
Refuse outgoing during simlification. Refuse start simplification when other Gizmo is active Fix close after preview to revert changes Allow change model for simplification
This commit is contained in:
parent
11c91d781e
commit
1e863cc031
@ -3961,7 +3961,23 @@ void ObjectList::fix_through_netfabb()
|
|||||||
|
|
||||||
void ObjectList::simplify()
|
void ObjectList::simplify()
|
||||||
{
|
{
|
||||||
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
|
auto plater = wxGetApp().plater();
|
||||||
|
GLGizmosManager& gizmos_mgr = plater->canvas3D()->get_gizmos_manager();
|
||||||
|
|
||||||
|
// Do not simplify when a gizmo is open. There might be issues with updates
|
||||||
|
// and what is worse, the snapshot time would refer to the internal stack.
|
||||||
|
auto current_type = gizmos_mgr.get_current_type();
|
||||||
|
if (current_type == GLGizmosManager::Simplify) {
|
||||||
|
// close first
|
||||||
|
gizmos_mgr.open_gizmo(GLGizmosManager::EType::Simplify);
|
||||||
|
}else if (current_type != GLGizmosManager::Undefined) {
|
||||||
|
plater->get_notification_manager()->push_notification(
|
||||||
|
NotificationType::CustomSupportsAndSeamRemovedAfterRepair,
|
||||||
|
NotificationManager::NotificationLevel::RegularNotification,
|
||||||
|
_u8L("ERROR: Please close all manipulators available from "
|
||||||
|
"the left toolbar before start simplify the mesh."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
gizmos_mgr.open_gizmo(GLGizmosManager::EType::Simplify);
|
gizmos_mgr.open_gizmo(GLGizmosManager::EType::Simplify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
// Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro.
|
|
||||||
#include "GLGizmoSimplify.hpp"
|
#include "GLGizmoSimplify.hpp"
|
||||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
|
||||||
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||||
|
#include "slic3r/GUI/NotificationManager.hpp"
|
||||||
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
#include "libslic3r/AppConfig.hpp"
|
#include "libslic3r/AppConfig.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/QuadricEdgeCollapse.hpp"
|
#include "libslic3r/QuadricEdgeCollapse.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace Slic3r::GUI {
|
namespace Slic3r::GUI {
|
||||||
|
|
||||||
GLGizmoSimplify::GLGizmoSimplify(GLCanvas3D & parent,
|
GLGizmoSimplify::GLGizmoSimplify(GLCanvas3D & parent,
|
||||||
@ -38,7 +35,6 @@ bool GLGizmoSimplify::on_init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string GLGizmoSimplify::on_get_name() const
|
std::string GLGizmoSimplify::on_get_name() const
|
||||||
{
|
{
|
||||||
return (_L("Simplify")).ToUTF8().data();
|
return (_L("Simplify")).ToUTF8().data();
|
||||||
@ -195,6 +191,11 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||||||
process();
|
process();
|
||||||
} else {
|
} else {
|
||||||
// use preview and close
|
// use preview and close
|
||||||
|
if (m_original_its.has_value()) {
|
||||||
|
// fix hollowing, sla support points, modifiers, ...
|
||||||
|
auto plater = wxGetApp().plater();
|
||||||
|
plater->changed_mesh(m_obj_index);
|
||||||
|
}
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,18 +214,17 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||||||
|
|
||||||
if (m_need_reload) {
|
if (m_need_reload) {
|
||||||
m_need_reload = false;
|
m_need_reload = false;
|
||||||
|
bool close_on_end = (m_state == State::close_on_end);
|
||||||
// Reload visualization of mesh - change VBO, FBO on GPU
|
// Reload visualization of mesh - change VBO, FBO on GPU
|
||||||
m_parent.reload_scene(true);
|
m_parent.reload_scene(true);
|
||||||
if (m_state == State::close_on_end) {
|
// set m_state must be before close() !!!
|
||||||
|
m_state = State::settings;
|
||||||
|
if (close_on_end) {
|
||||||
// fix hollowing, sla support points, modifiers, ...
|
// fix hollowing, sla support points, modifiers, ...
|
||||||
auto plater = wxGetApp().plater();
|
auto plater = wxGetApp().plater();
|
||||||
plater->changed_mesh(m_obj_index);
|
plater->changed_mesh(m_obj_index);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// change from simplifying | apply
|
|
||||||
m_state = State::settings;
|
|
||||||
|
|
||||||
// Fix warning icon in object list
|
// Fix warning icon in object list
|
||||||
wxGetApp().obj_list()->update_item_error_icon(m_obj_index, -1);
|
wxGetApp().obj_list()->update_item_error_icon(m_obj_index, -1);
|
||||||
@ -287,7 +287,6 @@ void GLGizmoSimplify::process()
|
|||||||
m_last_error = max_error;
|
m_last_error = max_error;
|
||||||
} catch (SimplifyCanceledException &) {
|
} catch (SimplifyCanceledException &) {
|
||||||
// set state out of main thread
|
// set state out of main thread
|
||||||
m_last_error = {};
|
|
||||||
m_state = State::settings;
|
m_state = State::settings;
|
||||||
}
|
}
|
||||||
// need to render last status fn to change bar graph to buttons
|
// need to render last status fn to change bar graph to buttons
|
||||||
@ -310,10 +309,30 @@ bool GLGizmoSimplify::on_is_activable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoSimplify::on_set_state()
|
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) {
|
||||||
m_volume = nullptr;
|
|
||||||
|
// refuse outgoing during simlification
|
||||||
|
if (m_state != State::settings) {
|
||||||
|
GLGizmoBase::m_state = GLGizmoBase::On;
|
||||||
|
auto notification_manager = wxGetApp().plater()->get_notification_manager();
|
||||||
|
notification_manager->push_notification(
|
||||||
|
NotificationType::CustomNotification,
|
||||||
|
NotificationManager::NotificationLevel::RegularNotification,
|
||||||
|
_u8L("ERROR: Wait until Simplification ends or Cancel process."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// revert preview
|
||||||
|
if (m_original_its.has_value()) {
|
||||||
|
set_its(*m_original_its);
|
||||||
|
m_parent.reload_scene(true);
|
||||||
|
m_need_reload = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalidate selected model
|
||||||
|
m_volume = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
#ifndef slic3r_GLGizmoSimplify_hpp_
|
#ifndef slic3r_GLGizmoSimplify_hpp_
|
||||||
#define slic3r_GLGizmoSimplify_hpp_
|
#define slic3r_GLGizmoSimplify_hpp_
|
||||||
|
|
||||||
|
// Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code,
|
||||||
|
// which overrides our localization "L" macro.
|
||||||
#include "GLGizmoBase.hpp"
|
#include "GLGizmoBase.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "admesh/stl.h" // indexed_triangle_set
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
class ModelVolume;
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
class GLGizmoSimplify : public GLGizmoBase
|
class GLGizmoSimplify : public GLGizmoBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -4283,6 +4283,12 @@ bool Plater::priv::can_fix_through_netfabb() const
|
|||||||
|
|
||||||
bool Plater::priv::can_simplify() const
|
bool Plater::priv::can_simplify() const
|
||||||
{
|
{
|
||||||
|
// is object for simplification selected
|
||||||
|
if (get_selected_object_idx() < 0) return false;
|
||||||
|
// is already opened?
|
||||||
|
if (q->canvas3D()->get_gizmos_manager().get_current_type() ==
|
||||||
|
GLGizmosManager::EType::Simplify)
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user