Merge some BS1.7 changes:

Port object canceling for BL X1 from BS.

Todo: refactor
This commit is contained in:
SoftFever 2023-08-08 00:13:33 +08:00
parent 3acd89e877
commit 7ece35931e
15 changed files with 557 additions and 162 deletions

View file

@ -81,6 +81,13 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags_compatible = {
const std::string GCodeProcessor::Flush_Start_Tag = " FLUSH_START";
const std::string GCodeProcessor::Flush_End_Tag = " FLUSH_END";
const std::map<NozzleType,int> GCodeProcessor::Nozzle_Type_To_HRC={
{NozzleType::ntStainlessSteel,20},
{NozzleType::ntHardenedSteel,55},
{NozzleType::ntBrass,2},
{NozzleType::ntUndefine,0}
};
const float GCodeProcessor::Wipe_Width = 0.05f;
const float GCodeProcessor::Wipe_Height = 0.05f;
@ -792,6 +799,8 @@ void GCodeProcessorResult::reset() {
bed_exclude_area = Pointfs();
//BBS: add toolpath_outside
toolpath_outside = false;
//BBS: add label_object_enabled
label_object_enabled = false;
printable_height = 0.0f;
settings_ids.reset();
extruders_count = 0;
@ -817,6 +826,8 @@ void GCodeProcessorResult::reset() {
bed_exclude_area = Pointfs();
//BBS: add toolpath_outside
toolpath_outside = false;
//BBS: add label_object_enabled
label_object_enabled = false;
printable_height = 0.0f;
settings_ids.reset();
extruders_count = 0;
@ -936,7 +947,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
m_result.filament_vitrification_temperature.resize(extruders_count);
m_extruder_temps.resize(extruders_count);
m_result.nozzle_hrc = static_cast<int>(config.nozzle_hrc.getInt());
m_result.nozzle_type = config.nozzle_type;
for (size_t i = 0; i < extruders_count; ++ i) {
m_extruder_offsets[i] = to_3d(config.extruder_offset.get_at(i).cast<float>().eval(), 0.f);
m_extruder_colors[i] = static_cast<unsigned char>(i);
@ -1000,6 +1011,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
const ConfigOptionInt *nozzle_HRC = config.option<ConfigOptionInt>("nozzle_hrc");
if (nozzle_HRC != nullptr) m_result.nozzle_hrc = nozzle_HRC->value;
const ConfigOptionEnum<NozzleType>* nozzle_type = config.option<ConfigOptionEnum<NozzleType>>("nozzle_type");
if (nozzle_type != nullptr)
m_result.nozzle_type=nozzle_type->value;
const ConfigOptionEnum<GCodeFlavor>* gcode_flavor = config.option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor");
if (gcode_flavor != nullptr)
m_flavor = gcode_flavor->value;
@ -1252,6 +1267,11 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
const ConfigOptionBool* spiral_vase = config.option<ConfigOptionBool>("spiral_mode");
if (spiral_vase != nullptr)
m_spiral_vase_active = spiral_vase->value;
const ConfigOptionEnumGeneric *bed_type = config.option<ConfigOptionEnumGeneric>("curr_bed_type");
if (bed_type != nullptr)
m_result.bed_type = (BedType)bed_type->value;
}
void GCodeProcessor::enable_stealth_time_estimator(bool enabled)
@ -4305,12 +4325,16 @@ void GCodeProcessor::update_slice_warnings()
//bbs:HRC checker
warning.params.clear();
warning.level=1;
if (m_result.nozzle_hrc!=0) {
int nozzle_hrc = m_result.nozzle_hrc;
if(nozzle_hrc <= 0)
nozzle_hrc = Nozzle_Type_To_HRC.find(m_result.nozzle_type)->second;
if (nozzle_hrc!=0) {
for (size_t i = 0; i < used_extruders.size(); i++) {
int HRC=0;
if (used_extruders[i] < m_result.required_nozzle_HRC.size())
HRC = m_result.required_nozzle_HRC[used_extruders[i]];
if (HRC != 0 && (m_result.nozzle_hrc<HRC))
if (HRC != 0 && (nozzle_hrc<HRC))
warning.params.push_back(std::to_string(used_extruders[i]));
}
}

View file

@ -177,6 +177,8 @@ namespace Slic3r {
Pointfs bed_exclude_area;
//BBS: add toolpath_outside
bool toolpath_outside;
//BBS: add object_label_enabled
bool label_object_enabled;
float printable_height;
SettingsIds settings_ids;
size_t extruders_count;
@ -191,7 +193,8 @@ namespace Slic3r {
//BBS
std::vector<SliceWarning> warnings;
int nozzle_hrc;
NozzleType nozzle_type;
BedType bed_type = BedType::btCount;
#if ENABLE_GCODE_VIEWER_STATISTICS
int64_t time{ 0 };
#endif // ENABLE_GCODE_VIEWER_STATISTICS
@ -208,6 +211,7 @@ namespace Slic3r {
printable_area = other.printable_area;
bed_exclude_area = other.bed_exclude_area;
toolpath_outside = other.toolpath_outside;
label_object_enabled = other.label_object_enabled;
printable_height = other.printable_height;
settings_ids = other.settings_ids;
extruders_count = other.extruders_count;
@ -218,6 +222,7 @@ namespace Slic3r {
custom_gcode_per_print_z = other.custom_gcode_per_print_z;
spiral_vase_layers = other.spiral_vase_layers;
warnings = other.warnings;
bed_type = other.bed_type;
#if ENABLE_GCODE_VIEWER_STATISTICS
time = other.time;
#endif
@ -234,7 +239,7 @@ namespace Slic3r {
static const std::vector<std::string> Reserved_Tags_compatible;
static const std::string Flush_Start_Tag;
static const std::string Flush_End_Tag;
static const std::map<NozzleType, int>Nozzle_Type_To_HRC;
public:
enum class ETags : unsigned char
{