mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 06:29:00 +08:00
Fix
../src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp:3021:58: error: use of deleted function 'std::optional<wxFont>& std::optional<wxFont>::operator=(std::optional<wxFont>&&)' ../src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp:3026:55: error: use of deleted function 'std::optional<wxFont>& std::optional<wxFont>::operator=(std::optional<wxFont>&&)'
This commit is contained in:
parent
225fb7d8aa
commit
a8318ee4f3
@ -3016,40 +3016,43 @@ bool GLGizmoEmboss::load_configuration(ModelVolume *volume)
|
||||
return es.name == style.name;
|
||||
};
|
||||
|
||||
std::optional<wxFont> wx_font_opt;
|
||||
if (style.type == WxFontUtils::get_actual_type())
|
||||
wx_font_opt = WxFontUtils::load_wxFont(style.path);
|
||||
int wx_font_opt;
|
||||
wxFont wx_font;
|
||||
bool is_path_changed = false;
|
||||
if (!wx_font_opt.has_value()) {
|
||||
if (style.type == WxFontUtils::get_actual_type())
|
||||
wx_font = WxFontUtils::load_wxFont(style.path);
|
||||
if (!wx_font.IsOk()) {
|
||||
create_notification_not_valid_font(tc);
|
||||
// Try create similar wx font
|
||||
wx_font_opt = WxFontUtils::create_wxFont(style);
|
||||
is_path_changed = wx_font_opt.has_value();
|
||||
wx_font = WxFontUtils::create_wxFont(style);
|
||||
is_path_changed = wx_font.IsOk();
|
||||
}
|
||||
|
||||
const auto& styles = m_style_manager.get_styles();
|
||||
auto it = std::find_if(styles.begin(), styles.end(), has_same_name);
|
||||
if (it == styles.end()) {
|
||||
// style was not found
|
||||
if (wx_font_opt.has_value())
|
||||
m_style_manager.load_style(style, *wx_font_opt);
|
||||
if (wx_font.IsOk())
|
||||
m_style_manager.load_style(style, wx_font);
|
||||
} else {
|
||||
size_t style_index = it - styles.begin();
|
||||
if (!m_style_manager.load_style(style_index)) {
|
||||
// can`t load stored style
|
||||
m_style_manager.erase(style_index);
|
||||
if (wx_font_opt.has_value())
|
||||
m_style_manager.load_style(style, *wx_font_opt);
|
||||
if (wx_font.IsOk())
|
||||
m_style_manager.load_style(style, wx_font);
|
||||
|
||||
} else {
|
||||
// stored style is loaded, now set modification of style
|
||||
m_style_manager.get_style() = style;
|
||||
m_style_manager.set_wx_font(*wx_font_opt);
|
||||
m_style_manager.set_wx_font(wx_font);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_path_changed)
|
||||
m_style_manager.get_style().path = WxFontUtils::store_wxFont(*wx_font_opt);
|
||||
if (is_path_changed) {
|
||||
std::string path = WxFontUtils::store_wxFont(wx_font);
|
||||
m_style_manager.get_style().path = path;
|
||||
}
|
||||
|
||||
m_text = tc.text;
|
||||
m_volume = volume;
|
||||
|
@ -171,13 +171,11 @@ std::string WxFontUtils::store_wxFont(const wxFont &font)
|
||||
return std::string(font_descriptor.c_str());
|
||||
}
|
||||
|
||||
std::optional<wxFont> WxFontUtils::load_wxFont(
|
||||
const std::string &font_descriptor)
|
||||
wxFont WxFontUtils::load_wxFont(const std::string &font_descriptor)
|
||||
{
|
||||
wxString font_descriptor_wx(font_descriptor);
|
||||
std::optional<wxFont> res = std::make_optional<wxFont>(font_descriptor_wx);
|
||||
if (!res->IsOk()) return {};
|
||||
return res;
|
||||
wxFont wx_font(font_descriptor_wx);
|
||||
return wx_font;
|
||||
}
|
||||
|
||||
using TypeToFamily = boost::bimap<wxFontFamily, std::string_view>;
|
||||
@ -212,7 +210,7 @@ const TypeToWeight WxFontUtils::type_to_weight =
|
||||
(wxFONTWEIGHT_HEAVY, "heavy")
|
||||
(wxFONTWEIGHT_EXTRAHEAVY, "extraHeavy");
|
||||
|
||||
std::optional<wxFont> WxFontUtils::create_wxFont(const EmbossStyle &style)
|
||||
wxFont WxFontUtils::create_wxFont(const EmbossStyle &style)
|
||||
{
|
||||
const FontProp &fp = style.prop;
|
||||
double point_size = static_cast<double>(fp.size_in_mm);
|
||||
@ -244,9 +242,12 @@ std::optional<wxFont> WxFontUtils::create_wxFont(const EmbossStyle &style)
|
||||
// default:
|
||||
//}
|
||||
|
||||
std::optional<wxFont> res = std::make_optional<wxFont>(info);
|
||||
if (!res->IsOk()) return {};
|
||||
return res;
|
||||
wxFont wx_font(info);
|
||||
// Check if exist font file
|
||||
std::unique_ptr<Emboss::FontFile> ff = create_font_file(wx_font);
|
||||
if (ff == nullptr) return {};
|
||||
|
||||
return wx_font;
|
||||
}
|
||||
|
||||
void WxFontUtils::update_property(FontProp &font_prop, const wxFont &font)
|
||||
|
@ -33,10 +33,10 @@ public:
|
||||
|
||||
// serialize / deserialize font
|
||||
static std::string store_wxFont(const wxFont &font);
|
||||
static std::optional<wxFont> load_wxFont(const std::string &font_descriptor);
|
||||
static wxFont load_wxFont(const std::string &font_descriptor);
|
||||
|
||||
// Try to create similar font, loaded from 3mf from different Computer
|
||||
static std::optional<wxFont> create_wxFont(const EmbossStyle &style);
|
||||
static wxFont create_wxFont(const EmbossStyle &style);
|
||||
// update font property by wxFont - without emboss depth and font size
|
||||
static void update_property(FontProp &font_prop, const wxFont &font);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user