diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 399bc846e6..9a575f9ff9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -1356,18 +1356,8 @@ void GLGizmoEmboss::draw_model_type() ModelVolumeType part = ModelVolumeType::MODEL_PART; ModelVolumeType type = (m_volume != nullptr) ? m_volume->type() : ModelVolumeType::INVALID; - bool is_last_solid_part = false; - if (type == part) { - is_last_solid_part = true; - for (const ModelVolume* vol : m_volume->get_object()->volumes) { - if (vol == m_volume) continue; - if (vol->type() == part) { - is_last_solid_part = false; - break; - } - } - } + bool is_last_solid_part = is_text_object(m_volume); ImGui::Text("%s :", _u8L("Type").c_str()); ImGui::SameLine(75); if (type == part) { @@ -2124,12 +2114,17 @@ void GLGizmoEmboss::draw_advanced() } // input surface distance + bool allowe_surface_distance = + m_volume->text_configuration.has_value() && + !m_volume->text_configuration->font_item.prop.use_surface && + !is_text_object(m_volume); std::optional &distance = font_prop.distance; float prev_distance = distance.has_value() ? *distance : .0f, min_distance = -2 * font_prop.emboss, max_distance = 2 * font_prop.emboss; auto def_distance = m_stored_font_item.has_value() ? - &m_stored_font_item->prop.distance : nullptr; + &m_stored_font_item->prop.distance : nullptr; + m_imgui->disabled_begin(!allowe_surface_distance); if (rev_slider(tr.surface_distance, distance, def_distance, _u8L("Undo translation"), min_distance, max_distance, "%.2f mm", _L("Distance center of text from model surface")) && m_volume != nullptr && m_volume->text_configuration.has_value()){ @@ -2137,6 +2132,7 @@ void GLGizmoEmboss::draw_advanced() float act_distance = font_prop.distance.has_value() ? *font_prop.distance : .0f; do_translate(Vec3d::UnitZ() * (act_distance - prev_distance)); } + m_imgui->disabled_end(); // slider for Clock-wise angle in degress // stored angle is optional CCW and in radians @@ -2654,6 +2650,17 @@ void GLGizmoEmboss::store_font_list_to_app_config() cfg->save(); } +bool GLGizmoEmboss::is_text_object(const ModelVolume *text) { + if (text == nullptr) return false; + if (!text->text_configuration.has_value()) return false; + if (text->type() != ModelVolumeType::MODEL_PART) return false; + for (const ModelVolume *v : text->get_object()->volumes) { + if (v == text) continue; + if (v->type() == ModelVolumeType::MODEL_PART) return false; + } + return true; +} + //void GLGizmoEmboss::store_font_item_to_app_config() const //{ // AppConfig *cfg = wxGetApp().app_config; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp index 295d836fe8..8b59044999 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp @@ -291,9 +291,16 @@ private: static const std::string M_ICON_FILENAME; public: + /// + /// Check if text is last solid part of object + /// TODO: move to emboss gui utils + /// + /// Model volume of Text + /// True when object otherwise False + static bool is_text_object(const ModelVolume *text); + // TODO: move to file utils static std::string get_file_name(const std::string &file_path); - }; } // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/Jobs/EmbossJob.cpp b/src/slic3r/GUI/Jobs/EmbossJob.cpp index 2507cb159b..1cfdf00395 100644 --- a/src/slic3r/GUI/Jobs/EmbossJob.cpp +++ b/src/slic3r/GUI/Jobs/EmbossJob.cpp @@ -430,6 +430,14 @@ void priv::update_volume(TriangleMesh &&mesh, // update printable state on canvas if (volume->type() == ModelVolumeType::MODEL_PART) canvas->update_instance_printable_state_for_object((size_t) object_idx); + + // Move object on bed + if (GLGizmoEmboss::is_text_object(volume)) { + // Must be called after because GLVolume is invalidated by new_unique_id + plater->CallAfter([object_idx]() { + wxGetApp().plater()->canvas3D()->ensure_on_bed(object_idx, false); + }); + } // redraw scene bool refresh_immediately = false;