update src

This commit is contained in:
QIDI TECH
2024-11-28 15:23:54 +08:00
parent 7eb6543991
commit 79518648c0
37 changed files with 615 additions and 14023 deletions

View File

@@ -145,7 +145,8 @@ std::map<int, std::string> cli_errors = {
{CLI_OBJECT_COLLISION_IN_LAYER_PRINT, "Object conflicts were detected. Please verify the slicing of all plates in QIDI Studio before uploading."},
{CLI_SPIRAL_MODE_INVALID_PARAMS, "Some slicing parameters cannot work with Spiral Vase mode. Please solve the issue in QIDI Studio before uploading."},
{CLI_SLICING_ERROR, "Failed slicing the model. Please verify the slicing of all plates on QIDI Studio before uploading."},
{CLI_GCODE_PATH_CONFLICTS, " G-code conflicts detected after slicing. Please make sure the 3mf file can be successfully sliced in the latest QIDI Studio."}
{CLI_GCODE_PATH_CONFLICTS, " G-code conflicts detected after slicing. Please make sure the 3mf file can be successfully sliced in the latest QIDI Studio."},
{CLI_FILAMENT_UNPRINTABLE_ON_FIRST_LAYER, "Found some filament unprintable at first layer on current Plate. Please make sure the 3mf file can be successfully sliced with the same Plate type in the latest QIDI Studio."}
};
typedef struct _sliced_plate_info{
@@ -651,6 +652,11 @@ static int load_assemble_plate_list(std::string config_file, std::vector<assembl
return CLI_CONFIG_FILE_ERROR;
}
if (object_json.contains(JSON_ASSEMPLE_SUBTYPE))
assemble_object.subtype = ModelVolume::type_from_string(object_json[JSON_ASSEMPLE_SUBTYPE]);
else
assemble_object.subtype = ModelVolumeType::MODEL_PART;
assemble_object.filaments = object_json.at(JSON_ASSEMPLE_OBJECT_FILAMENTS).get<std::vector<int>>();
if ((assemble_object.filaments.size() > 0) && (assemble_object.filaments.size() != assemble_object.count) && (assemble_object.filaments.size() != 1))
{
@@ -751,7 +757,7 @@ static int load_assemble_plate_list(std::string config_file, std::vector<assembl
return ret;
}
void merge_or_add_object(assemble_plate_info_t& assemble_plate_info, Model &model, int assemble_index, std::map<int, ModelObject*> &merged_objects, ModelObject *ori_object)
void merge_or_add_object(assemble_plate_info_t& assemble_plate_info, Model &model, int assemble_index, std::map<int, ModelObject*> &merged_objects, ModelObject *ori_object, ModelVolumeType type)
{
if (assemble_index > 0) {
auto iter = merged_objects.find(assemble_index);
@@ -762,17 +768,21 @@ void merge_or_add_object(assemble_plate_info_t& assemble_plate_info, Model &mode
new_object->name = "assemble_" + std::to_string(assemble_index);
merged_objects[assemble_index] = new_object;
assemble_plate_info.loaded_obj_list.emplace_back(new_object);
new_object->config.assign_config(ori_object->config.get());
//new_object->config.assign_config(ori_object->config.get());
}
else
new_object = iter->second;
for (auto volume : ori_object->volumes) {
ModelVolume* new_volume = new_object->add_volume(*volume);
ModelVolume* new_volume = new_object->add_volume(*volume, type);
// set extruder id
new_volume->config.set_key_value("extruder", new ConfigOptionInt(ori_object->config.extruder()));
//new_volume->config.set_key_value("extruder", new ConfigOptionInt(ori_object->config.extruder()));
if (type == ModelVolumeType::MODEL_PART || type == ModelVolumeType::PARAMETER_MODIFIER)
{
new_volume->config.apply(ori_object->config);
}
}
BOOST_LOG_TRIVIAL(debug) << boost::format("assemble_index %1%, name %2%, merged to new model %3%") % assemble_index % ori_object->name % new_object->name;
BOOST_LOG_TRIVIAL(debug) << boost::format("assemble_index %1%, name %2%, merged to new model %3%, subtype %4%") % assemble_index % ori_object->name % new_object->name %(int)type;
}
else {
ModelObject* new_object = model.add_object(*ori_object);
@@ -932,7 +942,7 @@ static int construct_assemble_list(std::vector<assemble_plate_info_t>& assemble_
return CLI_DATA_FILE_ERROR;
}
}
else if (boost::algorithm::iends_with(assemble_object.path, ".obj"))
else if ((boost::algorithm::iends_with(assemble_object.path, ".obj")) && assemble_object.subtype == ModelVolumeType::MODEL_PART)
{
std::string message;
ObjInfo obj_info;
@@ -982,7 +992,7 @@ static int construct_assemble_list(std::vector<assemble_plate_info_t>& assemble_
obj_temp_model.clear_materials();
}
else {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": unsupported file %1%, plate index %2%, object index %3%") % assemble_object.path % (index + 1) % (obj_index + 1);
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": unsupported file %1%, plate index %2%, object index %3%, subtype %4%") % assemble_object.path % (index + 1) % (obj_index + 1) %(int)(assemble_object.subtype);
return CLI_INVALID_PARAMS;
}
//1.9.5
@@ -1008,6 +1018,10 @@ static int construct_assemble_list(std::vector<assemble_plate_info_t>& assemble_
if (!assemble_object.height_ranges.empty())
{
if (assemble_object.subtype != ModelVolumeType::MODEL_PART) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": only normal part can have height ranges, file %1%, plate index %2%, object index %3%, subtype %4%") % assemble_object.path % (index + 1) % (obj_index + 1) %(int)(assemble_object.subtype);
return CLI_INVALID_PARAMS;
}
for (int range_index = 0; range_index < assemble_object.height_ranges.size(); range_index++)
{
height_range_info_t& range = assemble_object.height_ranges[range_index];
@@ -1027,11 +1041,21 @@ static int construct_assemble_list(std::vector<assemble_plate_info_t>& assemble_
assemble_object.pos_y.resize(1, 0.f);
if (assemble_object.pos_z.empty())
assemble_object.pos_z.resize(1, 0.f);
if (assemble_object.assemble_index.empty())
if (assemble_object.assemble_index.empty()) {
if (assemble_object.subtype != ModelVolumeType::MODEL_PART) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": only normal part can be used as individual object, file %1%, plate index %2%, object index %3%, subtype %4%") % assemble_object.path % (index + 1) % (obj_index + 1) %(int)(assemble_object.subtype);
return CLI_INVALID_PARAMS;
}
assemble_object.assemble_index.resize(1, 0);
}
if ((assemble_object.subtype != ModelVolumeType::MODEL_PART)&&(assemble_object.assemble_index[0] == 0)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": only normal part can have height ranges, file %1%, plate index %2%, object index %3%, subtype %4%") % assemble_object.path % (index + 1) % (obj_index + 1) %(int)(assemble_object.subtype);
return CLI_INVALID_PARAMS;
}
object->translate(assemble_object.pos_x[0], assemble_object.pos_y[0], assemble_object.pos_z[0]);
merge_or_add_object(assemble_plate_info, model, assemble_object.assemble_index[0], merged_objects, object);
merge_or_add_object(assemble_plate_info, model, assemble_object.assemble_index[0], merged_objects, object, assemble_object.subtype);
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": object %1%, name %2%, pos_x %3% pos_y %4%, pos_z %5%, filament %6%, assemble_index %7%")
%obj_index %object->name %assemble_object.pos_x[0] %assemble_object.pos_y[0] %assemble_object.pos_z[0] %assemble_object.filaments[0] %assemble_object.assemble_index[0];
@@ -1063,7 +1087,13 @@ static int construct_assemble_list(std::vector<assemble_plate_info_t>& assemble_
array_index = copy_index;
else
array_index = 0;
merge_or_add_object(assemble_plate_info, model, assemble_object.assemble_index[array_index], merged_objects, copy_obj);
if ((assemble_object.subtype != ModelVolumeType::MODEL_PART)&&(assemble_object.assemble_index[array_index] == 0)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": only normal part can have height ranges, file %1%, plate index %2%, object index %3%, subtype %4%, copy_index %5%")
% assemble_object.path % (index + 1) % (obj_index + 1) %(int)(assemble_object.subtype) %copy_index;
return CLI_INVALID_PARAMS;
}
merge_or_add_object(assemble_plate_info, model, assemble_object.assemble_index[array_index], merged_objects, copy_obj, assemble_object.subtype);
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": cloned object %1%, name %2%, pos_x %3% pos_y %4%, pos_z %5%")
%copy_index %object->name %assemble_object.pos_x[array_index] %assemble_object.pos_y[array_index] %assemble_object.pos_z[array_index];
@@ -1264,6 +1294,7 @@ int CLI::run(int argc, char **argv)
const std::vector<std::string> &uptodate_filaments = m_config.option<ConfigOptionStrings>("uptodate_filaments", true)->values;
std::vector<std::string> downward_settings = m_config.option<ConfigOptionStrings>("downward_settings", true)->values;
std::vector<std::string> downward_compatible_machines;
std::set<std::string> downward_uncompatible_machines;
//QDS: always use ForwardCompatibilitySubstitutionRule::Enable
//const ForwardCompatibilitySubstitutionRule config_substitution_rule = m_config.option<ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>>("config_compatibility", true)->value;
const ForwardCompatibilitySubstitutionRule config_substitution_rule = ForwardCompatibilitySubstitutionRule::Enable;
@@ -1350,7 +1381,7 @@ int CLI::run(int argc, char **argv)
//QDS: add plate data related logic
PlateDataPtrs plate_data_src;
std::vector<plate_obj_size_info_t> plate_obj_size_infos;
int arrange_option;
//int arrange_option;
int plate_to_slice = 0, filament_count = 0, duplicate_count = 0, real_duplicate_count = 0;
bool first_file = true, is_qdt_3mf = false, need_arrange = true, has_thumbnails = false, up_config_to_date = false, normative_check = true, duplicate_single_object = false, use_first_fila_as_default = false, minimum_save = false, enable_timelapse = false;
bool allow_rotations = true, skip_modified_gcodes = false, avoid_extrusion_cali_region = false, skip_useless_pick = false, allow_newer_file = false;
@@ -1550,7 +1581,7 @@ int CLI::run(int argc, char **argv)
// QDS: adjust whebackup
//LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig|LoadStrategy::AddDefaultInstances;
//if (load_aux) strategy = strategy | LoadStrategy::LoadAuxiliary;
model = Model::read_from_file(file, &config, &config_substitutions, strategy, &plate_data_src, &project_presets, &is_qdt_3mf, &file_version, nullptr, nullptr, nullptr, nullptr, nullptr, plate_to_slice);
model = Model::read_from_file(file, &config, &config_substitutions, strategy, &plate_data_src, &project_presets, &is_qdt_3mf, &file_version, nullptr, nullptr, nullptr, plate_to_slice);
if (is_qdt_3mf)
{
if (!first_file)
@@ -1708,7 +1739,7 @@ int CLI::run(int argc, char **argv)
{
ModelObject* object = model.objects[obj_index];
for (unsigned int clone_index = 1; clone_index < clone_count; clone_index++)
for (int clone_index = 1; clone_index < clone_count; clone_index++)
{
ModelObject* newObj = model.add_object(*object);
newObj->name = object->name +"_"+ std::to_string(clone_index+1);
@@ -3642,19 +3673,29 @@ int CLI::run(int argc, char **argv)
}
}
}
if (failed_count < downward_check_size)
for (int index2 = 0; index2 < downward_check_size; index2 ++)
{
//has success ones
BOOST_LOG_TRIVIAL(info) << boost::format("downward_check: downward_check_size %1%, failed_count %2%")%downward_check_size %failed_count;
for (int index2 = 0; index2 < downward_check_size; index2 ++)
{
if (downward_check_status[index2])
continue;
printer_plate_info_t& plate_info = downward_check_printers[index2];
BOOST_LOG_TRIVIAL(info) << boost::format("downward_check: found compatible printer %1%")%plate_info.printer_name;
downward_compatible_machines.push_back(plate_info.printer_name);
printer_plate_info_t& plate_info = downward_check_printers[index2];
if (downward_check_status[index2]) {
downward_uncompatible_machines.emplace(plate_info.printer_name);
BOOST_LOG_TRIVIAL(info) << boost::format("downward_check: found uncompatible printer %1%")%plate_info.printer_name;
}
else {
downward_compatible_machines.push_back(plate_info.printer_name);
BOOST_LOG_TRIVIAL(info) << boost::format("downward_check: found compatible printer %1%")%plate_info.printer_name;
}
}
BOOST_LOG_TRIVIAL(info) << boost::format("downward_check: downward_check_size %1%, failed_count %2%")%downward_check_size %failed_count;
sliced_info.downward_machines = downward_compatible_machines;
for(std::vector<std::string>::iterator it = sliced_info.upward_machines.begin(); it != sliced_info.upward_machines.end();){
if(downward_uncompatible_machines.find(*it) != downward_uncompatible_machines.end()){
BOOST_LOG_TRIVIAL(info) << boost::format("downward_check: remove %1% from upward compatible printers")%*it;
it = sliced_info.upward_machines.erase(it);
} else {
it ++;
}
sliced_info.downward_machines = downward_compatible_machines;
}
}
@@ -4176,12 +4217,11 @@ int CLI::run(int argc, char **argv)
arrange_cfg.align_to_y_axis = (printer_structure_opt->value == PrinterStructure::psI3);
}
arrangement::update_arrange_params(arrange_cfg, &m_print_config, selected);
arrangement::update_selected_items_inflation(selected, &m_print_config, arrange_cfg);
arrangement::update_unselected_items_inflation(unselected, &m_print_config, arrange_cfg);
arrangement::update_selected_items_axis_align(selected, &m_print_config, arrange_cfg);
arrangement::update_arrange_params(arrange_cfg, m_print_config, selected);
arrangement::update_selected_items_inflation(selected, m_print_config, arrange_cfg);
arrangement::update_unselected_items_inflation(unselected, m_print_config, arrange_cfg);
beds = get_shrink_bedpts(&m_print_config, arrange_cfg);
beds = get_shrink_bedpts(m_print_config, arrange_cfg);
partplate_list.preprocess_exclude_areas(arrange_cfg.excluded_regions, 1, scale_(1));
@@ -4577,12 +4617,11 @@ int CLI::run(int argc, char **argv)
arrange_cfg.align_to_y_axis = (printer_structure_opt->value == PrinterStructure::psI3);
}
arrangement::update_arrange_params(arrange_cfg, &m_print_config, selected);
arrangement::update_selected_items_inflation(selected, &m_print_config, arrange_cfg);
arrangement::update_unselected_items_inflation(unselected, &m_print_config, arrange_cfg);
arrangement::update_selected_items_axis_align(selected, &m_print_config, arrange_cfg);
arrangement::update_arrange_params(arrange_cfg, m_print_config, selected);
arrangement::update_selected_items_inflation(selected, m_print_config, arrange_cfg);
arrangement::update_unselected_items_inflation(unselected, m_print_config, arrange_cfg);
beds=get_shrink_bedpts(&m_print_config, arrange_cfg);
beds=get_shrink_bedpts(m_print_config, arrange_cfg);
partplate_list.preprocess_exclude_areas(arrange_cfg.excluded_regions, 1, scale_(1));
@@ -4987,7 +5026,7 @@ int CLI::run(int argc, char **argv)
// continue;
for (int instance_idx = 0; instance_idx < (int)model_object.instances.size(); ++ instance_idx) {
const ModelInstance &model_instance = *model_object.instances[instance_idx];
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, "volume", true, false, true);
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, "volume", true, false, true, false);
//glvolume_collection.volumes.back()->geometry_id = key.geometry_id;
std::string color = filament_color?filament_color->get_at(volume_extruder_id - 1):"#00FF00FF";
@@ -5370,14 +5409,14 @@ int CLI::run(int argc, char **argv)
bool is_qdt_vendor_preset = false;
if (!printer_model_string.empty()) {
is_qdt_vendor_preset = (printer_model_string.compare(0, 9, "QIDI Lab") == 0);
is_qdt_vendor_preset = (printer_model_string.compare(0, 9, "QIDI Tech") == 0);
BOOST_LOG_TRIVIAL(info) << boost::format("printer_model_string: %1%, is_qdt_vendor_preset %2%")%printer_model_string %is_qdt_vendor_preset;
}
else {
if (!new_printer_name.empty())
is_qdt_vendor_preset = (new_printer_name.compare(0, 9, "QIDI Lab") == 0);
is_qdt_vendor_preset = (new_printer_name.compare(0, 9, "QIDI Tech") == 0);
else if (!current_printer_system_name.empty())
is_qdt_vendor_preset = (current_printer_system_name.compare(0, 9, "QIDI Lab") == 0);
is_qdt_vendor_preset = (current_printer_system_name.compare(0, 9, "QIDI Tech") == 0);
BOOST_LOG_TRIVIAL(info) << boost::format("new_printer_name: %1%, current_printer_system_name %2%, is_qdt_vendor_preset %3%")%new_printer_name %current_printer_system_name %is_qdt_vendor_preset;
}
(dynamic_cast<Print*>(print))->set_QDT_Printer(is_qdt_vendor_preset);
@@ -5508,6 +5547,13 @@ int CLI::run(int argc, char **argv)
slice_time[TIME_USING_CACHE] = slice_time[TIME_USING_CACHE] + ((long long)Slic3r::Utils::get_current_milliseconds_time_utc() - temp_time);
BOOST_LOG_TRIVIAL(info) << "export_gcode finished: time_using_cache update to " << slice_time[TIME_USING_CACHE] << " secs.";
if (gcode_result && gcode_result->filament_printable_reuslt.has_value()) {
//found gcode error
BOOST_LOG_TRIVIAL(error) << "plate " << index + 1 << ": found some filament unprintable on current bed- "<< gcode_result->filament_printable_reuslt.plate_name << std::endl;
record_exit_reson(outfile_dir, CLI_FILAMENT_UNPRINTABLE_ON_FIRST_LAYER, index + 1, cli_errors[CLI_FILAMENT_UNPRINTABLE_ON_FIRST_LAYER], sliced_info);
flush_and_exit(CLI_FILAMENT_UNPRINTABLE_ON_FIRST_LAYER);
}
//outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
//m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
}/* else {
@@ -5868,7 +5914,7 @@ int CLI::run(int argc, char **argv)
// continue;
for (int instance_idx = 0; instance_idx < (int)model_object.instances.size(); ++ instance_idx) {
const ModelInstance &model_instance = *model_object.instances[instance_idx];
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, "volume", true, false, true);
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, "volume", true, false, true, false);
//glvolume_collection.volumes.back()->geometry_id = key.geometry_id;
std::string color = filament_color?filament_color->get_at(volume_extruder_id - 1):"#00FF00FF";