diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index 88b207d82f..c29c4d1cc8 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -93,7 +93,7 @@ public: // to the z coordinate of the object coordinate system. struct SliceRecord { using Key = long long; - inline static float scale_back(Key h) { return float(scale_(h)); } + inline static float scale_back(Key h) { return float(h * SCALING_FACTOR); } using Idx = size_t; static const Idx NONE = Idx(-1); // this will be the max limit of size_t diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 62e996ba14..42df2f4213 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -7003,7 +7003,7 @@ void GLCanvas3D::_load_shells_sla() unsigned int partial_volumes_count = (unsigned int)m_volumes.volumes.size(); // add supports - if (obj->is_step_done(slaposSupportTree)) + if (obj->is_step_done(slaposSupportTree) && obj->has_mesh(slaposSupportTree)) { const TriangleMesh& mesh = obj->support_mesh(); m_volumes.volumes.emplace_back(new GLVolume(GLVolume::SLA_SUPPORT_COLOR)); @@ -7021,7 +7021,7 @@ void GLCanvas3D::_load_shells_sla() } // add pad - if (obj->is_step_done(slaposBasePool)) + if (obj->is_step_done(slaposBasePool) && obj->has_mesh(slaposBasePool)) { const TriangleMesh& mesh = obj->pad_mesh(); m_volumes.volumes.emplace_back(new GLVolume(GLVolume::SLA_PAD_COLOR)); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 5b0153c20e..cae7440f68 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -22,6 +22,7 @@ // this include must follow the wxWidgets ones or it won't compile on Windows -> see http://trac.wxwidgets.org/ticket/2421 #include "libslic3r/Print.hpp" +#include "libslic3r/SLAPrint.hpp" namespace Slic3r { namespace GUI { @@ -326,10 +327,10 @@ void Preview::reset_sliders() m_double_slider_sizer->Hide((size_t)0); } -void Preview::update_sliders() +void Preview::update_sliders(const std::vector& layers_z) { m_enabled = true; - update_double_slider(m_force_sliders_full_range); + update_double_slider(layers_z, m_force_sliders_full_range); m_double_slider_sizer->Show((size_t)0); Layout(); } @@ -402,10 +403,9 @@ void Preview::create_double_slider() }); } -void Preview::update_double_slider(bool force_sliders_full_range) +void Preview::update_double_slider(const std::vector& layers_z, bool force_sliders_full_range) { std::vector> values; - std::vector layers_z = m_canvas->get_current_print_zs(true); fill_slider_values(values, layers_z); const double z_low = m_slider->GetLowerValueD(); @@ -606,7 +606,7 @@ void Preview::load_print_as_fff() } if (n_layers > 0) - update_sliders(); + update_sliders(m_canvas->get_current_print_zs(true)); m_loaded = true; } @@ -617,9 +617,44 @@ void Preview::load_print_as_sla() if (m_loaded || (m_process->current_printer_technology() != ptSLA)) return; - std::cout << "Preview::load_print_as_sla()" << std::endl; - m_canvas->load_sla_preview(); - show_hide_ui_elements("none"); + unsigned int n_layers = 0; + const SLAPrint* print = m_process->sla_print(); + + std::set zs; + for (const SLAPrintObject* obj : print->objects()) + { + if (obj->is_step_done(slaposIndexSlices)) + { + const SLAPrintObject::SliceIndex& index = obj->get_slice_index(); + for (const SLAPrintObject::SliceIndex::value_type& id : index) + { + zs.insert(id.second.scale_back(id.first)); + } + } + } + + n_layers = (unsigned int)zs.size(); + if (n_layers == 0) + { + reset_sliders(); + m_canvas_widget->Refresh(); + } + + if (IsShown()) + { + std::cout << "Preview::load_print_as_sla()" << std::endl; + m_canvas->load_sla_preview(); + show_hide_ui_elements("none"); + + if (n_layers > 0) + { + std::vector layer_zs; + std::copy(zs.begin(), zs.end(), std::back_inserter(layer_zs)); + update_sliders(layer_zs); + } + + m_loaded = true; + } } } // namespace GUI diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 9a175205cb..902ead38d4 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -85,7 +85,7 @@ private: void show_hide_ui_elements(const std::string& what); void reset_sliders(); - void update_sliders(); + void update_sliders(const std::vector& layers_z); void on_size(wxSizeEvent& evt); void on_choice_view_type(wxCommandEvent& evt); @@ -97,8 +97,8 @@ private: // Create/Update/Reset double slider on 3dPreview void create_double_slider(); - void update_double_slider(bool force_sliders_full_range); - void fill_slider_values(std::vector> &values, + void update_double_slider(const std::vector& layers_z, bool force_sliders_full_range); + void fill_slider_values(std::vector> &values, const std::vector &layers_z); void set_double_slider_thumbs( const bool force_sliders_full_range, const std::vector &layers_z,