Some refactoring

This commit is contained in:
enricoturri1966 2023-11-22 15:46:09 +01:00 committed by Lukas Matena
parent 7be092d200
commit 1ee29acc4f
25 changed files with 500 additions and 496 deletions

View File

@ -49,119 +49,136 @@
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
namespace Slic3r {
namespace GUI {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
// mapping from Slic3r::Vec3f to libvgcode::Vec3f namespace libvgcode {
static libvgcode::Vec3f convert(const Vec3f& v)
// mapping from Slic3r::Vec3f to libvgcode::Vec3
static Vec3 convert(const Slic3r::Vec3f& v)
{ {
return { v.x(), v.y(), v.z() }; return { v.x(), v.y(), v.z() };
} }
// 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 // mapping from libvgcode::Color to Slic3r::ColorRGBA
static ColorRGBA convert(const libvgcode::Color& c) static Slic3r::ColorRGBA convert(const Color& c)
{ {
return { c[0], c[1], c[2], 1.0f }; return { c[0], c[1], c[2], 1.0f };
} }
// mapping from Slic3r::ColorRGBA to libvgcode::Color // mapping from Slic3r::ColorRGBA to libvgcode::Color
static libvgcode::Color convert(const ColorRGBA& c) static Color convert(const Slic3r::ColorRGBA& c)
{ {
return { c.r(), c.g(), c.b() }; return { c.r(), c.g(), c.b() };
} }
// mapping from libvgcode::EGCodeExtrusionRole to Slic3r::GCodeExtrusionRole // mapping from libvgcode::EGCodeExtrusionRole to Slic3r::GCodeExtrusionRole
static GCodeExtrusionRole convert(libvgcode::EGCodeExtrusionRole role) static Slic3r::GCodeExtrusionRole convert(EGCodeExtrusionRole role)
{ {
switch (role) switch (role)
{ {
case libvgcode::EGCodeExtrusionRole::None: { return GCodeExtrusionRole::None; } case EGCodeExtrusionRole::None: { return Slic3r::GCodeExtrusionRole::None; }
case libvgcode::EGCodeExtrusionRole::Perimeter: { return GCodeExtrusionRole::Perimeter; } case EGCodeExtrusionRole::Perimeter: { return Slic3r::GCodeExtrusionRole::Perimeter; }
case libvgcode::EGCodeExtrusionRole::ExternalPerimeter: { return GCodeExtrusionRole::ExternalPerimeter; } case EGCodeExtrusionRole::ExternalPerimeter: { return Slic3r::GCodeExtrusionRole::ExternalPerimeter; }
case libvgcode::EGCodeExtrusionRole::OverhangPerimeter: { return GCodeExtrusionRole::OverhangPerimeter; } case EGCodeExtrusionRole::OverhangPerimeter: { return Slic3r::GCodeExtrusionRole::OverhangPerimeter; }
case libvgcode::EGCodeExtrusionRole::InternalInfill: { return GCodeExtrusionRole::InternalInfill; } case EGCodeExtrusionRole::InternalInfill: { return Slic3r::GCodeExtrusionRole::InternalInfill; }
case libvgcode::EGCodeExtrusionRole::SolidInfill: { return GCodeExtrusionRole::SolidInfill; } case EGCodeExtrusionRole::SolidInfill: { return Slic3r::GCodeExtrusionRole::SolidInfill; }
case libvgcode::EGCodeExtrusionRole::TopSolidInfill: { return GCodeExtrusionRole::TopSolidInfill; } case EGCodeExtrusionRole::TopSolidInfill: { return Slic3r::GCodeExtrusionRole::TopSolidInfill; }
case libvgcode::EGCodeExtrusionRole::Ironing: { return GCodeExtrusionRole::Ironing; } case EGCodeExtrusionRole::Ironing: { return Slic3r::GCodeExtrusionRole::Ironing; }
case libvgcode::EGCodeExtrusionRole::BridgeInfill: { return GCodeExtrusionRole::BridgeInfill; } case EGCodeExtrusionRole::BridgeInfill: { return Slic3r::GCodeExtrusionRole::BridgeInfill; }
case libvgcode::EGCodeExtrusionRole::GapFill: { return GCodeExtrusionRole::GapFill; } case EGCodeExtrusionRole::GapFill: { return Slic3r::GCodeExtrusionRole::GapFill; }
case libvgcode::EGCodeExtrusionRole::Skirt: { return GCodeExtrusionRole::Skirt; } case EGCodeExtrusionRole::Skirt: { return Slic3r::GCodeExtrusionRole::Skirt; }
case libvgcode::EGCodeExtrusionRole::SupportMaterial: { return GCodeExtrusionRole::SupportMaterial; } case EGCodeExtrusionRole::SupportMaterial: { return Slic3r::GCodeExtrusionRole::SupportMaterial; }
case libvgcode::EGCodeExtrusionRole::SupportMaterialInterface: { return GCodeExtrusionRole::SupportMaterialInterface; } case EGCodeExtrusionRole::SupportMaterialInterface: { return Slic3r::GCodeExtrusionRole::SupportMaterialInterface; }
case libvgcode::EGCodeExtrusionRole::WipeTower: { return GCodeExtrusionRole::WipeTower; } case EGCodeExtrusionRole::WipeTower: { return Slic3r::GCodeExtrusionRole::WipeTower; }
case libvgcode::EGCodeExtrusionRole::Custom: { return GCodeExtrusionRole::Custom; } case EGCodeExtrusionRole::Custom: { return Slic3r::GCodeExtrusionRole::Custom; }
case libvgcode::EGCodeExtrusionRole::COUNT: { return GCodeExtrusionRole::Count; }
} }
assert(false); assert(false);
return GCodeExtrusionRole::None; return Slic3r::GCodeExtrusionRole::None;
} }
// mapping from Slic3r::GCodeExtrusionRole to libvgcode::EGCodeExtrusionRole // mapping from Slic3r::GCodeExtrusionRole to libvgcode::EGCodeExtrusionRole
static libvgcode::EGCodeExtrusionRole convert(GCodeExtrusionRole role) static EGCodeExtrusionRole convert(Slic3r::GCodeExtrusionRole role)
{ {
switch (role) switch (role)
{ {
case GCodeExtrusionRole::None: { return libvgcode::EGCodeExtrusionRole::None; } case Slic3r::GCodeExtrusionRole::None: { return EGCodeExtrusionRole::None; }
case GCodeExtrusionRole::Perimeter: { return libvgcode::EGCodeExtrusionRole::Perimeter; } case Slic3r::GCodeExtrusionRole::Perimeter: { return EGCodeExtrusionRole::Perimeter; }
case GCodeExtrusionRole::ExternalPerimeter: { return libvgcode::EGCodeExtrusionRole::ExternalPerimeter; } case Slic3r::GCodeExtrusionRole::ExternalPerimeter: { return EGCodeExtrusionRole::ExternalPerimeter; }
case GCodeExtrusionRole::OverhangPerimeter: { return libvgcode::EGCodeExtrusionRole::OverhangPerimeter; } case Slic3r::GCodeExtrusionRole::OverhangPerimeter: { return EGCodeExtrusionRole::OverhangPerimeter; }
case GCodeExtrusionRole::InternalInfill: { return libvgcode::EGCodeExtrusionRole::InternalInfill; } case Slic3r::GCodeExtrusionRole::InternalInfill: { return EGCodeExtrusionRole::InternalInfill; }
case GCodeExtrusionRole::SolidInfill: { return libvgcode::EGCodeExtrusionRole::SolidInfill; } case Slic3r::GCodeExtrusionRole::SolidInfill: { return EGCodeExtrusionRole::SolidInfill; }
case GCodeExtrusionRole::TopSolidInfill: { return libvgcode::EGCodeExtrusionRole::TopSolidInfill; } case Slic3r::GCodeExtrusionRole::TopSolidInfill: { return EGCodeExtrusionRole::TopSolidInfill; }
case GCodeExtrusionRole::Ironing: { return libvgcode::EGCodeExtrusionRole::Ironing; } case Slic3r::GCodeExtrusionRole::Ironing: { return EGCodeExtrusionRole::Ironing; }
case GCodeExtrusionRole::BridgeInfill: { return libvgcode::EGCodeExtrusionRole::BridgeInfill; } case Slic3r::GCodeExtrusionRole::BridgeInfill: { return EGCodeExtrusionRole::BridgeInfill; }
case GCodeExtrusionRole::GapFill: { return libvgcode::EGCodeExtrusionRole::GapFill; } case Slic3r::GCodeExtrusionRole::GapFill: { return EGCodeExtrusionRole::GapFill; }
case GCodeExtrusionRole::Skirt: { return libvgcode::EGCodeExtrusionRole::Skirt; } case Slic3r::GCodeExtrusionRole::Skirt: { return EGCodeExtrusionRole::Skirt; }
case GCodeExtrusionRole::SupportMaterial: { return libvgcode::EGCodeExtrusionRole::SupportMaterial; } case Slic3r::GCodeExtrusionRole::SupportMaterial: { return EGCodeExtrusionRole::SupportMaterial; }
case GCodeExtrusionRole::SupportMaterialInterface: { return libvgcode::EGCodeExtrusionRole::SupportMaterialInterface; } case Slic3r::GCodeExtrusionRole::SupportMaterialInterface: { return EGCodeExtrusionRole::SupportMaterialInterface; }
case GCodeExtrusionRole::WipeTower: { return libvgcode::EGCodeExtrusionRole::WipeTower; } case Slic3r::GCodeExtrusionRole::WipeTower: { return EGCodeExtrusionRole::WipeTower; }
case GCodeExtrusionRole::Custom: { return libvgcode::EGCodeExtrusionRole::Custom; } case Slic3r::GCodeExtrusionRole::Custom: { return EGCodeExtrusionRole::Custom; }
case GCodeExtrusionRole::Count: { return libvgcode::EGCodeExtrusionRole::COUNT; }
} }
assert(false); assert(false);
return libvgcode::EGCodeExtrusionRole::None; return EGCodeExtrusionRole::None;
} }
// mapping from Slic3r::EMoveType to libvgcode::EMoveType // mapping from Slic3r::EMoveType to libvgcode::EMoveType
static libvgcode::EMoveType convert(EMoveType type) static EMoveType convert(Slic3r::EMoveType type)
{ {
switch (type) switch (type)
{ {
case EMoveType::Noop: { return libvgcode::EMoveType::Noop; } case Slic3r::EMoveType::Noop: { return EMoveType::Noop; }
case EMoveType::Retract: { return libvgcode::EMoveType::Retract; } case Slic3r::EMoveType::Retract: { return EMoveType::Retract; }
case EMoveType::Unretract: { return libvgcode::EMoveType::Unretract; } case Slic3r::EMoveType::Unretract: { return EMoveType::Unretract; }
case EMoveType::Seam: { return libvgcode::EMoveType::Seam; } case Slic3r::EMoveType::Seam: { return EMoveType::Seam; }
case EMoveType::Tool_change: { return libvgcode::EMoveType::ToolChange; } case Slic3r::EMoveType::Tool_change: { return EMoveType::ToolChange; }
case EMoveType::Color_change: { return libvgcode::EMoveType::ColorChange; } case Slic3r::EMoveType::Color_change: { return EMoveType::ColorChange; }
case EMoveType::Pause_Print: { return libvgcode::EMoveType::PausePrint; } case Slic3r::EMoveType::Pause_Print: { return EMoveType::PausePrint; }
case EMoveType::Custom_GCode: { return libvgcode::EMoveType::CustomGCode; } case Slic3r::EMoveType::Custom_GCode: { return EMoveType::CustomGCode; }
case EMoveType::Travel: { return libvgcode::EMoveType::Travel; } case Slic3r::EMoveType::Travel: { return EMoveType::Travel; }
case EMoveType::Wipe: { return libvgcode::EMoveType::Wipe; } case Slic3r::EMoveType::Wipe: { return EMoveType::Wipe; }
case EMoveType::Extrude: { return libvgcode::EMoveType::Extrude; } case Slic3r::EMoveType::Extrude: { return EMoveType::Extrude; }
case EMoveType::Count: { return libvgcode::EMoveType::COUNT; }
default: { return libvgcode::EMoveType::COUNT; }
} }
assert(false);
return EMoveType::COUNT;
} }
// mapping from Slic3r::PrintEstimatedStatistics::ETimeMode to libvgcode::ETimeMode // mapping from Slic3r::PrintEstimatedStatistics::ETimeMode to libvgcode::ETimeMode
static libvgcode::ETimeMode convert(const PrintEstimatedStatistics::ETimeMode& mode) static ETimeMode convert(const Slic3r::PrintEstimatedStatistics::ETimeMode& mode)
{ {
switch (mode) switch (mode)
{ {
case PrintEstimatedStatistics::ETimeMode::Normal: { return libvgcode::ETimeMode::Normal; } case Slic3r::PrintEstimatedStatistics::ETimeMode::Normal: { return ETimeMode::Normal; }
case PrintEstimatedStatistics::ETimeMode::Stealth: { return libvgcode::ETimeMode::Stealth; } case Slic3r::PrintEstimatedStatistics::ETimeMode::Stealth: { return ETimeMode::Stealth; }
case PrintEstimatedStatistics::ETimeMode::Count: { return libvgcode::ETimeMode::COUNT; }
default: { return libvgcode::ETimeMode::COUNT; }
} }
assert(false);
return ETimeMode::COUNT;
} }
// mapping from Slic3r::GCodeProcessorResult to libvgcode::GCodeInputData // mapping from libvgcode::ETimeMode to Slic3r::PrintEstimatedStatistics::ETimeMode
static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result) static Slic3r::PrintEstimatedStatistics::ETimeMode convert(const ETimeMode& mode)
{ {
const std::vector<GCodeProcessorResult::MoveVertex>& moves = result.moves; switch (mode)
libvgcode::GCodeInputData ret; {
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()); ret.vertices.reserve(2 * moves.size());
// Seam moves have no correspondence in the gcode, // Seam moves have no correspondence in the gcode,
// there are no gcode lines associated to them, // there are no gcode lines associated to them,
@ -170,24 +187,24 @@ static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
// of them and modify the vertices' move_id accordingly. // of them and modify the vertices' move_id accordingly.
uint32_t seams_count = 0; uint32_t seams_count = 0;
for (size_t i = 1; i < moves.size(); ++i) { for (size_t i = 1; i < moves.size(); ++i) {
const GCodeProcessorResult::MoveVertex& curr = moves[i]; const Slic3r::GCodeProcessorResult::MoveVertex& curr = moves[i];
const GCodeProcessorResult::MoveVertex& prev = moves[i - 1]; const Slic3r::GCodeProcessorResult::MoveVertex& prev = moves[i - 1];
const libvgcode::EMoveType curr_type = convert(curr.type); const EMoveType curr_type = convert(curr.type);
const libvgcode::EGCodeExtrusionRole curr_role = convert(curr.extrusion_role); const EGCodeExtrusionRole curr_role = convert(curr.extrusion_role);
if (curr_type == libvgcode::EMoveType::Seam) if (curr_type == EMoveType::Seam)
++seams_count; ++seams_count;
libvgcode::EGCodeExtrusionRole extrusion_role; EGCodeExtrusionRole extrusion_role;
if (curr_type == libvgcode::EMoveType::Travel) { if (curr_type == EMoveType::Travel) {
// for travel moves set the extrusion role // for travel moves set the extrusion role
// which will be used later to select the proper color // which will be used later to select the proper color
if (curr.delta_extruder == 0.0f) if (curr.delta_extruder == 0.0f)
extrusion_role = static_cast<libvgcode::EGCodeExtrusionRole>(0); // Move extrusion_role = static_cast<EGCodeExtrusionRole>(0); // Move
else if (curr.delta_extruder > 0.0f) else if (curr.delta_extruder > 0.0f)
extrusion_role = static_cast<libvgcode::EGCodeExtrusionRole>(1); // Extrude extrusion_role = static_cast<EGCodeExtrusionRole>(1); // Extrude
else else
extrusion_role = static_cast<libvgcode::EGCodeExtrusionRole>(2); // Retract extrusion_role = static_cast<EGCodeExtrusionRole>(2); // Retract
} }
else else
extrusion_role = convert(curr.extrusion_role); extrusion_role = convert(curr.extrusion_role);
@ -196,17 +213,32 @@ static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
float height; float height;
switch (curr_type) switch (curr_type)
{ {
case libvgcode::EMoveType::Travel: { width = libvgcode::TRAVEL_RADIUS; height = libvgcode::TRAVEL_RADIUS; break; } case EMoveType::Travel:
case libvgcode::EMoveType::Wipe: { width = libvgcode::WIPE_RADIUS; height = libvgcode::WIPE_RADIUS; break; } {
default: { width = curr.width; height = curr.height; break; } 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 (type_to_option(curr_type) == libvgcode::EOptionType::COUNT) {
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_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_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(), extrusion_role, curr_type, curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type,
static_cast<uint32_t>(i) - seams_count, static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(i) - seams_count, static_cast<uint32_t>(curr.layer_id),
@ -217,12 +249,12 @@ static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
extrusion_role, curr_type, extrusion_role, curr_type,
static_cast<uint32_t>(i) - seams_count, static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(i) - seams_count, 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_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex); ret.vertices.emplace_back(vertex);
} }
} }
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #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, 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>(i) - seams_count, static_cast<uint32_t>(curr.layer_id), curr.volumetric_rate(), extrusion_role, curr_type, static_cast<uint32_t>(i) - seams_count, 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 };
@ -231,27 +263,25 @@ static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
curr.volumetric_rate(), curr.mm3_per_mm * (curr.position - prev.position).norm(), extrusion_role, curr_type, curr.volumetric_rate(), curr.mm3_per_mm * (curr.position - prev.position).norm(), extrusion_role, curr_type,
static_cast<uint32_t>(i) - seams_count, static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(i) - seams_count, 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 };
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex); ret.vertices.emplace_back(vertex);
} }
ret.vertices.shrink_to_fit(); ret.vertices.shrink_to_fit();
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) { for (size_t i = 0; i < static_cast<size_t>(Slic3r::PrintEstimatedStatistics::ETimeMode::Count); ++i) {
ret.times[static_cast<size_t>(convert(static_cast<PrintEstimatedStatistics::ETimeMode>(i)))] = result.print_statistics.modes[i].time; ret.times[static_cast<size_t>(convert(static_cast<Slic3r::PrintEstimatedStatistics::ETimeMode>(i)))] = result.print_statistics.modes[i].time;
} }
return ret; return ret;
} }
static libvgcode::Color lerp(const libvgcode::Color& c1, const libvgcode::Color& c2, float t) } // namespace libvgcode
{
t = std::clamp(t, 0.0f, 1.0f);
const float one_minus_t = 1.0f - t;
return { one_minus_t * c1[0] + t * c2[0], one_minus_t * c1[1] + t * c2[1], one_minus_t * c1[2] + t * c2[2] };
}
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
namespace Slic3r {
namespace GUI {
static unsigned char buffer_id(EMoveType type) { static unsigned char buffer_id(EMoveType type) {
return static_cast<unsigned char>(type) - static_cast<unsigned char>(EMoveType::Retract); return static_cast<unsigned char>(type) - static_cast<unsigned char>(EMoveType::Retract);
} }
@ -393,11 +423,11 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
void GCodeViewer::COG::render() void GCodeViewer::COG::render()
#else #else
void GCodeViewer::COG::render(bool fixed_screen_size) void GCodeViewer::COG::render(bool fixed_screen_size)
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GCodeViewer::COG::render() void GCodeViewer::COG::render()
@ -410,12 +440,12 @@ void GCodeViewer::COG::render()
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
init(); init();
#else #else
fixed_screen_size = true; fixed_screen_size = true;
init(fixed_screen_size); init(fixed_screen_size);
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
init(); init();
@ -435,11 +465,11 @@ void GCodeViewer::COG::render()
Transform3d model_matrix = Geometry::translation_transform(cog()) * Geometry::scale_transform(m_scale_factor); Transform3d model_matrix = Geometry::translation_transform(cog()) * Geometry::scale_transform(m_scale_factor);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (m_fixed_screen_size) { if (m_fixed_screen_size) {
#else #else
if (fixed_screen_size) { if (fixed_screen_size) {
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (m_fixed_screen_size) { if (m_fixed_screen_size) {
@ -538,7 +568,8 @@ ColorRGBA GCodeViewer::Extrusions::Range::get_color_at(float value, EType type)
// 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
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
return convert(lerp(libvgcode::Ranges_Colors[color_low_idx], libvgcode::Ranges_Colors[color_high_idx], global_t - static_cast<float>(color_low_idx))); return libvgcode::convert(libvgcode::lerp(libvgcode::Ranges_Colors[color_low_idx], libvgcode::Ranges_Colors[color_high_idx],
global_t - static_cast<float>(color_low_idx)));
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
return lerp(Range_Colors[color_low_idx], Range_Colors[color_high_idx], global_t - static_cast<float>(color_low_idx)); return lerp(Range_Colors[color_low_idx], Range_Colors[color_high_idx], global_t - static_cast<float>(color_low_idx));
@ -1116,9 +1147,9 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
void GCodeViewer::SequentialView::render(float legend_height, const libvgcode::Viewer* viewer) void GCodeViewer::SequentialView::render(float legend_height, const libvgcode::Viewer* viewer)
{ {
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (viewer == nullptr) if (viewer == nullptr)
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GCodeViewer::SequentialView::render(float legend_height) void GCodeViewer::SequentialView::render(float legend_height)
@ -1357,7 +1388,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
std::vector<libvgcode::Color> colors; std::vector<libvgcode::Color> colors;
colors.reserve(tool_colors.size()); colors.reserve(tool_colors.size());
for (const ColorRGBA& color : tool_colors) { for (const ColorRGBA& color : tool_colors) {
colors.emplace_back(convert(color)); colors.emplace_back(libvgcode::convert(color));
} }
m_new_viewer.set_tool_colors(colors); m_new_viewer.set_tool_colors(colors);
@ -1371,7 +1402,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
reset(); reset();
// convert data from PrusaSlicer format to libvgcode format // convert data from PrusaSlicer format to libvgcode format
libvgcode::GCodeInputData data = convert(gcode_result); libvgcode::GCodeInputData data = libvgcode::convert(gcode_result);
// send data to the viewer // send data to the viewer
m_new_viewer.load(std::move(data)); m_new_viewer.load(std::move(data));
@ -1525,11 +1556,11 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
m_extrusions.ranges.height.update_from(round_to_bin(curr.height)); m_extrusions.ranges.height.update_from(round_to_bin(curr.height));
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
if (curr.extrusion_role != GCodeExtrusionRole::Custom || is_visible(convert(GCodeExtrusionRole::Custom))) if (curr.extrusion_role != GCodeExtrusionRole::Custom || is_visible(libvgcode::convert(GCodeExtrusionRole::Custom)))
m_extrusions.ranges.width.update_from(round_to_bin(curr.width)); m_extrusions.ranges.width.update_from(round_to_bin(curr.width));
m_extrusions.ranges.fan_speed.update_from(curr.fan_speed); m_extrusions.ranges.fan_speed.update_from(curr.fan_speed);
m_extrusions.ranges.temperature.update_from(curr.temperature); m_extrusions.ranges.temperature.update_from(curr.temperature);
if (curr.extrusion_role != GCodeExtrusionRole::Custom || is_visible(convert(GCodeExtrusionRole::Custom))) if (curr.extrusion_role != GCodeExtrusionRole::Custom || is_visible(libvgcode::convert(GCodeExtrusionRole::Custom)))
m_extrusions.ranges.volumetric_rate.update_from(round_to_bin(curr.volumetric_rate())); m_extrusions.ranges.volumetric_rate.update_from(round_to_bin(curr.volumetric_rate()));
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -1676,22 +1707,15 @@ void GCodeViewer::render()
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
if (m_use_new_viewer) { if (m_use_new_viewer) {
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Matrix4f view_matrix = camera.get_view_matrix().matrix().cast<float>(); libvgcode::Mat4x4 converted_view_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_view_matrix().matrix().cast<float>()));
const Matrix4f projection_matrix = camera.get_projection_matrix().matrix().cast<float>(); libvgcode::Mat4x4 converted_projetion_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_projection_matrix().matrix().cast<float>()));
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
libvgcode::Mat4x4f converted_view_matrix; libvgcode::Vec3 converted_tool_marker_position = libvgcode::convert(m_sequential_view.current_position);
std::memcpy(converted_view_matrix.data(), view_matrix.data(), 16 * sizeof(float));
libvgcode::Mat4x4f converted_projetion_matrix;
std::memcpy(converted_projetion_matrix.data(), projection_matrix.data(), 16 * sizeof(float));
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
libvgcode::Vec3f converted_tool_marker_position;
std::memcpy(converted_tool_marker_position.data(), m_sequential_view.current_position.data(), 3 * sizeof(float));
m_new_viewer.set_cog_marker_scale_factor(m_cog_marker_fixed_screen_size ? 10.0f * m_cog_marker_size * camera.get_inv_zoom() : m_cog_marker_size); m_new_viewer.set_cog_marker_scale_factor(m_cog_marker_fixed_screen_size ? 10.0f * m_cog_marker_size * camera.get_inv_zoom() : m_cog_marker_size);
m_new_viewer.enable_tool_marker(m_sequential_view.current.last != m_sequential_view.endpoints.last); m_new_viewer.enable_tool_marker(m_sequential_view.current.last != m_sequential_view.endpoints.last);
m_new_viewer.set_tool_marker_position(converted_tool_marker_position); m_new_viewer.set_tool_marker_position(converted_tool_marker_position);
m_new_viewer.set_tool_marker_scale_factor(m_tool_marker_fixed_screen_size ? 10.0f * m_tool_marker_size * camera.get_inv_zoom() : m_tool_marker_size); m_new_viewer.set_tool_marker_scale_factor(m_tool_marker_fixed_screen_size ? 10.0f * m_tool_marker_size * camera.get_inv_zoom() : m_tool_marker_size);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
m_new_viewer.render(converted_view_matrix, converted_projetion_matrix); m_new_viewer.render(converted_view_matrix, converted_projetion_matrix);
} }
else else
@ -1723,7 +1747,7 @@ void GCodeViewer::render()
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (m_use_new_viewer) { if (m_use_new_viewer) {
ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui(); ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
imgui.begin(std::string("LibVGCode Viewer Controller"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); imgui.begin(std::string("LibVGCode Viewer Controller"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
@ -1754,7 +1778,7 @@ void GCodeViewer::render()
imgui.end(); imgui.end();
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
@ -3212,7 +3236,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
switch (m_new_viewer.get_view_type()) switch (m_new_viewer.get_view_type())
{ {
case libvgcode::EViewType::FeatureType: { color = convert(libvgcode::Extrusion_Roles_Colors[static_cast<unsigned int>(path.role)]); break; } case libvgcode::EViewType::FeatureType: { color = libvgcode::convert(libvgcode::Extrusion_Roles_Colors[static_cast<unsigned int>(path.role)]); break; }
case libvgcode::EViewType::Height: { color = m_extrusions.ranges.height.get_color_at(path.height); break; } case libvgcode::EViewType::Height: { color = m_extrusions.ranges.height.get_color_at(path.height); break; }
case libvgcode::EViewType::Width: { color = m_extrusions.ranges.width.get_color_at(path.width); break; } case libvgcode::EViewType::Width: { color = m_extrusions.ranges.width.get_color_at(path.width); break; }
case libvgcode::EViewType::Speed: { color = m_extrusions.ranges.feedrate.get_color_at(path.feedrate); break; } case libvgcode::EViewType::Speed: { color = m_extrusions.ranges.feedrate.get_color_at(path.feedrate); break; }
@ -3241,10 +3265,10 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
break; break;
} }
case libvgcode::EViewType::VolumetricFlowRate: { color = m_extrusions.ranges.volumetric_rate.get_color_at(path.volumetric_rate); break; } case libvgcode::EViewType::VolumetricFlowRate: { color = m_extrusions.ranges.volumetric_rate.get_color_at(path.volumetric_rate); break; }
case libvgcode::EViewType::Tool: { color = convert(m_new_viewer.get_tool_colors()[path.extruder_id]); break; } case libvgcode::EViewType::Tool: { color = libvgcode::convert(m_new_viewer.get_tool_colors()[path.extruder_id]); break; }
case libvgcode::EViewType::ColorPrint: { case libvgcode::EViewType::ColorPrint: {
color = (path.cp_color_id >= m_new_viewer.get_tool_colors_count()) ? color = (path.cp_color_id >= m_new_viewer.get_tool_colors_count()) ?
ColorRGBA::GRAY() : convert(m_new_viewer.get_tool_colors()[path.cp_color_id]); ColorRGBA::GRAY() : libvgcode::convert(m_new_viewer.get_tool_colors()[path.cp_color_id]);
break; break;
} }
default: { color = ColorRGBA::WHITE(); break; } default: { color = ColorRGBA::WHITE(); break; }
@ -3301,9 +3325,9 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
auto travel_color = [](const Path& path) { auto travel_color = [](const Path& path) {
return (path.delta_extruder < 0.0f) ? convert(libvgcode::Travels_Colors[2]) /* Retract */ : return (path.delta_extruder < 0.0f) ? libvgcode::convert(libvgcode::Travels_Colors[2]) /* Retract */ :
((path.delta_extruder > 0.0f) ? convert(libvgcode::Travels_Colors[1]) /* Extrude */ : ((path.delta_extruder > 0.0f) ? libvgcode::convert(libvgcode::Travels_Colors[1]) /* Extrude */ :
convert(libvgcode::Travels_Colors[0]) /* Move */); libvgcode::convert(libvgcode::Travels_Colors[0]) /* Move */);
}; };
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -3550,7 +3574,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
else else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
color = convert(libvgcode::Dummy_Color); color = libvgcode::convert(libvgcode::Dummy_Color);
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
color = Neutral_Color; color = Neutral_Color;
@ -3570,7 +3594,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
extrusion_color(path) : travel_color(path); extrusion_color(path) : travel_color(path);
} }
else else
color = convert(libvgcode::Dummy_Color); color = libvgcode::convert(libvgcode::Dummy_Color);
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_travel_in_layers_range(path_id, m_layers_z_range[1], m_layers_z_range[1])) if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_travel_in_layers_range(path_id, m_layers_z_range[1], m_layers_z_range[1]))
@ -3585,7 +3609,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
case EMoveType::Wipe: { color = convert(libvgcode::Wipe_Color); break; } case EMoveType::Wipe: { color = libvgcode::convert(libvgcode::Wipe_Color); break; }
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
case EMoveType::Wipe: { color = Wipe_Color; break; } case EMoveType::Wipe: { color = Wipe_Color; break; }
@ -3678,7 +3702,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
if (has_second_range) if (has_second_range)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
buffer.model.instances.render_ranges.ranges.push_back({ 0, 0, 0, convert(libvgcode::Dummy_Color) }); buffer.model.instances.render_ranges.ranges.push_back({ 0, 0, 0, libvgcode::convert(libvgcode::Dummy_Color) });
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
buffer.model.instances.render_ranges.ranges.push_back({ 0, 0, 0, Neutral_Color }); buffer.model.instances.render_ranges.ranges.push_back({ 0, 0, 0, Neutral_Color });
@ -4387,7 +4411,7 @@ void GCodeViewer::render_legend(float& legend_height)
::sprintf(buf, "%.*f", decimals, value); ::sprintf(buf, "%.*f", decimals, value);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, 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);
@ -4435,7 +4459,7 @@ void GCodeViewer::render_legend(float& legend_height)
str_value = "< 1s"; str_value = "< 1s";
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, 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);
@ -4838,7 +4862,7 @@ void GCodeViewer::render_legend(float& legend_height)
const bool visible = is_visible(role); const bool visible = is_visible(role);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, convert(libvgcode::Extrusion_Roles_Colors[static_cast<unsigned int>(role)]), labels[i], append_item(EItemType::Rect, libvgcode::convert(libvgcode::Extrusion_Roles_Colors[static_cast<unsigned int>(role)]), labels[i],
visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i], visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i],
[this, role, visible]() { [this, role, visible]() {
m_new_viewer.toggle_extrusion_role_visibility((libvgcode::EGCodeExtrusionRole)role); m_new_viewer.toggle_extrusion_role_visibility((libvgcode::EGCodeExtrusionRole)role);
@ -4868,7 +4892,7 @@ void GCodeViewer::render_legend(float& legend_height)
if (m_buffers[buffer_id(EMoveType::Travel)].visible) if (m_buffers[buffer_id(EMoveType::Travel)].visible)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Line, convert(libvgcode::Travels_Colors[0]), _u8L("Travel"), true, short_time_ui(get_time_dhms(travels_time)), append_item(EItemType::Line, libvgcode::convert(libvgcode::Travels_Colors[0]), _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
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -4894,7 +4918,7 @@ void GCodeViewer::render_legend(float& legend_height)
// shows only extruders actually used // shows only extruders actually used
for (unsigned char extruder_id : m_extruder_ids) { for (unsigned char extruder_id : m_extruder_ids) {
if (used_filaments_m[extruder_id] > 0.0 && used_filaments_g[extruder_id] > 0.0) if (used_filaments_m[extruder_id] > 0.0 && used_filaments_g[extruder_id] > 0.0)
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors()[extruder_id]), _u8L("Extruder") + " " + std::to_string(extruder_id + 1), append_item(EItemType::Rect, libvgcode::convert(m_new_viewer.get_tool_colors()[extruder_id]), _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]); true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]);
} }
break; break;
@ -4941,7 +4965,7 @@ void GCodeViewer::render_legend(float& legend_height)
if (items_cnt == 0) // There are no color changes, but there are some pause print or custom Gcode if (items_cnt == 0) // There are no color changes, but there are some pause print or custom Gcode
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors().front()), _u8L("Default color")); append_item(EItemType::Rect, libvgcode::convert(m_new_viewer.get_tool_colors().front()), _u8L("Default color"));
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color")); append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color"));
@ -4954,7 +4978,7 @@ void GCodeViewer::render_legend(float& legend_height)
if (i == 0) { if (i == 0) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors().front()), upto_label(cp_values.front().second.first)); append_item(EItemType::Rect, libvgcode::convert(m_new_viewer.get_tool_colors().front()), upto_label(cp_values.front().second.first));
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
append_item(EItemType::Rect, m_tool_colors[0], upto_label(cp_values.front().second.first)); append_item(EItemType::Rect, m_tool_colors[0], upto_label(cp_values.front().second.first));
@ -4980,7 +5004,7 @@ void GCodeViewer::render_legend(float& legend_height)
// There are no color changes, but there are some pause print or custom Gcode // There are no color changes, but there are some pause print or custom Gcode
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors()[i]), _u8L("Extruder") + " " + append_item(EItemType::Rect, libvgcode::convert(m_new_viewer.get_tool_colors()[i]), _u8L("Extruder") + " " +
std::to_string(i + 1) + " " + _u8L("default color")); std::to_string(i + 1) + " " + _u8L("default color"));
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -4996,7 +5020,7 @@ void GCodeViewer::render_legend(float& legend_height)
label += " " + upto_label(cp_values.front().second.first); label += " " + upto_label(cp_values.front().second.first);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors()[i]), label); append_item(EItemType::Rect, libvgcode::convert(m_new_viewer.get_tool_colors()[i]), label);
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
append_item(EItemType::Rect, m_tool_colors[i], label); append_item(EItemType::Rect, m_tool_colors[i], label);
@ -5065,7 +5089,7 @@ void GCodeViewer::render_legend(float& legend_height)
for (size_t i = 0; i < m_extruders_count; ++i) { for (size_t i = 0; i < m_extruders_count; ++i) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
last_color[i] = convert(m_new_viewer.get_tool_colors()[i]); last_color[i] = libvgcode::convert(m_new_viewer.get_tool_colors()[i]);
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
last_color[i] = m_tool_colors[i]; last_color[i] = m_tool_colors[i];
@ -5483,9 +5507,9 @@ void GCodeViewer::render_legend(float& legend_height)
if (imgui.draw_radio_button(name, 1.5f * icon_size, active, draw_callback)) { if (imgui.draw_radio_button(name, 1.5f * icon_size, active, draw_callback)) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (type != Preview::OptionType::CenterOfGravity && type != Preview::OptionType::ToolMarker && type != Preview::OptionType::Shells) if (type != Preview::OptionType::CenterOfGravity && type != Preview::OptionType::ToolMarker && type != Preview::OptionType::Shells)
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type); m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type);
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -5692,7 +5716,7 @@ void GCodeViewer::render_statistics()
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
bool GCodeViewer::is_visible(const Path& path) const bool GCodeViewer::is_visible(const Path& path) const
{ {
return is_visible(convert(path.role)); return is_visible(libvgcode::convert(path.role));
} }
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -5724,14 +5748,14 @@ ColorRGBA GCodeViewer::option_color(EMoveType move_type) const
{ {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
case EMoveType::Tool_change: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::ToolChange)); } case EMoveType::Tool_change: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::ToolChange)); }
case EMoveType::Color_change: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::ColorChange)); } case EMoveType::Color_change: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::ColorChange)); }
case EMoveType::Pause_Print: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::PausePrint)); } case EMoveType::Pause_Print: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::PausePrint)); }
case EMoveType::Custom_GCode: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::CustomGCode)); } case EMoveType::Custom_GCode: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::CustomGCode)); }
case EMoveType::Retract: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Retract)); } case EMoveType::Retract: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Retract)); }
case EMoveType::Unretract: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Unretract)); } case EMoveType::Unretract: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Unretract)); }
case EMoveType::Seam: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Seam)); } case EMoveType::Seam: { return libvgcode::convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Seam)); }
default: { return convert(libvgcode::Dummy_Color); } default: { return libvgcode::convert(libvgcode::Dummy_Color); }
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
case EMoveType::Tool_change: { return Options_Colors[static_cast<unsigned int>(EOptionsColors::ToolChanges)]; } case EMoveType::Tool_change: { return Options_Colors[static_cast<unsigned int>(EOptionsColors::ToolChanges)]; }

View File

@ -404,10 +404,10 @@ class GCodeViewer
bool m_visible{ false }; bool m_visible{ false };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// whether or not to render the model with fixed screen size // whether or not to render the model with fixed screen size
bool m_fixed_screen_size{ true }; bool m_fixed_screen_size{ true };
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// whether or not to render the model with fixed screen size // whether or not to render the model with fixed screen size
@ -422,11 +422,11 @@ class GCodeViewer
public: public:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
void render(); void render();
#else #else
void render(bool fixed_screen_size); void render(bool fixed_screen_size);
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render(); void render();
@ -453,11 +453,11 @@ class GCodeViewer
private: private:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
void init() { void init() {
#else #else
void init(bool fixed_screen_size) { void init(bool fixed_screen_size) {
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void init() { void init() {
@ -469,11 +469,11 @@ class GCodeViewer
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
const float radius = m_fixed_screen_size ? 10.0f : 1.0f; const float radius = m_fixed_screen_size ? 10.0f : 1.0f;
#else #else
const float radius = fixed_screen_size ? 10.0f : 1.0f; const float radius = fixed_screen_size ? 10.0f : 1.0f;
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const float radius = m_fixed_screen_size ? 10.0f : 1.0f; const float radius = m_fixed_screen_size ? 10.0f : 1.0f;
@ -1006,11 +1006,11 @@ public:
void render(); void render();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
void render_cog() { m_cog.render(); } void render_cog() { m_cog.render(); }
#else #else
void render_cog() { m_cog.render(m_cog_marker_fixed_screen_size); } void render_cog() { m_cog.render(m_cog_marker_fixed_screen_size); }
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render_cog() { m_cog.render(); } void render_cog() { m_cog.render(); }
@ -1110,10 +1110,10 @@ public:
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
bool use_new_viewer() const { return m_use_new_viewer; } bool use_new_viewer() const { return m_use_new_viewer; }
void toggle_use_new_viewer() { m_use_new_viewer = !m_use_new_viewer; } void toggle_use_new_viewer() { m_use_new_viewer = !m_use_new_viewer; }
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #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(); } 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); } void set_cog_marker_scale_factor(float factor) { return m_new_viewer.set_cog_marker_scale_factor(factor); }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -1128,9 +1128,7 @@ private:
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
bool is_visible(libvgcode::EGCodeExtrusionRole role) const { bool is_visible(libvgcode::EGCodeExtrusionRole role) const { return m_new_viewer.is_extrusion_role_visible(role); }
return m_new_viewer.is_extrusion_role_visible(role);
}
bool is_visible(const Path& path) const; bool is_visible(const Path& path) const;
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

View File

@ -1949,7 +1949,7 @@ void GLCanvas3D::render()
#endif // ENABLE_RENDER_SELECTION_CENTER #endif // ENABLE_RENDER_SELECTION_CENTER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (!m_main_toolbar.is_enabled()) if (!m_main_toolbar.is_enabled())
_render_gcode_cog(); _render_gcode_cog();
#else #else
@ -1957,7 +1957,7 @@ void GLCanvas3D::render()
if (!m_gcode_viewer.use_new_viewer()) if (!m_gcode_viewer.use_new_viewer())
_render_gcode_cog(); _render_gcode_cog();
} }
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (!m_main_toolbar.is_enabled()) if (!m_main_toolbar.is_enabled())

View File

@ -18,7 +18,7 @@
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
namespace libvgcode { namespace libvgcode {
@ -64,16 +64,16 @@ void CogMarker::init(uint8_t resolution, float radius)
const float xy = radius * std::cos(stack_angle); const float xy = radius * std::cos(stack_angle);
const float z = radius * std::sin(stack_angle); const float z = radius * std::sin(stack_angle);
if (i == 0 || i == stack_count) { if (i == 0 || i == stack_count) {
const Vec3f pos = { xy, 0.0f, z }; const Vec3 pos = { xy, 0.0f, z };
const Vec3f norm = normalize(pos); const Vec3 norm = normalize(pos);
add_vertex(pos, norm, vertices); add_vertex(pos, norm, vertices);
} }
else { else {
for (uint16_t j = 0; j < sector_count; ++j) { for (uint16_t j = 0; j < sector_count; ++j) {
// from 0 to 2pi // from 0 to 2pi
const float sector_angle = sector_step * float(j); const float sector_angle = sector_step * float(j);
const Vec3f pos = { xy * std::cos(sector_angle), xy * std::sin(sector_angle), z }; const Vec3 pos = { xy * std::cos(sector_angle), xy * std::sin(sector_angle), z };
const Vec3f norm = normalize(pos); const Vec3 norm = normalize(pos);
add_vertex(pos, norm, vertices); add_vertex(pos, norm, vertices);
} }
} }
@ -145,7 +145,7 @@ void CogMarker::render()
glsafe(glBindVertexArray(curr_vertex_array)); glsafe(glBindVertexArray(curr_vertex_array));
} }
void CogMarker::update(const Vec3f& position, float mass) void CogMarker::update(const Vec3& position, float mass)
{ {
m_total_position = m_total_position + mass * position; m_total_position = m_total_position + mass * position;
m_total_mass += mass; m_total_mass += mass;
@ -157,7 +157,7 @@ void CogMarker::reset()
m_total_mass = 0.0f; m_total_mass = 0.0f;
} }
Vec3f CogMarker::get_position() const Vec3 CogMarker::get_position() const
{ {
assert(m_total_mass > 0.0f); assert(m_total_mass > 0.0f);
const float inv_total_mass = 1.0f / m_total_mass; const float inv_total_mass = 1.0f / m_total_mass;
@ -168,6 +168,6 @@ Vec3f CogMarker::get_position() const
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//################################################################################################################################ //################################################################################################################################

View File

@ -8,7 +8,7 @@
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
#include "Types.hpp" #include "Types.hpp"
@ -34,7 +34,7 @@ public:
// //
// Update values used to calculate the center of gravity // Update values used to calculate the center of gravity
// //
void update(const Vec3f& position, float mass); void update(const Vec3& position, float mass);
// //
// Reset values used to calculate the center of gravity // Reset values used to calculate the center of gravity
@ -44,14 +44,14 @@ public:
// //
// Return the calculated center of gravity // Return the calculated center of gravity
// //
Vec3f get_position() const; Vec3 get_position() const;
private: private:
// //
// Values used to calculate the center of gravity // Values used to calculate the center of gravity
// //
float m_total_mass{ 0.0f }; float m_total_mass{ 0.0f };
Vec3f m_total_position{ 0.0f, 0.0f, 0.0f }; Vec3 m_total_position{ 0.0f, 0.0f, 0.0f };
uint16_t m_indices_count{ 0 }; uint16_t m_indices_count{ 0 };
unsigned int m_vao_id{ 0 }; unsigned int m_vao_id{ 0 };
@ -63,7 +63,7 @@ private:
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//################################################################################################################################ //################################################################################################################################

View File

@ -62,16 +62,6 @@ ColorRange::EType ColorRange::get_type() const
Color ColorRange::get_color_at(float value) const Color ColorRange::get_color_at(float value) const
{ {
// std::lerp is available with c++20
auto lerp = [](const Color& a, const Color& b, float t) {
t = std::clamp(t, 0.0f, 1.0f);
Color ret;
for (int i = 0; i < 3; ++i) {
ret[i] = (1.0f - t) * a[i] + t * b[i];
}
return ret;
};
// Input value scaled to the colors range // Input value scaled to the colors range
float global_t = 0.0f; float global_t = 0.0f;
value = std::clamp(value, m_range[0], m_range[1]); value = std::clamp(value, m_range[0], m_range[1]);

View File

@ -16,13 +16,13 @@
namespace libvgcode { namespace libvgcode {
void ExtrusionRoles::add(EGCodeExtrusionRole role, const std::array<float, static_cast<size_t>(ETimeMode::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 < static_cast<size_t>(ETimeMode::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

@ -21,10 +21,10 @@ class ExtrusionRoles
public: public:
struct Item struct Item
{ {
std::array<float, static_cast<size_t>(ETimeMode::COUNT)> times; std::array<float, Time_Modes_Count> times;
}; };
void add(EGCodeExtrusionRole role, const std::array<float, static_cast<size_t>(ETimeMode::COUNT)>& times); void add(EGCodeExtrusionRole role, const std::array<float, Time_Modes_Count>& times);
size_t get_roles_count() const; size_t get_roles_count() const;
std::vector<EGCodeExtrusionRole> get_roles() const; std::vector<EGCodeExtrusionRole> get_roles() const;

View File

@ -24,7 +24,7 @@ struct GCodeInputData
// //
// Total time for each time mode // Total time for each time mode
// //
std::array<float, static_cast<size_t>(ETimeMode::COUNT)> times{ 0.0f, 0.0f }; std::array<float, Time_Modes_Count> times{ 0.0f, 0.0f };
}; };
} // namespace libvgcode } // namespace libvgcode

View File

@ -39,7 +39,7 @@ void Layers::update(const PathVertex& vertex, uint32_t vertex_id)
else { else {
Item& item = m_items.back(); Item& item = m_items.back();
item.range.set(item.range.get()[0], vertex_id); item.range.set(item.range.get()[0], vertex_id);
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::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

@ -35,7 +35,7 @@ private:
struct Item struct Item
{ {
Range range; Range range;
std::array<float, static_cast<size_t>(ETimeMode::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

@ -53,8 +53,8 @@ void OptionTemplate::init(uint8_t resolution)
add_vertex({ 0.0f, 0.0f, 0.5f }, { 0.0f, 0.0f, 1.0f }, top_vertices); add_vertex({ 0.0f, 0.0f, 0.5f }, { 0.0f, 0.0f, 1.0f }, top_vertices);
for (uint8_t i = 0; i <= m_resolution; ++i) { for (uint8_t i = 0; i <= m_resolution; ++i) {
const float ii = float(i) * step; const float ii = float(i) * step;
const Vec3f pos = { 0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f }; const Vec3 pos = { 0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f };
const Vec3f norm = normalize(pos); const Vec3 norm = normalize(pos);
add_vertex(pos, norm, top_vertices); add_vertex(pos, norm, top_vertices);
} }
@ -66,8 +66,8 @@ void OptionTemplate::init(uint8_t resolution)
add_vertex({ 0.0f, 0.0f, -0.5f }, { 0.0f, 0.0f, -1.0f }, bottom_vertices); add_vertex({ 0.0f, 0.0f, -0.5f }, { 0.0f, 0.0f, -1.0f }, bottom_vertices);
for (uint8_t i = 0; i <= m_resolution; ++i) { for (uint8_t i = 0; i <= m_resolution; ++i) {
const float ii = -float(i) * step; const float ii = -float(i) * step;
const Vec3f pos = { 0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f }; const Vec3 pos = { 0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f };
const Vec3f norm = normalize(pos); const Vec3 norm = normalize(pos);
add_vertex(pos, norm, bottom_vertices); add_vertex(pos, norm, bottom_vertices);
} }

View File

@ -16,23 +16,23 @@ namespace libvgcode {
struct PathVertex struct PathVertex
{ {
Vec3f position{ 0.0f, 0.0f, 0.0f }; Vec3 position{ 0.0f, 0.0f, 0.0f };
float height{ 0.0f }; float height{ 0.0f };
float width{ 0.0f }; float width{ 0.0f };
float feedrate{ 0.0f }; float feedrate{ 0.0f };
float fan_speed{ 0.0f }; float fan_speed{ 0.0f };
float temperature{ 0.0f }; float temperature{ 0.0f };
float volumetric_rate{ 0.0f }; float volumetric_rate{ 0.0f };
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
float weight{ 0.0f }; float weight{ 0.0f };
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
EGCodeExtrusionRole role{ EGCodeExtrusionRole::None }; EGCodeExtrusionRole role{ EGCodeExtrusionRole::None };
EMoveType type{ EMoveType::Noop }; EMoveType type{ EMoveType::Noop };
uint32_t move_id{ 0 }; uint32_t move_id{ 0 };
uint32_t layer_id{ 0 }; uint32_t layer_id{ 0 };
uint8_t extruder_id{ 0 }; uint8_t extruder_id{ 0 };
uint8_t color_id{ 0 }; uint8_t color_id{ 0 };
std::array<float, static_cast<size_t>(ETimeMode::COUNT)> times{ 0.0f, 0.0f }; std::array<float, Time_Modes_Count> times{ 0.0f, 0.0f };
bool is_extrusion() const; bool is_extrusion() const;
bool is_travel() const; bool is_travel() const;

View File

@ -35,11 +35,11 @@ struct Settings
{ EOptionType::ColorChanges, false }, { EOptionType::ColorChanges, false },
{ EOptionType::PausePrints, false }, { EOptionType::PausePrints, false },
{ EOptionType::CustomGCodes, false }, { EOptionType::CustomGCodes, false },
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
{ EOptionType::CenterOfGravity, false }, { EOptionType::CenterOfGravity, false },
{ EOptionType::Shells, false }, { EOptionType::Shells, false },
{ EOptionType::ToolMarker, true } { EOptionType::ToolMarker, true }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} }; } };
std::map<EGCodeExtrusionRole, bool> extrusion_roles_visibility{ { std::map<EGCodeExtrusionRole, bool> extrusion_roles_visibility{ {

View File

@ -205,7 +205,7 @@ static const char* Options_Fragment_Shader =
" fragmentColor = vec4(color, 1.0);\n" " fragmentColor = vec4(color, 1.0);\n"
"}\n"; "}\n";
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
static const char* Cog_Marker_Vertex_Shader = static const char* Cog_Marker_Vertex_Shader =
"#version 150\n" "#version 150\n"
"const vec3 light_top_dir = vec3(-0.4574957, 0.4574957, 0.7624929);\n" "const vec3 light_top_dir = vec3(-0.4574957, 0.4574957, 0.7624929);\n"
@ -293,7 +293,7 @@ static const char* Tool_Marker_Fragment_Shader =
"void main() {\n" "void main() {\n"
" fragment_color = color;\n" " fragment_color = color;\n"
"}\n"; "}\n";
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -16,7 +16,7 @@
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
namespace libvgcode { namespace libvgcode {
@ -175,12 +175,12 @@ void ToolMarker::enable(bool value)
m_enabled = value; m_enabled = value;
} }
const Vec3f& ToolMarker::get_position() const const Vec3& ToolMarker::get_position() const
{ {
return m_position; return m_position;
} }
void ToolMarker::set_position(const Vec3f& position) void ToolMarker::set_position(const Vec3& position)
{ {
m_position = position; m_position = position;
} }
@ -219,6 +219,6 @@ void ToolMarker::set_alpha(float alpha)
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//################################################################################################################################ //################################################################################################################################

View File

@ -8,7 +8,7 @@
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
#include "Types.hpp" #include "Types.hpp"
@ -31,8 +31,8 @@ public:
bool is_enabled() const; bool is_enabled() const;
void enable(bool value); void enable(bool value);
const Vec3f& get_position() const; const Vec3& get_position() const;
void set_position(const Vec3f& position); void set_position(const Vec3& position);
float get_offset_z() const; float get_offset_z() const;
void set_offset_z(float offset_z); void set_offset_z(float offset_z);
@ -45,7 +45,7 @@ public:
private: private:
bool m_enabled{ false }; bool m_enabled{ false };
Vec3f m_position{ 0.0f, 0.0f, 0.0f }; Vec3 m_position{ 0.0f, 0.0f, 0.0f };
float m_offset_z{ 0.5f }; float m_offset_z{ 0.5f };
Color m_color{ 1.0f, 1.0f, 1.0f }; Color m_color{ 1.0f, 1.0f, 1.0f };
float m_alpha{ 0.5f }; float m_alpha{ 0.5f };
@ -60,7 +60,7 @@ private:
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
//################################################################################################################################ //################################################################################################################################

View File

@ -9,6 +9,13 @@
///|/ ///|/
#include "Types.hpp" #include "Types.hpp"
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER
//################################################################################################################################
#include <algorithm>
namespace libvgcode { namespace libvgcode {
// mapping from EMoveType to EOptionType // mapping from EMoveType to EOptionType
@ -27,4 +34,17 @@ EOptionType type_to_option(EMoveType type)
} }
} }
Color lerp(const Color& c1, const Color& c2, float t)
{
// It will be possible to replace this with std::lerp when using c++20
t = std::clamp(t, 0.0f, 1.0f);
const float one_minus_t = 1.0f - t;
return { one_minus_t * c1[0] + t * c2[0], one_minus_t * c1[1] + t * c2[1], one_minus_t * c1[2] + t * c2[2] };
}
} // namespace libvgcode } // namespace libvgcode
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // ENABLE_NEW_GCODE_VIEWER
//################################################################################################################################

View File

@ -18,27 +18,35 @@ namespace libvgcode {
static constexpr float PI = 3.141592f; static constexpr float PI = 3.141592f;
static constexpr float TRAVEL_RADIUS = 0.05f; static constexpr float Default_Travel_Radius = 0.05f;
static constexpr float WIPE_RADIUS = 0.05f; static constexpr float Default_Wipe_Radius = 0.05f;
using Vec3f = std::array<float, 3>;
// //
// 4 by 4 square matrix with column-major order: // Vector in 3 dimensions
// Used for positions, displacements and so on.
//
using Vec3 = std::array<float, 3>;
//
// 4x4 square matrix with elements in column-major order:
// | a[0] a[4] a[8] a[12] | // | a[0] a[4] a[8] a[12] |
// | a[1] a[5] a[9] a[13] | // | a[1] a[5] a[9] a[13] |
// | a[2] a[6] a[10] a[14] | // | a[2] a[6] a[10] a[14] |
// | a[3] a[7] a[11] a[15] | // | a[3] a[7] a[11] a[15] |
// //
using Mat4x4f = std::array<float, 16>; using Mat4x4 = std::array<float, 16>;
// //
// [0] = red // [0] -> red
// [1] = green // [1] -> green
// [2] = blue // [2] -> blue
// values should belong to [0..1] // Values should belong to the range [0..1]
// //
using Color = std::array<float, 3>; using Color = std::array<float, 3>;
// Alias for GCodeViewer::EViewType defined into GCodeViewer.hpp //
// View types
//
enum class EViewType : uint8_t enum class EViewType : uint8_t
{ {
FeatureType, FeatureType,
@ -55,7 +63,9 @@ enum class EViewType : uint8_t
COUNT COUNT
}; };
// Alias for EMoveType defined into GCodeProcessor.hpp //
// Move types
//
enum class EMoveType : uint8_t enum class EMoveType : uint8_t
{ {
Noop, Noop,
@ -72,7 +82,9 @@ enum class EMoveType : uint8_t
COUNT COUNT
}; };
// Alias for GCodeExtrusionRole defined into ExtrusionRole.hpp //
// Extrusion roles
//
enum class EGCodeExtrusionRole : uint8_t enum class EGCodeExtrusionRole : uint8_t
{ {
None, None,
@ -93,7 +105,9 @@ enum class EGCodeExtrusionRole : uint8_t
COUNT COUNT
}; };
// Alias for Preview::OptionType defined into GUI_Preview.hpp //
// Option types
//
enum class EOptionType : uint8_t enum class EOptionType : uint8_t
{ {
Travels, Travels,
@ -105,15 +119,17 @@ enum class EOptionType : uint8_t
ColorChanges, ColorChanges,
PausePrints, PausePrints,
CustomGCodes, CustomGCodes,
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
CenterOfGravity, CenterOfGravity,
Shells, Shells,
ToolMarker, ToolMarker,
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
COUNT COUNT
}; };
// Alias for PrintEstimatedStatistics::ETimeMode defined into GCodeProcessor.hpp //
// Time modes
//
enum class ETimeMode : uint8_t enum class ETimeMode : uint8_t
{ {
Normal, Normal,
@ -121,6 +137,8 @@ enum class ETimeMode : uint8_t
COUNT COUNT
}; };
static constexpr size_t Time_Modes_Count = static_cast<size_t>(ETimeMode::COUNT);
// //
// Predefined colors // Predefined colors
// //
@ -129,6 +147,8 @@ static const Color Wipe_Color{ 1.0f, 1.0f, 0.0f };
// //
// Palette used to render moves by ranges // Palette used to render moves by ranges
// EViewType: Height, Width, Speed, FanSpeed, Temperature, VolumetricFlowRate,
// LayerTimeLinear, LayerTimeLogarithmic
// //
static const std::vector<Color> Ranges_Colors{ { static const std::vector<Color> Ranges_Colors{ {
{ 0.043f, 0.173f, 0.478f }, // bluish { 0.043f, 0.173f, 0.478f }, // bluish
@ -146,6 +166,7 @@ static const std::vector<Color> Ranges_Colors{ {
// //
// Palette used to render extrusion moves by extrusion roles // Palette used to render extrusion moves by extrusion roles
// EViewType: FeatureType
// //
static const std::vector<Color> Extrusion_Roles_Colors{ { static const std::vector<Color> Extrusion_Roles_Colors{ {
{ 0.90f, 0.70f, 0.70f }, // None { 0.90f, 0.70f, 0.70f }, // None
@ -167,6 +188,8 @@ static const std::vector<Color> Extrusion_Roles_Colors{ {
// //
// Palette used to render travel moves // Palette used to render travel moves
// EViewType: FeatureType, Height, Width, FanSpeed, Temperature, VolumetricFlowRate,
// LayerTimeLinear, LayerTimeLogarithmic
// //
static const std::vector<Color> Travels_Colors{ { static const std::vector<Color> Travels_Colors{ {
{ 0.219f, 0.282f, 0.609f }, // Move { 0.219f, 0.282f, 0.609f }, // Move
@ -175,7 +198,7 @@ static const std::vector<Color> Travels_Colors{ {
} }; } };
// //
// Palette used to render option moves // Palette used to render options
// //
static const std::map<EMoveType, Color> Options_Colors{ { static const std::map<EMoveType, Color> Options_Colors{ {
{ EMoveType::Retract, { 0.803f, 0.135f, 0.839f } }, { EMoveType::Retract, { 0.803f, 0.135f, 0.839f } },
@ -192,6 +215,13 @@ static const std::map<EMoveType, Color> Options_Colors{ {
// //
extern EOptionType type_to_option(EMoveType type); extern EOptionType type_to_option(EMoveType type);
//
// Returns the linear interpolation between the two given colors
// at the given t.
// t is clamped in the range [0..1]
//
extern Color lerp(const Color& c1, const Color& c2, float t);
} // namespace libvgcode } // namespace libvgcode
//################################################################################################################################ //################################################################################################################################

View File

@ -18,7 +18,7 @@
namespace libvgcode { namespace libvgcode {
void add_vertex(const Vec3f& position, const Vec3f& normal, std::vector<float>& vertices) void add_vertex(const Vec3& position, const Vec3& normal, std::vector<float>& vertices)
{ {
vertices.emplace_back(position[0]); vertices.emplace_back(position[0]);
vertices.emplace_back(position[1]); vertices.emplace_back(position[1]);
@ -35,7 +35,7 @@ void add_triangle(uint16_t v1, uint16_t v2, uint16_t v3, std::vector<uint16_t>&
indices.emplace_back(v3); indices.emplace_back(v3);
} }
Vec3f normalize(const Vec3f& v) Vec3 normalize(const Vec3& v)
{ {
const float length = std::sqrt(dot(v, v)); const float length = std::sqrt(dot(v, v));
assert(length > 0.0f); assert(length > 0.0f);
@ -43,33 +43,33 @@ Vec3f normalize(const Vec3f& v)
return { v[0] * inv_length, v[1] * inv_length, v[2] * inv_length }; return { v[0] * inv_length, v[1] * inv_length, v[2] * inv_length };
} }
float dot(const Vec3f& v1, const Vec3f& v2) float dot(const Vec3& v1, const Vec3& v2)
{ {
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
} }
float length(const Vec3f& v) float length(const Vec3& v)
{ {
return std::sqrt(dot(v, v)); return std::sqrt(dot(v, v));
} }
bool operator == (const Vec3f& v1, const Vec3f& v2) { bool operator == (const Vec3& v1, const Vec3& v2) {
return v1[0] == v2[0] && v1[1] == v2[1] && v1[2] == v2[2]; return v1[0] == v2[0] && v1[1] == v2[1] && v1[2] == v2[2];
} }
bool operator != (const Vec3f& v1, const Vec3f& v2) { bool operator != (const Vec3& v1, const Vec3& v2) {
return v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]; return v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2];
} }
Vec3f operator + (const Vec3f& v1, const Vec3f& v2) { Vec3 operator + (const Vec3& v1, const Vec3& v2) {
return { v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2] }; return { v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2] };
} }
Vec3f operator - (const Vec3f& v1, const Vec3f& v2) { Vec3 operator - (const Vec3& v1, const Vec3& v2) {
return { v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2] }; return { v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2] };
} }
Vec3f operator * (float f, const Vec3f& v) { Vec3 operator * (float f, const Vec3& v) {
return { f * v[0], f * v[1], f * v[2] }; return { f * v[0], f * v[1], f * v[2] };
} }

View File

@ -16,16 +16,16 @@
namespace libvgcode { namespace libvgcode {
extern void add_vertex(const Vec3f& position, const Vec3f& normal, std::vector<float>& vertices); extern void add_vertex(const Vec3& position, const Vec3& normal, std::vector<float>& vertices);
extern void add_triangle(uint16_t v1, uint16_t v2, uint16_t v3, std::vector<uint16_t>& indices); extern void add_triangle(uint16_t v1, uint16_t v2, uint16_t v3, std::vector<uint16_t>& indices);
extern Vec3f normalize(const Vec3f& v); extern Vec3 normalize(const Vec3& v);
extern float dot(const Vec3f& v1, const Vec3f& v2); extern float dot(const Vec3& v1, const Vec3& v2);
extern float length(const Vec3f& v); extern float length(const Vec3& v);
extern bool operator == (const Vec3f& v1, const Vec3f& v2); extern bool operator == (const Vec3& v1, const Vec3& v2);
extern bool operator != (const Vec3f& v1, const Vec3f& v2); extern bool operator != (const Vec3& v1, const Vec3& v2);
extern Vec3f operator + (const Vec3f& v1, const Vec3f& v2); extern Vec3 operator + (const Vec3& v1, const Vec3& v2);
extern Vec3f operator - (const Vec3f& v1, const Vec3f& v2); extern Vec3 operator - (const Vec3& v1, const Vec3& v2);
extern Vec3f operator * (float f, const Vec3f& v); extern Vec3 operator * (float f, const Vec3& v);
} // namespace libvgcode } // namespace libvgcode

View File

@ -31,7 +31,7 @@ void Viewer::load(GCodeInputData&& gcode_data)
m_impl.load(std::move(gcode_data)); m_impl.load(std::move(gcode_data));
} }
void Viewer::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) void Viewer::render(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{ {
m_impl.render(view_matrix, projection_matrix); m_impl.render(view_matrix, projection_matrix);
} }
@ -186,8 +186,8 @@ void Viewer::set_tool_colors(const std::vector<Color>& colors)
m_impl.set_tool_colors(colors); m_impl.set_tool_colors(colors);
} }
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
Vec3f Viewer::get_cog_position() const Vec3 Viewer::get_cog_position() const
{ {
return m_impl.get_cog_marker_position(); return m_impl.get_cog_marker_position();
} }
@ -212,12 +212,12 @@ void Viewer::enable_tool_marker(bool value)
m_impl.enable_tool_marker(value); m_impl.enable_tool_marker(value);
} }
const Vec3f& Viewer::get_tool_marker_position() const const Vec3& Viewer::get_tool_marker_position() const
{ {
return m_impl.get_tool_marker_position(); return m_impl.get_tool_marker_position();
} }
void Viewer::set_tool_marker_position(const Vec3f& position) void Viewer::set_tool_marker_position(const Vec3& position)
{ {
m_impl.set_tool_marker_position(position); m_impl.set_tool_marker_position(position);
} }
@ -251,7 +251,7 @@ void Viewer::set_tool_marker_alpha(float alpha)
{ {
m_impl.set_tool_marker_alpha(alpha); m_impl.set_tool_marker_alpha(alpha);
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -29,7 +29,7 @@ public:
void init(); void init();
void reset(); void reset();
void load(GCodeInputData&& gcode_data); void load(GCodeInputData&& gcode_data);
void render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
EViewType get_view_type() const; EViewType get_view_type() const;
void set_view_type(EViewType type); void set_view_type(EViewType type);
@ -107,7 +107,7 @@ public:
const std::vector<Color>& get_tool_colors() const; const std::vector<Color>& get_tool_colors() const;
void set_tool_colors(const std::vector<Color>& colors); void set_tool_colors(const std::vector<Color>& colors);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// //
// Returns the position of the center of gravity of the toolpaths. // Returns the position of the center of gravity of the toolpaths.
// It does not take in account extrusions of type: // It does not take in account extrusions of type:
@ -117,7 +117,7 @@ public:
// WipeTower // WipeTower
// Custom // Custom
// //
Vec3f get_cog_position() const; Vec3 get_cog_position() const;
float get_cog_marker_scale_factor() const; float get_cog_marker_scale_factor() const;
void set_cog_marker_scale_factor(float factor); void set_cog_marker_scale_factor(float factor);
@ -125,8 +125,8 @@ public:
bool is_tool_marker_enabled() const; bool is_tool_marker_enabled() const;
void enable_tool_marker(bool value); void enable_tool_marker(bool value);
const Vec3f& get_tool_marker_position() const; const Vec3& get_tool_marker_position() const;
void set_tool_marker_position(const Vec3f& position); void set_tool_marker_position(const Vec3& position);
float get_tool_marker_scale_factor() const; float get_tool_marker_scale_factor() const;
void set_tool_marker_scale_factor(float factor); void set_tool_marker_scale_factor(float factor);
@ -136,7 +136,7 @@ public:
float get_tool_marker_alpha() const; float get_tool_marker_alpha() const;
void set_tool_marker_alpha(float alpha); void set_tool_marker_alpha(float alpha);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
private: private:
ViewerImpl m_impl; ViewerImpl m_impl;

View File

@ -71,11 +71,11 @@ static float round_to_bin(const float value)
return fast_round_up<int64_t>(a) * invscale[i]; return fast_round_up<int64_t>(a) * invscale[i];
} }
static Mat4x4f inverse(const Mat4x4f& m) static Mat4x4 inverse(const Mat4x4& m)
{ {
// ref: https://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix // ref: https://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix
std::array<float, 16> inv; Mat4x4 inv;
inv[0] = m[5] * m[10] * m[15] - inv[0] = m[5] * m[10] * m[15] -
m[5] * m[11] * m[14] - m[5] * m[11] * m[14] -
@ -406,7 +406,7 @@ void ViewerImpl::init()
m_option_template.init(16); m_option_template.init(16);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// cog marker shader // cog marker shader
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader); m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader);
@ -439,7 +439,7 @@ void ViewerImpl::init()
m_uni_tool_marker_color_base != -1); m_uni_tool_marker_color_base != -1);
m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f); m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} }
void ViewerImpl::reset() void ViewerImpl::reset()
@ -451,9 +451,9 @@ void ViewerImpl::reset()
m_travels_time = { 0.0f, 0.0f }; m_travels_time = { 0.0f, 0.0f };
m_vertices.clear(); m_vertices.clear();
m_valid_lines_bitset.clear(); m_valid_lines_bitset.clear();
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
m_cog_marker.reset(); m_cog_marker.reset();
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
delete_textures(m_enabled_options_tex_id); delete_textures(m_enabled_options_tex_id);
delete_buffers(m_enabled_options_buf_id); delete_buffers(m_enabled_options_buf_id);
@ -491,7 +491,7 @@ 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 i = 0; i < static_cast<size_t>(ETimeMode::COUNT); ++i) { for (size_t i = 0; i < Time_Modes_Count; ++i) {
m_travels_time[i] += v.times[i]; m_travels_time[i] += v.times[i];
} }
} }
@ -499,7 +499,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
m_extrusion_roles.add(v.role, v.times); m_extrusion_roles.add(v.role, v.times);
if (i > 0) { if (i > 0) {
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// updates calculation for center of gravity // updates calculation for center of gravity
if (v.type == EMoveType::Extrude && if (v.type == EMoveType::Extrude &&
v.role != EGCodeExtrusionRole::Skirt && v.role != EGCodeExtrusionRole::Skirt &&
@ -507,9 +507,9 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
v.role != EGCodeExtrusionRole::SupportMaterialInterface && v.role != EGCodeExtrusionRole::SupportMaterialInterface &&
v.role != EGCodeExtrusionRole::WipeTower && v.role != EGCodeExtrusionRole::WipeTower &&
v.role != EGCodeExtrusionRole::Custom) { v.role != EGCodeExtrusionRole::Custom) {
m_cog_marker.update(0.5f * (v.position + gcode_data.vertices[i - 1].position), v.weight); m_cog_marker.update(0.5f * (v.position + m_vertices[i - 1].position), v.weight);
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} }
} }
@ -517,23 +517,23 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
m_valid_lines_bitset = BitSet<>(m_vertices.size()); m_valid_lines_bitset = BitSet<>(m_vertices.size());
m_valid_lines_bitset.setAll(); m_valid_lines_bitset.setAll();
static constexpr const Vec3f ZERO = { 0.0f, 0.0f, 0.0f }; static constexpr const Vec3 ZERO = { 0.0f, 0.0f, 0.0f };
// buffers to send to gpu // buffers to send to gpu
std::vector<Vec3f> positions; std::vector<Vec3> positions;
std::vector<Vec3f> heights_widths_angles; std::vector<Vec3> heights_widths_angles;
positions.reserve(m_vertices.size()); positions.reserve(m_vertices.size());
heights_widths_angles.reserve(m_vertices.size()); heights_widths_angles.reserve(m_vertices.size());
for (size_t i = 0; i < m_vertices.size(); ++i) { for (size_t i = 0; i < m_vertices.size(); ++i) {
const PathVertex& v = m_vertices[i]; const PathVertex& v = m_vertices[i];
const EMoveType move_type = v.type; const EMoveType move_type = v.type;
const bool prev_line_valid = i > 0 && m_valid_lines_bitset[i - 1]; const bool prev_line_valid = i > 0 && m_valid_lines_bitset[i - 1];
const Vec3f prev_line = prev_line_valid ? v.position - m_vertices[i - 1].position : ZERO; const Vec3 prev_line = prev_line_valid ? v.position - m_vertices[i - 1].position : ZERO;
const bool this_line_valid = i + 1 < m_vertices.size() && const bool this_line_valid = i + 1 < m_vertices.size() &&
m_vertices[i + 1].position != v.position && m_vertices[i + 1].position != v.position &&
m_vertices[i + 1].type == move_type && m_vertices[i + 1].type == move_type &&
move_type != EMoveType::Seam; move_type != EMoveType::Seam;
const Vec3f this_line = this_line_valid ? m_vertices[i + 1].position - v.position : ZERO; const Vec3 this_line = this_line_valid ? m_vertices[i + 1].position - v.position : ZERO;
if (this_line_valid) { if (this_line_valid) {
// there is a valid path between point i and i+1. // there is a valid path between point i and i+1.
@ -543,7 +543,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
m_valid_lines_bitset.reset(i); m_valid_lines_bitset.reset(i);
} }
Vec3f position = v.position; Vec3 position = v.position;
if (move_type == EMoveType::Extrude) if (move_type == EMoveType::Extrude)
// push down extrusion vertices by half height to render them at the right z // push down extrusion vertices by half height to render them at the right z
position[2] -= 0.5 * v.height; position[2] -= 0.5 * v.height;
@ -560,14 +560,14 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
// create and fill positions buffer // create and fill positions buffer
glsafe(glGenBuffers(1, &m_positions_buf_id)); glsafe(glGenBuffers(1, &m_positions_buf_id));
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_positions_buf_id)); glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_positions_buf_id));
glsafe(glBufferData(GL_TEXTURE_BUFFER, positions.size() * sizeof(Vec3f), positions.data(), GL_STATIC_DRAW)); glsafe(glBufferData(GL_TEXTURE_BUFFER, positions.size() * sizeof(Vec3), positions.data(), GL_STATIC_DRAW));
glsafe(glGenTextures(1, &m_positions_tex_id)); glsafe(glGenTextures(1, &m_positions_tex_id));
glsafe(glBindTexture(GL_TEXTURE_BUFFER, m_positions_tex_id)); glsafe(glBindTexture(GL_TEXTURE_BUFFER, m_positions_tex_id));
// create and fill height, width and angles buffer // create and fill height, width and angles buffer
glsafe(glGenBuffers(1, &m_heights_widths_angles_buf_id)); glsafe(glGenBuffers(1, &m_heights_widths_angles_buf_id));
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_heights_widths_angles_buf_id)); glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_heights_widths_angles_buf_id));
glsafe(glBufferData(GL_TEXTURE_BUFFER, heights_widths_angles.size() * sizeof(Vec3f), heights_widths_angles.data(), GL_STATIC_DRAW)); glsafe(glBufferData(GL_TEXTURE_BUFFER, heights_widths_angles.size() * sizeof(Vec3), heights_widths_angles.data(), GL_STATIC_DRAW));
glsafe(glGenTextures(1, &m_heights_widths_angles_tex_id)); glsafe(glGenTextures(1, &m_heights_widths_angles_tex_id));
glsafe(glBindTexture(GL_TEXTURE_BUFFER, m_heights_widths_angles_tex_id)); glsafe(glBindTexture(GL_TEXTURE_BUFFER, m_heights_widths_angles_tex_id));
@ -700,7 +700,7 @@ void ViewerImpl::update_colors()
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0)); glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
} }
void ViewerImpl::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) void ViewerImpl::render(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{ {
if (m_settings.update_view_global_range) { if (m_settings.update_view_global_range) {
update_view_global_range(); update_view_global_range();
@ -717,17 +717,17 @@ void ViewerImpl::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_ma
m_settings.update_colors = false; m_settings.update_colors = false;
} }
const Mat4x4f inv_view_matrix = inverse(view_matrix); const Mat4x4 inv_view_matrix = inverse(view_matrix);
const Vec3f camera_position = { inv_view_matrix[12], inv_view_matrix[13], inv_view_matrix[14] }; 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_segments(view_matrix, projection_matrix, camera_position);
render_options(view_matrix, projection_matrix); render_options(view_matrix, projection_matrix);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
if (m_settings.options_visibility.at(EOptionType::ToolMarker)) if (m_settings.options_visibility.at(EOptionType::ToolMarker))
render_tool_marker(view_matrix, projection_matrix); render_tool_marker(view_matrix, projection_matrix);
if (m_settings.options_visibility.at(EOptionType::CenterOfGravity)) if (m_settings.options_visibility.at(EOptionType::CenterOfGravity))
render_cog_marker(view_matrix, projection_matrix); render_cog_marker(view_matrix, projection_matrix);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if ENABLE_NEW_GCODE_VIEWER_DEBUG
render_debug_window(); render_debug_window();
@ -739,57 +739,28 @@ EViewType ViewerImpl::get_view_type() const
return m_settings.view_type; return m_settings.view_type;
} }
ETimeMode ViewerImpl::get_time_mode() const
{
return m_settings.time_mode;
}
const std::array<uint32_t, 2>& ViewerImpl::get_layers_range() const
{
return m_layers_range.get();
}
bool ViewerImpl::is_top_layer_only_view_range() const
{
return m_settings.top_layer_only_view_range;
}
bool ViewerImpl::is_option_visible(EOptionType type) const
{
try
{
return m_settings.options_visibility.at(type);
}
catch (...)
{
return false;
}
}
bool ViewerImpl::is_extrusion_role_visible(EGCodeExtrusionRole role) const
{
try
{
return m_settings.extrusion_roles_visibility.at(role);
}
catch (...)
{
return false;
}
}
void ViewerImpl::set_view_type(EViewType type) void ViewerImpl::set_view_type(EViewType type)
{ {
m_settings.view_type = type; m_settings.view_type = type;
m_settings.update_colors = true; m_settings.update_colors = true;
} }
ETimeMode ViewerImpl::get_time_mode() const
{
return m_settings.time_mode;
}
void ViewerImpl::set_time_mode(ETimeMode mode) void ViewerImpl::set_time_mode(ETimeMode mode)
{ {
m_settings.time_mode = mode; m_settings.time_mode = mode;
m_settings.update_colors = true; m_settings.update_colors = true;
} }
const std::array<uint32_t, 2>& ViewerImpl::get_layers_range() const
{
return m_layers_range.get();
}
void ViewerImpl::set_layers_range(const std::array<uint32_t, 2>& range) void ViewerImpl::set_layers_range(const std::array<uint32_t, 2>& range)
{ {
set_layers_range(range[0], range[1]); set_layers_range(range[0], range[1]);
@ -803,16 +774,30 @@ void ViewerImpl::set_layers_range(uint32_t min, uint32_t max)
m_settings.update_colors = true; m_settings.update_colors = true;
} }
bool ViewerImpl::is_top_layer_only_view_range() const
{
return m_settings.top_layer_only_view_range;
}
void ViewerImpl::set_top_layer_only_view_range(bool top_layer_only_view_range) void ViewerImpl::set_top_layer_only_view_range(bool top_layer_only_view_range)
{ {
m_settings.top_layer_only_view_range = top_layer_only_view_range; m_settings.top_layer_only_view_range = top_layer_only_view_range;
m_settings.update_colors = true; m_settings.update_colors = true;
} }
bool ViewerImpl::is_option_visible(EOptionType type) const
{
try {
return m_settings.options_visibility.at(type);
}
catch (...) {
return false;
}
}
void ViewerImpl::toggle_option_visibility(EOptionType type) void ViewerImpl::toggle_option_visibility(EOptionType type)
{ {
try try {
{
bool& value = m_settings.options_visibility.at(type); bool& value = m_settings.options_visibility.at(type);
value = !value; value = !value;
if (type == EOptionType::Travels) if (type == EOptionType::Travels)
@ -820,23 +805,30 @@ void ViewerImpl::toggle_option_visibility(EOptionType type)
m_settings.update_enabled_entities = true; m_settings.update_enabled_entities = true;
m_settings.update_colors = true; m_settings.update_colors = true;
} }
catch (...) catch (...) {
{
// do nothing; // do nothing;
} }
} }
bool ViewerImpl::is_extrusion_role_visible(EGCodeExtrusionRole role) const
{
try {
return m_settings.extrusion_roles_visibility.at(role);
}
catch (...) {
return false;
}
}
void ViewerImpl::toggle_extrusion_role_visibility(EGCodeExtrusionRole role) void ViewerImpl::toggle_extrusion_role_visibility(EGCodeExtrusionRole role)
{ {
try try {
{
bool& value = m_settings.extrusion_roles_visibility.at(role); bool& value = m_settings.extrusion_roles_visibility.at(role);
value = !value; value = !value;
m_settings.update_enabled_entities = true; m_settings.update_enabled_entities = true;
m_settings.update_colors = true; m_settings.update_colors = true;
} }
catch (...) catch (...) {
{
// do nothing; // do nothing;
} }
} }
@ -964,8 +956,14 @@ const std::vector<Color>& ViewerImpl::get_tool_colors() const
return m_tool_colors; return m_tool_colors;
} }
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS void ViewerImpl::set_tool_colors(const std::vector<Color>& colors)
Vec3f ViewerImpl::get_cog_marker_position() const {
m_tool_colors = colors;
m_settings.update_colors = true;
}
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
Vec3 ViewerImpl::get_cog_marker_position() const
{ {
return m_cog_marker.get_position(); return m_cog_marker.get_position();
} }
@ -975,84 +973,75 @@ float ViewerImpl::get_cog_marker_scale_factor() const
return m_cog_marker_scale_factor; return m_cog_marker_scale_factor;
} }
bool ViewerImpl::is_tool_marker_enabled() const
{
return m_tool_marker.is_enabled();
}
const Vec3f& ViewerImpl::get_tool_marker_position() const
{
return m_tool_marker.get_position();
}
float ViewerImpl::get_tool_marker_offset_z() const
{
return m_tool_marker.get_offset_z();
}
float ViewerImpl::get_tool_marker_scale_factor() const
{
return m_tool_marker_scale_factor;
}
const Color& ViewerImpl::get_tool_marker_color() const
{
return m_tool_marker.get_color();
}
float ViewerImpl::get_tool_marker_alpha() const
{
return m_tool_marker.get_alpha();
}
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::set_tool_colors(const std::vector<Color>& colors)
{
m_tool_colors = colors;
m_settings.update_colors = true;
}
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::set_cog_marker_scale_factor(float factor) void ViewerImpl::set_cog_marker_scale_factor(float factor)
{ {
m_cog_marker_scale_factor = std::max(factor, 0.001f); m_cog_marker_scale_factor = std::max(factor, 0.001f);
} }
bool ViewerImpl::is_tool_marker_enabled() const
{
return m_tool_marker.is_enabled();
}
void ViewerImpl::enable_tool_marker(bool value) void ViewerImpl::enable_tool_marker(bool value)
{ {
m_tool_marker.enable(value); m_tool_marker.enable(value);
} }
void ViewerImpl::set_tool_marker_position(const Vec3f& position) const Vec3& ViewerImpl::get_tool_marker_position() const
{
return m_tool_marker.get_position();
}
void ViewerImpl::set_tool_marker_position(const Vec3& position)
{ {
m_tool_marker.set_position(position); m_tool_marker.set_position(position);
} }
float ViewerImpl::get_tool_marker_offset_z() const
{
return m_tool_marker.get_offset_z();
}
void ViewerImpl::set_tool_marker_offset_z(float offset_z) void ViewerImpl::set_tool_marker_offset_z(float offset_z)
{ {
m_tool_marker.set_offset_z(offset_z); m_tool_marker.set_offset_z(offset_z);
} }
float ViewerImpl::get_tool_marker_scale_factor() const
{
return m_tool_marker_scale_factor;
}
void ViewerImpl::set_tool_marker_scale_factor(float factor) void ViewerImpl::set_tool_marker_scale_factor(float factor)
{ {
m_tool_marker_scale_factor = std::max(factor, 0.001f); m_tool_marker_scale_factor = std::max(factor, 0.001f);
} }
const Color& ViewerImpl::get_tool_marker_color() const
{
return m_tool_marker.get_color();
}
void ViewerImpl::set_tool_marker_color(const Color& color) void ViewerImpl::set_tool_marker_color(const Color& color)
{ {
m_tool_marker.set_color(color); m_tool_marker.set_color(color);
} }
float ViewerImpl::get_tool_marker_alpha() const
{
return m_tool_marker.get_alpha();
}
void ViewerImpl::set_tool_marker_alpha(float alpha) void ViewerImpl::set_tool_marker_alpha(float alpha)
{ {
m_tool_marker.set_alpha(alpha); m_tool_marker.set_alpha(alpha);
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
static bool is_visible(EMoveType type, const Settings& settings) static bool is_visible(EMoveType type, const Settings& settings)
{ {
try try {
{
return ((type == EMoveType::Travel && !settings.options_visibility.at(EOptionType::Travels)) || return ((type == EMoveType::Travel && !settings.options_visibility.at(EOptionType::Travels)) ||
(type == EMoveType::Wipe && !settings.options_visibility.at(EOptionType::Wipes)) || (type == EMoveType::Wipe && !settings.options_visibility.at(EOptionType::Wipes)) ||
(type == EMoveType::Retract && !settings.options_visibility.at(EOptionType::Retractions)) || (type == EMoveType::Retract && !settings.options_visibility.at(EOptionType::Retractions)) ||
@ -1063,8 +1052,7 @@ static bool is_visible(EMoveType type, const Settings& settings)
(type == EMoveType::PausePrint && !settings.options_visibility.at(EOptionType::PausePrints)) || (type == EMoveType::PausePrint && !settings.options_visibility.at(EOptionType::PausePrints)) ||
(type == EMoveType::CustomGCode && !settings.options_visibility.at(EOptionType::CustomGCodes))) ? false : true; (type == EMoveType::CustomGCode && !settings.options_visibility.at(EOptionType::CustomGCodes))) ? false : true;
} }
catch (...) catch (...) {
{
return false; return false;
} }
} }
@ -1232,7 +1220,7 @@ Color ViewerImpl::select_color(const PathVertex& v) const
return Dummy_Color; return Dummy_Color;
} }
void ViewerImpl::render_segments(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix, const Vec3f& camera_position) void ViewerImpl::render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position)
{ {
if (m_segments_shader_id == 0) if (m_segments_shader_id == 0)
return; return;
@ -1284,7 +1272,7 @@ void ViewerImpl::render_segments(const Mat4x4f& view_matrix, const Mat4x4f& proj
glsafe(glActiveTexture(curr_active_texture)); glsafe(glActiveTexture(curr_active_texture));
} }
void ViewerImpl::render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) void ViewerImpl::render_options(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{ {
if (m_options_shader_id == 0) if (m_options_shader_id == 0)
return; return;
@ -1335,8 +1323,8 @@ void ViewerImpl::render_options(const Mat4x4f& view_matrix, const Mat4x4f& proje
glsafe(glActiveTexture(curr_active_texture)); glsafe(glActiveTexture(curr_active_texture));
} }
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) void ViewerImpl::render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{ {
if (m_cog_marker_shader_id == 0) if (m_cog_marker_shader_id == 0)
return; return;
@ -1367,7 +1355,7 @@ void ViewerImpl::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& pr
glsafe(glUseProgram(curr_shader)); glsafe(glUseProgram(curr_shader));
} }
void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) void ViewerImpl::render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{ {
if (m_tool_marker_shader_id == 0) if (m_tool_marker_shader_id == 0)
return; return;
@ -1392,9 +1380,9 @@ void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& p
glsafe(glUseProgram(m_tool_marker_shader_id)); glsafe(glUseProgram(m_tool_marker_shader_id));
const Vec3f& origin = m_tool_marker.get_position(); const Vec3& origin = m_tool_marker.get_position();
const Vec3f offset = { 0.0f, 0.0f, m_tool_marker.get_offset_z() }; const Vec3 offset = { 0.0f, 0.0f, m_tool_marker.get_offset_z() };
const Vec3f position = origin + offset; const Vec3 position = origin + offset;
glsafe(glUniform3fv(m_uni_tool_marker_world_origin, 1, position.data())); glsafe(glUniform3fv(m_uni_tool_marker_world_origin, 1, position.data()));
glsafe(glUniform1f(m_uni_tool_marker_scale_factor, m_tool_marker_scale_factor)); glsafe(glUniform1f(m_uni_tool_marker_scale_factor, m_tool_marker_scale_factor));
glsafe(glUniformMatrix4fv(m_uni_tool_marker_view_matrix, 1, GL_FALSE, view_matrix.data())); glsafe(glUniformMatrix4fv(m_uni_tool_marker_view_matrix, 1, GL_FALSE, view_matrix.data()));
@ -1414,7 +1402,7 @@ void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& p
glsafe(glUseProgram(curr_shader)); glsafe(glUseProgram(curr_shader));
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if ENABLE_NEW_GCODE_VIEWER_DEBUG
void ViewerImpl::render_debug_window() void ViewerImpl::render_debug_window()
@ -1486,7 +1474,7 @@ void ViewerImpl::render_debug_window()
ImGui::EndTable(); ImGui::EndTable();
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTable("Cog", 2)) { if (ImGui::BeginTable("Cog", 2)) {
@ -1536,52 +1524,10 @@ void ViewerImpl::render_debug_window()
ImGui::EndTable(); ImGui::EndTable();
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
} }
imgui.end(); imgui.end();
/*
auto to_string = [](EMoveType type) {
switch (type)
{
case EMoveType::Noop: { return "Noop"; }
case EMoveType::Retract: { return "Retract"; }
case EMoveType::Unretract: { return "Unretract"; }
case EMoveType::Seam: { return "Seam"; }
case EMoveType::ToolChange: { return "ToolChange"; }
case EMoveType::ColorChange: { return "ColorChange"; }
case EMoveType::PausePrint: { return "PausePrint"; }
case EMoveType::CustomGCode: { return "CustomGCode"; }
case EMoveType::Travel: { return "Travel"; }
case EMoveType::Wipe: { return "Wipe"; }
case EMoveType::Extrude: { return "Extrude"; }
default: { return "Error"; }
}
};
imgui.begin(std::string("LibVGCode Viewer Vertices"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
if (ImGui::BeginTable("VertexData", 4)) {
uint32_t counter = 0;
for (size_t i = 0; i < m_vertices.size(); ++i) {
const PathVertex& v = m_vertices[i];
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
imgui.text_colored(m_valid_lines_bitset[i] ? Slic3r::GUI::ImGuiWrapper::COL_ORANGE_LIGHT : Slic3r::GUI::ImGuiWrapper::COL_GREY_LIGHT, std::to_string(++counter));
ImGui::TableSetColumnIndex(1);
imgui.text(to_string(v.type));
ImGui::TableSetColumnIndex(2);
imgui.text(std::to_string(m_vertices_map[i]));
ImGui::TableSetColumnIndex(3);
imgui.text(std::to_string(v.position[0]) + ", " + std::to_string(v.position[1]) + ", " + std::to_string(v.position[2]));
}
ImGui::EndTable();
}
imgui.end();
*/
} }
#endif // ENABLE_NEW_GCODE_VIEWER_DEBUG #endif // ENABLE_NEW_GCODE_VIEWER_DEBUG

View File

@ -13,10 +13,10 @@
#include "Settings.hpp" #include "Settings.hpp"
#include "SegmentTemplate.hpp" #include "SegmentTemplate.hpp"
#include "OptionTemplate.hpp" #include "OptionTemplate.hpp"
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#include "CogMarker.hpp" #include "CogMarker.hpp"
#include "ToolMarker.hpp" #include "ToolMarker.hpp"
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#include "PathVertex.hpp" #include "PathVertex.hpp"
#include "Bitset.hpp" #include "Bitset.hpp"
#include "ColorRange.hpp" #include "ColorRange.hpp"
@ -39,7 +39,7 @@ public:
ViewerImpl& operator = (ViewerImpl&& other) = delete; ViewerImpl& operator = (ViewerImpl&& other) = delete;
// //
// Initialize shader, uniform indices and segment geometry // Initialize shaders, uniform indices and segment geometry
// //
void init(); void init();
@ -55,91 +55,87 @@ public:
void load(GCodeInputData&& gcode_data); void load(GCodeInputData&& gcode_data);
// //
// Update the visibility property of toolpaths // Update the visibility property of toolpaths in dependence
// of the current settings
// //
void update_enabled_entities(); void update_enabled_entities();
// //
// Update the color of toolpaths // Update the color of toolpaths in dependence of the current
// view type and settings
// //
void update_colors(); void update_colors();
// //
// Render the toolpaths // Render the toolpaths
// //
void render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
//
// Settings getters
//
EViewType get_view_type() const; EViewType get_view_type() const;
ETimeMode get_time_mode() const;
const std::array<uint32_t, 2>& get_layers_range() const;
bool is_top_layer_only_view_range() const;
bool is_option_visible(EOptionType type) const;
bool is_extrusion_role_visible(EGCodeExtrusionRole role) const;
//
// Settings setters
//
void set_view_type(EViewType type); void set_view_type(EViewType type);
ETimeMode get_time_mode() const;
void set_time_mode(ETimeMode mode); 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(const std::array<uint32_t, 2>& range);
void set_layers_range(uint32_t min, uint32_t max); void set_layers_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); void set_top_layer_only_view_range(bool top_layer_only_view_range);
bool is_option_visible(EOptionType type) const;
void toggle_option_visibility(EOptionType type); void toggle_option_visibility(EOptionType type);
bool is_extrusion_role_visible(EGCodeExtrusionRole role) const;
void toggle_extrusion_role_visibility(EGCodeExtrusionRole role); void toggle_extrusion_role_visibility(EGCodeExtrusionRole role);
//
// View range getters
//
const std::array<uint32_t, 2>& get_view_current_range() const; const std::array<uint32_t, 2>& get_view_current_range() const;
const std::array<uint32_t, 2>& get_view_global_range() const; const std::array<uint32_t, 2>& get_view_global_range() const;
//
// View range setters
//
void set_view_current_range(uint32_t min, uint32_t max); void set_view_current_range(uint32_t min, uint32_t max);
//
// Properties getters
//
size_t get_vertices_count() const; size_t get_vertices_count() const;
PathVertex get_current_vertex() const; PathVertex get_current_vertex() const;
PathVertex get_vertex_at(size_t id) const; PathVertex get_vertex_at(size_t id) const;
size_t get_extrusion_roles_count() const; size_t get_extrusion_roles_count() const;
std::vector<EGCodeExtrusionRole> get_extrusion_roles() const; std::vector<EGCodeExtrusionRole> get_extrusion_roles() const;
float get_extrusion_role_time(EGCodeExtrusionRole role) const; float get_extrusion_role_time(EGCodeExtrusionRole role) const;
float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const; float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const;
float get_travels_time() const; float get_travels_time() const;
float get_travels_time(ETimeMode mode) const; float get_travels_time(ETimeMode mode) const;
std::vector<float> get_layers_times() const; std::vector<float> get_layers_times() const;
std::vector<float> get_layers_times(ETimeMode mode) const; std::vector<float> get_layers_times(ETimeMode mode) const;
size_t get_tool_colors_count() const; size_t get_tool_colors_count() const;
const std::vector<Color>& get_tool_colors() const; const std::vector<Color>& get_tool_colors() const;
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Vec3f get_cog_marker_position() const;
float get_cog_marker_scale_factor() const;
bool is_tool_marker_enabled() const;
const Vec3f& get_tool_marker_position() const;
float get_tool_marker_offset_z() const;
float get_tool_marker_scale_factor() const;
const Color& get_tool_marker_color() const;
float get_tool_marker_alpha() const;
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//
// Properties setters
//
void set_tool_colors(const std::vector<Color>& colors); void set_tool_colors(const std::vector<Color>& colors);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
Vec3 get_cog_marker_position() const;
float get_cog_marker_scale_factor() const;
void set_cog_marker_scale_factor(float factor); void set_cog_marker_scale_factor(float factor);
bool is_tool_marker_enabled() const;
void enable_tool_marker(bool value); void enable_tool_marker(bool value);
void set_tool_marker_position(const Vec3f& position);
const Vec3& get_tool_marker_position() const;
void set_tool_marker_position(const Vec3& position);
float get_tool_marker_offset_z() const;
void set_tool_marker_offset_z(float offset_z); void set_tool_marker_offset_z(float offset_z);
float get_tool_marker_scale_factor() const;
void set_tool_marker_scale_factor(float factor); void set_tool_marker_scale_factor(float factor);
void set_tool_marker_color(const Color& color);
const Color& get_tool_marker_color() const;
void set_tool_marker_color(const Color & color);
float get_tool_marker_alpha() const;
void set_tool_marker_alpha(float size); void set_tool_marker_alpha(float size);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
private: private:
Settings m_settings; Settings m_settings;
@ -147,7 +143,7 @@ private:
Range m_layers_range; Range m_layers_range;
ViewRange m_view_range; ViewRange m_view_range;
ExtrusionRoles m_extrusion_roles; ExtrusionRoles m_extrusion_roles;
std::array<float, static_cast<size_t>(ETimeMode::COUNT)> m_travels_time{ 0.0f, 0.0f }; std::array<float, Time_Modes_Count> m_travels_time{ 0.0f, 0.0f };
// //
// The OpenGL element used to represent all toolpath segments // The OpenGL element used to represent all toolpath segments
@ -159,7 +155,7 @@ private:
// //
OptionTemplate m_option_template; OptionTemplate m_option_template;
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// //
// The OpenGL element used to represent the center of gravity // The OpenGL element used to represent the center of gravity
// //
@ -171,7 +167,7 @@ private:
// //
ToolMarker m_tool_marker; ToolMarker m_tool_marker;
float m_tool_marker_scale_factor{ 1.0f }; float m_tool_marker_scale_factor{ 1.0f };
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// //
// cpu buffer to store vertices // cpu buffer to store vertices
@ -232,7 +228,7 @@ private:
int m_uni_options_colors_tex_id{ -1 }; int m_uni_options_colors_tex_id{ -1 };
int m_uni_options_segment_index_tex_id{ -1 }; int m_uni_options_segment_index_tex_id{ -1 };
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// //
// Cache for OpenGL uniforms id for cog marker shader // Cache for OpenGL uniforms id for cog marker shader
// //
@ -249,7 +245,7 @@ private:
int m_uni_tool_marker_view_matrix{ -1 }; int m_uni_tool_marker_view_matrix{ -1 };
int m_uni_tool_marker_projection_matrix{ -1 }; int m_uni_tool_marker_projection_matrix{ -1 };
int m_uni_tool_marker_color_base{ -1 }; int m_uni_tool_marker_color_base{ -1 };
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
// //
// gpu buffers to store positions // gpu buffers to store positions
@ -280,12 +276,12 @@ private:
void update_view_global_range(); void update_view_global_range();
void update_color_ranges(); void update_color_ranges();
Color select_color(const PathVertex& v) const; Color select_color(const PathVertex& v) const;
void render_segments(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix, const Vec3f& camera_position); void render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position);
void render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render_options(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
void render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
void render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if ENABLE_NEW_GCODE_VIEWER_DEBUG
// Debug // Debug