Set volume only by function data_changed.

This commit is contained in:
Filip Sykala - NTB T15p 2023-03-23 16:29:23 +01:00
parent af21038d94
commit 4c0e7d9683

View File

@ -521,7 +521,7 @@ static void draw_mouse_offset(const std::optional<Vec2d> &offset)
void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit) 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 // Do not render window for not selected text volume
if (m_volume == nullptr || if (m_volume == nullptr ||
get_model_volume(m_volume_id, m_parent.get_selection().get_model()->objects) == 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 // to reload fonts from system, when install new one
wxFontEnumerator::InvalidateCache(); wxFontEnumerator::InvalidateCache();
// Try(when exist) set text configuration by volume // Immediately after set state On is called function data_changed(),
set_volume_by_selection(); // where one could distiguish undo/redo serialization from opening by letter 'T'
//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);
}
// change position of just opened emboss window // change position of just opened emboss window
if (m_allow_open_near_volume) { if (m_allow_open_near_volume) {
@ -697,7 +686,21 @@ 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(); 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(); } void GLGizmoEmboss::on_start_dragging() { m_rotate_gizmo.start_dragging(); }