ENH: CLI: some refines of slicing

1. add support_used flag in sliced_info
2. use the old thumbnail if no need

Change-Id: I8ad166978fe6f76f86b1ef014945dd70b26a6285
This commit is contained in:
lane.wei 2022-11-14 21:59:49 +08:00 committed by Lane.Wei
parent 0713945e02
commit c431cbf202
6 changed files with 329 additions and 235 deletions

View File

@ -654,9 +654,9 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << "start_gui="<< start_gui << std::endl; BOOST_LOG_TRIVIAL(info) << "start_gui="<< start_gui << std::endl;
//BBS: add plate data related logic //BBS: add plate data related logic
PlateDataPtrs plate_data; PlateDataPtrs plate_data_src;
int arrange_option; int arrange_option;
bool first_file = true, is_bbl_3mf = false, need_arrange = true; bool first_file = true, is_bbl_3mf = false, need_arrange = true, has_thumbnails = false;
Semver file_version; Semver file_version;
std::map<size_t, bool> orients_requirement; std::map<size_t, bool> orients_requirement;
std::vector<Preset*> project_presets; std::vector<Preset*> project_presets;
@ -696,7 +696,7 @@ int CLI::run(int argc, char **argv)
// BBS: adjust whebackup // BBS: adjust whebackup
//LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig|LoadStrategy::AddDefaultInstances; //LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig|LoadStrategy::AddDefaultInstances;
//if (load_aux) strategy = strategy | LoadStrategy::LoadAuxiliary; //if (load_aux) strategy = strategy | LoadStrategy::LoadAuxiliary;
model = Model::read_from_file(file, &config, &config_substitutions, strategy, &plate_data, &project_presets, &is_bbl_3mf, &file_version); model = Model::read_from_file(file, &config, &config_substitutions, strategy, &plate_data_src, &project_presets, &is_bbl_3mf, &file_version);
if (is_bbl_3mf) if (is_bbl_3mf)
{ {
if (!first_file) if (!first_file)
@ -704,7 +704,7 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << "The BBL 3mf file should be placed at the first position, filename=" << file << "\n"; BOOST_LOG_TRIVIAL(info) << "The BBL 3mf file should be placed at the first position, filename=" << file << "\n";
flush_and_exit(CLI_FILELIST_INVALID_ORDER); flush_and_exit(CLI_FILELIST_INVALID_ORDER);
} }
BOOST_LOG_TRIVIAL(info) << "the first file is a 3mf, got plate count:" << plate_data.size() << "\n"; BOOST_LOG_TRIVIAL(info) << "the first file is a 3mf, got plate count:" << plate_data_src.size() << "\n";
need_arrange = false; need_arrange = false;
for (ModelObject* o : model.objects) for (ModelObject* o : model.objects)
{ {
@ -841,10 +841,9 @@ int CLI::run(int argc, char **argv)
plate_stride = partplate_list.plate_stride_x(); plate_stride = partplate_list.plate_stride_x();
BOOST_LOG_TRIVIAL(info) << "bed size, x="<<bedfs[2].x() - bedfs[0].x()<<",y="<<bedfs[2].y() - bedfs[0].y()<<",z="<< print_height <<"\n"; BOOST_LOG_TRIVIAL(info) << "bed size, x="<<bedfs[2].x() - bedfs[0].x()<<",y="<<bedfs[2].y() - bedfs[0].y()<<",z="<< print_height <<"\n";
} }
if (plate_data.size() > 0) if (plate_data_src.size() > 0)
{ {
partplate_list.load_from_3mf_structure(plate_data); partplate_list.load_from_3mf_structure(plate_data_src);
release_PlateData_list(plate_data);
} }
/*for (ModelObject *model_object : m_models[0].objects) /*for (ModelObject *model_object : m_models[0].objects)
for (ModelInstance *model_instance : model_object->instances) for (ModelInstance *model_instance : model_object->instances)
@ -1088,6 +1087,7 @@ int CLI::run(int argc, char **argv)
} }
BOOST_LOG_TRIVIAL(info) << "finished model pre-process commands\n"; BOOST_LOG_TRIVIAL(info) << "finished model pre-process commands\n";
bool oriented_or_arranged = false;
//BBS: add orient and arrange logic here //BBS: add orient and arrange logic here
for (auto& model : m_models) for (auto& model : m_models)
{ {
@ -1097,6 +1097,7 @@ int CLI::run(int argc, char **argv)
{ {
BOOST_LOG_TRIVIAL(info) << "Before process command, Orient object, name=" << o->name <<",id="<<o->id().id<<std::endl; BOOST_LOG_TRIVIAL(info) << "Before process command, Orient object, name=" << o->name <<",id="<<o->id().id<<std::endl;
orientation::orient(o); orientation::orient(o);
oriented_or_arranged = true;
} }
else else
{ {
@ -1106,6 +1107,7 @@ int CLI::run(int argc, char **argv)
} }
//BBS: clear the orient objects lists //BBS: clear the orient objects lists
orients_requirement.clear(); orients_requirement.clear();
oriented_or_arranged |= need_arrange;
if (need_arrange) if (need_arrange)
{ {
@ -1532,6 +1534,7 @@ int CLI::run(int argc, char **argv)
} }
#endif #endif
bool need_regenerate_thumbnail = oriented_or_arranged;
// get type and color for platedata // get type and color for platedata
auto* filament_types = dynamic_cast<const ConfigOptionStrings*>(m_print_config.option("filament_type")); auto* filament_types = dynamic_cast<const ConfigOptionStrings*>(m_print_config.option("filament_type"));
const ConfigOptionStrings* filament_color = dynamic_cast<const ConfigOptionStrings *>(m_print_config.option("filament_colour")); const ConfigOptionStrings* filament_color = dynamic_cast<const ConfigOptionStrings *>(m_print_config.option("filament_colour"));
@ -1544,8 +1547,22 @@ int CLI::run(int argc, char **argv)
it->color = filament_color?filament_color->get_at(it->id):"#FFFFFF"; it->color = filament_color?filament_color->get_at(it->id):"#FFFFFF";
//it->filament_id = filament_id?filament_id->get_at(it->id):"unknown"; //it->filament_id = filament_id?filament_id->get_at(it->id):"unknown";
} }
if (!plate_data->plate_thumbnail.is_valid()) {
if (!oriented_or_arranged && plate_data_src.size() > i)
plate_data->thumbnail_file = plate_data_src[i]->thumbnail_file;
BOOST_LOG_TRIVIAL(info) << boost::format("thumbnails stage: plate %1%'s thumbnail data is invalid, check the file %2% exist or not")%(i+1) %plate_data->thumbnail_file;
if (plate_data->thumbnail_file.empty() || (!boost::filesystem::exists(plate_data->thumbnail_file))) {
BOOST_LOG_TRIVIAL(info) << boost::format("thumbnails stage: plate %1%'s thumbnail file also not there, need to regenerate")%(i+1);
need_regenerate_thumbnail = true;
}
else {
BOOST_LOG_TRIVIAL(info) << boost::format("thumbnails stage: plate %1%'s thumbnail file exists, no need to regenerate")%(i+1);
}
}
} }
if (need_regenerate_thumbnail) {
std::vector<std::string> colors; std::vector<std::string> colors;
if (filament_color) { if (filament_color) {
colors= filament_color->vserialize(); colors= filament_color->vserialize();
@ -1649,6 +1666,13 @@ int CLI::run(int argc, char **argv)
else { else {
for (int i = 0; i < partplate_list.get_plate_count(); i++) { for (int i = 0; i < partplate_list.get_plate_count(); i++) {
Slic3r::GUI::PartPlate *part_plate = partplate_list.get_plate(i); Slic3r::GUI::PartPlate *part_plate = partplate_list.get_plate(i);
PlateData *plate_data = plate_data_list[i];
if (plate_data->plate_thumbnail.is_valid()) {
thumbnails.push_back(&plate_data->plate_thumbnail);
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1% has a valid thumbnail, width %2%, height %3% directly using it")%(i+1) %plate_data->plate_thumbnail.width %plate_data->plate_thumbnail.height;
continue;
}
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1%'s thumbnail, need to regenerate")%(i+1);
ThumbnailData * thumbnail_data = new ThumbnailData(); ThumbnailData * thumbnail_data = new ThumbnailData();
unsigned int thumbnail_width = 256, thumbnail_height = 256; unsigned int thumbnail_width = 256, thumbnail_height = 256;
const ThumbnailsParams thumbnail_params = {{}, false, true, true, true, i}; const ThumbnailsParams thumbnail_params = {{}, false, true, true, true, i};
@ -1676,11 +1700,30 @@ int CLI::run(int argc, char **argv)
break; break;
} }
thumbnails.push_back(thumbnail_data); thumbnails.push_back(thumbnail_data);
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1%'s thumbnail,finished rendering")%(i+1);
}
}
}
//BBS: release glfw
glfwTerminate();
}
else {
for (int i = 0; i < partplate_list.get_plate_count(); i++) {
PlateData *plate_data = plate_data_list[i];
if (plate_data->plate_thumbnail.is_valid()) {
thumbnails.push_back(&plate_data->plate_thumbnail);
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1% has a valid thumbnail data, width %2%, height %3% directly using it")%(i+1) %plate_data->plate_thumbnail.width %plate_data->plate_thumbnail.height;
}
}
}
//generate first layer bboxes
for (int i = 0; i < partplate_list.get_plate_count(); i++) {
Slic3r::GUI::PartPlate *part_plate = partplate_list.get_plate(i);
//render calibration thumbnail //render calibration thumbnail
if (!part_plate->get_slice_result() || !part_plate->is_slice_result_valid()) { if (!part_plate->get_slice_result() || !part_plate->is_slice_result_valid()) {
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1% doesn't have a valid sliced result, skip it")%(i+1); BOOST_LOG_TRIVIAL(info) << boost::format("plate %1% doesn't have a valid sliced result, skip it")%(i+1);
calibration_thumbnails.push_back(new ThumbnailData()); //calibration_thumbnails.push_back(new ThumbnailData());
plate_bboxes.push_back(new PlateBBoxData()); plate_bboxes.push_back(new PlateBBoxData());
continue; continue;
} }
@ -1758,8 +1801,7 @@ int CLI::run(int argc, char **argv)
plate_bbox->bbox_all = { bbox_all.min.x(),bbox_all.min.y(),bbox_all.max.x(),bbox_all.max.y() }; plate_bbox->bbox_all = { bbox_all.min.x(),bbox_all.min.y(),bbox_all.max.x(),bbox_all.max.y() };
plate_bboxes.push_back(plate_bbox); plate_bboxes.push_back(plate_bbox);
} }
}
}
#if defined(__linux__) || defined(__LINUX__) #if defined(__linux__) || defined(__LINUX__)
if (g_cli_callback_mgr.is_started()) { if (g_cli_callback_mgr.is_started()) {
@ -1785,9 +1827,9 @@ int CLI::run(int argc, char **argv)
delete plate_bboxes[i]; delete plate_bboxes[i];
} }
//BBS: release glfw if (plate_data_src.size() > 0)
if (export_to_3mf) { {
glfwTerminate(); release_PlateData_list(plate_data_src);
} }
#if defined(__linux__) || defined(__LINUX__) #if defined(__linux__) || defined(__LINUX__)

View File

@ -247,6 +247,8 @@ static constexpr const char* PLATE_IDX_ATTR = "index";
static constexpr const char* SLICE_PREDICTION_ATTR = "prediction"; static constexpr const char* SLICE_PREDICTION_ATTR = "prediction";
static constexpr const char* SLICE_WEIGHT_ATTR = "weight"; static constexpr const char* SLICE_WEIGHT_ATTR = "weight";
static constexpr const char* OUTSIDE_ATTR = "outside"; static constexpr const char* OUTSIDE_ATTR = "outside";
static constexpr const char* SUPPORT_USED_ATTR = "support_used";
static constexpr const char* OBJECT_TYPE = "object"; static constexpr const char* OBJECT_TYPE = "object";
static constexpr const char* VOLUME_TYPE = "volume"; static constexpr const char* VOLUME_TYPE = "volume";
@ -1084,7 +1086,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
} }
//BBS progress point //BBS progress point
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_STAGE_OPEN\n"); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_STAGE_OPEN, m_load_restore=%1%\n")%m_load_restore;
if (proFn) { if (proFn) {
proFn(IMPORT_STAGE_OPEN, 0, 1, cb_cancel); proFn(IMPORT_STAGE_OPEN, 0, 1, cb_cancel);
if (cb_cancel) if (cb_cancel)
@ -1500,7 +1502,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
// model.adjust_min_z(); // model.adjust_min_z();
//BBS progress point //BBS progress point
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_STAGE_LOADING_PLATES, m_plater_data size %1%\n")%m_plater_data.size(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_STAGE_LOADING_PLATES, m_plater_data size %1%, m_backup_path %2%\n")%m_plater_data.size() %m_backup_path;
if (proFn) { if (proFn) {
proFn(IMPORT_STAGE_LOADING_PLATES, 0, 1, cb_cancel); proFn(IMPORT_STAGE_LOADING_PLATES, 0, 1, cb_cancel);
if (cb_cancel) if (cb_cancel)
@ -1530,12 +1532,14 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
plate_data_list[it->first-1]->gcode_prediction = it->second->gcode_prediction; plate_data_list[it->first-1]->gcode_prediction = it->second->gcode_prediction;
plate_data_list[it->first-1]->gcode_weight = it->second->gcode_weight; plate_data_list[it->first-1]->gcode_weight = it->second->gcode_weight;
plate_data_list[it->first-1]->toolpath_outside = it->second->toolpath_outside; plate_data_list[it->first-1]->toolpath_outside = it->second->toolpath_outside;
plate_data_list[it->first-1]->is_support_used = it->second->is_support_used;
plate_data_list[it->first-1]->slice_filaments_info = it->second->slice_filaments_info; plate_data_list[it->first-1]->slice_filaments_info = it->second->slice_filaments_info;
plate_data_list[it->first-1]->warnings = it->second->warnings; plate_data_list[it->first-1]->warnings = it->second->warnings;
plate_data_list[it->first-1]->thumbnail_file = (m_load_restore || it->second->thumbnail_file.empty()) ? it->second->thumbnail_file : m_backup_path + "/" + it->second->thumbnail_file; plate_data_list[it->first-1]->thumbnail_file = (m_load_restore || it->second->thumbnail_file.empty()) ? it->second->thumbnail_file : m_backup_path + "/" + it->second->thumbnail_file;
plate_data_list[it->first-1]->pattern_file = (m_load_restore || it->second->pattern_file.empty()) ? it->second->pattern_file : m_backup_path + "/" + it->second->pattern_file; plate_data_list[it->first-1]->pattern_file = (m_load_restore || it->second->pattern_file.empty()) ? it->second->pattern_file : m_backup_path + "/" + it->second->pattern_file;
plate_data_list[it->first-1]->pattern_bbox_file = (m_load_restore || it->second->pattern_bbox_file.empty()) ? it->second->pattern_bbox_file : m_backup_path + "/" + it->second->pattern_bbox_file; plate_data_list[it->first-1]->pattern_bbox_file = (m_load_restore || it->second->pattern_bbox_file.empty()) ? it->second->pattern_bbox_file : m_backup_path + "/" + it->second->pattern_bbox_file;
plate_data_list[it->first-1]->config = it->second->config; plate_data_list[it->first-1]->config = it->second->config;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", plate %1%, thumbnail_file=%2%")%it->first %plate_data_list[it->first-1]->thumbnail_file;
it++; it++;
} }
@ -3206,6 +3210,11 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
if (m_curr_plater) if (m_curr_plater)
std::istringstream(value) >> std::boolalpha >> m_curr_plater->toolpath_outside; std::istringstream(value) >> std::boolalpha >> m_curr_plater->toolpath_outside;
} }
else if (key == SUPPORT_USED_ATTR)
{
if (m_curr_plater)
std::istringstream(value) >> std::boolalpha >> m_curr_plater->is_support_used;
}
} }
return true; return true;
@ -4117,6 +4126,24 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
} }
} }
} }
else if (!m_skip_static && plate_data_list.size() > 0) {
for (int i = 0; i < plate_data_list.size(); i++) {
PlateData *plate_data = plate_data_list[i];
if (proFn) {
proFn(EXPORT_STAGE_ADD_THUMBNAILS, i, plate_data_list.size(), cb_cancel);
if (cb_cancel)
return false;
}
if (!plate_data->thumbnail_file.empty() && (boost::filesystem::exists(plate_data->thumbnail_file))){
std::string dst_in_3mf = (boost::format("Metadata/plate_%1%.png") % (i + 1)).str();
if (!_add_file_to_archive(archive, dst_in_3mf, plate_data->thumbnail_file)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":" << __LINE__ << boost::format(", add thumbnail %1% from file %2% failed\n") % (i+1) %plate_data->thumbnail_file;
return false;
}
}
}
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format(",before add calibration thumbnails, count %1%\n")%calibration_data.size(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format(",before add calibration thumbnails, count %1%\n")%calibration_data.size();
//BBS add calibration thumbnail for each plate //BBS add calibration thumbnail for each plate
@ -5604,6 +5631,10 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
std::string thumbnail_file_in_3mf = (boost::format(THUMBNAIL_FILE_FORMAT) % (plate_data->plate_index + 1)).str(); std::string thumbnail_file_in_3mf = (boost::format(THUMBNAIL_FILE_FORMAT) % (plate_data->plate_index + 1)).str();
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << THUMBNAIL_FILE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha << thumbnail_file_in_3mf << "\"/>\n"; stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << THUMBNAIL_FILE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha << thumbnail_file_in_3mf << "\"/>\n";
} }
else if (!plate_data->thumbnail_file.empty() && (boost::filesystem::exists(plate_data->thumbnail_file))){
std::string thumbnail_file_in_3mf = (boost::format(THUMBNAIL_FILE_FORMAT) % (plate_data->plate_index + 1)).str();
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << THUMBNAIL_FILE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha << thumbnail_file_in_3mf << "\"/>\n";
}
if (!plate_data->pattern_file.empty()) { if (!plate_data->pattern_file.empty()) {
std::string pattern_file_in_3mf = (boost::format(PATTERN_FILE_FORMAT) % (plate_data->plate_index + 1)).str(); std::string pattern_file_in_3mf = (boost::format(PATTERN_FILE_FORMAT) % (plate_data->plate_index + 1)).str();
@ -5713,6 +5744,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_PREDICTION_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_prediction_str() << "\"/>\n"; stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_PREDICTION_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_prediction_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_WEIGHT_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_weight_str() << "\"/>\n"; stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_WEIGHT_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_weight_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OUTSIDE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->toolpath_outside << "\"/>\n"; stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OUTSIDE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->toolpath_outside << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SUPPORT_USED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_support_used << "\"/>\n";
for (auto it = plate_data->slice_filaments_info.begin(); it != plate_data->slice_filaments_info.end(); it++) for (auto it = plate_data->slice_filaments_info.begin(); it != plate_data->slice_filaments_info.end(); it++)
{ {

View File

@ -68,6 +68,7 @@ struct PlateData
std::string gcode_weight; std::string gcode_weight;
std::vector<FilamentInfo> slice_filaments_info; std::vector<FilamentInfo> slice_filaments_info;
DynamicPrintConfig config; DynamicPrintConfig config;
bool is_support_used {false};
bool is_sliced_valid = false; bool is_sliced_valid = false;
bool toolpath_outside {false}; bool toolpath_outside {false};

View File

@ -720,6 +720,8 @@ public:
void export_gcode_from_previous_file(const std::string& file, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr); void export_gcode_from_previous_file(const std::string& file, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
//BBS: add modify_count logic //BBS: add modify_count logic
int get_modified_count() const {return m_modified_count;} int get_modified_count() const {return m_modified_count;}
//BBS: add status for whether support used
bool is_support_used() const {return m_support_used;}
//BBS //BBS
static StringObjectException sequential_print_clearance_valid(const Print &print, Polygons *polygons = nullptr, std::vector<std::pair<Polygon, float>>* height_polygons = nullptr); static StringObjectException sequential_print_clearance_valid(const Print &print, Polygons *polygons = nullptr, std::vector<std::pair<Polygon, float>>* height_polygons = nullptr);
@ -769,6 +771,7 @@ private:
// Estimated print time, filament consumed. // Estimated print time, filament consumed.
PrintStatistics m_print_statistics; PrintStatistics m_print_statistics;
bool m_support_used {false};
//BBS: plate's origin //BBS: plate's origin
Vec3d m_origin; Vec3d m_origin;

View File

@ -1031,6 +1031,11 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", i=%1%, key=%2%")%i %changed_keys[i]; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", i=%1%, key=%2%")%i %changed_keys[i];
} }
} }
const ConfigOption* enable_support_option = new_full_config.option("enable_support");
if (enable_support_option && enable_support_option->getBool())
m_support_used = true;
else
m_support_used = false;
// Find modified keys of the various configs. Resolve overrides extruder retract values by filament profiles. // Find modified keys of the various configs. Resolve overrides extruder retract values by filament profiles.
DynamicPrintConfig filament_overrides; DynamicPrintConfig filament_overrides;
@ -1550,7 +1555,10 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
// If it is not valid, then it is ensured that PrintObject.m_slicing_params is not in use // If it is not valid, then it is ensured that PrintObject.m_slicing_params is not in use
// (posSlicing and posSupportMaterial was invalidated). // (posSlicing and posSupportMaterial was invalidated).
for (PrintObject *object : m_objects) for (PrintObject *object : m_objects)
{
object->update_slicing_parameters(); object->update_slicing_parameters();
m_support_used |= object->config().enable_support;
}
#ifdef _DEBUG #ifdef _DEBUG
check_model_ids_equal(m_model, model); check_model_ids_equal(m_model, model);
@ -1559,7 +1567,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
//BBS: add timestamp logic //BBS: add timestamp logic
if (apply_status != APPLY_STATUS_UNCHANGED) if (apply_status != APPLY_STATUS_UNCHANGED)
m_modified_count++; m_modified_count++;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: finished, this %2%, m_modified_count %3%, apply_status %4%, ")%__LINE__ %this %m_modified_count %apply_status; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: finished, this %2%, m_modified_count %3%, apply_status %4%, m_support_used %5%")%__LINE__ %this %m_modified_count %apply_status %m_support_used;
return static_cast<ApplyStatus>(apply_status); return static_cast<ApplyStatus>(apply_status);
} }

View File

@ -4157,7 +4157,11 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
PlateData* plate_data_item = new PlateData(); PlateData* plate_data_item = new PlateData();
plate_data_item->locked = m_plate_list[i]->m_locked; plate_data_item->locked = m_plate_list[i]->m_locked;
plate_data_item->plate_index = m_plate_list[i]->m_plate_index; plate_data_item->plate_index = m_plate_list[i]->m_plate_index;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1% before load, width %2%, height %3%, size %4%!")
%(i+1) %m_plate_list[i]->thumbnail_data.width %m_plate_list[i]->thumbnail_data.height %m_plate_list[i]->thumbnail_data.pixels.size();
plate_data_item->plate_thumbnail.load_from(m_plate_list[i]->thumbnail_data); plate_data_item->plate_thumbnail.load_from(m_plate_list[i]->thumbnail_data);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1% after load, width %2%, height %3%, size %4%!")
%(i+1) %plate_data_item->plate_thumbnail.width %plate_data_item->plate_thumbnail.height %plate_data_item->plate_thumbnail.pixels.size();
plate_data_item->config.apply(*m_plate_list[i]->config()); plate_data_item->config.apply(*m_plate_list[i]->config());
if (m_plate_list[i]->obj_to_instance_set.size() > 0) if (m_plate_list[i]->obj_to_instance_set.size() > 0)
@ -4191,6 +4195,7 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
CNumericLocalesSetter locales_setter; CNumericLocalesSetter locales_setter;
plate_data_item->gcode_weight =wxString::Format("%.2f", ps.total_weight).ToStdString(); plate_data_item->gcode_weight =wxString::Format("%.2f", ps.total_weight).ToStdString();
} }
plate_data_item->is_support_used = print->is_support_used();
} else { } else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("print is null!"); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("print is null!");
} }
@ -4229,8 +4234,8 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
{ {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(":plate index %1% seems invalid, skip it")% plate_data_list[i]->plate_index; BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(":plate index %1% seems invalid, skip it")% plate_data_list[i]->plate_index;
} }
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1%, gcode_file %2%, is_sliced_valid %3%, toolpath_outside %4%") BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1%, gcode_file %2%, is_sliced_valid %3%, toolpath_outside %4%, is_support_used %5%")
%i %plate_data_list[i]->gcode_file %plate_data_list[i]->is_sliced_valid %plate_data_list[i]->toolpath_outside; %i %plate_data_list[i]->gcode_file %plate_data_list[i]->is_sliced_valid %plate_data_list[i]->toolpath_outside %plate_data_list[i]->is_support_used;
//load object and instance from 3mf //load object and instance from 3mf
//just test for file correct or not, we will rebuild later //just test for file correct or not, we will rebuild later
/*for (std::vector<std::pair<int, int>>::iterator it = plate_data_list[i]->objects_and_instances.begin(); it != plate_data_list[i]->objects_and_instances.end(); ++it) /*for (std::vector<std::pair<int, int>>::iterator it = plate_data_list[i]->objects_and_instances.begin(); it != plate_data_list[i]->objects_and_instances.end(); ++it)
@ -4254,8 +4259,11 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
m_plate_list[index]->slice_filaments_info = plate_data_list[i]->slice_filaments_info; m_plate_list[index]->slice_filaments_info = plate_data_list[i]->slice_filaments_info;
gcode_result->warnings = plate_data_list[i]->warnings; gcode_result->warnings = plate_data_list[i]->warnings;
if (m_plater && !plate_data_list[i]->thumbnail_file.empty()) { if (m_plater && !plate_data_list[i]->thumbnail_file.empty()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1%, load thumbnail from %2%.")%(i+1) %plate_data_list[i]->thumbnail_file;
if (boost::filesystem::exists(plate_data_list[i]->thumbnail_file)) { if (boost::filesystem::exists(plate_data_list[i]->thumbnail_file)) {
m_plate_list[index]->load_thumbnail_data(plate_data_list[i]->thumbnail_file); m_plate_list[index]->load_thumbnail_data(plate_data_list[i]->thumbnail_file);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ <<boost::format(": plate %1% after load, width %2%, height %3%, size %4%!")
%(i+1) %m_plate_list[index]->thumbnail_data.width %m_plate_list[index]->thumbnail_data.height %m_plate_list[index]->thumbnail_data.pixels.size();
} }
} }