mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-31 23:02:06 +00:00
ENH: add filament_printable and delete unprintable and printable list
jira: none Change-Id: I643ab11831ceac1fe0793510f64b288cbd16415a (cherry picked from commit 3dd5a601547485bfcc4188727343a52c30bb6a73)
This commit is contained in:
@@ -562,7 +562,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
||||
|
||||
if (vendor && (vendor->values.size() > 0)) {
|
||||
std::string vendor_name = vendor->values[0];
|
||||
DeviceManager::check_filaments_in_blacklist(obj->printer_type, vendor_name, filamnt_type, ams_id, slot_id, it->name, in_blacklist, action, info);
|
||||
DeviceManager::check_filaments_in_blacklist(obj->printer_type, vendor_name, filamnt_type, it->filament_id, ams_id, slot_id, it->name, in_blacklist, action, info);
|
||||
}
|
||||
|
||||
if (in_blacklist) {
|
||||
|
||||
@@ -1453,7 +1453,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset
|
||||
auto vendor = dynamic_cast<ConfigOptionStrings*> (preset->config.option("filament_vendor"));
|
||||
if (vendor && (vendor->values.size() > 0)) {
|
||||
std::string vendor_name = vendor->values[0];
|
||||
DeviceManager::check_filaments_in_blacklist(curr_obj->printer_type, vendor_name, filamnt_type, ams_id, slot_id, "", in_blacklist, action, info);
|
||||
DeviceManager::check_filaments_in_blacklist(curr_obj->printer_type, vendor_name, filamnt_type, preset->filament_id, ams_id, slot_id, "", in_blacklist, action, info);
|
||||
}
|
||||
|
||||
if (in_blacklist) {
|
||||
|
||||
@@ -306,6 +306,46 @@ void check_filaments_for_vt_slot(const std::string &tag_vendor, const std::strin
|
||||
}
|
||||
}
|
||||
|
||||
bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, const std::string& filament_id, int ams_id, bool &in_blacklist, std::string &ac, std::string &info)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MachineObject *obj = dev->get_selected_machine();
|
||||
if (obj == nullptr || !obj->is_multi_extruders()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Preset *printer_preset = GUI::get_printer_preset(obj);
|
||||
if (!printer_preset)
|
||||
return true;
|
||||
|
||||
ConfigOptionInts *physical_extruder_map_op = dynamic_cast<ConfigOptionInts *>(printer_preset->config.option("physical_extruder_map"));
|
||||
if (!physical_extruder_map_op)
|
||||
return true;
|
||||
std::vector<int> physical_extruder_maps = physical_extruder_map_op->values;
|
||||
int extruder_idx = obj->get_extruder_id_by_ams_id(std::to_string(ams_id));
|
||||
for (int index = 0; index < physical_extruder_maps.size(); ++index) {
|
||||
if (physical_extruder_maps[index] == extruder_idx) {
|
||||
extruder_idx = index;
|
||||
}
|
||||
}
|
||||
|
||||
PresetBundle *preset_bundle = GUI::wxGetApp().preset_bundle;
|
||||
std::optional<FilamentBaseInfo> filament_info = preset_bundle->get_filament_by_filament_id(filament_id, printer_preset->name);
|
||||
if (filament_info.has_value() && !(filament_info->filament_printable >> extruder_idx & 1)) {
|
||||
wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right");
|
||||
ac = "prohibition";
|
||||
info = (wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name)).ToUTF8().data();
|
||||
in_blacklist = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AmsTray::update_color_from_str(std::string color)
|
||||
{
|
||||
if (color.empty()) return;
|
||||
@@ -7737,73 +7777,24 @@ void DeviceManager::OnSelectedMachineLost() {
|
||||
GUI::wxGetApp().sidebar().load_ams_list(string(), nullptr);
|
||||
}
|
||||
|
||||
bool DeviceManager::check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MachineObject *obj = dev->get_selected_machine();
|
||||
if (obj == nullptr || !obj->is_multi_extruders()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Preset *printer_preset = GUI::get_printer_preset(obj);
|
||||
if (!printer_preset)
|
||||
return true;
|
||||
|
||||
ConfigOptionInts *physical_extruder_map_op = dynamic_cast<ConfigOptionInts *>(printer_preset->config.option("physical_extruder_map"));
|
||||
if (!physical_extruder_map_op)
|
||||
return true;
|
||||
std::vector<int> physical_extruder_maps = physical_extruder_map_op->values;
|
||||
|
||||
ConfigOptionStrings *unprintable_filament_types_op = dynamic_cast<ConfigOptionStrings *>(printer_preset->config.option("unprintable_filament_types"));
|
||||
if (unprintable_filament_types_op) {
|
||||
for (size_t idx = 0; idx < unprintable_filament_types_op->values.size(); ++idx) {
|
||||
if (physical_extruder_maps[idx] == obj->get_extruder_id_by_ams_id(std::to_string(ams_id))) {
|
||||
std::vector<std::string> filament_types = split_string(unprintable_filament_types_op->values.at(idx), ',');
|
||||
auto iter = std::find(filament_types.begin(), filament_types.end(), tag_type);
|
||||
if (iter != filament_types.end()) {
|
||||
wxString extruder_name = idx == 0 ? _L("left") : _L("right");
|
||||
ac = "prohibition";
|
||||
info = (wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name)).ToUTF8().data();
|
||||
in_blacklist = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigOptionStrings *printable_filament_types_op = dynamic_cast<ConfigOptionStrings *>(printer_preset->config.option("printable_filament_types"));
|
||||
if (printable_filament_types_op) {
|
||||
for (size_t idx = 0; idx < printable_filament_types_op->values.size(); ++idx) {
|
||||
if (physical_extruder_maps[idx] == obj->get_extruder_id_by_ams_id(std::to_string(ams_id))) {
|
||||
std::vector<std::string> filament_types = split_string(printable_filament_types_op->values.at(idx), ',');
|
||||
if (!filament_types.empty()) {
|
||||
auto iter = std::find(filament_types.begin(), filament_types.end(), tag_type);
|
||||
if (iter == filament_types.end()) {
|
||||
wxString extruder_name = idx == 0 ? _L("left") : _L("right");
|
||||
ac = "prohibition";
|
||||
info = (wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name)).ToUTF8().data();
|
||||
in_blacklist = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManager::check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, int ams_id, int slot_id, std::string tag_name, bool& in_blacklist, std::string& ac, std::string& info)
|
||||
void DeviceManager::check_filaments_in_blacklist(std::string model_id,
|
||||
std::string tag_vendor,
|
||||
std::string tag_type,
|
||||
const std::string &filament_id,
|
||||
int ams_id,
|
||||
int slot_id,
|
||||
std::string tag_name,
|
||||
bool &in_blacklist,
|
||||
std::string &ac,
|
||||
std::string &info)
|
||||
{
|
||||
if (ams_id < 0 || slot_id < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!check_filaments_printable(tag_vendor, tag_type, ams_id, in_blacklist, ac, info)) {
|
||||
if (!check_filaments_printable(tag_vendor, tag_type, filament_id, ams_id, in_blacklist, ac, info)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1488,8 +1488,7 @@ public:
|
||||
static std::vector<std::string> get_resolution_supported(std::string type_str);
|
||||
static std::vector<std::string> get_compatible_machine(std::string type_str);
|
||||
static std::vector<std::string> get_unsupport_auto_cali_filaments(std::string type_str);
|
||||
static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, int ams_id, int slot_id, std::string tag_name, bool &in_blacklist, std::string &ac, std::string &info);
|
||||
static bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info);
|
||||
static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool &in_blacklist, std::string &ac, std::string &info);
|
||||
static boost::bimaps::bimap<std::string, std::string> get_all_model_id_with_name();
|
||||
static std::string load_gcode(std::string type_str, std::string gcode_file);
|
||||
static bool is_virtual_slot(int ams_id);
|
||||
|
||||
@@ -1741,38 +1741,13 @@ bool PartPlate::check_filament_printable(const DynamicPrintConfig &config, wxStr
|
||||
for (auto filament_idx : used_filaments) {
|
||||
int filament_id = filament_idx - 1;
|
||||
std::string filament_type = config.option<ConfigOptionStrings>("filament_type")->values.at(filament_id);
|
||||
int filament_printable_status = config.option<ConfigOptionInts>("filament_printable")->values.at(filament_id);
|
||||
std::vector<int> filament_map = get_real_filament_maps(config);
|
||||
int extruder_idx = filament_map[filament_id] - 1;
|
||||
std::string filament_types_str;
|
||||
auto unprintable_filament_opt = config.option<ConfigOptionStrings>("unprintable_filament_types");
|
||||
if (unprintable_filament_opt) {
|
||||
auto unprintable_filament_types = unprintable_filament_opt->values;
|
||||
if (extruder_idx < unprintable_filament_types.size())
|
||||
filament_types_str = unprintable_filament_types.at(extruder_idx);
|
||||
std::vector<string> filament_types = split_string(filament_types_str, ',');
|
||||
auto iter = std::find(filament_types.begin(), filament_types.end(), filament_type);
|
||||
if (iter != filament_types.end()) {
|
||||
wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right");
|
||||
error_message = wxString::Format(_L("The %s nozzle can not print %s."), extruder_name, filament_type);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
filament_types_str.clear();
|
||||
auto printable_filament_opt = config.option<ConfigOptionStrings>("printable_filament_types");
|
||||
if (printable_filament_opt) {
|
||||
auto printable_filament_types = printable_filament_opt->values;
|
||||
if (extruder_idx < printable_filament_types.size())
|
||||
filament_types_str = printable_filament_types.at(extruder_idx);
|
||||
std::vector<string> filament_types = split_string(filament_types_str, ',');
|
||||
if (!filament_types.empty()) {
|
||||
auto iter = std::find(filament_types.begin(), filament_types.end(), filament_type);
|
||||
if (iter == filament_types.end()) {
|
||||
wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right");
|
||||
error_message = wxString::Format(_L("The %s nozzle can not print %s."), extruder_name, filament_type);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!(filament_printable_status >> extruder_idx & 1)) {
|
||||
wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right");
|
||||
error_message = wxString::Format(_L("The %s nozzle can not print %s."), extruder_name, filament_type);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1989,7 +1989,8 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
|
||||
std::string action;
|
||||
std::string info;
|
||||
|
||||
DeviceManager::check_filaments_in_blacklist(obj_->printer_type, filament_brand, filament_type, ams_id, slot_id, "", in_blacklist, action, info);
|
||||
DeviceManager::check_filaments_in_blacklist(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist,
|
||||
action, info);
|
||||
|
||||
if (in_blacklist && action == "warning") {
|
||||
wxString prohibited_error = wxString::FromUTF8(info);
|
||||
@@ -2067,7 +2068,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
|
||||
bool in_blacklist = false;
|
||||
std::string action;
|
||||
std::string info;
|
||||
DeviceManager::check_filaments_in_blacklist(obj_->printer_type, filament_brand, filament_type, ams_id, slot_id, "", in_blacklist, action, info);
|
||||
DeviceManager::check_filaments_in_blacklist(obj_->printer_type, filament_brand, filament_type, filament_id, ams_id, slot_id, "", in_blacklist, action, info);
|
||||
|
||||
if (in_blacklist && action == "prohibition") {
|
||||
has_prohibited_filament = true;
|
||||
|
||||
Reference in New Issue
Block a user