Files
OrcaSlicer/src/slic3r/GUI/GUI_App.hpp
T
a5413efc37 refactor: printer agent infrastructure changes to work with other printer agents aside from bambu (#15710)
* Add developer flag for printer agents

* Parse user print info on the UI thread to prevent heap corruption (#119)

get_user_print_info()'s HTTP fetch can run on a worker thread (e.g. BindJob),
but parse_user_print_info() mutates userMachineList (insert/erase/delete
MachineObject). on_machine_alive (SSDP) mutates the same maps on the UI thread
without locking, so parsing off-thread races the map and frees MachineObjects
out from under it -> heap corruption.

Keep all device-list mutation on the UI thread: parse inline when already on
the main thread, otherwise marshal via CallAfter so it stays serialized with
on_machine_alive.

* Prevent loss of user access code on LAN reselect

Keep user access code intact to maintain access rights even if
device slot is unpopulated, ensuring continuous connection
and status message reception.

* Harden send flow and separate upload failure recovery (#111)

* fix(send): harden FT send path + IP pre-flight UX

* Remove early returns

* Working Moonraker and Qidi printer agent transport (#104)

Folds the Qidi AMS box-mapping print
overrides (apply_box_mapping +
start_* wrappers) that the transport
fix builds on.

* Add support for runtime error status in plugins

Distinguish a loaded plugin whose
capability errored (RuntimeError,
warn-styled, stays checked) from a
load-time Error. Status now derives
via resolve_plugin_status(); enum
ordinal keeps dialog sort priority.
Unloading clears stale errors.

* Resolve duplicate agent ID conflicts

Reject a printer-agent capability
whose agent ID is already owned by
another capability or built-in:
flag the plugin error, disable the
capability, and warn the user
instead of silently ignoring it.

* fix: checkbox should depend on plugin is_loaded status

* Replace fake-enum printer agent dropdown (#121)

A dedicated PrinterAgentChoice field
reads rows straight from the live
agent registry and stores the agent
id string, replacing the fake-coEnum
index mapping. The field moves to
TabPrinter and registers with the
searcher so UnsavedChanges renders
it; the PhysicalPrinterDialog copy
and its update hook are removed
(#125). switch_printer_agent now
resolves ids via
resolve_printer_agent_id.

* Reset device selection on agent swap or unload (#124)

set_live_printer_agent centralizes
the swap: deselect the machine,
clear stale sidebar state and the
previous agent's Other Devices, then
install the new agent (or null when
its provider vanished). Plugin
load/unload callbacks refresh the
dropdown and re-run agent selection.
load_last_machine no longer falls
back to the first available machine.

* Gate agent mode behind use_printer_agents toggle

Replace per-printer auto-activation
(is_current_printer_agent_plugin)
with a global experimental AppConfig
toggle, default off: legacy
print-host behavior is unchanged
until the user opts in. The toggle
drives device-tab routing, print
button defaults, connect-button
visibility and sidebar layout, and
dedups machine-select dialog opens.

* Track BBLPrinterAgentPlugin.py

* Add printer-agent and plugin status tests

Ports the agent lifecycle, duplicate
agent-id, built-in-id clash and
status-resolution tests. The loader
runs on a detached worker thread, so
the lifecycle tests live in their own
executable. Tests install the
production unload-side registry
wiring themselves (no GUI in the
test binary) and register agents
manually so concurrent loads stay
deterministic.

* fix: pin HTTP to prevent connection refusal

Set `use_ssl` to false to ensure Moonraker
connectivity, as the service uses HTTP rather
than HTTPS, preventing connection issues. Initialize
device info early for reliable name resolution.

* Bring Moonraker device panel to feature parity

The monitor panel showed wrong or missing
data for Moonraker printers, and its
controls did nothing.

Push payload now carries layer number and
total layers. Remaining time replaces the
wrong total_duration - print_duration
formula. The chamber light toggle maps to
Klipper SET_PIN / SET_LED, and pause,
resume and stop post to
/printer/print/{action}. Task thumbnails
resolve via /server/files/thumbnails onto
a new MachineObject thumbnail url.

Filament sync switches to pull mode so the
agent is queried on demand.

Not compiled or run.

* Stop blocking print on unreported nozzle data

* fix: make Klipper macro lamp control reliable

* Surface Moonraker webcams and gate unrunnable controls

* Keep Bambu AMS dialect out of the agent waist

M620 is Bambu firmware dialect, not a
neutral command. Composing it in
MachineObject let non-Bambu agents
(Moonraker/Klipper) forward it and
report success on firmware that
cannot run it.

Agents now own the dialect: the
default refusal on IPrinterAgent
returns not-supported so the UI
can say so; BBLPrinterAgent keeps
the byte-identical composition.

* Fix multi-color filament logic

Reuse color decoding across functions to improve
code readability and maintain consistency in
multi-color filament handling.

* Move Moonraker commands off the UI thread

Pause/resume/stop, g-code sends, temps, and
light ran synchronous HTTP on the UI thread,
freezing the app up to 10s per click on slow
or unreachable printers.

Run them on a single agent-owned FIFO worker
so g-code ordering is preserved, while command
translation stays synchronous so unsupported-
command dialogs still work.

Add a pending-disabled state to the pause,
resume, and abort buttons for Moonraker-family
printers: the icon only flips once the
WebSocket reports the real state, which also
rules out double-click races.

* Show Snapmaker U1 camera in Device tab

The U1 exposes no /server/webcams/list entry;
its camera only captures after an explicit
camera.start_monitor RPC, which the Moonraker
websocket executes unauthenticated but only
answers over MQTT - so the call is fire and
forget.

Start the camera when the camera view is
shown and renew every 300 s: the printer
retires the capture task at ~362 s and
stop_monitor is accepted but ineffective,
so teardown is simply to stop renewing.

Frames land in monitor.jpg as still JPEGs
(~2 fps at interval 0), so the webview loads
a local HTML wrapper that repolls with a
cache buster.

* fix: start stream when camera URL changes

* fix: stop Qidi slot parse throwing on null

* Keep printer-agent progress in sync

Keep the shared task progress aligned with agent
reports that lack Bambu cloud task identity.

Release the lazily allocated task during reset to
avoid leaks when machine objects reconnect.

* docs: document the printer-agent subsystem

* fix: merge access codes into one

* Reconcile implementation split with PR tip

* feat: abstract remaining gcode commands in devicemanager

* refactor: abstract bambu specific protocol to printer agent

* refactor: push bbl workflows to bbl printer agent

* remove unused

* fix: default impl

* fix callback error

* fix: remove redundant cache

* specify api for getting file transfer url

* revert file transfer abstraction

* fix: ams filament mapping workflow

* feat: update qidi to use subscription based filament sync mode

* fix: resolve stubgen byte header conflict

* fix: ams sync info and periodic ams sync via subscription workflow

* fix: skip filament sync dialog if filamentSyncMode is none

* feat: parse nozzle information for qidi and moonraker printer agents

* fix: extend access code requirements t 0, 8 or more characters.

* remove irrelevant docs

* fix: remove heavy includes from IPrinterAgent

* fix: defer filesystem and camera abstractions

* fix: remote do_fetch_filament_info from tests

* cleanup moonraker and snapmaker printer agents

* fix: access codes regression

* fix: tests

* fix: printer agent switching on preset change

* fix: remove unused variable

* fix: snapmaker U1 SelectMachineDialog blocking print

* fix: merge artifact

* fix: clear up some unrelated changes

* feat: connect to cloud printer and monitor

* feat: connect to cloud printer and monitor

* feat: generic camera stream support for http snapshot and rtsp

* fix: build & access code UI

* feat: generic camera stream support for http snapshot and rtsp

* fix: build & access code UI

* feat: connect to cloud printer and monitor

* feat: connect to cloud printer and monitor

* fix: build errors

* feat: camera via webrtc

* fix: build

* fix: cmake

* feat: remove frame assembler and change config to set protocol

* fix: orcaprinteragent refactor

* fix: LAN paths and camera stream

* feat: use ffmpeg to render http camera stream

* fix: make model_id/dev_type optional instead of blocking

* fix: connect via ip dialog

* feat: LAN impl for Orca Printer Agent

* fix: model_id resolution method for non bambu printers

* fix: ffmpeg http camera stream jittering due to incomplete frames

* fix: revert sdcard check

* feat: check printer storage status before sending

* fix: moonraker printer agent hang on printer power cut

* fix: shim layer for any compatibiliity changes

* fix: cloud printers were using the wrong MQTT endpoint

* feat: cloud download via HTTP

* temp: doc for intended change

* fix: warnings

* fix: warnings

* fix: camera auto-play on startup

* fix: split infra from impl

* fix: uninitialized ams state blocking print

* Fixes nullptr deref

* Log first before std::move

* fix: printer agent virutal optional functions

* fix: parameterize orcaslicer_copy_test_dlls() for printer_agent_plugin_tests

* Revert "fix: parameterize orcaslicer_copy_test_dlls() for printer_agent_plugin_tests"

This reverts commit 2f566e3779.

* Guard libdatachannel. Remove unused code

* fix: unit tests & unused variables

* fix(ci): deps build order for datachannel

* Resolve printer agent first before getting cloud printer agent

* fix(ci): set depends openssl

* fix: re-include apply header guarded by ifdef __APPLE__

* fix(ci): add libdatachannel to flatpak manifest

* fix: add internal_developer_mode chekc back to MediaPlayCtrl::load()

* fix: invoke js clearInterval on WebMediaController::stop

* fix: change rtc log level

* fix: inject provider, agent id and generation to get_user_print_info to ensure correct metadata

* fix: revert moonraker specific behavior

* fix: remove stale comment

* fix: use ORCA_CLOUD_PROVIDER instead of hardcoded string

* fix: remove hardcoded ICE servers

* feat: enable https camera stream mode

* fix: move non-mandatory printer agent function stubs to IPrinterAgent

* fix: dedupe compatible printer type check

* fix: stop the correct media controller

* fix: scope get_my_machine_list to printers listed under the current printer agent

* fix: move printer agent plugin tests into test_plugin_lifecycle.cpp

* fix: always build bundled DataChannel dep

* fix: disable unused DataChannel media support

* revert: filament sync work

* fix: wrap command_* with small wrapper

* fix: regression bug, connecting to bambu needs bblp username

* fix: default impl for vendor agnostic gcode commansd

* refactor: media controller playback routing and ownership

* fix: bump libdatachannel ver & update flatpak to use tar instead

* fix: stop flatpak DataChannel build from re-cloning over the sandboxed network

* fix: update windows ffmpeg prebuild

* fix: update printer agent plugin API

* fix: shift camera signaling channel to network agent

* fix: follow external-packages for flatpak libdatachannel deps & add flatpak path to use source_dir

* feat: add printer-agent.md doc to HLSD

* fix: guard DeviceManager command dispatch when no printer agent is bound

* fix: port BBL implementations from #15711

* refactor: connect_printer api and dialog

* fix(tests): make omitted printer agent operations answer like a missing agent

* fix: preserve printer agent defaults in PrinterAgentPluginCapabilityTrampoline

* test: cover printer agent default command dispatch

* fix: validate windows FFmpeg avformat library

* feat: extend optional printer model warnings to calibration & ams workflows

* fix: handle malformed printer progress values safely

* fix: clear webview document on stop

* chore: reduce diagnostic logging level to trace

* refactor: centralize printer compatibility checks

* tests: add device manager integration coverage

* tests: cover WebMediaController lifecycle with wxWebView stub

* fix: make integration tests headless

* refactor: collapse command_ams_refresh_rfid and command_ams_refresh_rfid2

* refactor: make printer connection SSL agent-specific

* fix: persist input printer host and port

* fix: use correct device id for Moonraker connections

* fix: make moonraker gcode commands asynchronous

* fix: preserve moonraker device names

* fix: add include for non BBL_RELEASE_TO_PUBLIC path in BBLPrinterAgent

---------

Co-authored-by: Andrew <159703254+andrewsoonqn@users.noreply.github.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
Co-authored-by: Lam Wei Lun <weilun.lam@gmail.com>
2026-10-01 00:30:44 +08:00

864 lines
38 KiB
C++

#ifndef slic3r_GUI_App_hpp_
#define slic3r_GUI_App_hpp_
#include <chrono>
#include <functional>
#include <memory>
#include <string>
#include "ActionRegistry.hpp"
#include "ImGuiWrapper.hpp"
#include "ConfigWizard.hpp"
#include "OpenGLManager.hpp"
#include "libslic3r/Preset.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "slic3r/GUI/UserNotification.hpp"
#include "slic3r/Utils/CloudProvider.hpp"
#include "slic3r/GUI/Jobs/UpgradeNetworkJob.hpp"
#include "slic3r/GUI/HttpServer.hpp"
#include "../Utils/PrintHost.hpp"
#include <wx/app.h>
#include <wx/colour.h>
#include <wx/font.h>
#include <wx/string.h>
#include <wx/snglinst.h>
#include <wx/msgdlg.h>
//#define BBL_HAS_FIRST_PAGE 1
#define STUDIO_INACTIVE_TIMEOUT 15*60*1000
#define LOG_FILES_MAX_NUM 30
#define TIMEOUT_CONNECT 15
#define TIMEOUT_RESPONSE 15
#define BE_UNACTED_ON 0x00200001
#define SHOW_BACKGROUND_BITMAP_PIXEL_THRESHOLD 80
#ifndef _MSW_DARK_MODE
#define _MSW_DARK_MODE 1
#endif // _MSW_DARK_MODE
class wxMenuItem;
class wxMenuBar;
class wxTopLevelWindow;
class wxDataViewCtrl;
class wxBookCtrlBase;
// BBS
class Notebook;
struct wxLanguageInfo;
namespace Slic3r {
class AppConfig;
class FilamentColorCodeQuery;
class PresetBundle;
class PresetUpdater;
class ModelObject;
class Model;
class UserManager;
class DeviceManager;
class MachineObject;
class NetworkAgent;
class IPrinterAgent;
class TaskManager;
// Same typedef as in bambu_networking.hpp, so this header need not include it.
typedef std::function<bool()> WasCancelledFn;
namespace GUI{
class RemovableDriveManager;
class OtherInstanceMessageHandler;
class ShortcutRegistry;
enum class ShortcutContext : uint8_t;
enum class PreferencesTab;
class MainFrame;
class Sidebar;
class ObjectSettings;
class ObjectList;
class ObjectLayers;
class Plater;
class ParamsPanel;
class NotificationManager;
class Downloader;
struct GUI_InitParams;
class ParamsDialog;
class HMSQuery;
class ModelMallDialog;
class PingCodeBindDialog;
class PresetBundleDialog;
class ZUserLogin;
class NetworkErrorDialog;
class PluginsDialog;
class SpeedDialWebDialog;
class TerminalDialog;
enum FileType
{
FT_STEP,
FT_STL,
FT_OBJ,
FT_AMF,
FT_3MF,
FT_GCODE_3MF,
FT_GCODE,
FT_MODEL,
FT_ZIP,
FT_PROJECT,
FT_GALLERY,
FT_INI,
FT_SVG,
FT_TEX,
FT_SL1,
FT_DRC,
FT_SIZE,
};
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string{});
enum ConfigMenuIDs {
//ConfigMenuWizard,
//ConfigMenuSnapshots,
//ConfigMenuTakeSnapshot,
//ConfigMenuUpdate,
//ConfigMenuDesktopIntegration,
ConfigMenuPreferences,
ConfigMenuPrinter,
//ConfigMenuModeSimple,
//ConfigMenuModeAdvanced,
//ConfigMenuLanguage,
//ConfigMenuFlashFirmware,
ConfigMenuCnt,
};
enum OrcaSlicerMenuIDs {
OrcaSlicerMenuAbout,
OrcaSlicerMenuPreferences,
};
enum CameraMenuIDs {
wxID_CAMERA_PERSPECTIVE,
wxID_CAMERA_ORTHOGONAL,
wxID_CAMERA_COUNT,
};
class Tab;
class ConfigWizard;
class GizmoObjectManipulation;
static wxString dots("...", wxConvUTF8);
// Does our wxWidgets version support markup?
#if wxUSE_MARKUP
#define SUPPORTS_MARKUP
#endif
#define VERSION_LEN 4
class VersionInfo
{
public:
std::string version_str;
std::string version_name;
std::string description;
std::string url;
bool force_upgrade{ false };
int ver_items[VERSION_LEN]; // AA.BB.CC.DD
VersionInfo() {
for (int i = 0; i < VERSION_LEN; i++) {
ver_items[i] = 0;
}
force_upgrade = false;
version_str = "";
}
void parse_version_str(std::string str) {
version_str = str;
std::vector<std::string> items;
boost::split(items, str, boost::is_any_of("."));
if (items.size() == VERSION_LEN) {
try {
for (int i = 0; i < VERSION_LEN; i++) {
ver_items[i] = stoi(items[i]);
}
}
catch (...) {
;
}
}
}
static std::string convert_full_version(std::string short_version);
static std::string convert_short_version(std::string full_version);
static std::string get_full_version() {
return convert_full_version(SLIC3R_VERSION);
}
/* return > 0, need update */
int compare(std::string ver_str) {
if (version_str.empty()) return -1;
int ver_target[VERSION_LEN];
std::vector<std::string> items;
boost::split(items, ver_str, boost::is_any_of("."));
if (items.size() == VERSION_LEN) {
try {
for (int i = 0; i < VERSION_LEN; i++) {
ver_target[i] = stoi(items[i]);
if (ver_target[i] < ver_items[i]) {
return 1;
}
else if (ver_target[i] == ver_items[i]) {
continue;
}
else {
return -1;
}
}
}
catch (...) {
return -1;
}
}
return -1;
}
};
class GUI_App : public wxApp
{
public:
//BBS: remove GCodeViewer as seperate APP logic
enum class EAppMode : unsigned char
{
Editor,
GCodeViewer
};
private:
bool m_initialized { false };
bool m_post_initialized { false };
bool m_app_conf_exists{ false };
EAppMode m_app_mode{ EAppMode::Editor };
bool m_is_recreating_gui{ false };
std::chrono::steady_clock::time_point m_last_input{ std::chrono::steady_clock::now() };
#ifdef __linux__
bool m_opengl_initialized{ false };
#endif
#if defined(__WINDOWS__)
bool m_is_arm64{false};
#endif
//#ifdef _WIN32
wxColour m_color_label_modified;
wxColour m_color_label_sys;
wxColour m_color_label_default;
wxColour m_color_window_default;
wxColour m_color_highlight_label_default;
wxColour m_color_hovered_btn_label;
wxColour m_color_default_btn_label;
wxColour m_color_highlight_default;
wxColour m_color_selected_btn_bg;
bool m_force_colors_update { false };
//#endif
wxFont m_small_font;
wxFont m_bold_font;
wxFont m_normal_font;
wxFont m_code_font;
wxFont m_link_font;
int m_em_unit; // width of a "m"-symbol in pixels for current system font
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls
std::unique_ptr<wxLocale> m_wxLocale;
// System language, from locales, owned by wxWidgets.
const wxLanguageInfo *m_language_info_system = nullptr;
// Best translation language, provided by Windows or OSX, owned by wxWidgets.
const wxLanguageInfo *m_language_info_best = nullptr;
wxString m_active_language_code;
OpenGLManager m_opengl_mgr;
std::unique_ptr<RemovableDriveManager> m_removable_drive_manager;
std::unique_ptr<ImGuiWrapper> m_imgui;
std::unique_ptr<ShortcutRegistry> m_shortcuts;
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
std::unique_ptr <OtherInstanceMessageHandler> m_other_instance_message_handler;
std::unique_ptr <wxSingleInstanceChecker> m_single_instance_checker;
std::string m_instance_hash_string;
size_t m_instance_hash_int;
std::unique_ptr<Downloader> m_downloader;
//BBS
std::atomic<bool> m_is_closing {false};
Slic3r::DeviceManager* m_device_manager { nullptr };
Slic3r::UserManager* m_user_manager { nullptr };
Slic3r::TaskManager* m_task_manager { nullptr };
NetworkAgent* m_agent { nullptr };
std::map<std::string, std::string> need_delete_presets; // store setting ids of preset
std::vector<bool> m_create_preset_blocked { false, false, false, false, false, false }; // excceed limit
std::vector<std::string> m_pending_conflict_setting_ids; // setting_id from the most recent 409 conflict
bool m_networking_compatible { false };
bool m_networking_need_update { false };
bool m_networking_cancel_update { false };
std::shared_ptr<UpgradeNetworkJob> m_upgrade_network_job;
// ORCA: for installing vendors on the main thread when presets to be synced requires it
// vendor structure is:
// [vendor_name]: { model: variants, model: variants, ... }
// filaments structure is:
// [filament_name]: true/false, ...
std::map<std::string, std::map<std::string, std::set<std::string>>> need_add_vendors;
std::map<std::string, std::string> need_add_filaments;
// login widget
ZUserLogin* login_dlg { nullptr };
VersionInfo version_info;
VersionInfo privacy_version_info;
static std::string version_display;
HMSQuery *hms_query { nullptr };
FilamentColorCodeQuery* m_filament_color_code_query{ nullptr };
boost::thread m_sync_update_thread;
std::shared_ptr<int> m_user_sync_token;
std::atomic<bool> m_restart_sync_pending {false};
std::atomic<bool> m_sync_user_preset_dlg_active {false}; // a manual "Sync Presets" progress dialog is on screen (see restart_sync_user_preset)
std::atomic<bool> m_sync_user_presets_now {false}; // request the sync loop to push user presets on its next tick
std::atomic<bool> m_migration_retry_pending {false};
bool m_is_dark_mode{ false };
bool m_adding_script_handler { false };
bool m_side_popup_status{false};
bool m_show_http_error_msgdlg{false};
std::chrono::steady_clock::time_point m_last_401_error_time;
bool m_show_error_msgdlg{false};
wxString m_info_dialog_content;
HttpServer m_http_server;
bool m_show_gcode_window{true};
boost::thread m_check_network_thread;
public:
//try again when subscription fails
void on_start_subscribe_again(std::string dev_id);
void reset_unsigned_plugin_warning() { m_unsigned_plugin_warning_shown = false; }
std::string get_local_models_path();
bool OnInit() override;
int OnExit() override;
bool initialized() const { return m_initialized; }
inline bool is_enable_multi_machine() { return this->app_config&& this->app_config->get("enable_multi_machine") == "true"; }
#ifdef SLIC3R_CAD
inline bool is_enable_cad_feature() { return this->app_config && this->app_config->get_bool("enable_cad_feature"); }
inline bool is_auto_close_sketch_loops() { return !this->app_config
|| this->app_config->get_bool("auto_close_sketch_loops"); }
#endif
std::map<std::string, bool> test_url_state;
//BBS: remove GCodeViewer as seperate APP logic
explicit GUI_App();
//explicit GUI_App(EAppMode mode = EAppMode::Editor);
~GUI_App() override;
void show_message_box(std::string msg) { wxMessageBox(msg); }
EAppMode get_app_mode() const { return m_app_mode; }
Slic3r::DeviceManager* getDeviceManager() { return m_device_manager; }
bool is_blocking_printing(MachineObject *obj_ = nullptr);
bool is_blocking_printing(MachineObject *obj_, const std::string& source_model);
Slic3r::TaskManager* getTaskManager() { return m_task_manager; }
HMSQuery* get_hms_query() { return hms_query; }
NetworkAgent* getAgent() { return m_agent; }
// Reconcile the live printer agent with the stored preset selection.
void switch_printer_agent();
std::string resolve_printer_agent_id(const std::string& stored_id) const;
// ORCA TODO: in the future, bbl presets should specify "bbl" printer agent id
// then, all resolve and canonical would just be ORCA<->""
std::string canonical_printer_agent_id(const std::string& picked_id);
FilamentColorCodeQuery* get_filament_color_code_query();
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
bool is_recreating_gui() const { return m_is_recreating_gui; }
// Milliseconds since the last mouse or keyboard event the app processed, or main window resize.
int input_idle_ms() const;
int FilterEvent(wxEvent& event) override;
// The Preferences "Default page" choice, stored as its index: 0 Home, 1 Prepare.
bool starts_on_prepare() const;
std::string logo_name() const { return is_editor() ? "OrcaSlicer" : "OrcaSlicer-gcodeviewer"; }
bool is_closing() const { return m_is_closing.load(std::memory_order_acquire); }
void set_closing(bool closing) { m_is_closing.store(closing, std::memory_order_release); }
// SoftFever
bool show_gcode_window() const { return m_show_gcode_window; }
void toggle_show_gcode_window();
bool show_3d_navigator() const { return app_config->get_bool("show_3d_navigator"); }
void toggle_show_3d_navigator() const { app_config->set_bool("show_3d_navigator", !show_3d_navigator()); }
bool show_plate_gridlines() const { return app_config->get_bool("show_plate_gridlines"); }
void toggle_show_plate_gridlines() const { app_config->set_bool("show_plate_gridlines", !show_plate_gridlines()); }
bool show_canvas_zoom_button() const { return app_config->get_bool("show_canvas_zoom_button"); }
void toggle_canvas_zoom_button() const { app_config->set_bool("show_canvas_zoom_button", !show_canvas_zoom_button()); }
bool show_outline() const { return app_config->get_bool("show_outline"); }
void toggle_show_outline() const { app_config->set_bool("show_outline", !show_outline()); }
wxString get_inf_dialog_contect () {return m_info_dialog_content;};
std::vector<std::string> split_str(std::string src, std::string separator);
// To be called after the GUI is fully built up.
// Process command line parameters cached in this->init_params,
// load configs, STLs etc.
void post_init();
void shutdown();
// If formatted for github, plaintext with OpenGL extensions enclosed into <details>.
// Otherwise HTML formatted for the system info dialog.
static std::string get_gl_info(bool for_github);
wxGLContext* init_glcontext(wxGLCanvas& canvas);
bool init_opengl();
void init_download_path();
#if wxUSE_WEBVIEW_EDGE
void init_webview_runtime();
#endif
static unsigned get_colour_approx_luma(const wxColour& colour);
static bool dark_mode();
const wxColour get_label_default_clr_system();
const wxColour get_label_default_clr_modified();
void init_label_colours();
void update_label_colours_from_appconfig();
void update_publish_status();
bool has_model_mall();
void update_label_colours();
// update color mode for window
void UpdateDarkUI(wxWindow *window, bool highlited = false, bool just_font = false);
void UpdateDarkUIWin(wxWindow* win);
void Update_dark_mode_flag();
// update color mode for whole dialog including all children
void UpdateDlgDarkUI(wxDialog* dlg);
void UpdateFrameDarkUI(wxFrame* dlg);
// update color mode for DataViewControl
void UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited = false);
// update color mode for panel including all static texts controls
void UpdateAllStaticTextDarkUI(wxWindow* parent);
void init_fonts();
void update_fonts(const MainFrame *main_frame = nullptr);
void set_label_clr_modified(const wxColour& clr);
void set_label_clr_sys(const wxColour& clr);
//update side popup status
bool get_side_menu_popup_status();
void set_side_menu_popup_status(bool status);
std::string link_to_network_check(); // ORCA
std::string link_to_lan_only_wiki(); // ORCA
const wxColour& get_label_clr_modified() { return m_color_label_modified; }
const wxColour& get_label_clr_sys() { return m_color_label_sys; }
const wxColour& get_label_clr_default() { return m_color_label_default; }
const wxColour& get_window_default_clr(){ return m_color_window_default; }
// BBS
//#ifdef _WIN32
const wxColour& get_label_highlight_clr() { return m_color_highlight_label_default; }
const wxColour& get_highlight_default_clr() { return m_color_highlight_default; }
const wxColour& get_color_hovered_btn_label() { return m_color_hovered_btn_label; }
const wxColour& get_color_selected_btn_bg() { return m_color_selected_btn_bg; }
void force_colors_update();
#ifdef _MSW_DARK_MODE
void force_menu_update();
#endif //_MSW_DARK_MODE
//#endif
const wxFont& small_font() { return m_small_font; }
const wxFont& bold_font() { return m_bold_font; }
const wxFont& normal_font() { return m_normal_font; }
const wxFont& code_font() { return m_code_font; }
const wxFont& link_font() { return m_link_font; }
int em_unit() const { return m_em_unit; }
bool tabs_as_menu() const;
wxSize get_min_size() const;
float toolbar_icon_scale(const bool is_limited = false) const;
void set_auto_toolbar_icon_scale(float scale) const;
void check_printer_presets();
void recreate_GUI(const wxString& message);
void system_info();
void keyboard_shortcuts(ShortcutContext page, wxWindow* parent = nullptr); // the main frame when null
void troubleshoot();
void load_project(wxWindow *parent, wxString& input_file) const;
void import_model(wxWindow *parent, wxArrayString& input_files) const;
void import_zip(wxWindow* parent, wxString& input_file) const;
void load_gcode(wxWindow* parent, wxString& input_file) const;
wxString transition_tridid(int trid_id) const;
void ShowUserGuide();
void ShowDownNetPluginDlg();
void ShowUserLogin(bool show = true, const std::string& provider = ORCA_CLOUD_PROVIDER);
void ShowOnlyFilament();
// Orca auth
void request_login(bool show_user_info = false, const std::string& provider = ORCA_CLOUD_PROVIDER);
bool check_login(const std::string& provider = ORCA_CLOUD_PROVIDER);
void get_login_info(const std::string& provider = ORCA_CLOUD_PROVIDER);
bool is_user_login(const std::string& provider = ORCA_CLOUD_PROVIDER);
std::string get_printer_cloud_provider() const;
void request_user_login(int online_login = 0, const std::string& provider = ORCA_CLOUD_PROVIDER);
void request_user_handle(int online_login = 0, const std::string& provider = ORCA_CLOUD_PROVIDER);
void request_user_logout(const std::string& provider = ORCA_CLOUD_PROVIDER);
void post_logout_to_webview(const std::string& provider);
int request_user_unbind(std::string dev_id, const std::string& provider = ORCA_CLOUD_PROVIDER);
std::string handle_web_request(std::string cmd);
void handle_script_message(std::string msg, const std::string& provider = ORCA_CLOUD_PROVIDER);
void request_model_download(wxString url);
void download_project(std::string project_id);
void request_project_download(std::string project_id);
void request_open_project(std::string project_id);
void request_remove_project(std::string project_id);
void handle_http_error(unsigned int status, std::string body, const std::string& provider = "");
void on_http_error(wxCommandEvent &evt);
void on_update_machine_list(wxCommandEvent& evt);
void on_user_login(wxCommandEvent &evt);
void on_user_login_handle(wxCommandEvent& evt);
void enable_user_preset_folder(bool enable);
// BBS
bool is_studio_active();
void reset_to_active();
bool m_studio_active = true;
std::chrono::system_clock::time_point last_active_point;
void check_update(bool show_tips, int by_user);
void check_new_version(bool show_tips = false, int by_user = 0);
void check_new_version_sf(bool show_tips = false, int by_user = 0);
bool process_network_msg(std::string dev_id, std::string msg);
void request_new_version(int by_user);
void enter_force_upgrade();
void set_skip_version(bool skip = true);
void no_new_version();
static std::string format_display_version();
std::string format_IP(const std::string& ip);
void show_dialog(wxString msg);
void push_notification(const MachineObject* obj, wxString msg, wxString title = wxEmptyString, UserNotificationStyle style = UserNotificationStyle::UNS_NORMAL);
void reload_settings();
void remove_user_presets();
bool maybe_migrate_user_presets_on_login();
// ORCA: functions for loading unloaded vendors to allow for proper inheritance when syncing user presets/bundles
bool check_preset_parent_available(const std::pair<std::string, std::map<std::string, std::string>>& preset_data);
void add_pending_vendor_preset(const std::pair<std::string, std::map<std::string, std::string>>& preset_data);
void load_pending_vendors();
void sync_preset(Preset* preset, bool force = false);
void start_sync_user_preset(bool with_progress_dlg = false);
void stop_sync_user_preset();
void restart_sync_user_preset();
// Resolve a cloud sync 409 by force-pushing the conflicting preset: clears the "hold"
// state the conflict left behind and queues it to be re-uploaded with force=true.
void force_push_conflicting_preset(const std::string& setting_id);
void on_stealth_mode_enter();
// Bundle subscription sync
void check_bundle_updates();
int sync_bundle(std::string bundle_id, std::string version);
bool unsubscribe_bundle(const std::string& id);
void update_single_bundle(wxCommandEvent& evt);
PresetBundleDialog* m_preset_bundle_dlg{nullptr};
PluginsDialog* m_plugins_dlg{nullptr};
SpeedDialWebDialog* m_speed_dial_dialog{nullptr};
TerminalDialog* m_terminal_dlg{nullptr};
ActionRegistry m_action_registry;
void start_http_server(const std::string& provider = ORCA_CLOUD_PROVIDER);
void start_http_server(int port, const std::string& provider = ORCA_CLOUD_PROVIDER);
void stop_http_server();
void on_show_check_privacy_dlg(int online_login = 0, const std::string& provider = ORCA_CLOUD_PROVIDER);
void show_check_privacy_dlg(wxCommandEvent& evt);
void on_check_privacy_update(wxCommandEvent &evt);
bool check_privacy_update();
void check_privacy_version(int online_login = 0, const std::string& provider = ORCA_CLOUD_PROVIDER);
void check_track_enable();
static bool catch_error(std::function<void()> cb, const std::string& err);
void persist_window_geometry(wxTopLevelWindow *window, bool default_maximized = false);
void update_ui_from_settings();
bool load_language(wxString language, bool initial);
Tab* get_tab(Preset::Type type);
Tab* get_plate_tab();
Tab* get_model_tab(bool part = false);
Tab* get_layer_tab();
ConfigOptionMode get_saved_mode();
ConfigOptionMode get_mode();
std::string get_saved_mode_str();
std::string get_mode_str();
void save_mode(const /*ConfigOptionMode*/int mode) ;
// Switch to `mode` from the Speed Dial: a developer-mode override hides the saved mode
// (get_mode returns comDevelop), so clear it first and persist the choice.
void set_mode(ConfigOptionMode mode);
// Turn the developer-mode override on and refresh the UI (used before jumping to a Developer setting).
void enable_developer_mode();
void update_mode();
void update_internal_development();
void show_ip_address_enter_dialog(wxString title = wxEmptyString);
void show_ip_address_enter_dialog_handler(wxCommandEvent &evt);
bool show_modal_ip_address_enter_dialog(bool input_sn, wxString title = wxEmptyString);
// BBS
//void add_config_menu(wxMenuBar *menu);
//void add_config_menu(wxMenu* menu);
bool has_unsaved_preset_changes() const;
bool has_current_preset_changes() const;
void update_saved_preset_from_current_preset();
std::vector<std::pair<unsigned int, std::string>> get_selected_presets() const;
bool check_and_save_current_preset_changes(const wxString& caption, const wxString& header, bool remember_choice = true, bool use_dont_save_insted_of_discard = false);
void apply_keeped_preset_modifications();
bool check_and_keep_current_preset_changes(const wxString& caption, const wxString& header, int action_buttons, bool* postponed_apply_of_keeped_changes = nullptr);
bool can_load_project();
bool check_print_host_queue();
bool checked_tab(Tab* tab);
//BBS: add preset combox re-active logic
void load_current_presets(bool active_preset_combox = false, bool check_printer_presets = true);
std::map<std::string, std::string> &get_delete_cache_presets();
std::map<std::string, std::string> get_delete_cache_presets_lock();
void process_delete_presets();
void delete_preset_from_cloud(std::string setting_id, std::string preset_file_path);
void preset_deleted_from_cloud(std::string setting_id);
void scan_orphaned_info_files();
static std::string extract_setting_id_from_info(const std::string& info_file_path);
wxString filter_string(wxString str);
wxString current_language_code() const { return m_active_language_code.empty() && m_wxLocale ? m_wxLocale->GetCanonicalName() : m_active_language_code; }
// Translate the language code to a code, for which Prusa Research maintains translations. Defaults to "en_US".
wxString current_language_code_safe() const;
bool is_localized() const { return m_wxLocale->GetLocale() != "English"; }
void open_preferences(); // on the General tab
void open_preferences(PreferencesTab tab, const std::string& highlight_option = std::string());
void open_presetbundledialog(size_t open_on_tab = 0, const std::string& highlight_option = std::string());
void open_plugins_dialog(size_t open_on_tab = 0, const std::string& highlight_option = std::string());
// Dialog-free plugin actions used by the speed dial: they never require the Plugins dialog to be open.
void refresh_plugins();
void install_local_plugin();
void open_terminal_dialog();
void open_speed_dial();
ActionRegistry& action_registry() { return m_action_registry; }
void open_exportpresetbundledialog(size_t open_on_tab = 0, const std::string& highlight_option = std::string());
virtual bool OnExceptionInMainLoop() override;
// Calls wxLaunchDefaultBrowser if user confirms in dialog.
bool open_browser_with_warning_dialog(const wxString& url, int flags = 0);
#ifdef __APPLE__
void OSXStoreOpenFiles(const wxArrayString &files);
// wxWidgets override to get an event on open files.
void MacOpenFiles(const wxArrayString &fileNames) override;
void MacOpenURL(const wxString& url) override;
#endif /* __APPLE */
Sidebar& sidebar();
GizmoObjectManipulation *obj_manipul();
ObjectSettings* obj_settings();
ObjectList* obj_list();
ObjectLayers* obj_layers();
Plater* plater();
const Plater* plater() const;
ParamsPanel* params_panel();
ParamsDialog* params_dialog();
Model& model();
NotificationManager * notification_manager();
Downloader* downloader();
std::string m_mall_model_download_url;
std::string m_mall_model_download_name;
ModelMallDialog* m_mall_publish_dialog{ nullptr };
PingCodeBindDialog* m_ping_code_binding_dialog{ nullptr };
NetworkErrorDialog* m_server_error_dialog { nullptr };
void set_download_model_url(std::string url) {m_mall_model_download_url = url;}
void set_download_model_name(std::string name) {m_mall_model_download_name = name;}
std::string get_download_model_url() {return m_mall_model_download_url;}
std::string get_download_model_name() {return m_mall_model_download_name;}
#if defined(__WINDOWS__)
bool is_running_on_arm64() { return m_is_arm64; }
#endif
void load_url(wxString url);
void open_mall_page_dialog();
void open_publish_page_dialog();
void remove_mall_system_dialog();
void run_script(wxString js);
bool is_adding_script_handler() { return m_adding_script_handler; }
void set_adding_script_handler(bool status) { m_adding_script_handler = status; }
char from_hex(char ch);
std::string url_encode(std::string value);
std::string url_decode(std::string value);
void popup_ping_bind_dialog();
void remove_ping_bind_dialog();
// Parameters extracted from the command line to be passed to GUI after initialization.
GUI_InitParams* init_params { nullptr };
AppConfig* app_config{ nullptr };
PresetBundle* preset_bundle{ nullptr };
PresetUpdater* preset_updater{ nullptr };
MainFrame* mainframe{ nullptr };
Plater* plater_{ nullptr };
PresetUpdater* get_preset_updater() { return preset_updater; }
Notebook* tab_panel() const ;
int extruders_cnt() const;
int extruders_edited_cnt() const;
// BBS
int filaments_cnt() const;
PrintSequence global_print_sequence() const;
std::vector<Tab *> tabs_list;
std::vector<Tab *> model_tabs_list;
Tab* plate_tab;
RemovableDriveManager* removable_drive_manager() { return m_removable_drive_manager.get(); }
OtherInstanceMessageHandler* other_instance_message_handler() { return m_other_instance_message_handler.get(); }
wxSingleInstanceChecker* single_instance_checker() {return m_single_instance_checker.get();}
void init_single_instance_checker(const std::string &name, const std::string &path);
void set_instance_hash (const size_t hash) { m_instance_hash_int = hash; m_instance_hash_string = std::to_string(hash); }
std::string get_instance_hash_string () { return m_instance_hash_string; }
size_t get_instance_hash_int () { return m_instance_hash_int; }
ImGuiWrapper* imgui() { return m_imgui.get(); }
ShortcutRegistry& shortcuts() { return *m_shortcuts; }
// Saves the bindings and refreshes every menu label, tooltip and accelerator table that shows one.
void on_shortcuts_changed();
PrintHostJobQueue& printhost_job_queue() { return *m_printhost_job_queue.get(); }
void open_web_page_localized(const std::string &http_address);
bool may_switch_to_SLA_preset(const wxString& caption);
bool run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage start_page = ConfigWizard::SP_WELCOME);
void show_desktop_integration_dialog();
#if ENABLE_THUMBNAIL_GENERATOR_DEBUG
// temporary and debug only -> extract thumbnails from selected gcode and save them as png files
void gcode_thumbnails_debug();
#endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG
OpenGLManager& get_opengl_manager() { return m_opengl_mgr; }
GLShaderProgram* get_shader(const std::string& shader_name) { return m_opengl_mgr.get_shader(shader_name); }
GLShaderProgram* get_current_shader() { return m_opengl_mgr.get_current_shader(); }
bool is_gl_version_greater_or_equal_to(unsigned int major, unsigned int minor) const { return m_opengl_mgr.get_gl_info().is_version_greater_or_equal_to(major, minor); }
bool is_glsl_version_greater_or_equal_to(unsigned int major, unsigned int minor) const { return m_opengl_mgr.get_gl_info().is_glsl_version_greater_or_equal_to(major, minor); }
int GetSingleChoiceIndex(const wxString& message, const wxString& caption, const wxArrayString& choices, int initialSelection);
// extend is stl/3mf/gcode/step etc
void associate_files(std::wstring extend);
void disassociate_files(std::wstring extend);
bool check_url_association(std::wstring url_prefix, std::wstring& reg_bin);
void associate_url(std::wstring url_prefix);
void disassociate_url(std::wstring url_prefix);
// URL download - PrusaSlicer gets system call to open prusaslicer:// URL which should contain address of download
void start_download(std::string url);
std::string get_plugin_url(std::string name, std::string country_code);
int download_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
int install_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
std::string get_http_url(std::string country_code, std::string path = {});
std::string get_model_http_url(std::string country_code);
bool use_legacy_network_plugin() const;
bool is_compatibility_version();
bool check_networking_version();
void cancel_networking_install();
void restart_networking();
void check_config_updates_from_updater() { check_updates(false); }
void show_network_plugin_download_dialog(bool is_update = false);
// One-time normalization of an older full-version identity (config 02.08.01.53 + file
// ..._02.08.01.53.dylib) to the AA.BB.CC series form, with no re-download. Runs at startup
// before the plug-in is loaded.
void migrate_network_plugin_config();
bool hot_reload_network_plugin();
bool install_network_plugin_from_ota(bool& had_cache);
std::string get_latest_network_version() const;
bool has_network_update_available() const;
// Orca: return the client version to report to Bambu servers. Pinned to
// 01.10.01.50 when the legacy network plugin lacks get_my_token support
// so the auth server stays on the ?access_token= redirect path.
std::string get_bbl_client_version();
private:
int updating_bambu_networking();
bool on_init_inner();
void copy_network_if_available();
bool on_init_network(bool try_backup = false);
void init_networking_callbacks();
void init_app_config();
// GUI-side subscriptions to plugin loader events (dialog refresh,
// network-agent registration, plate revalidation).
void init_plugin_gui_wiring();
void remove_old_networking_plugins();
void drain_pending_events(int timeout_ms);
bool wait_for_network_idle(int timeout_ms);
bool check_older_app_config(Semver current_version, bool backup);
void copy_older_config();
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
bool window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
void window_pos_sanitize(wxTopLevelWindow* window);
void window_pos_center(wxTopLevelWindow *window);
// Dynamic printer agent selection - internal helpers for switch_printer_agent
// and the plugin load/unload callbacks (init_plugin_gui_wiring).
void refresh_printer_agent_dropdown();
void set_live_printer_agent(std::shared_ptr<IPrinterAgent> agent); // null clears the selection
bool config_wizard_startup();
void check_updates(const bool verbose);
// select or add MachineObject
void select_machine(const std::string& agent_id);
bool m_init_app_config_from_older { false };
bool m_datadir_redefined { false };
std::string m_older_data_dir_path;
bool m_unsigned_plugin_warning_shown { false };
boost::optional<Semver> m_last_config_version;
bool m_config_corrupted { false };
std::string m_open_method;
};
DECLARE_APP(GUI_App)
wxDECLARE_EVENT(EVT_CONNECT_LAN_MODE_PRINT, wxCommandEvent);
wxDECLARE_EVENT(EVT_UPDATE_PRESET_BUNDLE, wxCommandEvent);
wxDECLARE_EVENT(EVT_UPDATE_BUNDLE_COMPLETE, wxCommandEvent);
bool is_support_filament(int extruder_id, bool strict_check = true);
bool is_soluble_filament(int extruder_id);
// check if the filament for model is in the list
bool has_filaments(const std::vector<std::string>& model_filaments);
} // namespace GUI
} // Slic3r
#endif // slic3r_GUI_App_hpp_