OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::TextConfigurationSerialization Struct Reference

Public Types

using TypeToName = boost::bimap<EmbossStyle::Type, std::string_view>
using HorizontalAlignToName = boost::bimap<FontProp::HorizontalAlign, std::string_view>
using VerticalAlignToName = boost::bimap<FontProp::VerticalAlign, std::string_view>

Public Member Functions

 TextConfigurationSerialization ()=delete

Static Public Member Functions

static EmbossStyle::Type get_type (std::string_view type)
static std::string_view get_name (EmbossStyle::Type type)
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)

Static Public Attributes

static const TypeToName type_to_name
 TextConfiguration serialization.
static const HorizontalAlignToName horizontal_align_to_name
static const VerticalAlignToName vertical_align_to_name

Detailed Description

Member Typedef Documentation

◆ HorizontalAlignToName

◆ TypeToName

◆ VerticalAlignToName

Constructor & Destructor Documentation

◆ TextConfigurationSerialization()

Slic3r::TextConfigurationSerialization::TextConfigurationSerialization ( )
delete

Member Function Documentation

◆ get_name()

std::string_view Slic3r::TextConfigurationSerialization::get_name ( EmbossStyle::Type type)
inlinestatic
4285 {
4286 const auto& to_name = TextConfigurationSerialization::type_to_name.left;
4287 auto type_name = to_name.find(type);
4288 assert(type_name != to_name.end());
4289 if (type_name == to_name.end()) return "unknown type";
4290 return type_name->second;
4291 }
static const TypeToName type_to_name
TextConfiguration serialization.
Definition bbs_3mf.cpp:4269

References type_to_name.

◆ get_type()

EmbossStyle::Type Slic3r::TextConfigurationSerialization::get_type ( std::string_view type)
inlinestatic
4277 {
4278 const auto& to_type = TextConfigurationSerialization::type_to_name.right;
4279 auto type_item = to_type.find(type);
4280 assert(type_item != to_type.end());
4281 if (type_item == to_type.end()) return EmbossStyle::Type::undefined;
4282 return type_item->second;
4283 }
@ undefined
Definition TextConfiguration.hpp:138

References type_to_name, and Slic3r::EmbossStyle::undefined.

◆ read()

std::optional< TextConfiguration > Slic3r::TextConfigurationSerialization::read ( const char ** attributes,
unsigned int num_attributes )
static
10006{
10007 FontProp fp;
10008 int char_gap = bbs_get_attribute_value_int(attributes, num_attributes, CHAR_GAP_ATTR);
10009 if (char_gap != 0) fp.char_gap = char_gap;
10010 int line_gap = bbs_get_attribute_value_int(attributes, num_attributes, LINE_GAP_ATTR);
10011 if (line_gap != 0) fp.line_gap = line_gap;
10012 float boldness = bbs_get_attribute_value_float(attributes, num_attributes, BOLDNESS_ATTR);
10013 if (std::fabs(boldness) > std::numeric_limits<float>::epsilon())
10014 fp.boldness = boldness;
10015 float skew = bbs_get_attribute_value_float(attributes, num_attributes, SKEW_ATTR);
10016 if (std::fabs(skew) > std::numeric_limits<float>::epsilon())
10017 fp.skew = skew;
10018 int per_glyph = bbs_get_attribute_value_int(attributes, num_attributes, PER_GLYPH_ATTR);
10019 if (per_glyph == 1) fp.per_glyph = true;
10020
10021 fp.align = FontProp::Align(
10022 read_horizontal_align(attributes, num_attributes, horizontal_align_to_name),
10023 read_vertical_align(attributes, num_attributes, vertical_align_to_name));
10024
10025 int collection_number = bbs_get_attribute_value_int(attributes, num_attributes, COLLECTION_NUMBER_ATTR);
10026 if (collection_number > 0) fp.collection_number = static_cast<unsigned int>(collection_number);
10027
10028 fp.size_in_mm = bbs_get_attribute_value_float(attributes, num_attributes, LINE_HEIGHT_ATTR);
10029
10030 std::string family = bbs_get_attribute_value_string(attributes, num_attributes, FONT_FAMILY_ATTR);
10031 if (!family.empty()) fp.family = family;
10032 std::string face_name = bbs_get_attribute_value_string(attributes, num_attributes, FONT_FACE_NAME_ATTR);
10033 if (!face_name.empty()) fp.face_name = face_name;
10034 std::string style = bbs_get_attribute_value_string(attributes, num_attributes, FONT_STYLE_ATTR);
10035 if (!style.empty()) fp.style = style;
10036 std::string weight = bbs_get_attribute_value_string(attributes, num_attributes, FONT_WEIGHT_ATTR);
10037 if (!weight.empty()) fp.weight = weight;
10038
10039 std::string style_name = bbs_get_attribute_value_string(attributes, num_attributes, STYLE_NAME_ATTR);
10040 std::string font_descriptor = bbs_get_attribute_value_string(attributes, num_attributes, FONT_DESCRIPTOR_ATTR);
10041 std::string type_str = bbs_get_attribute_value_string(attributes, num_attributes, FONT_DESCRIPTOR_TYPE_ATTR);
10042 EmbossStyle::Type type = bimap_cvt(type_to_name, std::string_view{type_str}, EmbossStyle::Type::undefined);
10043
10044 std::string text = bbs_get_attribute_value_string(attributes, num_attributes, TEXT_DATA_ATTR);
10045 EmbossStyle es{style_name, std::move(font_descriptor), type, std::move(fp)};
10046 return TextConfiguration{std::move(es), std::move(text)};
10047}
#define style
Definition WipeTowerDialog.cpp:101
static constexpr const char * STYLE_NAME_ATTR
Definition bbs_3mf.cpp:453
static constexpr const char * FONT_FACE_NAME_ATTR
Definition bbs_3mf.cpp:469
static constexpr const char * CHAR_GAP_ATTR
Definition bbs_3mf.cpp:458
static constexpr const char * COLLECTION_NUMBER_ATTR
Definition bbs_3mf.cpp:466
static constexpr const char * FONT_DESCRIPTOR_TYPE_ATTR
Definition bbs_3mf.cpp:455
static constexpr const char * FONT_STYLE_ATTR
Definition bbs_3mf.cpp:470
int bbs_get_attribute_value_int(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:552
static constexpr const char * FONT_DESCRIPTOR_ATTR
Definition bbs_3mf.cpp:454
float bbs_get_attribute_value_float(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:544
static constexpr const char * SKEW_ATTR
Definition bbs_3mf.cpp:462
std::string bbs_get_attribute_value_string(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:538
static constexpr const char * PER_GLYPH_ATTR
Definition bbs_3mf.cpp:463
static constexpr const char * LINE_GAP_ATTR
Definition bbs_3mf.cpp:459
static constexpr const char * LINE_HEIGHT_ATTR
Definition bbs_3mf.cpp:460
static constexpr const char * TEXT_DATA_ATTR
Definition bbs_3mf.cpp:451
static constexpr const char * FONT_WEIGHT_ATTR
Definition bbs_3mf.cpp:471
static constexpr const char * BOLDNESS_ATTR
Definition bbs_3mf.cpp:461
static constexpr const char * FONT_FAMILY_ATTR
Definition bbs_3mf.cpp:468
FontProp::VerticalAlign read_vertical_align(const char **attributes, unsigned int num_attributes, const TextConfigurationSerialization::VerticalAlignToName &vertical_align_to_name)
Definition bbs_3mf.cpp:9984
FontProp::HorizontalAlign read_horizontal_align(const char **attributes, unsigned int num_attributes, const TextConfigurationSerialization::HorizontalAlignToName &horizontal_align_to_name)
Definition bbs_3mf.cpp:9964
F bimap_cvt(const boost::bimap< F, S > &bmap, S s, const F &def_value)
Definition bbs_3mf.cpp:9868
Type
Definition TextConfiguration.hpp:137
std::pair< HorizontalAlign, VerticalAlign > Align
Definition TextConfiguration.hpp:51
static const VerticalAlignToName vertical_align_to_name
Definition bbs_3mf.cpp:4275
static const HorizontalAlignToName horizontal_align_to_name
Definition bbs_3mf.cpp:4272

References Slic3r::FontProp::align, bbs_get_attribute_value_float(), bbs_get_attribute_value_int(), bbs_get_attribute_value_string(), Slic3r::FontProp::boldness, BOLDNESS_ATTR, Slic3r::FontProp::char_gap, CHAR_GAP_ATTR, Slic3r::FontProp::collection_number, COLLECTION_NUMBER_ATTR, Slic3r::FontProp::face_name, Slic3r::FontProp::family, FONT_DESCRIPTOR_ATTR, FONT_DESCRIPTOR_TYPE_ATTR, FONT_FACE_NAME_ATTR, FONT_FAMILY_ATTR, FONT_STYLE_ATTR, FONT_WEIGHT_ATTR, horizontal_align_to_name, Slic3r::FontProp::line_gap, LINE_GAP_ATTR, LINE_HEIGHT_ATTR, Slic3r::FontProp::per_glyph, PER_GLYPH_ATTR, read(), Slic3r::FontProp::size_in_mm, Slic3r::FontProp::skew, SKEW_ATTR, Slic3r::FontProp::style, style, STYLE_NAME_ATTR, TEXT_DATA_ATTR, type_to_name, Slic3r::EmbossStyle::undefined, vertical_align_to_name, and Slic3r::FontProp::weight.

Referenced by Slic3r::_BBS_3MF_Importer::_handle_start_text_configuration(), and read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_old()

EmbossShape Slic3r::TextConfigurationSerialization::read_old ( const char ** attributes,
unsigned int num_attributes )
static
10050{
10051 EmbossShape es;
10052 std::string fix_tr_mat_str = bbs_get_attribute_value_string(attributes, num_attributes, TRANSFORM_ATTR);
10053 if (!fix_tr_mat_str.empty())
10054 es.fix_3mf_tr = bbs_get_transform_from_3mf_specs_string(fix_tr_mat_str);
10055
10056
10057 if (bbs_get_attribute_value_int(attributes, num_attributes, USE_SURFACE_ATTR) == 1)
10058 es.projection.use_surface = true;
10059
10060 es.projection.depth = bbs_get_attribute_value_float(attributes, num_attributes, DEPTH_ATTR);
10061
10062 int use_surface = bbs_get_attribute_value_int(attributes, num_attributes, USE_SURFACE_ATTR);
10063 if (use_surface == 1)
10064 es.projection.use_surface = true;
10065
10066 return es;
10067}
static constexpr const char * TRANSFORM_ATTR
Definition 3mf.cpp:137
Slic3r::Transform3d bbs_get_transform_from_3mf_specs_string(const std::string &mat_str)
Definition bbs_3mf.cpp:637
static constexpr const char * DEPTH_ATTR
Definition bbs_3mf.cpp:481
static constexpr const char * USE_SURFACE_ATTR
Definition bbs_3mf.cpp:482

References bbs_get_attribute_value_float(), bbs_get_attribute_value_int(), bbs_get_attribute_value_string(), bbs_get_transform_from_3mf_specs_string(), Slic3r::EmbossProjection::depth, DEPTH_ATTR, Slic3r::EmbossShape::fix_3mf_tr, Slic3r::EmbossShape::projection, read_old(), TRANSFORM_ATTR, Slic3r::EmbossProjection::use_surface, and USE_SURFACE_ATTR.

Referenced by Slic3r::_BBS_3MF_Importer::_handle_start_text_configuration(), and read_old().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_xml()

void Slic3r::TextConfigurationSerialization::to_xml ( std::stringstream & stream,
const TextConfiguration & tc )
static
9920{
9921 stream << " <" << TEXT_TAG << " ";
9922
9923 stream << TEXT_DATA_ATTR << "=\"" << xml_escape_double_quotes_attribute_value(tc.text) << "\" ";
9924 // font item
9925 const EmbossStyle &style = tc.style;
9926 stream << STYLE_NAME_ATTR << "=\"" << xml_escape_double_quotes_attribute_value(style.name) << "\" ";
9927 stream << FONT_DESCRIPTOR_ATTR << "=\"" << xml_escape_double_quotes_attribute_value(style.path) << "\" ";
9928 constexpr std::string_view dafault_type{"undefined"};
9929 std::string_view style_type = bimap_cvt(type_to_name, style.type, dafault_type);
9930 stream << FONT_DESCRIPTOR_TYPE_ATTR << "=\"" << style_type << "\" ";
9931
9932 // font property
9933 const FontProp &fp = tc.style.prop;
9934 if (fp.char_gap.has_value())
9935 stream << CHAR_GAP_ATTR << "=\"" << *fp.char_gap << "\" ";
9936 if (fp.line_gap.has_value())
9937 stream << LINE_GAP_ATTR << "=\"" << *fp.line_gap << "\" ";
9938
9939 stream << LINE_HEIGHT_ATTR << "=\"" << fp.size_in_mm << "\" ";
9940 if (fp.boldness.has_value())
9941 stream << BOLDNESS_ATTR << "=\"" << *fp.boldness << "\" ";
9942 if (fp.skew.has_value())
9943 stream << SKEW_ATTR << "=\"" << *fp.skew << "\" ";
9944 if (fp.per_glyph)
9945 stream << PER_GLYPH_ATTR << "=\"" << 1 << "\" ";
9946 stream << HORIZONTAL_ALIGN_ATTR << "=\"" << bimap_cvt(horizontal_align_to_name, fp.align.first, dafault_type) << "\" ";
9947 stream << VERTICAL_ALIGN_ATTR << "=\"" << bimap_cvt(vertical_align_to_name, fp.align.second, dafault_type) << "\" ";
9948 if (fp.collection_number.has_value())
9949 stream << COLLECTION_NUMBER_ATTR << "=\"" << *fp.collection_number << "\" ";
9950 // font descriptor
9951 if (fp.family.has_value())
9952 stream << FONT_FAMILY_ATTR << "=\"" << *fp.family << "\" ";
9953 if (fp.face_name.has_value())
9954 stream << FONT_FACE_NAME_ATTR << "=\"" << *fp.face_name << "\" ";
9955 if (fp.style.has_value())
9956 stream << FONT_STYLE_ATTR << "=\"" << *fp.style << "\" ";
9957 if (fp.weight.has_value())
9958 stream << FONT_WEIGHT_ATTR << "=\"" << *fp.weight << "\" ";
9959
9960 stream << "/>\n"; // end TEXT_TAG
9961}
static constexpr const char * TEXT_TAG
Definition bbs_3mf.cpp:450
static constexpr const char * VERTICAL_ALIGN_ATTR
Definition bbs_3mf.cpp:465
static constexpr const char * HORIZONTAL_ALIGN_ATTR
Definition bbs_3mf.cpp:464
std::string xml_escape_double_quotes_attribute_value(std::string text)
Definition utils.cpp:1616

References Slic3r::FontProp::align, Slic3r::FontProp::boldness, BOLDNESS_ATTR, Slic3r::FontProp::char_gap, CHAR_GAP_ATTR, Slic3r::FontProp::collection_number, COLLECTION_NUMBER_ATTR, Slic3r::FontProp::face_name, Slic3r::FontProp::family, FONT_DESCRIPTOR_ATTR, FONT_DESCRIPTOR_TYPE_ATTR, FONT_FACE_NAME_ATTR, FONT_FAMILY_ATTR, FONT_STYLE_ATTR, FONT_WEIGHT_ATTR, HORIZONTAL_ALIGN_ATTR, horizontal_align_to_name, Slic3r::FontProp::line_gap, LINE_GAP_ATTR, LINE_HEIGHT_ATTR, Slic3r::FontProp::per_glyph, PER_GLYPH_ATTR, Slic3r::EmbossStyle::prop, Slic3r::FontProp::size_in_mm, Slic3r::FontProp::skew, SKEW_ATTR, Slic3r::FontProp::style, Slic3r::TextConfiguration::style, style, STYLE_NAME_ATTR, Slic3r::TextConfiguration::text, TEXT_DATA_ATTR, TEXT_TAG, to_xml(), type_to_name, VERTICAL_ALIGN_ATTR, vertical_align_to_name, Slic3r::FontProp::weight, and Slic3r::xml_escape_double_quotes_attribute_value().

Referenced by Slic3r::_BBS_3MF_Exporter::_add_model_config_file_to_archive(), and to_xml().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ horizontal_align_to_name

const TextConfigurationSerialization::HorizontalAlignToName Slic3r::TextConfigurationSerialization::horizontal_align_to_name
static
Initial value:
=
boost::assign::list_of<HorizontalAlignToName::relation>
@ right
Definition TextConfiguration.hpp:49
@ left
Definition TextConfiguration.hpp:49
@ center
Definition TextConfiguration.hpp:49

Referenced by read(), and to_xml().

◆ type_to_name

const TextConfigurationSerialization::TypeToName Slic3r::TextConfigurationSerialization::type_to_name
static
Initial value:
=
boost::assign::list_of<TypeToName::relation>
(EmbossStyle::Type::wx_win_font_descr, "wxFontDescriptor_Windows")
(EmbossStyle::Type::wx_lin_font_descr, "wxFontDescriptor_Linux")
(EmbossStyle::Type::wx_mac_font_descr, "wxFontDescriptor_MacOsX")
@ wx_mac_font_descr
Definition TextConfiguration.hpp:144
@ wx_lin_font_descr
Definition TextConfiguration.hpp:143
@ file_path
Definition TextConfiguration.hpp:148
@ wx_win_font_descr
Definition TextConfiguration.hpp:142

TextConfiguration serialization.

Referenced by get_name(), get_type(), read(), and to_xml().

◆ vertical_align_to_name

const TextConfigurationSerialization::VerticalAlignToName Slic3r::TextConfigurationSerialization::vertical_align_to_name
static
Initial value:
=
boost::assign::list_of<VerticalAlignToName::relation>
@ bottom
Definition TextConfiguration.hpp:50
@ center
Definition TextConfiguration.hpp:50
@ top
Definition TextConfiguration.hpp:50

Referenced by read(), and to_xml().


The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Format/bbs_3mf.cpp