Follow-up to 84de301:

- Fixed updating of model when printers are switched
- Fixed needless updates of model when seq printing is disabled (introduced in 8e5f5e1)
This commit is contained in:
Lukas Matena 2025-02-13 12:53:40 +01:00
parent 8180bea835
commit 075ff32718
3 changed files with 23 additions and 29 deletions

View File

@ -217,29 +217,21 @@ int GCodeViewer::SequentialView::ActualSpeedImguiWidget::plot(const char* label,
}
#endif // ENABLE_ACTUAL_SPEED_DEBUG
bool GCodeViewer::SequentialView::Marker::init(std::optional<std::unique_ptr<GLModel>>& model_opt)
{
if (! model_opt.has_value())
return false;
if (m_generic_marker != (model_opt->get() == nullptr))
m_model.reset();
m_generic_marker = (model_opt->get() == nullptr);
bool ret = false;
if (!m_model.is_initialized()) {
if (m_generic_marker)
m_model.init_from(stilized_arrow(16, 2.0f, 4.0f, 1.0f, 8.0f));
else {
m_model = **model_opt;
model_opt.reset();
}
ret = true;
}
m_model.set_color({ 1.0f, 1.0f, 1.0f, 0.5f });
return ret;
}
void GCodeViewer::SequentialView::Marker::init(std::optional<std::unique_ptr<GLModel>>& model_opt)
{
if (! model_opt.has_value())
return;
m_model.reset();
m_generic_marker = (model_opt->get() == nullptr);
if (m_generic_marker)
m_model.init_from(stilized_arrow(16, 2.0f, 4.0f, 1.0f, 8.0f));
else
m_model = **model_opt;
m_model.set_color({ 1.0f, 1.0f, 1.0f, 0.5f });
}
void GCodeViewer::SequentialView::Marker::render()
{
@ -1213,7 +1205,8 @@ void GCodeViewer::render()
// Following just makes sure that the shown marker is correct.
auto marker_model_opt = wxGetApp().plater()->get_current_canvas3D()->get_current_marker_model();
if (m_sequential_view.marker.init(marker_model_opt))
m_sequential_view.marker.init(marker_model_opt);
if (marker_model_opt.has_value())
m_max_bounding_box.reset();
m_sequential_view.render(legend_height, &m_viewer, curr_vertex.gcode_id);

View File

@ -133,7 +133,7 @@ public:
#endif // ENABLE_ACTUAL_SPEED_DEBUG
public:
bool init(std::optional<std::unique_ptr<GLModel>>& model_opt);
void init(std::optional<std::unique_ptr<GLModel>>& model_opt);
const BoundingBoxf3& get_bounding_box() const { return m_model.get_bounding_box(); }

View File

@ -177,6 +177,11 @@ std::optional<std::unique_ptr<GLModel>> GLCanvas3D::get_current_marker_model() c
bool seq = m_config->opt_bool("complete_objects");
if (last_printer_notes != printer_notes || r != old_r || h != old_h || seq != old_seq) {
last_printer_notes = printer_notes;
old_r = r;
old_h = h;
old_seq = seq;
out = std::make_optional(nullptr);
if (! seq)
return out;
@ -212,10 +217,6 @@ std::optional<std::unique_ptr<GLModel>> GLCanvas3D::get_current_marker_model() c
m->init_from(mesh);
out = std::make_optional(std::move(m));
}
last_printer_notes = printer_notes;
old_r = r;
old_h = h;
old_seq = seq;
}
return out;
}