mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-03 00:02:14 +00:00
ENH: Add gcode check for multi_extruder
jira: none Change-Id: Iebc43e608c4509eb62b280af2d401fa9e0e089ba (cherry picked from commit c75c10e312b8d0bd5404d92db88c95a9e6186bc1)
This commit is contained in:
@@ -1078,6 +1078,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
|
||||
BuildVolume plate_build_volume(pp_bed_shape, build_volume.printable_height(), build_volume.extruder_areas());
|
||||
const std::vector<BoundingBoxf3>& exclude_areas = curr_plate->get_exclude_areas();
|
||||
|
||||
curr_plate->clear_unprintable_filament_ids();
|
||||
for (GLVolume* volume : this->volumes)
|
||||
{
|
||||
if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0))) {
|
||||
@@ -1094,6 +1095,17 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
|
||||
{
|
||||
std::vector<bool> inside_extruders;
|
||||
state = plate_build_volume.check_volume_bbox_state_with_extruder_areas(bb, inside_extruders);
|
||||
if (state == BuildVolume::ObjectState::Limited) {
|
||||
const ModelObjectPtrs &model_objects = model.objects;
|
||||
ModelObject *model_object = model_objects[volume->object_idx()];
|
||||
ModelVolume *model_volume = model_object->volumes[volume->volume_idx()];
|
||||
for (size_t i = 0; i < inside_extruders.size(); ++i) {
|
||||
if (!inside_extruders[i]) {
|
||||
std::vector<int> extruders = model_volume->get_extruders();
|
||||
curr_plate->append_unprintable_filament_ids(i, extruders);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1094,6 +1094,8 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||
m_conflict_result = gcode_result.conflict_result;
|
||||
if (m_conflict_result) { m_conflict_result.value().layer = m_layers.get_l_at(m_conflict_result.value()._height); }
|
||||
|
||||
m_gcode_check_result = gcode_result.gcode_check_result;
|
||||
|
||||
//BBS: add mutex for protection of gcode result
|
||||
gcode_result.unlock();
|
||||
//BBS: add logs
|
||||
|
||||
@@ -736,6 +736,7 @@ public:
|
||||
|
||||
//BBS
|
||||
ConflictResultOpt m_conflict_result;
|
||||
GCodeCheckResult m_gcode_check_result;
|
||||
private:
|
||||
std::vector<int> m_plater_extruder;
|
||||
bool m_gl_data_initialized{ false };
|
||||
|
||||
@@ -2906,6 +2906,7 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
|
||||
_set_warning_notification_if_needed(EWarning::ToolHeightOutside);
|
||||
_set_warning_notification_if_needed(EWarning::ToolpathOutside);
|
||||
_set_warning_notification_if_needed(EWarning::GCodeConflict);
|
||||
_set_warning_notification_if_needed(EWarning::MultiExtruderPrintableError);
|
||||
}
|
||||
|
||||
m_gcode_viewer.refresh(gcode_result, str_tool_colors);
|
||||
@@ -9646,6 +9647,8 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
|
||||
}
|
||||
else if (warning == EWarning::GCodeConflict)
|
||||
show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.m_conflict_result.has_value();
|
||||
else if (warning == EWarning::MultiExtruderPrintableError)
|
||||
show = m_gcode_viewer.has_data() && m_gcode_viewer.m_gcode_check_result.error_code != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9690,6 +9693,25 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
case EWarning::ObjectOutside: text = _u8L("An object is laid over the plate boundaries."); break;
|
||||
case EWarning::ToolHeightOutside: text = _u8L("A G-code path goes beyond the max print height."); error = ErrorType::SLICING_ERROR; break;
|
||||
case EWarning::ToolpathOutside: text = _u8L("A G-code path goes beyond the plate boundaries."); error = ErrorType::SLICING_ERROR; break;
|
||||
case EWarning::MultiExtruderPrintableError: {
|
||||
text.clear();
|
||||
for (auto error_iter = m_gcode_viewer.m_gcode_check_result.error_infos.begin(); error_iter != m_gcode_viewer.m_gcode_check_result.error_infos.end(); ++error_iter) {
|
||||
if (error_iter != m_gcode_viewer.m_gcode_check_result.error_infos.begin()) {
|
||||
text += "\n";
|
||||
}
|
||||
int extruder_id = error_iter->first + 1;
|
||||
std::string filaments;
|
||||
for (size_t i = 0; i < error_iter->second.size(); ++i) {
|
||||
if (i > 0) {
|
||||
filaments += ", ";
|
||||
}
|
||||
filaments += std::to_string(error_iter->second[i] + 1);
|
||||
}
|
||||
text += (boost::format(_u8L("Extruder %d conflicts with filaments: %s.")) %extruder_id %filaments).str();
|
||||
}
|
||||
error = ErrorType::SLICING_ERROR;
|
||||
break;
|
||||
}
|
||||
// BBS: remove _u8L() for SLA
|
||||
case EWarning::SlaSupportsOutside: text = ("SLA supports outside the print area were detected."); error = ErrorType::PLATER_ERROR; break;
|
||||
case EWarning::SomethingNotShown: text = _u8L("Only the object being edited is visible."); break;
|
||||
|
||||
@@ -382,7 +382,8 @@ class GLCanvas3D
|
||||
ObjectClashed,
|
||||
ObjectLimited,
|
||||
GCodeConflict,
|
||||
ToolHeightOutside
|
||||
ToolHeightOutside,
|
||||
MultiExtruderPrintableError, // after slice
|
||||
};
|
||||
|
||||
class RenderStats
|
||||
|
||||
@@ -2898,6 +2898,7 @@ void PartPlate::update_slice_context(BackgroundSlicingProcess & process)
|
||||
process.select_technology(this->printer_technology);
|
||||
process.set_current_plate(this);
|
||||
m_print->set_status_callback(statuscb);
|
||||
m_print->set_unprintable_filament_ids(m_unprintable_filament_ids);
|
||||
process.switch_print_preprocess();
|
||||
|
||||
return;
|
||||
@@ -3223,6 +3224,14 @@ std::vector<int> PartPlate::get_filament_maps()
|
||||
return filament_maps;
|
||||
}
|
||||
|
||||
void PartPlate::append_unprintable_filament_ids(int extruder_id, const std::vector<int> &filament_ids)
|
||||
{
|
||||
if (extruder_id > m_unprintable_filament_ids.size()) {
|
||||
m_unprintable_filament_ids.resize(extruder_id + 1);
|
||||
}
|
||||
m_unprintable_filament_ids[extruder_id].insert(m_unprintable_filament_ids[extruder_id].end(), filament_ids.begin(), filament_ids.end());
|
||||
}
|
||||
|
||||
void PartPlate::set_filament_maps(const std::vector<int>& f_maps)
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
@@ -112,6 +112,9 @@ private:
|
||||
std::vector<FilamentInfo> slice_filaments_info;
|
||||
int m_print_index;
|
||||
|
||||
// filament ids of extruder
|
||||
std::vector<std::vector<int>> m_unprintable_filament_ids;
|
||||
|
||||
std::string m_tmp_gcode_path; //use a temp path to store the gcode
|
||||
std::string m_temp_config_3mf_path; //use a temp path to store the config 3mf
|
||||
std::string m_gcode_path_from_3mf; //use a path to store the gcode loaded from 3mf
|
||||
@@ -497,6 +500,11 @@ public:
|
||||
std::vector<int> get_filament_maps();
|
||||
void set_filament_maps(const std::vector<int>& f_maps);
|
||||
|
||||
const std::vector<std::vector<int>> &get_unprintable_filament_ids() const { return m_unprintable_filament_ids; }
|
||||
void set_unprintable_filament_ids(const std::vector<std::vector<int>> &filament_ids) { m_unprintable_filament_ids = filament_ids; }
|
||||
void clear_unprintable_filament_ids() { m_unprintable_filament_ids.clear(); }
|
||||
void append_unprintable_filament_ids(int extruder_id, const std::vector<int> &filament_ids);
|
||||
|
||||
void on_extruder_count_changed(int extruder_count);
|
||||
void set_filament_count(int filament_count);
|
||||
void on_filament_added();
|
||||
|
||||
Reference in New Issue
Block a user