New gcode visualization library - Travel and wipe moves as options

This commit is contained in:
enricoturri1966 2024-01-08 16:39:48 +01:00 committed by Lukas Matena
parent eaa1920bac
commit ecd829de80
16 changed files with 130 additions and 179 deletions

View File

@ -77,7 +77,7 @@ struct PathVertex
// //
// Segment estimated times // Segment estimated times
// //
std::array<float, Time_Modes_Count> times{ 0.0f, 0.0f }; std::array<float, TIME_MODES_COUNT> times{ 0.0f, 0.0f };
// //
// Return true if the segment is an extrusion move // Return true if the segment is an extrusion move
@ -102,7 +102,7 @@ struct PathVertex
bool is_custom_gcode() const; bool is_custom_gcode() const;
}; };
static const PathVertex Dummy_Path_Vertex = PathVertex(); static const PathVertex DUMMY_PATH_VERTEX = PathVertex();
} // namespace libvgcode } // namespace libvgcode

View File

@ -15,8 +15,8 @@ namespace libvgcode {
static constexpr float PI = 3.141592f; static constexpr float PI = 3.141592f;
static constexpr float Default_Travels_Radius = 0.1f; static constexpr float DEFAULT_TRAVELS_RADIUS = 0.1f;
static constexpr float Default_Wipes_Radius = 0.1f; static constexpr float DEFAULT_WIPES_RADIUS = 0.1f;
// //
// Vector in 3 dimensions // Vector in 3 dimensions
@ -77,7 +77,7 @@ enum class EViewType : uint8_t
COUNT COUNT
}; };
static constexpr size_t View_Types_Count = static_cast<size_t>(EViewType::COUNT); static constexpr size_t VIEW_TYPES_COUNT = static_cast<size_t>(EViewType::COUNT);
// //
// Move types // Move types
@ -98,20 +98,7 @@ enum class EMoveType : uint8_t
COUNT COUNT
}; };
static constexpr size_t Move_Types_Count = static_cast<size_t>(EMoveType::COUNT); static constexpr size_t MOVE_TYPES_COUNT = static_cast<size_t>(EMoveType::COUNT);
//
// Travel move types
//
enum class ETravelMoveType : uint8_t
{
Move,
Extrude,
Retract,
COUNT
};
static constexpr size_t Travel_Move_Types_Count = static_cast<size_t>(ETravelMoveType::COUNT);
// //
// Extrusion roles // Extrusion roles
@ -136,7 +123,7 @@ enum class EGCodeExtrusionRole : uint8_t
COUNT COUNT
}; };
static constexpr size_t GCode_Extrusion_Roles_Count = static_cast<size_t>(EGCodeExtrusionRole::COUNT); static constexpr size_t GCODE_EXTRUSION_ROLES_COUNT = static_cast<size_t>(EGCodeExtrusionRole::COUNT);
// //
// Option types // Option types
@ -159,7 +146,7 @@ enum class EOptionType : uint8_t
COUNT COUNT
}; };
static constexpr size_t Option_Types_Count = static_cast<size_t>(EOptionType::COUNT); static constexpr size_t OPTION_TYPES_COUNT = static_cast<size_t>(EOptionType::COUNT);
// //
// Time modes // Time modes
@ -171,7 +158,7 @@ enum class ETimeMode : uint8_t
COUNT COUNT
}; };
static constexpr size_t Time_Modes_Count = static_cast<size_t>(ETimeMode::COUNT); static constexpr size_t TIME_MODES_COUNT = static_cast<size_t>(ETimeMode::COUNT);
// //
// Color range types // Color range types
@ -183,7 +170,7 @@ enum class EColorRangeType : uint8_t
COUNT COUNT
}; };
static constexpr size_t Color_Range_Types_Count = static_cast<size_t>(EColorRangeType::COUNT); static constexpr size_t COLOR_RANGE_TYPES_COUNT = static_cast<size_t>(EColorRangeType::COUNT);
// //
// Bounding box types // Bounding box types
@ -196,20 +183,19 @@ enum class EBBoxType : uint8_t
COUNT COUNT
}; };
static constexpr size_t BBox_Types_Count = static_cast<size_t>(EBBoxType::COUNT); static constexpr size_t BBOX_TYPES_COUNT = static_cast<size_t>(EBBoxType::COUNT);
// //
// Predefined colors // Predefined colors
// //
static const Color Dummy_Color{ 64, 64, 64 }; static const Color DUMMY_COLOR{ 64, 64, 64 };
static const Color Wipe_Color { 255, 255, 0 };
// //
// Palette used to render moves by ranges // Palette used to render moves by ranges
// EViewType: Height, Width, Speed, FanSpeed, Temperature, VolumetricFlowRate, // EViewType: Height, Width, Speed, FanSpeed, Temperature, VolumetricFlowRate,
// LayerTimeLinear, LayerTimeLogarithmic // LayerTimeLinear, LayerTimeLogarithmic
// //
static const std::vector<Color> Ranges_Colors{ { static const std::vector<Color> RANGES_COLORS{ {
{ 11, 44, 122 }, // bluish { 11, 44, 122 }, // bluish
{ 19, 89, 133 }, { 19, 89, 133 },
{ 28, 136, 145 }, { 28, 136, 145 },
@ -226,7 +212,7 @@ static const std::vector<Color> Ranges_Colors{ {
// //
// Mapping from EMoveType to EOptionType // Mapping from EMoveType to EOptionType
// //
extern EOptionType type_to_option(EMoveType type); extern EOptionType move_type_to_option(EMoveType type);
// //
// Returns the linear interpolation between the two given colors // Returns the linear interpolation between the two given colors

View File

@ -112,6 +112,16 @@ public:
// //
std::vector<EGCodeExtrusionRole> get_extrusion_roles() const; std::vector<EGCodeExtrusionRole> get_extrusion_roles() const;
//
// Return the count of detected options
//
size_t get_options_count() const;
//
// Return the list of detected options
//
const std::vector<EOptionType>& get_options() const;
// //
// Return the estimated time for the given role and the current time mode // Return the estimated time for the given role and the current time mode
// //
@ -154,10 +164,6 @@ public:
void set_option_color(EOptionType type, const Color& color); void set_option_color(EOptionType type, const Color& color);
void reset_default_options_colors(); void reset_default_options_colors();
const Color& get_travel_move_color(ETravelMoveType type) const;
void set_travel_move_color(ETravelMoveType type, const Color& color);
void reset_default_travel_moves_colors();
const ColorRange& get_height_range() const; const ColorRange& get_height_range() const;
const ColorRange& get_width_range() const; const ColorRange& get_width_range() const;
const ColorRange& get_speed_range() const; const ColorRange& get_speed_range() const;

View File

@ -52,14 +52,14 @@ Color ColorRange::get_color_at(float value) const
global_t = (value - m_range[0]) / step; global_t = (value - m_range[0]) / step;
} }
const size_t color_max_idx = Ranges_Colors.size() - 1; const size_t color_max_idx = RANGES_COLORS.size() - 1;
// Compute the two colors just below (low) and above (high) the input value // 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>(static_cast<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); 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 // Interpolate between the low and high colors to find exactly which color the input value should get
return lerp(Ranges_Colors[color_low_idx], Ranges_Colors[color_high_idx], global_t - static_cast<float>(color_low_idx)); return lerp(RANGES_COLORS[color_low_idx], RANGES_COLORS[color_high_idx], global_t - static_cast<float>(color_low_idx));
} }
const std::array<float, 2>& ColorRange::get_range() const const std::array<float, 2>& ColorRange::get_range() const
@ -74,11 +74,11 @@ float ColorRange::get_step_size() const
default: default:
case EColorRangeType::Linear: case EColorRangeType::Linear:
{ {
return (m_range[1] - m_range[0]) / (static_cast<float>(Ranges_Colors.size()) - 1.0f); return (m_range[1] - m_range[0]) / (static_cast<float>(RANGES_COLORS.size()) - 1.0f);
} }
case EColorRangeType::Logarithmic: 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; return (m_range[0] != 0.0f) ? std::log(m_range[1] / m_range[0]) / (static_cast<float>(RANGES_COLORS.size()) - 1.0f) : 0.0f;
} }
} }
} }
@ -98,7 +98,7 @@ std::vector<float> ColorRange::get_values() const
} }
else { else {
const float step_size = get_step_size(); const float step_size = get_step_size();
for (size_t i = 0; i < Ranges_Colors.size(); ++i) { for (size_t i = 0; i < RANGES_COLORS.size(); ++i) {
float value = 0.0f; float value = 0.0f;
switch (m_type) switch (m_type)
{ {

View File

@ -6,13 +6,13 @@
namespace libvgcode { namespace libvgcode {
void ExtrusionRoles::add(EGCodeExtrusionRole role, const std::array<float, Time_Modes_Count>& times) void ExtrusionRoles::add(EGCodeExtrusionRole role, const std::array<float, TIME_MODES_COUNT>& times)
{ {
auto role_it = m_items.find(role); auto role_it = m_items.find(role);
if (role_it == m_items.end()) if (role_it == m_items.end())
role_it = m_items.insert(std::make_pair(role, Item())).first; role_it = m_items.insert(std::make_pair(role, Item())).first;
for (size_t i = 0; i < Time_Modes_Count; ++i) { for (size_t i = 0; i < TIME_MODES_COUNT; ++i) {
role_it->second.times[i] += times[i]; role_it->second.times[i] += times[i];
} }
} }

View File

@ -16,10 +16,10 @@ class ExtrusionRoles
public: public:
struct Item struct Item
{ {
std::array<float, Time_Modes_Count> times; std::array<float, TIME_MODES_COUNT> times;
}; };
void add(EGCodeExtrusionRole role, const std::array<float, Time_Modes_Count>& times); void add(EGCodeExtrusionRole role, const std::array<float, TIME_MODES_COUNT>& times);
size_t get_roles_count() const { return m_items.size(); } size_t get_roles_count() const { return m_items.size(); }
std::vector<EGCodeExtrusionRole> get_roles() const; std::vector<EGCodeExtrusionRole> get_roles() const;

View File

@ -33,7 +33,7 @@ void Layers::update(const PathVertex& vertex, uint32_t vertex_id)
if (vertex.type == EMoveType::Extrude && vertex.role != EGCodeExtrusionRole::Custom && item.z != vertex.position[2]) if (vertex.type == EMoveType::Extrude && vertex.role != EGCodeExtrusionRole::Custom && item.z != vertex.position[2])
item.z = vertex.position[2]; item.z = vertex.position[2];
item.range.set_max(vertex_id); item.range.set_max(vertex_id);
for (size_t i = 0; i < Time_Modes_Count; ++i) { for (size_t i = 0; i < TIME_MODES_COUNT; ++i) {
item.times[i] += vertex.times[i]; item.times[i] += vertex.times[i];
} }
item.contains_colorprint_options |= is_colorprint_option(vertex); item.contains_colorprint_options |= is_colorprint_option(vertex);

View File

@ -45,7 +45,7 @@ private:
{ {
float z{ 0.0f }; float z{ 0.0f };
Range range; Range range;
std::array<float, Time_Modes_Count> times{ 0.0f, 0.0f }; std::array<float, TIME_MODES_COUNT> times{ 0.0f, 0.0f };
bool contains_colorprint_options{ false }; bool contains_colorprint_options{ false };
}; };

View File

@ -9,10 +9,12 @@
namespace libvgcode { namespace libvgcode {
// mapping from EMoveType to EOptionType // mapping from EMoveType to EOptionType
EOptionType type_to_option(EMoveType type) EOptionType move_type_to_option(EMoveType type)
{ {
switch (type) switch (type)
{ {
case EMoveType::Travel: { return EOptionType::Travels; }
case EMoveType::Wipe: { return EOptionType::Wipes; }
case EMoveType::Retract: { return EOptionType::Retractions; } case EMoveType::Retract: { return EOptionType::Retractions; }
case EMoveType::Unretract: { return EOptionType::Unretractions; } case EMoveType::Unretract: { return EOptionType::Unretractions; }
case EMoveType::Seam: { return EOptionType::Seams; } case EMoveType::Seam: { return EOptionType::Seams; }

View File

@ -8,28 +8,18 @@ namespace libvgcode {
void ViewRange::set_full(Interval::value_type min, Interval::value_type max) void ViewRange::set_full(Interval::value_type min, Interval::value_type max)
{ {
// is the full range being extended ?
const bool new_max = max > m_full.get_max();
m_full.set(min, max); m_full.set(min, max);
// force the enabled range to stay inside the modified full range // force the enabled range to stay inside the modified full range
m_full.clamp(m_enabled); m_full.clamp(m_enabled);
// force the visible range to stay inside the modified enabled range // force the visible range to stay inside the modified enabled range
m_enabled.clamp(m_visible); m_enabled.clamp(m_visible);
if (new_max)
// force the enabled range to fill the extended full range
m_enabled.set_max(max);
} }
void ViewRange::set_enabled(Interval::value_type min, Interval::value_type max) void ViewRange::set_enabled(Interval::value_type min, Interval::value_type max)
{ {
// is the enabled range being extended ?
const bool new_max = max > m_enabled.get_max();
m_enabled.set(min, max); m_enabled.set(min, max);
// force the visible range to stay inside the modified enabled range // force the visible range to stay inside the modified enabled range
m_enabled.clamp(m_visible); m_enabled.clamp(m_visible);
if (new_max)
// force the visible range to fill the extended enabled range
m_visible.set_max(max);
} }
void ViewRange::set_visible(Interval::value_type min, Interval::value_type max) void ViewRange::set_visible(Interval::value_type min, Interval::value_type max)

View File

@ -212,6 +212,16 @@ std::vector<EGCodeExtrusionRole> Viewer::get_extrusion_roles() const
return m_impl->get_extrusion_roles(); return m_impl->get_extrusion_roles();
} }
size_t Viewer::get_options_count() const
{
return m_impl->get_options_count();
}
const std::vector<EOptionType>& Viewer::get_options() const
{
return m_impl->get_options();
}
float Viewer::get_extrusion_role_time(EGCodeExtrusionRole role) const float Viewer::get_extrusion_role_time(EGCodeExtrusionRole role) const
{ {
return m_impl->get_extrusion_role_time(role); return m_impl->get_extrusion_role_time(role);
@ -287,21 +297,6 @@ void Viewer::reset_default_options_colors()
m_impl->reset_default_options_colors(); m_impl->reset_default_options_colors();
} }
const Color& Viewer::get_travel_move_color(ETravelMoveType type) const
{
return m_impl->get_travel_move_color(type);
}
void Viewer::set_travel_move_color(ETravelMoveType type, const Color& color)
{
m_impl->set_travel_move_color(type, color);
}
void Viewer::reset_default_travel_moves_colors()
{
m_impl->reset_default_travel_moves_colors();
}
const ColorRange& Viewer::get_height_range() const const ColorRange& Viewer::get_height_range() const
{ {
return m_impl->get_height_range(); return m_impl->get_height_range();

View File

@ -282,7 +282,7 @@ static void delete_buffers(unsigned int& id)
// Palette used to render extrusion moves by extrusion roles // Palette used to render extrusion moves by extrusion roles
// EViewType: FeatureType // EViewType: FeatureType
// //
const std::map<EGCodeExtrusionRole, Color> ViewerImpl::Default_Extrusion_Roles_Colors{ { const std::map<EGCodeExtrusionRole, Color> ViewerImpl::DEFAULT_EXTRUSION_ROLES_COLORS{ {
{ EGCodeExtrusionRole::None, { 230, 179, 179 } }, { EGCodeExtrusionRole::None, { 230, 179, 179 } },
{ EGCodeExtrusionRole::Perimeter, { 255, 230, 77 } }, { EGCodeExtrusionRole::Perimeter, { 255, 230, 77 } },
{ EGCodeExtrusionRole::ExternalPerimeter, { 255, 125, 56 } }, { EGCodeExtrusionRole::ExternalPerimeter, { 255, 125, 56 } },
@ -304,7 +304,9 @@ const std::map<EGCodeExtrusionRole, Color> ViewerImpl::Default_Extrusion_Roles_C
// Palette used to render options // Palette used to render options
// EViewType: FeatureType // EViewType: FeatureType
// //
const std::map<EOptionType, Color> ViewerImpl::Default_Options_Colors{ { const std::map<EOptionType, Color> ViewerImpl::DEFAULT_OPTIONS_COLORS{ {
{ EOptionType::Travels, { 56, 72, 155 } },
{ EOptionType::Wipes, { 255, 255, 0 } },
{ EOptionType::Retractions, { 205, 34, 214 } }, { EOptionType::Retractions, { 205, 34, 214 } },
{ EOptionType::Unretractions, { 73, 173, 207 } }, { EOptionType::Unretractions, { 73, 173, 207 } },
{ EOptionType::Seams, { 230, 230, 230 } }, { EOptionType::Seams, { 230, 230, 230 } },
@ -314,17 +316,6 @@ const std::map<EOptionType, Color> ViewerImpl::Default_Options_Colors{ {
{ EOptionType::CustomGCodes, { 226, 210, 67 } } { EOptionType::CustomGCodes, { 226, 210, 67 } }
} }; } };
//
// Palette used to render travel moves
// EViewType: FeatureType, Height, Width, FanSpeed, Temperature, VolumetricFlowRate,
// LayerTimeLinear, LayerTimeLogarithmic
//
const std::map<ETravelMoveType, Color> ViewerImpl::Default_Travel_Moves_Colors{ {
{ ETravelMoveType::Move, { 56, 72, 155 } },
{ ETravelMoveType::Extrude, { 29, 108, 26 } },
{ ETravelMoveType::Retract, { 129, 16, 7 } }
} };
ViewerImpl::~ViewerImpl() ViewerImpl::~ViewerImpl()
{ {
reset(); reset();
@ -428,6 +419,7 @@ void ViewerImpl::reset()
m_layers.reset(); m_layers.reset();
m_view_range.reset(); m_view_range.reset();
m_extrusion_roles.reset(); m_extrusion_roles.reset();
m_options.clear();
m_travels_time = { 0.0f, 0.0f }; m_travels_time = { 0.0f, 0.0f };
m_used_extruders_ids.clear(); m_used_extruders_ids.clear();
m_vertices.clear(); m_vertices.clear();
@ -471,13 +463,17 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
const PathVertex& v = m_vertices[i]; const PathVertex& v = m_vertices[i];
m_layers.update(v, static_cast<uint32_t>(i)); m_layers.update(v, static_cast<uint32_t>(i));
if (v.type == EMoveType::Travel) { if (v.type == EMoveType::Travel) {
for (size_t j = 0; j < Time_Modes_Count; ++j) { for (size_t j = 0; j < TIME_MODES_COUNT; ++j) {
m_travels_time[j] += v.times[j]; m_travels_time[j] += v.times[j];
} }
} }
else else
m_extrusion_roles.add(v.role, v.times); m_extrusion_roles.add(v.role, v.times);
const EOptionType option_type = move_type_to_option(v.type);
if (option_type != EOptionType::COUNT)
m_options.emplace_back(option_type);
if (v.type == EMoveType::Extrude) if (v.type == EMoveType::Extrude)
m_used_extruders_ids.emplace_back(v.extruder_id); m_used_extruders_ids.emplace_back(v.extruder_id);
@ -499,6 +495,10 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
if (!m_layers.empty()) if (!m_layers.empty())
m_layers.set_view_range(0, static_cast<uint32_t>(m_layers.count()) - 1); m_layers.set_view_range(0, static_cast<uint32_t>(m_layers.count()) - 1);
std::sort(m_options.begin(), m_options.end());
m_options.erase(std::unique(m_options.begin(), m_options.end()), m_options.end());
m_options.shrink_to_fit();
std::sort(m_used_extruders_ids.begin(), m_used_extruders_ids.end()); 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()); m_used_extruders_ids.erase(std::unique(m_used_extruders_ids.begin(), m_used_extruders_ids.end()), m_used_extruders_ids.end());
m_used_extruders_ids.shrink_to_fit(); m_used_extruders_ids.shrink_to_fit();
@ -628,7 +628,7 @@ void ViewerImpl::update_enabled_entities()
continue; continue;
} }
else if (v.is_option()) { else if (v.is_option()) {
if (!m_settings.options_visibility.at(type_to_option(v.type))) if (!m_settings.options_visibility.at(move_type_to_option(v.type)))
continue; continue;
} }
else if (v.is_extrusion()) { else if (v.is_extrusion()) {
@ -695,7 +695,7 @@ void ViewerImpl::update_colors()
for (size_t i = 0; i < m_vertices.size(); ++i) { for (size_t i = 0; i < m_vertices.size(); ++i) {
colors[i] = (color_top_layer_only && m_vertices[i].layer_id < top_layer_id && colors[i] = (color_top_layer_only && m_vertices[i].layer_id < top_layer_id &&
(!m_settings.spiral_vase_mode || i != m_view_range.get_enabled()[0])) ? (!m_settings.spiral_vase_mode || i != m_view_range.get_enabled()[0])) ?
encode_color(Dummy_Color) : encode_color(get_vertex_color(m_vertices[i])); encode_color(DUMMY_COLOR) : encode_color(get_vertex_color(m_vertices[i]));
} }
// update gpu buffer for colors // update gpu buffer for colors
@ -793,7 +793,16 @@ void ViewerImpl::toggle_option_visibility(EOptionType type)
auto it = m_settings.options_visibility.find(type); auto it = m_settings.options_visibility.find(type);
if (it != m_settings.options_visibility.end()) { if (it != m_settings.options_visibility.end()) {
it->second = !it->second; it->second = !it->second;
const Interval old_enabled_range = m_view_range.get_enabled();
update_view_full_range(); update_view_full_range();
const Interval& new_enabled_range = m_view_range.get_enabled();
if (old_enabled_range != new_enabled_range) {
const Interval& visible_range = m_view_range.get_visible();
if (old_enabled_range == visible_range)
m_view_range.set_visible(new_enabled_range);
else if (m_settings.top_layer_only_view_range && new_enabled_range[0] < visible_range[0])
m_view_range.set_visible(new_enabled_range[0], visible_range[1]);
}
m_settings.update_enabled_entities = true; m_settings.update_enabled_entities = true;
m_settings.update_colors = true; m_settings.update_colors = true;
} }
@ -829,27 +838,24 @@ void ViewerImpl::set_view_visible_range(uint32_t min, uint32_t max)
Color ViewerImpl::get_vertex_color(const PathVertex& v) const Color ViewerImpl::get_vertex_color(const PathVertex& v) const
{ {
if (v.type == EMoveType::Noop) if (v.type == EMoveType::Noop)
return Dummy_Color; return DUMMY_COLOR;
if (v.is_wipe()) if (v.is_wipe() || v.is_option())
return Wipe_Color; return get_option_color(move_type_to_option(v.type));
if (v.is_option())
return get_option_color(type_to_option(v.type));
switch (m_settings.view_type) switch (m_settings.view_type)
{ {
case EViewType::FeatureType: case EViewType::FeatureType:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : get_extrusion_role_color(v.role); return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : get_extrusion_role_color(v.role);
} }
case EViewType::Height: case EViewType::Height:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : m_height_range.get_color_at(v.height); return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_height_range.get_color_at(v.height);
} }
case EViewType::Width: case EViewType::Width:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : m_width_range.get_color_at(v.width); return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_width_range.get_color_at(v.width);
} }
case EViewType::Speed: case EViewType::Speed:
{ {
@ -857,24 +863,24 @@ Color ViewerImpl::get_vertex_color(const PathVertex& v) const
} }
case EViewType::FanSpeed: case EViewType::FanSpeed:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : m_fan_speed_range.get_color_at(v.fan_speed); return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_fan_speed_range.get_color_at(v.fan_speed);
} }
case EViewType::Temperature: case EViewType::Temperature:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : m_temperature_range.get_color_at(v.temperature); return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_temperature_range.get_color_at(v.temperature);
} }
case EViewType::VolumetricFlowRate: case EViewType::VolumetricFlowRate:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : m_volumetric_rate_range.get_color_at(v.volumetric_rate); return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_volumetric_rate_range.get_color_at(v.volumetric_rate);
} }
case EViewType::LayerTimeLinear: case EViewType::LayerTimeLinear:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : return v.is_travel() ? get_option_color(move_type_to_option(v.type)) :
m_layer_time_range[0].get_color_at(m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id))); 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: case EViewType::LayerTimeLogarithmic:
{ {
return v.is_travel() ? get_travel_move_color(static_cast<ETravelMoveType>(v.role)) : return v.is_travel() ? get_option_color(move_type_to_option(v.type)) :
m_layer_time_range[1].get_color_at(m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id))); 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: case EViewType::Tool:
@ -884,13 +890,13 @@ Color ViewerImpl::get_vertex_color(const PathVertex& v) const
} }
case EViewType::ColorPrint: case EViewType::ColorPrint:
{ {
return m_layers.layer_contains_colorprint_options(static_cast<size_t>(v.layer_id)) ? Dummy_Color : 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()]; m_tool_colors[static_cast<size_t>(v.color_id) % m_tool_colors.size()];
} }
default: { break; } default: { break; }
} }
return Dummy_Color; return DUMMY_COLOR;
} }
void ViewerImpl::set_tool_colors(const std::vector<Color>& colors) void ViewerImpl::set_tool_colors(const std::vector<Color>& colors)
@ -902,7 +908,7 @@ void ViewerImpl::set_tool_colors(const std::vector<Color>& colors)
const Color& ViewerImpl::get_extrusion_role_color(EGCodeExtrusionRole role) const const Color& ViewerImpl::get_extrusion_role_color(EGCodeExtrusionRole role) const
{ {
const auto it = m_extrusion_roles_colors.find(role); const auto it = m_extrusion_roles_colors.find(role);
return (it == m_extrusion_roles_colors.end()) ? Dummy_Color : it->second; return (it == m_extrusion_roles_colors.end()) ? DUMMY_COLOR : it->second;
} }
void ViewerImpl::set_extrusion_role_color(EGCodeExtrusionRole role, const Color& color) void ViewerImpl::set_extrusion_role_color(EGCodeExtrusionRole role, const Color& color)
@ -915,7 +921,7 @@ void ViewerImpl::set_extrusion_role_color(EGCodeExtrusionRole role, const Color&
const Color& ViewerImpl::get_option_color(EOptionType type) const const Color& ViewerImpl::get_option_color(EOptionType type) const
{ {
const auto it = m_options_colors.find(type); const auto it = m_options_colors.find(type);
return (it == m_options_colors.end()) ? Dummy_Color : it->second; return (it == m_options_colors.end()) ? DUMMY_COLOR : it->second;
} }
void ViewerImpl::set_option_color(EOptionType type, const Color& color) void ViewerImpl::set_option_color(EOptionType type, const Color& color)
@ -925,19 +931,6 @@ void ViewerImpl::set_option_color(EOptionType type, const Color& color)
it->second = color; it->second = color;
} }
const Color& ViewerImpl::get_travel_move_color(ETravelMoveType type) const
{
const auto it = m_travel_moves_colors.find(type);
return (it == m_travel_moves_colors.end()) ? Dummy_Color : it->second;
}
void ViewerImpl::set_travel_move_color(ETravelMoveType type, const Color& color)
{
auto it = m_travel_moves_colors.find(type);
if (it != m_travel_moves_colors.end())
it->second = color;
}
void ViewerImpl::set_travels_radius(float radius) void ViewerImpl::set_travels_radius(float radius)
{ {
m_travels_radius = std::clamp(radius, 0.05f, 0.5f); m_travels_radius = std::clamp(radius, 0.05f, 0.5f);
@ -952,19 +945,15 @@ void ViewerImpl::set_wipes_radius(float radius)
static bool is_visible(const PathVertex& v, const Settings& settings) static bool is_visible(const PathVertex& v, const Settings& settings)
{ {
try { const EOptionType option_type = move_type_to_option(v.type);
return ((v.type == EMoveType::Travel && !settings.options_visibility.at(EOptionType::Travels)) || try
(v.type == EMoveType::Wipe && !settings.options_visibility.at(EOptionType::Wipes)) || {
(v.type == EMoveType::Retract && !settings.options_visibility.at(EOptionType::Retractions)) || return (option_type == EOptionType::COUNT) ?
(v.type == EMoveType::Unretract && !settings.options_visibility.at(EOptionType::Unretractions)) || (v.type == EMoveType::Extrude) ? settings.extrusion_roles_visibility.at(v.role) : false :
(v.type == EMoveType::Seam && !settings.options_visibility.at(EOptionType::Seams)) || settings.options_visibility.at(option_type);
(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 (...) { catch (...)
{
return false; return false;
} }
} }

View File

@ -106,7 +106,7 @@ public:
size_t get_vertices_count() const { return m_vertices.size(); } size_t get_vertices_count() const { return m_vertices.size(); }
const PathVertex& get_current_vertex() const { return get_vertex_at(m_view_range.get_visible()[1]); } const PathVertex& get_current_vertex() const { return get_vertex_at(m_view_range.get_visible()[1]); }
const PathVertex& get_vertex_at(size_t id) const { const PathVertex& get_vertex_at(size_t id) const {
return (id < m_vertices.size()) ? m_vertices[id] : Dummy_Path_Vertex; return (id < m_vertices.size()) ? m_vertices[id] : DUMMY_PATH_VERTEX;
} }
Color get_vertex_color(const PathVertex& vertex) const; Color get_vertex_color(const PathVertex& vertex) const;
@ -121,6 +121,9 @@ public:
size_t get_extrusion_roles_count() const { return m_extrusion_roles.get_roles_count(); } size_t get_extrusion_roles_count() const { return m_extrusion_roles.get_roles_count(); }
float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const { return m_extrusion_roles.get_time(role, mode); } float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const { return m_extrusion_roles.get_time(role, mode); }
size_t get_options_count() const { return m_options.size(); }
const std::vector<EOptionType>& get_options() const { return m_options; }
float get_travels_time() const { return get_travels_time(m_settings.time_mode); } float get_travels_time() const { return get_travels_time(m_settings.time_mode); }
float get_travels_time(ETimeMode mode) const { float get_travels_time(ETimeMode mode) const {
return (mode < ETimeMode::COUNT) ? m_travels_time[static_cast<size_t>(mode)] : 0.0f; return (mode < ETimeMode::COUNT) ? m_travels_time[static_cast<size_t>(mode)] : 0.0f;
@ -134,15 +137,11 @@ public:
const Color& get_extrusion_role_color(EGCodeExtrusionRole role) const; const Color& get_extrusion_role_color(EGCodeExtrusionRole role) const;
void set_extrusion_role_color(EGCodeExtrusionRole role, const Color& color); void set_extrusion_role_color(EGCodeExtrusionRole role, const Color& color);
void reset_default_extrusion_roles_colors() { m_extrusion_roles_colors = Default_Extrusion_Roles_Colors; } void reset_default_extrusion_roles_colors() { m_extrusion_roles_colors = DEFAULT_EXTRUSION_ROLES_COLORS; }
const Color& get_option_color(EOptionType type) const; const Color& get_option_color(EOptionType type) const;
void set_option_color(EOptionType type, const Color& color); void set_option_color(EOptionType type, const Color& color);
void reset_default_options_colors() { m_options_colors = Default_Options_Colors; } void reset_default_options_colors() { m_options_colors = DEFAULT_OPTIONS_COLORS; }
const Color& get_travel_move_color(ETravelMoveType type) const;
void set_travel_move_color(ETravelMoveType type, const Color& color);
void reset_default_travel_moves_colors() { m_travel_moves_colors = Default_Travel_Moves_Colors; }
const ColorRange& get_height_range() const { return m_height_range; } const ColorRange& get_height_range() const { return m_height_range; }
const ColorRange& get_width_range() const { return m_width_range; } const ColorRange& get_width_range() const { return m_width_range; }
@ -190,17 +189,17 @@ private:
Layers m_layers; Layers m_layers;
ViewRange m_view_range; ViewRange m_view_range;
ExtrusionRoles m_extrusion_roles; ExtrusionRoles m_extrusion_roles;
std::array<float, Time_Modes_Count> m_travels_time{ 0.0f, 0.0f }; std::vector<EOptionType> m_options;
std::array<float, TIME_MODES_COUNT> m_travels_time{ 0.0f, 0.0f };
std::vector<uint8_t> m_used_extruders_ids; std::vector<uint8_t> m_used_extruders_ids;
float m_travels_radius{ Default_Travels_Radius }; float m_travels_radius{ DEFAULT_TRAVELS_RADIUS };
float m_wipes_radius{ Default_Wipes_Radius }; float m_wipes_radius{ DEFAULT_WIPES_RADIUS };
bool m_initialized{ false }; bool m_initialized{ false };
bool m_loading{ false }; bool m_loading{ false };
std::map<EGCodeExtrusionRole, Color> m_extrusion_roles_colors{ Default_Extrusion_Roles_Colors }; std::map<EGCodeExtrusionRole, Color> m_extrusion_roles_colors{ DEFAULT_EXTRUSION_ROLES_COLORS };
std::map<EOptionType, Color> m_options_colors{ Default_Options_Colors }; std::map<EOptionType, Color> m_options_colors{ DEFAULT_OPTIONS_COLORS };
std::map<ETravelMoveType, Color> m_travel_moves_colors{ Default_Travel_Moves_Colors };
// //
// The OpenGL element used to represent all toolpath segments // The OpenGL element used to represent all toolpath segments
@ -249,7 +248,7 @@ private:
ColorRange m_fan_speed_range; ColorRange m_fan_speed_range;
ColorRange m_temperature_range; ColorRange m_temperature_range;
ColorRange m_volumetric_rate_range; ColorRange m_volumetric_rate_range;
std::array<ColorRange, Color_Range_Types_Count> m_layer_time_range{ std::array<ColorRange, COLOR_RANGE_TYPES_COUNT> m_layer_time_range{
ColorRange(EColorRangeType::Linear), ColorRange(EColorRangeType::Logarithmic) ColorRange(EColorRangeType::Linear), ColorRange(EColorRangeType::Logarithmic)
}; };
std::vector<Color> m_tool_colors; std::vector<Color> m_tool_colors;
@ -344,18 +343,12 @@ private:
// Palette used to render extrusion moves by extrusion roles // Palette used to render extrusion moves by extrusion roles
// EViewType: FeatureType // EViewType: FeatureType
// //
static const std::map<EGCodeExtrusionRole, Color> Default_Extrusion_Roles_Colors; static const std::map<EGCodeExtrusionRole, Color> DEFAULT_EXTRUSION_ROLES_COLORS;
// //
// Palette used to render options // Palette used to render options
// EViewType: FeatureType // EViewType: FeatureType
// //
static const std::map<EOptionType, Color> Default_Options_Colors; static const std::map<EOptionType, Color> DEFAULT_OPTIONS_COLORS;
//
// Palette used to render travel moves
// EViewType: FeatureType, Height, Width, FanSpeed, Temperature, VolumetricFlowRate,
// LayerTimeLinear, LayerTimeLogarithmic
//
static const std::map<ETravelMoveType, Color> Default_Travel_Moves_Colors;
}; };
} // namespace libvgcode } // namespace libvgcode

View File

@ -1956,7 +1956,7 @@ private:
const bool color_top_layer_only = m_viewer.get_view_full_range()[1] != m_viewer.get_view_visible_range()[1]; const bool color_top_layer_only = m_viewer.get_view_full_range()[1] != m_viewer.get_view_visible_range()[1];
const libvgcode::Color color = (color_top_layer_only && v.layer_id < top_layer_id && const libvgcode::Color color = (color_top_layer_only && v.layer_id < top_layer_id &&
(!m_viewer.is_spiral_vase_mode() || vertex_id != m_viewer.get_view_enabled_range()[0])) ? (!m_viewer.is_spiral_vase_mode() || vertex_id != m_viewer.get_view_enabled_range()[0])) ?
libvgcode::Dummy_Color : m_viewer.get_vertex_color(v); libvgcode::DUMMY_COLOR : m_viewer.get_vertex_color(v);
auto color_it = std::find_if(m_colors.begin(), m_colors.end(), [&color](const libvgcode::Color& m) { return m == color; }); auto color_it = std::find_if(m_colors.begin(), m_colors.end(), [&color](const libvgcode::Color& m) { return m == color; });
if (color_it == m_colors.end()) { if (color_it == m_colors.end()) {
m_colors.emplace_back(color); m_colors.emplace_back(color);
@ -4547,7 +4547,7 @@ void GCodeViewer::render_legend(float& legend_height)
char buf[1024]; char buf[1024];
::sprintf(buf, "%.*f", decimals, value); ::sprintf(buf, "%.*f", decimals, value);
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, libvgcode::convert(libvgcode::Ranges_Colors[i]), buf); append_item(EItemType::Rect, libvgcode::convert(libvgcode::RANGES_COLORS[i]), buf);
#else #else
append_item(EItemType::Rect, Range_Colors[i], buf); append_item(EItemType::Rect, Range_Colors[i], buf);
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -4560,11 +4560,11 @@ void GCodeViewer::render_legend(float& legend_height)
append_range_item(0, values.front(), decimals); append_range_item(0, values.front(), decimals);
else if (values.size() == 2) { else if (values.size() == 2) {
// two items use case // two items use case
append_range_item(static_cast<int>(libvgcode::Ranges_Colors.size()) - 1, values.back(), decimals); append_range_item(static_cast<int>(libvgcode::RANGES_COLORS.size()) - 1, values.back(), decimals);
append_range_item(0, values.front(), decimals); append_range_item(0, values.front(), decimals);
} }
else { else {
for (int i = static_cast<int>(libvgcode::Ranges_Colors.size()) - 1; i >= 0; --i) { for (int i = static_cast<int>(libvgcode::RANGES_COLORS.size()) - 1; i >= 0; --i) {
append_range_item(i, values[i], decimals); append_range_item(i, values[i], decimals);
} }
} }
@ -4596,7 +4596,7 @@ void GCodeViewer::render_legend(float& legend_height)
if (str_value == "0s") if (str_value == "0s")
str_value = "< 1s"; str_value = "< 1s";
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, libvgcode::convert(libvgcode::Ranges_Colors[i]), str_value); append_item(EItemType::Rect, libvgcode::convert(libvgcode::RANGES_COLORS[i]), str_value);
#else #else
append_item(EItemType::Rect, Range_Colors[i], str_value); append_item(EItemType::Rect, Range_Colors[i], str_value);
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -4609,11 +4609,11 @@ void GCodeViewer::render_legend(float& legend_height)
append_range_item(0, values.front()); append_range_item(0, values.front());
else if (values.size() == 2) { else if (values.size() == 2) {
// two items use case // two items use case
append_range_item(static_cast<int>(libvgcode::Ranges_Colors.size()) - 1, values.back()); append_range_item(static_cast<int>(libvgcode::RANGES_COLORS.size()) - 1, values.back());
append_range_item(0, values.front()); append_range_item(0, values.front());
} }
else { else {
for (int i = static_cast<int>(libvgcode::Ranges_Colors.size()) - 1; i >= 0; --i) { for (int i = static_cast<int>(libvgcode::RANGES_COLORS.size()) - 1; i >= 0; --i) {
append_range_item(i, values[i]); append_range_item(i, values[i]);
} }
} }
@ -4777,8 +4777,8 @@ void GCodeViewer::render_legend(float& legend_height)
// calculate offsets to align time/percentage data // calculate offsets to align time/percentage data
const std::vector<libvgcode::EGCodeExtrusionRole>& roles = m_viewer.get_extrusion_roles(); const std::vector<libvgcode::EGCodeExtrusionRole>& roles = m_viewer.get_extrusion_roles();
for (libvgcode::EGCodeExtrusionRole role : roles) { for (libvgcode::EGCodeExtrusionRole role : roles) {
assert(static_cast<size_t>(role) < libvgcode::GCode_Extrusion_Roles_Count); assert(static_cast<size_t>(role) < libvgcode::GCODE_EXTRUSION_ROLES_COUNT);
if (static_cast<size_t>(role) < libvgcode::GCode_Extrusion_Roles_Count) { if (static_cast<size_t>(role) < libvgcode::GCODE_EXTRUSION_ROLES_COUNT) {
labels.push_back(_u8L(gcode_extrusion_role_to_string(convert(role)))); labels.push_back(_u8L(gcode_extrusion_role_to_string(convert(role))));
auto [time, percent] = role_time_and_percent(role); auto [time, percent] = role_time_and_percent(role);
#else #else
@ -4972,7 +4972,7 @@ void GCodeViewer::render_legend(float& legend_height)
const std::vector<libvgcode::EGCodeExtrusionRole>& roles = m_viewer.get_extrusion_roles(); const std::vector<libvgcode::EGCodeExtrusionRole>& roles = m_viewer.get_extrusion_roles();
for (size_t i = 0; i < roles.size(); ++i) { for (size_t i = 0; i < roles.size(); ++i) {
libvgcode::EGCodeExtrusionRole role = roles[i]; libvgcode::EGCodeExtrusionRole role = roles[i];
if (static_cast<size_t>(role) >= libvgcode::GCode_Extrusion_Roles_Count) if (static_cast<size_t>(role) >= libvgcode::GCODE_EXTRUSION_ROLES_COUNT)
continue; continue;
const bool visible = m_viewer.is_extrusion_role_visible(role); const bool visible = m_viewer.is_extrusion_role_visible(role);
@ -5005,7 +5005,7 @@ void GCodeViewer::render_legend(float& legend_height)
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
if (m_viewer.is_option_visible(libvgcode::EOptionType::Travels)) if (m_viewer.is_option_visible(libvgcode::EOptionType::Travels))
append_item(EItemType::Line, libvgcode::convert(m_viewer.get_travel_move_color(libvgcode::ETravelMoveType::Move)), _u8L("Travel"), true, short_time_ui(get_time_dhms(travels_time)), append_item(EItemType::Line, libvgcode::convert(m_viewer.get_option_color(libvgcode::EOptionType::Travels)), _u8L("Travel"), true, short_time_ui(get_time_dhms(travels_time)),
travels_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f); travels_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f);
#else #else
if (m_buffers[buffer_id(EMoveType::Travel)].visible) if (m_buffers[buffer_id(EMoveType::Travel)].visible)

View File

@ -157,17 +157,6 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels
const Slic3r::GCodeProcessorResult::MoveVertex& prev = moves[i - 1]; const Slic3r::GCodeProcessorResult::MoveVertex& prev = moves[i - 1];
const EMoveType curr_type = convert(curr.type); const EMoveType curr_type = convert(curr.type);
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
extrusion_role = (curr.delta_extruder == 0.0f) ? static_cast<EGCodeExtrusionRole>(ETravelMoveType::Move) :
(curr.delta_extruder > 0.0f) ? static_cast<EGCodeExtrusionRole>(ETravelMoveType::Extrude) :
static_cast<EGCodeExtrusionRole>(ETravelMoveType::Retract);
}
else
extrusion_role = convert(curr.extrusion_role);
float width; float width;
float height; float height;
switch (curr_type) switch (curr_type)
@ -192,19 +181,20 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels
} }
} }
if (type_to_option(curr_type) == libvgcode::EOptionType::COUNT) { const EOptionType option_type = move_type_to_option(curr_type);
if (option_type == EOptionType::COUNT || option_type == EOptionType::Travels || option_type == EOptionType::Wipes) {
if (ret.vertices.empty() || prev.type != curr.type || prev.extrusion_role != curr.extrusion_role) { 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 // 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, // 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 // and the times, which are set to zero
#if ENABLE_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed, 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, curr.temperature, curr.volumetric_rate(), 0.0f, convert(curr.extrusion_role), curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id), 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 } }; static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#else #else
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed, const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type, curr.temperature, curr.volumetric_rate(), convert(curr.extrusion_role), curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id), 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 } }; static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#endif // ENABLE_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
@ -215,11 +205,11 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels
#if ENABLE_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed, 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(), 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), convert(curr.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 }; static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time };
#else #else
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed, 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), curr.temperature, curr.volumetric_rate(), convert(curr.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 }; 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_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex); ret.vertices.emplace_back(vertex);

View File

@ -55,8 +55,8 @@ extern ETimeMode convert(const Slic3r::PrintEstimatedStatistics::ETimeMode& mode
extern Slic3r::PrintEstimatedStatistics::ETimeMode convert(const ETimeMode& mode); extern Slic3r::PrintEstimatedStatistics::ETimeMode convert(const ETimeMode& mode);
// mapping from Slic3r::GCodeProcessorResult to libvgcode::GCodeInputData // mapping from Slic3r::GCodeProcessorResult to libvgcode::GCodeInputData
extern GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels_radius = Default_Travels_Radius, extern GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels_radius = DEFAULT_TRAVELS_RADIUS,
float wipes_radius = Default_Wipes_Radius); float wipes_radius = DEFAULT_WIPES_RADIUS);
// mapping from Slic3r::Print to libvgcode::GCodeInputData // mapping from Slic3r::Print to libvgcode::GCodeInputData
extern GCodeInputData convert(const Slic3r::Print& print, const std::vector<std::string>& str_tool_colors, extern GCodeInputData convert(const Slic3r::Print& print, const std::vector<std::string>& str_tool_colors,