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

This commit is contained in:
Enrico Turri 2019-03-19 10:48:51 +01:00
commit 5bb89f4da2
3 changed files with 21 additions and 13 deletions

View File

@ -1696,8 +1696,11 @@ void GLCanvas3D::Selection::render_sidebar_hints(const std::string& sidebar_fiel
} }
else if (is_single_volume() || is_single_modifier()) else if (is_single_volume() || is_single_modifier())
{ {
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true) * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true);
::glTranslated(center(0), center(1), center(2)); ::glTranslated(center(0), center(1), center(2));
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
if (!boost::starts_with(sidebar_field, "position"))
orient_matrix = orient_matrix * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true);
::glMultMatrixd(orient_matrix.data()); ::glMultMatrixd(orient_matrix.data());
} }
else else

View File

@ -357,11 +357,11 @@ void Preview::set_drop_target(wxDropTarget* target)
SetDropTarget(target); SetDropTarget(target);
} }
void Preview::load_print() void Preview::load_print(bool keep_z_range)
{ {
PrinterTechnology tech = m_process->current_printer_technology(); PrinterTechnology tech = m_process->current_printer_technology();
if (tech == ptFFF) if (tech == ptFFF)
load_print_as_fff(); load_print_as_fff(keep_z_range);
else if (tech == ptSLA) else if (tech == ptSLA)
load_print_as_sla(); load_print_as_sla();
} }
@ -392,7 +392,7 @@ void Preview::refresh_print()
if (!IsShown()) if (!IsShown())
return; return;
load_print(); load_print(true);
} }
void Preview::bind_event_handlers() void Preview::bind_event_handlers()
@ -449,10 +449,10 @@ void Preview::reset_sliders()
m_double_slider_sizer->Hide((size_t)0); m_double_slider_sizer->Hide((size_t)0);
} }
void Preview::update_sliders(const std::vector<double>& layers_z) void Preview::update_sliders(const std::vector<double>& layers_z, bool keep_z_range)
{ {
m_enabled = true; m_enabled = true;
update_double_slider(layers_z); update_double_slider(layers_z, keep_z_range);
m_double_slider_sizer->Show((size_t)0); m_double_slider_sizer->Show((size_t)0);
Layout(); Layout();
} }
@ -561,13 +561,18 @@ 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) void Preview::update_double_slider(const std::vector<double>& layers_z, bool keep_z_range)
{ {
// 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 force_sliders_full_range = was_empty; bool force_sliders_full_range = was_empty;
if (!keep_z_range)
{
bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > 1e-6;
force_sliders_full_range |= 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();
@ -654,7 +659,7 @@ void Preview::update_double_slider_from_canvas(wxKeyEvent& event)
event.Skip(); event.Skip();
} }
void Preview::load_print_as_fff() void Preview::load_print_as_fff(bool keep_z_range)
{ {
if (m_loaded || m_process->current_printer_technology() != ptFFF) if (m_loaded || m_process->current_printer_technology() != ptFFF)
return; return;
@ -755,7 +760,7 @@ void Preview::load_print_as_fff()
reset_sliders(); reset_sliders();
m_canvas_widget->Refresh(); m_canvas_widget->Refresh();
} else } else
update_sliders(zs); update_sliders(zs, keep_z_range);
} }
} }

View File

@ -115,7 +115,7 @@ public:
void select_view(const std::string& direction); void select_view(const std::string& direction);
void set_drop_target(wxDropTarget* target); void set_drop_target(wxDropTarget* target);
void load_print(); void load_print(bool keep_z_range = false);
void reload_print(bool keep_volumes = false); void reload_print(bool keep_volumes = false);
void refresh_print(); void refresh_print();
@ -128,7 +128,7 @@ private:
void show_hide_ui_elements(const std::string& what); void show_hide_ui_elements(const std::string& what);
void reset_sliders(); void reset_sliders();
void update_sliders(const std::vector<double>& layers_z); void update_sliders(const std::vector<double>& layers_z, bool keep_z_range = false);
void on_size(wxSizeEvent& evt); void on_size(wxSizeEvent& evt);
void on_choice_view_type(wxCommandEvent& evt); void on_choice_view_type(wxCommandEvent& evt);
@ -140,14 +140,14 @@ 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); void update_double_slider(const std::vector<double>& layers_z, bool keep_z_range = false);
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();
// update DoubleSlider after keyDown in canvas // update DoubleSlider after keyDown in canvas
void update_double_slider_from_canvas(wxKeyEvent& event); void update_double_slider_from_canvas(wxKeyEvent& event);
void load_print_as_fff(); void load_print_as_fff(bool keep_z_range = false);
void load_print_as_sla(); void load_print_as_sla();
void on_sliders_scroll_changed(wxEvent& event); void on_sliders_scroll_changed(wxEvent& event);