Add Filament Web

This commit is contained in:
QIDI TECH
2024-09-28 16:26:58 +08:00
parent e84f284825
commit 680346707d
8 changed files with 1648 additions and 73 deletions

View File

@@ -502,6 +502,8 @@ set(SLIC3R_GUI_SOURCES
Utils/FontConfigHelp.hpp
Utils/FontUtils.cpp
Utils/FontUtils.hpp
GUI/Filament_web.hpp
GUI/Filament_web.cpp
)
if(QDT_RELEASE_TO_PUBLIC)

View File

@@ -0,0 +1,66 @@
#include "Tab.hpp"
#include "Project.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Format/qds_3mf.hpp"
#include <wx/app.h>
#include <wx/button.h>
#include <wx/scrolwin.h>
#include <wx/sizer.h>
#include <wx/bmpcbox.h>
#include <wx/bmpbuttn.h>
#include <wx/treectrl.h>
#include <wx/imaglist.h>
#include <wx/settings.h>
#include <wx/filedlg.h>
#include <wx/wupdlock.h>
#include <wx/dataview.h>
#include <wx/tokenzr.h>
#include <wx/arrstr.h>
#include <wx/tglbtn.h>
#include <boost/log/trivial.hpp>
#include "wxExtensions.hpp"
#include "GUI_App.hpp"
#include "GUI_ObjectList.hpp"
#include "MainFrame.hpp"
#include <slic3r/GUI/Widgets/WebView.hpp>
namespace Slic3r {
namespace GUI {
FilamentPanel::FilamentPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxPanel(parent, id, pos, size, style)
{
m_project_home_url = wxString::Format("file://%s/web/filament/index.html", from_u8(resources_dir()));
wxString strlang = wxGetApp().current_language_code_safe();
if (strlang != "")
m_project_home_url = wxString::Format("file://%s/web/filament/index.html?lang=%s", from_u8(resources_dir()), strlang);
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
m_browser = WebView::CreateWebView(this, m_project_home_url);
if (m_browser == nullptr) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("load web view of project page failed");
return;
}
//m_browser->Hide();
main_sizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
SetSizer(main_sizer);
Layout();
Fit();
}
FilamentPanel::~FilamentPanel() {}
}
} // namespace Slic3r::GUI

View File

@@ -0,0 +1,69 @@
#ifndef slic3r_GUI_Filament_web_hpp_
#define slic3r_GUI_Filament_web_hpp_
#include "Tabbook.hpp"
#include "wx/artprov.h"
#include "wx/cmdline.h"
#include "wx/notifmsg.h"
#include "wx/settings.h"
#include "wx/webview.h"
#if wxUSE_WEBVIEW_EDGE
#include "wx/msw/webview_edge.h"
#endif
#include "wx/numdlg.h"
#include "wx/infobar.h"
#include "wx/filesys.h"
#include "wx/fs_arc.h"
#include "wx/fs_mem.h"
#include "wx/stdpaths.h"
#include <wx/panel.h>
#include <wx/tbarbase.h>
#include "wx/textctrl.h"
#include <wx/timer.h>
#include "nlohmann/json.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <map>
#include <vector>
#include <memory>
#include "Event.hpp"
#include "libslic3r/ProjectTask.hpp"
#include "wxExtensions.hpp"
namespace Slic3r {
namespace GUI {
struct filament_file {
std::string filepath;
std::string filename;
std::string size;
};
class FilamentPanel : public wxPanel
{
private:
bool m_web_init_completed = { false };
bool m_reload_already = { false };
wxWebView* m_browser = { nullptr };
wxString m_project_home_url;
wxString m_root_dir;
std::map<std::string, std::string> m_model_id_map;
static inline int m_sequence_id = 8000;
public:
FilamentPanel(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~FilamentPanel();
};
}
} // namespace Slic3r::GUI
#endif

View File

@@ -1205,6 +1205,10 @@ void MainFrame::init_tabpanel()
m_calibration->SetBackgroundColour(*wxWHITE);
m_tabpanel->AddPage(m_calibration, _L("Calibration"), std::string("tab_calibration_active"), std::string("tab_calibration_active"), false);
m_filament = new FilamentPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_filament->SetBackgroundColour(*wxWHITE);
m_tabpanel->AddPage(m_filament, _L("Filament"), std::string("model_weight"), std::string("model_weight"), false);
if (m_plater) {
// load initial config
auto full_config = wxGetApp().preset_bundle->full_config();

View File

@@ -24,6 +24,7 @@
#include "Auxiliary.hpp"
#include "Project.hpp"
#include "CalibrationPanel.hpp"
#include "Filament_web.hpp"
#include "UnsavedChangesDialog.hpp"
#include "Widgets/SideButton.hpp"
#include "Widgets/SideMenuPopup.hpp"
@@ -224,6 +225,7 @@ public:
tpProject = 4,
tpCalibration = 5,
tpMultiDevice = 6, // none
tpFilamentweb = 7,
};
//QDS: add slice&&print status update logic
@@ -377,6 +379,7 @@ public:
ProjectPanel* m_project{ nullptr };
CalibrationPanel* m_calibration{ nullptr };
FilamentPanel* m_filament{nullptr};
WebViewPanel* m_webview { nullptr };
PrinterWebView* m_printer_view{nullptr};
wxLogWindow* m_log_window { nullptr };