From 8a99e2b2375c305a259b096df245d1468851685c Mon Sep 17 00:00:00 2001
From: enricoturri1966 <enricoturri@seznam.cz>
Date: Thu, 8 Oct 2020 11:21:27 +0200
Subject: [PATCH] Small refactoring in GCodeViewer

---
 src/slic3r/GUI/GCodeViewer.cpp | 8 ++++----
 src/slic3r/GUI/GCodeViewer.hpp | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp
index 40f3d0ba2..ed26e0b79 100644
--- a/src/slic3r/GUI/GCodeViewer.cpp
+++ b/src/slic3r/GUI/GCodeViewer.cpp
@@ -1633,10 +1633,10 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
         for (size_t i = 0; i < buffer.paths.size(); ++i) {
             const Path& path = buffer.paths[i];
             if (path.type == EMoveType::Travel) {
-                if (!is_travel_in_z_range(i))
+                if (!is_travel_in_z_range(i, m_layers_z_range[0], m_layers_z_range[1]))
                     continue;
             }
-            else if (!is_in_z_range(path))
+            else if (!is_in_z_range(path, m_layers_z_range[0], m_layers_z_range[1]))
                 continue;
 
             if (path.type == EMoveType::Extrude && !is_visible(path))
@@ -2613,7 +2613,7 @@ void GCodeViewer::render_statistics() const
 }
 #endif // ENABLE_GCODE_VIEWER_STATISTICS
 
-bool GCodeViewer::is_travel_in_z_range(size_t id) const
+bool GCodeViewer::is_travel_in_z_range(size_t id, double min_z, double max_z) const
 {
     const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)];
     if (id >= buffer.paths.size())
@@ -2633,7 +2633,7 @@ bool GCodeViewer::is_travel_in_z_range(size_t id) const
         path.last = buffer.paths[last].last;
     }
 
-    return is_in_z_range(path);
+    return is_in_z_range(path, min_z, max_z);
 }
 
 void GCodeViewer::log_memory_used(const std::string& label, long long additional) const
diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp
index c2ebce9b9..ffef05bcb 100644
--- a/src/slic3r/GUI/GCodeViewer.hpp
+++ b/src/slic3r/GUI/GCodeViewer.hpp
@@ -468,14 +468,14 @@ private:
         return role < erCount && (m_extrusions.role_visibility_flags & (1 << role)) != 0;
     }
     bool is_visible(const Path& path) const { return is_visible(path.role); }
-    bool is_in_z_range(const Path& path) const {
-        auto in_z_range = [this](double z) {
-            return z > m_layers_z_range[0] - EPSILON && z < m_layers_z_range[1] + EPSILON;
+    bool is_in_z_range(const Path& path, double min_z, double max_z) const {
+        auto in_z_range = [this, min_z, max_z](double z) {
+            return z > min_z - EPSILON && z < max_z + EPSILON;
         };
 
         return in_z_range(path.first.position[2]) || in_z_range(path.last.position[2]);
     }
-    bool is_travel_in_z_range(size_t id) const;
+    bool is_travel_in_z_range(size_t id, double min_z, double max_z) const;
     void log_memory_used(const std::string& label, long long additional = 0) const;
 };