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

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

Inheritance diagram for Slic3r::GUI::ExportPresetBundleDialog:
Collaboration diagram for Slic3r::GUI::ExportPresetBundleDialog:

Public Member Functions

 ExportPresetBundleDialog (wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT(""), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX)
 ~ExportPresetBundleDialog ()
bool seq_top_layer_only_changed () const
bool recreate_GUI () const
void show_export_result (const ExportCase &e)
void Init ()
void InitExportData ()
void on_script_message (const nlohmann::json &payload) override
nlohmann::json localized_strings () const override
void OnRequestPresets ()
void OnExportData (const wxString &path, const wxString &name, nlohmann::json data)
bool create_webview (const std::string &resource_path, const wxString &title, const wxSize &dialog_size=wxSize(820, 660), const wxSize &min_size=wxSize(640, 640))
void load_url (const wxString &url)
bool run_script (const wxString &script)
void call_web_handler (const nlohmann::json &payload, const wxString &handler=wxT("HandleStudio"))
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 ()

Static Public Member Functions

static std::string document_start_injector (const std::string &markup, const char *dom_id, const char *position, const std::string &prelude={}, const std::string &on_inject={})
static std::string theme_user_script ()
static std::string element_defaults_user_script ()
static std::string theme_apply_script ()
static std::string localized_strings_script (const nlohmann::json &strings)

Protected Member Functions

wxWebView * browser () const
wxString build_resource_url (const std::string &resource_path) const
bool handle_common_script_command (const nlohmann::json &payload, int close_return_code=wxID_CANCEL)
void on_dpi_changed (const wxRect &suggested_rect) override
virtual void on_script_message_parse_error (const wxString &payload, const std::exception &error)
virtual bool append_language_to_url () const
void register_theme_user_scripts ()
virtual void add_user_scripts ()
void apply_theme_live ()
virtual void on_sys_color_changed ()

Protected Attributes

bool m_seq_top_layer_only_changed {false}
bool m_recreate_GUI {false}
std::unordered_map< std::string, Preset * > m_printer_presets
std::unordered_map< std::string, std::vector< const Preset * > > m_filament_presets
std::unordered_map< std::string, std::vector< const Preset * > > m_process_presets
std::unordered_map< std::string, std::vector< std::pair< std::string, Preset * > > > m_filament_name_to_presets

Private Member Functions

void on_script_message_event (wxWebViewEvent &event)
void on_webview_recreated (wxCommandEvent &event)
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

wxWebView * m_browser {nullptr}
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

Constructor & Destructor Documentation

◆ ExportPresetBundleDialog()

Slic3r::GUI::ExportPresetBundleDialog::ExportPresetBundleDialog ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxString & title = wxT(""),
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxMAXIMIZE_BOX )
44 : WebViewHostDialog(parent, id, _L("ExportPresetBundle"), pos, size, style)
45{
46 Init();
47 wxGetApp().UpdateDlgDarkUI(this);
48}
#define _L(s)
Definition OBJ.cpp:34
#define style
Definition WipeTowerDialog.cpp:101
void Init()
Definition ExportPresetBundleDialog.cpp:61
WebViewHostDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT(""), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER)
Definition WebViewHostDialog.cpp:161

References Slic3r::GUI::WebViewHostDialog::WebViewHostDialog(), _L, Init(), and style.

Here is the call graph for this function:

◆ ~ExportPresetBundleDialog()

Slic3r::GUI::ExportPresetBundleDialog::~ExportPresetBundleDialog ( )
51{
52 for (std::pair<std::string, Preset*> printer_preset : m_printer_presets) {
53 Preset* preset = printer_preset.second;
54 if (preset) {
55 delete preset;
56 preset = nullptr;
57 }
58 }
59}
std::unordered_map< std::string, Preset * > m_printer_presets
Definition ExportPresetBundleDialog.hpp:79
@ Preset
Definition calib.hpp:39

References m_printer_presets.

Member Function Documentation

◆ add_user_scripts()

virtual void Slic3r::GUI::WebViewHostDialog::add_user_scripts ( )
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::ColorPickerDialog, and Slic3r::GUI::WebDialog.

95{}

Referenced by register_theme_user_scripts().

Here is the caller graph for this function:

◆ append_language_to_url()

virtual bool Slic3r::GUI::WebViewHostDialog::append_language_to_url ( ) const
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::WebDialog.

84{ return true; }

Referenced by build_resource_url().

Here is the caller graph for this function:

◆ apply_theme_live()

void Slic3r::GUI::WebViewHostDialog::apply_theme_live ( )
protectedinherited
300{
301 if (!m_browser)
302 return;
303 // Update the already-loaded document in place (no reload, no flash) by rewriting the
304 // injected :root variables + data-orca-theme; the whole cascade re-flows from these.
305 // The document-start script keeps the creation-time theme for any later reload, and
306 // these dialogs are not reloaded on a theme toggle (see WebView::RecreateAll).
307 run_script(wxString::FromUTF8(host_theme_apply_js()));
308}
bool run_script(const wxString &script)
Definition WebViewHostDialog.cpp:234
wxWebView * m_browser
Definition WebViewHostDialog.hpp:109
std::string host_theme_apply_js()
Definition WebViewHostDialog.cpp:73

References m_browser, and run_script().

Referenced by on_webview_recreated().

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

◆ browser()

◆ build_resource_url()

wxString Slic3r::GUI::WebViewHostDialog::build_resource_url ( const std::string & resource_path) const
protectedinherited
210{
211 wxString target_url = file_url_from_path(boost::filesystem::path(resources_dir()) / resource_path);
212
214 const wxString lang = wxGetApp().current_language_code_safe();
215 if (!lang.empty()) {
216 target_url += wxT("?lang=");
217 target_url += lang;
218 }
219 }
220
221 return target_url;
222}
virtual bool append_language_to_url() const
Definition WebViewHostDialog.hpp:84
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
const std::string & resources_dir()
Definition utils.cpp:296

References append_language_to_url(), Slic3r::GUI::file_url_from_path(), and Slic3r::resources_dir().

Referenced by create_webview().

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

◆ call_web_handler()

void Slic3r::GUI::WebViewHostDialog::call_web_handler ( const nlohmann::json & payload,
const wxString & handler = wxT("HandleStudio") )
inherited
243{
244 const wxString payload_text = wxString::FromUTF8(payload.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore));
245 const wxString script = handler + wxT("(") + payload_text + wxT(")");
246
247 wxGetApp().CallAfter([this, script] { run_script(script); });
248}

References run_script().

Referenced by Slic3r::GUI::SpeedDialWebDialog::handle_web_command(), Slic3r::GUI::PresetBundleDialog::ListBundles(), Slic3r::GUI::ExportPresetBundleDialog::OnRequestPresets(), Slic3r::GUI::WebDialog::push_message(), Slic3r::GUI::TerminalDialog::resolve_and_run(), Slic3r::GUI::PluginsDialog::restore_capability_config(), Slic3r::GUI::PluginsDialog::save_capability_config(), Slic3r::GUI::SpeedDialWebDialog::search_tabs(), Slic3r::GUI::SpeedDialWebDialog::send_actions(), Slic3r::GUI::PluginsConfigDialog::send_capabilities(), Slic3r::GUI::PluginsConfigDialog::send_capability_config(), Slic3r::GUI::PluginsDialog::send_capability_config(), Slic3r::GUI::PluginsDialog::send_plugins(), Slic3r::GUI::PluginsConfigDialog::send_save_error(), Slic3r::GUI::PluginsConfigDialog::show_status(), and Slic3r::GUI::PluginsDialog::show_status().

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

◆ create_webview()

bool Slic3r::GUI::WebViewHostDialog::create_webview ( const std::string & resource_path,
const wxString & title,
const wxSize & dialog_size = wxSize(820, 660),
const wxSize & min_size = wxSize(640, 640) )
inherited
176{
177 SetTitle(title);
178 SetMinSize(FromDIP(min_size));
179
180 const wxString target_url = build_resource_url(resource_path);
181 wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
182
183 // Created empty and loaded below, after the user scripts are added, so the first load already has them.
184 m_browser = WebView::CreateWebView(this, wxEmptyString);
185 if (m_browser == nullptr) {
186 wxLogError("Could not init m_browser");
187 delete topsizer;
188 return false;
189 }
190
191 SetSizer(topsizer);
192 topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
193
194 SetSize(FromDIP(dialog_size));
195 CenterOnParent();
196
197 Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewHostDialog::on_script_message_event, this, m_browser->GetId());
198
199 // Inject the shared host theme contract BEFORE the first load so the page paints in
200 // the app theme with no flash, and re-theme live when the app theme toggles.
202 m_browser->Bind(EVT_WEBVIEW_RECREATED, &WebViewHostDialog::on_webview_recreated, this);
203
204 load_url(target_url);
205 wxGetApp().UpdateDlgDarkUI(this);
206 return true;
207}
void on_webview_recreated(wxCommandEvent &event)
Definition WebViewHostDialog.cpp:310
wxString build_resource_url(const std::string &resource_path) const
Definition WebViewHostDialog.cpp:209
void register_theme_user_scripts()
Definition WebViewHostDialog.cpp:285
void on_script_message_event(wxWebViewEvent &event)
Definition WebViewHostDialog.cpp:274
void load_url(const wxString &url)
Definition WebViewHostDialog.cpp:224
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313

References build_resource_url(), WebView::CreateWebView(), load_url(), m_browser, on_script_message_event(), on_webview_recreated(), and register_theme_user_scripts().

Referenced by Slic3r::GUI::ColorPickerDialog::ColorPickerDialog(), Slic3r::GUI::PluginsConfigDialog::PluginsConfigDialog(), Slic3r::GUI::PluginsDialog::PluginsDialog(), Slic3r::GUI::SpeedDialWebDialog::SpeedDialWebDialog(), Slic3r::GUI::TerminalDialog::TerminalDialog(), Slic3r::GUI::WebDialog::WebDialog(), Slic3r::GUI::PresetBundleDialog::create(), and Slic3r::GUI::ExportPresetBundleDialog::Init().

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

◆ document_start_injector()

std::string Slic3r::GUI::WebViewHostDialog::document_start_injector ( const std::string & markup,
const char * dom_id,
const char * position,
const std::string & prelude = {},
const std::string & on_inject = {} )
staticinherited
135{
136 const std::string literal = nlohmann::json(markup).dump();
137 std::string s;
138 s += "(function(){";
139 // wxWebView's AddUserScript runs in child frames too (including cross-origin
140 // frames on WebView2). Host theme state belongs only to the top-level page.
141 s += "if(window.top!==window.self)return;";
142 s += prelude;
143 s += "var css=" + literal + ";";
144 s += "function inject(){";
145 s += "var root=document.head||document.documentElement;if(!root)return false;";
146 s += "if(!document.getElementById('" + std::string(dom_id) + "'))root.insertAdjacentHTML('" +
147 std::string(position) + "',css);";
148 s += on_inject;
149 s += "return true;}";
150 s += "if(inject())return;";
151 s += "var obs=new MutationObserver(function(){if(inject())obs.disconnect();});";
152 s += "obs.observe(document,{childList:true});})();";
153 return s;
154}

Referenced by element_defaults_user_script(), and theme_user_script().

Here is the caller graph for this function:

◆ element_defaults_user_script()

std::string Slic3r::GUI::WebViewHostDialog::element_defaults_user_script ( )
staticinherited
103{
104 std::string css;
105 css += "<style id=\"orca-plugin-defaults\">";
106 css += "html,body{background:var(--orca-bg);color:var(--orca-fg);"
107 "font-family:var(--orca-font);font-size:13px;}";
108 css += "body{margin:0;}";
109 css += "h1,h2,h3,h4,h5,h6{color:var(--orca-fg);font-weight:600;}";
110 css += "a{color:var(--orca-accent);}";
111 css += "hr{border:0;border-top:1px solid var(--orca-border);}";
112 css += "button{font:inherit;color:var(--orca-accent-fg);background:var(--orca-accent);"
113 "border:1px solid var(--orca-accent);border-radius:4px;padding:5px 14px;cursor:pointer;}";
114 css += "button:hover{filter:brightness(1.1);}";
115 css += "button:disabled{opacity:.5;cursor:default;}";
116 css += "input,select,textarea{font:inherit;color:var(--orca-fg);"
117 "background:var(--orca-bg);border:1px solid var(--orca-border);"
118 "border-radius:4px;padding:4px 8px;}";
119 css += "input:focus,select:focus,textarea:focus{outline:none;border-color:var(--orca-accent);}";
120 css += "table{border-collapse:collapse;}";
121 css += "th,td{text-align:left;padding:6px 10px;border-bottom:1px solid var(--orca-border);}";
122 css += "th{color:var(--orca-muted);font-weight:600;}";
123 css += "::-webkit-scrollbar{width:12px;height:12px;}";
124 css += "::-webkit-scrollbar-thumb{background:var(--orca-border);border-radius:6px;}";
125 css += "::-webkit-scrollbar-track{background:transparent;}";
126 css += "</style>";
127 return document_start_injector(css, "orca-plugin-defaults", "beforeend");
128}
static std::string document_start_injector(const std::string &markup, const char *dom_id, const char *position, const std::string &prelude={}, const std::string &on_inject={})
Definition WebViewHostDialog.cpp:130

References document_start_injector().

Referenced by Slic3r::GUI::WebPanel::WebPanel(), and Slic3r::GUI::WebDialog::add_user_scripts().

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; }

◆ handle_common_script_command()

bool Slic3r::GUI::WebViewHostDialog::handle_common_script_command ( const nlohmann::json & payload,
int close_return_code = wxID_CANCEL )
protectedinherited
251{
252 const std::string command = payload.value("command", "");
253 if (command == "close_page") {
254 if (IsModal())
255 EndModal(close_return_code);
256 else
257 Close();
258 return true;
259 }
260
261 return false;
262}
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305

References Slic3r::GUI::DPIDialog::EndModal().

Referenced by Slic3r::GUI::ExportPresetBundleDialog::on_script_message(), Slic3r::GUI::PluginsConfigDialog::on_script_message(), Slic3r::GUI::PluginsDialog::on_script_message(), Slic3r::GUI::PresetBundleDialog::on_script_message(), Slic3r::GUI::SpeedDialWebDialog::on_script_message(), Slic3r::GUI::TerminalDialog::on_script_message(), and Slic3r::GUI::WebDialog::on_script_message().

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

◆ Init()

void Slic3r::GUI::ExportPresetBundleDialog::Init ( )
62{
63 create_webview("web/dialog/ExportPresetDialog/index.html", _L("Export Preset Bundle"),
64 wxSize(820, 660), wxSize(640, 640));
65}
bool create_webview(const std::string &resource_path, const wxString &title, const wxSize &dialog_size=wxSize(820, 660), const wxSize &min_size=wxSize(640, 640))
Definition WebViewHostDialog.cpp:172

References _L, and Slic3r::GUI::WebViewHostDialog::create_webview().

Referenced by ExportPresetBundleDialog().

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

◆ InitExportData()

void Slic3r::GUI::ExportPresetBundleDialog::InitExportData ( )
169{
170 // Delete the Temp folder
171 boost::filesystem::path folder(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp");
172 if (boost::filesystem::exists(folder))
173 boost::filesystem::remove_all(folder);
174
175 boost::system::error_code ec;
176 boost::filesystem::path user_folder(data_dir() + "/" + PRESET_USER_DIR);
177 bool temp_folder_exist = true;
178 if (!boost::filesystem::exists(user_folder)) {
179 if (!boost::filesystem::create_directories(user_folder, ec)) {
180 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << user_folder << " " << ec.message();
181 temp_folder_exist = false;
182 }
183 }
184 boost::filesystem::path temp_folder(user_folder / "Temp");
185 if (!boost::filesystem::exists(temp_folder)) {
186 if (!boost::filesystem::create_directories(temp_folder, ec)) {
187 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << temp_folder << " " << ec.message();
188 temp_folder_exist = false;
189 }
190 }
191 if (!temp_folder_exist) {
192 MessageDialog dlg(this, _L("Failed to create temporary folder, please try Export Configs again."),
193 wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
194 dlg.ShowModal();
195 EndModal(wxCANCEL);
196 }
197
198 PresetBundle preset_bundle(*wxGetApp().preset_bundle);
199
200 const std::deque<Preset>& printer_presets = preset_bundle.printers.get_presets();
201 // for all the printers
202 for (const Preset& printer_preset : printer_presets) {
203 std::string preset_name = printer_preset.name;
204 if (!printer_preset.is_visible || printer_preset.is_default || printer_preset.is_project_embedded)
205 continue;
206 if (preset_bundle.printers.select_preset_by_name(preset_name, true)) {
207 preset_bundle.update_compatible(PresetSelectCompatibleType::Always);
208
209 const std::deque<Preset>& filament_presets = preset_bundle.filaments.get_presets();
210 for (const Preset& filament_preset : filament_presets) {
211 if (!filament_preset.is_user())
212 continue;
213 if (filament_preset.is_compatible) {
214 Preset* new_filament_preset = new Preset(filament_preset);
215 m_filament_presets[preset_name].push_back(new_filament_preset);
216 }
217 }
218
219 const std::deque<Preset>& process_presets = preset_bundle.prints.get_presets();
220 for (const Preset& process_preset : process_presets) {
221 if (!process_preset.is_user())
222 continue;
223 if (process_preset.is_compatible) {
224 Preset* new_prpcess_preset = new Preset(process_preset);
225 m_process_presets[preset_name].push_back(new_prpcess_preset);
226 }
227 }
228 // make new and erase sensitive information
229 Preset* new_printer_preset = new Preset(printer_preset);
230 if (new_printer_preset->type == Preset::Type::TYPE_PRINTER) {
231 boost::filesystem::path file_path(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp" + "/" +
232 (new_printer_preset->name + ".json"));
233 new_printer_preset->file = file_path.make_preferred().string();
234
235 DynamicPrintConfig& config = new_printer_preset->config;
236 config.erase("print_host");
237 config.erase("print_host_webui");
238 config.erase("printhost_apikey");
239 config.erase("printhost_cafile");
240 config.erase("printhost_user");
241 config.erase("printhost_password");
242 config.erase("printhost_port");
243
244 new_printer_preset->save(nullptr);
245 }
246 m_printer_presets[preset_name] = new_printer_preset;
247 }
248 }
249 const std::deque<Preset>& filament_presets = preset_bundle.filaments.get_presets();
250 for (const Preset& filament_preset : filament_presets) {
251 if (!filament_preset.can_overwrite())
252 continue;
253 Preset* new_filament_preset = new Preset(filament_preset);
254 const Preset* base_filament_preset = preset_bundle.filaments.get_preset_base(*new_filament_preset);
255
256 if (base_filament_preset == nullptr) {
257 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " Failed to find base preset";
258 continue;
259 }
260 std::string filament_preset_name = base_filament_preset->name;
261 std::string machine_name = get_machine_name(filament_preset_name);
262 m_filament_name_to_presets[get_filament_name(filament_preset_name)].push_back(
263 std::make_pair(get_vendor_name(machine_name), new_filament_preset));
264 }
265}
#define PRESET_USER_DIR
Definition Preset.hpp:32
std::unordered_map< std::string, std::vector< const Preset * > > m_filament_presets
Definition ExportPresetBundleDialog.hpp:81
std::unordered_map< std::string, std::vector< const Preset * > > m_process_presets
Definition ExportPresetBundleDialog.hpp:83
std::unordered_map< std::string, std::vector< std::pair< std::string, Preset * > > > m_filament_name_to_presets
Definition ExportPresetBundleDialog.hpp:85
const std::deque< Preset > & get_presets() const
Definition Preset.hpp:781
@ TYPE_PRINTER
Definition Preset.hpp:250
#define SLIC3R_APP_FULL_NAME
Definition libslic3r.h:11
static std::string get_machine_name(const std::string &preset_name)
Definition CreatePresetsDialog.cpp:417
static std::string get_filament_name(std::string &preset_name)
Definition CreatePresetsDialog.cpp:427
static std::string get_vendor_name(std::string &preset_name)
Definition CreatePresetsDialog.cpp:461
PresetCollection & printer_presets(PresetBundle &bundle)
Definition PluginHostPresets.cpp:50
const std::string & data_dir()
Definition utils.cpp:365
@ Always
Definition Preset.hpp:527

References _L, Slic3r::Always, Slic3r::Preset::config, Slic3r::data_dir(), Slic3r::GUI::DPIDialog::EndModal(), Slic3r::DynamicConfig::erase(), Slic3r::PresetBundle::filaments, Slic3r::Preset::file, Slic3r::GUI::get_filament_name(), Slic3r::GUI::get_machine_name(), Slic3r::PresetCollection::get_preset_base(), Slic3r::PresetCollection::get_presets(), Slic3r::GUI::get_vendor_name(), m_filament_name_to_presets, m_filament_presets, m_printer_presets, m_process_presets, Slic3r::Preset::name, Slic3r::Preset, PRESET_USER_DIR, Slic3r::PresetBundle::printers, Slic3r::PresetBundle::prints, Slic3r::Preset::save(), Slic3r::PresetCollection::select_preset_by_name(), Slic3r::GUI::DPIAware< P >::ShowModal(), SLIC3R_APP_FULL_NAME, Slic3r::Preset::type, Slic3r::Preset::TYPE_PRINTER, and Slic3r::PresetBundle::update_compatible().

Referenced by on_script_message().

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_url()

void Slic3r::GUI::WebViewHostDialog::load_url ( const wxString & url)
inherited
225{
226 if (!m_browser)
227 return;
228
229 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << " enter, url=" << into_u8(url);
231 m_browser->SetFocus();
232}
static void LoadUrl(wxWebView *webView, wxString const &url)
Definition WebView.cpp:480
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
void trace(unsigned int level, const char *message)
Definition utils.cpp:247

References Slic3r::GUI::into_u8(), WebView::LoadUrl(), m_browser, and Slic3r::trace().

Referenced by create_webview().

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

◆ localized_strings()

nlohmann::json Slic3r::GUI::ExportPresetBundleDialog::localized_strings ( ) const
overridevirtual

Reimplemented from Slic3r::GUI::WebViewHostDialog.

68{
69 return {
70 {"printer", _u8L("Printer")},
71 {"filament", _u8L("Filament")},
72 {"process", _u8L("Process")},
73 {"all", _u8L("All")},
74 {"no_items", _u8L("No items")},
75 {"export_cloud", _u8L("Export to OrcaCloud")},
76 {"export_folder", _u8L("Export to folder")},
77 {"close", _u8L("Close")},
78 };
79}
#define _u8L(s)
Definition I18N.hpp:11

References _u8L.

◆ localized_strings_script()

std::string Slic3r::GUI::WebViewHostDialog::localized_strings_script ( const nlohmann::json & strings)
staticinherited
157{
158 return "window.ORCA_UI_STRINGS = " + strings.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore) + ";";
159}

Referenced by Slic3r::GUI::GuideFrame::GuideFrame(), WipingDialog::WipingDialog(), Slic3r::GUI::add_page_strings(), Slic3r::GUI::ProjectPanel::create_browser(), Slic3r::GUI::WebViewPanel::create_browser(), and register_theme_user_scripts().

Here is the caller graph for this function:

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::WebViewHostDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtualinherited

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

265{
266 Refresh();
267}

◆ on_script_message()

void Slic3r::GUI::ExportPresetBundleDialog::on_script_message ( const nlohmann::json & payload)
overridevirtual

Implements Slic3r::GUI::WebViewHostDialog.

82{
84 return;
85
86 const std::string strCmd = j.value("command", "");
87 if (strCmd == "request_export_preset_profile") {
90 } else if (strCmd == "export_local") {
91 wxFileDialog dlg(this, _L("Save preset bundle"), "", "export.orca_bundle",
92 _L("Orca Preset Bundle (*.orca_bundle)|*.orca_bundle"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
93 wxString path;
94 wxString name;
95 if (dlg.ShowModal() == wxID_OK) {
96 path = dlg.GetPath();
97 wxFileName file_name(path);
98 name = file_name.GetName();
99 if (file_name.GetExt().empty()) {
100 file_name.SetExt("orca_bundle");
101 path = file_name.GetFullPath();
102 }
103 }
104 OnExportData(path, name, j.value("data", json()));
105 }
106}
void OnExportData(const wxString &path, const wxString &name, nlohmann::json data)
Definition ExportPresetBundleDialog.cpp:310
void OnRequestPresets()
Definition ExportPresetBundleDialog.cpp:267
void InitExportData()
Definition ExportPresetBundleDialog.cpp:168
bool handle_common_script_command(const nlohmann::json &payload, int close_return_code=wxID_CANCEL)
Definition WebViewHostDialog.cpp:250
nlohmann::json json
Definition AssembleList.cpp:42

References _L, Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), InitExportData(), OnExportData(), and OnRequestPresets().

Here is the call graph for this function:

◆ on_script_message_event()

void Slic3r::GUI::WebViewHostDialog::on_script_message_event ( wxWebViewEvent & event)
privateinherited
275{
276 const wxString payload = event.GetString();
277
278 try {
279 on_script_message(nlohmann::json::parse(payload.utf8_string()));
280 } catch (const std::exception& e) {
282 }
283}
virtual void on_script_message_parse_error(const wxString &payload, const std::exception &error)
Definition WebViewHostDialog.cpp:269
virtual void on_script_message(const nlohmann::json &payload)=0

References on_script_message(), and on_script_message_parse_error().

Referenced by create_webview().

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

◆ on_script_message_parse_error()

void Slic3r::GUI::WebViewHostDialog::on_script_message_parse_error ( const wxString & payload,
const std::exception & error )
protectedvirtualinherited
270{
271 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << "; payload=" << into_u8(payload) << "; error=" << error.what();
272}

References Slic3r::GUI::into_u8(), and Slic3r::trace().

Referenced by on_script_message_event().

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

◆ on_sys_color_changed()

◆ on_webview_recreated()

void Slic3r::GUI::WebViewHostDialog::on_webview_recreated ( wxCommandEvent & event)
privateinherited
311{
312 // Handled: do NOT Skip(), so WebView::RecreateAll skips the redundant reload.
314}
void apply_theme_live()
Definition WebViewHostDialog.cpp:299

References apply_theme_live().

Referenced by create_webview().

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

◆ OnExportData()

void Slic3r::GUI::ExportPresetBundleDialog::OnExportData ( const wxString & path,
const wxString & name,
nlohmann::json data )
311{
312 auto get_names = [&](const char* key) {
313 std::vector<std::string> out;
314 auto it = data.find(key);
315 if (it == data.end() || !it->is_array())
316 return out;
317 for (const auto& v : *it) {
318 if (v.is_string())
319 out.push_back(v.get<std::string>());
320 }
321 return out;
322 };
323
324 // JS BuildResultPayload uses: machines / filaments / presets
325 const auto machine_names = get_names("machines");
326 const auto filament_names = get_names("filaments");
327 const auto process_names = get_names("presets"); // or "process" if your JS sends that
328
329 std::vector<Preset*> selected_printers;
330 for (const auto& name : machine_names) {
331 auto it = m_printer_presets.find(name);
332 if (it != m_printer_presets.end() && it->second)
333 selected_printers.push_back(it->second);
334 }
335
336 std::vector<Preset*> selected_filaments;
337 for (const auto& name : filament_names) {
338 auto it = m_filament_name_to_presets.find(name); // name -> vector<pair<vendor, Preset*>>
339 if (it == m_filament_name_to_presets.end())
340 continue;
341 for (const auto& vp : it->second) {
342 if (vp.second)
343 selected_filaments.push_back(vp.second);
344 }
345 }
346
347 std::vector<Preset*> selected_processes;
348 for (const auto& name : process_names) {
349 if (Preset* p = wxGetApp().preset_bundle->prints.find_preset(name, false))
350 selected_processes.push_back(p);
351 }
352
353 std::string export_path = into_u8(path);
354 if (export_path.empty() || "initial_failed" == export_path)
355 return;
356
357 boost::filesystem::path export_file_path = boost::filesystem::path(export_path).make_preferred();
358 if (export_file_path.extension().empty())
359 export_file_path += ".orca_bundle";
360
361 const boost::filesystem::path export_dir = export_file_path.parent_path();
362 if (!export_dir.empty() && !boost::filesystem::exists(export_dir)) {
363 boost::system::error_code ec;
364 if (!boost::filesystem::create_directories(export_dir, ec)) {
365 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << export_dir << " " << ec.message();
366 return;
367 }
368 }
369
370 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " export file path: " << export_file_path.string();
371
372 BOOST_LOG_TRIVIAL(info) << "Export printer preset bundle";
373
374 json bundle_structure;
375 NetworkAgent* agent = wxGetApp().getAgent();
376 std::string clock = get_curr_time();
377 if (agent) {
378 bundle_structure["version"] = agent->get_version();
379 bundle_structure["bundle_id"] = agent->get_user_id() + "_" + std::string(filename.utf8_string()) + "_" + clock;
380 } else {
381 bundle_structure["version"] = "";
382 std::string id;
383 bundle_structure["bundle_id"] = id + "offline_" + "_" + clock;
384 }
385 bundle_structure["bundle_type"] = "printer config bundle";
386 bundle_structure["printer_preset_name"] = "export";
387 json printer_config = json::array();
388 json filament_configs = json::array();
389 json process_configs = json::array();
390 mz_zip_archive zip_archive;
391 mz_bool status = initial_zip_archive(zip_archive, export_file_path.string());
392 if (MZ_FALSE == status) {
393 BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
395 }
396 for (auto& printer : selected_printers) {
397 boost::filesystem::path printer_file_path = boost::filesystem::path(printer->file);
398 std::string preset_path = printer_file_path.make_preferred().string();
399 if (preset_path.empty()) {
400 BOOST_LOG_TRIVIAL(info) << "Export printer preset: " << printer->name << " skip because of the preset file path is empty.";
401 continue;
402 }
403
404 // Add a file to the ZIP file
405 std::string printer_config_file_name = "printer/" + printer_file_path.filename().string();
406 status = mz_zip_writer_add_file(&zip_archive, printer_config_file_name.c_str(), encode_path(preset_path.c_str()).c_str(), NULL, 0,
407 MZ_DEFAULT_COMPRESSION);
408 if (MZ_FALSE == status) {
409 BOOST_LOG_TRIVIAL(info) << printer->name << " Failed to add file to ZIP archive";
410 mz_zip_writer_end(&zip_archive);
412 return;
413 }
414 printer_config.push_back(printer_config_file_name);
415 BOOST_LOG_TRIVIAL(info) << "Printer preset json add successful: " << printer->name;
416 }
417 for (auto& filament : selected_filaments) {
418 boost::filesystem::path filament_file_path = boost::filesystem::path(filament->file);
419 std::string filament_preset_path = filament_file_path.make_preferred().string();
420 if (filament_preset_path.empty()) {
421 BOOST_LOG_TRIVIAL(info) << "Export filament preset: " << filament->name << " skip because of the preset file path is empty.";
422 continue;
423 }
424 std::string filament_config_file_name = "filament/" + filament_file_path.filename().string();
425 status = mz_zip_writer_add_file(&zip_archive, filament_config_file_name.c_str(), encode_path(filament_preset_path.c_str()).c_str(),
426 NULL, 0, MZ_DEFAULT_COMPRESSION);
427 if (MZ_FALSE == status) {
428 BOOST_LOG_TRIVIAL(info) << filament->name << " Failed to add file to ZIP archive";
429 mz_zip_writer_end(&zip_archive);
431 return;
432 }
433 filament_configs.push_back(filament_config_file_name);
434 BOOST_LOG_TRIVIAL(info) << "Filament preset json add successful.";
435 }
436
437 for (auto& process : selected_processes) {
438 boost::filesystem::path process_file_path = boost::filesystem::path(process->file);
439 std::string process_preset_path = process_file_path.make_preferred().string();
440 if (process_preset_path.empty()) {
441 BOOST_LOG_TRIVIAL(info) << "Export process preset: " << process->name << " skip because of the preset file path is empty.";
442 continue;
443 }
444
445 std::string process_config_file_name = "process/" + process_file_path.filename().string();
446 status = mz_zip_writer_add_file(&zip_archive, process_config_file_name.c_str(), encode_path(process_preset_path.c_str()).c_str(),
447 NULL, 0, MZ_DEFAULT_COMPRESSION);
448 if (MZ_FALSE == status) {
449 BOOST_LOG_TRIVIAL(info) << process->name << " Failed to add file to ZIP archive";
450 mz_zip_writer_end(&zip_archive);
452 return;
453 }
454 process_configs.push_back(process_config_file_name);
455 BOOST_LOG_TRIVIAL(info) << "Process preset json add successful: ";
456 }
457
458 bundle_structure["printer_config"] = printer_config;
459 bundle_structure["filament_config"] = filament_configs;
460 bundle_structure["process_config"] = process_configs;
461
462 std::string bundle_structure_str = bundle_structure.dump();
463 status = mz_zip_writer_add_mem(&zip_archive, BUNDLE_STRUCTURE_JSON_NAME, bundle_structure_str.data(), bundle_structure_str.size(),
464 MZ_DEFAULT_COMPRESSION);
465 if (MZ_FALSE == status) {
466 BOOST_LOG_TRIVIAL(info) << " Failed to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
467 mz_zip_writer_end(&zip_archive);
469 return;
470 }
471 BOOST_LOG_TRIVIAL(info) << " Success to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
472
473 // Complete writing of ZIP file
474 mz_bool s = mz_zip_writer_finalize_archive(&zip_archive);
475 if (MZ_FALSE == s) {
476 BOOST_LOG_TRIVIAL(info) << "Failed to finalize ZIP archive";
477 mz_zip_writer_end(&zip_archive);
479 return;
480 }
481
482 // Release ZIP file to write structure and related resources
483 mz_zip_writer_end(&zip_archive);
484 // if (ExportCase::CASE_COUNT != save_result) return save_result;
485 BOOST_LOG_TRIVIAL(info) << "ZIP archive created successfully";
486}
#define BUNDLE_STRUCTURE_JSON_NAME
Definition PresetBundle.hpp:32
void show_export_result(const ExportCase &e)
Definition ExportPresetBundleDialog.cpp:488
static mz_bool initial_zip_archive(mz_zip_archive &zip_archive, const std::string &file_path)
Definition ExportPresetBundleDialog.cpp:156
static DynamicPrintConfig & printer_config()
Definition GUI_ObjectList.cpp:131
@ ADD_FILE_FAIL
Definition ExportPresetBundleDialog.hpp:40
@ INITIALIZE_FAIL
Definition ExportPresetBundleDialog.hpp:39
@ FINALIZE_FAIL
Definition ExportPresetBundleDialog.hpp:42
@ ADD_BUNDLE_STRUCTURE_FAIL
Definition ExportPresetBundleDialog.hpp:41
static std::string get_curr_time(const char *format="%Y_%m_%d_%H_%M_%S")
Definition CreatePresetsDialog.cpp:327
std::string encode_path(const char *src)
Definition utils.cpp:1382
bool process(std::exception_ptr &eptr)
Definition EmbossJob.cpp:1427

References Slic3r::GUI::ADD_BUNDLE_STRUCTURE_FAIL, Slic3r::GUI::ADD_FILE_FAIL, BUNDLE_STRUCTURE_JSON_NAME, Slic3r::encode_path(), Slic3r::GUI::FINALIZE_FAIL, Slic3r::GUI::get_curr_time(), Slic3r::NetworkAgent::get_user_id(), Slic3r::NetworkAgent::get_version(), Slic3r::GUI::initial_zip_archive(), Slic3r::GUI::INITIALIZE_FAIL, Slic3r::GUI::into_u8(), m_filament_name_to_presets, m_printer_presets, Slic3r::GUI::printer_config(), and show_export_result().

Referenced by on_script_message().

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

◆ OnRequestPresets()

void Slic3r::GUI::ExportPresetBundleDialog::OnRequestPresets ( )
268{
269 PresetBundle* preset_bundle = wxGetApp().preset_bundle;
270 json res;
271 res["command"] = "response_export_preset_profile";
272 res["sequence_id"] = "2000";
273 res["data"] = json::object();
274
275 res["data"]["printers"] = json::array();
276 res["data"]["filaments"] = json::array();
277 res["data"]["process"] = json::array();
278
279 for (std::pair<std::string, Preset*> preset : m_printer_presets) {
280 if (preset.second->is_system)
281 continue;
282 res["data"]["printers"].push_back(preset.first);
283 }
284
285 for (std::pair<std::string, std::vector<std::pair<std::string, Preset*>>> filament_name_to_preset : m_filament_name_to_presets) {
286 if (filament_name_to_preset.second.empty())
287 continue;
288 res["data"]["filaments"].push_back(filament_name_to_preset.first);
289 }
290
291 for (std::pair<std::string, std::vector<const Preset*>> presets : m_process_presets) {
292 Preset* printer_preset = preset_bundle->printers.find_preset(presets.first, false);
293 if (!printer_preset)
294 continue;
295 if (!printer_preset->is_system)
296 continue;
297 if (preset_bundle->printers.get_preset_base(*printer_preset) != printer_preset)
298 continue;
299 for (const Preset* preset : presets.second) {
300 if (!preset->is_system) {
301 res["data"]["process"].push_back(preset->name);
302 break;
303 }
304 }
305 }
306
307 call_web_handler(res);
308}
void call_web_handler(const nlohmann::json &payload, const wxString &handler=wxT("HandleStudio"))
Definition WebViewHostDialog.cpp:242

References Slic3r::GUI::WebViewHostDialog::call_web_handler(), Slic3r::PresetCollection::find_preset(), Slic3r::PresetCollection::get_preset_base(), Slic3r::Preset::is_system, m_filament_name_to_presets, m_printer_presets, m_process_presets, Slic3r::Preset::name, and Slic3r::PresetBundle::printers.

Referenced by on_script_message().

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; }

◆ recreate_GUI()

bool Slic3r::GUI::ExportPresetBundleDialog::recreate_GUI ( ) const
inline
63{ return m_recreate_GUI; }
bool m_recreate_GUI
Definition ExportPresetBundleDialog.hpp:76

References m_recreate_GUI.

◆ register_theme_user_scripts()

void Slic3r::GUI::WebViewHostDialog::register_theme_user_scripts ( )
protectedinherited
286{
287 if (!m_browser)
288 return;
289 // Added once, at creation. Deliberately no RemoveAllUserScripts() here: the "wx"
290 // script message handler is registered separately (AddScriptMessageHandler), but on
291 // some backends RemoveAllUserScripts() drops it too, which would break
292 // window.wx.postMessage / HandleStudio. Live re-theme goes through apply_theme_live().
293 m_browser->AddUserScript(wxString::FromUTF8(theme_user_script()));
294 if (const nlohmann::json strings = localized_strings(); !strings.is_null())
295 m_browser->AddUserScript(wxString::FromUTF8(localized_strings_script(strings)));
297}
static std::string theme_user_script()
Definition WebViewHostDialog.cpp:93
static std::string localized_strings_script(const nlohmann::json &strings)
Definition WebViewHostDialog.cpp:156
virtual void add_user_scripts()
Definition WebViewHostDialog.hpp:95
virtual nlohmann::json localized_strings() const
Definition WebViewHostDialog.hpp:99

References add_user_scripts(), localized_strings(), localized_strings_script(), m_browser, and theme_user_script().

Referenced by create_webview().

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

◆ 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

◆ run_script()

bool Slic3r::GUI::WebViewHostDialog::run_script ( const wxString & script)
inherited
235{
236 if (!m_browser)
237 return false;
238
239 return WebView::RunScript(m_browser, script);
240}
static bool RunScript(wxWebView *webView, wxString const &msg)
Definition WebView.cpp:491

References m_browser, and WebView::RunScript().

Referenced by apply_theme_live(), call_web_handler(), Slic3r::GUI::ColorPickerDialog::focus_webview(), Slic3r::GUI::ColorPickerDialog::handle_web_command(), and Slic3r::GUI::ColorPickerDialog::send_initial_state().

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

◆ scale_factor()

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

◆ seq_top_layer_only_changed()

bool Slic3r::GUI::ExportPresetBundleDialog::seq_top_layer_only_changed ( ) const
inline
bool m_seq_top_layer_only_changed
Definition ExportPresetBundleDialog.hpp:75

References m_seq_top_layer_only_changed.

Referenced by Slic3r::GUI::GUI_App::open_exportpresetbundledialog().

Here is the caller graph for this function:

◆ 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; }

◆ show_export_result()

void Slic3r::GUI::ExportPresetBundleDialog::show_export_result ( const ExportCase & e)
489{
490 MessageDialog* msg_dlg = nullptr;
491 switch (export_case) {
493 msg_dlg = new MessageDialog(this, _L("initialize fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
494 wxOK | wxCENTRE);
495 break;
497 msg_dlg = new MessageDialog(this, _L("add file fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
498 wxOK | wxCENTRE);
499 break;
501 msg_dlg = new MessageDialog(this, _L("add bundle structure file fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
502 wxOK | wxCENTRE);
503 break;
505 msg_dlg = new MessageDialog(this, _L("finalize fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
506 wxOK | wxCENTRE);
507 break;
509 msg_dlg = new MessageDialog(this, _L("open zip written fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
510 wxOK | wxCENTRE);
511 break;
513 msg_dlg = new MessageDialog(this, _L("Export successful"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
514 wxOK | wxCENTRE);
515 break;
516 }
517
518 if (msg_dlg) {
519 msg_dlg->ShowModal();
520 delete msg_dlg;
521 msg_dlg = nullptr;
522 }
523}
@ OPEN_ZIP_WRITTEN_FILE
Definition ExportPresetBundleDialog.hpp:43
@ EXPORT_SUCCESS
Definition ExportPresetBundleDialog.hpp:45

References _L, Slic3r::GUI::ADD_BUNDLE_STRUCTURE_FAIL, Slic3r::GUI::ADD_FILE_FAIL, Slic3r::GUI::EXPORT_SUCCESS, Slic3r::GUI::FINALIZE_FAIL, Slic3r::GUI::INITIALIZE_FAIL, Slic3r::GUI::OPEN_ZIP_WRITTEN_FILE, Slic3r::GUI::DPIAware< P >::ShowModal(), and SLIC3R_APP_FULL_NAME.

Referenced by OnExportData().

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

◆ ShowModal()

◆ theme_apply_script()

std::string Slic3r::GUI::WebViewHostDialog::theme_apply_script ( )
staticinherited
88{ return host_theme_apply_js(); }

Referenced by Slic3r::GUI::WebPanel::apply_theme().

Here is the caller graph for this function:

◆ theme_user_script()

std::string Slic3r::GUI::WebViewHostDialog::theme_user_script ( )
staticinherited
94{
95 const std::string style = "<style id=\"orca-host-theme-vars\">" + host_theme_vars_css() + "</style>";
97 style, "orca-host-theme-vars", "afterbegin",
98 "window.__orcaHostThemed=true;var theme=\"" + host_theme_name() + "\";",
99 "if(document.documentElement)document.documentElement.setAttribute('data-orca-theme',theme);");
100}
std::string host_theme_vars_css()
Definition WebViewHostDialog.cpp:40
std::string host_theme_name()
Definition WebViewHostDialog.cpp:35

References document_start_injector(), and style.

Referenced by Slic3r::GUI::WebPanel::WebPanel(), and register_theme_user_scripts().

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 }

Member Data Documentation

◆ m_browser

wxWebView* Slic3r::GUI::WebViewHostDialog::m_browser {nullptr}
privateinherited

◆ m_can_rescale

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

◆ m_em_unit

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

◆ m_filament_name_to_presets

std::unordered_map<std::string, std::vector<std::pair<std::string, Preset*> > > Slic3r::GUI::ExportPresetBundleDialog::m_filament_name_to_presets
protected

◆ m_filament_presets

std::unordered_map<std::string, std::vector<const Preset*> > Slic3r::GUI::ExportPresetBundleDialog::m_filament_presets
protected

Referenced by InitExportData().

◆ m_force_rescale

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

◆ 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_prev_scale_factor

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

◆ m_printer_presets

std::unordered_map<std::string, Preset*> Slic3r::GUI::ExportPresetBundleDialog::m_printer_presets
protected

◆ m_process_presets

std::unordered_map<std::string, std::vector<const Preset*> > Slic3r::GUI::ExportPresetBundleDialog::m_process_presets
protected

Referenced by InitExportData(), and OnRequestPresets().

◆ m_recreate_GUI

bool Slic3r::GUI::ExportPresetBundleDialog::m_recreate_GUI {false}
protected
76{false};

Referenced by recreate_GUI().

◆ m_scale_factor

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

◆ m_seq_top_layer_only_changed

bool Slic3r::GUI::ExportPresetBundleDialog::m_seq_top_layer_only_changed {false}
protected
75{false};

Referenced by seq_top_layer_only_changed().


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