Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_canvas_gui_refactoring

This commit is contained in:
Enrico Turri 2019-03-19 08:25:50 +01:00
commit c0a2360c46
7 changed files with 39 additions and 12 deletions

View File

@ -1466,7 +1466,7 @@ public:
m_cfg.head_back_radius_mm, m_cfg.head_back_radius_mm,
w); w);
if(t <= w || (hp(Z) + nn(Z) * w) < m_result.ground_level) { if(t <= w) {
// Let's try to optimize this angle, there might be a // Let's try to optimize this angle, there might be a
// viable normal that doesn't collide with the model // viable normal that doesn't collide with the model
@ -1509,7 +1509,7 @@ public:
// save the verified and corrected normal // save the verified and corrected normal
m_support_nmls.row(fidx) = nn; m_support_nmls.row(fidx) = nn;
if(t > w && (hp(Z) + nn(Z) * w) > m_result.ground_level) { if(t > w) {
// mark the point for needing a head. // mark the point for needing a head.
m_iheads.emplace_back(fidx); m_iheads.emplace_back(fidx);
} else if( polar >= 3*PI/4 ) { } else if( polar >= 3*PI/4 ) {

View File

@ -571,7 +571,24 @@ void swapXY(ExPolygon& expoly) {
for(auto& p : expoly.contour.points) std::swap(p(X), p(Y)); for(auto& p : expoly.contour.points) std::swap(p(X), p(Y));
for(auto& h : expoly.holes) for(auto& p : h.points) std::swap(p(X), p(Y)); for(auto& h : expoly.holes) for(auto& p : h.points) std::swap(p(X), p(Y));
} }
}
std::string SLAPrint::validate() const
{
for(SLAPrintObject * po : m_objects) {
sla::SupportConfig cfg = make_support_cfg(po->config());
double pinhead_width =
2 * cfg.head_front_radius_mm +
cfg.head_width_mm +
2 * cfg.head_back_radius_mm -
cfg.head_penetration_mm;
if(pinhead_width > cfg.object_elevation_mm)
return L("Elevetion is too low for object.");
}
return "";
} }
std::vector<float> SLAPrint::calculate_heights(const BoundingBoxf3& bb3d, std::vector<float> SLAPrint::calculate_heights(const BoundingBoxf3& bb3d,

View File

@ -240,6 +240,8 @@ public:
const SLAPrintStatistics& print_statistics() const { return m_print_statistics; } const SLAPrintStatistics& print_statistics() const { return m_print_statistics; }
std::string validate() const override;
private: private:
using SLAPrinter = FilePrinter<FilePrinterFormat::SLA_PNGZIP>; using SLAPrinter = FilePrinter<FilePrinterFormat::SLA_PNGZIP>;
using SLAPrinterPtr = std::unique_ptr<SLAPrinter>; using SLAPrinterPtr = std::unique_ptr<SLAPrinter>;

View File

@ -2022,6 +2022,8 @@ void ObjectList::update_selections_on_canvas()
void ObjectList::select_item(const wxDataViewItem& item) void ObjectList::select_item(const wxDataViewItem& item)
{ {
if (! item.IsOk()) { return; }
m_prevent_list_events = true; m_prevent_list_events = true;
UnselectAll(); UnselectAll();

View File

@ -192,6 +192,7 @@ Preview::Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_t
, m_loaded(false) , m_loaded(false)
, m_enabled(false) , m_enabled(false)
, m_schedule_background_process(schedule_background_process_func) , m_schedule_background_process(schedule_background_process_func)
, m_volumes_cleanup_required(false)
{ {
if (init(parent, bed, camera, view_toolbar)) if (init(parent, bed, camera, view_toolbar))
{ {
@ -369,16 +370,20 @@ void Preview::load_print()
load_print_as_sla(); load_print_as_sla();
} }
void Preview::reload_print(bool force, bool keep_volumes) void Preview::reload_print(bool keep_volumes)
{ {
if (!IsShown() && !force) if (!IsShown())
{
m_volumes_cleanup_required = !keep_volumes;
return; return;
}
if (!keep_volumes) if (m_volumes_cleanup_required || !keep_volumes)
{ {
m_canvas->reset_volumes(); m_canvas->reset_volumes();
m_canvas->reset_legend_texture(); m_canvas->reset_legend_texture();
m_loaded = false; m_loaded = false;
m_volumes_cleanup_required = false;
} }
load_print(); load_print();
@ -560,15 +565,14 @@ static int find_close_layer_idx(const std::vector<double>& zs, double &z, double
return -1; return -1;
} }
void Preview::update_double_slider(const std::vector<double>& layers_z, bool force_sliders_full_range) void Preview::update_double_slider(const std::vector<double>& layers_z)
{ {
// Save the initial slider span. // Save the initial slider span.
double z_low = m_slider->GetLowerValueD(); double z_low = m_slider->GetLowerValueD();
double z_high = m_slider->GetHigherValueD(); double z_high = m_slider->GetHigherValueD();
bool was_empty = m_slider->GetMaxValue() == 0; bool was_empty = m_slider->GetMaxValue() == 0;
bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > 1e-6; bool force_sliders_full_range = was_empty;
force_sliders_full_range |= was_empty | span_changed; bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min();
bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min();
bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max(); bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max();
std::vector<std::pair<int, double>> values; std::vector<std::pair<int, double>> values;

View File

@ -92,6 +92,8 @@ class Preview : public wxPanel
BackgroundSlicingProcess* m_process; BackgroundSlicingProcess* m_process;
GCodePreviewData* m_gcode_preview_data; GCodePreviewData* m_gcode_preview_data;
bool m_volumes_cleanup_required;
// Calling this function object forces Plater::schedule_background_process. // Calling this function object forces Plater::schedule_background_process.
std::function<void()> m_schedule_background_process; std::function<void()> m_schedule_background_process;
@ -118,7 +120,7 @@ public:
void set_drop_target(wxDropTarget* target); void set_drop_target(wxDropTarget* target);
void load_print(); void load_print();
void reload_print(bool force = false, bool keep_volumes = false); void reload_print(bool keep_volumes = false);
void refresh_print(); void refresh_print();
private: private:
@ -142,7 +144,7 @@ private:
// Create/Update/Reset double slider on 3dPreview // Create/Update/Reset double slider on 3dPreview
void create_double_slider(); void create_double_slider();
void update_double_slider(const std::vector<double>& layers_z, bool force_sliders_full_range = false); void update_double_slider(const std::vector<double>& layers_z);
void fill_slider_values(std::vector<std::pair<int, double>> &values, void fill_slider_values(std::vector<std::pair<int, double>> &values,
const std::vector<double> &layers_z); const std::vector<double> &layers_z);
void reset_double_slider(); void reset_double_slider();

View File

@ -2449,7 +2449,7 @@ void Plater::priv::set_current_panel(wxPanel* panel)
{ {
this->q->reslice(); this->q->reslice();
// keeps current gcode preview, if any // keeps current gcode preview, if any
preview->reload_print(false, true); preview->reload_print(true);
preview->set_canvas_as_dirty(); preview->set_canvas_as_dirty();
view_toolbar.select_item("Preview"); view_toolbar.select_item("Preview");
} }