Fix taking entering/leaving snapshots in SLA gizmo:
This was broken between 2.2.0 and 2.3.0. The 'entering' snapshot should be taken before the gizmo opens, not after. Otherwise it is in fact the same as the next snapshot.
This commit is contained in:
parent
ed7ebf15d9
commit
4c80d9ed01
4 changed files with 22 additions and 26 deletions
|
@ -135,6 +135,7 @@ public:
|
||||||
bool is_activable() const { return on_is_activable(); }
|
bool is_activable() const { return on_is_activable(); }
|
||||||
bool is_selectable() const { return on_is_selectable(); }
|
bool is_selectable() const { return on_is_selectable(); }
|
||||||
CommonGizmosDataID get_requirements() const { return on_get_requirements(); }
|
CommonGizmosDataID get_requirements() const { return on_get_requirements(); }
|
||||||
|
virtual bool wants_enter_leave_snapshots() const { return false; }
|
||||||
void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; }
|
void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; }
|
||||||
|
|
||||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||||
|
|
|
@ -901,15 +901,6 @@ void GLGizmoSlaSupports::on_set_state()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
|
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
|
||||||
if (! m_parent.get_gizmos_manager().is_serializing()) {
|
|
||||||
// Only take the snapshot when the USER opens the gizmo. Common gizmos
|
|
||||||
// data are not yet available, the CallAfter will postpone taking the
|
|
||||||
// snapshot until they are. No, it does not feel right.
|
|
||||||
wxGetApp().CallAfter([]() {
|
|
||||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Entering SLA gizmo"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default head diameter from config.
|
// Set default head diameter from config.
|
||||||
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
||||||
m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value;
|
m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value;
|
||||||
|
@ -925,8 +916,6 @@ void GLGizmoSlaSupports::on_set_state()
|
||||||
else {
|
else {
|
||||||
// we are actually shutting down
|
// we are actually shutting down
|
||||||
disable_editing_mode(); // so it is not active next time the gizmo opens
|
disable_editing_mode(); // so it is not active next time the gizmo opens
|
||||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Leaving SLA gizmo"));
|
|
||||||
m_normal_cache.clear();
|
|
||||||
m_old_mo_id = -1;
|
m_old_mo_id = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
bool has_backend_supports() const;
|
bool has_backend_supports() const;
|
||||||
void reslice_SLA_supports(bool postpone_error_messages = false) const;
|
void reslice_SLA_supports(bool postpone_error_messages = false) const;
|
||||||
|
|
||||||
|
bool wants_enter_leave_snapshots() const override { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool on_init() override;
|
bool on_init() override;
|
||||||
void on_update(const UpdateData& data) override;
|
void on_update(const UpdateData& data) override;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp"
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
||||||
|
|
||||||
|
#include "libslic3r/format.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/PresetBundle.hpp"
|
#include "libslic3r/PresetBundle.hpp"
|
||||||
|
|
||||||
|
@ -1198,26 +1199,29 @@ void GLGizmosManager::activate_gizmo(EType type)
|
||||||
if (m_gizmos.empty() || m_current == type)
|
if (m_gizmos.empty() || m_current == type)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_current != Undefined) {
|
GLGizmoBase* old_gizmo = m_current == Undefined ? nullptr : m_gizmos[m_current].get();
|
||||||
m_gizmos[m_current]->set_state(GLGizmoBase::Off);
|
GLGizmoBase* new_gizmo = type == Undefined ? nullptr : m_gizmos[type].get();
|
||||||
if (m_gizmos[m_current]->get_state() != GLGizmoBase::Off)
|
|
||||||
|
if (old_gizmo) {
|
||||||
|
old_gizmo->set_state(GLGizmoBase::Off);
|
||||||
|
if (old_gizmo->get_state() != GLGizmoBase::Off)
|
||||||
return; // gizmo refused to be turned off, do nothing.
|
return; // gizmo refused to be turned off, do nothing.
|
||||||
|
|
||||||
|
if (! m_parent.get_gizmos_manager().is_serializing()
|
||||||
|
&& old_gizmo->wants_enter_leave_snapshots())
|
||||||
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(),
|
||||||
|
Slic3r::format(_utf8("Leaving %1%"), old_gizmo->get_name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_gizmo && ! m_parent.get_gizmos_manager().is_serializing()
|
||||||
|
&& new_gizmo->wants_enter_leave_snapshots())
|
||||||
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(),
|
||||||
|
Slic3r::format(_utf8("Entering %1%"), new_gizmo->get_name()));
|
||||||
|
|
||||||
m_current = type;
|
m_current = type;
|
||||||
|
|
||||||
// Updating common data should be left to the update_data function, which
|
if (new_gizmo)
|
||||||
// is always called after this one. activate_gizmo can be called by undo/redo,
|
new_gizmo->set_state(GLGizmoBase::On);
|
||||||
// when selection is not yet deserialized, so the common data would update
|
|
||||||
// incorrectly (or crash if relying on unempty selection). Undo/redo stack
|
|
||||||
// will also call update_data, after selection is restored.
|
|
||||||
|
|
||||||
//m_common_gizmos_data->update(get_current()
|
|
||||||
// ? get_current()->get_requirements()
|
|
||||||
// : CommonGizmosDataID(0));
|
|
||||||
|
|
||||||
if (type != Undefined)
|
|
||||||
m_gizmos[type]->set_state(GLGizmoBase::On);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue