mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-06 11:47:58 -05:00
Outside the Design tab an agent had 175 commands, 50 of them in the tool list. There are now 118, named by what they act on (`object_`, `plate_`, `preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes its target and values in the call, acts on the selection when it names no target and says what it acted on; an old name is refused. Printers and system filaments install and uninstall, preferences read and write, plugins enable, reload, uninstall and refresh, and objects reorder, with no dialog to drive. The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the rows these commands share with the menus are fixed. For a person: an object row that cannot run says why instead of "Select an object first.", rows that failed no longer claim success, Duplicate Plate can be undone, and Refresh Plugins picked while a refresh runs now runs after it instead of beside it.
191 lines
5.2 KiB
C++
191 lines
5.2 KiB
C++
#ifndef slic3r_WebGuideDialog_hpp_
|
|
#define slic3r_WebGuideDialog_hpp_
|
|
|
|
#include "wx/artprov.h"
|
|
#include "wx/cmdline.h"
|
|
#include "wx/notifmsg.h"
|
|
#include "wx/settings.h"
|
|
#include "wx/webview.h"
|
|
#include <wx/setup.h>
|
|
#include "slic3r/GUI/GUI_Utils.hpp"
|
|
#include <wx/toplevel.h>
|
|
#include <wx/string.h>
|
|
#include <wx/event.h>
|
|
#include <string>
|
|
#include <wx/gdicmn.h>
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#if wxUSE_WEBVIEW_IE
|
|
#include "wx/msw/webview_ie.h"
|
|
#endif
|
|
#if wxUSE_WEBVIEW_EDGE
|
|
#include "wx/msw/webview_edge.h"
|
|
#endif
|
|
|
|
#include "wx/webviewarchivehandler.h"
|
|
#include "wx/webviewfshandler.h"
|
|
#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/frame.h>
|
|
#include <wx/tbarbase.h>
|
|
#include "wx/textctrl.h"
|
|
|
|
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <unordered_map>
|
|
#include <unordered_set>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <boost/thread.hpp>
|
|
#include "libslic3r/AppConfig.hpp"
|
|
|
|
class wxCommandEvent;
|
|
class wxIdleEvent;
|
|
class wxWebView;
|
|
class wxWebViewEvent;
|
|
namespace Slic3r { class PresetBundle; }
|
|
namespace Slic3r { class PresetUpdater; }
|
|
namespace Slic3r::GUI { class GUI_App; }
|
|
namespace boost { class thread; }
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
|
|
class GuideFrame : public DPIDialog
|
|
{
|
|
public:
|
|
using json = nlohmann::json;
|
|
|
|
GuideFrame(GUI_App *pGUI, long style = wxCAPTION | wxCLOSE_BOX | wxSYSTEM_MENU);
|
|
virtual ~GuideFrame();
|
|
|
|
enum GuidePage {
|
|
BBL_WELCOME,
|
|
BBL_REGION,
|
|
BBL_MODELS,
|
|
BBL_FILAMENTS,
|
|
BBL_FILAMENT_ONLY,
|
|
BBL_MODELS_ONLY
|
|
}m_page;
|
|
|
|
//Web Function
|
|
void load_url(wxString &url);
|
|
wxString SetStartPage(GuidePage startpage=BBL_WELCOME, bool load = true);
|
|
|
|
void UpdateState();
|
|
void OnIdle(wxIdleEvent &evt);
|
|
// void OnClose(wxCloseEvent &evt);
|
|
|
|
void OnNavigationRequest(wxWebViewEvent &evt);
|
|
void OnNavigationComplete(wxWebViewEvent &evt);
|
|
void OnDocumentLoaded(wxWebViewEvent &evt);
|
|
void OnNewWindow(wxWebViewEvent &evt);
|
|
void OnError(wxWebViewEvent &evt);
|
|
void OnTitleChanged(wxWebViewEvent &evt);
|
|
void OnFullScreenChanged(wxWebViewEvent &evt);
|
|
void OnScriptMessage(wxWebViewEvent &evt);
|
|
|
|
void OnScriptResponseMessage(wxCommandEvent &evt);
|
|
void RunScript(const wxString &javascript);
|
|
|
|
//Logic
|
|
bool IsFirstUse();
|
|
|
|
//Model - Machine - Filaments
|
|
int LoadProfileData();
|
|
int SaveProfileData();
|
|
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
|
|
void init_guide_paths();
|
|
void on_profile_loaded();
|
|
void notify_profile_loaded();
|
|
bool BuildProfileDataFromPresetBundle();
|
|
bool BuildProfileDataFromVendors();
|
|
void reset_profile_json();
|
|
int SaveProfile();
|
|
int GetFilamentInfo( std::string VendorDirectory,json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType);
|
|
|
|
|
|
bool apply_config();
|
|
bool run();
|
|
|
|
void StrReplace(std::string &strBase, std::string strSrc, std::string strDes);
|
|
std::string w2s(wxString sSrc);
|
|
void GetStardardFilePath(std::string &FilePath);
|
|
bool LoadFile(std::string jPath, std::string & sContent);
|
|
|
|
// install plugin
|
|
int DownloadPlugin();
|
|
int InstallPlugin();
|
|
int ShowPluginStatus(int status, int percent, bool &cancel);
|
|
|
|
void on_dpi_changed(const wxRect &suggested_rect) {}
|
|
|
|
private:
|
|
int GetFilamentInfo(const std::string& VendorDirectory, json& pFilaList, const std::string& filepath,
|
|
std::string& sVendor, std::string& sType, std::unordered_set<std::string>& visiting);
|
|
|
|
GUI_App *m_MainPtr;
|
|
AppConfig m_appconfig_new;
|
|
|
|
wxWebView *m_browser;
|
|
|
|
wxString m_SectionName;
|
|
|
|
bool orca_bundle_rsrc;
|
|
boost::filesystem::path vendor_dir;
|
|
boost::filesystem::path rsrc_vendor_dir;
|
|
|
|
//First Load
|
|
bool bFirstComplete{false};
|
|
// The loading page gets userguide_profile_load_finish once both are true;
|
|
// every instance of it reports in, so the flag is never reset.
|
|
bool m_profile_ready{false};
|
|
bool m_page_ready{false};
|
|
// Set once in the destructor. Read through `this` by the loading thread
|
|
// (joined before `this` dies) and captured as the shared_ptr by CallAfter
|
|
// lambdas so they don't touch `this` after the object is freed.
|
|
std::shared_ptr<std::atomic<bool>> m_cancel_token{std::make_shared<std::atomic<bool>>(false)};
|
|
std::unique_ptr<boost::thread> m_load_task;
|
|
|
|
// User Config
|
|
bool PrivacyUse;
|
|
bool StealthMode;
|
|
std::string m_Region;
|
|
|
|
bool InstallNetplugin;
|
|
bool network_plugin_ready {false};
|
|
|
|
json m_ProfileJson;
|
|
json m_OrcaFilaList;
|
|
std::string m_OrcaFilaLibPath;
|
|
|
|
#if wxUSE_WEBVIEW_IE
|
|
wxMenuItem *m_script_object_el;
|
|
wxMenuItem *m_script_date_el;
|
|
wxMenuItem *m_script_array_el;
|
|
#endif
|
|
// Last executed JavaScript snippet, for convenience.
|
|
wxString m_javascript;
|
|
wxString m_response_js;
|
|
|
|
wxString m_bbl_user_agent;
|
|
std::string m_editing_filament_id;
|
|
|
|
struct CachedFilamentInfo
|
|
{
|
|
int status{-1};
|
|
std::string vendor;
|
|
std::string type;
|
|
};
|
|
std::unordered_map<std::string, CachedFilamentInfo> filament_info_cache;
|
|
};
|
|
|
|
}} // namespace Slic3r::GUI
|
|
|
|
#endif /* slic3r_Tab_hpp_ */
|