New gcode visualization integration - Removal of old visualization

This commit is contained in:
enricoturri1966 2023-11-30 13:09:58 +01:00 committed by Lukas Matena
parent 5c323527ce
commit 1d6fb321af
19 changed files with 1250 additions and 1008 deletions

View File

@ -93,6 +93,9 @@ set(SLIC3R_GUI_SOURCES
GUI/Gizmos/GLGizmoMeasure.cpp
GUI/Gizmos/GLGizmoMeasure.hpp
#====================================================================================================================
GUI/LibVGCode/LibVGCodeWrapper.hpp
GUI/LibVGCode/LibVGCodeWrapper.cpp
GUI/LibVGCode/include/ColorRange.hpp
GUI/LibVGCode/include/GCodeInputData.hpp
GUI/LibVGCode/include/PathVertex.hpp
GUI/LibVGCode/include/Types.hpp
@ -101,7 +104,6 @@ set(SLIC3R_GUI_SOURCES
GUI/LibVGCode/src/Bitset.cpp
GUI/LibVGCode/src/CogMarker.hpp
GUI/LibVGCode/src/CogMarker.cpp
GUI/LibVGCode/src/ColorRange.hpp
GUI/LibVGCode/src/ColorRange.cpp
GUI/LibVGCode/src/ExtrusionRoles.hpp
GUI/LibVGCode/src/ExtrusionRoles.cpp

File diff suppressed because it is too large Load Diff

View File

@ -14,9 +14,7 @@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#include "LibVGCode/include/Viewer.hpp"
#include "LibVGCode/include/PathVertex.hpp"
#include "LibVGCode/include/GCodeInputData.hpp"
#include "LibVGCode/LibVGCodeWrapper.hpp"
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -63,9 +61,6 @@ class GCodeViewer
PausePrints,
CustomGCodes
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// vbo buffer containing vertices data used to render a specific toolpath type
struct VBuffer
@ -390,6 +385,9 @@ class GCodeViewer
}
}
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// helper to render shells
struct Shells
@ -445,9 +443,22 @@ class GCodeViewer
void set_visible(bool visible) { m_visible = visible; }
void add_segment(const Vec3d& v1, const Vec3d& v2, double mass) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
if (mass > 0.0) {
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
assert(mass > 0.0);
m_total_position += mass * 0.5 * (v1 + v2);
m_total_mass += mass;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_total_position += mass * 0.5 * (v1 + v2);
m_total_mass += mass;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
}
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
Vec3d cog() const { return (m_total_mass > 0.0) ? (Vec3d)(m_total_position / m_total_mass) : Vec3d::Zero(); }
@ -486,6 +497,9 @@ class GCodeViewer
}
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// helper to render extrusion paths
struct Extrusions
{
@ -530,15 +544,7 @@ class GCodeViewer
// Color mapping by extrusion temperature.
Range temperature;
// Color mapping by layer time.
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
std::array<Range, static_cast<size_t>(libvgcode::ETimeMode::COUNT)> layer_time;
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::array<Range, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> layer_time;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void reset() {
height.reset();
@ -553,27 +559,15 @@ class GCodeViewer
}
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unsigned int role_visibility_flags{ 0 };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Ranges ranges;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void reset_role_visibility_flags() {
role_visibility_flags = 0;
for (uint32_t i = 0; i < uint32_t(GCodeExtrusionRole::Count); ++i) {
role_visibility_flags |= 1 << i;
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void reset_ranges() { ranges.reset(); }
};
@ -644,6 +638,9 @@ class GCodeViewer
void reset();
size_t indices_count() const { return 6; }
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_GCODE_VIEWER_STATISTICS
struct Statistics
@ -816,49 +813,44 @@ public:
void add_gcode_line_to_lines_cache(const std::string& src);
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
struct Endpoints
{
size_t first{ 0 };
size_t last{ 0 };
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool skip_invisible_moves{ false };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Endpoints endpoints;
Endpoints current;
Endpoints last_current;
Endpoints global;
Vec3f current_position{ Vec3f::Zero() };
Vec3f current_offset{ Vec3f::Zero() };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Marker marker;
GCodeWindow gcode_window;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<unsigned int> gcode_ids;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
void render(float legend_height, const libvgcode::Viewer* viewer, uint32_t gcode_id);
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<unsigned int> gcode_ids;
void render(float legend_height);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
enum class EViewType : unsigned char
{
FeatureType,
@ -874,22 +866,22 @@ public:
ColorPrint,
Count
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
private:
bool m_gl_data_initialized{ false };
unsigned int m_last_result_id{ 0 };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EViewType m_last_view_type{ EViewType::Count };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
size_t m_moves_count{ 0 };
std::vector<TBuffer> m_buffers{ static_cast<size_t>(EMoveType::Extrude) };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// bounding box of toolpaths
BoundingBoxf3 m_paths_bounding_box;
// bounding box of shells
@ -902,44 +894,34 @@ private:
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<ColorRGBA> m_tool_colors;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Layers m_layers;
std::array<unsigned int, 2> m_layers_z_range;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<GCodeExtrusionRole> m_roles;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
size_t m_extruders_count;
std::vector<unsigned char> m_extruder_ids;
Extrusions m_extrusions;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<float> m_filament_diameters;
std::vector<float> m_filament_densities;
Extrusions m_extrusions;
SequentialView m_sequential_view;
Shells m_shells;
COG m_cog;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// whether or not to render the cog model with fixed screen size
bool m_cog_marker_fixed_screen_size{ true };
float m_cog_marker_size{ 1.0f };
bool m_tool_marker_fixed_screen_size{ false };
float m_tool_marker_size{ 1.0f };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EViewType m_view_type{ EViewType::FeatureType };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool m_legend_enabled{ true };
struct LegendResizer
{
@ -952,6 +934,8 @@ private:
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
PrintEstimatedStatistics::ETimeMode m_time_estimate_mode{ PrintEstimatedStatistics::ETimeMode::Normal };
std::array<SequentialRangeCap, 2> m_sequential_range_caps;
std::array<std::vector<float>, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> m_layers_times;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -959,14 +943,6 @@ private:
Statistics m_statistics;
#endif // ENABLE_GCODE_VIEWER_STATISTICS
GCodeProcessorResult::SettingsIds m_settings_ids;
std::array<SequentialRangeCap, 2> m_sequential_range_caps;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::array<std::vector<float>, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> m_layers_times;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<CustomGCode::Item> m_custom_gcode_per_print_z;
@ -977,7 +953,6 @@ private:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
libvgcode::Viewer m_new_viewer;
bool m_use_new_viewer{ true };
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -994,20 +969,12 @@ public:
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void load(const GCodeProcessorResult& gcode_result, const Print& print);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// recalculate ranges in dependence of what is visible and sets tool/print colors
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
void refresh(const GCodeProcessorResult& gcode_result);
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const;
void update_shells_color_by_extruder(const DynamicPrintConfig* config);
void reset();
@ -1052,25 +1019,35 @@ public:
}
return m_max_bounding_box;
}
const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
std::vector<double> get_layers_zs() const {
const std::vector<float> zs = m_new_viewer.get_layers_zs();
std::vector<double> ret;
std::transform(zs.begin(), zs.end(), std::back_inserter(ret), [](float z) { return static_cast<double>(z); });
return ret;
}
std::vector<float> get_layers_times() const { return m_new_viewer.get_layers_times(); }
std::vector<float> get_layers_times(libvgcode::ETimeMode mode) const { return m_new_viewer.get_layers_times(mode); }
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const SequentialView& get_sequential_view() const { return m_sequential_view; }
void update_sequential_view_current(unsigned int first, unsigned int last);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
const std::array<uint32_t, 2>& get_gcode_view_full_range() const { return m_new_viewer.get_view_full_range(); }
const std::array<uint32_t, 2>& get_gcode_view_enabled_range() const { return m_new_viewer.get_view_enabled_range(); }
const std::array<uint32_t, 2>& get_gcode_view_visible_range() const { return m_new_viewer.get_view_visible_range(); }
libvgcode::PathVertex get_gcode_vertex_at(size_t id) const { return m_new_viewer.get_vertex_at(id); }
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool is_contained_in_bed() const { return m_contained_in_bed; }
@ -1087,22 +1064,15 @@ public:
m_view_type = type;
}
bool is_toolpath_move_type_visible(EMoveType type) const;
void set_toolpath_move_type_visible(EMoveType type, bool visible);
unsigned int get_toolpath_role_visibility_flags() const { return m_extrusions.role_visibility_flags; }
void set_toolpath_role_visibility_flags(unsigned int flags) { m_extrusions.role_visibility_flags = flags; }
unsigned int get_options_visibility_flags() const;
void set_options_visibility_from_flags(unsigned int flags);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool is_toolpath_move_type_visible(EMoveType type) const;
void set_toolpath_move_type_visible(EMoveType type, bool visible);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unsigned int get_toolpath_role_visibility_flags() const { return m_extrusions.role_visibility_flags; }
void set_toolpath_role_visibility_flags(unsigned int flags) { m_extrusions.role_visibility_flags = flags; }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unsigned int get_options_visibility_flags() const;
void set_options_visibility_from_flags(unsigned int flags);
void set_layers_z_range(const std::array<unsigned int, 2>& layers_z_range);
bool is_legend_enabled() const { return m_legend_enabled; }
@ -1115,7 +1085,15 @@ public:
void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); }
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
size_t get_extruders_count() { return m_new_viewer.get_extruders_count(); }
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
size_t get_extruders_count() { return m_extruders_count; }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void invalidate_legend() { m_legend_resizer.reset(); }
@ -1125,8 +1103,6 @@ public:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
bool use_new_viewer() const { return m_use_new_viewer; }
void toggle_use_new_viewer() { m_use_new_viewer = !m_use_new_viewer; }
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
float get_cog_marker_scale_factor() const { return m_new_viewer.get_cog_marker_scale_factor(); }
void set_cog_marker_scale_factor(float factor) { return m_new_viewer.set_cog_marker_scale_factor(factor); }
@ -1135,33 +1111,41 @@ public:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
private:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void load_toolpaths(const GCodeProcessorResult& gcode_result);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void load_wipetower_shell(const Print& print);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
void render_new_toolpaths();
#endif // ENABLE_NEW_GCODE_VIEWER
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render_toolpaths();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render_shells();
void render_legend(float& legend_height);
#if ENABLE_GCODE_VIEWER_STATISTICS
void render_statistics();
#endif // ENABLE_GCODE_VIEWER_STATISTICS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
bool is_visible(libvgcode::EGCodeExtrusionRole role) const { return m_new_viewer.is_extrusion_role_visible(role); }
bool is_visible(const Path& path) const;
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool is_visible(GCodeExtrusionRole role) const {
return role < GCodeExtrusionRole::Count && (m_extrusions.role_visibility_flags & (1 << int(role))) != 0;
}
bool is_visible(const Path& path) const { return is_visible(path.role); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void log_memory_used(const std::string& label, int64_t additional = 0) const;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ColorRGBA option_color(EMoveType move_type) const;
};

View File

@ -1947,24 +1947,8 @@ void GLCanvas3D::render()
#if ENABLE_RENDER_SELECTION_CENTER
_render_selection_center();
#endif // ENABLE_RENDER_SELECTION_CENTER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (!m_main_toolbar.is_enabled())
_render_gcode_cog();
#else
if (!m_main_toolbar.is_enabled()) {
if (!m_gcode_viewer.use_new_viewer())
_render_gcode_cog();
}
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (!m_main_toolbar.is_enabled())
_render_gcode_cog();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// we need to set the mouse's scene position here because the depth buffer
// could be invalidated by the following gizmo render methods
@ -2154,7 +2138,15 @@ void GLCanvas3D::ensure_on_bed(unsigned int object_idx, bool allow_negative_z)
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
std::vector<double> GLCanvas3D::get_gcode_layers_zs() const
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const std::vector<double>& GLCanvas3D::get_gcode_layers_zs() const
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
{
return m_gcode_viewer.get_layers_zs();
}
@ -2164,14 +2156,14 @@ std::vector<double> GLCanvas3D::get_volumes_print_zs(bool active_only) const
return m_volumes.get_current_print_zs(active_only);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::set_gcode_options_visibility_from_flags(unsigned int flags)
{
m_gcode_viewer.set_options_visibility_from_flags(flags);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::set_toolpath_role_visibility_flags(unsigned int flags)
{
m_gcode_viewer.set_toolpath_role_visibility_flags(flags);
@ -2181,9 +2173,9 @@ void GLCanvas3D::set_toolpath_view_type(GCodeViewer::EViewType type)
{
m_gcode_viewer.set_view_type(type);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::set_volumes_z_range(const std::array<double, 2>& range)
{
@ -2717,24 +2709,28 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
m_gcode_viewer.refresh(gcode_result);
#else
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_gcode_viewer.refresh(gcode_result, str_tool_colors);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
set_as_dirty();
request_extra_frame();
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last)
{
m_gcode_viewer.refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last);
set_as_dirty();
request_extra_frame();
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::load_sla_preview()
{
@ -2998,16 +2994,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_RELOAD_FROM_DISK));
break;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
case WXK_F2: {
m_gcode_viewer.toggle_use_new_viewer();
m_dirty = true;
request_extra_frame();
break;
}
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
case '0': { select_view("iso"); break; }
case '1': { select_view("top"); break; }
case '2': { select_view("bottom"); break; }
@ -6144,19 +6130,6 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
void GLCanvas3D::_render_gcode()
{
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
Slic3r::GUI::ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
const Size cnv_size = get_canvas_size();
imgui.set_next_window_pos(0.5f * static_cast<float>(cnv_size.get_width()), 0.0f, ImGuiCond_Always, 0.5f, 0.0f);
imgui.begin(std::string("LibVGCode Viewer Info"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
if (m_gcode_viewer.use_new_viewer())
imgui.text("Press F2 to switch to old visualization");
else
imgui.text("Press F2 to switch to new visualization");
imgui.end();
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_gcode_viewer.render();
}

View File

@ -837,31 +837,23 @@ public:
bool is_gcode_legend_enabled() const { return m_gcode_viewer.is_legend_enabled(); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
GCodeViewer::EViewType get_gcode_view_type() const { return m_gcode_viewer.get_view_type(); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const std::vector<double>& get_gcode_layers_zs() const;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
std::vector<double> get_gcode_layers_zs() const;
std::vector<float> get_gcode_layers_times() const { return m_gcode_viewer.get_layers_times(); }
std::vector<float> get_gcode_layers_times(libvgcode::ETimeMode mode) const { return m_gcode_viewer.get_layers_times(mode); }
#endif // ENABLE_NEW_GCODE_VIEWER
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<double> get_volumes_print_zs(bool active_only) const;
GCodeViewer::EViewType get_gcode_view_type() const { return m_gcode_viewer.get_view_type(); }
const std::vector<double>& get_gcode_layers_zs() const;
unsigned int get_gcode_options_visibility_flags() const { return m_gcode_viewer.get_options_visibility_flags(); }
void set_gcode_options_visibility_from_flags(unsigned int flags);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unsigned int get_toolpath_role_visibility_flags() const { return m_gcode_viewer.get_toolpath_role_visibility_flags(); }
void set_toolpath_role_visibility_flags(unsigned int flags);
void set_toolpath_view_type(GCodeViewer::EViewType type);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
std::vector<double> get_volumes_print_zs(bool active_only) const;
void set_volumes_z_range(const std::array<double, 2>& range);
void set_toolpaths_z_range(const std::array<unsigned int, 2>& range);
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_gcode_viewer.get_custom_gcode_per_print_z(); }
@ -876,18 +868,18 @@ public:
void load_gcode_shells();
void load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
void refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
void set_gcode_view_preview_type(libvgcode::EViewType type) { return m_gcode_viewer.set_view_type(type); }
libvgcode::EViewType get_gcode_view_preview_type() const { return m_gcode_viewer.get_view_type(); }
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last);
void set_gcode_view_preview_type(GCodeViewer::EViewType type) { return m_gcode_viewer.set_view_type(type); }
GCodeViewer::EViewType get_gcode_view_preview_type() const { return m_gcode_viewer.get_view_type(); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void load_sla_preview();
void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values);
void bind_event_handlers();

View File

@ -491,8 +491,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
bool was_empty = m_layers_slider->GetMaxValue() == 0;
bool force_sliders_full_range = was_empty;
if (!keep_z_range)
{
if (!keep_z_range) {
bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_layers_slider->GetMaxValueD()) > DoubleSlider::epsilon()/*1e-6*/;
force_sliders_full_range |= span_changed;
}

View File

@ -0,0 +1,8 @@
///|/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966
///|/
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#include "libslic3r/libslic3r.h"
#include "LibVGCodeWrapper.hpp"

View File

@ -0,0 +1,269 @@
///|/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966
///|/
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#ifndef slic3r_LibVGCodeWrapper_hpp_
#define slic3r_LibVGCodeWrapper_hpp_
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#include "libslic3r/Color.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "slic3r/GUI/GUI_Preview.hpp"
#include "include/Viewer.hpp"
#include "include/PathVertex.hpp"
#include "include/GCodeInputData.hpp"
#include "include/ColorRange.hpp"
namespace libvgcode {
// mapping from Slic3r::Vec3f to libvgcode::Vec3
static Vec3 convert(const Slic3r::Vec3f& v)
{
return { v.x(), v.y(), v.z() };
}
// mapping from libvgcode::Vec3 to Slic3r::Vec3f
static Slic3r::Vec3f convert(const Vec3& v)
{
return { v[0], v[1], v[2] };
}
// mapping from Slic3r::Matrix4f to libvgcode::Mat4x4
static Mat4x4 convert(const Slic3r::Matrix4f& m)
{
Mat4x4 ret;
std::memcpy(ret.data(), m.data(), 16 * sizeof(float));
return ret;
}
// mapping from libvgcode::Color to Slic3r::ColorRGBA
static Slic3r::ColorRGBA convert(const Color& c)
{
static const float inv_255 = 1.0f / 255.0f;
return { c[0] * inv_255, c[1] * inv_255, c[2] * inv_255, 1.0f };
}
// mapping from Slic3r::ColorRGBA to libvgcode::Color
static Color convert(const Slic3r::ColorRGBA& c)
{
return { static_cast<uint8_t>(c.r() * 255.0f), static_cast<uint8_t>(c.g() * 255.0f), static_cast<uint8_t>(c.b() * 255.0f) };
}
// mapping from libvgcode::EGCodeExtrusionRole to Slic3r::GCodeExtrusionRole
static Slic3r::GCodeExtrusionRole convert(EGCodeExtrusionRole role)
{
switch (role)
{
case EGCodeExtrusionRole::None: { return Slic3r::GCodeExtrusionRole::None; }
case EGCodeExtrusionRole::Perimeter: { return Slic3r::GCodeExtrusionRole::Perimeter; }
case EGCodeExtrusionRole::ExternalPerimeter: { return Slic3r::GCodeExtrusionRole::ExternalPerimeter; }
case EGCodeExtrusionRole::OverhangPerimeter: { return Slic3r::GCodeExtrusionRole::OverhangPerimeter; }
case EGCodeExtrusionRole::InternalInfill: { return Slic3r::GCodeExtrusionRole::InternalInfill; }
case EGCodeExtrusionRole::SolidInfill: { return Slic3r::GCodeExtrusionRole::SolidInfill; }
case EGCodeExtrusionRole::TopSolidInfill: { return Slic3r::GCodeExtrusionRole::TopSolidInfill; }
case EGCodeExtrusionRole::Ironing: { return Slic3r::GCodeExtrusionRole::Ironing; }
case EGCodeExtrusionRole::BridgeInfill: { return Slic3r::GCodeExtrusionRole::BridgeInfill; }
case EGCodeExtrusionRole::GapFill: { return Slic3r::GCodeExtrusionRole::GapFill; }
case EGCodeExtrusionRole::Skirt: { return Slic3r::GCodeExtrusionRole::Skirt; }
case EGCodeExtrusionRole::SupportMaterial: { return Slic3r::GCodeExtrusionRole::SupportMaterial; }
case EGCodeExtrusionRole::SupportMaterialInterface: { return Slic3r::GCodeExtrusionRole::SupportMaterialInterface; }
case EGCodeExtrusionRole::WipeTower: { return Slic3r::GCodeExtrusionRole::WipeTower; }
case EGCodeExtrusionRole::Custom: { return Slic3r::GCodeExtrusionRole::Custom; }
}
assert(false);
return Slic3r::GCodeExtrusionRole::None;
}
// mapping from Slic3r::GCodeExtrusionRole to libvgcode::EGCodeExtrusionRole
static EGCodeExtrusionRole convert(Slic3r::GCodeExtrusionRole role)
{
switch (role)
{
case Slic3r::GCodeExtrusionRole::None: { return EGCodeExtrusionRole::None; }
case Slic3r::GCodeExtrusionRole::Perimeter: { return EGCodeExtrusionRole::Perimeter; }
case Slic3r::GCodeExtrusionRole::ExternalPerimeter: { return EGCodeExtrusionRole::ExternalPerimeter; }
case Slic3r::GCodeExtrusionRole::OverhangPerimeter: { return EGCodeExtrusionRole::OverhangPerimeter; }
case Slic3r::GCodeExtrusionRole::InternalInfill: { return EGCodeExtrusionRole::InternalInfill; }
case Slic3r::GCodeExtrusionRole::SolidInfill: { return EGCodeExtrusionRole::SolidInfill; }
case Slic3r::GCodeExtrusionRole::TopSolidInfill: { return EGCodeExtrusionRole::TopSolidInfill; }
case Slic3r::GCodeExtrusionRole::Ironing: { return EGCodeExtrusionRole::Ironing; }
case Slic3r::GCodeExtrusionRole::BridgeInfill: { return EGCodeExtrusionRole::BridgeInfill; }
case Slic3r::GCodeExtrusionRole::GapFill: { return EGCodeExtrusionRole::GapFill; }
case Slic3r::GCodeExtrusionRole::Skirt: { return EGCodeExtrusionRole::Skirt; }
case Slic3r::GCodeExtrusionRole::SupportMaterial: { return EGCodeExtrusionRole::SupportMaterial; }
case Slic3r::GCodeExtrusionRole::SupportMaterialInterface: { return EGCodeExtrusionRole::SupportMaterialInterface; }
case Slic3r::GCodeExtrusionRole::WipeTower: { return EGCodeExtrusionRole::WipeTower; }
case Slic3r::GCodeExtrusionRole::Custom: { return EGCodeExtrusionRole::Custom; }
}
assert(false);
return EGCodeExtrusionRole::None;
}
// mapping from Slic3r::EMoveType to libvgcode::EMoveType
static EMoveType convert(Slic3r::EMoveType type)
{
switch (type)
{
case Slic3r::EMoveType::Noop: { return EMoveType::Noop; }
case Slic3r::EMoveType::Retract: { return EMoveType::Retract; }
case Slic3r::EMoveType::Unretract: { return EMoveType::Unretract; }
case Slic3r::EMoveType::Seam: { return EMoveType::Seam; }
case Slic3r::EMoveType::Tool_change: { return EMoveType::ToolChange; }
case Slic3r::EMoveType::Color_change: { return EMoveType::ColorChange; }
case Slic3r::EMoveType::Pause_Print: { return EMoveType::PausePrint; }
case Slic3r::EMoveType::Custom_GCode: { return EMoveType::CustomGCode; }
case Slic3r::EMoveType::Travel: { return EMoveType::Travel; }
case Slic3r::EMoveType::Wipe: { return EMoveType::Wipe; }
case Slic3r::EMoveType::Extrude: { return EMoveType::Extrude; }
}
assert(false);
return EMoveType::COUNT;
}
// mapping from Slic3r::GUI::Preview::OptionType to libvgcode::EOptionType
static EOptionType convert(const Slic3r::GUI::Preview::OptionType& type)
{
switch (type)
{
case Slic3r::GUI::Preview::OptionType::Travel: { return EOptionType::Travels; }
case Slic3r::GUI::Preview::OptionType::Wipe: { return EOptionType::Wipes; }
case Slic3r::GUI::Preview::OptionType::Retractions: { return EOptionType::Retractions; }
case Slic3r::GUI::Preview::OptionType::Unretractions: { return EOptionType::Unretractions; }
case Slic3r::GUI::Preview::OptionType::Seams: { return EOptionType::Seams; }
case Slic3r::GUI::Preview::OptionType::ToolChanges: { return EOptionType::ToolChanges; }
case Slic3r::GUI::Preview::OptionType::ColorChanges: { return EOptionType::ColorChanges; }
case Slic3r::GUI::Preview::OptionType::PausePrints: { return EOptionType::PausePrints; }
case Slic3r::GUI::Preview::OptionType::CustomGCodes: { return EOptionType::CustomGCodes; }
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::COUNT; }
case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::COUNT; }
#else
case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::CenterOfGravity; }
case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::ToolMarker; }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
}
assert(false);
return EOptionType::COUNT;
}
// mapping from Slic3r::PrintEstimatedStatistics::ETimeMode to libvgcode::ETimeMode
static ETimeMode convert(const Slic3r::PrintEstimatedStatistics::ETimeMode& mode)
{
switch (mode)
{
case Slic3r::PrintEstimatedStatistics::ETimeMode::Normal: { return ETimeMode::Normal; }
case Slic3r::PrintEstimatedStatistics::ETimeMode::Stealth: { return ETimeMode::Stealth; }
}
assert(false);
return ETimeMode::COUNT;
}
// mapping from libvgcode::ETimeMode to Slic3r::PrintEstimatedStatistics::ETimeMode
static Slic3r::PrintEstimatedStatistics::ETimeMode convert(const ETimeMode& mode)
{
switch (mode)
{
case ETimeMode::Normal: { return Slic3r::PrintEstimatedStatistics::ETimeMode::Normal; }
case ETimeMode::Stealth: { return Slic3r::PrintEstimatedStatistics::ETimeMode::Stealth; }
}
assert(false);
return Slic3r::PrintEstimatedStatistics::ETimeMode::Count;
}
// mapping from Slic3r::GCodeProcessorResult to libvgcode::GCodeInputData
static GCodeInputData convert(const Slic3r::GCodeProcessorResult& result)
{
const std::vector<Slic3r::GCodeProcessorResult::MoveVertex>& moves = result.moves;
GCodeInputData ret;
ret.vertices.reserve(2 * moves.size());
for (size_t i = 1; i < moves.size(); ++i) {
const Slic3r::GCodeProcessorResult::MoveVertex& curr = moves[i];
const Slic3r::GCodeProcessorResult::MoveVertex& prev = moves[i - 1];
const EMoveType curr_type = convert(curr.type);
const EGCodeExtrusionRole curr_role = convert(curr.extrusion_role);
EGCodeExtrusionRole extrusion_role;
if (curr_type == EMoveType::Travel) {
// for travel moves set the extrusion role
// which will be used later to select the proper color
if (curr.delta_extruder == 0.0f)
extrusion_role = static_cast<EGCodeExtrusionRole>(0); // Move
else if (curr.delta_extruder > 0.0f)
extrusion_role = static_cast<EGCodeExtrusionRole>(1); // Extrude
else
extrusion_role = static_cast<EGCodeExtrusionRole>(2); // Retract
}
else
extrusion_role = convert(curr.extrusion_role);
float width;
float height;
switch (curr_type)
{
case EMoveType::Travel:
{
width = Default_Travel_Radius;
height = Default_Travel_Radius;
break;
}
case EMoveType::Wipe:
{
width = Default_Wipe_Radius;
height = Default_Wipe_Radius;
break;
}
default:
{
width = curr.width;
height = curr.height;
break;
}
}
if (type_to_option(curr_type) == libvgcode::EOptionType::COUNT) {
if (ret.vertices.empty() || prev.type != curr.type || prev.extrusion_role != curr.extrusion_role) {
// to allow libvgcode to properly detect the start/end of a path we need to add a 'phantom' vertex
// equal to the current one with the exception of the position, which should match the previous move position,
// and the times, which are set to zero
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#else
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), 0.0f, extrusion_role, curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex);
}
}
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type, static_cast<uint32_t>(curr.gcode_id),
static_cast<uint32_t>(curr.layer_id), static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time };
#else
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), curr.mm3_per_mm * (curr.position - prev.position).norm(),
extrusion_role, curr_type, static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex);
}
ret.vertices.shrink_to_fit();
ret.extruders_count = static_cast<uint8_t>(result.extruders_count);
return ret;
}
} // namespace libvgcode
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // slic3r_LibVGCodeWrapper_hpp_

View File

@ -14,19 +14,61 @@
namespace libvgcode {
//
// Helper class to interpolate between colors defined in Ranges_Colors palette.
// Interpolation can be done linearly or logarithmically.
// Usage:
// 1) Define an instance of ColorRange of the desired type
// ColorRange range(EColorRangeType::Linear);
// 2) Pass to the instance all the values needed to setup the range:
// for (size_t i = 0; i < my_data.size(); ++i) {
// range.update(my_data[i]);
// }
// 3) Get the color at the desired value:
// Color c = range.get_color_at(value);
//
class ColorRange
{
public:
//
// Constructor
//
explicit ColorRange(EColorRangeType type = EColorRangeType::Linear);
//
// Use the passed value to update the range
//
void update(float value);
//
// Reset the range
// Call this method before reuse an instance of ColorRange
//
void reset();
//
// Return the type of this ColorRange
//
EColorRangeType get_type() const;
//
// Return the interpolated color at the given value
// Value is clamped to the range
//
Color get_color_at(float value) const;
//
// Return the range of this ColorRange
// [0] -> min
// [1] -> max
//
const std::array<float, 2>& get_range() const;
float get_step_size() const;
std::vector<float> get_values() const;
static const ColorRange Dummy_Color_Range;
private:
EColorRangeType m_type{ EColorRangeType::Linear };
@ -35,6 +77,11 @@ private:
// [1] = max
//
std::array<float, 2> m_range{ FLT_MAX, -FLT_MAX };
//
// Count of different values passed to update()
//
size_t m_count{ 0 };
};
} // namespace libvgcode

View File

@ -16,6 +16,11 @@ namespace libvgcode {
struct GCodeInputData
{
//
// Count of extruders
//
uint8_t extruders_count{ 0 };
//
// List of path vertices
//

View File

@ -47,6 +47,13 @@ using Mat4x4 = std::array<float, 16>;
//
using Color = std::array<uint8_t, 3>;
//
// Axis aligned box in 3 dimensions
// [0] -> { min_x, min_y, min_z }
// [1] -> { max_x, max_y, max_z }
//
using AABox = std::array<Vec3, 2>;
//
// View types
//
@ -108,6 +115,8 @@ enum class EGCodeExtrusionRole : uint8_t
COUNT
};
static constexpr size_t GCode_Extrusion_Roles_Count = static_cast<size_t>(EGCodeExtrusionRole::COUNT);
//
// Option types
//
@ -124,7 +133,6 @@ enum class EOptionType : uint8_t
CustomGCodes,
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
CenterOfGravity,
Shells,
ToolMarker,
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
COUNT
@ -143,7 +151,7 @@ enum class ETimeMode : uint8_t
static constexpr size_t Time_Modes_Count = static_cast<size_t>(ETimeMode::COUNT);
//
// Color range type
// Color range types
//
enum class EColorRangeType : uint8_t
{
@ -154,6 +162,17 @@ enum class EColorRangeType : uint8_t
static constexpr size_t Color_Range_Types_Count = static_cast<size_t>(EColorRangeType::COUNT);
//
// Bounding box types
//
enum class EBBoxType : uint8_t
{
Full,
Extrusion,
ExtrusionNoCustom,
COUNT
};
//
// Predefined colors
//

View File

@ -17,6 +17,7 @@ namespace libvgcode {
class ViewerImpl;
struct GCodeInputData;
struct PathVertex;
class ColorRange;
class Viewer
{
@ -39,13 +40,25 @@ public:
ETimeMode get_time_mode() const;
void set_time_mode(ETimeMode mode);
const std::array<uint32_t, 2>& get_layers_range() const;
void set_layers_range(const std::array<uint32_t, 2>& range);
void set_layers_range(uint32_t min, uint32_t max);
const std::array<uint32_t, 2>& get_layers_view_range() const;
void set_layers_view_range(const std::array<uint32_t, 2>& range);
void set_layers_view_range(uint32_t min, uint32_t max);
bool is_top_layer_only_view_range() const;
void set_top_layer_only_view_range(bool top_layer_only_view_range);
size_t get_layers_count() const;
float get_layer_z(size_t layer_id) const;
std::vector<float> get_layers_zs() const;
size_t get_layer_id_at(float z) const;
size_t get_extruders_count() const;
size_t get_used_extruders_count() const;
const std::vector<uint8_t>& get_used_extruders_ids() const;
AABox get_bounding_box(EBBoxType type) const;
bool is_option_visible(EOptionType type) const;
void toggle_option_visibility(EOptionType type);
@ -135,13 +148,13 @@ public:
const std::vector<Color>& get_tool_colors() const;
void set_tool_colors(const std::vector<Color>& colors);
const std::array<float, 2>& get_height_range() const;
const std::array<float, 2>& get_width_range() const;
const std::array<float, 2>& get_speed_range() const;
const std::array<float, 2>& get_fan_speed_range() const;
const std::array<float, 2>& get_temperature_range() const;
const std::array<float, 2>& get_volumetric_rate_range() const;
std::array<float, 2> get_layer_time_range(EColorRangeType type) const;
const ColorRange& get_height_range() const;
const ColorRange& get_width_range() const;
const ColorRange& get_speed_range() const;
const ColorRange& get_fan_speed_range() const;
const ColorRange& get_temperature_range() const;
const ColorRange& get_volumetric_rate_range() const;
const ColorRange& get_layer_time_range(EColorRangeType type) const;
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
//

View File

@ -7,7 +7,7 @@
///|/
///|/ libvgcode is released under the terms of the AGPLv3 or higher
///|/
#include "ColorRange.hpp"
#include "../include/ColorRange.hpp"
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
@ -19,6 +19,8 @@
namespace libvgcode {
const ColorRange ColorRange::Dummy_Color_Range = ColorRange();
ColorRange::ColorRange(EColorRangeType type)
: m_type(type)
{
@ -26,6 +28,9 @@ ColorRange::ColorRange(EColorRangeType type)
void ColorRange::update(float value)
{
if (value != m_range[0] && value != m_range[1])
++m_count;
m_range[0] = std::min(m_range[0], value);
m_range[1] = std::max(m_range[1], value);
}
@ -33,22 +38,7 @@ void ColorRange::update(float value)
void ColorRange::reset()
{
m_range = { FLT_MAX, -FLT_MAX };
}
static float step_size(const std::array<float, 2>& range, EColorRangeType type)
{
switch (type)
{
default:
case EColorRangeType::Linear:
{
return (range[1] - range[0]) / (static_cast<float>(Ranges_Colors.size()) - 1.0f);
}
case EColorRangeType::Logarithmic:
{
return (range[0] != 0.0f) ? std::log(range[1] / range[0]) / (static_cast<float>(Ranges_Colors.size()) - 1.0f) : 0.0f;
}
}
m_count = 0;
}
EColorRangeType ColorRange::get_type() const
@ -61,7 +51,7 @@ Color ColorRange::get_color_at(float value) const
// Input value scaled to the colors range
float global_t = 0.0f;
value = std::clamp(value, m_range[0], m_range[1]);
const float step = step_size(m_range, m_type);
const float step = get_step_size();
if (step > 0.0f) {
if (m_type == EColorRangeType::Logarithmic) {
if (m_range[0] != 0.0f)
@ -74,7 +64,7 @@ Color ColorRange::get_color_at(float value) const
const size_t color_max_idx = Ranges_Colors.size() - 1;
// Compute the two colors just below (low) and above (high) the input value
const size_t color_low_idx = std::clamp<size_t>(static_cast<size_t>(global_t), 0, color_max_idx);
const size_t color_low_idx = std::clamp<size_t>(global_t, 0, color_max_idx);
const size_t color_high_idx = std::clamp<size_t>(color_low_idx + 1, 0, color_max_idx);
// Interpolate between the low and high colors to find exactly which color the input value should get
@ -86,6 +76,52 @@ const std::array<float, 2>& ColorRange::get_range() const
return m_range;
}
float ColorRange::get_step_size() const
{
switch (m_type)
{
default:
case EColorRangeType::Linear:
{
return (m_range[1] - m_range[0]) / (static_cast<float>(Ranges_Colors.size()) - 1.0f);
}
case EColorRangeType::Logarithmic:
{
return (m_range[0] != 0.0f) ? std::log(m_range[1] / m_range[0]) / (static_cast<float>(Ranges_Colors.size()) - 1.0f) : 0.0f;
}
}
}
std::vector<float> ColorRange::get_values() const
{
std::vector<float> ret;
if (m_count == 1) {
// single item use case
ret.emplace_back(m_range[0]);
}
else if (m_count == 2) {
// two items use case
ret.emplace_back(m_range[0]);
ret.emplace_back(m_range[1]);
}
else {
const float step_size = get_step_size();
for (size_t i = 0; i < Ranges_Colors.size(); ++i) {
float value = 0.0f;
switch (m_type)
{
default:
case EColorRangeType::Linear: { value = m_range[0] + static_cast<float>(i) * step_size; break; }
case EColorRangeType::Logarithmic: { value = ::exp(::log(m_range[0]) + static_cast<float>(i) * step_size); break; }
}
ret.emplace_back(value);
}
}
return ret;
}
} // namespace libvgcode
//################################################################################################################################

View File

@ -27,18 +27,21 @@ static bool is_colorprint_option(const PathVertex& v)
void Layers::update(const PathVertex& vertex, uint32_t vertex_id)
{
if (m_items.empty() || vertex.layer_id == m_items.size()) {
// this code assumes that gcode paths are sent sequentially, one layer after the other
assert(vertex.layer_id == static_cast<uint32_t>(m_items.size()));
Item& item = m_items.emplace_back(Item());
if (vertex.type == EMoveType::Extrude && vertex.role != EGCodeExtrusionRole::Custom)
item.z = vertex.position[2];
item.range.set(vertex_id, vertex_id);
item.times = vertex.times;
item.contains_colorprint_options |= is_colorprint_option(vertex);
}
else {
Item& item = m_items.back();
item.range.set(item.range.get()[0], vertex_id);
if (vertex.type == EMoveType::Extrude && vertex.role != EGCodeExtrusionRole::Custom && item.z != vertex.position[2])
item.z = vertex.position[2];
item.range.set_max(vertex_id);
for (size_t i = 0; i < Time_Modes_Count; ++i) {
item.times[i] += vertex.times[i];
}
@ -62,24 +65,44 @@ size_t Layers::count() const
return m_items.size();
}
float Layers::get_time(ETimeMode mode, uint32_t layer_id) const
{
return (mode < ETimeMode::COUNT&& layer_id < static_cast<uint32_t>(m_items.size())) ?
m_items[layer_id].times[static_cast<size_t>(mode)] : 0.0f;
}
std::vector<float> Layers::get_times(ETimeMode mode) const
{
std::vector<float> ret;
if (mode < ETimeMode::COUNT) {
const size_t mode_id = static_cast<size_t>(mode);
for (const Item& item : m_items) {
ret.emplace_back(item.times[mode_id]);
ret.emplace_back(item.times[static_cast<size_t>(mode)]);
}
}
return ret;
}
std::vector<float> Layers::get_zs() const
{
std::vector<float> ret;
ret.reserve(m_items.size());
for (const Item& item : m_items) {
ret.emplace_back(item.z);
}
return ret;
}
float Layers::get_layer_time(ETimeMode mode, size_t layer_id) const
{
return (mode < ETimeMode::COUNT&& layer_id < m_items.size()) ?
m_items[layer_id].times[static_cast<size_t>(mode)] : 0.0f;
}
float Layers::get_layer_z(size_t layer_id) const
{
return (layer_id < m_items.size()) ? m_items[layer_id].z : 0.0f;
}
size_t Layers::get_layer_id_at(float z) const
{
auto iter = std::upper_bound(m_items.begin(), m_items.end(), z, [](float z, const Item& item) { return item.z < z; });
return std::distance(m_items.begin(), iter);
}
const std::array<uint32_t, 2>& Layers::get_view_range() const
{
return m_view_range.get();
@ -95,9 +118,9 @@ void Layers::set_view_range(uint32_t min, uint32_t max)
m_view_range.set(min, max);
}
bool Layers::layer_contains_colorprint_options(uint32_t layer_id) const
bool Layers::layer_contains_colorprint_options(size_t layer_id) const
{
return (layer_id < static_cast<uint32_t>(m_items.size())) ? m_items[layer_id].contains_colorprint_options : false;
return (layer_id < m_items.size()) ? m_items[layer_id].contains_colorprint_options : false;
}
} // namespace libvgcode

View File

@ -26,18 +26,23 @@ public:
bool empty() const;
size_t count() const;
float get_time(ETimeMode mode, uint32_t layer_id) const;
std::vector<float> get_times(ETimeMode mode) const;
std::vector<float> get_zs() const;
float get_layer_time(ETimeMode mode, size_t layer_id) const;
float get_layer_z(size_t layer_id) const;
size_t get_layer_id_at(float z) const;
const std::array<uint32_t, 2>& get_view_range() const;
void set_view_range(const std::array<uint32_t, 2>& range);
void set_view_range(uint32_t min, uint32_t max);
bool layer_contains_colorprint_options(uint32_t layer_id) const;
bool layer_contains_colorprint_options(size_t layer_id) const;
private:
struct Item
{
float z{ 0.0f };
Range range;
std::array<float, Time_Modes_Count> times{ 0.0f, 0.0f };
bool contains_colorprint_options{ false };

View File

@ -37,7 +37,6 @@ struct Settings
{ EOptionType::CustomGCodes, false },
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
{ EOptionType::CenterOfGravity, false },
{ EOptionType::Shells, false },
{ EOptionType::ToolMarker, true }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} };

View File

@ -67,19 +67,19 @@ void Viewer::set_time_mode(ETimeMode mode)
m_impl->set_time_mode(mode);
}
const std::array<uint32_t, 2>& Viewer::get_layers_range() const
const std::array<uint32_t, 2>& Viewer::get_layers_view_range() const
{
return m_impl->get_layers_range();
return m_impl->get_layers_view_range();
}
void Viewer::set_layers_range(const std::array<uint32_t, 2>& range)
void Viewer::set_layers_view_range(const std::array<uint32_t, 2>& range)
{
m_impl->set_layers_range(range);
m_impl->set_layers_view_range(range);
}
void Viewer::set_layers_range(uint32_t min, uint32_t max)
void Viewer::set_layers_view_range(uint32_t min, uint32_t max)
{
m_impl->set_layers_range(min, max);
m_impl->set_layers_view_range(min, max);
}
bool Viewer::is_top_layer_only_view_range() const
@ -92,6 +92,46 @@ void Viewer::set_top_layer_only_view_range(bool top_layer_only_view_range)
m_impl->set_top_layer_only_view_range(top_layer_only_view_range);
}
size_t Viewer::get_layers_count() const
{
return m_impl->get_layers_count();
}
float Viewer::get_layer_z(size_t layer_id) const
{
return m_impl->get_layer_z(layer_id);
}
std::vector<float> Viewer::get_layers_zs() const
{
return m_impl->get_layers_zs();
}
size_t Viewer::get_layer_id_at(float z) const
{
return m_impl->get_layer_id_at(z);
}
size_t Viewer::get_extruders_count() const
{
return m_impl->get_extruders_count();
}
size_t Viewer::get_used_extruders_count() const
{
return m_impl->get_used_extruders_count();
}
const std::vector<uint8_t>& Viewer::get_used_extruders_ids() const
{
return m_impl->get_used_extruders_ids();
}
AABox Viewer::get_bounding_box(EBBoxType type) const
{
return m_impl->get_bounding_box(type);
}
bool Viewer::is_option_visible(EOptionType type) const
{
return m_impl->is_option_visible(type);
@ -222,37 +262,37 @@ void Viewer::set_tool_colors(const std::vector<Color>& colors)
m_impl->set_tool_colors(colors);
}
const std::array<float, 2>& Viewer::get_height_range() const
const ColorRange& Viewer::get_height_range() const
{
return m_impl->get_height_range();
}
const std::array<float, 2>& Viewer::get_width_range() const
const ColorRange& Viewer::get_width_range() const
{
return m_impl->get_width_range();
}
const std::array<float, 2>& Viewer::get_speed_range() const
const ColorRange& Viewer::get_speed_range() const
{
return m_impl->get_speed_range();
}
const std::array<float, 2>& Viewer::get_fan_speed_range() const
const ColorRange& Viewer::get_fan_speed_range() const
{
return m_impl->get_fan_speed_range();
}
const std::array<float, 2>& Viewer::get_temperature_range() const
const ColorRange& Viewer::get_temperature_range() const
{
return m_impl->get_temperature_range();
}
const std::array<float, 2>& Viewer::get_volumetric_rate_range() const
const ColorRange& Viewer::get_volumetric_rate_range() const
{
return m_impl->get_volumetric_rate_range();
}
std::array<float, 2> Viewer::get_layer_time_range(EColorRangeType type) const
const ColorRange& Viewer::get_layer_time_range(EColorRangeType type) const
{
return m_impl->get_layer_time_range(type);
}

View File

@ -200,69 +200,6 @@ static Mat4x4 inverse(const Mat4x4& m)
return ret;
}
static std::string short_time(const std::string& time)
{
// Parse the dhms time format.
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
if (time.find('d') != std::string::npos)
sscanf(time.c_str(), "%dd %dh %dm %ds", &days, &hours, &minutes, &seconds);
else if (time.find('h') != std::string::npos)
sscanf(time.c_str(), "%dh %dm %ds", &hours, &minutes, &seconds);
else if (time.find('m') != std::string::npos)
sscanf(time.c_str(), "%dm %ds", &minutes, &seconds);
else if (time.find('s') != std::string::npos)
sscanf(time.c_str(), "%ds", &seconds);
// Round to full minutes.
if (days + hours + minutes > 0 && seconds >= 30) {
if (++minutes == 60) {
minutes = 0;
if (++hours == 24) {
hours = 0;
++days;
}
}
}
// Format the dhm time
char buffer[64];
if (days > 0)
sprintf(buffer, "%dd%dh%dm", days, hours, minutes);
else if (hours > 0)
sprintf(buffer, "%dh%dm", hours, minutes);
else if (minutes > 0)
sprintf(buffer, "%dm", minutes);
else
sprintf(buffer, "%ds", seconds);
return buffer;
}
// Returns the given time is seconds in format DDd HHh MMm SSs
static std::string get_time_dhms(float time_in_secs)
{
int days = (int)(time_in_secs / 86400.0f);
time_in_secs -= (float)days * 86400.0f;
int hours = (int)(time_in_secs / 3600.0f);
time_in_secs -= (float)hours * 3600.0f;
int minutes = (int)(time_in_secs / 60.0f);
time_in_secs -= (float)minutes * 60.0f;
char buffer[64];
if (days > 0)
sprintf(buffer, "%dd %dh %dm %ds", days, hours, minutes, (int)time_in_secs);
else if (hours > 0)
sprintf(buffer, "%dh %dm %ds", hours, minutes, (int)time_in_secs);
else if (minutes > 0)
sprintf(buffer, "%dm %ds", minutes, (int)time_in_secs);
else
sprintf(buffer, "%ds", (int)std::round(time_in_secs));
return buffer;
}
std::string check_shader(GLuint handle)
{
std::string ret;
@ -446,6 +383,8 @@ void ViewerImpl::reset()
m_view_range.reset();
m_extrusion_roles.reset();
m_travels_time = { 0.0f, 0.0f };
m_extruders_count = 0;
m_used_extruders_ids.clear();
m_vertices.clear();
m_valid_lines_bitset.clear();
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
@ -470,14 +409,17 @@ void ViewerImpl::reset()
void ViewerImpl::load(GCodeInputData&& gcode_data)
{
m_loading = true;
m_vertices = std::move(gcode_data.vertices);
m_extruders_count = gcode_data.extruders_count;
for (size_t i = 0; i < m_vertices.size(); ++i) {
const PathVertex& v = m_vertices[i];
m_layers.update(v, static_cast<uint32_t>(i));
if (v.type == EMoveType::Travel) {
for (size_t i = 0; i < Time_Modes_Count; ++i) {
m_travels_time[i] += v.times[i];
for (size_t j = 0; j < Time_Modes_Count; ++j) {
m_travels_time[j] += v.times[j];
}
}
else
@ -501,6 +443,9 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
if (!m_layers.empty())
m_layers.set_view_range(0, static_cast<uint32_t>(m_layers.count()) - 1);
std::sort(m_used_extruders_ids.begin(), m_used_extruders_ids.end());
m_used_extruders_ids.erase(std::unique(m_used_extruders_ids.begin(), m_used_extruders_ids.end()), m_used_extruders_ids.end());
// reset segments visibility bitset
m_valid_lines_bitset = BitSet<>(m_vertices.size());
m_valid_lines_bitset.setAll();
@ -582,9 +527,12 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
}
if (!m_layers.empty())
set_layers_range(0, static_cast<uint32_t>(m_layers.count() - 1));
set_layers_view_range(0, static_cast<uint32_t>(m_layers.count() - 1));
m_settings.update_colors = true;
update_enabled_entities();
update_colors();
m_loading = false;
}
void ViewerImpl::update_enabled_entities()
@ -662,6 +610,8 @@ void ViewerImpl::update_enabled_entities()
glsafe(glBufferData(GL_TEXTURE_BUFFER, 0, nullptr, GL_STATIC_DRAW));
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
m_settings.update_enabled_entities = false;
}
static float encode_color(const Color& color) {
@ -688,30 +638,30 @@ void ViewerImpl::update_colors()
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_colors_buf_id));
glsafe(glBufferData(GL_TEXTURE_BUFFER, colors.size() * sizeof(float), colors.data(), GL_STATIC_DRAW));
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
m_settings.update_colors = false;
}
void ViewerImpl::render(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{
if (m_settings.update_view_full_range) {
// ensure that the render does take place while loading the data
if (m_loading)
return;
if (m_settings.update_view_full_range)
update_view_full_range();
m_settings.update_view_full_range = false;
}
if (m_settings.update_enabled_entities) {
if (m_settings.update_enabled_entities)
update_enabled_entities();
m_settings.update_enabled_entities = false;
}
if (m_settings.update_colors) {
if (m_settings.update_colors)
update_colors();
m_settings.update_colors = false;
}
const Mat4x4 inv_view_matrix = inverse(view_matrix);
const Vec3 camera_position = { inv_view_matrix[12], inv_view_matrix[13], inv_view_matrix[14] };
render_segments(view_matrix, projection_matrix, camera_position);
render_options(view_matrix, projection_matrix);
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (m_settings.options_visibility.at(EOptionType::ToolMarker))
render_tool_marker(view_matrix, projection_matrix);
@ -742,22 +692,21 @@ void ViewerImpl::set_time_mode(ETimeMode mode)
m_settings.update_colors = true;
}
const std::array<uint32_t, 2>& ViewerImpl::get_layers_range() const
const std::array<uint32_t, 2>& ViewerImpl::get_layers_view_range() const
{
return m_layers.get_view_range();
}
void ViewerImpl::set_layers_range(const std::array<uint32_t, 2>& range)
void ViewerImpl::set_layers_view_range(const std::array<uint32_t, 2>& range)
{
set_layers_range(range[0], range[1]);
set_layers_view_range(range[0], range[1]);
}
void ViewerImpl::set_layers_range(uint32_t min, uint32_t max)
void ViewerImpl::set_layers_view_range(uint32_t min, uint32_t max)
{
m_layers.set_view_range(min, max);
// force immediate update of the full range
update_view_full_range();
m_settings.update_view_full_range = false;
m_settings.update_enabled_entities = true;
m_settings.update_colors = true;
}
@ -773,6 +722,60 @@ void ViewerImpl::set_top_layer_only_view_range(bool top_layer_only_view_range)
m_settings.update_colors = true;
}
size_t ViewerImpl::get_layers_count() const
{
return m_layers.count();
}
float ViewerImpl::get_layer_z(size_t layer_id) const
{
return m_layers.get_layer_z(layer_id);
}
std::vector<float> ViewerImpl::get_layers_zs() const
{
return m_layers.get_zs();
}
size_t ViewerImpl::get_layer_id_at(float z) const
{
return m_layers.get_layer_id_at(z);
}
size_t ViewerImpl::get_extruders_count() const
{
return m_extruders_count;
}
size_t ViewerImpl::get_used_extruders_count() const
{
return m_used_extruders_ids.size();
}
const std::vector<uint8_t>& ViewerImpl::get_used_extruders_ids() const
{
return m_used_extruders_ids;
}
AABox ViewerImpl::get_bounding_box(EBBoxType type) const
{
assert(type < EBBoxType::COUNT);
Vec3 min = { FLT_MAX, FLT_MAX, FLT_MAX };
Vec3 max = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
for (const PathVertex& v : m_vertices) {
if (type != EBBoxType::Full && (v.type != EMoveType::Extrude || v.width == 0.0f || v.height == 0.0f))
continue;
else if (type == EBBoxType::ExtrusionNoCustom && v.role == EGCodeExtrusionRole::Custom)
continue;
for (int j = 0; j < 3; ++j) {
min[j] = std::min(min[j], v.position[j]);
max[j] = std::max(max[j], v.position[j]);
}
}
return { min, max };
}
bool ViewerImpl::is_option_visible(EOptionType type) const
{
try {
@ -841,8 +844,6 @@ void ViewerImpl::set_view_visible_range(uint32_t min, uint32_t max)
// force update of the full range, to avoid clamping the visible range with full old values
// when calling m_view_range.set_visible()
update_view_full_range();
m_settings.update_view_full_range = false;
m_view_range.set_visible(min, max);
m_settings.update_enabled_entities = true;
m_settings.update_colors = true;
@ -939,43 +940,43 @@ void ViewerImpl::set_tool_colors(const std::vector<Color>& colors)
m_settings.update_colors = true;
}
const std::array<float, 2>& ViewerImpl::get_height_range() const
const ColorRange& ViewerImpl::get_height_range() const
{
return m_height_range.get_range();
return m_height_range;
}
const std::array<float, 2>& ViewerImpl::get_width_range() const
const ColorRange& ViewerImpl::get_width_range() const
{
return m_width_range.get_range();
return m_width_range;
}
const std::array<float, 2>& ViewerImpl::get_speed_range() const
const ColorRange& ViewerImpl::get_speed_range() const
{
return m_speed_range.get_range();
return m_speed_range;
}
const std::array<float, 2>& ViewerImpl::get_fan_speed_range() const
const ColorRange& ViewerImpl::get_fan_speed_range() const
{
return m_fan_speed_range.get_range();
return m_fan_speed_range;
}
const std::array<float, 2>& ViewerImpl::get_temperature_range() const
const ColorRange& ViewerImpl::get_temperature_range() const
{
return m_temperature_range.get_range();
return m_temperature_range;
}
const std::array<float, 2>& ViewerImpl::get_volumetric_rate_range() const
const ColorRange& ViewerImpl::get_volumetric_rate_range() const
{
return m_volumetric_rate_range.get_range();
return m_volumetric_rate_range;
}
std::array<float, 2> ViewerImpl::get_layer_time_range(EColorRangeType type) const
const ColorRange& ViewerImpl::get_layer_time_range(EColorRangeType type) const
{
try {
return m_layer_time_range[static_cast<size_t>(type)].get_range();
return m_layer_time_range[static_cast<size_t>(type)];
}
catch (...) {
return { 0.0f, 0.0f };
return ColorRange::Dummy_Color_Range;
}
}
@ -1059,16 +1060,16 @@ void ViewerImpl::set_tool_marker_alpha(float alpha)
static bool is_visible(const PathVertex& v, const Settings& settings)
{
try {
return ((v.type == EMoveType::Travel && !settings.options_visibility.at(EOptionType::Travels)) ||
(v.type == EMoveType::Wipe && !settings.options_visibility.at(EOptionType::Wipes)) ||
(v.type == EMoveType::Retract && !settings.options_visibility.at(EOptionType::Retractions)) ||
(v.type == EMoveType::Unretract && !settings.options_visibility.at(EOptionType::Unretractions)) ||
(v.type == EMoveType::Seam && !settings.options_visibility.at(EOptionType::Seams)) ||
(v.type == EMoveType::ToolChange && !settings.options_visibility.at(EOptionType::ToolChanges)) ||
(v.type == EMoveType::ColorChange && !settings.options_visibility.at(EOptionType::ColorChanges)) ||
(v.type == EMoveType::PausePrint && !settings.options_visibility.at(EOptionType::PausePrints)) ||
(v.type == EMoveType::CustomGCode && !settings.options_visibility.at(EOptionType::CustomGCodes)) ||
(v.type == EMoveType::Extrude && !settings.extrusion_roles_visibility.at(v.role))) ? false : true;
return ((v.type == EMoveType::Travel && !settings.options_visibility.at(EOptionType::Travels)) ||
(v.type == EMoveType::Wipe && !settings.options_visibility.at(EOptionType::Wipes)) ||
(v.type == EMoveType::Retract && !settings.options_visibility.at(EOptionType::Retractions)) ||
(v.type == EMoveType::Unretract && !settings.options_visibility.at(EOptionType::Unretractions)) ||
(v.type == EMoveType::Seam && !settings.options_visibility.at(EOptionType::Seams)) ||
(v.type == EMoveType::ToolChange && !settings.options_visibility.at(EOptionType::ToolChanges)) ||
(v.type == EMoveType::ColorChange && !settings.options_visibility.at(EOptionType::ColorChanges)) ||
(v.type == EMoveType::PausePrint && !settings.options_visibility.at(EOptionType::PausePrints)) ||
(v.type == EMoveType::CustomGCode && !settings.options_visibility.at(EOptionType::CustomGCodes)) ||
(v.type == EMoveType::Extrude && !settings.extrusion_roles_visibility.at(v.role))) ? false : true;
}
catch (...) {
return false;
@ -1145,6 +1146,8 @@ void ViewerImpl::update_view_full_range()
else
m_view_range.set_enabled(m_view_range.get_full());
}
m_settings.update_view_full_range = false;
}
void ViewerImpl::update_color_ranges()
@ -1232,12 +1235,14 @@ Color ViewerImpl::select_color(const PathVertex& v) const
case EViewType::LayerTimeLinear:
{
assert(!v.is_travel() || role < Travels_Colors.size());
return v.is_travel() ? Travels_Colors[role] : m_layer_time_range[0].get_color_at(m_layers.get_time(m_settings.time_mode, v.layer_id));
return v.is_travel() ? Travels_Colors[role] :
m_layer_time_range[0].get_color_at(m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id)));
}
case EViewType::LayerTimeLogarithmic:
{
assert(!v.is_travel() || role < Travels_Colors.size());
return v.is_travel() ? Travels_Colors[role] : m_layer_time_range[1].get_color_at(m_layers.get_time(m_settings.time_mode, v.layer_id));
return v.is_travel() ? Travels_Colors[role] :
m_layer_time_range[1].get_color_at(m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id)));
}
case EViewType::Tool:
{
@ -1246,7 +1251,8 @@ Color ViewerImpl::select_color(const PathVertex& v) const
}
case EViewType::ColorPrint:
{
return m_layers.layer_contains_colorprint_options(v.layer_id) ? Dummy_Color : m_tool_colors[v.color_id % m_tool_colors.size()];
return m_layers.layer_contains_colorprint_options(static_cast<size_t>(v.layer_id)) ? Dummy_Color :
m_tool_colors[static_cast<size_t>(v.color_id) % m_tool_colors.size()];
}
default: { break; }
}

View File

@ -18,8 +18,8 @@
#include "ToolMarker.hpp"
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#include "../include/PathVertex.hpp"
#include "../include/ColorRange.hpp"
#include "Bitset.hpp"
#include "ColorRange.hpp"
#include "ViewRange.hpp"
#include "Layers.hpp"
#include "ExtrusionRoles.hpp"
@ -77,13 +77,25 @@ public:
ETimeMode get_time_mode() const;
void set_time_mode(ETimeMode mode);
const std::array<uint32_t, 2>& get_layers_range() const;
void set_layers_range(const std::array<uint32_t, 2>& range);
void set_layers_range(uint32_t min, uint32_t max);
const std::array<uint32_t, 2>& get_layers_view_range() const;
void set_layers_view_range(const std::array<uint32_t, 2>& range);
void set_layers_view_range(uint32_t min, uint32_t max);
bool is_top_layer_only_view_range() const;
void set_top_layer_only_view_range(bool top_layer_only_view_range);
size_t get_layers_count() const;
float get_layer_z(size_t layer_id) const;
std::vector<float> get_layers_zs() const;
size_t get_layer_id_at(float z) const;
size_t get_extruders_count() const;
size_t get_used_extruders_count() const;
const std::vector<uint8_t>& get_used_extruders_ids() const;
AABox get_bounding_box(EBBoxType type) const;
bool is_option_visible(EOptionType type) const;
void toggle_option_visibility(EOptionType type);
@ -119,13 +131,13 @@ public:
const std::vector<Color>& get_tool_colors() const;
void set_tool_colors(const std::vector<Color>& colors);
const std::array<float, 2>& get_height_range() const;
const std::array<float, 2>& get_width_range() const;
const std::array<float, 2>& get_speed_range() const;
const std::array<float, 2>& get_fan_speed_range() const;
const std::array<float, 2>& get_temperature_range() const;
const std::array<float, 2>& get_volumetric_rate_range() const;
std::array<float, 2> get_layer_time_range(EColorRangeType type) const;
const ColorRange& get_height_range() const;
const ColorRange& get_width_range() const;
const ColorRange& get_speed_range() const;
const ColorRange& get_fan_speed_range() const;
const ColorRange& get_temperature_range() const;
const ColorRange& get_volumetric_rate_range() const;
const ColorRange& get_layer_time_range(EColorRangeType type) const;
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
Vec3 get_cog_marker_position() const;
@ -158,6 +170,10 @@ private:
ViewRange m_view_range;
ExtrusionRoles m_extrusion_roles;
std::array<float, Time_Modes_Count> m_travels_time{ 0.0f, 0.0f };
size_t m_extruders_count{ 0 };
std::vector<uint8_t> m_used_extruders_ids;
bool m_loading{ false };
//
// The OpenGL element used to represent all toolpath segments