Merge branch 'SoftFever' into feature/more_parameters

This commit is contained in:
SoftFever 2022-10-18 18:06:39 +08:00
commit d0fab5a5bd
7 changed files with 46 additions and 50 deletions

View file

@ -129,6 +129,7 @@
"silent_mode": "0", "silent_mode": "0",
"single_extruder_multi_material": "1", "single_extruder_multi_material": "1",
"change_filament_gcode": "", "change_filament_gcode": "",
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
"layer_change_gcode": "", "layer_change_gcode": "",
"machine_pause_gcode": "M400 U1\n", "machine_pause_gcode": "M400 U1\n",
"wipe": [ "wipe": [

View file

@ -133,6 +133,7 @@
"machine_start_gcode": ";M190 S0\n;M104 S0\nPRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single]\n; You can use following code instead if your PRINT_START macro support Chamber and print area bedmesh\n; PRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single] Chamber=[chamber_temperature] PRINT_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} PRINT_MAX={first_layer_print_max[0]},{first_layer_print_max[1]}", "machine_start_gcode": ";M190 S0\n;M104 S0\nPRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single]\n; You can use following code instead if your PRINT_START macro support Chamber and print area bedmesh\n; PRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single] Chamber=[chamber_temperature] PRINT_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} PRINT_MAX={first_layer_print_max[0]},{first_layer_print_max[1]}",
"machine_end_gcode": "PRINT_END", "machine_end_gcode": "PRINT_END",
"layer_change_gcode": "", "layer_change_gcode": "",
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
"scan_first_layer": "0", "scan_first_layer": "0",
"nozzle_type": "hardened_steel", "nozzle_type": "hardened_steel",
"auxiliary_fan": "0" "auxiliary_fan": "0"

View file

@ -1164,10 +1164,10 @@ namespace DoExport {
print_statistics.clear(); print_statistics.clear();
print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges); print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges);
if (! extruders.empty()) { if (! extruders.empty()) {
//std::pair<std::string, unsigned int> out_filament_used_mm ("; filament used [mm] = ", 0); std::pair<std::string, unsigned int> out_filament_used_mm ("; filament used [mm] = ", 0);
//std::pair<std::string, unsigned int> out_filament_used_cm3("; filament used [cm3] = ", 0); std::pair<std::string, unsigned int> out_filament_used_cm3("; filament used [cm3] = ", 0);
//std::pair<std::string, unsigned int> out_filament_used_g ("; filament used [g] = ", 0); std::pair<std::string, unsigned int> out_filament_used_g ("; filament used [g] = ", 0);
//std::pair<std::string, unsigned int> out_filament_cost ("; filament cost = ", 0); std::pair<std::string, unsigned int> out_filament_cost ("; filament cost = ", 0);
for (const Extruder &extruder : extruders) { for (const Extruder &extruder : extruders) {
double used_filament = extruder.used_filament() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] : 0.f); double used_filament = extruder.used_filament() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] : 0.f);
double extruded_volume = extruder.extruded_volume() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] * 2.4052f : 0.f); // assumes 1.75mm filament diameter double extruded_volume = extruder.extruded_volume() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] * 2.4052f : 0.f); // assumes 1.75mm filament diameter
@ -1187,14 +1187,14 @@ namespace DoExport {
dst.first += buf; dst.first += buf;
++ dst.second; ++ dst.second;
}; };
//append(out_filament_used_mm, "%.2lf", used_filament); append(out_filament_used_mm, "%.2lf", used_filament);
//append(out_filament_used_cm3, "%.2lf", extruded_volume * 0.001); append(out_filament_used_cm3, "%.2lf", extruded_volume * 0.001);
if (filament_weight > 0.) { if (filament_weight > 0.) {
print_statistics.total_weight = print_statistics.total_weight + filament_weight; print_statistics.total_weight = print_statistics.total_weight + filament_weight;
//append(out_filament_used_g, "%.2lf", filament_weight); append(out_filament_used_g, "%.2lf", filament_weight);
if (filament_cost > 0.) { if (filament_cost > 0.) {
print_statistics.total_cost = print_statistics.total_cost + filament_cost; print_statistics.total_cost = print_statistics.total_cost + filament_cost;
//append(out_filament_cost, "%.2lf", filament_cost); append(out_filament_cost, "%.2lf", filament_cost);
} }
} }
print_statistics.total_used_filament += used_filament; print_statistics.total_used_filament += used_filament;
@ -1202,12 +1202,12 @@ namespace DoExport {
print_statistics.total_wipe_tower_filament += has_wipe_tower ? used_filament - extruder.used_filament() : 0.; print_statistics.total_wipe_tower_filament += has_wipe_tower ? used_filament - extruder.used_filament() : 0.;
print_statistics.total_wipe_tower_cost += has_wipe_tower ? (extruded_volume - extruder.extruded_volume())* extruder.filament_density() * 0.001 * extruder.filament_cost() * 0.001 : 0.; print_statistics.total_wipe_tower_cost += has_wipe_tower ? (extruded_volume - extruder.extruded_volume())* extruder.filament_density() * 0.001 * extruder.filament_cost() * 0.001 : 0.;
} }
//filament_stats_string_out += out_filament_used_mm.first; filament_stats_string_out += out_filament_used_mm.first;
//filament_stats_string_out += "\n" + out_filament_used_cm3.first; filament_stats_string_out += "\n" + out_filament_used_cm3.first;
//if (out_filament_used_g.second) if (out_filament_used_g.second)
//filament_stats_string_out += "\n" + out_filament_used_g.first; filament_stats_string_out += "\n" + out_filament_used_g.first;
//if (out_filament_cost.second) if (out_filament_cost.second)
// filament_stats_string_out += "\n" + out_filament_cost.first; filament_stats_string_out += "\n" + out_filament_cost.first;
} }
return filament_stats_string_out; return filament_stats_string_out;
} }
@ -1353,17 +1353,24 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
// Append full config, delimited by two 'phony' configuration keys CONFIG_BLOCK_START and CONFIG_BLOCK_END. // Append full config, delimited by two 'phony' configuration keys CONFIG_BLOCK_START and CONFIG_BLOCK_END.
// The delimiters are structured as configuration key / value pairs to be parsable by older versions of PrusaSlicer G-code viewer. // The delimiters are structured as configuration key / value pairs to be parsable by older versions of PrusaSlicer G-code viewer.
{ {
file.write_format("; hack-fix: write fake slicer info here so that Moonraker will extract thumbs.\n");
file.write_format("; %s\n\n",std::string(std::string("generated by SuperSlicer " SLIC3R_VERSION " on " ) + Slic3r::Utils::utc_timestamp()).c_str());
file.write("; CONFIG_BLOCK_START\n"); file.write("; CONFIG_BLOCK_START\n");
std::string full_config; std::string full_config;
append_full_config(print, full_config); append_full_config(print, full_config);
if (!full_config.empty()) if (!full_config.empty())
file.write(full_config); file.write(full_config);
// SoftFever: write compatiple image
std::vector<int> temps_per_bed;
int first_layer_bed_temperature = 0;
get_bed_temperature(0, true, temps_per_bed, first_layer_bed_temperature);
file.write_format("; first_layer_bed_temperature = %d\n", first_layer_bed_temperature);
file.write_format("; first_layer_temperature = %d\n", print.config().nozzle_temperature_initial_layer.get_at(0));
file.write("; CONFIG_BLOCK_END\n\n"); file.write("; CONFIG_BLOCK_END\n\n");
} }
//BBS: add plate id into thumbnail render logic //BBS: add plate id into thumbnail render logic
file.write_format("; hack-fix: write fake slicer info here so that Moonraker will extract thumbs.\n");
file.write_format("; %s\n\n",std::string(std::string("generated by PrusaSlicer " SLIC3R_VERSION " on " ) + Slic3r::Utils::utc_timestamp()).c_str());
DoExport::export_thumbnails_to_file(thumbnail_cb, print.get_plate_index(), { Vec2d(300, 300) }, DoExport::export_thumbnails_to_file(thumbnail_cb, print.get_plate_index(), { Vec2d(300, 300) },
[&file](const char* sz) { file.write(sz); }, [&file](const char* sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); }); [&print]() { print.throw_if_canceled(); });
@ -1373,8 +1380,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
const PrintObject *first_object = print.objects().front(); const PrintObject *first_object = print.objects().front();
const double layer_height = first_object->config().layer_height.value; const double layer_height = first_object->config().layer_height.value;
const double initial_layer_print_height = print.config().initial_layer_print_height.value; const double initial_layer_print_height = print.config().initial_layer_print_height.value;
//BBS: remove useless information in gcode file
#if 0
for (size_t region_id = 0; region_id < print.num_print_regions(); ++ region_id) { for (size_t region_id = 0; region_id < print.num_print_regions(); ++ region_id) {
const PrintRegion &region = print.get_print_region(region_id); const PrintRegion &region = print.get_print_region(region_id);
file.write_format("; external perimeters extrusion width = %.2fmm\n", region.flow(*first_object, frExternalPerimeter, layer_height).width()); file.write_format("; external perimeters extrusion width = %.2fmm\n", region.flow(*first_object, frExternalPerimeter, layer_height).width());
@ -1388,8 +1393,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
file.write_format("; first layer extrusion width = %.2fmm\n", region.flow(*first_object, frPerimeter, initial_layer_print_height, true).width()); file.write_format("; first layer extrusion width = %.2fmm\n", region.flow(*first_object, frPerimeter, initial_layer_print_height, true).width());
file.write_format("\n"); file.write_format("\n");
} }
print.throw_if_canceled();
#endif
file.write_format("; EXECUTABLE_BLOCK_START\n"); file.write_format("; EXECUTABLE_BLOCK_START\n");
// adds tags for time estimators // adds tags for time estimators
@ -1800,11 +1803,14 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_writer.extruders(), m_writer.extruders(),
// Modifies // Modifies
print.m_print_statistics)); print.m_print_statistics));
//file.write("\n"); file.write("\n");
//file.write_format("; total filament weight [g] = %.2lf\n", print.m_print_statistics.total_weight); file.write_format("; total filament used [g] = %.2lf\n", print.m_print_statistics.total_weight);
//file.write_format("; total filament cost = %.2lf\n", print.m_print_statistics.total_cost); file.write_format("; total filament cost = %.2lf\n", print.m_print_statistics.total_cost);
//if (print.m_print_statistics.total_toolchanges > 0) if (print.m_print_statistics.total_toolchanges > 0)
// file.write_format("; total filament change = %i\n", print.m_print_statistics.total_toolchanges); file.write_format("; total filament change = %i\n", print.m_print_statistics.total_toolchanges);
file.write_format("; total layers count = %i\n", m_layer_count);
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
print.throw_if_canceled(); print.throw_if_canceled();
} }

View file

@ -452,10 +452,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
PrintEstimatedStatistics::ETimeMode mode = static_cast<PrintEstimatedStatistics::ETimeMode>(i); PrintEstimatedStatistics::ETimeMode mode = static_cast<PrintEstimatedStatistics::ETimeMode>(i);
if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) { if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) {
char buf[128]; char buf[128];
//sprintf(buf, "; estimated printing time (%s mode) = %s\n", sprintf(buf, "; estimated printing time: %s\n", get_time_dhms(machine.time).c_str());
// (mode == PrintEstimatedStatistics::ETimeMode::Normal) ? "normal" : "silent",
// get_time_dhms(machine.time).c_str());
sprintf(buf, "; total estimated time: %s\n", get_time_dhms(machine.time).c_str());
ret += buf; ret += buf;
} }
} }

View file

@ -554,17 +554,14 @@ void Camera::look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up
void Camera::set_default_orientation() void Camera::set_default_orientation()
{ {
// BBS modify default orientation m_zenit = 45.0f;
look_at(m_target - 0.707 * m_distance * Vec3d::UnitY() + 0.707 * m_distance * Vec3d::UnitZ(), m_target, Vec3d::UnitY() + Vec3d::UnitZ());
/*m_zenit = 45.0f;
const double theta_rad = Geometry::deg2rad(-(double)m_zenit); const double theta_rad = Geometry::deg2rad(-(double)m_zenit);
const double phi_rad = Geometry::deg2rad(45.0); const double phi_rad = Geometry::deg2rad(45.0);
const double sin_theta = ::sin(theta_rad); const double sin_theta = ::sin(theta_rad);
const Vec3d camera_pos = m_target + m_distance * Vec3d(sin_theta * ::sin(phi_rad), sin_theta * ::cos(phi_rad), ::cos(theta_rad)); const Vec3d camera_pos = m_target + m_distance * Vec3d(sin_theta * ::sin(phi_rad), sin_theta * ::cos(phi_rad), ::cos(theta_rad));
m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ()); m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ());
m_view_rotation.normalize(); m_view_rotation.normalize();
m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());*/ m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());
} }
Vec3d Camera::validate_target(const Vec3d& target) const Vec3d Camera::validate_target(const Vec3d& target) const

View file

@ -4695,12 +4695,12 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
double width = volumes_box.max.x() - volumes_box.min.x(); double width = volumes_box.max.x() - volumes_box.min.x();
double depth = volumes_box.max.y() - volumes_box.min.y(); double depth = volumes_box.max.y() - volumes_box.min.y();
double height = volumes_box.max.z() - volumes_box.min.z(); double height = volumes_box.max.z() - volumes_box.min.z();
volumes_box.max.x() = volumes_box.max.x() + width * 0.25f; volumes_box.max.x() = volumes_box.max.x() + width * 0.05f;
volumes_box.min.x() = volumes_box.min.x() - width * 0.25f; volumes_box.min.x() = volumes_box.min.x() - width * 0.05f;
volumes_box.max.y() = volumes_box.max.y() + depth * 0.25f; volumes_box.max.y() = volumes_box.max.y() + depth * 0.05f;
volumes_box.min.y() = volumes_box.min.y() - depth * 0.25f; volumes_box.min.y() = volumes_box.min.y() - depth * 0.05f;
volumes_box.max.z() = volumes_box.max.z() + height * 0.25f; volumes_box.max.z() = volumes_box.max.z() + height * 0.05f;
volumes_box.min.z() = volumes_box.min.z() - height * 0.25f; volumes_box.min.z() = volumes_box.min.z() - height * 0.05f;
Camera camera; Camera camera;
camera.set_type(camera_type); camera.set_type(camera_type);
@ -4715,16 +4715,11 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
camera.zoom_to_box(volumes_box); camera.zoom_to_box(volumes_box);
const Vec3d& target = camera.get_target(); const Vec3d& target = camera.get_target();
double distance = camera.get_distance(); double distance = camera.get_distance();
//camera.select_view("topfront"); camera.select_view("iso");
camera.look_at(target - 0.707 * distance * Vec3d::UnitY() + 0.3 * distance * Vec3d::UnitZ(), target, Vec3d::UnitY() + Vec3d::UnitZ());
camera.apply_view_matrix(); camera.apply_view_matrix();
camera.apply_projection(plate_build_volume); camera.apply_projection(plate_build_volume);
//double near_z = -1.0;
//double far_z = -1.0;
//camera.apply_projection(volumes_box, near_z, far_z);
//GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); //GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr) { if (shader == nullptr) {
BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail: shader is null, return directly"); BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail: shader is null, return directly");
@ -4732,7 +4727,7 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
} }
//if (thumbnail_params.transparent_background) //if (thumbnail_params.transparent_background)
glsafe(::glClearColor(0.906f, 0.906f, 0.906f, 1.0f)); glsafe(::glClearColor(0.2f, 0.2f, 0.2f, 0.0f));
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));

View file

@ -2913,8 +2913,8 @@ void TabPrinter::build_fff()
option.opt.is_code = true; option.opt.is_code = true;
option.opt.height = gcode_field_height;//150; option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option); optgroup->append_single_option_line(option);
#if 0
optgroup = page->new_optgroup(L("Before layer change G-code"), 0); optgroup = page->new_optgroup(L("Before layer change G-code"),"param_gcode", 0);
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
validate_custom_gcode_cb(this, optgroup, opt_key, value); validate_custom_gcode_cb(this, optgroup, opt_key, value);
}; };
@ -2923,7 +2923,6 @@ void TabPrinter::build_fff()
option.opt.is_code = true; option.opt.is_code = true;
option.opt.height = gcode_field_height;//150; option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option); optgroup->append_single_option_line(option);
#endif
optgroup = page->new_optgroup(L("Layer change G-code"), L"param_gcode", 0); optgroup = page->new_optgroup(L("Layer change G-code"), L"param_gcode", 0);
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {