OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
anonymous_namespace{GLGizmoEmboss.cpp} Namespace Reference

Classes

struct  Limit
struct  Limits
struct  TextDataBase
struct  FaceName
struct  Facenames
struct  GuiCfg

Enumerations

enum class  IconType : unsigned {
  rename = 0 , erase , add , save ,
  undo , italic , unitalic , bold ,
  unbold , system_selector , open_file , exclamation ,
  lock , lock_bold , unlock , unlock_bold ,
  align_horizontal_left , align_horizontal_center , align_horizontal_right , align_vertical_top ,
  align_vertical_center , align_vertical_bottom , _count
}
enum class  IconState : unsigned { activable = 0 , hovered , disabled }

Functions

std::unique_ptr< DataBase > create_emboss_data_base (const std::string &text, StyleManager &style_manager, TextLinesModel &text_lines, const Selection &selection, ModelVolumeType type, std::shared_ptr< std::atomic< bool > > &cancel)
 Prepare data for emboss.
CreateVolumeParams create_input (GLCanvas3D &canvas, const StyleManager::Style &style, RaycastManager &raycaster, ModelVolumeType volume_type)
ImVec2 calc_fine_position (const Selection &selection, const ImVec2 &windows_size, const Size &canvas_size)
 Move window for edit emboss text near to embossed object NOTE: embossed object must be selected.
const IconManager::Icon & get_icon (const IconManager::VIcons &icons, IconType type, IconState state)
bool draw_button (const IconManager::VIcons &icons, IconType type, bool disable=false)
bool store (const Facenames &facenames)
bool load (Facenames &facenames)
void init_face_names (Facenames &facenames)
void init_truncated_names (Facenames &face_names, float max_width)
GuiCfg create_gui_configuration ()
void draw_font_preview (FaceName &face, const std::string &text, Facenames &faces, const GuiCfg &cfg, bool is_visible)
void init_text_lines (TextLinesModel &text_lines, const Selection &selection, StyleManager &style_manager, unsigned count_lines=0)
ModelVolumePtrs prepare_volumes_to_slice (const ModelVolume &mv)
bool check (ModelVolumeType volume_type)
bool can_write (StyleManager &style_manager, const std::string &text)
bool can_write (const EmbossStyle &style, const std::string &text)
void add_style_for_default_text (EmbossStyles &styles)
std::optional< wxString > get_installed_face_name (const std::optional< std::string > &face_name_opt, ::Facenames &face_names)
 Check installed fonts whether optional face name exist in installed fonts.
void fix_transformation (const StyleManager::Style &from, const StyleManager::Style &to, GLCanvas3D &canvas)
bool is_text_empty (std::string_view text)
std::string concat (std::vector< wxString > data)
boost::filesystem::path get_fontlist_cache_path ()

Variables

const std::string rotation_snapshot_name = L("Text rotate")
const std::string move_snapshot_name = L("Text move")
static const struct anonymous_namespace{GLGizmoEmboss.cpp}::Limits limits
static const float SELECTABLE_INNER_OFFSET = 8.0f
const char *const default_text = L("Embossed text")

Class Documentation

◆ anonymous_namespace{GLGizmoEmboss.cpp}::Limit

struct anonymous_namespace{GLGizmoEmboss.cpp}::Limit
template<typename T>
struct anonymous_namespace{GLGizmoEmboss.cpp}::Limit< T >
Inheritance diagram for anonymous_namespace{GLGizmoEmboss.cpp}::Limit< T >:
Class Members
MinMax< T > gui
MinMax< T > values

◆ anonymous_namespace{GLGizmoEmboss.cpp}::Limits

struct anonymous_namespace{GLGizmoEmboss.cpp}::Limits
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::Limits:
Class Members
MinMax< float > angle {-180.f, 180.f}
Limit< float > boldness {{-.5f, .5f}, {-5e5f, 5e5f}}
MinMax< int > char_gap {-20000, 20000}
MinMax< double > emboss {0.01, 1e4}
MinMax< int > line_gap {-20000, 20000}
MinMax< float > size_in_mm {0.1f, 1000.f}
Limit< float > skew {{-1.f, 1.f}, {-100.f, 100.f}}

◆ anonymous_namespace{GLGizmoEmboss.cpp}::FaceName

struct anonymous_namespace{GLGizmoEmboss.cpp}::FaceName
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::FaceName:
Class Members
shared_ptr< atomic< bool > > cancel = nullptr
shared_ptr< bool > is_created = nullptr
string name_truncated = ""
size_t texture_index = 0
wxString wx_name

◆ anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg

struct anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg:
Class Members
float advanced_input_offset = 0.f
bool dark_mode = false
float delete_pos_x = 0.f
Vec2i32 face_name_size = Vec2i32(0, 0)
float face_name_texture_offset_x = 0.f
float height_of_volume_type_selector = 0.f
unsigned int icon_width = 0
float indent = 0.f
float input_offset = 0.f
float input_width = 0.f
float lock_offset = 0.f
unsigned int max_count_opened_font_files = 10
Vec2i32 max_style_image_size = Vec2i32(0, 0)
float max_style_name_width = 0.f
float max_tooltip_width = 0.f
double screen_scale
ImVec2 text_size
Translations translations

Enumeration Type Documentation

◆ IconState

enum class anonymous_namespace{GLGizmoEmboss.cpp}::IconState : unsigned
strong
Enumerator
activable 
hovered 
disabled 
223: unsigned { activable = 0, hovered /*1*/, disabled /*2*/ };
@ disabled
Definition GLGizmoEmboss.cpp:223
@ activable
Definition GLGizmoEmboss.cpp:223
@ hovered
Definition GLGizmoEmboss.cpp:223

◆ IconType

enum class anonymous_namespace{GLGizmoEmboss.cpp}::IconType : unsigned
strong
Enumerator
rename 
erase 
add 
save 
undo 
italic 
unitalic 
bold 
unbold 
system_selector 
open_file 
exclamation 
lock 
lock_bold 
unlock 
unlock_bold 
align_horizontal_left 
align_horizontal_center 
align_horizontal_right 
align_vertical_top 
align_vertical_center 
align_vertical_bottom 
_count 
196 : unsigned {
197 rename = 0,
198 erase,
199 add,
200 save,
201 undo,
202 italic,
203 unitalic,
204 bold,
205 unbold,
207 open_file,
209 lock,
210 lock_bold,
211 unlock,
219 // automatic calc of icon's count
220 _count
221};
@ italic
Definition GLGizmoEmboss.cpp:202
@ unitalic
Definition GLGizmoEmboss.cpp:203
@ align_horizontal_left
Definition GLGizmoEmboss.cpp:213
@ align_vertical_center
Definition GLGizmoEmboss.cpp:217
@ exclamation
Definition GLGizmoEmboss.cpp:208
@ align_vertical_top
Definition GLGizmoEmboss.cpp:216
@ unlock_bold
Definition GLGizmoEmboss.cpp:212
@ erase
Definition GLGizmoEmboss.cpp:198
@ undo
Definition GLGizmoEmboss.cpp:201
@ add
Definition GLGizmoEmboss.cpp:199
@ save
Definition GLGizmoEmboss.cpp:200
@ unlock
Definition GLGizmoEmboss.cpp:211
@ align_horizontal_right
Definition GLGizmoEmboss.cpp:215
@ align_vertical_bottom
Definition GLGizmoEmboss.cpp:218
@ lock_bold
Definition GLGizmoEmboss.cpp:210
@ align_horizontal_center
Definition GLGizmoEmboss.cpp:214
@ bold
Definition GLGizmoEmboss.cpp:204
@ unbold
Definition GLGizmoEmboss.cpp:205
@ system_selector
Definition GLGizmoEmboss.cpp:206
@ _count
Definition GLGizmoEmboss.cpp:220
@ rename
Definition GLGizmoEmboss.cpp:197
@ lock
Definition GLGizmoEmboss.cpp:209
@ open_file
Definition GLGizmoEmboss.cpp:207

Function Documentation

◆ add_style_for_default_text()

void anonymous_namespace{GLGizmoEmboss.cpp}::add_style_for_default_text ( EmbossStyles & styles)
543{
544 const std::string text = _u8L(default_text);
545 // the untranslated text is Latin, which the system fonts have
546 if (text == default_text || can_write(styles.front(), text))
547 return;
548
549 for (const char *face_name : {"HarmonyOS Sans SC", "NanumGothic", "Sarabun"}) {
550 wxFont wx_font = *wxNORMAL_FONT;
551 if (!wx_font.SetFaceName(face_name))
552 continue;
553 EmbossStyle style = WxFontUtils::create_emboss_style(wx_font, _u8L("Default font"));
554 if (can_write(style, text)) {
555 styles.insert(styles.begin(), std::move(style));
556 return;
557 }
558 }
559}
#define style
Definition WipeTowerDialog.cpp:101
static EmbossStyle create_emboss_style(const wxFont &font, const std::string &name="")
Definition WxFontUtils.cpp:133
bool can_write(StyleManager &style_manager, const std::string &text)
Definition GLGizmoEmboss.cpp:525
const char *const default_text
Definition GLGizmoEmboss.cpp:522
#define _u8L(s)
Definition I18N.hpp:11
Style of embossed text (Path + Type) must define how to open font for using on different OS NOTE: OnE...
Definition TextConfiguration.hpp:118

References _u8L, add_style_for_default_text(), can_write(), Slic3r::GUI::WxFontUtils::create_emboss_style(), default_text, and style.

Referenced by add_style_for_default_text().

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

◆ calc_fine_position()

ImVec2 anonymous_namespace{GLGizmoEmboss.cpp}::calc_fine_position ( const Selection & selection,
const ImVec2 & windows_size,
const Size & canvas_size )

Move window for edit emboss text near to embossed object NOTE: embossed object must be selected.

3531{
3532 const Selection::IndicesList indices = selection.get_volume_idxs();
3533 // no selected volume
3534 if (indices.empty())
3535 return {};
3536 const GLVolume *volume = selection.get_volume(*indices.begin());
3537 // bad volume selected (e.g. deleted one)
3538 if (volume == nullptr)
3539 return {};
3540
3541 const Camera &camera = wxGetApp().plater()->get_camera();
3542 Slic3r::Polygon hull = CameraUtils::create_hull2d(camera, *volume);
3543
3544 ImVec2 c_size(canvas_size.get_width(), canvas_size.get_height());
3545 ImVec2 offset = ImGuiWrapper::suggest_location(windows_size, hull, c_size);
3546 return offset;
3547}
Definition 3DScene.hpp:90
static Polygon create_hull2d(const Camera &camera, const GLVolume &volume)
Create hull around GLVolume in 2d space of camera.
Definition CameraUtils.cpp:59
static ImVec2 suggest_location(const ImVec2 &dialog_size, const Slic3r::Polygon &interest, const ImVec2 &canvas_size)
Suggest loacation of dialog window, dependent on actual visible thing on platter like Gizmo menu size...
Definition ImGuiWrapper.cpp:2476
std::set< unsigned int > IndicesList
Definition Selection.hpp:49
const IndicesList & get_volume_idxs() const
Definition Selection.hpp:315
const GLVolume * get_volume(unsigned int volume_idx) const
Definition Selection.cpp:984
int get_height() const
Definition GLCanvas3D.hpp:122
int get_width() const
Definition GLCanvas3D.hpp:119
@ Camera
Definition Shortcuts.hpp:72
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References Slic3r::GUI::CameraUtils::create_hull2d(), Slic3r::GUI::Size::get_height(), Slic3r::GUI::Selection::get_volume(), Slic3r::GUI::Selection::get_volume_idxs(), Slic3r::GUI::Size::get_width(), Slic3r::offset(), and Slic3r::GUI::ImGuiWrapper::suggest_location().

Here is the call graph for this function:

◆ can_write() [1/2]

bool anonymous_namespace{GLGizmoEmboss.cpp}::can_write ( const EmbossStyle & style,
const std::string & text )
534{
535 StyleManager style_manager(nullptr, {});
536 return style_manager.load_style(StyleManager::Style{style}) && can_write(style_manager, text);
537}
Manage Emboss text styles Cache actual state of style.
Definition EmbossStyleManager.hpp:29
bool load_style(size_t font_index)
Change active font When font not loaded roll back activ font.
Definition EmbossStyleManager.cpp:233
All connected with one style keep temporary data and caches for style.
Definition EmbossStyleManager.hpp:197

References can_write(), Slic3r::GUI::Emboss::StyleManager::load_style(), and style.

Here is the call graph for this function:

◆ can_write() [2/2]

bool anonymous_namespace{GLGizmoEmboss.cpp}::can_write ( StyleManager & style_manager,
const std::string & text )
526{
527 bool exist_unknown = false;
529 style_manager.get_font_prop().collection_number.value_or(0), &exist_unknown);
530 return !exist_unknown;
531}
const FontProp & get_font_prop() const
Definition EmbossStyleManager.hpp:123
Slic3r::Emboss::FontFileWithCache & get_font_file_with_cache()
Definition EmbossStyleManager.hpp:127
std::string create_range_text(const std::string &text, const FontFile &font, unsigned int font_index, bool *exist_unknown=nullptr)
Create unique character set from string with filtered from text with only character from font.
Definition Emboss.cpp:1529
std::shared_ptr< const FontFile > font_file
Definition Emboss.hpp:116
std::optional< unsigned int > collection_number
Definition TextConfiguration.hpp:43

References can_write(), Slic3r::FontProp::collection_number, Slic3r::Emboss::create_range_text(), Slic3r::Emboss::FontFileWithCache::font_file, Slic3r::GUI::Emboss::StyleManager::get_font_file_with_cache(), and Slic3r::GUI::Emboss::StyleManager::get_font_prop().

Referenced by add_style_for_default_text(), can_write(), and can_write().

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

◆ check()

bool anonymous_namespace{GLGizmoEmboss.cpp}::check ( ModelVolumeType volume_type)
515 {
516 return volume_type == ModelVolumeType::MODEL_PART ||
517 volume_type == ModelVolumeType::NEGATIVE_VOLUME ||
518 volume_type == ModelVolumeType::PARAMETER_MODIFIER;
519}

References check(), Slic3r::MODEL_PART, Slic3r::NEGATIVE_VOLUME, and Slic3r::PARAMETER_MODIFIER.

Referenced by check().

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

◆ concat()

std::string anonymous_namespace{GLGizmoEmboss.cpp}::concat ( std::vector< wxString > data)
3549 {
3550 std::stringstream ss;
3551 for (const auto &d : data)
3552 ss << d.c_str() << ", ";
3553 return ss.str();
3554}

Referenced by init_face_names().

Here is the caller graph for this function:

◆ create_emboss_data_base()

std::unique_ptr< DataBase > anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base ( const std::string & text,
StyleManager & style_manager,
TextLinesModel & text_lines,
const Selection & selection,
ModelVolumeType type,
std::shared_ptr< std::atomic< bool > > & cancel )

Prepare data for emboss.

Parameters
textText to emboss
style_managerKeep actual selected style
text_linesNeeded when transform per glyph
selectionNeeded for transform per glyph
typeDefine type of volume - side of surface(in / out)
cancelCancel for previous job
Returns
Base data for emboss text
3474{
3475 // create volume_name
3476 std::string volume_name = text; // copy
3477 // contain_enter?
3478 if (volume_name.find('\n') != std::string::npos)
3479 // change enters to space
3480 std::replace(volume_name.begin(), volume_name.end(), '\n', ' ');
3481
3482 if (!style_manager.is_active_font()) {
3483 style_manager.load_valid_style();
3484 assert(style_manager.is_active_font());
3485 if (!style_manager.is_active_font())
3486 return {}; // no active font in style, should never happend !!!
3487 }
3488
3489 const StyleManager::Style &style = style_manager.get_style();
3490 // actualize font path - during changes in gui it could be corrupted
3491 // volume must store valid path
3492 assert(style_manager.get_wx_font().IsOk());
3493 assert(style.path.compare(WxFontUtils::store_wxFont(style_manager.get_wx_font())) == 0);
3494
3495 if (style.prop.per_glyph) {
3496 if (!text_lines.is_init())
3497 init_text_lines(text_lines, selection, style_manager);
3498 } else
3499 text_lines.reset();
3500
3501 bool is_outside = (type == ModelVolumeType::MODEL_PART);
3502
3503 // Cancel previous Job, when it is in process
3504 // worker.cancel(); --> Use less in this case I want cancel only previous EmbossJob no other jobs
3505 // Cancel only EmbossUpdateJob no others
3506 if (cancel != nullptr)
3507 cancel->store(true);
3508 // create new shared ptr to cancel new job
3509 cancel = std::make_shared<std::atomic<bool>>(false);
3510
3511 DataBase base(volume_name, cancel);
3512 base.is_outside = is_outside;
3513 base.text_lines = text_lines.get_lines();
3514 base.from_surface = style.distance;
3515
3516 FontFileWithCache &font = style_manager.get_font_file_with_cache();
3517 TextConfiguration tc{static_cast<EmbossStyle>(style), text};
3518 return std::make_unique<TextDataBase>(std::move(base), font, std::move(tc), style.projection);
3519}
bool is_active_font()
Definition EmbossStyleManager.cpp:320
void load_valid_style()
load some valid style
Definition EmbossStyleManager.cpp:201
const wxFont & get_wx_font() const
Definition EmbossStyleManager.hpp:125
const Style & get_style() const
Definition EmbossStyleManager.hpp:118
void reset()
Definition TextLines.hpp:33
const Slic3r::Emboss::TextLines & get_lines() const
Definition TextLines.hpp:34
bool is_init() const
Definition TextLines.hpp:32
static std::string store_wxFont(const wxFont &font)
Definition WxFontUtils.cpp:176
void init_text_lines(TextLinesModel &text_lines, const Selection &selection, StyleManager &style_manager, unsigned count_lines=0)
Definition GLGizmoEmboss.cpp:1187

References Slic3r::GUI::Emboss::StyleManager::get_font_file_with_cache(), Slic3r::GUI::TextLinesModel::get_lines(), Slic3r::GUI::Emboss::StyleManager::get_style(), Slic3r::GUI::Emboss::StyleManager::get_wx_font(), init_text_lines(), Slic3r::GUI::Emboss::StyleManager::is_active_font(), Slic3r::GUI::TextLinesModel::is_init(), Slic3r::GUI::Emboss::StyleManager::load_valid_style(), Slic3r::MODEL_PART, Slic3r::GUI::TextLinesModel::reset(), Slic3r::GUI::WxFontUtils::store_wxFont(), and style.

Here is the call graph for this function:

◆ create_gui_configuration()

GuiCfg anonymous_namespace{GLGizmoEmboss.cpp}::create_gui_configuration ( )
3799{
3800 GuiCfg cfg; // initialize by default values;
3801
3802 float line_height = ImGui::GetTextLineHeight();
3803 float line_height_with_spacing = ImGui::GetTextLineHeightWithSpacing();
3804 float space = line_height_with_spacing - line_height;
3805 const ImGuiStyle &style = ImGui::GetStyle();
3806
3807 cfg.max_style_name_width = ImGui::CalcTextSize("Maximal style name..").x;
3808
3809 cfg.icon_width = static_cast<unsigned int>(std::ceil(line_height));
3810 // make size pair number
3811 if (cfg.icon_width % 2 != 0) ++cfg.icon_width;
3812
3813 cfg.delete_pos_x = cfg.max_style_name_width + space;
3814 const float count_line_of_text = 3.f;
3815 cfg.text_size = ImVec2(-FLT_MIN, line_height_with_spacing * count_line_of_text);
3816 ImVec2 letter_m_size = ImGui::CalcTextSize("M");
3817 const float count_letter_M_in_input = 12.f;
3818 cfg.input_width = letter_m_size.x * count_letter_M_in_input;
3820
3821 // TRN - Input label. Be short as possible
3822 // Select look of letter shape
3823 tr.font = _u8L("Font");
3824 // TRN - Input label. Be short as possible
3825 // Height of one text line - Font Ascent
3826 tr.height = _u8L("Height");
3827 // TRN - Input label. Be short as possible
3828 // Size in emboss direction
3829 tr.depth = _u8L("Depth");
3830
3831 float max_text_width = std::max({
3832 ImGui::CalcTextSize(tr.font.c_str()).x,
3833 ImGui::CalcTextSize(tr.height.c_str()).x,
3834 ImGui::CalcTextSize(tr.depth.c_str()).x});
3835 cfg.indent = 20.0f;
3836 cfg.input_offset = style.WindowPadding.x + cfg.indent + max_text_width + space;
3837
3838 // TRN - Input label. Be short as possible
3839 // Copy surface of model on surface of the embossed text
3840 tr.use_surface = _u8L("Use surface");
3841 // TRN - Input label. Be short as possible
3842 // Option to change projection on curved surface
3843 // for each character(glyph) in text separately
3844 tr.per_glyph = _u8L("Per glyph");
3845 // TRN - Input label. Be short as possible
3846 // Align Top|Middle|Bottom and Left|Center|Right
3847 tr.alignment = _u8L("Alignment");
3848 // TRN - Input label. Be short as possible
3849 tr.char_gap = _u8L("Char gap");
3850 // TRN - Input label. Be short as possible
3851 tr.line_gap = _u8L("Line gap");
3852 // TRN - Input label. Be short as possible
3853 tr.boldness = _u8L("Boldness");
3854
3855 // TRN - Input label. Be short as possible
3856 // Like Font italic
3857 tr.skew_ration = _u8L("Skew ratio");
3858
3859 // TRN - Input label. Be short as possible
3860 // Distance from model surface to be able
3861 // move text as part fully into not flat surface
3862 // move text as modifier fully out of not flat surface
3863 tr.from_surface = _u8L("From surface");
3864
3865 // TRN - Input label. Be short as possible
3866 // Angle between Y axis and text line direction.
3867 tr.rotation = _u8L("Rotation");
3868
3869 // TRN - Input label. Be short as possible
3870 // Keep vector from bottom to top of text aligned with printer Y axis
3871 tr.keep_up = _u8L("Keep up");
3872
3873 // TRN - Input label. Be short as possible.
3874 // Some Font file contain multiple fonts inside and
3875 // this is numerical selector of font inside font collections
3876 tr.collection = _u8L("Collection");
3877
3878 float max_advanced_text_width = std::max({
3879 ImGui::CalcTextSize(tr.use_surface.c_str()).x,
3880 ImGui::CalcTextSize(tr.per_glyph.c_str()).x,
3881 ImGui::CalcTextSize(tr.alignment.c_str()).x,
3882 ImGui::CalcTextSize(tr.char_gap.c_str()).x,
3883 ImGui::CalcTextSize(tr.line_gap.c_str()).x,
3884 ImGui::CalcTextSize(tr.boldness.c_str()).x,
3885 ImGui::CalcTextSize(tr.skew_ration.c_str()).x,
3886 ImGui::CalcTextSize(tr.from_surface.c_str()).x,
3887 ImGui::CalcTextSize(tr.rotation.c_str()).x + cfg.icon_width + 2*space,
3888 ImGui::CalcTextSize(tr.keep_up.c_str()).x,
3889 ImGui::CalcTextSize(tr.collection.c_str()).x });
3890 cfg.advanced_input_offset = max_advanced_text_width
3891 + 3 * space + cfg.indent;
3892
3893 cfg.lock_offset = cfg.advanced_input_offset - (cfg.icon_width + space);
3894 // calculate window size
3895 float input_height = line_height_with_spacing + 2*style.FramePadding.y;
3896 float separator_height = 2 + style.FramePadding.y;
3897
3898 // "Text is to object" + radio buttons
3899 cfg.height_of_volume_type_selector = separator_height + line_height_with_spacing + input_height;
3900
3901 int max_style_image_width = static_cast<int>(std::round(cfg.max_style_name_width - 2 * style.FramePadding.x));
3902 cfg.max_style_image_size = Vec2i32(max_style_image_width, line_height_with_spacing);
3903 cfg.face_name_size = Vec2i32(cfg.input_width, line_height_with_spacing);
3904 cfg.face_name_texture_offset_x = cfg.face_name_size.x() + style.WindowPadding.x + space;
3905
3906 cfg.max_tooltip_width = ImGui::GetFontSize() * 20.0f;
3907
3908 return cfg;
3909}
Eigen::Matrix< int32_t, 2, 1, Eigen::DontAlign > Vec2i32
Definition Point.hpp:57
std::string boldness
Definition GLGizmoEmboss.cpp:337
float advanced_input_offset
Definition GLGizmoEmboss.cpp:312
float input_offset
Definition GLGizmoEmboss.cpp:311
std::string line_gap
Definition GLGizmoEmboss.cpp:336
std::string from_surface
Definition GLGizmoEmboss.cpp:339
Vec2i32 max_style_image_size
Definition GLGizmoEmboss.cpp:308
float input_width
Definition GLGizmoEmboss.cpp:301
std::string use_surface
Definition GLGizmoEmboss.cpp:332
unsigned int icon_width
Definition GLGizmoEmboss.cpp:304
float lock_offset
Definition GLGizmoEmboss.cpp:313
float indent
Definition GLGizmoEmboss.cpp:310
std::string keep_up
Definition GLGizmoEmboss.cpp:341
std::string char_gap
Definition GLGizmoEmboss.cpp:335
float max_style_name_width
Definition GLGizmoEmboss.cpp:303
std::string collection
Definition GLGizmoEmboss.cpp:342
std::string per_glyph
Definition GLGizmoEmboss.cpp:333
ImVec2 text_size
Definition GLGizmoEmboss.cpp:315
std::string font
Definition GLGizmoEmboss.cpp:327
std::string rotation
Definition GLGizmoEmboss.cpp:340
std::string alignment
Definition GLGizmoEmboss.cpp:334
Translations translations
Definition GLGizmoEmboss.cpp:344
std::string height
Definition GLGizmoEmboss.cpp:328
std::string skew_ration
Definition GLGizmoEmboss.cpp:338
float height_of_volume_type_selector
Definition GLGizmoEmboss.cpp:300
Vec2i32 face_name_size
Definition GLGizmoEmboss.cpp:318
float delete_pos_x
Definition GLGizmoEmboss.cpp:302
std::string depth
Definition GLGizmoEmboss.cpp:329
float face_name_texture_offset_x
Definition GLGizmoEmboss.cpp:319
float max_tooltip_width
Definition GLGizmoEmboss.cpp:305
Definition GLGizmoEmboss.cpp:294

References _u8L, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::advanced_input_offset, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::alignment, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::boldness, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::char_gap, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::collection, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::delete_pos_x, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::depth, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::face_name_size, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::face_name_texture_offset_x, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::font, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::from_surface, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::height, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::height_of_volume_type_selector, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::icon_width, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::indent, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::input_offset, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::input_width, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::keep_up, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::line_gap, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::lock_offset, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::max_style_image_size, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::max_style_name_width, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::max_tooltip_width, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::per_glyph, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::rotation, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::skew_ration, style, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::text_size, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::translations, and anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations::use_surface.

◆ create_input()

CreateVolumeParams anonymous_namespace{GLGizmoEmboss.cpp}::create_input ( GLCanvas3D & canvas,
const StyleManager::Style & style,
RaycastManager & raycaster,
ModelVolumeType volume_type )
3522{
3523 auto gizmo = static_cast<unsigned char>(GLGizmosManager::Emboss);
3524 const GLVolume *gl_volume = get_first_hovered_gl_volume(canvas);
3525 Plater *plater = wxGetApp().plater();
3526 return CreateVolumeParams{canvas, plater->get_camera(), plater->build_volume(),
3527 plater->get_ui_job_worker(), volume_type, raycaster, gizmo, gl_volume, style.distance, style.angle};
3528}
@ Emboss
Definition GLGizmosManager.hpp:99
Definition Plater.hpp:337
shorten params for start_crate_volume functions
Definition EmbossJob.hpp:206
GLVolume * get_first_hovered_gl_volume(const GLCanvas3D &canvas)
Definition GLCanvas3D.cpp:12990
static Plater * plater()
Definition GUI_Factories.cpp:400

References Slic3r::GUI::GLGizmosManager::Emboss, Slic3r::GUI::get_first_hovered_gl_volume(), Slic3r::GUI::plater(), and style.

Here is the call graph for this function:

◆ draw_button()

bool anonymous_namespace{GLGizmoEmboss.cpp}::draw_button ( const IconManager::VIcons & icons,
IconType type,
bool disable = false )
3425 {
3426 return Slic3r::GUI::button(
3427 get_icon(icons, type, IconState::activable),
3428 get_icon(icons, type, IconState::hovered),
3429 get_icon(icons, type, IconState::disabled),
3430 disable);}
bool button(const IconManager::Icon &activ, const IconManager::Icon &hover, const IconManager::Icon &disable, bool disabled)
Use icon as button with 3 states activ hover and disabled.
Definition IconManager.cpp:418
const IconManager::Icon & get_icon(const IconManager::VIcons &icons, IconType type, IconState state)
Definition GLGizmoEmboss.cpp:3422

References activable, Slic3r::GUI::button(), disabled, draw_button(), get_icon(), and hovered.

Referenced by draw_button().

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

◆ draw_font_preview()

void anonymous_namespace{GLGizmoEmboss.cpp}::draw_font_preview ( FaceName & face,
const std::string & text,
Facenames & faces,
const GuiCfg & cfg,
bool is_visible )
3712 {
3713 // Limit for opened font files at one moment
3714 unsigned int &count_opened_fonts = faces.count_opened_font_files;
3715 // Size of texture
3716 ImVec2 size(cfg.face_name_size.x(), cfg.face_name_size.y());
3717 float count_cached_textures_f = static_cast<float>(faces.count_cached_textures);
3718 std::string state_text;
3719 // uv0 and uv1 set to pixel 0,0 in texture
3720 ImVec2 uv0(0.f, 0.f), uv1(1.f / size.x, 1.f / size.y / count_cached_textures_f);
3721 if (face.is_created != nullptr) {
3722 // not created preview
3723 if (*face.is_created) {
3724 // Already created preview
3725 size_t texture_index = face.texture_index;
3726 uv0 = ImVec2(0.f, texture_index / count_cached_textures_f);
3727 uv1 = ImVec2(1.f, (texture_index + 1) / count_cached_textures_f);
3728 } else {
3729 // Not finished preview
3730 if (is_visible) {
3731 // when not canceled still loading
3732 state_text = (face.cancel->load()) ?
3733 " " + _u8L("No symbol"):
3734 " ... " + _u8L("Loading");
3735 } else {
3736 // not finished and not visible cancel job
3737 face.is_created = nullptr;
3738 face.cancel->store(true);
3739 }
3740 }
3741 } else if (is_visible && count_opened_fonts < cfg.max_count_opened_font_files) {
3742 ++count_opened_fonts;
3743 face.cancel = std::make_shared<std::atomic_bool>(false);
3744 face.is_created = std::make_shared<bool>(false);
3745
3746 const unsigned char gray_level = 5;
3747 // format type and level must match to texture data
3748 const GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE;
3749 const GLint level = 0;
3750 // select next texture index
3751 size_t texture_index = (faces.texture_index + 1) % faces.count_cached_textures;
3752
3753 // set previous cach as deleted
3754 for (FaceName &f : faces.faces)
3755 if (f.texture_index == texture_index) {
3756 if (f.cancel != nullptr) f.cancel->store(true);
3757 f.is_created = nullptr;
3758 }
3759
3760 faces.texture_index = texture_index;
3761 face.texture_index = texture_index;
3762
3763 // render text to texture
3764 FontImageData data{
3765 text,
3766 face.wx_name,
3767 faces.encoding,
3768 faces.texture_id,
3769 faces.texture_index,
3770 cfg.face_name_size,
3771 gray_level,
3772 format,
3773 type,
3774 level,
3775 &count_opened_fonts,
3776 face.cancel, // copy
3777 face.is_created // copy
3778 };
3779 auto job = std::make_unique<CreateFontImageJob>(std::move(data));
3780 auto &worker = wxGetApp().plater()->get_ui_job_worker();
3781 queue_job(worker, std::move(job));
3782 } else {
3783 // cant start new thread at this moment so wait in queue
3784 state_text = " ... " + _u8L("In queue");
3785 }
3786
3787 if (!state_text.empty()) {
3788 ImGui::SameLine(cfg.face_name_texture_offset_x);
3789 ImGui::Text("%s", state_text.c_str());
3790 }
3791
3792 ImGui::SameLine(cfg.face_name_texture_offset_x);
3793 ImTextureID tex_id = (void *) (intptr_t) faces.texture_id;
3794 ImVec4 tint_color = ImGui::GetStyleColorVec4(ImGuiCol_Text);
3795 ImGui::Image(tex_id, size, uv0, uv1, tint_color);
3796}
int GLint
Definition gl.h:2062
unsigned int GLenum
Definition gl.h:2054
#define GL_UNSIGNED_BYTE
Definition gl.h:1937
#define GL_RGBA
Definition gl.h:1493
bool queue_job(Worker &w, ProcessFn fn, FinishFn finishfn)
Definition Worker.hpp:62
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45
wxString wx_name
Definition GLGizmoEmboss.cpp:231
std::shared_ptr< bool > is_created
Definition GLGizmoEmboss.cpp:238
size_t texture_index
Definition GLGizmoEmboss.cpp:233
unsigned int max_count_opened_font_files
Definition GLGizmoEmboss.cpp:322
std::shared_ptr< std::atomic< bool > > cancel
Definition GLGizmoEmboss.cpp:236
Definition GLGizmoEmboss.cpp:230
GLuint texture_id
Definition GLGizmoEmboss.cpp:262
unsigned int count_opened_font_files
Definition GLGizmoEmboss.cpp:268
const int count_cached_textures
Definition GLGizmoEmboss.cpp:271
size_t texture_index
Definition GLGizmoEmboss.cpp:274
std::vector< FaceName > faces
Definition GLGizmoEmboss.cpp:253
static const wxFontEncoding encoding
Definition GLGizmoEmboss.cpp:259

References _u8L, anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::cancel, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::count_cached_textures, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::count_opened_font_files, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::encoding, Slic3r::f(), anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::face_name_size, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::face_name_texture_offset_x, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces, Slic3r::format(), GL_RGBA, GL_UNSIGNED_BYTE, anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::is_created, anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::max_count_opened_font_files, Slic3r::GUI::queue_job(), anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::texture_id, anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::texture_index, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::texture_index, and anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::wx_name.

Here is the call graph for this function:

◆ fix_transformation()

void anonymous_namespace{GLGizmoEmboss.cpp}::fix_transformation ( const StyleManager::Style & from,
const StyleManager::Style & to,
GLCanvas3D & canvas )
1361{
1362 // fix Z rotation when exists difference in styles
1363 const std::optional<float>& f_angle_opt = from.angle;
1364 const std::optional<float>& t_angle_opt = to.angle;
1365 if (!is_approx(f_angle_opt, t_angle_opt)) {
1366 // fix rotation
1367 float f_angle = f_angle_opt.value_or(.0f);
1368 float t_angle = t_angle_opt.value_or(.0f);
1369 do_local_z_rotate(canvas.get_selection(), t_angle - f_angle);
1370 std::string no_snapshot;
1371 canvas.do_rotate(no_snapshot);
1372 }
1373
1374 // fix distance (Z move) when exists difference in styles
1375 const std::optional<float>& f_move_opt = from.distance;
1376 const std::optional<float>& t_move_opt = to.distance;
1377 if (!is_approx(f_move_opt, t_move_opt)) {
1378 float f_move = f_move_opt.value_or(.0f);
1379 float t_move = t_move_opt.value_or(.0f);
1380 do_local_z_move(canvas.get_selection(), t_move - f_move);
1381 std::string no_snapshot;
1382 canvas.do_move(no_snapshot);
1383 }
1384}
void do_move(const std::string &snapshot_type, bool force_volume_move=false)
Definition GLCanvas3D.cpp:5635
void do_rotate(const std::string &snapshot_type)
Definition GLCanvas3D.cpp:5773
const Selection & get_selection() const
Definition GLCanvas3D.hpp:1028
void do_local_z_rotate(Selection &selection, double relative_angle)
Rotation around z Axis(emboss direction).
Definition SurfaceDrag.cpp:406
void do_local_z_move(Selection &selection, double relative_move)
Translation along local z Axis (emboss direction).
Definition SurfaceDrag.cpp:438
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:320
std::optional< float > distance
Definition EmbossStyleManager.hpp:204
std::optional< float > angle
Definition EmbossStyleManager.hpp:210

References Slic3r::GUI::Emboss::StyleManager::Style::angle, Slic3r::GUI::Emboss::StyleManager::Style::distance, Slic3r::GUI::do_local_z_move(), Slic3r::GUI::do_local_z_rotate(), Slic3r::GUI::GLCanvas3D::do_move(), Slic3r::GUI::GLCanvas3D::do_rotate(), fix_transformation(), Slic3r::GUI::GLCanvas3D::get_selection(), and Slic3r::is_approx().

Referenced by fix_transformation().

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

◆ get_fontlist_cache_path()

boost::filesystem::path anonymous_namespace{GLGizmoEmboss.cpp}::get_fontlist_cache_path ( )
3556 {
3557 return boost::filesystem::path(data_dir()) / "cache" / "fonts.cereal";
3558}
const std::string & data_dir()
Definition utils.cpp:365

References Slic3r::data_dir().

Referenced by init_face_names(), load(), and store().

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

◆ get_icon()

const IconManager::Icon & anonymous_namespace{GLGizmoEmboss.cpp}::get_icon ( const IconManager::VIcons & icons,
IconType type,
IconState state )
3422 {
3423 return *icons[(unsigned) type][(unsigned) state]; }

References get_icon().

Referenced by draw_button(), and get_icon().

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

◆ get_installed_face_name()

std::optional< wxString > anonymous_namespace{GLGizmoEmboss.cpp}::get_installed_face_name ( const std::optional< std::string > & face_name_opt,
::Facenames & face_names )

Check installed fonts whether optional face name exist in installed fonts.

Parameters
face_name_optName from style - style.prop.face_name
face_namesAll installed good and bad fonts - not const must be possible to initialize it
Returns
When it could be installed it contain value(potentionaly empty string)
1149{
1150 // Could exist OS without getter on face_name,
1151 // but it is able to restore font from descriptor
1152 // Soo default value must be TRUE
1153 if (!face_name_opt.has_value())
1154 return wxString();
1155
1156 wxString face_name = wxString::FromUTF8(face_name_opt->c_str());
1157
1158 // search in enumerated fonts
1159 // refresh list of installed font in the OS.
1160 init_face_names(face_names);
1161 face_names.is_init = false;
1162
1163 auto cmp = [](const FaceName &fn, const wxString &wx_name) { return fn.wx_name < wx_name; };
1164 const std::vector<FaceName> &faces = face_names.faces;
1165 // is font installed?
1166 if (auto it = std::lower_bound(faces.begin(), faces.end(), face_name, cmp);
1167 it != faces.end() && it->wx_name == face_name)
1168 return face_name;
1169
1170 const std::vector<wxString> &bad = face_names.bad;
1171 auto it_bad = std::lower_bound(bad.begin(), bad.end(), face_name);
1172 if (it_bad == bad.end() || *it_bad != face_name) {
1173 // check if wx allowed to set it up - another encoding of name
1174 wxFontEnumerator::InvalidateCache();
1175 wxFont wx_font_; // temporary structure
1176 if (wx_font_.SetFaceName(face_name) && WxFontUtils::create_font_file(wx_font_) != nullptr // can load TTF file?
1177 ) {
1178 return wxString();
1179 // QUESTION: add this name to allowed faces?
1180 // Could create twin of font face name
1181 // When not add it will be hard to select it again when change font
1182 }
1183 }
1184 return {}; // not installed
1185}
static std::unique_ptr< Slic3r::Emboss::FontFile > create_font_file(const wxFont &font)
Definition WxFontUtils.cpp:93
void init_face_names(Facenames &facenames)
Definition GLGizmoEmboss.cpp:3622

References Slic3r::GUI::WxFontUtils::create_font_file(), get_installed_face_name(), init_face_names(), and anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::wx_name.

Referenced by get_installed_face_name().

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

◆ init_face_names()

void anonymous_namespace{GLGizmoEmboss.cpp}::init_face_names ( Facenames & facenames)
3623{
3624 Timer t("enumerate_fonts");
3625 if (face_names.is_init) return;
3626 face_names.is_init = true;
3627
3628 // to reload fonts from system, when install new one
3629 wxFontEnumerator::InvalidateCache();
3630
3631 // try load cache
3632 // Only not OS enumerated face has hash value 0
3633 if (face_names.hash == 0) {
3634 load(face_names);
3635 face_names.has_truncated_names = false;
3636 }
3637
3638 using namespace std::chrono;
3639 steady_clock::time_point enumerate_start = steady_clock::now();
3640 ScopeGuard sg([&enumerate_start, &face_names = face_names]() {
3641 steady_clock::time_point enumerate_end = steady_clock::now();
3642 long long enumerate_duration = duration_cast<milliseconds>(enumerate_end - enumerate_start).count();
3643 BOOST_LOG_TRIVIAL(info) << "OS enumerate " << face_names.faces.size() << " fonts "
3644 << "(+ " << face_names.bad.size() << " can't load "
3645 << "= " << face_names.faces.size() + face_names.bad.size() << " fonts) "
3646 << "in " << enumerate_duration << " ms\n" << concat(face_names.bad);
3647 });
3648 wxArrayString facenames = wxFontEnumerator::GetFacenames(face_names.encoding);
3649 size_t hash = boost::hash_range(facenames.begin(), facenames.end());
3650 // Zero value is used as uninitialized hash
3651 if (hash == 0) hash = 1;
3652 // check if it is same as last time
3653 if (face_names.hash == hash) {
3654 // no new installed font
3655 BOOST_LOG_TRIVIAL(info) << "Same FontNames hash, cache is used. "
3656 << "For clear cache delete file: " << get_fontlist_cache_path().string();
3657 return;
3658 }
3659
3660 BOOST_LOG_TRIVIAL(info) << ((face_names.hash == 0) ?
3661 "FontName list is generate from scratch." :
3662 "Hash are different. Only previous bad fonts are used and set again as bad");
3663 face_names.hash = hash;
3664
3665 // validation lambda
3666 auto is_valid_font = [encoding = face_names.encoding, bad = face_names.bad /*copy*/](const wxString &name) {
3667 if (name.empty()) return false;
3668
3669 // vertical font start with @, we will filter it out
3670 // Not sure if it is only in Windows so filtering is on all platforms
3671 if (name[0] == '@') return false;
3672
3673 // previously detected bad font
3674 auto it = std::lower_bound(bad.begin(), bad.end(), name);
3675 if (it != bad.end() && *it == name) return false;
3676
3677 wxFont wx_font(wxFontInfo().FaceName(name).Encoding(encoding));
3678 //*
3679 // Faster chech if wx_font is loadable but not 100%
3680 // names could contain not loadable font
3681 if (!WxFontUtils::can_load(wx_font)) return false;
3682
3683 /*/
3684 // Slow copy of font files to try load font
3685 // After this all files are loadable
3686 auto font_file = WxFontUtils::create_font_file(wx_font);
3687 if (font_file == nullptr)
3688 return false; // can't create font file
3689 // */
3690 return true;
3691 };
3692
3693 face_names.faces.clear();
3694 face_names.faces_names.clear();
3695 face_names.bad.clear();
3696 face_names.faces.reserve(facenames.size());
3697 face_names.faces_names.reserve(facenames.size());
3698 std::sort(facenames.begin(), facenames.end());
3699 for (const wxString &name : facenames) {
3700 if (is_valid_font(name)) {
3701 face_names.faces.push_back({name});
3702 face_names.faces_names.push_back(name.utf8_string());
3703 }else{
3704 face_names.bad.push_back(name);
3705 }
3706 }
3707 assert(std::is_sorted(face_names.bad.begin(), face_names.bad.end()));
3708 face_names.has_truncated_names = false;
3709 store(face_names);
3710}
static bool can_load(const wxFont &font)
Definition WxFontUtils.cpp:75
Definition Utils.hpp:533
Instance of this class is used for measure time consumtion of block code until instance is alive and ...
Definition Timer.hpp:16
bool load(Facenames &facenames)
Definition GLGizmoEmboss.cpp:3581
std::string concat(std::vector< wxString > data)
Definition GLGizmoEmboss.cpp:3549
boost::filesystem::path get_fontlist_cache_path()
Definition GLGizmoEmboss.cpp:3556
bool store(const Facenames &facenames)
Definition GLGizmoEmboss.cpp:3560

References anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::bad, Slic3r::GUI::WxFontUtils::can_load(), concat(), anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::encoding, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces_names, get_fontlist_cache_path(), anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::has_truncated_names, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::hash, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::is_init, load(), and store().

Referenced by get_installed_face_name().

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

◆ init_text_lines()

void anonymous_namespace{GLGizmoEmboss.cpp}::init_text_lines ( TextLinesModel & text_lines,
const Selection & selection,
StyleManager & style_manager,
unsigned count_lines = 0 )
1188{
1189 const GLVolume *gl_volume_ptr = selection.get_first_volume();
1190 if (gl_volume_ptr == nullptr)
1191 return;
1192 const GLVolume &gl_volume = *gl_volume_ptr;
1193 const ModelObjectPtrs &objects = selection.get_model()->objects;
1194 const ModelVolume *mv_ptr = get_model_volume(gl_volume, objects);
1195 if (mv_ptr == nullptr)
1196 return;
1197 const ModelVolume &mv = *mv_ptr;
1198 if (mv.is_the_only_one_part())
1199 return;
1200
1201 const std::optional<EmbossShape> &es_opt = mv.emboss_shape;
1202 if (!es_opt.has_value())
1203 return;
1204 const EmbossShape &es = *es_opt;
1205
1206 const std::optional<TextConfiguration> &tc_opt = mv.text_configuration;
1207 if (!tc_opt.has_value())
1208 return;
1209 const TextConfiguration &tc = *tc_opt;
1210
1211 // calculate count lines when not set
1212 if (count_lines == 0) {
1213 count_lines = get_count_lines(tc.text);
1214 if (count_lines == 0)
1215 return;
1216 }
1217
1218 // prepare volumes to slice
1220
1221 // For interactivity during drag over surface it must be from gl_volume not volume.
1222 Transform3d mv_trafo = gl_volume.get_volume_transformation().get_matrix();
1223 if (es.fix_3mf_tr.has_value())
1224 mv_trafo = mv_trafo * (es.fix_3mf_tr->inverse());
1225 text_lines.init(mv_trafo, volumes, style_manager, count_lines);
1226}
const Geometry::Transformation & get_volume_transformation() const
Definition 3DScene.hpp:306
Model * get_model() const
Definition Selection.hpp:219
const GLVolume * get_first_volume() const
Definition Selection.hpp:317
void init(const Transform3d &text_tr, const ModelVolumePtrs &volumes_to_slice, Emboss::StyleManager &style_manager, unsigned count_lines)
Initialize model and lines.
Definition TextLines.cpp:240
const Transform3d & get_matrix() const
Definition Geometry.hpp:477
Definition Model.hpp:832
bool is_the_only_one_part() const
Definition Model.cpp:2128
std::optional< EmbossShape > emboss_shape
Definition Model.hpp:1019
std::optional< TextConfiguration > text_configuration
Definition Model.hpp:1015
ModelObjectPtrs objects
Definition Model.hpp:1702
unsigned get_count_lines(const std::wstring &ws)
Sum of character ' '.
Definition Emboss.cpp:1437
static ModelVolume * get_model_volume(const Selection &selection, Model &model)
Definition GLGizmoBrimEars.cpp:66
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
std::vector< ModelVolume * > ModelVolumePtrs
Definition Model.hpp:139
std::vector< ModelObject * > ModelObjectPtrs
Definition CutUtils.hpp:13
ModelVolumePtrs prepare_volumes_to_slice(const ModelVolume &mv)
Definition GLGizmoEmboss.cpp:436
Contain plane shape information to be able emboss it and edit it.
Definition EmbossShape.hpp:66
std::optional< Slic3r::Transform3d > fix_3mf_tr
Definition EmbossShape.hpp:87
Define how to create 'Text volume' It is stored into .3mf by TextConfigurationSerialization It is par...
Definition TextConfiguration.hpp:176
std::string text
Definition TextConfiguration.hpp:181

References Slic3r::ModelVolume::emboss_shape, Slic3r::EmbossShape::fix_3mf_tr, Slic3r::Emboss::get_count_lines(), Slic3r::GUI::Selection::get_first_volume(), Slic3r::Geometry::Transformation::get_matrix(), Slic3r::GUI::Selection::get_model(), Slic3r::GUI::get_model_volume(), Slic3r::GLVolume::get_volume_transformation(), Slic3r::GUI::TextLinesModel::init(), init_text_lines(), Slic3r::ModelVolume::is_the_only_one_part(), Slic3r::Model::objects, prepare_volumes_to_slice(), Slic3r::TextConfiguration::text, and Slic3r::ModelVolume::text_configuration.

Referenced by create_emboss_data_base(), and init_text_lines().

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

◆ init_truncated_names()

void anonymous_namespace{GLGizmoEmboss.cpp}::init_truncated_names ( Facenames & face_names,
float max_width )
3614{
3615 for (FaceName &face : face_names.faces) {
3616 std::string name_str(face.wx_name.ToUTF8().data());
3617 face.name_truncated = ImGuiWrapper::trunc(name_str, max_width);
3618 }
3619 face_names.has_truncated_names = true;
3620}
static std::string trunc(const std::string &text, float width, const char *tail=" ..")
Truncate text by ImGui draw function to specific width NOTE 1: ImGui must be initialized NOTE 2: Calc...
Definition ImGuiWrapper.cpp:2427
std::string name_truncated
Definition GLGizmoEmboss.cpp:232
bool has_truncated_names
Definition GLGizmoEmboss.cpp:250

References anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::has_truncated_names, anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::name_truncated, Slic3r::GUI::ImGuiWrapper::trunc(), and anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::wx_name.

Here is the call graph for this function:

◆ is_text_empty()

bool anonymous_namespace{GLGizmoEmboss.cpp}::is_text_empty ( std::string_view text)
1437{ return text.empty() || text.find_first_not_of(" \n\t\r") == std::string::npos; }

References is_text_empty().

Referenced by is_text_empty().

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

◆ load()

bool anonymous_namespace{GLGizmoEmboss.cpp}::load ( Facenames & facenames)
3581 {
3582 boost::filesystem::path path = get_fontlist_cache_path();
3583 std::string path_str = path.string();
3584 if (!boost::filesystem::exists(path)) {
3585 BOOST_LOG_TRIVIAL(warning) << "Fontlist cache - '" << path_str << "' does not exists.";
3586 return false;
3587 }
3588 boost::nowide::ifstream file(path_str, std::ios::binary);
3589 cereal::BinaryInputArchive archive(file);
3590
3592 try {
3593 archive(data);
3594 } catch (const std::exception &ex) {
3595 BOOST_LOG_TRIVIAL(error) << "Failed to load fontlist cache - '" << path_str << "'. Exception: " << ex.what();
3596 return false;
3597 }
3598
3599 assert(std::is_sorted(data.bad.begin(), data.bad.end()));
3600 assert(std::is_sorted(data.good.begin(), data.good.end()));
3601
3602 facenames.hash = data.hash;
3603 facenames.faces.reserve(data.good.size());
3604 facenames.faces_names.reserve(data.good.size());
3605 for (const wxString &face : data.good) {
3606 facenames.faces.push_back({face});
3607 facenames.faces_names.push_back(face.utf8_string());
3608 }
3609 facenames.bad = data.bad;
3610 return true;
3611}
size_t hash
Definition GLGizmoEmboss.cpp:3396
std::vector< wxString > bad
Definition GLGizmoEmboss.cpp:3400
std::vector< wxString > good
Definition GLGizmoEmboss.cpp:3398
Definition GLGizmoEmboss.cpp:3394
std::vector< std::string > faces_names
Definition GLGizmoEmboss.cpp:254
size_t hash
Definition GLGizmoEmboss.cpp:278
std::vector< wxString > bad
Definition GLGizmoEmboss.cpp:256

References anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::bad, FacenamesSerializer::bad, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces_names, get_fontlist_cache_path(), FacenamesSerializer::good, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::hash, and FacenamesSerializer::hash.

Referenced by init_face_names().

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

◆ prepare_volumes_to_slice()

ModelVolumePtrs anonymous_namespace{GLGizmoEmboss.cpp}::prepare_volumes_to_slice ( const ModelVolume & mv)
437{
438 const ModelVolumePtrs &volumes = mv.get_object()->volumes;
439 ModelVolumePtrs result;
440 result.reserve(volumes.size());
441 for (ModelVolume *volume : volumes) {
442 // only part could be surface for volumes
443 if (!volume->is_model_part())
444 continue;
445
446 // is selected volume
447 if (mv.id() == volume->id())
448 continue;
449
450 result.push_back(volume);
451 }
452 return result;
453}
ModelVolumePtrs volumes
Definition Model.hpp:393
ModelObject * get_object() const
Definition Model.hpp:1022
ObjectID id() const
Definition ObjectID.hpp:69
size_t id
Definition ObjectID.hpp:39

References Slic3r::ModelVolume::get_object(), Slic3r::ObjectBase::id(), Slic3r::ObjectID::id, prepare_volumes_to_slice(), and Slic3r::ModelObject::volumes.

Referenced by init_text_lines(), and prepare_volumes_to_slice().

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

◆ store()

bool anonymous_namespace{GLGizmoEmboss.cpp}::store ( const Facenames & facenames)
3560 {
3561 std::string cache_path = get_fontlist_cache_path().string();
3562 boost::nowide::ofstream file(cache_path, std::ios::binary);
3563 ::cereal::BinaryOutputArchive archive(file);
3564 std::vector<wxString> good;
3565 good.reserve(facenames.faces.size());
3566 for (const FaceName &face : facenames.faces) good.push_back(face.wx_name);
3567 FacenamesSerializer data = {facenames.hash, good, facenames.bad};
3568
3569 assert(std::is_sorted(data.bad.begin(), data.bad.end()));
3570 assert(std::is_sorted(data.good.begin(), data.good.end()));
3571
3572 try {
3573 archive(data);
3574 } catch (const std::exception &ex) {
3575 BOOST_LOG_TRIVIAL(error) << "Failed to write fontlist cache - " << cache_path << ex.what();
3576 return false;
3577 }
3578 return true;
3579}

References anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::bad, FacenamesSerializer::bad, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::faces, get_fontlist_cache_path(), FacenamesSerializer::good, anonymous_namespace{GLGizmoEmboss.cpp}::Facenames::hash, and anonymous_namespace{GLGizmoEmboss.cpp}::FaceName::wx_name.

Referenced by init_face_names().

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

Variable Documentation

◆ default_text

const char* const anonymous_namespace{GLGizmoEmboss.cpp}::default_text = L("Embossed text")

◆ limits

const struct anonymous_namespace{GLGizmoEmboss.cpp}::Limits anonymous_namespace{GLGizmoEmboss.cpp}::limits
static

◆ move_snapshot_name

const std::string anonymous_namespace{GLGizmoEmboss.cpp}::move_snapshot_name = L("Text move")

◆ rotation_snapshot_name

const std::string anonymous_namespace{GLGizmoEmboss.cpp}::rotation_snapshot_name = L("Text rotate")

◆ SELECTABLE_INNER_OFFSET

const float anonymous_namespace{GLGizmoEmboss.cpp}::SELECTABLE_INNER_OFFSET = 8.0f
static