SLA slices preview - wip 2
This commit is contained in:
parent
a4e204012d
commit
b153c8cb20
4 changed files with 49 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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<double>& 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<double>& layers_z, bool force_sliders_full_range)
|
||||
{
|
||||
std::vector<std::pair<int, double>> values;
|
||||
std::vector<double> 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<float> 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<double> layer_zs;
|
||||
std::copy(zs.begin(), zs.end(), std::back_inserter(layer_zs));
|
||||
update_sliders(layer_zs);
|
||||
}
|
||||
|
||||
m_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -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<double>& 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<std::pair<int, double>> &values,
|
||||
void update_double_slider(const std::vector<double>& layers_z, bool force_sliders_full_range);
|
||||
void fill_slider_values(std::vector<std::pair<int, double>> &values,
|
||||
const std::vector<double> &layers_z);
|
||||
void set_double_slider_thumbs( const bool force_sliders_full_range,
|
||||
const std::vector<double> &layers_z,
|
||||
|
|
Loading…
Reference in a new issue