diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 7ae6f5cb6..41307bad9 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -671,6 +671,7 @@ public: #if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER std::vector& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; } + size_t get_extruders_count() { return m_extruders_count; } #endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER private: diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 609c903fa..b46778c39 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -636,6 +636,7 @@ public: void set_toolpaths_z_range(const std::array& range); #if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER std::vector& get_custom_gcode_per_print_z() { return m_gcode_viewer.get_custom_gcode_per_print_z(); } + size_t get_gcode_extruders_count() { return m_gcode_viewer.get_extruders_count(); } #endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER std::vector load_object(const ModelObject& model_object, int obj_idx, std::vector instance_idxs); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 91964b648..3f4537af6 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -935,9 +935,9 @@ void Preview::load_print_as_fff(bool keep_z_range) color_print_values.clear(); } - if (IsShown()) { - std::vector zs; + std::vector zs; + if (IsShown()) { m_canvas->set_selected_extruder(0); if (gcode_preview_data_valid) { // Load the real G-code preview. @@ -948,7 +948,12 @@ void Preview::load_print_as_fff(bool keep_z_range) Refresh(); zs = m_canvas->get_gcode_layers_zs(); m_loaded = true; - } else { + } +#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER + else if (wxGetApp().is_editor()) { +#else + else { +#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER // Load the initial preview based on slices, not the final G-code. m_canvas->load_preview(colors, color_print_values); m_left_sizer->Hide(m_bottom_toolbar_panel); @@ -956,6 +961,33 @@ void Preview::load_print_as_fff(bool keep_z_range) Refresh(); zs = m_canvas->get_volumes_print_zs(true); } + +#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER + if (!zs.empty() && !m_keep_current_preview_type) { + unsigned int number_extruders = wxGetApp().is_editor() ? + (unsigned int)print->extruders().size() : + m_canvas->get_gcode_extruders_count(); + std::vector gcodes = wxGetApp().is_editor() ? + wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : + m_canvas->get_custom_gcode_per_print_z(); + const wxString choice = !gcodes.empty() ? + _L("Color Print") : + (number_extruders > 1) ? _L("Tool") : _L("Feature type"); + + int type = m_choice_view_type->FindString(choice); + if (m_choice_view_type->GetSelection() != type) { + if (0 <= type && type < static_cast(GCodeViewer::EViewType::Count)) { + m_choice_view_type->SetSelection(type); + m_canvas->set_gcode_view_preview_type(static_cast(type)); + if (wxGetApp().is_gcode_viewer()) { + m_keep_current_preview_type = true; + refresh_print(); + } + } + } + } +#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER + if (zs.empty()) { // all layers filtered out hide_layers_slider(); @@ -964,35 +996,22 @@ void Preview::load_print_as_fff(bool keep_z_range) update_layers_slider(zs, keep_z_range); } +#if !ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER if (!m_keep_current_preview_type) { unsigned int number_extruders = (unsigned int)print->extruders().size(); -#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER - std::vector gcodes = wxGetApp().is_editor() ? - wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : - m_canvas->get_custom_gcode_per_print_z(); - const wxString choice = !gcodes.empty() ? - _L("Color Print") : - (number_extruders > 1) ? _L("Tool") : _L("Feature type"); -#else const wxString choice = !wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes.empty() ? _L("Color Print") : (number_extruders > 1) ? _L("Tool") : _L("Feature type"); -#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER int type = m_choice_view_type->FindString(choice); if (m_choice_view_type->GetSelection() != type) { if (0 <= type && type < static_cast(GCodeViewer::EViewType::Count)) { m_choice_view_type->SetSelection(type); m_canvas->set_gcode_view_preview_type(static_cast(type)); -#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER - if (wxGetApp().is_gcode_viewer()) { - m_keep_current_preview_type = true; - refresh_print(); - } -#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER } } } +#endif // !ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER } void Preview::load_print_as_sla()