From 166a46caa8157e246adfeec591dc13383a47b252 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Wed, 16 Oct 2024 10:38:52 +0800 Subject: [PATCH] NEW:add "slice error" for double extruder jira: none Change-Id: I58e86c33bc91456d42efcc1a0cad003432bb13df --- src/slic3r/GUI/3DScene.cpp | 4 +++- src/slic3r/GUI/3DScene.hpp | 2 ++ src/slic3r/GUI/GCodeViewer.hpp | 24 ++++++++++++------------ src/slic3r/GUI/GLCanvas3D.cpp | 21 ++++++++++++++++++++- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 083ef01b0..2d0dd659d 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -495,6 +495,7 @@ GLVolume::GLVolume(float r, float g, float b, float a, bool create_index_data) , partly_inside(false) , hover(HS_None) , is_modifier(false) + , slice_error(false) , is_wipe_tower(false) , is_extrusion_path(false) , force_transparent(false) @@ -1652,7 +1653,8 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, glcheck(); //BBS: add outline related logic - volume.first->render(with_outline && volume.first->selected, body_color); + auto red_color = std::array({1.0f, 0.0f, 0.0f, 1.0f});//slice_error + volume.first->render(with_outline && volume.first->selected, volume.first->slice_error ? red_color : body_color); #if ENABLE_ENVIRONMENT_MAP if (use_environment_texture) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 4f96c05c0..cf51901ec 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -448,6 +448,8 @@ public: bool force_neutral_color : 1; // Whether or not to force rendering of sinking contours bool force_sinking_contours : 1; + // slice error + bool slice_error : 1; }; // Is mouse or rectangle selection over this object to select/deselect it ? diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index f36d3f12c..f69b7b5dc 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -380,16 +380,6 @@ class GCodeViewer } }; - // helper to render shells - struct Shells - { - GLVolumeCollection volumes; - bool visible{ false }; - //BBS: always load shell when preview - int print_id{ -1 }; - int print_modify_count { -1 }; - bool previewing{ false }; - }; // helper to render extrusion paths struct Extrusions @@ -743,11 +733,21 @@ public: LayerTime, Count }; - + // helper to render shells + struct Shells + { + GLVolumeCollection volumes; + bool visible{false}; + // BBS: always load shell when preview + int print_id{-1}; + int print_modify_count{-1}; + bool previewing{false}; + }; //BBS ConflictResultOpt m_conflict_result; GCodeCheckResult m_gcode_check_result; FilamentPrintableResult filament_printable_reuslt; + Shells m_shells; private: std::vector m_plater_extruder; @@ -790,7 +790,7 @@ private: SequentialView m_sequential_view; IMSlider* m_moves_slider; IMSlider* m_layers_slider; - Shells m_shells; + /*BBS GUI refactor, store displayed items in color scheme combobox */ std::vector view_type_items; std::vector view_type_items_str; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4cb5c0c93..b0ca3b0c3 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -9678,15 +9678,34 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) } int extruder_id = error_iter->first + 1; std::string filaments; + std::vector slice_error_object_idxs; for (size_t i = 0; i < error_iter->second.size(); ++i) { if (i > 0) { filaments += ", "; } int filament_id = error_iter->second[i].first; int object_label_id = error_iter->second[i].second; - // todo: display the conflict objects + //ModelObject* object->instances[0]->get_labeled_id(); filaments += std::to_string(filament_id); + for (int object_idx = 0; object_idx < (int) m_model->objects.size(); ++object_idx) { + const ModelObject *model_object = m_model->objects[object_idx]; + for (int instance_idx = 0; instance_idx < (int) model_object->instances.size(); ++instance_idx) { + const ModelInstance *model_instance = model_object->instances[instance_idx]; + auto expect_id = model_instance->get_labeled_id(); + if (object_label_id == expect_id) { + slice_error_object_idxs.emplace_back(object_idx); + } + } + } + } + for (GLVolume *volume : m_gcode_viewer.m_shells.volumes.volumes) { + for (auto obj_idx : slice_error_object_idxs) { + if (volume->object_idx() == obj_idx) { + volume->slice_error = true; + volume->selected = true; + } + } } std::string extruder_name = extruder_id == master_extruder_id ? "Left extruder" : "Right extruder"; if (error_iter->second.size() == 1) {