From b1e3b0cdf9660961d291cfde508c7bcf3b9dd22b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 20 Sep 2017 10:16:00 +0200 Subject: [PATCH] Further fixes of the previous commit. --- lib/Slic3r/GUI/Tab.pm | 6 +++--- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Preset.hpp | 1 + xs/xsp/GUI_Preset.xsp | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index b0897ab66..fb9d7e8b0 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -530,7 +530,7 @@ sub title { 'Print Settings' } sub build { my $self = shift; - $self->{config}->apply(wxTheApp->{preset_bundle}->prints->preset(0)->config); + $self->{config}->apply(wxTheApp->{preset_bundle}->prints->default_preset->config); { my $page = $self->add_options_page('Layers and perimeters', 'layers.png'); @@ -1011,7 +1011,7 @@ sub title { 'Filament Settings' } sub build { my $self = shift; - $self->{config}->apply(wxTheApp->{preset_bundle}->filaments->preset(0)->config); + $self->{config}->apply(wxTheApp->{preset_bundle}->filaments->default_preset->config); { my $page = $self->add_options_page('Filament', 'spool.png'); @@ -1193,7 +1193,7 @@ sub build { my $self = shift; my (%params) = @_; - $self->{config}->apply(wxTheApp->{preset_bundle}->printers->preset(0)->config); + $self->{config}->apply(wxTheApp->{preset_bundle}->printers->default_preset->config); my $bed_shape_widget = sub { my ($parent) = @_; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 451675d8d..3aa051d1c 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -97,7 +97,7 @@ void PresetCollection::update_editor_ui(wxBitmapComboBox *ui) size_t n_visible = this->num_visible(); size_t n_choice = size_t(ui->GetCount()); - std::string name_selected = ui->GetStringSelection().ToUTF8().data(); + std::string name_selected = dynamic_cast(ui)->GetStringSelection().ToUTF8().data(); if (boost::algorithm::iends_with(name_selected, g_suffix_modified)) // Remove the g_suffix_modified. name_selected.erase(name_selected.end() - g_suffix_modified.size(), name_selected.end()); diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 9ee7b54ee..cd4bdfdf6 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -83,6 +83,7 @@ public: Preset& get_edited_preset() { return m_edited_preset; } const Preset& get_edited_preset() const { return m_edited_preset; } // Return a preset possibly with modifications. + const Preset& default_preset() const { return m_presets.front(); } Preset& preset(size_t idx) { return (int(idx) == m_idx_selected) ? m_edited_preset : m_presets[idx]; } const Preset& preset(size_t idx) const { return const_cast(this)->preset(idx); } size_t size() const { return this->m_presets.size(); } diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp index 938a86373..f32a07d58 100644 --- a/xs/xsp/GUI_Preset.xsp +++ b/xs/xsp/GUI_Preset.xsp @@ -24,6 +24,7 @@ %name{Slic3r::GUI::PresetCollection} class PresetCollection { Ref preset(size_t idx) %code%{ RETVAL = &THIS->preset(idx); %}; + Ref default_preset() %code%{ RETVAL = &THIS->default_preset(); %}; size_t size() const; size_t num_visible() const; %{