ENH: global_endpoints should not include seam

This is fix for jira STUDIO-1501

Global_endpoints should not include seam vertex.
So the initial value should be gcode_ids.size(),
rather than m_move_vertex

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: Id4162e63640509521cc7c76bc0d860f27e0c316e
This commit is contained in:
salt.wei 2023-01-09 18:31:40 +08:00 committed by Lane.Wei
parent 534dcf11c1
commit 3291a452da
2 changed files with 12 additions and 21 deletions

View file

@ -699,10 +699,9 @@ void GCodeViewer::SequentialView::GCodeWindow::stop_mapping_file()
} }
} }
//BBS: GUI refactor: move to the right //BBS: GUI refactor: move to the right
void GCodeViewer::SequentialView::render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, const EViewType& view_type, const std::vector<GCodeProcessorResult::MoveVertex>& moves) const void GCodeViewer::SequentialView::render(float legend_height, int canvas_width, int canvas_height, const EViewType& view_type, const std::vector<GCodeProcessorResult::MoveVertex>& moves) const
{ {
if (has_render_path) marker.render(canvas_width, canvas_height, view_type, moves, static_cast<uint64_t>(gcode_ids[current.last]));
marker.render(canvas_width, canvas_height, view_type, moves, static_cast<uint64_t>(gcode_ids[current.last]));
//float bottom = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size().get_height(); //float bottom = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size().get_height();
// BBS // BBS
#if 0 #if 0
@ -711,8 +710,7 @@ void GCodeViewer::SequentialView::render(const bool has_render_path, float legen
#endif #endif
//gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last])); //gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last]));
if (wxGetApp().get_mode() == ConfigOptionMode::comDevelop) { if (wxGetApp().get_mode() == ConfigOptionMode::comDevelop) {
if (has_render_path) gcode_window.render(legend_height, (float)canvas_height, (float)canvas_width, static_cast<uint64_t>(gcode_ids[current.last]));
gcode_window.render(legend_height, (float)canvas_height, (float)canvas_width, static_cast<uint64_t>(gcode_ids[current.last]));
} }
} }
@ -1282,13 +1280,12 @@ void GCodeViewer::render(int canvas_width, int canvas_height, int right_margin)
//BBS fixed bottom_margin for space to render horiz slider //BBS fixed bottom_margin for space to render horiz slider
int bottom_margin = 64; int bottom_margin = 64;
//BBS always render the hotend-marker if (m_sequential_view.current.last != m_sequential_view.endpoints.last) {
//if (m_sequential_view.current.last != m_sequential_view.endpoints.last && !m_no_render_path) {
m_sequential_view.marker.set_world_position(m_sequential_view.current_position); m_sequential_view.marker.set_world_position(m_sequential_view.current_position);
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset); m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
//BBS fixed buttom margin. m_moves_slider.pos_y //BBS fixed buttom margin. m_moves_slider.pos_y
m_sequential_view.render(!m_no_render_path, legend_height, canvas_width - right_margin * m_scale, canvas_height - bottom_margin * m_scale, m_view_type, m_gcode_result->moves); m_sequential_view.render(legend_height, canvas_width - right_margin * m_scale, canvas_height - bottom_margin * m_scale, m_view_type, m_gcode_result->moves);
//} }
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
render_statistics(); render_statistics();
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
@ -3311,11 +3308,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
const bool top_layer_only = true; const bool top_layer_only = true;
SequentialView::Endpoints global_endpoints = { m_moves_count , 0 }; //BBS
SequentialView::Endpoints global_endpoints = { m_sequential_view.gcode_ids.size() , 0 };
SequentialView::Endpoints top_layer_endpoints = global_endpoints; SequentialView::Endpoints top_layer_endpoints = global_endpoints;
SequentialView* sequential_view = const_cast<SequentialView*>(&m_sequential_view); SequentialView* sequential_view = const_cast<SequentialView*>(&m_sequential_view);
if (top_layer_only || !keep_sequential_current_first) sequential_view->current.first = 0; if (top_layer_only || !keep_sequential_current_first) sequential_view->current.first = 0;
if (!keep_sequential_current_last) sequential_view->current.last = m_moves_count; //BBS
if (!keep_sequential_current_last) sequential_view->current.last = m_sequential_view.gcode_ids.size();
// first pass: collect visible paths and update sequential view data // first pass: collect visible paths and update sequential view data
std::vector<std::tuple<unsigned char, unsigned int, unsigned int, unsigned int>> paths; std::vector<std::tuple<unsigned char, unsigned int, unsigned int, unsigned int>> paths;
@ -3389,15 +3388,9 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
// update current sequential position // update current sequential position
sequential_view->current.first = !top_layer_only && keep_sequential_current_first ? std::clamp(sequential_view->current.first, global_endpoints.first, global_endpoints.last) : global_endpoints.first; sequential_view->current.first = !top_layer_only && keep_sequential_current_first ? std::clamp(sequential_view->current.first, global_endpoints.first, global_endpoints.last) : global_endpoints.first;
if (global_endpoints.last == 0) { if (global_endpoints.last == 0) {
m_no_render_path = true; sequential_view->current.last = global_endpoints.last;
} else { } else {
m_no_render_path = false;
}
if (!m_no_render_path) {
sequential_view->current.last = keep_sequential_current_last ? std::clamp(sequential_view->current.last, global_endpoints.first, global_endpoints.last) : global_endpoints.last; sequential_view->current.last = keep_sequential_current_last ? std::clamp(sequential_view->current.last, global_endpoints.first, global_endpoints.last) : global_endpoints.last;
} else {
sequential_view->current.last = sequential_view->current.first;
} }
// get the world position from the vertex buffer // get the world position from the vertex buffer
@ -5290,7 +5283,6 @@ void GCodeViewer::pop_combo_style()
} }
void GCodeViewer::render_slider(int canvas_width, int canvas_height) { void GCodeViewer::render_slider(int canvas_width, int canvas_height) {
m_moves_slider->render(canvas_width, canvas_height); m_moves_slider->render(canvas_width, canvas_height);
m_layers_slider->render(canvas_width, canvas_height); m_layers_slider->render(canvas_width, canvas_height);
} }

View file

@ -698,7 +698,7 @@ public:
float m_scale = 1.0; float m_scale = 1.0;
//BBS: GUI refactor: add canvas size //BBS: GUI refactor: add canvas size
void render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, const EViewType& view_type, const std::vector<GCodeProcessorResult::MoveVertex>& moves) const; void render(float legend_height, int canvas_width, int canvas_height, const EViewType& view_type, const std::vector<GCodeProcessorResult::MoveVertex>& moves) const;
}; };
struct ETools struct ETools
@ -781,7 +781,6 @@ private:
std::vector<CustomGCode::Item> m_custom_gcode_per_print_z; std::vector<CustomGCode::Item> m_custom_gcode_per_print_z;
bool m_contained_in_bed{ true }; bool m_contained_in_bed{ true };
mutable bool m_no_render_path { false };
bool m_is_dark = false; bool m_is_dark = false;
public: public: