OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{PluginHostApp.cpp} Namespace Reference

Functions

GUI::Plater * current_plater ()
PresetBundle * current_preset_bundle ()
GUI::GUI_App & current_app ()
void require_main_thread (const char *function_name)
void export_3mf_copy (GUI::Plater &plater, const std::string &path)
py::object gl_info ()
py::dict app_info ()
py::object selected_printer ()

Function Documentation

◆ app_info()

py::dict Slic3r::anonymous_namespace{PluginHostApp.cpp}::app_info ( )
110{
111 GUI::GUI_App& app = current_app();
112 // The app config has no lock of its own; the UI thread is where it is written.
113 require_main_thread("app_info");
114 py::dict out;
115 out["version"] = SoftFever_VERSION;
116 out["build"] = GUI::build_commit_label;
117 out["mode"] = app.is_editor() ? "editor" : "gcode viewer";
118 out["language"] = GUI::into_u8(app.current_language_code_safe());
119 // The app config file is deny-listed for plugins; these are the parts a bug report needs.
120 const boost::optional<Semver>& config_version = app.last_config_version();
121 out["app_config_version"] = config_version && config_version->valid() ? config_version->to_string_sf() : std::string();
122 out["stealth_mode"] = app.app_config != nullptr && app.app_config->get_stealth_mode();
123 out["is_signed_in"] = app.is_user_login(ORCA_CLOUD_PROVIDER);
124 out["is_bambu_signed_in"] = app.is_user_login(BBL_CLOUD_PROVIDER);
125 out["network_plugin_version"] = NetworkAgent::is_network_module_loaded() ? NetworkAgent::get_version() : std::string();
127 out["network_plugin_error"] = load_error.has_error ? load_error.message : std::string();
128 return out;
129}
bool get_stealth_mode()
Definition AppConfig.cpp:108
Definition GUI_App.hpp:255
wxString current_language_code_safe() const
Definition GUI_App.cpp:9916
bool is_user_login(const std::string &provider=ORCA_CLOUD_PROVIDER)
Definition GUI_App.cpp:5317
const boost::optional< Semver > & last_config_version() const
Definition GUI_App.hpp:411
bool is_editor() const
Definition GUI_App.hpp:426
AppConfig * app_config
Definition GUI_App.hpp:787
static NetworkLibraryLoadError get_load_error()
Definition NetworkAgent.cpp:88
static bool is_network_module_loaded()
Definition NetworkAgent.cpp:76
static std::string get_version()
Definition NetworkAgent.cpp:84
const char *const build_commit_label
Definition BuildCommit.cpp:7
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
void require_main_thread(const char *function_name)
Definition PluginHostApp.cpp:73
GUI::GUI_App & current_app()
Definition PluginHostApp.cpp:64
std::string message
Definition bambu_networking.hpp:553
static const std::string ORCA_CLOUD_PROVIDER("orca")
static const std::string BBL_CLOUD_PROVIDER("bbl")
bool has_error
Definition bambu_networking.hpp:552
Definition bambu_networking.hpp:551
Definition 3DPrinterOS.hpp:13
STL namespace.

References Slic3r::GUI::GUI_App::app_config, app_info(), Slic3r::BBL_CLOUD_PROVIDER(), Slic3r::GUI::build_commit_label, current_app(), Slic3r::GUI::GUI_App::current_language_code_safe(), Slic3r::NetworkAgent::get_load_error(), Slic3r::AppConfig::get_stealth_mode(), Slic3r::NetworkAgent::get_version(), Slic3r::NetworkLibraryLoadError::has_error, Slic3r::GUI::into_u8(), Slic3r::GUI::GUI_App::is_editor(), Slic3r::NetworkAgent::is_network_module_loaded(), Slic3r::GUI::GUI_App::is_user_login(), Slic3r::GUI::GUI_App::last_config_version(), Slic3r::NetworkLibraryLoadError::message, Slic3r::ORCA_CLOUD_PROVIDER(), and require_main_thread().

Referenced by app_info().

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

◆ current_app()

GUI::GUI_App & Slic3r::anonymous_namespace{PluginHostApp.cpp}::current_app ( )
65{
66 if (wxTheApp == nullptr)
67 throw std::runtime_error("OrcaSlicer application is not initialized");
68 return GUI::wxGetApp();
69}

References current_app().

Referenced by app_info(), current_app(), and selected_printer().

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

◆ current_plater()

GUI::Plater * Slic3r::anonymous_namespace{PluginHostApp.cpp}::current_plater ( )
41{
42 if (wxTheApp == nullptr)
43 throw std::runtime_error("OrcaSlicer application is not initialized");
44
45 GUI::Plater* plater = GUI::wxGetApp().plater();
46 if (plater == nullptr)
47 throw std::runtime_error("Plater is not available");
48
49 return plater;
50}
Definition Plater.hpp:337

References current_plater().

Referenced by current_plater().

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

◆ current_preset_bundle()

PresetBundle * Slic3r::anonymous_namespace{PluginHostApp.cpp}::current_preset_bundle ( )
53{
54 if (wxTheApp == nullptr)
55 throw std::runtime_error("OrcaSlicer application is not initialized");
56
57 PresetBundle* preset_bundle = GUI::wxGetApp().preset_bundle;
58 if (preset_bundle == nullptr)
59 throw std::runtime_error("Preset bundle is not available");
60
61 return preset_bundle;
62}
Definition PresetBundle.hpp:210

References current_preset_bundle().

Referenced by current_preset_bundle().

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

◆ export_3mf_copy()

void Slic3r::anonymous_namespace{PluginHostApp.cpp}::export_3mf_copy ( GUI::Plater & plater,
const std::string & path )
80{
81 require_main_thread("export_3mf_copy");
82 if (!boost::iends_with(path, ".3mf"))
83 throw py::value_error("export_3mf_copy() needs a path ending in .3mf");
84 // The thumbnails are rendered by the 3D view, which may not exist yet while plugins load.
85 if (!GUI::OpenGLManager::get_gl_info().is_detected())
86 throw std::runtime_error("export_3mf_copy() needs the 3D view, which is not ready yet");
87 // The file is written from C++, so raise the audit event Python's open(path, "w") raises: the
88 // plugin gets the same deny list, permissions and prompt as for writing the file itself.
89 if (PySys_Audit("open", "ssi", path.c_str(), "w", 0) < 0)
90 throw py::error_already_set();
92 throw std::runtime_error("Failed to write " + path);
93}
static const GLInfo & get_gl_info()
Definition OpenGLManager.hpp:106
bool export_3mf_copy(const boost::filesystem::path &output_path)
Definition Plater.cpp:19729
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
boost::filesystem::path into_path(const wxString &str)
Definition GUI.cpp:564

References export_3mf_copy(), Slic3r::GUI::Plater::export_3mf_copy(), Slic3r::GUI::from_u8(), Slic3r::GUI::OpenGLManager::get_gl_info(), Slic3r::GUI::into_path(), and require_main_thread().

Referenced by export_3mf_copy().

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

◆ gl_info()

py::object Slic3r::anonymous_namespace{PluginHostApp.cpp}::gl_info ( )
96{
98 if (!info.is_detected())
99 return py::none();
100 py::dict out;
101 out["vendor"] = info.get_vendor();
102 out["renderer"] = info.get_renderer();
103 out["version"] = info.get_version();
104 out["glsl_version"] = info.get_glsl_version();
105 out["core_profile"] = info.is_core_profile();
106 return std::move(out);
107}
Definition OpenGLManager.hpp:28
const std::string & get_glsl_version() const
Definition OpenGLManager.cpp:66
const std::string & get_version() const
Definition OpenGLManager.cpp:58
bool is_detected() const
Definition OpenGLManager.hpp:52
bool is_core_profile() const
Definition OpenGLManager.hpp:53
const std::string & get_vendor() const
Definition OpenGLManager.cpp:74
const std::string & get_renderer() const
Definition OpenGLManager.cpp:82

References Slic3r::GUI::OpenGLManager::get_gl_info(), Slic3r::GUI::OpenGLManager::GLInfo::get_glsl_version(), Slic3r::GUI::OpenGLManager::GLInfo::get_renderer(), Slic3r::GUI::OpenGLManager::GLInfo::get_vendor(), Slic3r::GUI::OpenGLManager::GLInfo::get_version(), gl_info(), Slic3r::GUI::OpenGLManager::GLInfo::is_core_profile(), and Slic3r::GUI::OpenGLManager::GLInfo::is_detected().

Referenced by gl_info().

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

◆ require_main_thread()

void Slic3r::anonymous_namespace{PluginHostApp.cpp}::require_main_thread ( const char * function_name)
74{
75 if (!wxIsMainThread())
76 throw std::runtime_error(std::string(function_name) + "() must be called from the UI thread");
77}

References require_main_thread().

Referenced by app_info(), export_3mf_copy(), require_main_thread(), and selected_printer().

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

◆ selected_printer()

py::object Slic3r::anonymous_namespace{PluginHostApp.cpp}::selected_printer ( )
132{
133 GUI::GUI_App& app = current_app();
134 require_main_thread("selected_printer");
135 DeviceManager* devices = app.getDeviceManager();
136 MachineObject* machine = devices != nullptr ? devices->get_selected_machine() : nullptr;
137 if (machine == nullptr)
138 return py::none();
139 // Agent, model, link and firmware only: no name, serial, address or access code. Other agents
140 // fill the model and firmware with placeholders, so those come from Bambu printers only.
141 const bool bambu = machine->printer_agent_id == BBL_PRINTER_AGENT_ID;
142 py::dict out;
143 out["agent"] = machine->printer_agent_id;
144 out["model_id"] = bambu ? machine->printer_type : std::string();
145 out["connection"] = machine->connection_type();
146 out["online"] = machine->is_online();
147 out["connected"] = machine->is_connected();
148 out["firmware"] = bambu ? machine->get_ota_version() : std::string();
149 return std::move(out);
150}
Definition DevManager.h:26
MachineObject * get_selected_machine()
Definition DevManager.cpp:747
Slic3r::DeviceManager * getDeviceManager()
Definition GUI_App.hpp:404
Definition DeviceManager.hpp:111
std::string connection_type() const
Definition DeviceManager.hpp:220
bool is_connected()
Definition DeviceManager.cpp:2750
std::string printer_agent_id
Definition DeviceManager.hpp:248
std::string get_ota_version()
Definition DeviceManager.cpp:955
std::string printer_type
Definition DeviceManager.hpp:239
bool is_online()
Definition DeviceManager.hpp:898
static constexpr char BBL_PRINTER_AGENT_ID[]
Definition NetworkAgentFactory.hpp:20

References Slic3r::BBL_PRINTER_AGENT_ID, Slic3r::MachineObject::connection_type(), current_app(), Slic3r::MachineObject::get_ota_version(), Slic3r::DeviceManager::get_selected_machine(), Slic3r::GUI::GUI_App::getDeviceManager(), Slic3r::MachineObject::is_connected(), Slic3r::MachineObject::is_online(), Slic3r::MachineObject::printer_agent_id, Slic3r::MachineObject::printer_type, require_main_thread(), and selected_printer().

Referenced by selected_printer().

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