From 622c613b410fd0f8ac82b78ae577194f9e1c3607 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 21 May 2018 14:49:31 +0200 Subject: [PATCH] Update of the view mode works correctly --- lib/Slic3r/GUI/MainFrame.pm | 2 ++ lib/Slic3r/GUI/Plater.pm | 7 ++++--- lib/Slic3r/GUI/Plater/3D.pm | 2 +- xs/src/slic3r/GUI/GUI.cpp | 9 ++++----- xs/src/slic3r/GUI/GUI.hpp | 2 ++ xs/src/slic3r/GUI/Tab.cpp | 16 ++++++++++------ xs/xsp/GUI.xsp | 3 +++ 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index fbcd34a3f..51f5911f0 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -96,6 +96,8 @@ sub new { $self->update_ui_from_settings; + Slic3r::GUI::update_mode(); + return $self; } diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e57c2267a..5bd4587bb 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -449,7 +449,8 @@ sub new { $self->{"object_info_manifold_warning_icon_show"} = sub { if ($self->{object_info_manifold_warning_icon}->IsShown() != $_[0]) { Slic3r::GUI::set_show_manifold_warning_icon($_[0]); - return if (wxTheApp->{app_config}->get("view_mode") eq "simple"); + my $mode = wxTheApp->{app_config}->get("view_mode"); + return if ($mode eq "" || $mode eq "simple"); $self->{object_info_manifold_warning_icon}->Show($_[0]); $self->Layout } @@ -548,7 +549,7 @@ sub new { $self->SetSizer($sizer); # Send sizers/buttons to C++ - Slic3r::GUI::set_objects_from_perl( $self, + Slic3r::GUI::set_objects_from_perl( $self->{right_panel}, $frequently_changed_parameters_sizer, $expert_mode_part_sizer, $scrolled_window_sizer, @@ -1767,7 +1768,7 @@ sub on_extruders_change { my @presets = $choices->[0]->GetStrings; # initialize new choice - my $choice = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); my $extruder_idx = scalar @$choices; EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down($extruder_idx, @_); } ); push @$choices, $choice; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index c9c954276..c3521a4da 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -245,7 +245,7 @@ sub reload_scene { $self->set_warning_enabled(0); $self->volumes->update_outside_state($self->{config}, 1); Slic3r::GUI::_3DScene::reset_warning_texture(); - $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); + $self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons); } } else { $self->set_warning_enabled(0); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index abdeb6c72..1fc02ed1f 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -202,7 +202,7 @@ double m_brim_width = 0.0; wxButton* g_wiping_dialog_button = nullptr; //showed/hided controls according to the view mode -wxWindow *g_plater = nullptr; +wxWindow *g_right_panel = nullptr; wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr; wxBoxSizer *g_expert_mode_part_sizer = nullptr; wxBoxSizer *g_scrolled_window_sizer = nullptr; @@ -279,7 +279,7 @@ void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_par wxButton *btn_print, wxButton *btn_send_gcode, wxStaticBitmap *manifold_warning_icon) { - g_plater = parent; + g_right_panel = parent; g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; g_expert_mode_part_sizer = expert_mode_part_sizer; g_scrolled_window_sizer = scrolled_window_sizer; @@ -616,7 +616,6 @@ void create_preset_tabs(bool no_controller, int event_value_change, int event_pr tab->set_event_value_change(wxEventType(event_value_change)); tab->set_event_presets_changed(wxEventType(event_presets_changed)); } - update_mode();// TODO change place of call this function } TabIface* get_preset_tab_iface(char *name) @@ -1136,14 +1135,14 @@ void show_scrolled_window_sizer(bool show) void update_mode() { - wxWindowUpdateLocker noUpdates(g_plater); + wxWindowUpdateLocker noUpdates(g_right_panel); ConfigMenuIDs mode = get_view_mode(); show_frequently_changed_parameters(mode >= ConfigMenuModeRegular); g_expert_mode_part_sizer->Show(mode == ConfigMenuModeExpert); show_scrolled_window_sizer(mode >= ConfigMenuModeRegular); show_buttons(mode >= ConfigMenuModeRegular); - g_plater->Layout(); + g_right_panel->Layout(); } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 4fd8b800a..5f89d8b66 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -142,6 +142,8 @@ void save_language(); void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers); // select language from the list of installed languages bool select_language(wxArrayString & names, wxArrayLong & identifiers); +// update right panel of the Plater according to view mode +void update_mode(); std::vector& get_tabs_list(); bool checked_tab(Tab* tab); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 5a47dd1e7..21c85925d 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -705,13 +705,17 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) // Show/hide the 'purging volumes' button void Tab::update_wiping_button_visibility() { - bool wipe_tower_enabled = dynamic_cast( (m_preset_bundle->prints.get_edited_preset().config ).option("wipe_tower"))->value; - bool multiple_extruders = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; - bool single_extruder_mm = dynamic_cast( (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; + if (!get_app_config()->has("view_mode") || get_app_config()->get("view_mode") == "simple") + get_wiping_dialog_button()->Hide(); + else { + bool wipe_tower_enabled = dynamic_cast((m_preset_bundle->prints.get_edited_preset().config).option("wipe_tower"))->value; + bool multiple_extruders = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; + bool single_extruder_mm = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; - if (wipe_tower_enabled && multiple_extruders && single_extruder_mm) - get_wiping_dialog_button()->Show(); - else get_wiping_dialog_button()->Hide(); + if (wipe_tower_enabled && multiple_extruders && single_extruder_mm) + get_wiping_dialog_button()->Show(); + else get_wiping_dialog_button()->Hide(); + } (get_wiping_dialog_button()->GetParent())->Layout(); } diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 6dcb4a6ab..aca60d0f8 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -116,6 +116,9 @@ void set_show_print_info(bool show) void set_show_manifold_warning_icon(bool show) %code%{ Slic3r::GUI::set_show_manifold_warning_icon(show); %}; +void update_mode() + %code%{ Slic3r::GUI::update_mode(); %}; + std::string fold_utf8_to_ascii(const char *src) %code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %};