Further fixes of the previous commit.

This commit is contained in:
bubnikv 2017-09-20 10:16:00 +02:00
parent 8089631f10
commit b1e3b0cdf9
4 changed files with 6 additions and 4 deletions

View File

@ -530,7 +530,7 @@ sub title { 'Print Settings' }
sub build { sub build {
my $self = shift; 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'); my $page = $self->add_options_page('Layers and perimeters', 'layers.png');
@ -1011,7 +1011,7 @@ sub title { 'Filament Settings' }
sub build { sub build {
my $self = shift; 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'); my $page = $self->add_options_page('Filament', 'spool.png');
@ -1193,7 +1193,7 @@ sub build {
my $self = shift; my $self = shift;
my (%params) = @_; 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 $bed_shape_widget = sub {
my ($parent) = @_; my ($parent) = @_;

View File

@ -97,7 +97,7 @@ void PresetCollection::update_editor_ui(wxBitmapComboBox *ui)
size_t n_visible = this->num_visible(); size_t n_visible = this->num_visible();
size_t n_choice = size_t(ui->GetCount()); size_t n_choice = size_t(ui->GetCount());
std::string name_selected = ui->GetStringSelection().ToUTF8().data(); std::string name_selected = dynamic_cast<wxItemContainerImmutable*>(ui)->GetStringSelection().ToUTF8().data();
if (boost::algorithm::iends_with(name_selected, g_suffix_modified)) if (boost::algorithm::iends_with(name_selected, g_suffix_modified))
// Remove the g_suffix_modified. // Remove the g_suffix_modified.
name_selected.erase(name_selected.end() - g_suffix_modified.size(), name_selected.end()); name_selected.erase(name_selected.end() - g_suffix_modified.size(), name_selected.end());

View File

@ -83,6 +83,7 @@ public:
Preset& get_edited_preset() { return m_edited_preset; } Preset& get_edited_preset() { return m_edited_preset; }
const Preset& get_edited_preset() const { return m_edited_preset; } const Preset& get_edited_preset() const { return m_edited_preset; }
// Return a preset possibly with modifications. // 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]; } 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<PresetCollection*>(this)->preset(idx); } const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); }
size_t size() const { return this->m_presets.size(); } size_t size() const { return this->m_presets.size(); }

View File

@ -24,6 +24,7 @@
%name{Slic3r::GUI::PresetCollection} class PresetCollection { %name{Slic3r::GUI::PresetCollection} class PresetCollection {
Ref<Preset> preset(size_t idx) %code%{ RETVAL = &THIS->preset(idx); %}; Ref<Preset> preset(size_t idx) %code%{ RETVAL = &THIS->preset(idx); %};
Ref<Preset> default_preset() %code%{ RETVAL = &THIS->default_preset(); %};
size_t size() const; size_t size() const;
size_t num_visible() const; size_t num_visible() const;
%{ %{