mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-23 00:42:33 +00:00
refactor: centralize printer compatibility checks
This commit is contained in:
@@ -1640,19 +1640,6 @@ void CalibrationPresetPage::update_combobox_filaments(MachineObject* obj)
|
||||
select_default_compatible_filament();
|
||||
}
|
||||
|
||||
bool CalibrationPresetPage::is_blocking_printing()
|
||||
{
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
|
||||
MachineObject* obj_ = dev->get_selected_machine();
|
||||
if (obj_ == nullptr) return true;
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
const auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
bool CalibrationPresetPage::is_nozzle_info_synced() const
|
||||
{
|
||||
if (!curr_obj || !curr_obj->is_info_ready())
|
||||
@@ -1741,11 +1728,6 @@ void CalibrationPresetPage::update_show_status()
|
||||
preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle));
|
||||
}
|
||||
|
||||
//if (is_blocking_printing()) {
|
||||
// show_status(CaliPresetPageStatus::CaliPresetStatusUnsupportedPrinter);
|
||||
// return;
|
||||
//}
|
||||
//else
|
||||
if (obj_->is_connecting() || !obj_->is_connected()) {
|
||||
show_status(CaliPresetPageStatus::CaliPresetStatusInConnecting);
|
||||
return;
|
||||
|
||||
@@ -269,7 +269,6 @@ protected:
|
||||
bool is_nozzle_info_synced() const;
|
||||
void show_status(CaliPresetPageStatus status);
|
||||
void Enable_Send_Button(bool enable);
|
||||
bool is_blocking_printing();
|
||||
bool need_check_sdcard(MachineObject* obj);
|
||||
|
||||
CaliPresetPageStatus get_status() { return m_page_status; }
|
||||
|
||||
+14
-12
@@ -2383,19 +2383,21 @@ GUI_App::~GUI_App()
|
||||
|
||||
bool GUI_App::is_blocking_printing(MachineObject *obj_)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
if (obj_ == nullptr) {
|
||||
obj_ = dev->get_selected_machine();
|
||||
}
|
||||
|
||||
if (!obj_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
std::string source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
const std::string source_model = preset_bundle
|
||||
? preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle)
|
||||
: std::string();
|
||||
return is_blocking_printing(obj_, source_model);
|
||||
}
|
||||
|
||||
bool GUI_App::is_blocking_printing(MachineObject *obj_, const std::string& source_model)
|
||||
{
|
||||
DeviceManager *dev = getDeviceManager();
|
||||
if (!dev) return true;
|
||||
if (obj_ == nullptr)
|
||||
obj_ = dev->get_selected_machine();
|
||||
if (!obj_)
|
||||
return false;
|
||||
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
@@ -368,6 +368,7 @@ public:
|
||||
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; }
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "DeviceCore/DevConfigUtil.h"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@@ -52,7 +51,7 @@ void DeviceItem::sync_state()
|
||||
state_printable = 6;
|
||||
}
|
||||
|
||||
if (is_blocking_printing(obj_)) {
|
||||
if (wxGetApp().is_blocking_printing(obj_)) {
|
||||
state_printable = 5;
|
||||
}
|
||||
|
||||
@@ -105,18 +104,6 @@ void DeviceItem::unselected()
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceItem::is_blocking_printing(MachineObject* obj_)
|
||||
{
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
std::string source_model = "";
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
void DeviceItem::update_item(const DeviceItem* item)
|
||||
{
|
||||
// Except for the selected status, everything else is updated
|
||||
|
||||
@@ -59,7 +59,6 @@ public:
|
||||
|
||||
void selected();
|
||||
void unselected();
|
||||
bool is_blocking_printing(MachineObject* obj_);
|
||||
void update_item(const DeviceItem* item);
|
||||
};
|
||||
|
||||
|
||||
@@ -2518,23 +2518,13 @@ void SelectMachineDialog::on_cancel(wxCloseEvent &event)
|
||||
|
||||
bool SelectMachineDialog::is_blocking_printing(MachineObject* obj_)
|
||||
{
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
auto target_model = obj_->printer_type;
|
||||
std::string source_model = "";
|
||||
if (m_print_type == PrintFromType::FROM_NORMAL)
|
||||
return wxGetApp().is_blocking_printing(obj_);
|
||||
|
||||
if (m_print_type == PrintFromType::FROM_NORMAL) {
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
|
||||
|
||||
}else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) {
|
||||
if (m_required_data_plate_data_list.size() > 0) {
|
||||
source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id;
|
||||
}
|
||||
}
|
||||
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
std::string source_model;
|
||||
if (m_print_type == PrintFromType::FROM_SDCARD_VIEW && !m_required_data_plate_data_list.empty())
|
||||
source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id;
|
||||
return wxGetApp().is_blocking_printing(obj_, source_model);
|
||||
}
|
||||
|
||||
static std::unordered_set<int> _get_used_nozzle_idxes()
|
||||
|
||||
@@ -738,7 +738,7 @@ void SendMultiMachinePage::on_send(wxCommandEvent& event)
|
||||
|
||||
if (obj && obj->is_online() && !obj->can_abort() && !obj->is_in_upgrading() && it->second->get_state_selected() == 1 && it->second->state_printable <= 2) {
|
||||
|
||||
if (!it->second->is_blocking_printing(obj)) {
|
||||
if (!wxGetApp().is_blocking_printing(obj)) {
|
||||
PrintParams params = request_params(obj);
|
||||
print_params.push_back(params);
|
||||
}
|
||||
|
||||
@@ -1277,7 +1277,7 @@ void SendToPrinterDialog::update_show_status()
|
||||
reset_timeout();
|
||||
|
||||
// reading done
|
||||
if (is_blocking_printing(obj_)) {
|
||||
if (wxGetApp().is_blocking_printing(obj_)) {
|
||||
show_status(PrintDialogStatus::PrintStatusUnsupportedPrinter);
|
||||
return;
|
||||
}
|
||||
@@ -1342,16 +1342,6 @@ void SendToPrinterDialog::update_show_status()
|
||||
}
|
||||
}
|
||||
|
||||
bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
|
||||
{
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
void SendToPrinterDialog::Enable_Refresh_Button(bool en)
|
||||
{
|
||||
if (!en) {
|
||||
|
||||
@@ -181,7 +181,6 @@ public:
|
||||
void reset_timeout();
|
||||
void update_user_printer();
|
||||
void update_show_status();
|
||||
bool is_blocking_printing(MachineObject* obj_);
|
||||
void prepare(int print_plate_idx);
|
||||
void check_focus(wxWindow* window);
|
||||
void check_fcous_state(wxWindow* window);
|
||||
|
||||
@@ -1863,19 +1863,13 @@ void SyncAmsInfoDialog::on_cancel(wxCloseEvent &event)
|
||||
|
||||
bool SyncAmsInfoDialog::is_blocking_printing(MachineObject *obj_)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
std::string source_model = "";
|
||||
if (m_print_type == PrintFromType::FROM_NORMAL)
|
||||
return wxGetApp().is_blocking_printing(obj_);
|
||||
|
||||
if (m_print_type == PrintFromType::FROM_NORMAL) {
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
|
||||
} else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) {
|
||||
if (m_required_data_plate_data_list.size() > 0) { source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id; }
|
||||
}
|
||||
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
std::string source_model;
|
||||
if (m_print_type == PrintFromType::FROM_SDCARD_VIEW && !m_required_data_plate_data_list.empty())
|
||||
source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id;
|
||||
return wxGetApp().is_blocking_printing(obj_, source_model);
|
||||
}
|
||||
|
||||
bool SyncAmsInfoDialog::is_same_nozzle_type(std::string &filament_type, NozzleType &tag_nozzle_type)
|
||||
|
||||
Reference in New Issue
Block a user