Seam gizmo: fixed action names in undo/redo stack

This commit is contained in:
Lukas Matena 2020-09-04 12:46:34 +02:00
parent ba87a4fd9a
commit 436e12e99f
6 changed files with 51 additions and 7 deletions

View file

@ -285,5 +285,12 @@ void GLGizmoFdmSupports::update_from_model_object()
} }
PainterGizmoType GLGizmoFdmSupports::get_painter_type() const
{
return PainterGizmoType::FDM_SUPPORTS;
}
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r

View file

@ -27,6 +27,7 @@ private:
void on_opening() override {} void on_opening() override {}
void on_shutdown() override; void on_shutdown() override;
PainterGizmoType get_painter_type() const override;
void select_facets_by_angle(float threshold, bool block); void select_facets_by_angle(float threshold, bool block);
float m_angle_threshold_deg = 45.f; float m_angle_threshold_deg = 45.f;

View file

@ -28,13 +28,19 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic
void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate) void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
{ {
if (activate && ! m_internal_stack_active) { if (activate && ! m_internal_stack_active) {
Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned on")); wxString str = get_painter_type() == PainterGizmoType::FDM_SUPPORTS
? _L("Supports gizmo turned on")
: _L("Seam gizmo turned on");
Plater::TakeSnapshot(wxGetApp().plater(), str);
wxGetApp().plater()->enter_gizmos_stack(); wxGetApp().plater()->enter_gizmos_stack();
m_internal_stack_active = true; m_internal_stack_active = true;
} }
if (! activate && m_internal_stack_active) { if (! activate && m_internal_stack_active) {
wxString str = get_painter_type() == PainterGizmoType::SEAM
? _L("Seam gizmo turned off")
: _L("Supports gizmo turned off");
wxGetApp().plater()->leave_gizmos_stack(); wxGetApp().plater()->leave_gizmos_stack();
Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned off")); Plater::TakeSnapshot(wxGetApp().plater(), str);
m_internal_stack_active = false; m_internal_stack_active = false;
} }
} }
@ -356,11 +362,28 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::RightUp) if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::RightUp)
&& m_button_down != Button::None) { && m_button_down != Button::None) {
// Take snapshot and update ModelVolume data. // Take snapshot and update ModelVolume data.
wxString action_name = shift_down wxString action_name;
? _L("Remove selection") if (get_painter_type() == PainterGizmoType::FDM_SUPPORTS) {
: (m_button_down == Button::Left if (shift_down)
? _L("Add supports") action_name = _L("Remove selection");
: _L("Block supports")); else {
if (m_button_down == Button::Left)
action_name = _L("Add supports");
else
action_name = _L("Block supports");
}
}
if (get_painter_type() == PainterGizmoType::SEAM) {
if (shift_down)
action_name = _L("Remove selection");
else {
if (m_button_down == Button::Left)
action_name = _L("Enforce seam");
else
action_name = _L("Block seam");
}
}
activate_internal_undo_redo_stack(true); activate_internal_undo_redo_stack(true);
Plater::TakeSnapshot(wxGetApp().plater(), action_name); Plater::TakeSnapshot(wxGetApp().plater(), action_name);
update_model_object(); update_model_object();

View file

@ -22,6 +22,10 @@ namespace GUI {
enum class SLAGizmoEventType : unsigned char; enum class SLAGizmoEventType : unsigned char;
class ClippingPlane; class ClippingPlane;
enum class PainterGizmoType {
FDM_SUPPORTS,
SEAM
};
class TriangleSelectorGUI : public TriangleSelector { class TriangleSelectorGUI : public TriangleSelector {
@ -103,6 +107,7 @@ protected:
virtual void on_opening() = 0; virtual void on_opening() = 0;
virtual void on_shutdown() = 0; virtual void on_shutdown() = 0;
virtual PainterGizmoType get_painter_type() const = 0;
bool on_is_activable() const override; bool on_is_activable() const override;
bool on_is_selectable() const override; bool on_is_selectable() const override;

View file

@ -204,5 +204,12 @@ void GLGizmoSeam::update_from_model_object()
} }
PainterGizmoType GLGizmoSeam::get_painter_type() const
{
return PainterGizmoType::SEAM;
}
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r

View file

@ -16,6 +16,7 @@ public:
protected: protected:
void on_render_input_window(float x, float y, float bottom_limit) override; void on_render_input_window(float x, float y, float bottom_limit) override;
std::string on_get_name() const override; std::string on_get_name() const override;
PainterGizmoType get_painter_type() const override;
private: private:
bool on_init() override; bool on_init() override;