Add Pressure Advance visualization support (#11673)

* Add Pressure Advance visualization support

Signed-off-by: minicx <minicx@disroot.org>

* Port Pressure Advance visualization to libvgcode architecture

Adapt PA visualization (originally in commit e3a77259) to work with
the new libvgcode library introduced by upstream PR #10735.

Changes across the libvgcode stack:
- PathVertex: add pressure_advance field
- Types.hpp: add PressureAdvance to EViewType enum
- ViewerImpl: add ColorRange, color mapping, range updates for PA
- LibVGCodeWrapper: pass pressure_advance from MoveVertex to PathVertex

GCodeViewer UI integration:
- Add "Pressure Advance" to view type dropdown
- Add PA color range in legend (3 decimal places)
- Add PA value display in sequential view marker tooltip
- Add PA row in position properties table

The GCodeProcessor PA parsing (M900, M572, SET_PRESSURE_ADVANCE)
is preserved from the original implementation.

* Tag Pressure Advance visualization changes with ORCA comments

Signed-off-by: minicx <minicx@disroot.org>

---------

Signed-off-by: minicx <minicx@disroot.org>
Co-authored-by: Ioannis Giannakas <59056762+igiannakas@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
minicx
2026-02-21 16:10:08 +03:00
committed by GitHub
parent 528e7c6780
commit 7e1b2d99d3
9 changed files with 111 additions and 4 deletions

View File

@@ -1967,6 +1967,10 @@ void GCodeProcessor::register_commands()
{"M702", [this](const GCodeReader::GCodeLine& line) { process_M702(line); }}, // Unload the current filament into the MK3 MMU2 unit at the end of print.
{"M1020", [this](const GCodeReader::GCodeLine& line) { process_M1020(line); }}, // Select Tool
// ORCA: Add Pressure Advance visualization support
{"M900", [this](const GCodeReader::GCodeLine& line) { process_M900(line); }}, // Marlin: Set pressure advance
{"M572", [this](const GCodeReader::GCodeLine& line) { process_M572(line); }}, // RepRapFirmware/Duet: Set pressure advance
{"T", [this](const GCodeReader::GCodeLine& line) { process_T(line); }}, // Select Tool
{"SYNC", [this](const GCodeReader::GCodeLine& line) { process_SYNC(line); }}, // SYNC TIME
@@ -3028,6 +3032,12 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line, bool
process_SET_VELOCITY_LIMIT(line);
return;
}
// ORCA: Add Pressure Advance visualization support
if (boost::iequals(cmd, "SET_PRESSURE_ADVANCE"))
{
process_SET_PRESSURE_ADVANCE(line);
return;
}
}
if (cmd.length() > 1) {
@@ -5150,6 +5160,37 @@ void GCodeProcessor::process_M106(const GCodeReader::GCodeLine& line)
}
}
// ORCA: Add Pressure Advance visualization support
void GCodeProcessor::process_M900(const GCodeReader::GCodeLine &line)
{
float pa_value = m_pressure_advance;
line.has_value('K', pa_value);
m_pressure_advance = std::max(0.0f, pa_value);
// BOOST_LOG_TRIVIAL(debug) << "M900 command: PA set to " << m_pressure_advance;
}
void GCodeProcessor::process_M572(const GCodeReader::GCodeLine &line)
{
float pa_value = m_pressure_advance;
line.has_value('S', pa_value);
m_pressure_advance = std::max(0.0f, pa_value);
// BOOST_LOG_TRIVIAL(debug) << "M572 command: PA set to " << m_pressure_advance;
}
void GCodeProcessor::process_SET_PRESSURE_ADVANCE(const GCodeReader::GCodeLine& line)
{
std::regex regex(R"(SET_PRESSURE_ADVANCE\s+(?:.*\s+)?ADVANCE\s*=\s*([\d.]+))");
std::smatch matches;
if (std::regex_search(line.raw(), matches, regex) && matches.size() > 1) {
float pa_value = 0;
try {
pa_value = std::stof(matches[1].str());
} catch (...) {}
m_pressure_advance = std::max(0.0f, pa_value);
}
}
void GCodeProcessor::process_M107(const GCodeReader::GCodeLine& line)
{
m_fan_speed = 0.0f;
@@ -5689,6 +5730,8 @@ void GCodeProcessor::store_move_vertex(EMoveType type, EMovePathType path_type,
m_travel_dist,
m_fan_speed,
m_extruder_temps[filament_id],
// ORCA: Add Pressure Advance visualization support
m_pressure_advance,
{ 0.0f, 0.0f }, // time
static_cast<float>(m_layer_id), //layer_duration: set later
std::max<unsigned int>(1, m_layer_id) - 1,