mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-14 05:31:49 +08:00
Fix Minimize cases when can't open GizmoEmboss due to can't create object.
This commit is contained in:
parent
4a406e27d4
commit
f2e61f295f
@ -238,12 +238,11 @@ void GLGizmoEmboss::on_set_state()
|
|||||||
m_volume = nullptr;
|
m_volume = nullptr;
|
||||||
} else if (GLGizmoBase::m_state == GLGizmoBase::On) {
|
} else if (GLGizmoBase::m_state == GLGizmoBase::On) {
|
||||||
if (!m_is_initialized) initialize();
|
if (!m_is_initialized) initialize();
|
||||||
Selection &s = m_parent.get_selection();
|
|
||||||
// When add Text on empty plate,
|
// When add Text on empty plate, Create new object with volume
|
||||||
// Create object with volume
|
if (m_parent.get_selection().is_empty()) {
|
||||||
if (s.is_empty()) {
|
if (!create_default_model_object())
|
||||||
set_default_configuration();
|
GLGizmoBase::m_state = GLGizmoBase::Off;
|
||||||
process();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,6 +660,42 @@ void GLGizmoEmboss::draw_advanced() {
|
|||||||
// if (ImGui::InputFloat3("Up", m_up.data())) m_up.normalize();
|
// if (ImGui::InputFloat3("Up", m_up.data())) m_up.normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLGizmoEmboss::create_default_model_object()
|
||||||
|
{
|
||||||
|
set_default_configuration();
|
||||||
|
// Is created default model?
|
||||||
|
if (process()) return true;
|
||||||
|
|
||||||
|
// can't create object,
|
||||||
|
// e.g. selected font don't have letter for "Emboss text"
|
||||||
|
|
||||||
|
// try select another font
|
||||||
|
for (size_t font_index = 0; font_index < m_font_list.size(); ++font_index) {
|
||||||
|
if (!load_font(font_index)) continue;
|
||||||
|
// Is fixed by change to font from font list?
|
||||||
|
if (process()) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try add system font and use it
|
||||||
|
size_t font_index = m_font_list.size();
|
||||||
|
m_font_list.push_back(WxFontUtils::get_os_font());
|
||||||
|
if (!load_font(font_index)) {
|
||||||
|
// TODO: Solve wrong os font !!!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Is fixed by change font to os font?
|
||||||
|
if (process()) return true;
|
||||||
|
|
||||||
|
// try change default text
|
||||||
|
// Do NOT translate it!
|
||||||
|
m_text = u8"text";
|
||||||
|
// Is fixed by change translation of Emboss text?
|
||||||
|
if (process()) return true;
|
||||||
|
|
||||||
|
// Bad os font can't process "text" with os default font
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GLGizmoEmboss::load_font(size_t font_index)
|
bool GLGizmoEmboss::load_font(size_t font_index)
|
||||||
{
|
{
|
||||||
std::swap(font_index, m_font_selected);
|
std::swap(font_index, m_font_selected);
|
||||||
@ -1125,7 +1160,7 @@ FontItem WxFontUtils::get_os_font()
|
|||||||
wxSystemFont system_font = wxSYS_DEFAULT_GUI_FONT;
|
wxSystemFont system_font = wxSYS_DEFAULT_GUI_FONT;
|
||||||
wxFont font = wxSystemSettings::GetFont(system_font);
|
wxFont font = wxSystemSettings::GetFont(system_font);
|
||||||
FontItem fi = get_font_item(font);
|
FontItem fi = get_font_item(font);
|
||||||
fi.name += +" (" + _u8L("OS default") + ")";
|
fi.name += std::string(" (" + _u8L("OS default") + ")");
|
||||||
return get_font_item(font);
|
return get_font_item(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ private:
|
|||||||
void draw_text_input();
|
void draw_text_input();
|
||||||
void draw_advanced();
|
void draw_advanced();
|
||||||
|
|
||||||
|
bool create_default_model_object();
|
||||||
|
|
||||||
bool load_font();
|
bool load_font();
|
||||||
// try to set font_index
|
// try to set font_index
|
||||||
bool load_font(size_t font_index);
|
bool load_font(size_t font_index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user