mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
fix: dedupe compatible printer type check
This commit is contained in:
@@ -1648,23 +1648,8 @@ bool CalibrationPresetPage::is_blocking_printing()
|
||||
if (obj_ == nullptr) return true;
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
auto target_model = obj_->printer_type;
|
||||
|
||||
if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) ||
|
||||
DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source_model != target_model) {
|
||||
std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
|
||||
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
|
||||
if (it == compatible_machine.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
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
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "DevConfigUtil.h"
|
||||
|
||||
#include "slic3r/GUI/DeviceManager.hpp"
|
||||
|
||||
#include <wx/dir.h>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include "../I18N.hpp"
|
||||
@@ -41,6 +43,19 @@ static void _toolhead_translation_markers()
|
||||
|
||||
std::string DevPrinterConfigUtil::m_resource_file_path = "";
|
||||
|
||||
bool DevPrinterConfigUtil::is_printer_model_compatible(const std::string& source_model, MachineObject& machine)
|
||||
{
|
||||
const std::string& target_model = machine.printer_type;
|
||||
if (is_optional_printer_model_id(source_model) || is_optional_printer_model_id(target_model))
|
||||
return true;
|
||||
|
||||
if (source_model == target_model)
|
||||
return true;
|
||||
|
||||
const auto compatible_machine = machine.get_compatible_machine();
|
||||
return std::find(compatible_machine.begin(), compatible_machine.end(), source_model) != compatible_machine.end();
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::string> DevPrinterConfigUtil::get_all_model_id_with_name()
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
namespace Slic3r
|
||||
{
|
||||
|
||||
class MachineObject;
|
||||
|
||||
/// Toolhead component type (extruder / nozzle / hotend)
|
||||
enum class ToolHeadComponent {
|
||||
Extruder,
|
||||
@@ -61,19 +63,8 @@ public:
|
||||
static std::map<std::string, std::string> get_all_model_id_with_name();
|
||||
// A printer agent may not know the physical model. Keep that case optional so
|
||||
// model compatibility checks do not turn missing identity into a hard error.
|
||||
static bool is_optional_printer_model_id(const std::string& model_id)
|
||||
{
|
||||
if (model_id.empty())
|
||||
return true;
|
||||
if (model_id.size() != 9)
|
||||
return false;
|
||||
|
||||
static constexpr char generic_model_id[] = "orcasonar";
|
||||
return std::equal(model_id.begin(), model_id.end(), generic_model_id,
|
||||
[](char lhs, char rhs) {
|
||||
return static_cast<char>(std::tolower(static_cast<unsigned char>(lhs))) == rhs;
|
||||
});
|
||||
}
|
||||
static bool is_printer_model_compatible(const std::string& source_model, MachineObject& machine);
|
||||
static bool is_optional_printer_model_id(const std::string& model_id) { return model_id.empty(); }
|
||||
static std::string get_printer_type(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "printer_type"); }
|
||||
static std::string get_printer_display_name(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "display_name"); }
|
||||
static std::string get_printer_series_str(std::string type_str) { return get_value_from_config<std::string>(type_str, "printer_series"); }
|
||||
|
||||
@@ -2382,14 +2382,8 @@ bool GUI_App::is_blocking_printing(MachineObject *obj_)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return true;
|
||||
std::string target_model;
|
||||
if (obj_ == nullptr) {
|
||||
obj_ = dev->get_selected_machine();
|
||||
if (obj_) {
|
||||
target_model = obj_->printer_type;
|
||||
}
|
||||
} else {
|
||||
target_model = obj_->printer_type;
|
||||
}
|
||||
|
||||
if (!obj_)
|
||||
@@ -2400,19 +2394,7 @@ bool GUI_App::is_blocking_printing(MachineObject *obj_)
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
std::string source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
|
||||
if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) ||
|
||||
DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source_model != target_model) {
|
||||
std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
|
||||
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
|
||||
if (it == compatible_machine.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
// If formatted for github, plaintext with OpenGL extensions enclosed into <details>.
|
||||
|
||||
@@ -109,26 +109,12 @@ bool DeviceItem::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 = "";
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
|
||||
if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) ||
|
||||
DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source_model != target_model) {
|
||||
std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
|
||||
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
|
||||
if (it == compatible_machine.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
void DeviceItem::update_item(const DeviceItem* item)
|
||||
|
||||
@@ -2534,20 +2534,7 @@ bool SelectMachineDialog::is_blocking_printing(MachineObject* obj_)
|
||||
}
|
||||
}
|
||||
|
||||
if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) ||
|
||||
DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source_model != target_model) {
|
||||
std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
|
||||
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
|
||||
if (it == compatible_machine.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
static std::unordered_set<int> _get_used_nozzle_idxes()
|
||||
|
||||
@@ -1349,22 +1349,7 @@ bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
auto target_model = obj_->printer_type;
|
||||
|
||||
if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) ||
|
||||
DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source_model != target_model) {
|
||||
std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
|
||||
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
|
||||
if (it == compatible_machine.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
void SendToPrinterDialog::Enable_Refresh_Button(bool en)
|
||||
|
||||
@@ -1863,7 +1863,6 @@ bool SyncAmsInfoDialog::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) {
|
||||
@@ -1874,18 +1873,7 @@ bool SyncAmsInfoDialog::is_blocking_printing(MachineObject *obj_)
|
||||
if (m_required_data_plate_data_list.size() > 0) { source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id; }
|
||||
}
|
||||
|
||||
if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) ||
|
||||
DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source_model != target_model) {
|
||||
std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
|
||||
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
|
||||
if (it == compatible_machine.end()) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
return !DevPrinterConfigUtil::is_printer_model_compatible(source_model, *obj_);
|
||||
}
|
||||
|
||||
bool SyncAmsInfoDialog::is_same_nozzle_type(std::string &filament_type, NozzleType &tag_nozzle_type)
|
||||
|
||||
Reference in New Issue
Block a user