diff --git a/BuildLinux.sh b/BuildLinux.sh index 2dd11272240..45f01e7f4f7 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -54,13 +54,16 @@ then exit 0 fi -# mkdir build -if [ ! -d "build" ] +if [[ -n "$FOUND_GTK3" ]] then - mkdir build + echo "Found GTK3" +else + if [[ -n "$FOUND_GTK2" ]] + then + echo "Found GTK2" + fi fi - if [[ -n "$UPDATE_LIB" ]] then echo -n -e "Updating linux ...\n" @@ -118,6 +121,12 @@ echo "[2/9] Changing date in version..." } echo "done" +# mkdir build +if [ ! -d "build" ] +then + mkdir build +fi + # mkdir in deps if [ ! -d "deps/build" ] then diff --git a/create_release.py b/create_release.py index 77d6120cccf..f36a7eac96c 100644 --- a/create_release.py +++ b/create_release.py @@ -83,7 +83,7 @@ def get_version(): print("gtk2 appimage: " +str(resp)); z = zipfile.ZipFile(io.BytesIO(resp.content)); z.extractall(release_path); - os.rename(release_path+"/"+program_name+"_ubu64.AppImage", release_path+"/"+program_name+"-ubuntu_18.04-gtk2-" + version + ".AppImage"); + os.rename(release_path+"/"+program_name+"_ubu64.AppImage", release_path+"/"+program_name+"-ubuntu_20.04-gtk2-" + version + ".AppImage"); if entry["name"] == "rc-"+program_name+"-gtk3.AppImage" and not found_linux_appimage_gtk3: found_linux_appimage_gtk3 = True; print("ask for: "+entry["archive_download_url"]); @@ -91,7 +91,7 @@ def get_version(): print("gtk3 appimage: " +str(resp)); z = zipfile.ZipFile(io.BytesIO(resp.content)); z.extractall(release_path); - os.rename(release_path+"/"+program_name+"_ubu64.AppImage", release_path+"/"+program_name+"-ubuntu_18.04-" + version + ".AppImage"); + os.rename(release_path+"/"+program_name+"_ubu64.AppImage", release_path+"/"+program_name+"-ubuntu_20.04-" + version + ".AppImage"); if entry["name"] == "rc_linux_gtk3.tar" and not found_linux: found_linux = True; print("ask for: "+entry["archive_download_url"]); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 547d59d576e..bf721a76351 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -303,5 +303,5 @@ else () install(TARGETS Slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") # Install the symlink for gcodeviewer - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink slic3r ${GCODEVIEWER_APP_CMD} WORKING_DIRECTORY \$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})") + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SLIC3R_APP_CMD} ${GCODEVIEWER_APP_CMD} WORKING_DIRECTORY \$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})") endif () diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 7298244ac0c..2e47f5d5a7b 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -1,10 +1,12 @@ -#include "libslic3r/libslic3r.h" -#include "libslic3r/Utils.hpp" #include "AppConfig.hpp" + +#include "libslic3r.h" +#include "format.hpp" #include "Exception.hpp" +#include "I18N.hpp" #include "LocalesUtils.hpp" #include "Thread.hpp" -#include "format.hpp" +#include "Utils.hpp" #include #include @@ -13,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libslic3r/AppConfig.hpp b/src/libslic3r/AppConfig.hpp index 2b52956fb17..6da1f7353ba 100644 --- a/src/libslic3r/AppConfig.hpp +++ b/src/libslic3r/AppConfig.hpp @@ -6,6 +6,7 @@ #include #include +#include #include "libslic3r/Config.hpp" #include "libslic3r/Semver.hpp" diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index e3a5014a02d..20dd50e0ca8 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -820,9 +820,9 @@ class ConfigOptionFloatsTempl : public ConfigOptionVector return false; return true; } else { - return idx < values.size() ? (std::isnan(this->values[idx]) || NIL_VALUE() == this->values[idx]) : - values.empty() ? (std::isnan(this->default_value) || NIL_VALUE() == this->default_value) : - (std::isnan(this->values.front()) || NIL_VALUE() == this->values.front()); + return idx < int32_t(values.size()) ? (std::isnan(this->values[idx]) || NIL_VALUE() == this->values[idx]) : + values.empty() ? (std::isnan(this->default_value) || NIL_VALUE() == this->default_value) : + (std::isnan(this->values.front()) || NIL_VALUE() == this->values.front()); } } double get_float(size_t idx = 0) const override { return get_at(idx); } @@ -1004,9 +1004,9 @@ class ConfigOptionIntsTempl : public ConfigOptionVector return false; return true; } else { - return idx < values.size() ? NIL_VALUE() == this->values[idx] : - values.empty() ? NIL_VALUE() == this->default_value : - NIL_VALUE() == this->values.front(); + return idx < int32_t(values.size()) ? NIL_VALUE() == this->values[idx] : + values.empty() ? NIL_VALUE() == this->default_value : + NIL_VALUE() == this->values.front(); } } int32_t get_int(size_t idx = 0) const override { return get_at(idx); } @@ -1349,9 +1349,9 @@ class ConfigOptionFloatsOrPercentsTempl : public ConfigOptionVectorvalues[idx].value) || NIL_VALUE() == this->values[idx]) : - values.empty() ? (std::isnan(this->default_value.value) || NIL_VALUE() == this->default_value) : - (std::isnan(this->values.front().value) || NIL_VALUE() == this->values.front()); + return idx < int32_t(values.size()) ? (std::isnan(this->values[idx].value) || NIL_VALUE() == this->values[idx]) : + values.empty() ? (std::isnan(this->default_value.value) || NIL_VALUE() == this->default_value) : + (std::isnan(this->values.front().value) || NIL_VALUE() == this->values.front()); } } double get_abs_value(size_t i, double ratio_over) const { @@ -1718,9 +1718,9 @@ class ConfigOptionBoolsTempl : public ConfigOptionVector return false; return true; } else { - return idx < values.size() ? NIL_VALUE() == this->values[idx] : - values.empty() ? NIL_VALUE() == this->default_value : - NIL_VALUE() == this->values.front(); + return idx < int32_t(values.size()) ? NIL_VALUE() == this->values[idx] : + values.empty() ? NIL_VALUE() == this->default_value : + NIL_VALUE() == this->values.front(); } } bool get_bool(size_t idx = 0) const override { return ConfigOptionVector::get_at(idx) != 0; } diff --git a/src/libslic3r/ExtrusionEntity.cpp b/src/libslic3r/ExtrusionEntity.cpp index b116ae77ba3..1beae06780c 100644 --- a/src/libslic3r/ExtrusionEntity.cpp +++ b/src/libslic3r/ExtrusionEntity.cpp @@ -2,6 +2,7 @@ #include "ExtrusionEntityCollection.hpp" #include "ExPolygonCollection.hpp" #include "ClipperUtils.hpp" +#include "Config.hpp" #include "Extruder.hpp" #include "Flow.hpp" #include @@ -592,6 +593,13 @@ bool HasRoleVisitor::search(const ExtrusionEntitiesPtr &entities, HasRoleVisitor return visitor.found; } +void SimplifyVisitor::use(ExtrusionPath& path) { + path.simplify(m_scaled_resolution, m_use_arc_fitting, scale_d(m_arc_fitting_tolearance->get_abs_value(path.width))); +} +void SimplifyVisitor::use(ExtrusionPath3D& path3D) { + path3D.simplify(m_scaled_resolution, m_use_arc_fitting, scale_d(m_arc_fitting_tolearance->get_abs_value(path3D.width))); +} + //class ExtrusionTreeVisitor : ExtrusionVisitor { //public: // //virtual void use(ExtrusionEntity &entity) { assert(false); }; diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index 2e750307716..08718a2f70c 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -637,18 +637,15 @@ struct HasThisRoleVisitor : public HasRoleVisitor{ //call simplify for all paths. +class ConfigOptionFloatOrPercent; class SimplifyVisitor : public ExtrusionVisitorRecursive { bool m_use_arc_fitting; coordf_t m_scaled_resolution; const ConfigOptionFloatOrPercent* m_arc_fitting_tolearance; public: SimplifyVisitor(coordf_t scaled_resolution, bool use_arc_fitting, const ConfigOptionFloatOrPercent* arc_fitting_tolearance) : m_scaled_resolution(scaled_resolution), m_use_arc_fitting(use_arc_fitting), m_arc_fitting_tolearance(arc_fitting_tolearance){} - virtual void use(ExtrusionPath& path) override { - path.simplify(m_scaled_resolution, m_use_arc_fitting, scale_d(m_arc_fitting_tolearance->get_abs_value(path.width))); - } - virtual void use(ExtrusionPath3D& path3D) override { - path3D.simplify(m_scaled_resolution, m_use_arc_fitting, scale_d(m_arc_fitting_tolearance->get_abs_value(path3D.width))); - } + virtual void use(ExtrusionPath& path) override; + virtual void use(ExtrusionPath3D& path3D) override; }; class GetPathsVisitor : public ExtrusionVisitorRecursive { public: diff --git a/src/libslic3r/Flow.cpp b/src/libslic3r/Flow.cpp index e8be7b07bba..d1c30d1173c 100644 --- a/src/libslic3r/Flow.cpp +++ b/src/libslic3r/Flow.cpp @@ -6,6 +6,7 @@ #include #include +#include // Mark string for localization and translate. #define L(s) Slic3r::I18N::translate(s) diff --git a/src/libslic3r/Format/BBConfig.cpp b/src/libslic3r/Format/BBConfig.cpp index f635ee6c0ff..ffb22ab40e2 100644 --- a/src/libslic3r/Format/BBConfig.cpp +++ b/src/libslic3r/Format/BBConfig.cpp @@ -9,6 +9,11 @@ #include #include +#include +#include +#include +#include + namespace Slic3r { namespace BBConfiguration { diff --git a/src/libslic3r/Format/BBConfig.hpp b/src/libslic3r/Format/BBConfig.hpp index a4b27675c7d..8a0d11c6f16 100644 --- a/src/libslic3r/Format/BBConfig.hpp +++ b/src/libslic3r/Format/BBConfig.hpp @@ -3,19 +3,25 @@ #include "miniz_extension.hpp" + +#include + #ifdef __APPLE__ #include + #include typedef boost::filesystem::path std_path; typedef boost::nowide::ifstream std_ifstream; #define GET_STD_PATH_FOR_IFSTREAM(PARAM) PARAM.string() #else #include + #include typedef std::filesystem::path std_path; typedef std::ifstream std_ifstream; #define GET_STD_PATH_FOR_IFSTREAM(PARAM) PARAM #endif namespace Slic3r { +struct ConfigSubstitutionContext; class DynamicPrintConfig; class Model; class ModelConfigObject; diff --git a/src/libslic3r/Format/bbs_3mf.cpp b/src/libslic3r/Format/bbs_3mf.cpp index f1570b7a40e..68c775b4e4b 100644 --- a/src/libslic3r/Format/bbs_3mf.cpp +++ b/src/libslic3r/Format/bbs_3mf.cpp @@ -23,12 +23,12 @@ #include +#include #include #include #include #include - #include #include #include @@ -47,6 +47,7 @@ namespace pt = boost::property_tree; +#include #include #include @@ -721,11 +722,11 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result) // Base class with error messages management class _BBS_3MF_Base { - mutable boost::mutex mutex; + mutable std::mutex mutex_error; mutable std::vector m_errors; protected: - void add_error(const std::string& error) const { boost::unique_lock l(mutex); m_errors.push_back(error); } + void add_error(const std::string& error) const { std::lock_guard l(mutex_error); m_errors.push_back(error); } void clear_errors() { m_errors.clear(); } public: @@ -1770,15 +1771,15 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result) } bool object_load_result = true; - boost::mutex mutex; + std::mutex mutex_load; tbb::parallel_for( tbb::blocked_range(0, m_object_importers.size()), - [this, &mutex, &object_load_result](const tbb::blocked_range& importer_range) { + [this, &mutex_load, &object_load_result](const tbb::blocked_range& importer_range) { CNumericLocalesSetter locales_setter; for (size_t object_index = importer_range.begin(); object_index < importer_range.end(); ++ object_index) { bool result = m_object_importers[object_index]->extract_object_model(); { - boost::unique_lock l(mutex); + std::lock_guard l(mutex_load); object_load_result &= result; } } diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 77673221828..eaf71b6a5da 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -214,9 +214,13 @@ std::string Wipe::wipe(GCode& gcodegen, bool toolchange) /* Reduce feedrate a bit; travel speed is often too high to move on existing material. Too fast = ripping of existing material; too slow = short wipe path, thus more blob. */ + std::string comment_speed = gcodegen.config().gcode_comments ? "travel_speed * 0.8" : ""; double wipe_speed = gcodegen.writer().config.get_computed_value("travel_speed") * 0.8; - if(gcodegen.writer().tool_is_extruder() && gcodegen.writer().config.wipe_speed.get_at(gcodegen.writer().tool()->id()) > 0) + if(gcodegen.writer().tool_is_extruder() && gcodegen.writer().config.wipe_speed.get_at(gcodegen.writer().tool()->id()) > 0) { wipe_speed = gcodegen.writer().config.wipe_speed.get_at(gcodegen.writer().tool()->id()); + if(gcodegen.config().gcode_comments) + comment_speed = "wipe_speed"; + } // get the retraction length double length = gcodegen.writer().tool()->retract_length(); @@ -249,7 +253,7 @@ std::string Wipe::wipe(GCode& gcodegen, bool toolchange) } coordf_t min_sqr_dist = precision * precision; // Be sure the dist isn't too short - if (wipe_dist < min_sqr_dist * 2) { + if (wipe_dist * wipe_dist < min_sqr_dist * 2) { this->reset_path(); return ""; } @@ -287,7 +291,7 @@ std::string Wipe::wipe(GCode& gcodegen, bool toolchange) double dE = length * (segment_length / wipe_dist) * 0.95; //FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle. // Is it here for the cooling markers? Or should it be outside of the cycle? - gcode += gcodegen.writer().set_speed(wipe_speed, "", gcodegen.enable_cooling_markers() ? ";_WIPE" : ""); + gcode += gcodegen.writer().set_speed(wipe_speed, comment_speed, gcodegen.enable_cooling_markers() ? ";_WIPE" : ""); gcode += gcodegen.writer().extrude_to_xy( gcodegen.point_to_gcode(line.b), gcodegen.config().use_firmware_retraction? 0 : -dE, @@ -803,9 +807,18 @@ namespace DoExport { static void update_print_estimated_stats(const GCodeProcessor& processor, const std::vector& extruders, const PrintConfig& config, PrintStatistics& print_statistics) { const GCodeProcessorResult& result = processor.get_result(); - print_statistics.estimated_normal_print_time = get_time_dhms(result.print_statistics.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].time); - print_statistics.estimated_silent_print_time = processor.is_stealth_time_estimator_enabled() ? - get_time_dhms(result.print_statistics.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A"; + print_statistics.estimated_print_time.clear(); + print_statistics.estimated_print_time_str.clear(); + print_statistics.estimated_print_time[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)] = + result.print_statistics.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].time; + print_statistics.estimated_print_time_str[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)] = + get_time_dhms(result.print_statistics.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].time); + if(processor.is_stealth_time_estimator_enabled()){ + print_statistics.estimated_print_time[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)] = + result.print_statistics.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)].time; + print_statistics.estimated_print_time_str[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)] = + get_time_dhms(result.print_statistics.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)].time); + } // update filament statictics double total_extruded_volume = 0.0; @@ -4850,109 +4863,172 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s Vec2d next_pos = next_point.cast(); Vec2d vec_dist = next_pos - current_pos; double vec_norm = vec_dist.norm(); + double sin_a = std::abs(std::sin(angle)); + sin_a = std::max(0.1, sin_a); const double setting_max_depth = (m_config.wipe_inside_depth.get_abs_value(m_writer.tool()->id(), nozzle_diam)); - coordf_t dist = scale_d(nozzle_diam) / 2; + coordf_t dist = setting_max_depth <= 0 ? scale_d(nozzle_diam) / 2 : scale_d(setting_max_depth); if (nozzle_diam != 0 && setting_max_depth > nozzle_diam * 0.55) - dist = coordf_t(check_wipe::max_depth(wipe_paths, scale_t(setting_max_depth), scale_t(nozzle_diam), [current_pos, current_point, vec_dist, vec_norm, angle](coord_t dist)->Point { - Point pt = (current_pos + vec_dist * (2 * dist / vec_norm)).cast(); - pt.rotate(angle, current_point); - return pt; + dist = coordf_t(check_wipe::max_depth(wipe_paths, scale_t(setting_max_depth), scale_t(nozzle_diam), + [current_pos, current_point, vec_dist, vec_norm, angle, sin_a](coord_t dist)->Point { + Point pt = (current_pos + vec_dist * (dist / (vec_norm * sin_a))).cast(); + pt.rotate(angle, current_point); + return pt; })); // Shift by no more than a nozzle diameter. - //FIXME Hiding the seams will not work nicely for very densely discretized contours! - Point pt_inside = (/*(nd >= vec_norm) ? next_pos : */ (current_pos + vec_dist * (2 * dist / vec_norm))).cast(); + // FIXME Hiding the seams will not work nicely for very densely discretized contours! + Point pt_inside = (/*(nd >= vec_norm) ? next_pos : */ (current_pos + vec_dist * ( dist / (vec_norm * sin_a)))) + .cast(); pt_inside.rotate(angle, current_point); - // generate the travel move + Point aiuhazudp = m_last_pos; + if (EXTRUDER_CONFIG_WITH_DEFAULT(wipe_inside_end, true)) { - gcode += m_writer.travel_to_xy(this->point_to_gcode(pt_inside), 0.0, "move inwards before travel"); - this->set_last_pos(pt_inside); - } - - gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_End) + "\n"; - - // also shift the wipe on retract if wipe_inside_end - if (m_wipe.enable && EXTRUDER_CONFIG_WITH_DEFAULT(wipe_inside_end, true)) { - current_pos = pt_inside.cast(); - //go to the inside (use clipper for easy shift) - Polygon original_polygon = original_loop.polygon(); - for(int i=1;ipoint_to_gcode(pt_inside), 0.0, "move inwards before travel"); + this->set_last_pos(pt_inside); + } else { + // also shift the wipe on retract if wipe_inside_end + // go to the inside (use clipper for easy shift) + Polygon original_polygon = original_loop.polygon(); + for (int i = 1; i < original_polygon.points.size(); ++i) + assert(!original_polygon.points[i - 1].coincides_with_epsilon(original_polygon.points[i])); + Polygons polys = offset(original_polygon, -dist); + if (!polys.empty()) { + // if multiple polygon, keep only our nearest. + if (polys.size() > 1) { + size_t nearest_poly_idx = size_t(-1); + coordf_t best_dist_sqr = dist * dist * 100; + for (int idx_poly = 0; idx_poly < polys.size(); ++idx_poly) { + Polygon &poly = polys[idx_poly]; + for (int idxpt = 0; idxpt < poly.points.size(); ++idxpt) { + if (coordf_t test_dist = pt_inside.distance_to_square(poly.points[idxpt]); + test_dist < best_dist_sqr) { + nearest_poly_idx = idx_poly; + best_dist_sqr = test_dist; + } + } + } + if (nearest_poly_idx + 1 < polys.size()) + polys.erase(polys.begin() + nearest_poly_idx + 1, polys.end()); + if (nearest_poly_idx > 0) + polys.erase(polys.begin(), polys.begin() + nearest_poly_idx); + assert(polys.size() == 1); + assert(polys.front().closest_point(pt_inside) != nullptr && + std::abs(polys.front().closest_point(pt_inside)->distance_to_square(pt_inside) - + best_dist_sqr) < EPSILON); } - } - if (poly.size() > 1 && poly.front().distance_to_square(poly.back()) < min_dist_sqr) { - poly.points.pop_back(); - } - if (poly.size() < 2) { - polys.erase(polys.begin() + idx_poly); - idx_poly--; - } - } - assert(!polys.empty()); - for(Polygon &poly : polys) - for(int i=1;i 1 && poly.front().distance_to_square(poly.back()) < min_dist_sqr) { + last_pop_back = poly.points.back(); + poly.points.pop_back(); + pop_back++; + } + if (poly.size() < 3) { + polys.clear(); } } - } - if (best_sqr_dist == max_sqr_dist) { - //try to find an edge - for (size_t poly_idx = 0; poly_idx < polys.size(); poly_idx++) { - Polygon& poly = polys[poly_idx]; + // find nearest point + size_t best_poly_idx = 0; + size_t best_pt_idx = 0; + const coordf_t max_sqr_dist = dist * dist * 8; // 2*nozzle² + coordf_t best_sqr_dist = max_sqr_dist; + Point start_point = pt_inside; + if (!polys.empty()) { + Polygon &poly = polys.front(); + for (int i = 1; i < poly.points.size(); ++i) + assert(!poly.points[i - 1].coincides_with_epsilon(poly.points[i])); if (poly.is_clockwise() ^ original_polygon.is_clockwise()) poly.reverse(); - poly.points.push_back(poly.points.front()); - for (size_t pt_idx = 0; pt_idx < poly.points.size()-1; pt_idx++) { - if (Line{ poly.points[pt_idx], poly.points[pt_idx + 1] }.distance_to_squared(pt_inside) < best_sqr_dist) { - poly.points.insert(poly.points.begin() + pt_idx + 1, pt_inside); - best_sqr_dist = 0; - best_poly_idx = poly_idx; - best_pt_idx = pt_idx + 1; - poly.points.erase(poly.points.end() - 1); - break; + for (size_t pt_idx = 0; pt_idx < poly.size(); pt_idx++) { + if (poly.points[pt_idx].distance_to_square(pt_inside) < best_sqr_dist) { + best_sqr_dist = poly.points[pt_idx].distance_to_square(pt_inside); + best_pt_idx = pt_idx; + } + } + if (best_sqr_dist == max_sqr_dist) { + // fail to find nearest point, try to find an edge + if (poly.is_clockwise() ^ original_polygon.is_clockwise()) + poly.reverse(); + poly.points.push_back(poly.points.front()); + for (size_t pt_idx = 0; pt_idx < poly.points.size() - 1; pt_idx++) { + if (Line{poly.points[pt_idx], poly.points[pt_idx + 1]}.distance_to_squared(pt_inside) < + best_sqr_dist) { + poly.points.insert(poly.points.begin() + pt_idx + 1, pt_inside); + best_sqr_dist = 0; + best_pt_idx = pt_idx + 1; + start_point = pt_inside.projection_onto( + Line{poly.points[pt_idx], poly.points[pt_idx + 1]}); + poly.points.erase(poly.points.end() - 1); + break; + } + } + } else { + // check if the point is "before" or "after" + // get the intersection with line that start with the best point (works if the point is before + // us, ie in the wrong dir) + Point pt_if_before; + if (best_pt_idx + 1 < poly.size()) { + pt_if_before = pt_inside.projection_onto(Line{poly.points[best_pt_idx], poly.points[best_pt_idx + 1]}); + } else { + pt_if_before = pt_inside.projection_onto(Line{poly.points[best_pt_idx], poly.points.front()}); + } + // get the intersection with line that end with the best point (works if the point is after + // us, ie in the good dir) + Point pt_if_after; + if (best_pt_idx > 0) { + pt_if_after = pt_inside.projection_onto(Line{poly.points[best_pt_idx - 1], poly.points[best_pt_idx]}); + } else { + pt_if_after = pt_inside.projection_onto(Line{poly.points.back(), poly.points[best_pt_idx]}); + } + // choose + if (pt_if_before.distance_to_square(pt_inside) > pt_if_after.distance_to_square(pt_inside)) { + start_point = pt_if_after; + } else { + start_point = pt_if_before; + best_pt_idx = (best_pt_idx + 1) % poly.size(); } } } - } - if (best_sqr_dist == max_sqr_dist) { - //can't find a path, use the old one - //BOOST_LOG_TRIVIAL(warning) << "Warn: can't find a proper path for wipe on retract. Layer " << m_layer_index << ", pos " << this->point_to_gcode(pt).x() << " : " << this->point_to_gcode(pt).y() << " !"; - } else { - m_wipe.reset_path(); - //get the points from here - Polygon& poly = polys[best_poly_idx]; - for (size_t pt_idx = best_pt_idx; pt_idx < poly.points.size(); pt_idx++) { - m_wipe.append(poly.points[pt_idx]); - } - for (size_t pt_idx = 0; pt_idx < best_pt_idx; pt_idx++) { - m_wipe.append(poly.points[pt_idx]); + if (best_sqr_dist == max_sqr_dist || polys.empty()) { + // can't find a path, use the old one + //BOOST_LOG_TRIVIAL(warning) << "Warn: can't find a proper path for wipe on retract. Layer " << m_layer_index << ", pos " << this->point_to_gcode(pt).x() << " : " << this->point_to_gcode(pt).y() << " !"; + } else { + Polygon &poly = polys.front(); + m_wipe.reset_path(); + // add first point if not redondant + if (poly.points[best_pt_idx].distance_to_square(start_point) > SCALED_EPSILON * SCALED_EPSILON * 100) + m_wipe.append(start_point); + // get the points from here + for (size_t pt_idx = best_pt_idx; pt_idx < poly.points.size(); pt_idx++) { + m_wipe.append(poly.points[pt_idx]); + } + for (size_t pt_idx = 0; pt_idx < best_pt_idx; pt_idx++) { m_wipe.append(poly.points[pt_idx]); } } + + // generate the travel move + gcode += m_writer.travel_to_xy(this->point_to_gcode(start_point), 0.0, "move inwards before wipe"); + this->set_last_pos(start_point); } + + gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_End) + "\n"; } } @@ -5084,7 +5160,7 @@ std::string GCode::extrude_path(const ExtrusionPath &path, const std::string &de const double max_gcode_per_second = this->config().max_gcode_per_second.value; double current_scaled_min_length = scaled_min_length; if (max_gcode_per_second > 0) { - current_scaled_min_length = std::max(current_scaled_min_length, scale_(_compute_speed_mm_per_sec(path, speed_mm_per_sec)) / max_gcode_per_second); + current_scaled_min_length = std::max(current_scaled_min_length, scale_(_compute_speed_mm_per_sec(path, speed_mm_per_sec, nullptr)) / max_gcode_per_second); } simplifed_path.polyline.ensure_fitting_result_valid(); if (current_scaled_min_length > 0 && !m_last_too_small.empty()) { @@ -5594,8 +5670,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &descri return gcode; } -double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double speed) { - +double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath &path, double speed, std::string *comment) +{ float factor = 1; // set speed if (speed < 0) { @@ -5606,24 +5682,34 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee //it's a bit hacky, so if you want to rework it, help yourself. if (path.role() == erPerimeter) { speed = m_config.get_computed_value("perimeter_speed"); + if(comment) *comment = "perimeter_speed"; } else if (path.role() == erExternalPerimeter) { speed = m_config.get_computed_value("external_perimeter_speed"); + if(comment) *comment = "external_perimeter_speed"; } else if (path.role() == erBridgeInfill) { speed = m_config.get_computed_value("bridge_speed"); + if(comment) *comment = "bridge_speed"; } else if (path.role() == erInternalBridgeInfill) { speed = m_config.get_computed_value("bridge_speed_internal"); + if(comment) *comment = "bridge_speed_internal"; } else if (path.role() == erOverhangPerimeter) { speed = m_config.get_computed_value("overhangs_speed"); + if(comment) *comment = "overhangs_speed"; } else if (path.role() == erInternalInfill) { speed = m_config.get_computed_value("infill_speed"); + if(comment) *comment = "infill_speed"; } else if (path.role() == erSolidInfill) { speed = m_config.get_computed_value("solid_infill_speed"); + if(comment) *comment = "solid_infill_speed"; } else if (path.role() == erTopSolidInfill) { speed = m_config.get_computed_value("top_solid_infill_speed"); + if(comment) *comment = "top_solid_infill_speed"; } else if (path.role() == erThinWall) { speed = m_config.get_computed_value("thin_walls_speed"); + if(comment) *comment = "thin_walls_speed"; } else if (path.role() == erGapFill) { speed = m_config.get_computed_value("gap_fill_speed"); + if(comment) *comment = "gap_fill_speed"; double max_ratio = m_config.gap_fill_flow_match_perimeter.get_abs_value(1.); if (max_ratio > 0 && m_region) { //compute intended perimeter flow @@ -5632,68 +5718,101 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee double current_vol_speed = path.mm3_per_mm * speed; if (max_vol_speed < current_vol_speed) { speed = max_vol_speed / path.mm3_per_mm; + if(comment) *comment = "max_vol_speed (from " + (*comment) + ")"; } } } else if (path.role() == erIroning) { speed = m_config.get_computed_value("ironing_speed"); + if(comment) *comment = "ironing_speed"; } else if (path.role() == erNone || path.role() == erTravel) { assert(path.role() != erNone); speed = m_config.get_computed_value("travel_speed"); + if(comment) *comment = "travel_speed"; } else if (path.role() == erMilling) { speed = m_config.get_computed_value("milling_speed"); + if(comment) *comment = "milling_speed"; } else if (path.role() == erSupportMaterial) { speed = m_config.get_computed_value("support_material_speed"); + if(comment) *comment = "support_material_speed"; } else if (path.role() == erSupportMaterialInterface) { speed = m_config.get_computed_value("support_material_interface_speed"); + if(comment) *comment = "support_material_interface_speed"; } else if (path.role() == erSkirt) { speed = m_config.get_computed_value("brim_speed"); + if(comment) *comment = "brim_speed"; } else { throw Slic3r::InvalidArgument("Invalid speed"); } + } else { + if (comment) *comment = "previous speed"; } + const std::string comment_auto_speed = "(from autospeed)"; if (m_volumetric_speed != 0. && speed == 0) { //if m_volumetric_speed, use the max size for thinwall & gapfill, to avoid variations double vol_speed = m_volumetric_speed / path.mm3_per_mm; double max_print_speed = m_config.get_computed_value("max_print_speed"); - if (vol_speed > max_print_speed) + if (vol_speed > max_print_speed) { vol_speed = max_print_speed; + if(comment) *comment = std::string("% of max_volumetric_speed limited by max_print_speed") + std::to_string(vol_speed); + } else { + if(comment) *comment = std::string("% of max_volumetric_speed ") + std::to_string(vol_speed); + } + // if using a % of an auto speed, use the % over the volumetric speed. if (path.role() == erPerimeter) { speed = m_config.perimeter_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("perimeter_speed ") + *comment; } else if (path.role() == erExternalPerimeter) { speed = m_config.external_perimeter_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("external_perimeter_speed ") + *comment; } else if (path.role() == erBridgeInfill) { speed = m_config.bridge_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("bridge_speed ") + *comment; } else if (path.role() == erInternalBridgeInfill) { speed = m_config.bridge_speed_internal.get_abs_value(vol_speed); + if(comment) *comment = std::string("bridge_speed_internal ") + *comment; } else if (path.role() == erOverhangPerimeter) { speed = m_config.overhangs_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("overhangs_speed ") + *comment; } else if (path.role() == erInternalInfill) { speed = m_config.infill_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("infill_speed ") + *comment; } else if (path.role() == erSolidInfill) { speed = m_config.solid_infill_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("solid_infill_speed ") + *comment; } else if (path.role() == erTopSolidInfill) { speed = m_config.top_solid_infill_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("top_solid_infill_speed ") + *comment; } else if (path.role() == erThinWall) { speed = m_config.thin_walls_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("thin_walls_speed ") + *comment; } else if (path.role() == erGapFill) { speed = m_config.gap_fill_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("gap_fill_speed ") + *comment; } else if (path.role() == erIroning) { speed = m_config.ironing_speed.get_abs_value(vol_speed); + if(comment) *comment = std::string("ironing_speed ") + *comment; } if (speed == 0) { speed = vol_speed; + if(comment) *comment = "max_volumetric_speed"; + if (vol_speed > max_print_speed) + if(comment) *comment += " limited by max_print_speed"; } } - if (speed == 0) // if you don't have a m_volumetric_speed + if (speed == 0) { // if you don't have a m_volumetric_speed speed = m_config.max_print_speed.value; + if(comment) *comment = "max_print_speed"; + } // Apply small perimeter 'modifier // don't modify bridge speed if (factor < 1 && !(is_bridge(path.role()))) { float small_speed = (float)m_config.small_perimeter_speed.get_abs_value(m_config.get_computed_value("perimeter_speed")); - if (small_speed > 0) - //apply factor between feature speed and small speed + if (small_speed > 0) { + // apply factor between feature speed and small speed speed = (speed * factor) + double((1.f - factor) * small_speed); + if(comment) *comment += ", reduced by small_perimeter_speed"; + } } // Apply first layer modifier if (this->on_first_layer()) { @@ -5701,39 +5820,57 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee double first_layer_speed = m_config.first_layer_speed.get_abs_value(base_speed); if (path.role() == erInternalInfill || path.role() == erSolidInfill) { double first_layer_infill_speed = m_config.first_layer_infill_speed.get_abs_value(base_speed); - if (first_layer_infill_speed > 0) - speed = std::min(first_layer_infill_speed, speed); - else if (first_layer_speed > 0) - speed = std::min(first_layer_speed, speed); + if (first_layer_infill_speed > 0) { + if (first_layer_infill_speed < speed) { + speed = first_layer_infill_speed; + if(comment) *comment += ", reduced to first_layer_infill_speed"; + } + } else if (first_layer_speed > 0) { + if (first_layer_speed < speed) { + speed = first_layer_speed; + if(comment) *comment += ", reduced to first_layer_speed"; + } + } } else { - if (first_layer_speed > 0) - speed = std::min(first_layer_speed, speed); + if (first_layer_speed > 0 && first_layer_speed < speed) { + speed = first_layer_speed; + if(comment) *comment += ", reduced to first_layer_speed"; + } } double first_layer_min_speed = m_config.first_layer_min_speed.value; - speed = std::max(first_layer_min_speed, speed); + if (first_layer_min_speed > speed) { + speed = first_layer_min_speed; + if(comment) *comment += ", increased to first_layer_min_speed"; + } } else if (this->object_layer_over_raft()) { const double base_speed = speed; double first_layer_over_raft_speed = m_config.first_layer_speed_over_raft.get_abs_value(base_speed); - if (first_layer_over_raft_speed > 0) - speed = std::min(first_layer_over_raft_speed, speed); + if (first_layer_over_raft_speed > 0 && first_layer_over_raft_speed < speed) { + speed = first_layer_over_raft_speed; + if(comment) *comment += ", reduced to first_layer_over_raft_speed"; + } } // the first_layer_flow_ratio is added at the last time to take into account everything. So do the compute like it's here. double path_mm3_per_mm = path.mm3_per_mm; - if (m_layer->bottom_z() < EPSILON) + if (m_layer->bottom_z() < EPSILON) { path_mm3_per_mm *= this->config().first_layer_flow_ratio.get_abs_value(1); + } // cap speed with max_volumetric_speed anyway (even if user is not using autospeed) - if (m_config.max_volumetric_speed.value > 0 && path_mm3_per_mm > 0) { - speed = std::min(m_config.max_volumetric_speed.value / path_mm3_per_mm, speed); + if (m_config.max_volumetric_speed.value > 0 && path_mm3_per_mm > 0 && m_config.max_volumetric_speed.value / path_mm3_per_mm < speed) { + speed = m_config.max_volumetric_speed.value / path_mm3_per_mm; + if(comment) *comment += ", reduced by max_volumetric_speed"; } // filament cap (volumetric & raw speed) double filament_max_volumetric_speed = EXTRUDER_CONFIG_WITH_DEFAULT(filament_max_volumetric_speed, 0); - if (filament_max_volumetric_speed > 0 && path_mm3_per_mm > 0) { - speed = std::min(filament_max_volumetric_speed / path_mm3_per_mm, speed); + if (filament_max_volumetric_speed > 0 && path_mm3_per_mm > 0 && filament_max_volumetric_speed / path_mm3_per_mm < speed) { + speed = filament_max_volumetric_speed / path_mm3_per_mm; + if(comment) *comment += ", reduced by filament_max_volumetric_speed"; } double filament_max_speed = EXTRUDER_CONFIG_WITH_DEFAULT(filament_max_speed, 0); - if (filament_max_speed > 0) { - speed = std::min(filament_max_speed, speed); + if (filament_max_speed > 0 && filament_max_speed < speed) { + speed = filament_max_speed; + if(comment) *comment += ", reduced by filament_max_speed"; } return speed; @@ -5782,7 +5919,7 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string if (m_config.machine_limits_usage <= MachineLimitsUsage::Limits) max_acceleration = m_config.machine_max_acceleration_extruding.get_at(0); double travel_acceleration = get_travel_acceleration(m_config); - if(acceleration > 0){ + if (acceleration > 0) { switch (path.role()){ case erPerimeter: perimeter: @@ -5934,7 +6071,8 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string } // compute speed here to be able to know it for travel_deceleration_use_target - speed = _compute_speed_mm_per_sec(path, speed); + std::string speed_comment = ""; + speed = _compute_speed_mm_per_sec(path, speed, m_config.gcode_comments ? &speed_comment : nullptr); if (m_config.travel_deceleration_use_target){ if (travel_acceleration <= acceleration || travel_acceleration == 0 || acceleration == 0) { @@ -6125,7 +6263,7 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string } // F is mm per minute. // speed is mm per second - gcode += m_writer.set_speed(speed, "", comment); + gcode += m_writer.set_speed(speed, speed_comment, comment); return gcode; } diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 5bc16ec8747..8f5b62434f2 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -519,7 +519,7 @@ class GCode : ExtrusionVisitorConst { void _extrude_line(std::string& gcode_str, const Line& line, const double e_per_mm, const std::string& comment); void _extrude_line_cut_corner(std::string& gcode_str, const Line& line, const double e_per_mm, const std::string& comment, Point& last_pos, const double path_width); std::string _before_extrude(const ExtrusionPath &path, const std::string &description, double speed = -1); - double_t _compute_speed_mm_per_sec(const ExtrusionPath& path, double speed = -1); + double_t _compute_speed_mm_per_sec(const ExtrusionPath &path, double speed, std::string *comment); std::string _after_extrude(const ExtrusionPath &path); void print_machine_envelope(GCodeOutputStream &file, const Print &print); void _print_first_layer_bed_temperature(std::string &out, const Print &print, const std::string &gcode, uint16_t first_printing_extruder_id, bool wait); diff --git a/src/libslic3r/GCode/CoolingBuffer.cpp b/src/libslic3r/GCode/CoolingBuffer.cpp index 59cc887111c..f366d24d2ff 100644 --- a/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/src/libslic3r/GCode/CoolingBuffer.cpp @@ -1029,6 +1029,7 @@ std::string CoolingBuffer::apply_layer_cooldown( int current_feedrate = 0; int stored_fan_speed = m_fan_speed < 0 ? 0 : m_fan_speed; int current_fan_speed = -1; + const std::string comment_speed = m_config.gcode_comments ? " ; speed changed by the cooling algorithm" : ""; change_extruder_set_fan(); for (const CoolingLine *line : lines) { const char *line_start = gcode.c_str() + line->line_start; @@ -1100,7 +1101,7 @@ std::string CoolingBuffer::apply_layer_cooldown( char buf[64]; sprintf(buf, "%d", int(current_feedrate)); new_gcode += buf; - } else { + } else /*if (remove)*/ { // Remove the feedrate word. const char *f = fpos; // Roll the pointer before the 'F' word. @@ -1134,17 +1135,31 @@ std::string CoolingBuffer::apply_layer_cooldown( } if (line->type & CoolingLine::TYPE_WIPE) boost::replace_all(comment, ";_WIPE", ""); + assert((comment.empty() && new_gcode.back() == '\n') || + (!comment.empty() && comment.back() == '\n' && new_gcode.back() != '\n')); new_gcode += comment; } else { + assert((new_gcode.back() == '\n' && line_end == end) || + (new_gcode.back() != '\n' && (*(line_end-1)) == '\n')); // Just attach the rest of the source line. new_gcode.append(end, line_end - end); } } + if (modify) { + if (!comment_speed.empty()) { + assert(new_gcode.back() == '\n'); + new_gcode.resize(new_gcode.size() - 1); + new_gcode.append(comment_speed); + new_gcode.append("\n"); + } + } } else if(line->type == CoolingLine::TYPE_ADJUSTABLE_EMPTY) { // nothing useful, don't write it (an extrusion that don't move because it wasn't printed as it's too small). - std::string deleted(line_start, line_end - line_start); - boost::replace_all(deleted, "\n", ""); - new_gcode.append(std::string("; deleted stuff: ") + deleted); + if (m_config.gcode_comments) { + std::string deleted(line_start, line_end - line_start); + boost::replace_all(deleted, "\n", ""); + new_gcode.append(std::string("; deleted empty line: ") + deleted); + } } else { new_gcode.append(line_start, line_end - line_start); } diff --git a/src/libslic3r/GCode/FanMover.cpp b/src/libslic3r/GCode/FanMover.cpp index 1e764662698..951de6107e0 100644 --- a/src/libslic3r/GCode/FanMover.cpp +++ b/src/libslic3r/GCode/FanMover.cpp @@ -4,6 +4,9 @@ #include "LocalesUtils.hpp" #include + +#include + /* #include #include @@ -13,8 +16,6 @@ #include "../PrintConfig.hpp" #include "../Utils.hpp" #include "Print.hpp" - -#include */ diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 7a8ed99c738..6201c80c01f 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -12,9 +12,9 @@ #include "LocalesUtils.hpp" #include "Flow.hpp" +#include #include - namespace Slic3r { diff --git a/src/libslic3r/Geometry/ArcFitter.cpp b/src/libslic3r/Geometry/ArcFitter.cpp index 34ef2ae61d8..bf05ea93096 100644 --- a/src/libslic3r/Geometry/ArcFitter.cpp +++ b/src/libslic3r/Geometry/ArcFitter.cpp @@ -1,4 +1,5 @@ #include "ArcFitter.hpp" +#include "../Polyline.hpp" #include #include diff --git a/src/libslic3r/LocalesUtils.cpp b/src/libslic3r/LocalesUtils.cpp index f189466e017..e07a474b12d 100644 --- a/src/libslic3r/LocalesUtils.cpp +++ b/src/libslic3r/LocalesUtils.cpp @@ -65,7 +65,7 @@ std::string to_string_nozero(double value, int32_t max_precision) { double intpart; if (modf(value, &intpart) == 0.0) { //shortcut for int - return boost::lexical_cast(intpart); + return std::to_string(intpart); } else { std::stringstream ss; //first, get the int part, to see how many digit it takes diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 8fcec5d0e0a..acc6cf6ab50 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -1,33 +1,33 @@ +#include "clipper/clipper_z.hpp" + #include "PerimeterGenerator.hpp" +#include "BoundingBox.hpp" #include "BridgeDetector.hpp" #include "ClipperUtils.hpp" +#include "ExPolygon.hpp" #include "ExtrusionEntity.hpp" #include "ExtrusionEntityCollection.hpp" #include "Geometry.hpp" +#include "Geometry/MedialAxis.hpp" +#include "Geometry.hpp" +#include "Line.hpp" +#include "Milling/MillingPostProcess.hpp" +#include "Polygon.hpp" #include "ShortestPath.hpp" +#include "SVG.hpp" #include "Arachne/WallToolPaths.hpp" #include "Arachne/utils/ExtrusionLine.hpp" +#include #include #include +#include #include #include #include -#include "BoundingBox.hpp" -#include "ExPolygon.hpp" -#include "Geometry.hpp" -#include "Geometry/MedialAxis.hpp" -#include "Milling/MillingPostProcess.hpp" -#include "Polygon.hpp" -#include "Line.hpp" -#include "ClipperUtils.hpp" -#include "SVG.hpp" -#include -#include -#include #include //#define ARACHNE_DEBUG diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index ea70c4f0382..73921321f5d 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -23,11 +23,14 @@ #include #include #include + #include #include #include #include +#include + // Mark string for localization and translate. #define L(s) Slic3r::I18N::translate(s) @@ -1753,11 +1756,24 @@ std::string Print::output_filename(const std::string &filename_base) const DynamicConfig PrintStatistics::config() const { DynamicConfig config; - std::string normal_print_time = short_time(this->estimated_normal_print_time); - std::string silent_print_time = short_time(this->estimated_silent_print_time); - config.set_key_value("print_time", new ConfigOptionString(normal_print_time)); - config.set_key_value("normal_print_time", new ConfigOptionString(normal_print_time)); - config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time)); + if (this->estimated_print_time_str.find(static_cast(PrintEstimatedStatistics::ETimeMode::Normal)) != + this->estimated_print_time_str.end()) { + std::string normal_print_time = short_time( + this->estimated_print_time_str.at(static_cast(PrintEstimatedStatistics::ETimeMode::Normal))); + config.set_key_value("print_time", new ConfigOptionString(normal_print_time)); + config.set_key_value("normal_print_time", new ConfigOptionString(normal_print_time)); + } else if (this->estimated_print_time_str.find(static_cast( + PrintEstimatedStatistics::ETimeMode::Stealth)) != this->estimated_print_time_str.end()) { + std::string silent_print_time = short_time( + this->estimated_print_time_str.at(static_cast(PrintEstimatedStatistics::ETimeMode::Stealth))); + config.set_key_value("print_time", new ConfigOptionString(silent_print_time)); + } + if (this->estimated_print_time_str.find(static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)) != + this->estimated_print_time_str.end()) { + std::string silent_print_time = short_time( + this->estimated_print_time_str.at(static_cast(PrintEstimatedStatistics::ETimeMode::Stealth))); + config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time)); + } config.set_key_value("used_filament", new ConfigOptionFloat(this->total_used_filament / 1000.)); config.set_key_value("extruded_volume", new ConfigOptionFloat(this->total_extruded_volume)); config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost)); diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 7e5812954f6..3ba0ef55b1a 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -485,8 +485,9 @@ struct WipeTowerData struct PrintStatistics { PrintStatistics() { clear(); } - std::string estimated_normal_print_time; - std::string estimated_silent_print_time; + // PrintEstimatedStatistics::ETimeMode::Normal -> time + std::map estimated_print_time; + std::map estimated_print_time_str; double total_used_filament; std::vector> color_extruderid_to_used_filament; // id -> mm (length) double total_extruded_volume; diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp index 03a89ef7a92..255cb0bf305 100644 --- a/src/libslic3r/PrintBase.hpp +++ b/src/libslic3r/PrintBase.hpp @@ -466,7 +466,7 @@ class PrintBase : public ObjectBase } else { printf("%d => ", percent); if(args.empty()) - printf(message.c_str()); + printf("%s", message.c_str()); else if (args.size()==1) printf(message.c_str(), args.front().c_str()); else if (args.size()==2) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 5f0dfd14a66..34561c81b30 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2477,7 +2477,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("XY First layer compensation"); def->category = OptionCategory::slicing; def->tooltip = L("The first layer will be grown / shrunk in the XY plane by the configured value " - "to compensate for the 1st layer squish aka an Elephant Foot effect. (should be negative = inwards)"); + "to compensate for the 1st layer squish aka an Elephant Foot effect. (should be negative = inwards = remove area)"); def->sidetext = L("mm"); def->mode = comAdvancedE | comSuSi | comPrusa; // just a rename & inverted of prusa 's elefant_foot def->set_default_value(new ConfigOptionFloat(0)); @@ -3688,7 +3688,7 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionFloatsOrPercents{ FloatOrPercent{ 75, true} }); def = this->add("max_print_speed", coFloatOrPercent); - def->label = L("Max print speed"); + def->label = L("Max auto-speed"); def->full_label = L("Max print speed for Autospeed"); def->category = OptionCategory::speed; def->tooltip = L("When setting other speed settings to 0, Slic3r will autocalculate the optimal speed " @@ -3716,8 +3716,8 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionPercents{ 90 }); def = this->add("max_volumetric_speed", coFloat); - def->label = L("Volumetric speed"); - def->full_label = L("Maximum Print Volumetric speed"); + def->label = L("Volumetric auto-speed"); + def->full_label = L("Maximum Volumetric print speed for Autospeed"); def->category = OptionCategory::extruders; def->tooltip = L("This setting allows you to set the maximum flowrate for your print, and so cap the desired flow rate for the autospeed algorithm." " The autospeed tries to keep a constant feedrate for the entire object, and so can lower the volumetric speed for some features." @@ -6411,7 +6411,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Outer XY size compensation"); def->category = OptionCategory::slicing; def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value " - "(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes." + "(negative = inwards = remove area, positive = outwards = add area). This might be useful for fine-tuning sizes." "\nThis one only applies to the 'exterior' shell of the object." "\n !!! it's recommended you put the same value into the 'Inner XY size compensation', unless you are sure you don't have horizontal holes. !!! "); def->sidetext = L("mm"); @@ -6423,7 +6423,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Inner XY size compensation"); def->category = OptionCategory::slicing; def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value " - "(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes." + "(negative = inwards = remove area, positive = outwards = add area). This might be useful for fine-tuning sizes." "\nThis one only applies to the 'inner' shell of the object (!!! horizontal holes break the shell !!!)"); def->sidetext = L("mm"); def->mode = comExpert | comSuSi; @@ -6434,7 +6434,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("XY holes compensation"); def->category = OptionCategory::slicing; def->tooltip = L("The convex holes will be grown / shrunk in the XY plane by the configured value" - " (negative = inwards, positive = outwards, should be negative as the holes are always a bit smaller irl)." + " (negative = inwards = remove area, positive = outwards = add area, should be negative as the holes are always a bit smaller irl)." " This might be useful for fine-tuning hole sizes." "\nThis setting behaves the same as 'Inner XY size compensation' but only for convex shapes. It's added to 'Inner XY size compensation', it does not replace it. "); def->sidetext = L("mm"); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index a065cf00480..8d06e30f780 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -414,7 +414,7 @@ namespace Slic3r { void PrintObject::_compute_max_sparse_spacing() { m_max_sparse_spacing = 0; - std::atomic_int64_t max_sparse_spacing; + std::atomic_int64_t max_sparse_spacing(0); tbb::parallel_for( tbb::blocked_range(0, m_layers.size()), [this, &max_sparse_spacing](const tbb::blocked_range& range) { diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp index 16e5679459c..fc9115d98f7 100644 --- a/src/slic3r/GUI/BitmapCache.cpp +++ b/src/slic3r/GUI/BitmapCache.cpp @@ -6,6 +6,7 @@ #include "GUI_Utils.hpp" #include +#include #ifdef __WXGTK2__ // Broken alpha workaround diff --git a/src/slic3r/GUI/CreateMMUTiledCanvas.cpp b/src/slic3r/GUI/CreateMMUTiledCanvas.cpp index 6c2a2b345bc..8be76fcc546 100644 --- a/src/slic3r/GUI/CreateMMUTiledCanvas.cpp +++ b/src/slic3r/GUI/CreateMMUTiledCanvas.cpp @@ -33,12 +33,17 @@ #include #include #include +#include #include #include #include "wxExtensions.hpp" +#include #include +#include #include +#include +#include #if ENABLE_SCROLLABLE static wxSize get_screen_size(wxWindow* window) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index c505d63dfdf..11efa48133d 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1,16 +1,25 @@ -#include "GUI.hpp" -#include "GUI_App.hpp" -#include "I18N.hpp" #include "Field.hpp" -#include "wxExtensions.hpp" -#include "Plater.hpp" -#include "MainFrame.hpp" -#include "format.hpp" #include "libslic3r/PresetBundle.hpp" #include "libslic3r/PrintConfig.hpp" +#include "BitmapComboBox.hpp" +#include "format.hpp" +#include "GUI.hpp" +#include "GUI_App.hpp" +#include "I18N.hpp" +#include "OG_CustomCtrl.hpp" +#include "MainFrame.hpp" +#include "MsgDialog.hpp" +#include "Plater.hpp" +#include "wxExtensions.hpp" + #include + +#include +#include +#include + #include #include #include @@ -20,11 +29,6 @@ #include #endif #include -#include -#include -#include "OG_CustomCtrl.hpp" -#include "MsgDialog.hpp" -#include "BitmapComboBox.hpp" #ifdef __WXOSX__ #define wxOSX true diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index f82061b7ad5..c78a159886e 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1063,7 +1063,7 @@ GCodeViewer::GCodeViewer() ifs.open(path_colors.string()); boost::property_tree::read_ini(ifs, tree_colors); - for (int i = 0; i < Extrusion_Role_Colors.size(); i++) { + for (size_t i = 0; i < Extrusion_Role_Colors.size(); i++) { std::string color_code = tree_colors.get(ExtrusionEntity::role_to_string((ExtrusionRole)i)); if (color_code.length() > 5) { wxColour color; @@ -4026,7 +4026,7 @@ void GCodeViewer::render_legend(float& legend_height) last_color[i] = m_tool_colors[i]; } int last_extruder_id = 1; - int color_change_idx = 0; + size_t color_change_idx = 0; for (const auto& time_rec : times) { switch (time_rec.first) { @@ -4315,8 +4315,8 @@ void GCodeViewer::render_legend(float& legend_height) if (!outliers_allowed) ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.3333f); - ImDrawList *draw_list = ImGui::GetWindowDrawList(); - ImVec2 pos = ImGui::GetCursorScreenPos(); + //ImDrawList *draw_list = ImGui::GetWindowDrawList(); + //ImVec2 pos = ImGui::GetCursorScreenPos(); // draw text ImGui::SameLine(); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 7b67380cdda..e8662dc2d14 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -6654,6 +6654,7 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) "Resolve the current problem to continue slicing."); error = ErrorType::PLATER_ERROR; break; + case EWarning::PrintWarning: text = ""; error = ErrorType::PLATER_WARNING; break; } auto& notification_manager = *wxGetApp().plater()->get_notification_manager(); switch (error) diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index c5da933b639..eea3ad53e84 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -8,8 +8,9 @@ #include -#include #include +#include +#include #include #include diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 4a82ac8d3ac..57d201fcef9 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -282,8 +282,9 @@ void show_substitutions_info(const PresetsConfigSubstitutions &presets_config_su wxString changes; // check count - if (check_count(presets_config_substitutions) == 0) + if (check_count(presets_config_substitutions) == 0) { return; + } auto preset_type_name = [](Preset::Type type) { switch (type) { @@ -312,8 +313,9 @@ void show_substitutions_info(const PresetsConfigSubstitutions &presets_config_su void show_substitutions_info(const ConfigSubstitutions& config_substitutions, const std::string& filename) { // check count - if (check_count(config_substitutions) == 0) + if (check_count(config_substitutions) == 0) { return; + } wxString changes = "\n"; add_config_substitutions(config_substitutions, changes); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8e41e4a7ae1..d4661af775d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -725,7 +725,7 @@ static void generic_exception_handle() BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what(); std::terminate(); throw; - } catch (const std::exception& ex) { + } catch (const std::exception &ex) { wxLogError(format_wxstr(_L("Internal error: %1%"), ex.what())); BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what(); throw; @@ -860,7 +860,7 @@ bool GUI_App::init_opengl() hard_gpu = AppConfig::HardwareType::hGpuIntel; if (boost::contains(gpu_vendor, "ATI") || boost::contains(gpu_vendor, "AMD")) hard_gpu = AppConfig::HardwareType::hGpuAmd; - } catch (std::exception ex) {} + } catch (std::exception &ex) {} #else try { std::string gpu_vendor = OpenGLManager::get_gl_info().get_vendor(); @@ -873,7 +873,7 @@ bool GUI_App::init_opengl() if (boost::contains(gpu_vendor, "Apple") || boost::contains(gpu_vendor, "APPLE")) { assert(false); // apple gpu are only in _M_ARM64 } - } catch (std::exception ex) {} + } catch (std::exception &ex) {} #endif app_config->set_hardware_type(AppConfig::HardwareType(hard_cpu + hard_gpu)); } @@ -947,9 +947,9 @@ void GUI_App::init_app_config() if (!app_config) { app_config.reset(new AppConfig(is_editor() ? AppConfig::EAppMode::Editor : AppConfig::EAppMode::GCodeViewer)); +#ifdef _M_ARM64 AppConfig::HardwareType hard_cpu = AppConfig::HardwareType::hCpuOther; // TODO for x86 if needed AppConfig::HardwareType hard_gpu = AppConfig::HardwareType::hGpuOther; -#ifdef _M_ARM64 #ifdef __APPLE__ // Arm apple hard_cpu = AppConfig::HardwareType::hCpuApple; @@ -2410,21 +2410,24 @@ bool GUI_App::load_language(wxString language, bool initial) } #endif - if (! wxLocale::IsAvailable(language_info->Language)) { - // Loading the language dictionary failed. - wxString message = "Switching " SLIC3R_APP_NAME " to language " + language_info->CanonicalName + " failed."; + if (!wxLocale::IsAvailable(language_info->Language)) { + // Loading the language dictionary failed. + wxString message = "Switching " SLIC3R_APP_NAME " to language " + language_info->CanonicalName + " failed."; #if !defined(_WIN32) && !defined(__APPLE__) // likely some linux system - message += "\nYou may need to reconfigure the missing locales, likely by running the \"locale-gen\" and \"dpkg-reconfigure locales\" commands.\n"; + message += "\nYou may need to reconfigure the missing locales, likely by running the \"locale-gen\" and " + "\"dpkg-reconfigure locales\" commands.\n"; #endif - if (initial) - message + "\n\nApplication will close."; - wxMessageBox(message, SLIC3R_APP_NAME " - Switching language failed", wxOK | wxICON_ERROR); - if (initial) - std::exit(EXIT_FAILURE); - else - return false; - } + if (initial) { + message + "\n\nApplication will close."; + } + wxMessageBox(message, SLIC3R_APP_NAME " - Switching language failed", wxOK | wxICON_ERROR); + if (initial) { + std::exit(EXIT_FAILURE); + } else { + return false; + } + } // Release the old locales, create new locales. //FIXME wxWidgets cause havoc if the current locale is deleted. We just forget it causing memory leaks for now. @@ -2649,7 +2652,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu) associate_gcode_files(); } #endif // _WIN32 - } catch (std::exception e) {} + } catch (std::exception &e) {} } if (app_layout_changed) { // hide full main_sizer for mainFrame @@ -3393,8 +3396,7 @@ bool GUI_App::check_updates(const bool verbose) MsgNoUpdates dlg; dlg.ShowModal(); } - } - catch (const std::exception & ex) { + } catch (const std::exception &ex) { show_error(nullptr, ex.what()); } // Applicaiton will continue. diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 409fa5a220b..528d697e8c6 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -2015,11 +2015,12 @@ bool NotificationManager::push_notification_data(std::unique_ptrget_current_canvas3D()->schedule_extra_frame(0); - else - wxGetApp().CallAfter([](){ wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0); }); - return retval; + } else { + wxGetApp().CallAfter([]() { wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0); }); + } + return retval; } void NotificationManager::push_delayed_notification_data(std::unique_ptr notification, std::function condition_callback, int64_t initial_delay, int64_t delay_interval) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 21553c2e2aa..e28ded9cdbd 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -1466,21 +1467,35 @@ void Sidebar::update_sliced_info_sizer() wxString::Format("%.2f", ps.total_cost); p->sliced_info->SetTextAndShow(siCost, info_text, new_label); - if (ps.estimated_normal_print_time == "N/A" && ps.estimated_silent_print_time == "N/A") + const std::chrono::system_clock::time_point time_now = std::chrono::system_clock::now(); + if (ps.estimated_print_time.empty()) p->sliced_info->SetTextAndShow(siEstimatedTime, "N/A"); else { info_text = ""; new_label = _L("Estimated printing time") + ":"; - if (ps.estimated_normal_print_time != "N/A") { - new_label += format_wxstr("\n - %1%", _L("normal mode")); - info_text += format_wxstr("\n%1%", short_time(ps.estimated_normal_print_time)); + if (auto it = ps.estimated_print_time_str.find(static_cast(PrintEstimatedStatistics::ETimeMode::Normal)); it != ps.estimated_print_time_str.end()) { + if (ps.estimated_print_time_str.size() > 1) { + new_label += format_wxstr("\n - %1%", _L("normal mode")); + info_text += format_wxstr("\n%1%", short_time(it->second)); + } else { + info_text += format_wxstr("%1%", short_time(it->second)); + } - p->plater->get_notification_manager()->set_slicing_complete_print_time(_utf8("Estimated printing time: ") + ps.estimated_normal_print_time, p->plater->is_sidebar_collapsed()); + assert(ps.estimated_print_time.find(static_cast(PrintEstimatedStatistics::ETimeMode::Normal)) != ps.estimated_print_time.end()); + std::chrono::system_clock::time_point time_finished = time_now + std::chrono::seconds(int32_t(ps.estimated_print_time.at(static_cast(PrintEstimatedStatistics::ETimeMode::Normal)))); + std::time_t timestamp_finished = std::chrono::system_clock::to_time_t(time_finished); + info_text += format_wxstr(_L(" (finished at %1%)"), std::put_time(std::localtime(×tamp_finished), "%T")); + p->plater->get_notification_manager()->set_slicing_complete_print_time(_utf8("Estimated printing time: ") + it->second, p->plater->is_sidebar_collapsed()); } - if (ps.estimated_silent_print_time != "N/A") { + if (auto it = ps.estimated_print_time_str.find(static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)); it != ps.estimated_print_time_str.end()) { new_label += format_wxstr("\n - %1%", _L("stealth mode")); - info_text += format_wxstr("\n%1%", short_time(ps.estimated_silent_print_time)); + info_text += format_wxstr("\n%1%", short_time(it->second)); + + assert(ps.estimated_print_time.find(static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)) != ps.estimated_print_time.end()); + std::chrono::system_clock::time_point time_finished = time_now + std::chrono::seconds(int32_t(ps.estimated_print_time.at(static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)))); + std::time_t timestamp_finished = std::chrono::system_clock::to_time_t(time_finished); + info_text += format_wxstr(_L(" (finished at %1%)"), std::put_time(std::localtime(×tamp_finished), "%T")); } p->sliced_info->SetTextAndShow(siEstimatedTime, info_text, new_label); } diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 99f5cc728e0..9990f4cba34 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -6,16 +6,19 @@ #include "I18N.hpp" #include "libslic3r/AppConfig.hpp" -#include -#include #include "Notebook.hpp" #include "ButtonsDescription.hpp" #include "OG_CustomCtrl.hpp" #include "wxExtensions.hpp" +#include #include #include +#include +#include +#include + namespace Slic3r { static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values& enum_keys_map) @@ -1002,7 +1005,7 @@ void PreferencesDialog::accept(wxEvent&) m_seq_top_layer_only_changed = app_config->get("seq_top_layer_only") != it->second; m_settings_layout_changed = false; - for (const std::string& key : { "old_settings_layout_mode", + for (const std::string key : { "old_settings_layout_mode", "new_settings_layout_mode", "dlg_settings_layout_mode" }) { @@ -1013,7 +1016,7 @@ void PreferencesDialog::accept(wxEvent&) } } - for (const std::string& key : { "default_action_on_close_application", + for (const std::string key : { "default_action_on_close_application", "default_action_on_select_preset", "default_action_on_new_project" }) { auto it = m_values.find(key); diff --git a/src/slic3r/GUI/PresetHints.cpp b/src/slic3r/GUI/PresetHints.cpp index 84dcbf1e5e7..305e7b642a5 100644 --- a/src/slic3r/GUI/PresetHints.cpp +++ b/src/slic3r/GUI/PresetHints.cpp @@ -218,7 +218,7 @@ std::string PresetHints::cooling_description(const Preset &preset_fil, const Pre out += " "; out += format_wxstr(_L("print speed will be reduced so that no less than %1%s are spent on that layer"), slowdown_below_layer_time); - if(min_print_speed > 0) + if (min_print_speed > 0) { if (max_speed_reduc > 0) { out += " "; out += format_wxstr(_L("(however, speed will never be reduced below %1%mm/s or up to %2%%% reduction)"), min_print_speed, max_speed_reduc); @@ -226,6 +226,7 @@ std::string PresetHints::cooling_description(const Preset &preset_fil, const Pre out += " "; out += format_wxstr(_L("(however, speed will never be reduced below %1%mm/s)"), min_print_speed); } + } } if (fan_below_layer_time > 0 || slowdown_below_layer_time > 0) { @@ -285,7 +286,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle double support_material_interface_speed = full_print_config.get_computed_value("support_material_interface_speed"); double bridge_speed = full_print_config.get_computed_value("bridge_speed"); double bridge_flow_ratio = full_print_config.get_computed_value("bridge_flow_ratio"); - double over_bridge_flow_ratio = full_print_config.get_computed_value("over_bridge_flow_ratio"); + //double over_bridge_flow_ratio = full_print_config.get_computed_value("over_bridge_flow_ratio"); double perimeter_speed = full_print_config.get_computed_value("perimeter_speed"); double external_perimeter_speed = full_print_config.get_computed_value("external_perimeter_speed"); // double gap_fill_speed = full_print_config.get_computed_value("gap_fill_speed"); diff --git a/src/slic3r/GUI/ScriptExecutor.cpp b/src/slic3r/GUI/ScriptExecutor.cpp index 5fce15732d1..1693ac08b6e 100644 --- a/src/slic3r/GUI/ScriptExecutor.cpp +++ b/src/slic3r/GUI/ScriptExecutor.cpp @@ -1,9 +1,11 @@ #include "ScriptExecutor.hpp" + +#include "libslic3r/PresetBundle.hpp" +#include "libslic3r/Print.hpp" + #include "GUI_App.hpp" #include "Plater.hpp" #include "Tab.hpp" -#include "libslic3r/PresetBundle.hpp" -#include "libslic3r/Print.hpp" #include @@ -14,6 +16,11 @@ #include #include +#include +#include +#include +#include + using namespace gw; namespace Slic3r { namespace GUI { namespace script { @@ -1206,6 +1213,8 @@ boost::any ScriptContainer::call_script_function_get_value(const ConfigOptionDef case coString: case coStrings:func_name = "void"; break; case coEnum: func_name = "int"; break; + default: + assert(false); } func_name += (" " + def.opt_key + "_get("); switch (def.type) { @@ -1214,6 +1223,7 @@ boost::any ScriptContainer::call_script_function_get_value(const ConfigOptionDef case coString: case coStrings: case coEnum: func_name += "string &out"; break; + default:; } func_name += ")"; AngelScript::asIScriptFunction* func = m_script_module->GetFunctionByDecl(func_name.c_str()); diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 5fd851ea2b8..99f385841da 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -149,7 +149,7 @@ const GroupAndCategory& OptionsSearcher::get_group_and_category(const std::strin void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type type) { - const ConfigDef* defs = config->def(); + //const ConfigDef* defs = config->def(); auto emplace_option = [this, type](const std::string grp_key, const int16_t idx) { assert(groups_and_categories.find(grp_key) == groups_and_categories.end() @@ -190,7 +190,7 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty for (std::string opt_key : config->keys()) { - const ConfigOptionDef& opt = config->def()->options.at(opt_key); + //const ConfigOptionDef& opt = config->def()->options.at(opt_key); //if (opt.mode != comNone && (opt.mode & current_tags) == 0) // continue; @@ -310,39 +310,43 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) auto get_label = [this, &sep](const Option& opt, bool marked = true) { std::wstring out; - if (marked) + if (marked) { out += marker_by_type(opt.type, printer_technology); + } const std::wstring* prev = nullptr; for (const std::wstring* const s : { view_params.category ? &opt.category_local : nullptr, view_params.category ? &opt.group_local : nullptr, - & opt.label_local }) + & opt.label_local }) { if (s != nullptr && (prev == nullptr || *prev != *s)) { if (out.size() > 2) out += sep; out += *s; prev = s; } - return out; + } + return out; }; auto get_label_english = [this, &sep](const Option& opt, bool marked = true) { std::wstring out; - if (marked) + if (marked) { out += marker_by_type(opt.type, printer_technology); - const std::wstring* prev = nullptr; + } + const std::wstring *prev = nullptr; for (const std::wstring* const s : { view_params.category ? &opt.category : nullptr, view_params.category ? &opt.group : nullptr, - & opt.label }) + & opt.label }) { if (s != nullptr && (prev == nullptr || *prev != *s)) { if (out.size() > 2) out += sep; out += *s; prev = s; } - return out; + } + return out; }; auto get_tooltip = [this, &sep](const Option& opt) @@ -351,13 +355,15 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) std::wstring tooltip; int length = 0; for (int i = 0; i < opt.tooltip_local.size(); i++) { - if (length >= 80 && opt.tooltip_local[i] == u' ') + if (length >= 80 && opt.tooltip_local[i] == u' ') { tooltip.push_back(u'\n'); - else + } else { tooltip.push_back(opt.tooltip_local[i]); + } length++; - if (tooltip.back() == u'\n') + if (tooltip.back() == u'\n') { length = 0; + } } @@ -1008,7 +1014,7 @@ void SearchDialog::on_sys_color_changed() SearchListModel::SearchListModel(wxWindow* parent) : wxDataViewVirtualListModel(0) { int icon_id = 0; - for (const std::string& icon : { "cog", "printer", "sla_printer", "spool", "resin" }) + for (const std::string icon : { "cog", "printer", "sla_printer", "spool", "resin" }) m_icon[icon_id++] = ScalableBitmap(parent, icon); } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ac488d4c0db..da99d32c599 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1,35 +1,37 @@ -// #include "libslic3r/GCodeSender.hpp" -#include "slic3r/Utils/Serial.hpp" #include "Tab.hpp" -#include "PresetHints.hpp" + #include "libslic3r/Log.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/PresetBundle.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/GCode/GCodeProcessor.hpp" +#include -#include "slic3r/Utils/Http.hpp" -#include "slic3r/Utils/PrintHost.hpp" #include "BonjourDialog.hpp" -#include "WipeTowerDialog.hpp" -#include "GraphDialog.hpp" #include "ButtonsDescription.hpp" -#include "Search.hpp" +#include "GUI_App.hpp" +#include "GUI_ObjectList.hpp" +#include "MainFrame.hpp" +#include "GLCanvas3D.hpp" +#include "GraphDialog.hpp" +#include "slic3r/Utils/Http.hpp" +#include "format.hpp" +#include "MsgDialog.hpp" +#include "Notebook.hpp" #include "OG_CustomCtrl.hpp" +#include "PhysicalPrinterDialog.hpp" +#include "Plater.hpp" +#include "PresetComboBoxes.hpp" +#include "PresetHints.hpp" +#include "slic3r/Utils/PrintHost.hpp" +#include "slic3r/Utils/Serial.hpp" +#include "SavePresetDialog.hpp" +#include "Search.hpp" +#include "UnsavedChangesDialog.hpp" +#include "WipeTowerDialog.hpp" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -37,26 +39,23 @@ #include #include #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "wxExtensions.hpp" -#include "PresetComboBoxes.hpp" #include -#include - -#include "GUI_App.hpp" -#include "GUI_ObjectList.hpp" -#include "Plater.hpp" -#include "MainFrame.hpp" -#include "GLCanvas3D.hpp" -#include "format.hpp" -#include "PhysicalPrinterDialog.hpp" -#include "UnsavedChangesDialog.hpp" -#include "SavePresetDialog.hpp" -#include "Search.hpp" -#include "MsgDialog.hpp" -#include "Notebook.hpp" - #ifdef WIN32 #include #endif // WIN32 diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index f94d08016b1..29d587c479f 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -25,9 +25,10 @@ #include #include +#include #include -#include #include +#include #include "BedShapeDialog.hpp" #include "ButtonsDescription.hpp"