Merge remote-tracking branch 'origin/et_fix_options_z'
This commit is contained in:
commit
3e0b7910ea
4 changed files with 72 additions and 1 deletions
|
@ -828,6 +828,9 @@ bool GCodeProcessor::contains_reserved_tags(const std::string& gcode, unsigned i
|
|||
}
|
||||
|
||||
GCodeProcessor::GCodeProcessor()
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
: m_options_z_corrector(m_result)
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
{
|
||||
reset();
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_main_mask = "M73 P%s R%s\n";
|
||||
|
@ -1201,6 +1204,10 @@ void GCodeProcessor::reset()
|
|||
m_last_default_color_id = 0;
|
||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
m_options_z_corrector.reset();
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
m_mm3_per_mm_compare.reset();
|
||||
m_height_compare.reset();
|
||||
|
@ -1806,6 +1813,9 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
|||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
CustomGCode::Item item = { static_cast<double>(m_end_position[2]), CustomGCode::ColorChange, extruder_id + 1, color, "" };
|
||||
m_result.custom_gcode_per_print_z.emplace_back(item);
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
m_options_z_corrector.set();
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
process_custom_gcode_time(CustomGCode::ColorChange);
|
||||
process_filaments(CustomGCode::ColorChange);
|
||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
|
@ -1825,6 +1835,9 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
|||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
CustomGCode::Item item = { static_cast<double>(m_end_position[2]), CustomGCode::PausePrint, m_extruder_id + 1, "", "" };
|
||||
m_result.custom_gcode_per_print_z.emplace_back(item);
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
m_options_z_corrector.set();
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
process_custom_gcode_time(CustomGCode::PausePrint);
|
||||
return;
|
||||
|
@ -1836,6 +1849,9 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
|||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
CustomGCode::Item item = { static_cast<double>(m_end_position[2]), CustomGCode::Custom, m_extruder_id + 1, "", "" };
|
||||
m_result.custom_gcode_per_print_z.emplace_back(item);
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
m_options_z_corrector.set();
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
return;
|
||||
}
|
||||
|
@ -2416,7 +2432,9 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
else {
|
||||
if (m_end_position[Z] > m_extruded_last_z + EPSILON) {
|
||||
m_height = m_end_position[Z] - m_extruded_last_z;
|
||||
#if !ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
m_extruded_last_z = m_end_position[Z];
|
||||
#endif // !ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2426,6 +2444,11 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
if (m_end_position[Z] == 0.0f)
|
||||
m_end_position[Z] = m_height;
|
||||
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
m_extruded_last_z = m_end_position[Z];
|
||||
m_options_z_corrector.update(m_height);
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
m_height_compare.update(m_height, m_extrusion_role);
|
||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
|
|
|
@ -390,6 +390,45 @@ namespace Slic3r {
|
|||
bool has_first_vertex() const { return m_first_vertex.has_value(); }
|
||||
};
|
||||
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
// Helper class used to fix the z for color change, pause print and
|
||||
// custom gcode markes
|
||||
class OptionsZCorrector
|
||||
{
|
||||
Result& m_result;
|
||||
std::optional<size_t> m_move_id;
|
||||
std::optional<size_t> m_custom_gcode_per_print_z_id;
|
||||
|
||||
public:
|
||||
explicit OptionsZCorrector(Result& result) : m_result(result) {
|
||||
}
|
||||
|
||||
void set() {
|
||||
m_move_id = m_result.moves.size() - 1;
|
||||
m_custom_gcode_per_print_z_id = m_result.custom_gcode_per_print_z.size() - 1;
|
||||
}
|
||||
|
||||
void update(float height) {
|
||||
if (!m_move_id.has_value() || !m_custom_gcode_per_print_z_id.has_value())
|
||||
return;
|
||||
|
||||
const Vec3f position = m_result.moves.back().position;
|
||||
|
||||
MoveVertex& move = m_result.moves.emplace_back(m_result.moves[*m_move_id]);
|
||||
move.position = position;
|
||||
move.height = height;
|
||||
m_result.moves.erase(m_result.moves.begin() + *m_move_id);
|
||||
m_result.custom_gcode_per_print_z[*m_custom_gcode_per_print_z_id].print_z = position.z();
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
m_move_id.reset();
|
||||
m_custom_gcode_per_print_z_id.reset();
|
||||
}
|
||||
};
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
struct DataChecker
|
||||
{
|
||||
|
@ -494,6 +533,9 @@ namespace Slic3r {
|
|||
CpColor m_cp_color;
|
||||
bool m_use_volumetric_e;
|
||||
SeamsDetector m_seams_detector;
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
OptionsZCorrector m_options_z_corrector;
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
size_t m_last_default_color_id;
|
||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
|
||||
// Enable rendering seams (and other options) in preview using batched models on systems not supporting OpenGL 3.3
|
||||
#define ENABLE_SEAMS_USING_BATCHED_MODELS (1 && ENABLE_SEAMS_USING_MODELS && ENABLE_2_4_0_ALPHA2)
|
||||
// Enable fixing the z position of color change, pause print and custom gcode markers in preview
|
||||
#define ENABLE_FIX_PREVIEW_OPTIONS_Z (1 && ENABLE_SEAMS_USING_MODELS && ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER && ENABLE_2_4_0_ALPHA2)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
|
@ -2525,7 +2525,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
if (m_sequential_view.current.first <= buffer.model.instances.s_ids.back() && buffer.model.instances.s_ids.front() <= m_sequential_view.current.last) {
|
||||
for (size_t id : buffer.model.instances.s_ids) {
|
||||
if (has_second_range) {
|
||||
#if ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
if (id < m_sequential_view.endpoints.first) {
|
||||
#else
|
||||
if (id <= m_sequential_view.endpoints.first) {
|
||||
#endif // ENABLE_FIX_PREVIEW_OPTIONS_Z
|
||||
++buffer.model.instances.render_ranges.ranges.front().offset;
|
||||
if (id <= m_sequential_view.current.first)
|
||||
++buffer.model.instances.render_ranges.ranges.back().offset;
|
||||
|
@ -3041,7 +3045,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
|
||||
auto append_item = [this, icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const Color& color, const std::string& label,
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const Color& color, const std::string& label,
|
||||
bool visible = true, const std::string& time = "", float percent = 0.0f, float max_percent = 0.0f, const std::array<float, 4>& offsets = { 0.0f, 0.0f, 0.0f, 0.0f },
|
||||
double used_filament_m = 0.0, double used_filament_g = 0.0,
|
||||
std::function<void()> callback = nullptr) {
|
||||
|
|
Loading…
Add table
Reference in a new issue