From 3d3e36ba8d22d3654fb6adb451dae9f0eb6cf818 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 9 Mar 2020 16:20:50 +0100 Subject: Added "Filament spool weight" option to filament options --- src/slic3r/GUI/Plater.cpp | 26 ++++++++++++++++++++++++++ src/slic3r/GUI/Preset.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 22 ++++++++++++++++++++-- src/slic3r/GUI/Tab.hpp | 1 + 4 files changed, 48 insertions(+), 3 deletions(-) (limited to 'src/slic3r') diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 48eb86743..6a71debee 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -207,9 +207,11 @@ class SlicedInfo : public wxStaticBoxSizer public: SlicedInfo(wxWindow *parent); void SetTextAndShow(SlicedInfoIdx idx, const wxString& text, const wxString& new_label=""); + void SetNoteAndShow(const wxString& text); private: std::vector> info_vec; + wxStaticText* m_notes {nullptr}; }; SlicedInfo::SlicedInfo(wxWindow *parent) : @@ -241,6 +243,10 @@ SlicedInfo::SlicedInfo(wxWindow *parent) : init_info_label(_(L("Number of tool changes"))); Add(grid_sizer, 0, wxEXPAND); + + m_notes = new wxStaticText(parent, wxID_ANY, "N/A"); + Add(m_notes, 0, wxEXPAND); + this->Show(false); } @@ -255,6 +261,14 @@ void SlicedInfo::SetTextAndShow(SlicedInfoIdx idx, const wxString& text, const w info_vec[idx].second->Show(show); } +void SlicedInfo::SetNoteAndShow(const wxString& text) +{ + const bool show = text != "N/A"; + if (show) + m_notes->SetLabelText(text); + m_notes->Show(show); +} + PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) : PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)), preset_type(preset_type), @@ -1245,6 +1259,18 @@ void Sidebar::update_sliced_info_sizer() p->sliced_info->SetTextAndShow(siFilament_mm3, wxString::Format("%.2f", ps.total_extruded_volume)); p->sliced_info->SetTextAndShow(siFilament_g, ps.total_weight == 0.0 ? "N/A" : wxString::Format("%.2f", ps.total_weight)); + // Show a note information, if there is not enough filaments to complete a print + wxString note = "N/A"; + DynamicPrintConfig* cfg = wxGetApp().get_tab(Preset::TYPE_FILAMENT)->get_config(); + auto filament_spool_weights = dynamic_cast(cfg->option("filament_spool_weight"))->values; + if (ps.total_weight > 0.0 && !filament_spool_weights.empty() && filament_spool_weights[0] > 0.0 && + ps.total_weight > filament_spool_weights[0]) + note = "\n" + _(L("WARNING")) + ":\n " + + _(L("There is not enough filaments to complete a print")) + ".\n " + + from_u8((boost::format(_utf8(L("You only have %.2f g of the required %.2f g."))) % + filament_spool_weights[0] % ps.total_weight).str()); + p->sliced_info->SetNoteAndShow(note); + new_label = _(L("Cost")); if (is_wipe_tower) new_label += from_u8((boost::format(":\n - %1%\n - %2%") % _utf8(L("objects")) % _utf8(L("wipe tower"))).str()); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index b5d6392f9..fbb52791e 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -432,7 +432,7 @@ const std::vector& Preset::filament_options() { static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", - "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", + "extrusion_multiplier", "filament_density", "filament_cost", "filament_spool_weight", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", "filament_unloading_speed", "filament_unloading_speed_start", "filament_unload_time", "filament_toolchange_delay", "filament_cooling_moves", "filament_cooling_initial_speed", "filament_cooling_final_speed", "filament_ramming_parameters", "filament_minimal_purge_on_wipe_tower", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 9a6313e70..d8358af56 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1100,6 +1100,12 @@ void Tab::update_frequently_changed_parameters() } } +void Tab::update_sliced_info_on_plater() +{ + wxGetApp().sidebar().update_sliced_info_sizer(); + wxGetApp().sidebar().Layout(); +} + void TabPrint::build() { m_presets = &m_preset_bundle->prints; @@ -1484,6 +1490,19 @@ void TabFilament::build() optgroup->append_single_option_line("extrusion_multiplier"); optgroup->append_single_option_line("filament_density"); optgroup->append_single_option_line("filament_cost"); + optgroup->append_single_option_line("filament_spool_weight"); + + optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value) + { + update_dirty(); + + if (opt_key== "filament_spool_weight") + // Change of this option only has an influence to an update of "Sliced Info" + update_sliced_info_on_plater(); + else + // update configuration for its check and to schedule a background process, if needed + update(); + }; optgroup = page->new_optgroup(_(L("Temperature")) + wxString(" °C", wxConvUTF8)); Line line = { _(L("Extruder")), "" }; @@ -3567,8 +3586,7 @@ void TabSLAMaterial::build() update_dirty(); // Change of any from those options influences for an update of "Sliced Info" - wxGetApp().sidebar().update_sliced_info_sizer(); - wxGetApp().sidebar().Layout(); + update_sliced_info_on_plater(); }; optgroup = page->new_optgroup(_(L("Layers"))); diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index e2b00dc40..8cb1f549c 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -321,6 +321,7 @@ protected: void build_preset_description_line(ConfigOptionsGroup* optgroup); void update_preset_description_line(); void update_frequently_changed_parameters(); + void update_sliced_info_on_plater(); void fill_icon_descriptions(); void set_tooltips_text(); -- cgit v1.2.3 From 7fd9c736b339a46f3a94e80c017ea05288524c5a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 11 Mar 2020 10:43:59 +0100 Subject: Implemented "Use unlimited skirt" option --- src/slic3r/GUI/Preset.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/slic3r') diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index fbb52791e..97d17c05a 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -410,7 +410,7 @@ const std::vector& Preset::print_options() "perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "infill_speed", "solid_infill_speed", "top_solid_infill_speed", "support_material_speed", "support_material_xy_spacing", "support_material_interface_speed", "bridge_speed", "gap_fill_speed", "travel_speed", "first_layer_speed", "perimeter_acceleration", "infill_acceleration", - "bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height", + "bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height", "infinit_skirt", "min_skirt_length", "brim_width", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers", "raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing", "support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index d8358af56..dc98bda37 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1178,6 +1178,7 @@ void TabPrint::build() optgroup->append_single_option_line("skirts"); optgroup->append_single_option_line("skirt_distance"); optgroup->append_single_option_line("skirt_height"); + optgroup->append_single_option_line("infinit_skirt"); optgroup->append_single_option_line("min_skirt_length"); optgroup = page->new_optgroup(_(L("Brim"))); -- cgit v1.2.3 From 6a6790b8e76848a1cebf6fcb4db250948b448b7a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 12 Mar 2020 14:50:20 +0100 Subject: Implemented disabling of Add buttons if next layer range couldn't be added + Fixed "Layer ranges" expand. --- src/slic3r/GUI/GUI_ObjectLayers.cpp | 5 ++++- src/slic3r/GUI/GUI_ObjectList.cpp | 40 +++++++++++++++++++++++++++++++++---- src/slic3r/GUI/GUI_ObjectList.hpp | 1 + 3 files changed, 41 insertions(+), 5 deletions(-) (limited to 'src/slic3r') diff --git a/src/slic3r/GUI/GUI_ObjectLayers.cpp b/src/slic3r/GUI/GUI_ObjectLayers.cpp index d62bb2727..157e45ab4 100644 --- a/src/slic3r/GUI/GUI_ObjectLayers.cpp +++ b/src/slic3r/GUI/GUI_ObjectLayers.cpp @@ -156,8 +156,11 @@ void ObjectLayers::create_layers_list() const t_layer_height_range& range = layer.first; auto del_btn = new PlusMinusButton(m_parent, m_bmp_delete, range); del_btn->SetToolTip(_(L("Remove layer range"))); + auto add_btn = new PlusMinusButton(m_parent, m_bmp_add, range); - add_btn->SetToolTip(_(L("Add layer range"))); + wxString tooltip = wxGetApp().obj_list()->can_add_new_range_after_current(range); + add_btn->SetToolTip(tooltip.IsEmpty() ? _(L("Add layer range")) : tooltip); + add_btn->Enable(tooltip.IsEmpty()); auto sizer = create_layer(range, del_btn, add_btn); sizer->Add(del_btn, 0, wxRIGHT | wxLEFT, em_unit(m_parent)); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 80c1ce364..5ac22e54a 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -2978,6 +2978,40 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren select_item(layers_item); } +wxString ObjectList::can_add_new_range_after_current(const t_layer_height_range current_range) +{ + wxString ret; + const int obj_idx = get_selected_obj_idx(); + if (obj_idx < 0) + // This should not happen. + return ret; + + t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges; + auto it_range = ranges.find(current_range); + assert(it_range != ranges.end()); + if (it_range == ranges.end()) + // This shoudl not happen. + return ret; + + auto it_next_range = it_range; + if (++it_next_range == ranges.end()) + return ret; + + if (const std::pair& next_range = it_next_range->first; current_range.second <= next_range.first) + { + if (current_range.second == next_range.first && + next_range.second - next_range.first < get_min_layer_height(ranges.at(next_range).opt_int("extruder"))) + ret = _(L("A difference between ranges is a less than minimum layer height.")); + } + else + ret = _(L("End of current range is bigger then next one.")); + + if (!ret.IsEmpty()) + ret += "\n" + _(L("New range between them couldn't be added.")); + + return ret; +} + void ObjectList::add_layer_item(const t_layer_height_range& range, const wxDataViewItem layers_item, const int layer_idx /* = -1*/) @@ -3048,12 +3082,10 @@ bool ObjectList::edit_layer_range(const t_layer_height_range& range, const t_lay add_layer_item(r.first, root_item); } - if (dont_update_ui) - return true; + if (!dont_update_ui) + select_item(sel_type&itLayer ? m_objects_model->GetItemByLayerRange(obj_idx, new_range) : root_item); - select_item(sel_type&itLayer ? m_objects_model->GetItemByLayerRange(obj_idx, new_range) : root_item); Expand(root_item); - return true; } diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 0f067d116..adaa31242 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -327,6 +327,7 @@ public: // may have been postponed from the "kill focus" event of a text field, if the focus was lost for the "add layer" button. // Rather providing the range by a value than by a reference, so that the memory referenced cannot be invalidated. void add_layer_range_after_current(const t_layer_height_range current_range); + wxString can_add_new_range_after_current( t_layer_height_range current_range); void add_layer_item (const t_layer_height_range& range, const wxDataViewItem layers_item, const int layer_idx = -1); -- cgit v1.2.3