mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-02-07 04:11:50 +03:00
Optimized and fixed some bugs
This commit is contained in:
@@ -511,6 +511,11 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
config.set_key_value("flush_length", new ConfigOptionFloat(purge_length));
|
||||
|
||||
int flush_count = std::min(g_max_flush_count, (int)std::round(purge_volume / g_purge_volume_one_time));
|
||||
|
||||
//1.9.7.52
|
||||
// handle cases for very small purge
|
||||
if (flush_count == 0 && purge_volume > 0)
|
||||
flush_count += 1;
|
||||
float flush_unit = purge_length / flush_count;
|
||||
int flush_idx = 0;
|
||||
for (; flush_idx < flush_count; flush_idx++) {
|
||||
@@ -1269,7 +1274,8 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//1.9.7.52
|
||||
m_processor.set_filaments(m_writer.extruders());
|
||||
m_processor.finalize(true);
|
||||
// DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics);
|
||||
DoExport::update_print_estimated_stats(m_processor, m_writer.extruders(), print->m_print_statistics);
|
||||
@@ -1304,13 +1310,16 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||
|
||||
// free functions called by GCode::_do_export()
|
||||
namespace DoExport {
|
||||
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool& silent_time_estimator_enabled)
|
||||
//1.9.7.52
|
||||
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool& silent_time_estimator_enabled,const std::vector<Extruder>& filaments)
|
||||
{
|
||||
silent_time_estimator_enabled = (config.gcode_flavor == gcfMarlinLegacy || config.gcode_flavor == gcfMarlinFirmware)
|
||||
&& config.silent_mode;
|
||||
processor.reset();
|
||||
processor.apply_config(config);
|
||||
processor.enable_stealth_time_estimator(silent_time_estimator_enabled);
|
||||
//1.9.7.52
|
||||
processor.set_filaments(filaments);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -1586,7 +1595,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
PROFILE_FUNC();
|
||||
|
||||
// modifies m_silent_time_estimator_enabled
|
||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||
//1.9.7.52
|
||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled, m_writer.extruders());
|
||||
// resets analyzer's tracking data
|
||||
m_last_height = 0.f;
|
||||
m_last_layer_z = 0.f;
|
||||
@@ -1669,6 +1679,15 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
//file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
|
||||
//QDS: total layer number
|
||||
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Total_Layer_Number_Placeholder).c_str());
|
||||
|
||||
//1.9.7.52
|
||||
//QDS: total filament used in mm
|
||||
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Used_Filament_Length_Placeholder).c_str());
|
||||
//QDS: total filament used in cm3
|
||||
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Used_Filament_Volume_Placeholder).c_str());
|
||||
//QDS: total filament used in g
|
||||
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Used_Filament_Weight_Placeholder).c_str());
|
||||
|
||||
//QDS: judge whether support skipping, if yes, list all label_object_id with sorted order here
|
||||
if (print.num_object_instances() <= g_max_label_object && //Don't support too many objects on one plate
|
||||
(print.num_object_instances() > 1) && //Don't support skipping single object
|
||||
@@ -2399,12 +2418,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
has_wipe_tower, print.wipe_tower_data(),
|
||||
m_writer.extruders(),
|
||||
// Modifies
|
||||
print.m_print_statistics));
|
||||
file.write("\n");*/
|
||||
//file.write_format("; total filament weight [g] = %.2lf\n", print.m_print_statistics.total_weight);
|
||||
//file.write_format("; total filament cost = %.2lf\n", print.m_print_statistics.total_cost);
|
||||
//if (print.m_print_statistics.total_toolchanges > 0)
|
||||
// file.write_format("; total filament change = %i\n", print.m_print_statistics.total_toolchanges);
|
||||
print.m_print_statistics));*/
|
||||
|
||||
bool activate_air_filtration = false;
|
||||
for (const auto& extruder : m_writer.extruders())
|
||||
@@ -4677,41 +4691,38 @@ ExtrusionPaths GCode::split_and_mapping_speed(double &other_path_v, double &fina
|
||||
ExtrusionPaths GCode::merge_same_speed_paths(const ExtrusionPaths &paths)
|
||||
{
|
||||
ExtrusionPaths output_paths;
|
||||
//1.9.7.52
|
||||
std::optional<ExtrusionPath> merged_path;
|
||||
|
||||
size_t path_idx = 0;
|
||||
int merge_start = 0;
|
||||
ExtrusionPath merge_path;
|
||||
for (; path_idx < paths.size(); path_idx++) {
|
||||
for(size_t path_idx=0;path_idx<paths.size();++path_idx){
|
||||
ExtrusionPath path = paths[path_idx];
|
||||
path.smooth_speed = get_path_speed(path);
|
||||
path.smooth_speed = get_path_speed(path);
|
||||
|
||||
// 100% overhang speed will not to set smooth speed
|
||||
if (path.role() == erOverhangPerimeter) {
|
||||
if (!merge_path.empty()) {
|
||||
output_paths.push_back(std::move(merge_path));
|
||||
merge_path.polyline.clear();
|
||||
if(path.role() == erOverhangPerimeter){
|
||||
if(merged_path.has_value()){
|
||||
output_paths.push_back(std::move(*merged_path));
|
||||
merged_path=std::nullopt;
|
||||
}
|
||||
output_paths.push_back(std::move(path));
|
||||
merge_start = path_idx + 1;
|
||||
output_paths.emplace_back(path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (merge_start == path_idx) {
|
||||
merge_path = path;
|
||||
if(!merged_path.has_value()){
|
||||
merged_path=path;
|
||||
continue;
|
||||
}
|
||||
|
||||
// merge path with same speed
|
||||
if (merge_path.smooth_speed == path.smooth_speed) {
|
||||
merge_path.polyline.append(path.polyline);
|
||||
} else {
|
||||
output_paths.push_back(std::move(merge_path));
|
||||
merge_path = path;
|
||||
if(merged_path->can_merge(path)){
|
||||
merged_path->polyline.append(path.polyline);
|
||||
}
|
||||
else{
|
||||
output_paths.push_back(std::move(*merged_path));
|
||||
merged_path = path;
|
||||
}
|
||||
}
|
||||
|
||||
if (!merge_path.empty() && merge_start < paths.size())
|
||||
output_paths.push_back(std::move(merge_path));
|
||||
if(merged_path.has_value())
|
||||
output_paths.push_back(std::move(*merged_path));
|
||||
|
||||
return output_paths;
|
||||
}
|
||||
@@ -5594,6 +5605,10 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z, bool b
|
||||
dyn_config.set_key_value("flush_length", new ConfigOptionFloat(wipe_length));
|
||||
|
||||
int flush_count = std::min(g_max_flush_count, (int)std::round(wipe_volume / g_purge_volume_one_time));
|
||||
//1.9.7.52
|
||||
// handle cases for very small purge
|
||||
if (flush_count == 0 && wipe_volume > 0)
|
||||
flush_count += 1;
|
||||
float flush_unit = wipe_length / flush_count;
|
||||
int flush_idx = 0;
|
||||
for (; flush_idx < flush_count; flush_idx++) {
|
||||
|
||||
Reference in New Issue
Block a user