Fixed a preview mode selection after updating of a PrusaDoubleSlider

This commit is contained in:
YuSanka 2019-02-27 13:37:16 +01:00
parent 773f1c35cf
commit a76bd40c62
2 changed files with 12 additions and 15 deletions

View File

@ -563,8 +563,12 @@ void Preview::create_double_slider()
auto& config = wxGetApp().preset_bundle->project_config;
((config.option<ConfigOptionFloats>("colorprint_heights"))->values) = (m_slider->GetTicksValues());
m_schedule_background_process();
bool color_print = !config.option<ConfigOptionFloats>("colorprint_heights")->values.empty();
int type = m_choice_view_type->FindString(color_print ? _(L("Color Print")) : _(L("Feature type")) );
const wxString& choise = !config.option<ConfigOptionFloats>("colorprint_heights")->values.empty() ? _(L("Color Print")) :
config.option<ConfigOptionFloats>("wiping_volumes_matrix")->values.size() > 1 ?
_(L("Tool")) : _(L("Feature type"));
int type = m_choice_view_type->FindString(choise);
if (m_choice_view_type->GetSelection() != type) {
m_choice_view_type->SetSelection(type);
if ((0 <= type) && (type < (int)GCodePreviewData::Extrusion::Num_View_Types))
@ -638,18 +642,6 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool for
const auto& config = wxGetApp().preset_bundle->project_config;
const std::vector<double> &ticks_from_config = (config.option<ConfigOptionFloats>("colorprint_heights"))->values;
// Switch to the "Feature type" from the very beginning of a new object slicing after deleting of the old one
if (ticks_from_config.empty())
{
const int& type = m_choice_view_type->FindString(_(L("Feature type")));
if (m_choice_view_type->GetSelection() != type) {
m_choice_view_type->SetSelection(type);
if (0 <= type && type < int(GCodePreviewData::Extrusion::Num_View_Types))
m_gcode_preview_data->extrusion.view_type = GCodePreviewData::Extrusion::EViewType(type);
m_preferred_color_mode = "feature";
reload_print();
}
}
m_slider->SetTicksValues(ticks_from_config);
bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF);

View File

@ -1640,6 +1640,8 @@ void PrusaDoubleSlider::SetTicksValues(const std::vector<double>& heights)
if (m_values.empty())
return;
const bool was_empty = m_ticks.empty();
m_ticks.clear();
unsigned int i = 0;
for (auto h : heights) {
@ -1649,7 +1651,10 @@ void PrusaDoubleSlider::SetTicksValues(const std::vector<double>& heights)
return;
m_ticks.insert(i-1);
}
if (!was_empty && m_ticks.empty())
// Switch to the "Feature type"/"Tool" from the very beginning of a new object slicing after deleting of the old one
wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
}
void PrusaDoubleSlider::get_lower_and_higher_position(int& lower_pos, int& higher_pos)