Fix: moving with text object(not volume) over build plate by canvas dragging

This commit is contained in:
Filip Sykala - NTB T15p 2023-03-15 11:25:17 +01:00
parent f331bb5edf
commit ca5b310e43
5 changed files with 28 additions and 23 deletions

View File

@ -1397,6 +1397,25 @@ void ModelObject::clone_for_cut(ModelObject** obj)
(*obj)->input_file.clear();
}
bool ModelVolume::is_the_only_one_part() const
{
if (m_type != ModelVolumeType::MODEL_PART)
return false;
if (object == nullptr)
return false;
for (const ModelVolume *v : object->volumes) {
if (v == nullptr)
continue;
// is this volume?
if (v->id() == this->id())
continue;
// exist another model part in object?
if (v->type() == ModelVolumeType::MODEL_PART)
return false;
}
return true;
}
void ModelVolume::reset_extra_facets()
{
this->supported_facets.reset();

View File

@ -835,6 +835,7 @@ public:
bool is_support_blocker() const { return m_type == ModelVolumeType::SUPPORT_BLOCKER; }
bool is_support_modifier() const { return m_type == ModelVolumeType::SUPPORT_BLOCKER || m_type == ModelVolumeType::SUPPORT_ENFORCER; }
bool is_text() const { return text_configuration.has_value(); }
bool is_the_only_one_part() const; // behave like an object
t_model_material_id material_id() const { return m_material_id; }
void reset_extra_facets();
void apply_tolerance();

View File

@ -1169,7 +1169,8 @@ void GLGizmoEmboss::close()
m_volume->text_configuration.has_value() &&
priv::is_text_empty(m_text)) {
Plater &p = *wxGetApp().plater();
if (is_text_object(m_volume)) {
// is the text object?
if (m_volume->is_the_only_one_part()) {
// delete whole object
p.remove(m_parent.get_selection().get_object_idx());
} else {
@ -1912,7 +1913,7 @@ void GLGizmoEmboss::draw_font_list()
void GLGizmoEmboss::draw_model_type()
{
bool is_last_solid_part = is_text_object(m_volume);
bool is_last_solid_part = m_volume->is_the_only_one_part();
std::string title = _u8L("Text is to object");
if (is_last_solid_part) {
ImVec4 color{.5f, .5f, .5f, 1.f};
@ -2945,7 +2946,7 @@ void GLGizmoEmboss::draw_advanced()
// input surface distance
bool allowe_surface_distance =
!m_volume->text_configuration->style.prop.use_surface &&
!is_text_object(m_volume);
!m_volume->is_the_only_one_part();
std::optional<float> &distance = font_prop.distance;
float prev_distance = distance.has_value() ? *distance : .0f,
min_distance = -2 * font_prop.emboss,
@ -3336,17 +3337,6 @@ bool priv::draw_button(const IconManager::VIcons &icons, IconType type, bool dis
);
}
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;
}
/////////////
// priv namespace implementation
///////////////

View File

@ -328,15 +328,6 @@ private:
// only temporary solution
static const std::string M_ICON_FILENAME;
public:
/// <summary>
/// Check if text is last solid part of object
/// TODO: move to emboss gui utils
/// </summary>
/// <param name="text">Model volume of Text</param>
/// <returns>True when object otherwise False</returns>
static bool is_text_object(const ModelVolume *text);
};
} // namespace Slic3r::GUI

View File

@ -116,6 +116,10 @@ bool on_mouse_surface_drag(const wxMouseEvent &mouse_event,
if (object == nullptr || instance == nullptr || volume == nullptr)
return false;
// allowed drag&drop by canvas for object
if (volume->is_the_only_one_part())
return false;
const ModelVolumePtrs &volumes = object->volumes;
std::vector<size_t> allowed_volumes_id;
if (volumes.size() > 1) {