mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 21:55:59 +08:00
Move text object on bed
This commit is contained in:
parent
370e84b785
commit
73edac761b
@ -1356,18 +1356,8 @@ void GLGizmoEmboss::draw_model_type()
|
|||||||
ModelVolumeType part = ModelVolumeType::MODEL_PART;
|
ModelVolumeType part = ModelVolumeType::MODEL_PART;
|
||||||
ModelVolumeType type = (m_volume != nullptr) ? m_volume->type() :
|
ModelVolumeType type = (m_volume != nullptr) ? m_volume->type() :
|
||||||
ModelVolumeType::INVALID;
|
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::Text("%s :", _u8L("Type").c_str());
|
||||||
ImGui::SameLine(75);
|
ImGui::SameLine(75);
|
||||||
if (type == part) {
|
if (type == part) {
|
||||||
@ -2124,12 +2114,17 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// input surface distance
|
// 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<float> &distance = font_prop.distance;
|
std::optional<float> &distance = font_prop.distance;
|
||||||
float prev_distance = distance.has_value() ? *distance : .0f,
|
float prev_distance = distance.has_value() ? *distance : .0f,
|
||||||
min_distance = -2 * font_prop.emboss,
|
min_distance = -2 * font_prop.emboss,
|
||||||
max_distance = 2 * font_prop.emboss;
|
max_distance = 2 * font_prop.emboss;
|
||||||
auto def_distance = m_stored_font_item.has_value() ?
|
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"),
|
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")) &&
|
min_distance, max_distance, "%.2f mm", _L("Distance center of text from model surface")) &&
|
||||||
m_volume != nullptr && m_volume->text_configuration.has_value()){
|
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;
|
float act_distance = font_prop.distance.has_value() ? *font_prop.distance : .0f;
|
||||||
do_translate(Vec3d::UnitZ() * (act_distance - prev_distance));
|
do_translate(Vec3d::UnitZ() * (act_distance - prev_distance));
|
||||||
}
|
}
|
||||||
|
m_imgui->disabled_end();
|
||||||
|
|
||||||
// slider for Clock-wise angle in degress
|
// slider for Clock-wise angle in degress
|
||||||
// stored angle is optional CCW and in radians
|
// stored angle is optional CCW and in radians
|
||||||
@ -2654,6 +2650,17 @@ void GLGizmoEmboss::store_font_list_to_app_config()
|
|||||||
cfg->save();
|
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
|
//void GLGizmoEmboss::store_font_item_to_app_config() const
|
||||||
//{
|
//{
|
||||||
// AppConfig *cfg = wxGetApp().app_config;
|
// AppConfig *cfg = wxGetApp().app_config;
|
||||||
|
@ -291,9 +291,16 @@ private:
|
|||||||
static const std::string M_ICON_FILENAME;
|
static const std::string M_ICON_FILENAME;
|
||||||
|
|
||||||
public:
|
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);
|
||||||
|
|
||||||
// TODO: move to file utils
|
// TODO: move to file utils
|
||||||
static std::string get_file_name(const std::string &file_path);
|
static std::string get_file_name(const std::string &file_path);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r::GUI
|
} // namespace Slic3r::GUI
|
||||||
|
@ -431,6 +431,14 @@ void priv::update_volume(TriangleMesh &&mesh,
|
|||||||
if (volume->type() == ModelVolumeType::MODEL_PART)
|
if (volume->type() == ModelVolumeType::MODEL_PART)
|
||||||
canvas->update_instance_printable_state_for_object((size_t) object_idx);
|
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
|
// redraw scene
|
||||||
bool refresh_immediately = false;
|
bool refresh_immediately = false;
|
||||||
canvas->reload_scene(refresh_immediately);
|
canvas->reload_scene(refresh_immediately);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user