ENH: check wethether filaments print on first layer
Jira: none Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I1cc7cd9e9bbbcdf72112c0949196c09ef414cf91
This commit is contained in:
parent
5ae2f68d7b
commit
67039a6f4d
|
@ -1211,23 +1211,16 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
|||
m_processor.result().long_retraction_when_cut = activate_long_retraction_when_cut;
|
||||
|
||||
{ //BBS:check bed and filament compatible
|
||||
const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type");
|
||||
assert(bed_type_def != nullptr);
|
||||
const t_config_enum_values *bed_type_keys_map = bed_type_def->enum_keys_map;
|
||||
const ConfigOptionInts *bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_key(m_config.curr_bed_type));
|
||||
const ConfigOptionInts *bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_1st_layer_key(m_config.curr_bed_type));
|
||||
std::vector<int> conflict_filament;
|
||||
for(auto extruder_id : m_initial_layer_extruders){
|
||||
int cur_bed_temp = bed_temp_opt->get_at(extruder_id);
|
||||
if (cur_bed_temp == 0 && bed_type_keys_map != nullptr) {
|
||||
for (auto item : *bed_type_keys_map) {
|
||||
if (item.second == m_config.curr_bed_type) {
|
||||
m_processor.result().bed_match_result = BedMatchResult(false, item.first, extruder_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cur_bed_temp == 0) {
|
||||
conflict_filament.push_back(extruder_id);
|
||||
}
|
||||
if (m_processor.result().bed_match_result.match == false)
|
||||
break;
|
||||
}
|
||||
|
||||
m_processor.result().filament_printable_reuslt = FilamentPrintableResult(conflict_filament, bed_type_to_gcode_string(m_config.curr_bed_type));
|
||||
}
|
||||
m_processor.set_filaments(m_writer.extruders());
|
||||
m_processor.finalize(true);
|
||||
|
|
|
@ -960,7 +960,6 @@ void GCodeProcessorResult::reset() {
|
|||
filament_costs = std::vector<float>(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_COST);
|
||||
custom_gcode_per_print_z = std::vector<CustomGCode::Item>();
|
||||
spiral_vase_layers = std::vector<std::pair<float, std::pair<size_t, size_t>>>();
|
||||
bed_match_result = BedMatchResult(true);
|
||||
warnings.clear();
|
||||
|
||||
//BBS: add mutex for protection of gcode result
|
||||
|
|
|
@ -117,23 +117,23 @@ namespace Slic3r {
|
|||
ConflictResult() = default;
|
||||
};
|
||||
|
||||
struct BedMatchResult
|
||||
{
|
||||
bool match;
|
||||
std::string bed_type_name;
|
||||
int extruder_id;
|
||||
BedMatchResult():match(true),bed_type_name(""),extruder_id(-1) {}
|
||||
BedMatchResult(bool _match,const std::string& _bed_type_name="",int _extruder_id=-1)
|
||||
:match(_match),bed_type_name(_bed_type_name),extruder_id(_extruder_id)
|
||||
{}
|
||||
};
|
||||
|
||||
using ConflictResultOpt = std::optional<ConflictResult>;
|
||||
|
||||
struct FilamentPrintableResult
|
||||
{
|
||||
std::vector<int> conflict_filament;
|
||||
std::string plate_name;
|
||||
FilamentPrintableResult(){};
|
||||
FilamentPrintableResult(std::vector<int> &conflict_filament, std::string plate_name) : conflict_filament(conflict_filament), plate_name(plate_name) {}
|
||||
bool has_value(){
|
||||
return !conflict_filament.empty();
|
||||
};
|
||||
};
|
||||
|
||||
struct GCodeProcessorResult
|
||||
{
|
||||
ConflictResultOpt conflict_result;
|
||||
BedMatchResult bed_match_result;
|
||||
FilamentPrintableResult filament_printable_reuslt;
|
||||
|
||||
struct SettingsIds
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ namespace Slic3r {
|
|||
spiral_vase_layers = other.spiral_vase_layers;
|
||||
warnings = other.warnings;
|
||||
bed_type = other.bed_type;
|
||||
bed_match_result = other.bed_match_result;
|
||||
filament_printable_reuslt = other.filament_printable_reuslt;
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
time = other.time;
|
||||
#endif
|
||||
|
|
|
@ -1123,6 +1123,7 @@ 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); }
|
||||
|
||||
filament_printable_reuslt = gcode_result.filament_printable_reuslt;
|
||||
//BBS: add mutex for protection of gcode result
|
||||
gcode_result.unlock();
|
||||
//BBS: add logs
|
||||
|
|
|
@ -738,6 +738,8 @@ public:
|
|||
|
||||
//BBS
|
||||
ConflictResultOpt m_conflict_result;
|
||||
FilamentPrintableResult filament_printable_reuslt;
|
||||
|
||||
private:
|
||||
std::vector<int> m_plater_extruder;
|
||||
bool m_gl_data_initialized{ false };
|
||||
|
|
|
@ -2897,6 +2897,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::FilamentUnPrintableOnFirstLayer);
|
||||
}
|
||||
|
||||
m_gcode_viewer.refresh(gcode_result, str_tool_colors);
|
||||
|
@ -9446,14 +9447,15 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
|
|||
if (wxGetApp().is_editor()) {
|
||||
if (current_printer_technology() != ptSLA) {
|
||||
unsigned int max_z_layer = m_gcode_viewer.get_layers_z_range().back();
|
||||
if (warning == EWarning::ToolHeightOutside) // check if max z_layer height exceed max print height
|
||||
if (warning == EWarning::ToolHeightOutside) // check if max z_layer height exceed max print height
|
||||
show = m_gcode_viewer.has_data() && (m_gcode_viewer.get_layers_zs()[max_z_layer] - m_gcode_viewer.get_max_print_height() >= 1e-6);
|
||||
else if (warning == EWarning::ToolpathOutside) { // check if max x,y coords exceed bed area
|
||||
show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed() &&
|
||||
(m_gcode_viewer.get_max_print_height() -m_gcode_viewer.get_layers_zs()[max_z_layer] >= 1e-6);
|
||||
}
|
||||
else if (warning == EWarning::GCodeConflict)
|
||||
(m_gcode_viewer.get_max_print_height() - m_gcode_viewer.get_layers_zs()[max_z_layer] >= 1e-6);
|
||||
} 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::FilamentUnPrintableOnFirstLayer)
|
||||
show = m_gcode_viewer.has_data() && m_gcode_viewer.filament_printable_reuslt.has_value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9523,6 +9525,18 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
|||
"Please solve the problem by moving it totally on or off the plate, and confirming that the height is within the build volume.");
|
||||
error = ErrorType::PLATER_ERROR;
|
||||
break;
|
||||
case EWarning::FilamentUnPrintableOnFirstLayer: {
|
||||
std::string warning;
|
||||
const std::vector<int> &conflict_filament = m_gcode_viewer.filament_printable_reuslt.conflict_filament;
|
||||
auto iter = conflict_filament.begin();
|
||||
for (int filament : conflict_filament) {
|
||||
warning += std::to_string(filament + 1);
|
||||
warning+=" ";
|
||||
}
|
||||
text = (boost::format(_u8L("filaments %s cannot be printed directly on the surface of %s")) % warning % m_gcode_viewer.filament_printable_reuslt.plate_name).str();
|
||||
error = ErrorType::SLICING_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//BBS: this may happened when exit the app, plater is null
|
||||
if (!wxGetApp().plater())
|
||||
|
|
|
@ -377,7 +377,8 @@ class GLCanvas3D
|
|||
SomethingNotShown,
|
||||
ObjectClashed,
|
||||
GCodeConflict,
|
||||
ToolHeightOutside
|
||||
ToolHeightOutside,
|
||||
FilamentUnPrintableOnFirstLayer
|
||||
};
|
||||
|
||||
class RenderStats
|
||||
|
|
Loading…
Reference in New Issue