From b8fb80c17f3fd6814a5ec72f96f15fdcc7b0dcba Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 18 Oct 2022 00:18:06 +0800 Subject: [PATCH 1/2] bring back ISO view! --- src/slic3r/GUI/Camera.cpp | 7 ++----- src/slic3r/GUI/GLCanvas3D.cpp | 21 ++++++++------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp index ca37795489..24a7388e71 100644 --- a/src/slic3r/GUI/Camera.cpp +++ b/src/slic3r/GUI/Camera.cpp @@ -554,17 +554,14 @@ void Camera::look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up void Camera::set_default_orientation() { - // BBS modify default orientation - 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; + m_zenit = 45.0f; const double theta_rad = Geometry::deg2rad(-(double)m_zenit); const double phi_rad = Geometry::deg2rad(45.0); 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)); m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ()); 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 diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index c948b351df..fdc78d2226 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4695,12 +4695,12 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const double width = volumes_box.max.x() - volumes_box.min.x(); double depth = volumes_box.max.y() - volumes_box.min.y(); double height = volumes_box.max.z() - volumes_box.min.z(); - volumes_box.max.x() = volumes_box.max.x() + width * 0.25f; - volumes_box.min.x() = volumes_box.min.x() - width * 0.25f; - volumes_box.max.y() = volumes_box.max.y() + depth * 0.25f; - volumes_box.min.y() = volumes_box.min.y() - depth * 0.25f; - volumes_box.max.z() = volumes_box.max.z() + height * 0.25f; - volumes_box.min.z() = volumes_box.min.z() - height * 0.25f; + volumes_box.max.x() = volumes_box.max.x() + width * 0.05f; + volumes_box.min.x() = volumes_box.min.x() - width * 0.05f; + volumes_box.max.y() = volumes_box.max.y() + depth * 0.05f; + volumes_box.min.y() = volumes_box.min.y() - depth * 0.05f; + volumes_box.max.z() = volumes_box.max.z() + height * 0.05f; + volumes_box.min.z() = volumes_box.min.z() - height * 0.05f; Camera camera; camera.set_type(camera_type); @@ -4715,16 +4715,11 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const camera.zoom_to_box(volumes_box); const Vec3d& target = camera.get_target(); double distance = camera.get_distance(); - //camera.select_view("topfront"); - camera.look_at(target - 0.707 * distance * Vec3d::UnitY() + 0.3 * distance * Vec3d::UnitZ(), target, Vec3d::UnitY() + Vec3d::UnitZ()); + camera.select_view("iso"); camera.apply_view_matrix(); 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"); if (shader == nullptr) { 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) - 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(::glEnable(GL_DEPTH_TEST)); From eebb69d3ae65aea0841d3549ec44727f339dc4cd Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 18 Oct 2022 18:06:28 +0800 Subject: [PATCH 2/2] more moonraker support --- resources/profiles/Anycubic.json | 2 +- .../Anycubic/machine/fdm_machine_common.json | 1 + resources/profiles/Voron.json | 2 +- .../Voron/machine/fdm_klipper_common.json | 1 + src/libslic3r/GCode.cpp | 56 ++++++++++--------- src/libslic3r/GCode/GCodeProcessor.cpp | 5 +- src/libslic3r/PrintConfig.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 5 +- 8 files changed, 39 insertions(+), 35 deletions(-) diff --git a/resources/profiles/Anycubic.json b/resources/profiles/Anycubic.json index 3cc1a327e6..fbf6502645 100644 --- a/resources/profiles/Anycubic.json +++ b/resources/profiles/Anycubic.json @@ -1,6 +1,6 @@ { "name": "Anycubic", - "version": "01.02.00.01", + "version": "01.02.00.02", "force_update": "0", "description": "Anycubic configurations", "machine_model_list": [ diff --git a/resources/profiles/Anycubic/machine/fdm_machine_common.json b/resources/profiles/Anycubic/machine/fdm_machine_common.json index a6f78e6f0c..8680aa36fb 100644 --- a/resources/profiles/Anycubic/machine/fdm_machine_common.json +++ b/resources/profiles/Anycubic/machine/fdm_machine_common.json @@ -129,6 +129,7 @@ "silent_mode": "0", "single_extruder_multi_material": "1", "change_filament_gcode": "", + "before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n", "layer_change_gcode": "", "machine_pause_gcode": "M400 U1\n", "wipe": [ diff --git a/resources/profiles/Voron.json b/resources/profiles/Voron.json index 4e45baa9ff..a6d5ba4d8b 100644 --- a/resources/profiles/Voron.json +++ b/resources/profiles/Voron.json @@ -1,6 +1,6 @@ { "name": "Voron", - "version": "01.02.00.02", + "version": "01.02.00.03", "force_update": "0", "description": "Voron configurations", "machine_model_list": [ diff --git a/resources/profiles/Voron/machine/fdm_klipper_common.json b/resources/profiles/Voron/machine/fdm_klipper_common.json index d95df5e055..e94e73b9e6 100644 --- a/resources/profiles/Voron/machine/fdm_klipper_common.json +++ b/resources/profiles/Voron/machine/fdm_klipper_common.json @@ -133,6 +133,7 @@ "machine_start_gcode": "M190 S0\nM104 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", "layer_change_gcode": "", + "before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n", "scan_first_layer": "0", "nozzle_type": "hardened_steel", "auxiliary_fan": "0" diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 9fc4ad1f61..2d96eb418d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1164,10 +1164,10 @@ namespace DoExport { print_statistics.clear(); print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges); if (! extruders.empty()) { - //std::pair out_filament_used_mm ("; filament used [mm] = ", 0); - //std::pair out_filament_used_cm3("; filament used [cm3] = ", 0); - //std::pair out_filament_used_g ("; filament used [g] = ", 0); - //std::pair out_filament_cost ("; filament cost = ", 0); + std::pair out_filament_used_mm ("; filament used [mm] = ", 0); + std::pair out_filament_used_cm3("; filament used [cm3] = ", 0); + std::pair out_filament_used_g ("; filament used [g] = ", 0); + std::pair out_filament_cost ("; filament cost = ", 0); for (const Extruder &extruder : extruders) { 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 @@ -1187,14 +1187,14 @@ namespace DoExport { dst.first += buf; ++ dst.second; }; - //append(out_filament_used_mm, "%.2lf", used_filament); - //append(out_filament_used_cm3, "%.2lf", extruded_volume * 0.001); + append(out_filament_used_mm, "%.2lf", used_filament); + append(out_filament_used_cm3, "%.2lf", extruded_volume * 0.001); if (filament_weight > 0.) { 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.) { 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; @@ -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_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 += "\n" + out_filament_used_cm3.first; - //if (out_filament_used_g.second) - //filament_stats_string_out += "\n" + out_filament_used_g.first; - //if (out_filament_cost.second) - // filament_stats_string_out += "\n" + out_filament_cost.first; + filament_stats_string_out += out_filament_used_mm.first; + filament_stats_string_out += "\n" + out_filament_used_cm3.first; + if (out_filament_used_g.second) + filament_stats_string_out += "\n" + out_filament_used_g.first; + if (out_filament_cost.second) + filament_stats_string_out += "\n" + out_filament_cost.first; } 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. // 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"); std::string full_config; append_full_config(print, full_config); if (!full_config.empty()) file.write(full_config); + + // SoftFever: write compatiple image + std::vector 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"); } //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) }, [&file](const char* sz) { file.write(sz); }, [&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 double layer_height = first_object->config().layer_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) { const PrintRegion ®ion = print.get_print_region(region_id); 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("\n"); } - print.throw_if_canceled(); -#endif file.write_format("; EXECUTABLE_BLOCK_START\n"); // adds tags for time estimators @@ -1800,11 +1803,14 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato 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); + file.write("\n"); + 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); + 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 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(); } diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index edfb737882..6f7dc21cdd 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -452,10 +452,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st PrintEstimatedStatistics::ETimeMode mode = static_cast(i); if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) { char buf[128]; - //sprintf(buf, "; estimated printing time (%s mode) = %s\n", - // (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()); + sprintf(buf, "; estimated printing time: %s\n", get_time_dhms(machine.time).c_str()); ret += buf; } } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 90fd5bffe3..e7e4d5f0d9 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -571,7 +571,7 @@ void PrintConfigDef::init_fff_params() def->multiline = true; def->full_width = true; def->height = 5; - def->mode = comDevelop; + def->mode = comAdvanced; def->set_default_value(new ConfigOptionString("")); def = this->add("bottom_shell_layers", coInt); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 3a77ce19e5..4a4407d06b 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2911,8 +2911,8 @@ void TabPrinter::build_fff() option.opt.is_code = true; option.opt.height = gcode_field_height;//150; 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) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; @@ -2921,7 +2921,6 @@ void TabPrinter::build_fff() option.opt.is_code = true; option.opt.height = gcode_field_height;//150; optgroup->append_single_option_line(option); -#endif 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) {