diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index c74ab2e9db..656f174d31 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -521,7 +521,7 @@ static void draw_mouse_offset(const std::optional &offset) void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit) { - set_volume_by_selection(); + assert(m_volume != nullptr); // Do not render window for not selected text volume if (m_volume == nullptr || get_model_volume(m_volume_id, m_parent.get_selection().get_model()->objects) == nullptr || @@ -665,20 +665,9 @@ void GLGizmoEmboss::on_set_state() // to reload fonts from system, when install new one wxFontEnumerator::InvalidateCache(); - // Try(when exist) set text configuration by volume - set_volume_by_selection(); - - // when open window by "T" and no valid volume is selected, so Create new one - if (m_volume == nullptr || - get_model_volume(m_volume_id, m_parent.get_selection().get_model()->objects) == nullptr ) { - // reopen gizmo when new object is created - GLGizmoBase::m_state = GLGizmoBase::Off; - if (wxGetApp().get_mode() == comSimple || wxGetApp().obj_list()->has_selected_cut_object()) - // It's impossible to add a part in simple mode - return; - // start creating new object - create_volume(ModelVolumeType::MODEL_PART); - } + // Immediately after set state On is called function data_changed(), + // where one could distiguish undo/redo serialization from opening by letter 'T' + //set_volume_by_selection(); // change position of just opened emboss window if (m_allow_open_near_volume) { @@ -696,8 +685,22 @@ void GLGizmoEmboss::on_set_state() } } -void GLGizmoEmboss::data_changed(bool is_serializing) { +void GLGizmoEmboss::data_changed(bool is_serializing) { + if (is_serializing) + reset_volume(); + set_volume_by_selection(); + + // when open window by "T" and no valid volume is selected, so Create new one + if (!is_serializing && m_volume == nullptr) { + // reopen gizmo when new object is created + close(); + if (wxGetApp().get_mode() == comSimple || wxGetApp().obj_list()->has_selected_cut_object()) + // It's impossible to add a part in simple mode + return; + // start creating new object + create_volume(ModelVolumeType::MODEL_PART); + } } void GLGizmoEmboss::on_start_dragging() { m_rotate_gizmo.start_dragging(); }