mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 11:55:55 +08:00
Remove depricated variable
+ read old staff in separate 3mf function
This commit is contained in:
parent
b3d94bab8f
commit
3421a9298a
@ -1352,10 +1352,6 @@ unsigned Emboss::get_count_lines(const ExPolygonsWithIds &shapes) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Emboss::apply_transformation(const FontProp &font_prop, Transform3d &transformation){
|
||||
apply_transformation(font_prop.angle, font_prop.distance, transformation);
|
||||
}
|
||||
|
||||
void Emboss::apply_transformation(const std::optional<float>& angle, const std::optional<float>& distance, Transform3d &transformation) {
|
||||
if (angle.has_value()) {
|
||||
double angle_z = *angle;
|
||||
|
@ -198,10 +198,9 @@ namespace Emboss
|
||||
/// <summary>
|
||||
/// Use data from font property to modify transformation
|
||||
/// </summary>
|
||||
/// <param name="font_prop">Z-move as surface distance(FontProp::distance)
|
||||
/// Z-rotation as angle to Y axis(FontProp::angle)</param>
|
||||
/// <param name="angle">Z-rotation as angle to Y axis</param>
|
||||
/// <param name="distance">Z-move as surface distance</param>
|
||||
/// <param name="transformation">In / Out transformation to modify by property</param>
|
||||
void apply_transformation(const FontProp &font_prop, Transform3d &transformation);
|
||||
void apply_transformation(const std::optional<float> &angle, const std::optional<float> &distance, Transform3d &transformation);
|
||||
|
||||
/// <summary>
|
||||
|
@ -1982,6 +1982,7 @@ namespace Slic3r {
|
||||
|
||||
static void to_xml(std::stringstream &stream, const TextConfiguration &tc);
|
||||
static std::optional<TextConfiguration> read(const char **attributes, unsigned int num_attributes);
|
||||
static EmbossShape read_old(const char **attributes, unsigned int num_attributes);
|
||||
};
|
||||
|
||||
bool _3MF_Importer::_handle_start_text_configuration(const char **attributes, unsigned int num_attributes)
|
||||
@ -2005,14 +2006,7 @@ namespace Slic3r {
|
||||
return true;
|
||||
|
||||
// Back compatibility for 3mf version without shapes
|
||||
const TextConfiguration &tc = *volume.text_configuration;
|
||||
EmbossShape es;
|
||||
es.fix_3mf_tr = tc.fix_3mf_tr;
|
||||
const FontProp &fp = tc.style.prop;
|
||||
EmbossProjection& ep = es.projection;
|
||||
ep.depth = fp.emboss;
|
||||
ep.use_surface = fp.use_surface;
|
||||
volume.shape_configuration = es;
|
||||
volume.shape_configuration = TextConfigurationSerialization::read_old(attributes, num_attributes);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3655,8 +3649,6 @@ std::optional<TextConfiguration> TextConfigurationSerialization::read(const char
|
||||
float skew = get_attribute_value_float(attributes, num_attributes, SKEW_ATTR);
|
||||
if (std::fabs(skew) > std::numeric_limits<float>::epsilon())
|
||||
fp.skew = skew;
|
||||
int use_surface = get_attribute_value_int(attributes, num_attributes, USE_SURFACE_ATTR);
|
||||
if (use_surface == 1) fp.use_surface = true;
|
||||
int per_glyph = get_attribute_value_int(attributes, num_attributes, PER_GLYPH_ATTR);
|
||||
if (per_glyph == 1) fp.per_glyph = true;
|
||||
|
||||
@ -3686,18 +3678,28 @@ std::optional<TextConfiguration> TextConfigurationSerialization::read(const char
|
||||
EmbossStyle::Type type = TextConfigurationSerialization::get_type(type_str);
|
||||
|
||||
std::string text = get_attribute_value_string(attributes, num_attributes, TEXT_DATA_ATTR);
|
||||
EmbossStyle es{style_name, std::move(font_descriptor), type, std::move(fp)};
|
||||
return TextConfiguration{std::move(es), std::move(text)};
|
||||
}
|
||||
|
||||
// Read of old fashion save style for Back compatibility
|
||||
std::optional<Transform3d> fix_tr_mat;
|
||||
EmbossShape TextConfigurationSerialization::read_old(const char **attributes, unsigned int num_attributes)
|
||||
{
|
||||
EmbossShape es;
|
||||
std::string fix_tr_mat_str = get_attribute_value_string(attributes, num_attributes, TRANSFORM_ATTR);
|
||||
if (!fix_tr_mat_str.empty())
|
||||
fix_tr_mat = get_transform_from_3mf_specs_string(fix_tr_mat_str);
|
||||
if (get_attribute_value_int(attributes, num_attributes, USE_SURFACE_ATTR) == 1)
|
||||
fp.use_surface = true;
|
||||
fp.emboss = get_attribute_value_float(attributes, num_attributes, DEPTH_ATTR);
|
||||
if (!fix_tr_mat_str.empty())
|
||||
es.fix_3mf_tr = get_transform_from_3mf_specs_string(fix_tr_mat_str);
|
||||
|
||||
EmbossStyle fi{style_name, std::move(font_descriptor), type, std::move(fp)};
|
||||
return TextConfiguration{std::move(fi), std::move(text), std::move(fix_tr_mat)};
|
||||
|
||||
if (get_attribute_value_int(attributes, num_attributes, USE_SURFACE_ATTR) == 1)
|
||||
es.projection.use_surface = true;
|
||||
|
||||
es.projection.depth = get_attribute_value_float(attributes, num_attributes, DEPTH_ATTR);
|
||||
|
||||
int use_surface = get_attribute_value_int(attributes, num_attributes, USE_SURFACE_ATTR);
|
||||
if (use_surface == 1)
|
||||
es.projection.use_surface = true;
|
||||
|
||||
return es;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -54,18 +54,6 @@ struct FontProp
|
||||
// change pivot of text
|
||||
// When not set, center is used and is not stored
|
||||
Align align = Align(HorizontalAlign::center, VerticalAlign::center);
|
||||
|
||||
[[deprecated("Back compatibility only, now it is stored EmbossProjection like depth")]]
|
||||
float emboss;
|
||||
|
||||
[[deprecated("Back compatibility only, now it is stored EmbossProjection")]]
|
||||
bool use_surface;
|
||||
|
||||
[[deprecated("it is calculated on the fly")]]
|
||||
std::optional<float> distance;
|
||||
|
||||
[[deprecated("it is calculated on the fly")]]
|
||||
std::optional<float> angle;
|
||||
|
||||
//////
|
||||
// Duplicit data to wxFontDescriptor
|
||||
@ -88,7 +76,7 @@ struct FontProp
|
||||
/// </summary>
|
||||
/// <param name="line_height">Y size of text [in mm]</param>
|
||||
/// <param name="depth">Z size of text [in mm]</param>
|
||||
FontProp(float line_height = 10.f, float depth = 2.f) : emboss(depth), size_in_mm(line_height), use_surface(false), per_glyph(false)
|
||||
FontProp(float line_height = 10.f) : size_in_mm(line_height), per_glyph(false)
|
||||
{}
|
||||
|
||||
bool operator==(const FontProp& other) const {
|
||||
@ -194,9 +182,6 @@ struct TextConfiguration
|
||||
// Embossed text value
|
||||
std::string text = "None";
|
||||
|
||||
[[deprecated("only for back compatibility, now it is stored in EmbossShape")]]
|
||||
std::optional<Transform3d> fix_3mf_tr;
|
||||
|
||||
// undo / redo stack recovery
|
||||
template<class Archive> void serialize(Archive &ar) { ar(style, text); }
|
||||
};
|
||||
|
@ -413,12 +413,14 @@ bool GLGizmoEmboss::do_mirror(size_t axis)
|
||||
return false;
|
||||
|
||||
const TextConfiguration &tc= *m_volume->text_configuration;
|
||||
if(tc.style.prop.per_glyph){
|
||||
if(tc.style.prop.per_glyph){
|
||||
// init textlines before mirroring on mirrored text volume transformation
|
||||
Transform3d tr = m_volume->get_matrix();
|
||||
const std::optional<Transform3d> &fix_tr = tc.fix_3mf_tr;
|
||||
if (fix_tr.has_value())
|
||||
tr = tr * (fix_tr->inverse());
|
||||
if (m_volume->emboss_shape.has_value()) {
|
||||
const std::optional<Transform3d> &fix_tr = m_volume->emboss_shape->fix_3mf_tr;
|
||||
if (fix_tr.has_value())
|
||||
tr = tr * (fix_tr->inverse());
|
||||
}
|
||||
|
||||
// mirror
|
||||
Vec3d scale = Vec3d::Ones();
|
||||
@ -563,8 +565,7 @@ bool GLGizmoEmboss::on_mouse_for_translate(const wxMouseEvent &mouse_event)
|
||||
assert(m_style_manager.is_active_font());
|
||||
if (gl_volume == nullptr || !m_style_manager.is_active_font())
|
||||
return res;
|
||||
|
||||
m_style_manager.get_font_prop().angle = calc_up(gl_volume->world_matrix(), Slic3r::GUI::up_limit);
|
||||
m_style_manager.get_style().angle = calc_up(gl_volume->world_matrix(), Slic3r::GUI::up_limit);
|
||||
}
|
||||
|
||||
volume_transformation_changing();
|
||||
@ -1272,7 +1273,7 @@ void GLGizmoEmboss::set_volume_by_selection()
|
||||
// Calculate current angle of up vector
|
||||
assert(m_style_manager.is_active_font());
|
||||
if (m_style_manager.is_active_font())
|
||||
m_style_manager.get_font_prop().angle = calc_up(gl_volume->world_matrix(), up_limit);
|
||||
m_style_manager.get_style().angle = calc_up(gl_volume->world_matrix(), up_limit);
|
||||
|
||||
// calculate scale for height and depth inside of scaled object instance
|
||||
calculate_scale();
|
||||
@ -3261,26 +3262,7 @@ void TextDataBase::write(ModelVolume &volume) const
|
||||
{
|
||||
DataBase::write(volume);
|
||||
volume.text_configuration = m_text_configuration; // copy
|
||||
|
||||
// TEMPORARY check until depricated variable will be deleted
|
||||
FontProp &fp = volume.text_configuration->style.prop;
|
||||
// Distance and angle are calculated on the fly it should not be stored in volume
|
||||
assert(!fp.angle.has_value());
|
||||
if (fp.angle.has_value())
|
||||
fp.angle.reset();
|
||||
assert(!fp.distance.has_value());
|
||||
if (fp.distance.has_value())
|
||||
fp.distance.reset();
|
||||
|
||||
// use_surface and emboss are stored in projection
|
||||
assert(volume.emboss_shape.has_value());
|
||||
if (!volume.emboss_shape.has_value())
|
||||
return;
|
||||
const EmbossProjection &ep = volume.emboss_shape->projection;
|
||||
if (fp.use_surface != ep.use_surface)
|
||||
fp.use_surface = ep.use_surface;
|
||||
if (!is_approx(fp.emboss, static_cast<float>(ep.depth)))
|
||||
fp.emboss = static_cast<float>(ep.depth);
|
||||
}
|
||||
|
||||
std::unique_ptr<DataBase> create_emboss_data_base(const std::string &text,
|
||||
|
@ -129,7 +129,7 @@ EmbossStyle WxFontUtils::create_emboss_style(const wxFont &font, const std::stri
|
||||
{
|
||||
std::string name_item = name.empty()? get_human_readable_name(font) : name;
|
||||
std::string fontDesc = store_wxFont(font);
|
||||
EmbossStyle::Type type = get_current_type();
|
||||
EmbossStyle::Type type = get_current_type();
|
||||
|
||||
// synchronize font property with actual font
|
||||
FontProp font_prop;
|
||||
@ -138,7 +138,6 @@ EmbossStyle WxFontUtils::create_emboss_style(const wxFont &font, const std::stri
|
||||
// is approximately 0.0139 inch or 352.8 um. But it is too small, so I
|
||||
// decide use point size as mm for emboss
|
||||
font_prop.size_in_mm = font.GetPointSize(); // *0.3528f;
|
||||
font_prop.emboss = font_prop.size_in_mm / 2.f;
|
||||
|
||||
WxFontUtils::update_property(font_prop, font);
|
||||
return { name_item, fontDesc, type, font_prop };
|
||||
|
@ -313,18 +313,19 @@ The other kids at school nicknamed him Ix,\n\
|
||||
which in the language of Betelgeuse Five translates as\t\n\
|
||||
\"boy who is not able satisfactorily to explain what a Hrung is,\n\
|
||||
nor why it should choose to collapse on Betelgeuse Seven\".";
|
||||
float line_height = 10.f, depth = 2.f;
|
||||
float line_height = 10.f;
|
||||
|
||||
auto font = Emboss::create_font_file(font_path.c_str());
|
||||
REQUIRE(font != nullptr);
|
||||
|
||||
Emboss::FontFileWithCache ffwc(std::move(font));
|
||||
FontProp fp{line_height, depth};
|
||||
FontProp fp{line_height};
|
||||
|
||||
auto was_canceled = []() { return false; };
|
||||
ExPolygons shapes = Emboss::text2shapes(ffwc, text.c_str(), fp, was_canceled);
|
||||
REQUIRE(!shapes.empty());
|
||||
|
||||
float depth = 2.f;
|
||||
Emboss::ProjectZ projection(depth);
|
||||
indexed_triangle_set its = Emboss::polygons2model(shapes, projection);
|
||||
CHECK(!its.indices.empty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user