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

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

Inheritance diagram for Slic3r::GUI::ProjectPanel:
Collaboration diagram for Slic3r::GUI::ProjectPanel:

Public Member Functions

 ProjectPanel (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
 ~ProjectPanel ()
void shutdown ()
void onWebNavigating (wxWebViewEvent &evt)
void on_reload (wxCommandEvent &evt)
void on_size (wxSizeEvent &event)
void on_navigated (wxWebViewEvent &event)
void msw_rescale ()
void update_model_data ()
void clear_model_info ()
bool Show (bool show)
void OnScriptMessage (wxWebViewEvent &evt)
void RunScript (std::string content)
std::map< std::string, std::vector< nlohmann::json > > Reload (wxString aux_path)
std::string formatBytes (unsigned long bytes)
wxString to_base64 (std::string path)
bool built () const
bool build_step ()

Static Public Member Functions

static ProjectPanel * if_built ()
static ProjectPanel * ensure ()
static void when_built (std::function< void(ProjectPanel &)> fn)

Protected Member Functions

void add_build_step (std::function< void()> step)
void add_build_steps_of (StagedBuild &child)

Private Member Functions

void show_info_editor (bool show)
void create_browser ()
void reset_browser ()
StagedBuild * unfinished_child () const

Private Attributes

std::atomic< bool > m_web_init_completed {false}
std::shared_ptr< std::atomic< bool > > m_reload_cancel_token {std::make_shared<std::atomic<bool>>(false)}
std::unique_ptr< boost::thread > m_reload_task
wxWebView * m_browser = {nullptr}
AuxiliaryPanel * m_auxiliary {nullptr}
wxString m_project_home_url
wxString m_root_dir
std::string m_info_script
bool m_reset_on_show {false}
std::vector< std::function< void()> > m_steps
std::vector< StagedBuild * > m_children
size_t m_next_step { 0 }

Static Private Attributes

static std::atomic< int > m_sequence_id {8000}
static Lazy< ProjectPanel > * s_lazy

Detailed Description

Constructor & Destructor Documentation

◆ ProjectPanel()

Slic3r::GUI::ProjectPanel::ProjectPanel ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxTAB_TRAVERSAL )
102 : wxPanel(parent, id, pos, size, style)
103{
104 SetBackgroundColour(*wxWHITE);
105 m_project_home_url = file_url_from_path(boost::filesystem::path(resources_dir()) / "web/model/index.html");
106 wxString strlang = wxGetApp().current_language_code_safe();
107 if (strlang != "")
108 m_project_home_url += "?lang=" + strlang;
109
110 wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
111
114 //m_browser->Hide();
115 main_sizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
116
117 Bind(EVT_PROJECT_RELOAD, &ProjectPanel::on_reload, this);
118
119 m_auxiliary = new AuxiliaryPanel(this);
120 m_auxiliary->Hide();
121 main_sizer->Add(m_auxiliary, wxSizerFlags().Expand().Proportion(1));
123 Bind(EVT_AUXILIARY_DONE, [this](wxCommandEvent& e) { update_model_data();});
124
125 SetSizer(main_sizer);
126 Layout();
127 Fit();
128}
#define style
Definition WipeTowerDialog.cpp:101
void create_browser()
Definition Project.cpp:143
AuxiliaryPanel * m_auxiliary
Definition Project.hpp:79
void update_model_data()
Definition Project.cpp:402
wxString m_project_home_url
Definition Project.hpp:80
wxWebView * m_browser
Definition Project.hpp:78
bool m_reset_on_show
Definition Project.hpp:84
void on_reload(wxCommandEvent &evt)
Definition Project.cpp:186
void add_build_steps_of(StagedBuild &child)
Definition StagedBuild.hpp:43
static bool NeedsRecreateOnShow()
Definition WebView.cpp:424
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
const std::string & resources_dir()
Definition utils.cpp:296

References Slic3r::GUI::StagedBuild::add_build_steps_of(), create_browser(), Slic3r::GUI::file_url_from_path(), m_auxiliary, m_browser, m_project_home_url, m_reset_on_show, WebView::NeedsRecreateOnShow(), on_reload(), Slic3r::resources_dir(), style, and update_model_data().

Here is the call graph for this function:

◆ ~ProjectPanel()

Slic3r::GUI::ProjectPanel::~ProjectPanel ( )
131{
132 shutdown();
133}
void shutdown()
Definition Project.cpp:135

References shutdown().

Here is the call graph for this function:

Member Function Documentation

◆ add_build_step()

void Slic3r::GUI::StagedBuild::add_build_step ( std::function< void()> step)
inlineprotectedinherited
39{ m_steps.push_back(std::move(step)); }
std::vector< std::function< void()> > m_steps
Definition StagedBuild.hpp:57

References m_steps.

Referenced by Slic3r::GUI::StatusBasePanel::StatusBasePanel(), Slic3r::GUI::StatusPanel::StatusPanel(), add_build_steps_of(), Slic3r::GUI::CalibrationWizard::add_page_step(), Slic3r::GUI::StatusBasePanel::create_machine_control_page(), Slic3r::GUI::FlowRateWizard::create_pages(), Slic3r::GUI::PressureAdvanceWizard::create_pages(), Slic3r::GUI::AuxiliaryPanel::init_tabpanel(), and Slic3r::GUI::MonitorPanel::init_tabpanel().

Here is the caller graph for this function:

◆ add_build_steps_of()

void Slic3r::GUI::StagedBuild::add_build_steps_of ( StagedBuild & child)
inlineprotectedinherited
44 {
45 m_children.push_back(&child);
46 for (size_t i = child.m_next_step; i < child.m_steps.size(); ++i)
47 add_build_step([&child] { child.build_step(); });
48 }
std::vector< StagedBuild * > m_children
Definition StagedBuild.hpp:58
void add_build_step(std::function< void()> step)
Definition StagedBuild.hpp:39

References add_build_step(), build_step(), m_children, m_next_step, and m_steps.

Referenced by Slic3r::GUI::ProjectPanel::ProjectPanel(), Slic3r::GUI::CalibrationPanel::init_tabpanel(), and Slic3r::GUI::MonitorPanel::init_tabpanel().

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

◆ build_step()

bool Slic3r::GUI::StagedBuild::build_step ( )
inlineinherited
27 {
28 if (m_next_step < m_steps.size()) {
29 // Copied out, since a step may queue more steps and reallocate m_steps.
30 auto step = std::move(m_steps[m_next_step++]);
31 step();
32 } else if (StagedBuild* child = unfinished_child()) {
33 child->build_step();
34 }
35 return !built();
36 }
size_t m_next_step
Definition StagedBuild.hpp:59
StagedBuild * unfinished_child() const
Definition StagedBuild.hpp:51
bool built() const
Definition StagedBuild.hpp:18
void step(Coord &crd, const Dir d, const long n=1)
Definition MarchingSquares.hpp:213

References built(), m_next_step, m_steps, and unfinished_child().

Referenced by add_build_steps_of().

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

◆ built()

bool Slic3r::GUI::StagedBuild::built ( ) const
inlineinherited
19 {
20 return m_next_step == m_steps.size() &&
21 std::all_of(m_children.begin(), m_children.end(), [](const StagedBuild* child) { return child->built(); });
22 }

References m_children, m_next_step, and m_steps.

Referenced by Slic3r::GUI::StatusPanel::~StatusPanel(), build_step(), Slic3r::GUI::CalibrationPanel::show_status(), Slic3r::GUI::MonitorPanel::show_status(), Slic3r::GUI::CalibrationPanel::update_all(), and Slic3r::GUI::MonitorPanel::update_all().

Here is the caller graph for this function:

◆ clear_model_info()

void Slic3r::GUI::ProjectPanel::clear_model_info ( )
420{
421 if (wxTheApp == nullptr || wxGetApp().is_closing() ||
422 m_reload_cancel_token->load(std::memory_order_acquire))
423 return;
424
425 json m_Res = json::object();
426 m_Res["command"] = "clear_3mf_info";
427 m_Res["sequence_id"] = std::to_string(ProjectPanel::m_sequence_id.fetch_add(1, std::memory_order_relaxed));
428
429 wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore));
430
431 const auto cancel_token = m_reload_cancel_token;
432 wxGetApp().CallAfter([this, cancel_token, strJS] {
433 if (cancel_token->load(std::memory_order_acquire) || wxTheApp == nullptr || wxGetApp().is_closing())
434 return;
435 // Runs after any store queued by an earlier reload pass, so stale info is never replayed.
436 m_info_script.clear();
437 RunScript(strJS.ToStdString());
438 });
439}
static std::atomic< int > m_sequence_id
Definition Project.hpp:85
std::shared_ptr< std::atomic< bool > > m_reload_cancel_token
Definition Project.hpp:75
std::string m_info_script
Definition Project.hpp:83
void RunScript(std::string content)
Definition Project.cpp:572
nlohmann::json json
Definition AssembleList.cpp:42

References m_info_script, m_reload_cancel_token, m_sequence_id, and RunScript().

Referenced by on_reload(), and update_model_data().

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

◆ create_browser()

void Slic3r::GUI::ProjectPanel::create_browser ( )
private
144{
145 // Created empty and loaded after the strings are added, so the first load already has them.
146 m_browser = WebView::CreateWebView(this, wxEmptyString);
148 m_browser->Bind(wxEVT_WEBVIEW_NAVIGATED, &ProjectPanel::on_navigated, this);
149 m_browser->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &ProjectPanel::OnScriptMessage, this, m_browser->GetId());
150 m_browser->Bind(wxEVT_WEBVIEW_NAVIGATING, &ProjectPanel::onWebNavigating, this);
152}
void OnScriptMessage(wxWebViewEvent &evt)
Definition Project.cpp:354
void onWebNavigating(wxWebViewEvent &evt)
Definition Project.cpp:174
void on_navigated(wxWebViewEvent &event)
Definition Project.cpp:349
static std::string localized_strings_script(const nlohmann::json &strings)
Definition WebViewHostDialog.cpp:156
static void LoadUrl(wxWebView *webView, wxString const &url)
Definition WebView.cpp:480
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313
static json project_page_strings()
Definition Project.cpp:71

References WebView::CreateWebView(), WebView::LoadUrl(), Slic3r::GUI::WebViewHostDialog::localized_strings_script(), m_browser, m_project_home_url, on_navigated(), OnScriptMessage(), onWebNavigating(), and Slic3r::GUI::project_page_strings().

Referenced by ProjectPanel(), and reset_browser().

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

◆ ensure()

ProjectPanel * Slic3r::GUI::LazyInstance< ProjectPanel >::ensure ( )
inlinestaticinherited
186{ return s_lazy ? s_lazy->ensure() : nullptr; }
Definition Lazy.hpp:180
static Self * ensure()
Definition Lazy.hpp:186

◆ formatBytes()

std::string Slic3r::GUI::ProjectPanel::formatBytes ( unsigned long bytes)
536{
537 double dValidData = round(double(bytes) / (1024 * 1024) * 1000) / 1000;
538 return wxString::Format("%.2fMB", dValidData).ToStdString();
539}

Referenced by Reload().

Here is the caller graph for this function:

◆ if_built()

ProjectPanel * Slic3r::GUI::LazyInstance< ProjectPanel >::if_built ( )
inlinestaticinherited
183{ return s_lazy ? s_lazy->get() : nullptr; }

Referenced by Slic3r::GUI::MainFrame::shutdown().

Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::ProjectPanel::msw_rescale ( )
340{
341 m_auxiliary->msw_rescale();
342}

References m_auxiliary.

Referenced by Slic3r::GUI::MainFrame::on_dpi_changed().

Here is the caller graph for this function:

◆ on_navigated()

void Slic3r::GUI::ProjectPanel::on_navigated ( wxWebViewEvent & event)
350{
351 event.Skip();
352}

Referenced by create_browser().

Here is the caller graph for this function:

◆ on_reload()

void Slic3r::GUI::ProjectPanel::on_reload ( wxCommandEvent & evt)
187{
188 if (wxTheApp == nullptr || wxGetApp().is_closing() ||
189 m_reload_cancel_token->load(std::memory_order_acquire))
190 return;
191
192 if (m_reload_task && m_reload_task->joinable())
193 m_reload_task->join();
194
195 const auto cancel_token = m_reload_cancel_token;
196 m_reload_task = std::make_unique<boost::thread>([this, cancel_token] {
197 if (cancel_token->load(std::memory_order_acquire) || wxTheApp == nullptr || wxGetApp().is_closing())
198 return;
199 std::string update_type;
200 std::string license;
201 std::string model_name;
202 std::string model_author;
203 std::string cover_file;
204 std::string description;
205 std::string p_name;
206 std::string p_author;
207 std::string p_description;
208 std::string p_cover_file;
209
210 std::map<std::string, std::vector<json>> files;
211
212 if (wxGetApp().plater() == nullptr)
213 return;
214
215 Model model = wxGetApp().plater()->model();
216
217 auto model_info = model.model_info;
218 if (model_info != nullptr) {
219 license = model_info->license;
220 model_name = model_info->model_name;
221 cover_file = model_info->cover_file;
222 description = model_info->description;
223 update_type = model_info->origin;
224
225 try {
226 if (!model_info->copyright.empty()) {
227 json copy_right = json::parse(model_info->copyright);
228
229 if (copy_right.is_array()) {
230 for (auto it = copy_right.begin(); it != copy_right.end(); it++) {
231 if ((*it).contains("author")) {
232 model_author = (*it)["author"].get<std::string>();
233 }
234 }
235 }
236 }
237 } catch (...) {
238 ;
239 }
240 }
241
242 if (model_author.empty() && model.design_info != nullptr)
243 model_author = model.design_info->Designer;
244
245 if (model.profile_info != nullptr) {
246 p_name = model.profile_info->ProfileTile;
247 p_description = model.profile_info->ProfileDescription;
248 p_cover_file = model.profile_info->ProfileCover;
249 p_author = model.profile_info->ProfileUserName;
250 }
251
252 // file info
253 std::string file_path = encode_path(wxGetApp().plater()->model().get_auxiliary_file_temp_path().c_str());
254 if (!file_path.empty()) {
255 files = Reload(file_path);
256 if (cancel_token->load(std::memory_order_acquire) || wxTheApp == nullptr || wxGetApp().is_closing())
257 return;
258
259 wxGetApp().CallAfter([this, cancel_token, file_path, files] {
260 if (cancel_token->load(std::memory_order_acquire) || wxTheApp == nullptr || wxGetApp().is_closing())
261 return;
262 m_auxiliary->Reload(file_path, files);
263 });
264 } else {
266 return;
267 }
268
269 bool has_content = false;
270 for (const std::string& v : {
271 update_type,
272 license,
273 model_name,
274 model_author,
275 cover_file,
276 description,
277 p_name,
278 p_author,
279 p_description,
280 p_cover_file,
281 }) {
282 if (!v.empty()) {
283 has_content = true;
284 break;
285 }
286 }
287 if (!has_content) {
288 for (const auto & file : files) {
289 if (!file.second.empty()) {
290 has_content = true;
291 break;
292 }
293 }
294 }
295 if (!has_content) {
296 // Nothing to show, just return
298 return;
299 }
300
301 json j;
302 j["model"]["license"] = license;
303 j["model"]["name"] = wxGetApp().url_encode(model_name);
304 j["model"]["author"] = wxGetApp().url_encode(model_author);;
305 j["model"]["cover_img"] = wxGetApp().url_encode(cover_file);
306 j["model"]["description"] = wxGetApp().url_encode(convert_newlines_to_br(description));
307 j["model"]["preview_img"] = files["Model Pictures"];
308 j["model"]["upload_type"] = update_type;
309
310 j["file"]["BOM"] = files["Bill of Materials"];
311 j["file"]["Assembly"] = files["Assembly Guide"];
312 j["file"]["Other"] = files["Others"];
313
314 j["profile"]["name"] = wxGetApp().url_encode(p_name);
315 j["profile"]["author"] = wxGetApp().url_encode(p_author);
316 j["profile"]["description"] = wxGetApp().url_encode(p_description);
317 j["profile"]["cover_img"] = wxGetApp().url_encode(p_cover_file);
318 j["profile"]["preview_img"] = files["Profile Pictures"];
319
320 json m_Res = json::object();
321 m_Res["command"] = "show_3mf_info";
322 m_Res["sequence_id"] = std::to_string(ProjectPanel::m_sequence_id.fetch_add(1, std::memory_order_relaxed));
323 m_Res["model"] = j;
324
325 wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore));
326
327 if (!cancel_token->load(std::memory_order_acquire) && wxTheApp != nullptr && !wxGetApp().is_closing()) {
328 wxGetApp().CallAfter([this, cancel_token, strJS] {
329 if (cancel_token->load(std::memory_order_acquire) || wxTheApp == nullptr || wxGetApp().is_closing())
330 return;
331 m_info_script = strJS.ToStdString();
332 if (m_web_init_completed.load(std::memory_order_acquire))
334 });
335 }
336 });
337}
std::atomic< bool > m_web_init_completed
Definition Project.hpp:73
std::map< std::string, std::vector< nlohmann::json > > Reload(wxString aux_path)
Definition Project.cpp:441
void clear_model_info()
Definition Project.cpp:419
std::unique_ptr< boost::thread > m_reload_task
Definition Project.hpp:76
static Plater * plater()
Definition GUI_Factories.cpp:400
static std::string convert_newlines_to_br(const std::string &text)
Definition Project.cpp:164
std::string encode_path(const char *src)
Definition utils.cpp:1382

References clear_model_info(), Slic3r::GUI::convert_newlines_to_br(), Slic3r::Model::design_info, Slic3r::encode_path(), m_auxiliary, m_info_script, m_reload_cancel_token, m_reload_task, m_sequence_id, m_web_init_completed, Slic3r::Model::model_info, Slic3r::GUI::plater(), Slic3r::Model::profile_info, Reload(), and RunScript().

Referenced by ProjectPanel().

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

◆ on_size()

void Slic3r::GUI::ProjectPanel::on_size ( wxSizeEvent & event)
345{
346 event.Skip();
347}

◆ OnScriptMessage()

void Slic3r::GUI::ProjectPanel::OnScriptMessage ( wxWebViewEvent & evt)
355{
356 try {
357 wxString strInput = evt.GetString();
358 json j = json::parse(strInput.utf8_string());
359
360 wxString strCmd = j["command"];
361
362 if (strCmd == "open_3mf_accessory") {
363 wxString accessory_path = j["accessory_path"];
364
365 if (!accessory_path.empty()) {
366 std::string decode_path = wxGetApp().url_decode(accessory_path.ToStdString());
367 fs::path path(decode_path);
368 if (!desktop_open_project_attachment(this, path))
369 BOOST_LOG_TRIVIAL(warning) << "open_3mf_accessory: not opening " << decode_path;
370 }
371 }
372 else if (strCmd == "request_3mf_info") {
373 m_web_init_completed.store(true, std::memory_order_release);
374 // Replay the stored info after each page load.
375 CallAfter([this] {
376 if (!m_info_script.empty())
378 });
379 }
380 else if (strCmd == "edit_project_info") {
381 show_info_editor(true);
382 }
383 else if (strCmd == "debug_info") {
384 //wxString msg = j["msg"];
385 //OutputDebugString(wxString::Format("Model_Web: msg = %s \r\n", msg));
386 //BOOST_LOG_TRIVIAL(info) << wxString::Format("Model_Web: msg = %s", msg);
387 }
388
389 }
390 catch (std::exception&) {
391 // wxMessageBox(e.what(), "json Exception", MB_OK);
392 }
393}
void show_info_editor(bool show)
Definition Project.cpp:395
bool desktop_open_project_attachment(wxWindow *parent, const boost::filesystem::path &path)
Definition GUI.cpp:678
std::string decode_path(const char *src)
Definition utils.cpp:1401

References Slic3r::decode_path(), Slic3r::GUI::desktop_open_project_attachment(), m_info_script, m_web_init_completed, RunScript(), and show_info_editor().

Referenced by create_browser().

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

◆ onWebNavigating()

void Slic3r::GUI::ProjectPanel::onWebNavigating ( wxWebViewEvent & evt)
175{
176 wxString tmpUrl = evt.GetURL();
177 //wxString NowUrl = m_browser->GetCurrentURL();
178
179 if (boost::starts_with(tmpUrl, "http://") || boost::starts_with(tmpUrl, "https://")) {
180 m_browser->Stop();
181 evt.Veto();
182 wxLaunchDefaultApplication(tmpUrl);
183 }
184}

References m_browser.

Referenced by create_browser().

Here is the caller graph for this function:

◆ Reload()

std::map< std::string, std::vector< json > > Slic3r::GUI::ProjectPanel::Reload ( wxString aux_path)
442{
443 std::vector<fs::path> dir_cache;
444 fs::directory_iterator iter_end;
445 std::map<std::string, std::vector<json>> m_paths_list;
446
447 const static std::array<wxString, 5> s_default_folders = {
448 ("Model Pictures"),
449 ("Bill of Materials"),
450 ("Assembly Guide"),
451 ("Others"),
452 //(".thumbnails"),
453 ("Profile Pictures"),
454 };
455
456 for (auto folder : s_default_folders)
457 m_paths_list[folder.ToStdString()] = std::vector<json>{};
458
459
460 fs::path new_aux_path(aux_path.ToStdWstring());
461
462 // Check new path. If not exist, create a new one.
463 if (!fs::exists(new_aux_path)) {
464 fs::create_directory(new_aux_path);
465 }
466
467 // Create default folders if they are not loaded
468 for (auto folder : s_default_folders) {
469 wxString folder_path = aux_path + "/" + folder;
470 if (fs::exists(folder_path.ToStdWstring())) continue;
471 fs::create_directory(folder_path.ToStdWstring());
472 }
473
474 // Load from new path
475 for (fs::directory_iterator iter(new_aux_path); iter != iter_end; iter++) {
476 wxString path = iter->path().generic_wstring();
477 dir_cache.push_back(iter->path());
478 }
479
480
481 for (auto dir : dir_cache) {
482 for (fs::directory_iterator iter(dir); iter != iter_end; iter++) {
483 if (fs::is_directory(iter->path())) continue;
484
485 json pfile_obj;
486
487 std::string file_path = iter->path().string();
488 fs::path file_path_obj = fs::path(iter->path().string());
489
490 for (auto folder : s_default_folders) {
491 auto idx = file_path.find(folder.ToStdString());
492 if (idx != std::string::npos) {
493
494 wxStructStat strucStat;
495 wxString file_name = encode_path(file_path.c_str());
496 wxStat(file_name, &strucStat);
497 wxFileOffset filelen = strucStat.st_size;
498
499 pfile_obj["_filepath"] = file_path;
500 pfile_obj["filename"] = wxGetApp().url_encode(file_path_obj.filename().string().c_str());
501 pfile_obj["size"] = formatBytes((unsigned long)filelen);
502
503 std::string file_extension = file_path_obj.extension().string();
504 boost::algorithm::to_lower(file_extension);
505
506 //image
507 if (file_extension == ".jpg" ||
508 file_extension == ".jpeg" ||
509 file_extension == ".pjpeg" ||
510 file_extension == ".png" ||
511 file_extension == ".jfif" ||
512 file_extension == ".pjp" ||
513 file_extension == ".webp" ||
514 file_extension == ".bmp")
515 {
516
517 wxString base64_str = to_base64(file_path);
518 pfile_obj["filepath"] = base64_str.ToStdString();
519 m_paths_list[folder.ToStdString()].push_back(pfile_obj);
520 break;
521 }
522 else {
523 pfile_obj["filepath"] = wxGetApp().url_encode(file_path);
524 m_paths_list[folder.ToStdString()].push_back(pfile_obj);
525 break;
526 }
527 }
528 }
529 }
530 }
531
532 return m_paths_list;
533}
static const std::array< wxString, 5 > s_default_folders
Definition Auxiliary.hpp:84
wxString to_base64(std::string path)
Definition Project.cpp:541
std::string formatBytes(unsigned long bytes)
Definition Project.cpp:535

References Slic3r::encode_path(), formatBytes(), s_default_folders, and to_base64().

Referenced by on_reload().

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

◆ reset_browser()

void Slic3r::GUI::ProjectPanel::reset_browser ( )
private
155{
156 m_browser->Destroy(); // also removes it from the sizer
158 GetSizer()->Insert(0, m_browser, wxSizerFlags().Expand().Proportion(1));
159 Layout();
160 m_web_init_completed.store(false, std::memory_order_release);
161}

References create_browser(), m_browser, and m_web_init_completed.

Referenced by Show().

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

◆ RunScript()

void Slic3r::GUI::ProjectPanel::RunScript ( std::string content)
573{
575}
static bool RunScript(wxWebView *webView, wxString const &msg)
Definition WebView.cpp:491

References m_browser, and WebView::RunScript().

Referenced by clear_model_info(), on_reload(), and OnScriptMessage().

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

◆ Show()

bool Slic3r::GUI::ProjectPanel::Show ( bool show)
578{
579 if (show && std::exchange(m_reset_on_show, false))
581 if (show) update_model_data();
582 return wxPanel::Show(show);
583}
void reset_browser()
Definition Project.cpp:154

References m_reset_on_show, reset_browser(), and update_model_data().

Here is the call graph for this function:

◆ show_info_editor()

void Slic3r::GUI::ProjectPanel::show_info_editor ( bool show)
private
396{
397 m_browser->Show(!show);
398 m_auxiliary->Show(show);
399 Layout();
400}

References m_auxiliary, and m_browser.

Referenced by OnScriptMessage(), and update_model_data().

Here is the caller graph for this function:

◆ shutdown()

void Slic3r::GUI::ProjectPanel::shutdown ( )
136{
137 m_reload_cancel_token->store(true, std::memory_order_release);
138 if (m_reload_task && m_reload_task->joinable())
139 m_reload_task->join();
140 m_reload_task.reset();
141}

References m_reload_cancel_token, and m_reload_task.

Referenced by ~ProjectPanel().

Here is the caller graph for this function:

◆ to_base64()

wxString Slic3r::GUI::ProjectPanel::to_base64 ( std::string path)
542{
543
544 std::ifstream imageFile(encode_path(file_path.c_str()), std::ios::binary);
545 if (!imageFile) {
546 return wxEmptyString;
547 }
548
549 std::ostringstream imageStream;
550 imageStream << imageFile.rdbuf();
551
552 std::string binaryImageData = imageStream.str();
553
554 std::string extension;
555 size_t last_dot = file_path.find_last_of(".");
556
557 if (last_dot != std::string::npos) {
558 extension = file_path.substr(last_dot + 1);
559 }
560
561 wxString bease64_head = wxString::Format("data:image/%s;base64,", extension);
562
563
564 std::wstringstream wss;
565 wss << bease64_head;
566 wss << wxBase64Encode(binaryImageData.data(), binaryImageData.size());
567
568 wxString base64_str = wss.str();
569 return base64_str;
570}

References Slic3r::encode_path().

Referenced by Reload().

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

◆ unfinished_child()

StagedBuild * Slic3r::GUI::StagedBuild::unfinished_child ( ) const
inlineprivateinherited
52 {
53 auto it = std::find_if(m_children.begin(), m_children.end(), [](const StagedBuild* child) { return !child->built(); });
54 return it == m_children.end() ? nullptr : *it;
55 }

References m_children.

Referenced by build_step().

Here is the caller graph for this function:

◆ update_model_data()

void Slic3r::GUI::ProjectPanel::update_model_data ( )
403{
404 Model model = wxGetApp().plater()->model();
405 show_info_editor(false);
407
408 m_auxiliary->init_auxiliary();
409
410 //basics info
411 //if (model.model_info == nullptr)
412 // return;
413
414 auto event = wxCommandEvent(EVT_PROJECT_RELOAD);
415 event.SetEventObject(this);
416 wxPostEvent(this, event);
417}

References clear_model_info(), m_auxiliary, and show_info_editor().

Referenced by ProjectPanel(), and Show().

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

◆ when_built()

void Slic3r::GUI::LazyInstance< ProjectPanel >::when_built ( std::function< void(ProjectPanel &)> fn)
inlinestaticinherited
189 {
190 if (s_lazy)
192 }
static void when_built(std::function< void(Self &)> fn)
Definition Lazy.hpp:188

Referenced by Slic3r::GUI::MainFrame::on_dpi_changed().

Here is the caller graph for this function:

Member Data Documentation

◆ m_auxiliary

AuxiliaryPanel* Slic3r::GUI::ProjectPanel::m_auxiliary {nullptr}
private

◆ m_browser

wxWebView* Slic3r::GUI::ProjectPanel::m_browser = {nullptr}
private

◆ m_children

std::vector<StagedBuild*> Slic3r::GUI::StagedBuild::m_children
privateinherited

◆ m_info_script

std::string Slic3r::GUI::ProjectPanel::m_info_script
private

◆ m_next_step

size_t Slic3r::GUI::StagedBuild::m_next_step { 0 }
privateinherited
59{ 0 };

Referenced by add_build_steps_of(), build_step(), and built().

◆ m_project_home_url

wxString Slic3r::GUI::ProjectPanel::m_project_home_url
private

Referenced by ProjectPanel(), and create_browser().

◆ m_reload_cancel_token

std::shared_ptr<std::atomic<bool> > Slic3r::GUI::ProjectPanel::m_reload_cancel_token {std::make_shared<std::atomic<bool>>(false)}
private
75{std::make_shared<std::atomic<bool>>(false)};

Referenced by clear_model_info(), on_reload(), and shutdown().

◆ m_reload_task

std::unique_ptr<boost::thread> Slic3r::GUI::ProjectPanel::m_reload_task
private

Referenced by on_reload(), and shutdown().

◆ m_reset_on_show

bool Slic3r::GUI::ProjectPanel::m_reset_on_show {false}
private
84{false};

Referenced by ProjectPanel(), and Show().

◆ m_root_dir

wxString Slic3r::GUI::ProjectPanel::m_root_dir
private

◆ m_sequence_id

std::atomic<int> Slic3r::GUI::ProjectPanel::m_sequence_id {8000}
inlinestaticprivate
85{8000};

Referenced by clear_model_info(), and on_reload().

◆ m_steps

std::vector<std::function<void()> > Slic3r::GUI::StagedBuild::m_steps
privateinherited

◆ m_web_init_completed

std::atomic<bool> Slic3r::GUI::ProjectPanel::m_web_init_completed {false}
private
73{false};

Referenced by on_reload(), OnScriptMessage(), and reset_browser().

◆ s_lazy

Lazy<ProjectPanel>* Slic3r::GUI::LazyInstance< ProjectPanel >::s_lazy
inlinestaticprivateinherited
196{ nullptr };

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Project.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Project.cpp