Use frontend data to update labels

This commit is contained in:
Enrico Turri 2020-02-06 15:19:53 +01:00
parent 3981e25f75
commit c6ca180142
3 changed files with 10 additions and 10 deletions

View file

@ -1238,7 +1238,7 @@ void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
}
#if ENABLE_SHOW_SCENE_LABELS
void GLCanvas3D::Labels::render(const std::vector<const PrintInstance*>& sorted_instances) const
void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_instances) const
{
if (!m_enabled || !is_shown())
return;
@ -1298,7 +1298,7 @@ void GLCanvas3D::Labels::render(const std::vector<const PrintInstance*>& sorted_
// updates print order strings
if (sorted_instances.size() > 1) {
for (int i = 0; i < sorted_instances.size(); ++i) {
size_t id = sorted_instances[i]->model_instance->id().id;
size_t id = sorted_instances[i]->id().id;
std::vector<Owner>::iterator it = std::find_if(owners.begin(), owners.end(), [id](const Owner& owner) {
return owner.model_instance_id == id;
});
@ -5101,11 +5101,12 @@ void GLCanvas3D::_render_overlays() const
#if ENABLE_SHOW_SCENE_LABELS
const ConfigOptionBool* opt = dynamic_cast<const ConfigOptionBool*>(m_config->option("complete_objects"));
bool sequential_print = (opt != nullptr) ? m_config->opt_bool("complete_objects") : false;
std::vector<const PrintInstance*> sorted_instances;
std::vector<const ModelInstance*> sorted_instances;
if (sequential_print) {
const Print* print = fff_print();
if (print != nullptr)
sorted_instances = sort_object_instances_by_model_order(*print);
for (ModelObject* model_object : m_model->objects)
for (ModelInstance* model_instance : model_object->instances) {
sorted_instances.push_back(model_instance);
}
}
m_labels.render(sorted_instances);
#endif // ENABLE_SHOW_SCENE_LABELS

View file

@ -40,9 +40,6 @@ class GCodePreviewData;
struct ThumbnailData;
#endif // ENABLE_THUMBNAIL_GENERATOR
struct SlicingParameters;
#if ENABLE_SHOW_SCENE_LABELS
struct PrintInstance;
#endif // ENABLE_SHOW_SCENE_LABELS
enum LayerHeightEditActionType : unsigned int;
namespace GUI {
@ -390,7 +387,7 @@ private:
void enable(bool enable) { m_enabled = enable; }
void show(bool show) { m_shown = m_enabled ? show : false; }
bool is_shown() const { return m_shown; }
void render(const std::vector<const PrintInstance*>& sorted_instances) const;
void render(const std::vector<const ModelInstance*>& sorted_instances) const;
};
#endif // ENABLE_SHOW_SCENE_LABELS

View file

@ -1134,6 +1134,8 @@ void ObjectList::OnDrop(wxDataViewEvent &event)
changed_object(m_dragged_data.obj_idx());
m_dragged_data.clear();
wxGetApp().plater()->set_current_canvas_as_dirty();
}