mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-13 03:57:34 +00:00
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.
This commit is contained in:
@@ -708,7 +708,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||||||
m_print_enable = get_enable_print_status();
|
m_print_enable = get_enable_print_status();
|
||||||
m_print_btn->Enable(m_print_enable);
|
m_print_btn->Enable(m_print_enable);
|
||||||
if (m_print_enable) {
|
if (m_print_enable) {
|
||||||
if (wxGetApp().preset_bundle->use_bbl_network())
|
if (wxGetApp().preset_bundle->use_bbl_network() || wxGetApp().app_config->get_bool("use_printer_agents"))
|
||||||
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_PRINT_PLATE));
|
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_PRINT_PLATE));
|
||||||
else
|
else
|
||||||
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_GCODE));
|
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_GCODE));
|
||||||
@@ -1999,7 +1999,8 @@ wxBoxSizer* MainFrame::create_side_tools()
|
|||||||
SidePopup* p = new SidePopup(this);
|
SidePopup* p = new SidePopup(this);
|
||||||
|
|
||||||
if (wxGetApp().preset_bundle
|
if (wxGetApp().preset_bundle
|
||||||
&& !wxGetApp().preset_bundle->is_bbl_vendor()) {
|
&& !wxGetApp().preset_bundle->is_bbl_vendor()
|
||||||
|
&& !wxGetApp().app_config->get_bool("use_printer_agents")) {
|
||||||
// ThirdParty Buttons
|
// ThirdParty Buttons
|
||||||
SideButton* export_gcode_btn = new SideButton(p, _L("Export G-code file"), "");
|
SideButton* export_gcode_btn = new SideButton(p, _L("Export G-code file"), "");
|
||||||
export_gcode_btn->SetCornerRadius(0);
|
export_gcode_btn->SetCornerRadius(0);
|
||||||
@@ -2132,7 +2133,7 @@ wxBoxSizer* MainFrame::create_side_tools()
|
|||||||
|
|
||||||
const auto preset_bundle = wxGetApp().preset_bundle;
|
const auto preset_bundle = wxGetApp().preset_bundle;
|
||||||
if (preset_bundle) {
|
if (preset_bundle) {
|
||||||
if (preset_bundle->use_bbl_network()) {
|
if (preset_bundle->use_bbl_network() || wxGetApp().app_config->get_bool("use_printer_agents")) {
|
||||||
// BBL network support everything
|
// BBL network support everything
|
||||||
} else {
|
} else {
|
||||||
support_send = false; // All 3rd print hosts do not have the send options
|
support_send = false; // All 3rd print hosts do not have the send options
|
||||||
@@ -4253,7 +4254,7 @@ void MainFrame::load_printer_url(wxString url, wxString apikey)
|
|||||||
void MainFrame::load_printer_url()
|
void MainFrame::load_printer_url()
|
||||||
{
|
{
|
||||||
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||||
if (preset_bundle.use_bbl_device_tab() || NetworkAgentFactory::is_current_printer_agent_plugin())
|
if (preset_bundle.use_bbl_device_tab() || wxGetApp().app_config->get_bool("use_printer_agents"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto cfg = preset_bundle.printers.get_edited_preset().config;
|
auto cfg = preset_bundle.printers.get_edited_preset().config;
|
||||||
|
|||||||
@@ -669,7 +669,7 @@ void PhysicalPrinterDialog::update(bool printer_change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For bbl printers, show option to control the device tab
|
// For bbl printers, show option to control the device tab
|
||||||
if (wxGetApp().preset_bundle->is_bbl_vendor()) {
|
if (wxGetApp().preset_bundle->is_bbl_vendor() || wxGetApp().app_config->get_bool("use_printer_agents")) {
|
||||||
m_optgroup->show_field("bbl_use_print_host_webui");
|
m_optgroup->show_field("bbl_use_print_host_webui");
|
||||||
const bool use_print_host_webui = !current_webui.empty();
|
const bool use_print_host_webui = !current_webui.empty();
|
||||||
if (Field* printhost_webui_field = m_optgroup->get_field("bbl_use_print_host_webui"); printhost_webui_field) {
|
if (Field* printhost_webui_field = m_optgroup->get_field("bbl_use_print_host_webui"); printhost_webui_field) {
|
||||||
|
|||||||
@@ -3246,7 +3246,7 @@ void Sidebar::update_all_preset_comboboxes()
|
|||||||
|
|
||||||
auto p_mainframe = wxGetApp().mainframe;
|
auto p_mainframe = wxGetApp().mainframe;
|
||||||
auto cfg = preset_bundle.printers.get_edited_preset().config;
|
auto cfg = preset_bundle.printers.get_edited_preset().config;
|
||||||
const bool use_native_device_tab = preset_bundle.use_bbl_device_tab() || NetworkAgentFactory::is_current_printer_agent_plugin();
|
const bool use_native_device_tab = preset_bundle.use_bbl_device_tab() || wxGetApp().app_config->get_bool("use_printer_agents");
|
||||||
|
|
||||||
if (preset_bundle.use_bbl_network()) {
|
if (preset_bundle.use_bbl_network()) {
|
||||||
//only show connection button for not-BBL printer
|
//only show connection button for not-BBL printer
|
||||||
@@ -3258,7 +3258,8 @@ void Sidebar::update_all_preset_comboboxes()
|
|||||||
p_mainframe->set_print_button_to_default(MainFrame::PrintSelectType::ePrintPlate);
|
p_mainframe->set_print_button_to_default(MainFrame::PrintSelectType::ePrintPlate);
|
||||||
} else {
|
} else {
|
||||||
//p->btn_connect_printer->Show();
|
//p->btn_connect_printer->Show();
|
||||||
p->m_printer_connect->Show();
|
// ORCA: hide the physical-printer connection button when printer agents are enabled
|
||||||
|
p->m_printer_connect->Show(!wxGetApp().app_config->get_bool("use_printer_agents"));
|
||||||
|
|
||||||
// ORCA: show/hide sync-ams button based on filament sync mode
|
// ORCA: show/hide sync-ams button based on filament sync mode
|
||||||
auto agent = wxGetApp().getAgent();
|
auto agent = wxGetApp().getAgent();
|
||||||
@@ -3280,7 +3281,9 @@ void Sidebar::update_all_preset_comboboxes()
|
|||||||
const auto host_type = cfg.option<ConfigOptionEnum<PrintHostType>>("host_type")->value;
|
const auto host_type = cfg.option<ConfigOptionEnum<PrintHostType>>("host_type")->value;
|
||||||
if (cfg.has("printhost_apikey") && (host_type != htSimplyPrint))
|
if (cfg.has("printhost_apikey") && (host_type != htSimplyPrint))
|
||||||
apikey = cfg.opt_string("printhost_apikey");
|
apikey = cfg.opt_string("printhost_apikey");
|
||||||
print_btn_type = preset_bundle.is_bbl_vendor() ? MainFrame::PrintSelectType::ePrintPlate : MainFrame::PrintSelectType::eSendGcode;
|
print_btn_type = (preset_bundle.is_bbl_vendor() || wxGetApp().app_config->get_bool("use_printer_agents"))
|
||||||
|
? MainFrame::PrintSelectType::ePrintPlate
|
||||||
|
: MainFrame::PrintSelectType::eSendGcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_native_device_tab)
|
if (!use_native_device_tab)
|
||||||
@@ -3439,7 +3442,10 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
|||||||
|
|
||||||
bool isBBL = preset_bundle.is_bbl_vendor();
|
bool isBBL = preset_bundle.is_bbl_vendor();
|
||||||
bool is_dual_extruder = extruder_variants->size() == 2;
|
bool is_dual_extruder = extruder_variants->size() == 2;
|
||||||
p->layout_printer(preset_bundle.use_bbl_network(), isBBL && is_dual_extruder);
|
// why: agent mode drives the native device tab, so the sidebar lays out like BBL
|
||||||
|
// (no physical-printer connect button).
|
||||||
|
p->layout_printer(preset_bundle.use_bbl_network() || wxGetApp().app_config->get_bool("use_printer_agents"),
|
||||||
|
isBBL && is_dual_extruder);
|
||||||
|
|
||||||
// Update nozzle titles from printer config (e.g. "Main Nozzle" / "Auxiliary Nozzle" for N6)
|
// Update nozzle titles from printer config (e.g. "Main Nozzle" / "Auxiliary Nozzle" for N6)
|
||||||
// UI left = DEPUTY_EXTRUDER_ID(1), UI right = MAIN_EXTRUDER_ID(0)
|
// UI left = DEPUTY_EXTRUDER_ID(1), UI right = MAIN_EXTRUDER_ID(0)
|
||||||
@@ -5625,6 +5631,7 @@ struct Plater::priv
|
|||||||
void on_action_slice_all(SimpleEvent&);
|
void on_action_slice_all(SimpleEvent&);
|
||||||
void on_action_publish(wxCommandEvent &evt);
|
void on_action_publish(wxCommandEvent &evt);
|
||||||
void on_action_print_plate(SimpleEvent&);
|
void on_action_print_plate(SimpleEvent&);
|
||||||
|
void open_machine_select_dialog(int plate_idx, PrintFromType print_type = PrintFromType::FROM_NORMAL);
|
||||||
void on_action_print_all(SimpleEvent&);
|
void on_action_print_all(SimpleEvent&);
|
||||||
void on_action_export_gcode(SimpleEvent&);
|
void on_action_export_gcode(SimpleEvent&);
|
||||||
void on_action_send_gcode(SimpleEvent&);
|
void on_action_send_gcode(SimpleEvent&);
|
||||||
@@ -11166,18 +11173,23 @@ void Plater::priv::on_action_print_plate(SimpleEvent&)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PresetBundle& preset_bundle = *wxGetApp().preset_bundle;
|
PresetBundle& preset_bundle = *wxGetApp().preset_bundle;
|
||||||
if (preset_bundle.use_bbl_network()) {
|
if (preset_bundle.use_bbl_network() || wxGetApp().app_config->get_bool("use_printer_agents")) {
|
||||||
// BBS
|
open_machine_select_dialog(partplate_list.get_curr_plate_index());
|
||||||
if (!m_select_machine_dlg)
|
|
||||||
m_select_machine_dlg = new SelectMachineDialog(q);
|
|
||||||
m_select_machine_dlg->set_print_type(PrintFromType::FROM_NORMAL);
|
|
||||||
m_select_machine_dlg->prepare(partplate_list.get_curr_plate_index());
|
|
||||||
m_select_machine_dlg->ShowModal();
|
|
||||||
} else {
|
} else {
|
||||||
q->send_gcode_legacy(PLATE_CURRENT_IDX, nullptr);
|
q->send_gcode_legacy(PLATE_CURRENT_IDX, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plater::priv::open_machine_select_dialog(int plate_idx, PrintFromType print_type)
|
||||||
|
{
|
||||||
|
// BBS
|
||||||
|
if (!m_select_machine_dlg)
|
||||||
|
m_select_machine_dlg = new SelectMachineDialog(q);
|
||||||
|
m_select_machine_dlg->set_print_type(print_type);
|
||||||
|
m_select_machine_dlg->prepare(plate_idx);
|
||||||
|
m_select_machine_dlg->ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
void Plater::priv::on_action_send_to_multi_machine(SimpleEvent&)
|
void Plater::priv::on_action_send_to_multi_machine(SimpleEvent&)
|
||||||
{
|
{
|
||||||
if (!m_send_multi_dlg)
|
if (!m_send_multi_dlg)
|
||||||
@@ -11193,10 +11205,7 @@ void Plater::priv::on_action_print_plate_from_sdcard(SimpleEvent&)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
if (!m_select_machine_dlg) m_select_machine_dlg = new SelectMachineDialog(q);
|
open_machine_select_dialog(0, PrintFromType::FROM_SDCARD_VIEW);
|
||||||
m_select_machine_dlg->set_print_type(PrintFromType::FROM_SDCARD_VIEW);
|
|
||||||
m_select_machine_dlg->prepare(0);
|
|
||||||
m_select_machine_dlg->ShowModal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
||||||
@@ -11211,13 +11220,13 @@ void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
|||||||
sidebar_layout.show = new_sel == MainFrame::tp3DEditor || new_sel == MainFrame::tpPreview;
|
sidebar_layout.show = new_sel == MainFrame::tp3DEditor || new_sel == MainFrame::tpPreview;
|
||||||
update_sidebar();
|
update_sidebar();
|
||||||
int old_sel = e.GetOldSelection();
|
int old_sel = e.GetOldSelection();
|
||||||
const bool is_printer_agent_plugin = NetworkAgentFactory::is_current_printer_agent_plugin();
|
const bool use_printer_agents = wxGetApp().app_config->get_bool("use_printer_agents");
|
||||||
const bool use_native_device_tab = wxGetApp().preset_bundle &&
|
const bool use_native_device_tab = wxGetApp().preset_bundle &&
|
||||||
(wxGetApp().preset_bundle->use_bbl_device_tab() || is_printer_agent_plugin);
|
(wxGetApp().preset_bundle->use_bbl_device_tab() || use_printer_agents);
|
||||||
if (use_native_device_tab && new_sel == MainFrame::tpMonitor) {
|
if (use_native_device_tab && new_sel == MainFrame::tpMonitor) {
|
||||||
// BBL network module is only required for BBL-vendor printers.
|
// BBL network module is only required for BBL-vendor printers.
|
||||||
// Non-BBL Python plugins (e.g. moonraker) drive the Device tab without it.
|
// Non-BBL Python plugins (e.g. moonraker) drive the Device tab without it.
|
||||||
if (!is_printer_agent_plugin && wxGetApp().preset_bundle->is_bbl_vendor() && !Slic3r::NetworkAgent::is_network_module_loaded()) {
|
if (!use_printer_agents && wxGetApp().preset_bundle->is_bbl_vendor() && !Slic3r::NetworkAgent::is_network_module_loaded()) {
|
||||||
e.Veto();
|
e.Veto();
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2%, lack of network plugins") % old_sel % new_sel;
|
BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2%, lack of network plugins") % old_sel % new_sel;
|
||||||
if (q) {
|
if (q) {
|
||||||
@@ -11273,13 +11282,8 @@ void Plater::priv::on_action_print_all(SimpleEvent&)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PresetBundle& preset_bundle = *wxGetApp().preset_bundle;
|
PresetBundle& preset_bundle = *wxGetApp().preset_bundle;
|
||||||
if (preset_bundle.use_bbl_network()) {
|
if (preset_bundle.use_bbl_network() || wxGetApp().app_config->get_bool("use_printer_agents")) {
|
||||||
// BBS
|
open_machine_select_dialog(PLATE_ALL_IDX);
|
||||||
if (!m_select_machine_dlg)
|
|
||||||
m_select_machine_dlg = new SelectMachineDialog(q);
|
|
||||||
m_select_machine_dlg->set_print_type(PrintFromType::FROM_NORMAL);
|
|
||||||
m_select_machine_dlg->prepare(PLATE_ALL_IDX);
|
|
||||||
m_select_machine_dlg->ShowModal();
|
|
||||||
} else {
|
} else {
|
||||||
q->send_gcode_legacy(PLATE_ALL_IDX, nullptr);
|
q->send_gcode_legacy(PLATE_ALL_IDX, nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1135,6 +1135,14 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxString too
|
|||||||
wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_FILAMENT);
|
wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_FILAMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param == "use_printer_agents")
|
||||||
|
{
|
||||||
|
// Rebuild the Device tab so the native/web-UI choice reflects the new flag
|
||||||
|
// immediately, instead of only on the next printer-preset change or restart.
|
||||||
|
if (wxGetApp().plater())
|
||||||
|
wxGetApp().plater()->sidebar().update_all_preset_comboboxes();
|
||||||
|
}
|
||||||
|
|
||||||
if (param == "enable_high_low_temp_mixed_printing") {
|
if (param == "enable_high_low_temp_mixed_printing") {
|
||||||
if (checkbox->GetValue()) {
|
if (checkbox->GetValue()) {
|
||||||
const wxString warning_title = _L("Bed Temperature Difference Warning");
|
const wxString warning_title = _L("Bed Temperature Difference Warning");
|
||||||
|
|||||||
@@ -465,25 +465,5 @@ void NetworkAgentFactory::deregister_python_printer_agent(const std::string& plu
|
|||||||
<< plugin_key << "' with agent ID '" << agent_id << "'";
|
<< plugin_key << "' with agent ID '" << agent_id << "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkAgentFactory::is_current_printer_agent_plugin()
|
|
||||||
{
|
|
||||||
auto* preset_bundle = GUI::wxGetApp().preset_bundle;
|
|
||||||
if (!preset_bundle)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
std::string agent_key = ORCA_PRINTER_AGENT_ID;
|
|
||||||
if (preset_bundle->is_bbl_vendor())
|
|
||||||
agent_key = BBL_PRINTER_AGENT_ID;
|
|
||||||
|
|
||||||
const auto& cfg = preset_bundle->printers.get_edited_preset().config;
|
|
||||||
if (cfg.has("printer_agent")) {
|
|
||||||
const std::string& value = cfg.option<ConfigOptionString>("printer_agent")->value;
|
|
||||||
if (!value.empty())
|
|
||||||
agent_key = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const PrinterAgentInfo* info = get_printer_agent_info(agent_key);
|
|
||||||
return info && info->is_plugin();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|||||||
@@ -166,8 +166,6 @@ public:
|
|||||||
static void register_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
|
static void register_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
|
||||||
static void deregister_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
|
static void deregister_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
|
||||||
|
|
||||||
static bool is_current_printer_agent_plugin();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Factory is not instantiable
|
// Factory is not instantiable
|
||||||
NetworkAgentFactory() = delete;
|
NetworkAgentFactory() = delete;
|
||||||
|
|||||||
Reference in New Issue
Block a user