OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::DesignTextDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/CAD/DesignTextDialog.hpp>

Inheritance diagram for Slic3r::GUI::DesignTextDialog:
Collaboration diagram for Slic3r::GUI::DesignTextDialog:

Classes

struct  Spec

Public Member Functions

 DesignTextDialog (wxWindow *parent, const Spec *initial=nullptr)
const ImportRegions & regions () const
wxString text () const
Spec spec () const
void EndModal (int retCode) override
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()
int ShowModal ()

Public Attributes

std::function< void()> on_change
std::function< void()> on_accept
std::function< void()> on_cancel

Protected Member Functions

void on_dpi_changed (const wxRect &suggested_rect) override
void on_sys_color_changed () override

Private Member Functions

void load_font ()
void update_preview ()
wxFont current_font () const
void draw_preview (wxWindow *canvas)
void accept ()
void cancel ()
double height_mm () const
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

bool m_done {false}
::TextInput * m_text {nullptr}
::ComboBox * m_face {nullptr}
::CheckBox * m_bold {nullptr}
::CheckBox * m_italic {nullptr}
::TextInput * m_height {nullptr}
double m_last_height {10.0}
wxWindow * m_preview {nullptr}
wxStaticText * m_size {nullptr}
wxWindow * m_ok {nullptr}
std::shared_ptr< const Emboss::FontFile > m_font_file
ImportRegions m_regions
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description


Class Documentation

◆ Slic3r::GUI::DesignTextDialog::Spec

struct Slic3r::GUI::DesignTextDialog::Spec
Collaboration diagram for Slic3r::GUI::DesignTextDialog::Spec:
Class Members
string font
double height {10.0}
wxString text

Constructor & Destructor Documentation

◆ DesignTextDialog()

Slic3r::GUI::DesignTextDialog::DesignTextDialog ( wxWindow * parent,
const Spec * initial = nullptr )
65 : DPIDialog(parent, wxID_ANY, _L("Text"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
66{
67 SetFont(Label::Body_14);
68 SetBackgroundColour(*wxWHITE); // light palette colour, dark-mapped by UpdateDlgDarkUI
69 const int em = em_unit();
70
71 // The text being edited, else the last used font and height, else the GUI font at 10 mm.
72 wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
73 double height = 10.0;
74 if (initial != nullptr) {
75 wxFont f = WxFontUtils::load_wxFont(initial->font);
76 if (f.IsOk()) font = f;
77 if (initial->height > 0.0) height = std::clamp(initial->height, 0.5, 500.0);
78 } else if (AppConfig* cfg = wxGetApp().app_config) {
79 const std::string desc = cfg->get(kFontKey);
80 if (!desc.empty()) {
81 wxFont f = WxFontUtils::load_wxFont(desc);
82 if (f.IsOk()) font = f;
83 }
84 const std::string h = cfg->get(kHeightKey);
85 if (!h.empty()) {
86 try { height = std::clamp(std::stod(h), 0.5, 500.0); } catch (...) {}
87 }
88 }
90
91 auto* form = new wxFlexGridSizer(2, em / 2, em);
92 form->AddGrowableCol(1, 1);
93 auto label = [this, form](const wxString& text) {
94 form->Add(new wxStaticText(this, wxID_ANY, text), 0, wxALIGN_CENTER_VERTICAL);
95 };
96
97 m_text = new ::TextInput(this, initial ? initial->text : wxString(), "", "", wxDefaultPosition,
98 wxSize(30 * em, -1), wxTE_PROCESS_ENTER);
99 m_text->GetTextCtrl()->SetHint(_L("Type the text to insert"));
100 label(_L("Text"));
101 form->Add(m_text, 1, wxEXPAND);
102
103 m_face = new ::ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(30 * em, -1), 0, nullptr,
104 wxCB_READONLY);
105 const wxArrayString& faces = font_faces();
106 for (const wxString& f : faces)
107 m_face->Append(f);
108 const int sel = faces.Index(font.GetFaceName());
109 m_face->SetSelection(sel != wxNOT_FOUND ? sel : 0);
110 label(_L("Font"));
111 form->Add(m_face, 1, wxEXPAND);
112
113 // Orca's CheckBox carries no label: each one sits beside its own text.
114 auto* style = new wxBoxSizer(wxHORIZONTAL);
115 auto check = [this, style, em](const wxString& text, bool value) {
116 auto* c = new ::CheckBox(this);
117 c->SetValue(value);
118 style->Add(c, 0, wxALIGN_CENTER_VERTICAL);
119 style->Add(new wxStaticText(this, wxID_ANY, text), 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, em / 2);
120 return c;
121 };
122 m_bold = check(_L("Bold"), WxFontUtils::is_bold(font));
123 m_italic = check(_L("Italic"), WxFontUtils::is_italic(font));
124 form->AddSpacer(0);
125 form->Add(style, 0);
126
127 m_height = new ::TextInput(this, wxString::FromCDouble(height, 1), _L("mm"), "", wxDefaultPosition,
128 wxSize(10 * em, -1), wxTE_PROCESS_ENTER);
129 label(_L("Height"));
130 form->Add(m_height, 0);
131
132 // The outline of what will be inserted, fitted to the box, with its real size under it.
133 // A thumbnail only: the text itself is drawn in the canvas, where it will be.
134 m_preview = new wxWindow(this, wxID_ANY, wxDefaultPosition, wxSize(30 * em, 5 * em));
135 m_preview->SetBackgroundStyle(wxBG_STYLE_PAINT);
136 m_preview->Bind(wxEVT_PAINT, [this](wxPaintEvent&) { draw_preview(m_preview); });
137 m_preview->Bind(wxEVT_SIZE, [this](wxSizeEvent& e) { m_preview->Refresh(); e.Skip(); });
138 m_size = new wxStaticText(this, wxID_ANY, wxEmptyString);
139
140 auto* buttons = new DialogButtons(this, {"OK", "Cancel"});
141 m_ok = buttons->GetOK();
142
143 auto* top = new wxBoxSizer(wxVERTICAL);
144 top->Add(form, 0, wxEXPAND | wxALL, em);
145 top->Add(m_preview, 1, wxEXPAND | wxLEFT | wxRIGHT, em);
146 top->Add(m_size, 0, wxLEFT | wxRIGHT | wxTOP, em);
147 top->Add(buttons, 0, wxEXPAND);
148
149 m_text->Bind(wxEVT_TEXT, [this](wxCommandEvent& e) { update_preview(); e.Skip(); });
150 m_text->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent&) { accept(); }); // Enter = OK, as everywhere in the tab
151 m_face->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& e) { load_font(); update_preview(); e.Skip(); });
152 for (::CheckBox* c : {m_bold, m_italic})
153 c->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& e) { e.Skip(); CallAfter([this] { load_font(); update_preview(); }); });
154 m_height->Bind(wxEVT_TEXT, [this](wxCommandEvent& e) { update_preview(); e.Skip(); });
155 m_height->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent&) { accept(); });
156 buttons->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { accept(); });
157 buttons->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { cancel(); });
158 Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent&) { cancel(); });
159 Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
160 if (e.GetKeyCode() == WXK_ESCAPE) cancel();
161 else e.Skip();
162 });
163
164 SetSizerAndFit(top);
165 // Out of the middle of the window, where the text is being placed: top right of the parent.
166 if (parent != nullptr) {
167 const wxRect pr = parent->GetScreenRect();
168 SetPosition(wxPoint(std::max(pr.GetLeft(), pr.GetRight() - GetSize().x - 2 * em), pr.GetTop() + 8 * em));
169 } else {
170 CenterOnParent();
171 }
172 wxGetApp().UpdateDlgDarkUI(this);
173
174 load_font();
176 m_text->GetTextCtrl()->SetFocus();
177}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
#define style
Definition WipeTowerDialog.cpp:101
static wxFont Body_14
Definition Label.hpp:53
int em_unit() const
Definition GUI_Utils.hpp:203
::TextInput * m_height
Definition DesignTextDialog.hpp:68
void draw_preview(wxWindow *canvas)
Definition DesignTextDialog.cpp:260
wxString text() const
Definition DesignTextDialog.cpp:187
double m_last_height
Definition DesignTextDialog.hpp:69
void load_font()
Definition DesignTextDialog.cpp:221
wxWindow * m_ok
Definition DesignTextDialog.hpp:72
::ComboBox * m_face
Definition DesignTextDialog.hpp:65
::CheckBox * m_bold
Definition DesignTextDialog.hpp:66
wxWindow * m_preview
Definition DesignTextDialog.hpp:70
::CheckBox * m_italic
Definition DesignTextDialog.hpp:67
void update_preview()
Definition DesignTextDialog.cpp:229
::TextInput * m_text
Definition DesignTextDialog.hpp:64
void cancel()
Definition DesignTextDialog.cpp:205
wxStaticText * m_size
Definition DesignTextDialog.hpp:71
void accept()
Definition DesignTextDialog.cpp:194
static bool is_bold(const wxFont &font)
Definition WxFontUtils.cpp:304
static wxFont load_wxFont(const std::string &font_descriptor)
Definition WxFontUtils.cpp:190
static bool is_italic(const wxFont &font)
Definition WxFontUtils.cpp:298
static const char * kFontKey
Definition DesignTextDialog.cpp:41
static const char * kHeightKey
Definition DesignTextDialog.cpp:42
static const wxArrayString & font_faces()
Definition DesignTextDialog.cpp:46
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
bool check(ModelVolumeType volume_type)
Definition GLGizmoEmboss.cpp:515

References _L, accept(), Label::Body_14, draw_preview(), Slic3r::GUI::DPIAware< wxDialog >::em_unit(), Slic3r::f(), Slic3r::GUI::DesignTextDialog::Spec::font, Slic3r::GUI::font_faces(), Slic3r::GUI::DesignTextDialog::Spec::height, Slic3r::GUI::WxFontUtils::is_bold(), Slic3r::GUI::WxFontUtils::is_italic(), Slic3r::GUI::kFontKey, Slic3r::GUI::kHeightKey, load_font(), Slic3r::GUI::WxFontUtils::load_wxFont(), m_bold, m_face, m_height, m_italic, m_last_height, m_ok, m_preview, m_size, m_text, style, Slic3r::GUI::DesignTextDialog::Spec::text, text(), update_preview(), and wxStaticText.

Referenced by height_mm().

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

Member Function Documentation

◆ accept()

void Slic3r::GUI::DesignTextDialog::accept ( )
private
195{
196 if (m_done || m_regions.empty()) return; // nothing to insert: the size line says why
197 m_done = true;
198 if (AppConfig* cfg = wxGetApp().app_config) {
200 cfg->set(kHeightKey, std::to_string(height_mm()));
201 }
202 if (on_accept) on_accept();
203}
std::function< void()> on_accept
Definition DesignTextDialog.hpp:46
wxFont current_font() const
Definition DesignTextDialog.cpp:212
ImportRegions m_regions
Definition DesignTextDialog.hpp:75
double height_mm() const
Definition DesignTextDialog.cpp:179
bool m_done
Definition DesignTextDialog.hpp:60
static std::string store_wxFont(const wxFont &font)
Definition WxFontUtils.cpp:176

References accept(), current_font(), height_mm(), Slic3r::GUI::kFontKey, Slic3r::GUI::kHeightKey, m_done, m_regions, on_accept, and Slic3r::GUI::WxFontUtils::store_wxFont().

Referenced by DesignTextDialog(), and accept().

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

◆ cancel()

void Slic3r::GUI::DesignTextDialog::cancel ( )
private
206{
207 if (m_done) return;
208 m_done = true;
209 if (on_cancel) on_cancel();
210}
std::function< void()> on_cancel
Definition DesignTextDialog.hpp:47

References cancel(), m_done, and on_cancel.

Referenced by cancel().

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

◆ current_font()

wxFont Slic3r::GUI::DesignTextDialog::current_font ( ) const
private
213{
214 wxFontInfo info(12);
215 if (m_face->GetSelection() != wxNOT_FOUND)
216 info.FaceName(m_face->GetString(m_face->GetSelection()));
217 info.Bold(m_bold->GetValue()).Italic(m_italic->GetValue());
218 return wxFont(info);
219}

References current_font(), m_bold, m_face, and m_italic.

Referenced by accept(), current_font(), load_font(), and spec().

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

◆ draw_preview()

void Slic3r::GUI::DesignTextDialog::draw_preview ( wxWindow * canvas)
private
261{
262 wxAutoBufferedPaintDC dc(canvas);
263 const bool dark = wxGetApp().dark_mode();
264 dc.SetBackground(wxBrush(dark ? wxColour(0x1e, 0x1e, 0x22) : wxColour(0xf4, 0xf4, 0xf6)));
265 dc.Clear();
266 if (m_regions.empty()) return;
267
268 double lo_x = std::numeric_limits<double>::max(), lo_y = lo_x, hi_x = -lo_x, hi_y = -lo_x;
269 for (const auto& r : m_regions)
270 for (const auto& c : r)
271 for (const Vec2d& p : c) {
272 lo_x = std::min(lo_x, p.x()); hi_x = std::max(hi_x, p.x());
273 lo_y = std::min(lo_y, p.y()); hi_y = std::max(hi_y, p.y());
274 }
275 const wxSize sz = canvas->GetClientSize();
276 const double pad = 0.08 * std::min(sz.x, sz.y);
277 const double w = std::max(hi_x - lo_x, 1e-6), h = std::max(hi_y - lo_y, 1e-6);
278 const double k = std::min((sz.x - 2 * pad) / w, (sz.y - 2 * pad) / h);
279 const double ox = 0.5 * (sz.x - k * w), oy = 0.5 * (sz.y + k * h); // y up -> screen y down
280
281 std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
282 if (!gc) return;
283 wxGraphicsPath path = gc->CreatePath();
284 for (const auto& r : m_regions)
285 for (const auto& c : r) {
286 if (c.empty()) continue;
287 path.MoveToPoint(ox + k * (c[0].x() - lo_x), oy - k * (c[0].y() - lo_y));
288 for (size_t i = 1; i < c.size(); ++i)
289 path.AddLineToPoint(ox + k * (c[i].x() - lo_x), oy - k * (c[i].y() - lo_y));
290 path.CloseSubpath();
291 }
292 gc->SetBrush(wxBrush(wxColour(0x00, 0x96, 0x88))); // Orca accent
293 gc->SetPen(*wxTRANSPARENT_PEN);
294 gc->FillPath(path, wxODDEVEN_RULE); // holes (the counter of an "o") stay open
295}
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References draw_preview(), and m_regions.

Referenced by DesignTextDialog(), and draw_preview().

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

◆ em_unit()

int Slic3r::GUI::DPIAware< wxDialog >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxDialog >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxDialog >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

◆ height_mm()

double Slic3r::GUI::DesignTextDialog::height_mm ( ) const
private
180{
181 double h = 0.0;
182 if (parse_mm(m_height->GetTextCtrl()->GetValue(), h))
183 const_cast<DesignTextDialog*>(this)->m_last_height = h;
184 return m_last_height;
185}
DesignTextDialog(wxWindow *parent, const Spec *initial=nullptr)
Definition DesignTextDialog.cpp:64
static bool parse_mm(wxString t, double &out)
Definition DesignTextDialog.cpp:58

References DesignTextDialog(), height_mm(), m_height, m_last_height, and Slic3r::GUI::parse_mm().

Referenced by accept(), height_mm(), spec(), and update_preview().

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

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxDialog >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

◆ load_font()

void Slic3r::GUI::DesignTextDialog::load_font ( )
private
222{
223 const wxFont font = current_font();
224 m_font_file.reset();
225 if (font.IsOk() && WxFontUtils::can_load(font))
227}
std::shared_ptr< const Emboss::FontFile > m_font_file
Definition DesignTextDialog.hpp:74
static bool can_load(const wxFont &font)
Definition WxFontUtils.cpp:75
static std::unique_ptr< Slic3r::Emboss::FontFile > create_font_file(const wxFont &font)
Definition WxFontUtils.cpp:93

References Slic3r::GUI::WxFontUtils::can_load(), Slic3r::GUI::WxFontUtils::create_font_file(), current_font(), load_font(), and m_font_file.

Referenced by DesignTextDialog(), and load_font().

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

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::DesignTextDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtual

Implements Slic3r::GUI::DPIAware< wxDialog >.

298{
299 m_text->Rescale();
300 m_face->Rescale();
301 m_height->Rescale();
302 m_bold->Rescale();
303 m_italic->Rescale();
304 GetSizer()->SetSizeHints(this);
305 Refresh();
306}

References m_bold, m_face, m_height, m_italic, m_text, and on_dpi_changed().

Referenced by on_dpi_changed().

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

◆ on_sys_color_changed()

void Slic3r::GUI::DesignTextDialog::on_sys_color_changed ( )
overrideprotectedvirtual

Reimplemented from Slic3r::GUI::DPIAware< wxDialog >.

309{
310 SetBackgroundColour(*wxWHITE);
311 wxGetApp().UpdateDlgDarkUI(this);
312 m_preview->Refresh(); // its colours are read at paint time
313 Refresh();
314}

References m_preview, and on_sys_color_changed().

Referenced by on_sys_color_changed().

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

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

◆ regions()

const ImportRegions & Slic3r::GUI::DesignTextDialog::regions ( ) const
inline
41{ return m_regions; }

References m_regions.

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_prev_scale_factor ( float v)
inlineinherited

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

◆ ShowModal()

◆ spec()

DesignTextDialog::Spec Slic3r::GUI::DesignTextDialog::spec ( ) const
190{
192}

References current_font(), height_mm(), spec(), Slic3r::GUI::WxFontUtils::store_wxFont(), and text().

Referenced by spec().

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

◆ text()

wxString Slic3r::GUI::DesignTextDialog::text ( ) const
187{ return m_text->GetTextCtrl()->GetValue(); }

References m_text, and text().

Referenced by DesignTextDialog(), spec(), text(), and update_preview().

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

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

◆ update_preview()

void Slic3r::GUI::DesignTextDialog::update_preview ( )
private
230{
231 const std::string utf8(text().ToUTF8().data());
232 m_regions.clear();
233 if (m_font_file && !utf8.empty())
235
236 wxString line;
237 if (!m_font_file)
238 line = _L("This font cannot be used for text — pick another one");
239 else if (utf8.empty())
240 line = _L("Type the text to see its size");
241 else if (m_regions.empty())
242 line = _L("This font has no outline for this text");
243 else {
244 double lo_x = std::numeric_limits<double>::max(), lo_y = lo_x;
245 double hi_x = -lo_x, hi_y = -lo_x;
246 for (const auto& r : m_regions)
247 for (const auto& c : r)
248 for (const Vec2d& p : c) {
249 lo_x = std::min(lo_x, p.x()); hi_x = std::max(hi_x, p.x());
250 lo_y = std::min(lo_y, p.y()); hi_y = std::max(hi_y, p.y());
251 }
252 line = wxString::Format(_L("Size: %.1f × %.1f mm"), hi_x - lo_x, hi_y - lo_y);
253 }
254 m_size->SetLabel(line);
255 if (m_ok) m_ok->Enable(!m_regions.empty());
256 m_preview->Refresh();
257 if (on_change) on_change();
258}
std::function< void()> on_change
Definition DesignTextDialog.hpp:45
ImportRegions text_to_regions(const std::string &utf8, double size_mm, const std::string &font_path)
Definition SketchImport.cpp:71

References _L, height_mm(), m_font_file, m_ok, m_preview, m_regions, m_size, on_change, text(), Slic3r::text_to_regions(), and update_preview().

Referenced by DesignTextDialog(), and update_preview().

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

Member Data Documentation

◆ m_bold

::CheckBox* Slic3r::GUI::DesignTextDialog::m_bold {nullptr}
private
66{nullptr};

Referenced by DesignTextDialog(), current_font(), and on_dpi_changed().

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_can_rescale
privateinherited
235{ true };

◆ m_done

bool Slic3r::GUI::DesignTextDialog::m_done {false}
private
60{false}; // accept/cancel fire once

Referenced by accept(), and cancel().

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxDialog >::m_em_unit
privateinherited

◆ m_face

::ComboBox* Slic3r::GUI::DesignTextDialog::m_face {nullptr}
private
65{nullptr};

Referenced by DesignTextDialog(), current_font(), and on_dpi_changed().

◆ m_font_file

std::shared_ptr<const Emboss::FontFile> Slic3r::GUI::DesignTextDialog::m_font_file
private

Referenced by load_font(), and update_preview().

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_force_rescale
privateinherited
236{ false };

◆ m_height

::TextInput* Slic3r::GUI::DesignTextDialog::m_height {nullptr}
private
68{nullptr}; // mm; Orca's SpinInput is integer-only

Referenced by DesignTextDialog(), height_mm(), and on_dpi_changed().

◆ m_italic

::CheckBox* Slic3r::GUI::DesignTextDialog::m_italic {nullptr}
private
67{nullptr};

Referenced by DesignTextDialog(), current_font(), and on_dpi_changed().

◆ m_last_height

double Slic3r::GUI::DesignTextDialog::m_last_height {10.0}
private
69{10.0};

Referenced by DesignTextDialog(), and height_mm().

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxDialog >::m_new_font_point_size
privateinherited

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxDialog >::m_normal_font
privateinherited

◆ m_ok

wxWindow* Slic3r::GUI::DesignTextDialog::m_ok {nullptr}
private
72{nullptr};

Referenced by DesignTextDialog(), and update_preview().

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_prev_scale_factor
privateinherited

◆ m_preview

wxWindow* Slic3r::GUI::DesignTextDialog::m_preview {nullptr}
private
70{nullptr};

Referenced by DesignTextDialog(), on_sys_color_changed(), and update_preview().

◆ m_regions

ImportRegions Slic3r::GUI::DesignTextDialog::m_regions
private

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_scale_factor
privateinherited

◆ m_size

wxStaticText* Slic3r::GUI::DesignTextDialog::m_size {nullptr}
private
71{nullptr};

Referenced by DesignTextDialog(), and update_preview().

◆ m_text

::TextInput* Slic3r::GUI::DesignTextDialog::m_text {nullptr}
private
64{nullptr};

Referenced by DesignTextDialog(), on_dpi_changed(), and text().

◆ on_accept

std::function<void()> Slic3r::GUI::DesignTextDialog::on_accept

Referenced by accept().

◆ on_cancel

std::function<void()> Slic3r::GUI::DesignTextDialog::on_cancel

Referenced by cancel().

◆ on_change

std::function<void()> Slic3r::GUI::DesignTextDialog::on_change

Referenced by update_preview().


The documentation for this class was generated from the following files: