From 1399696b042358b70a5835ec4611de3bd0857149 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 13 Feb 2020 15:28:04 +0100 Subject: [PATCH] DoubleSlider: Suppressed manipulation for sequential print. + some code refactoring + experiment with alignment of several options inside the Line --- src/slic3r/GUI/DoubleSlider.cpp | 52 ++++++++++++++++++++++----------- src/slic3r/GUI/DoubleSlider.hpp | 13 +++++++-- src/slic3r/GUI/GUI_Preview.cpp | 8 +++-- src/slic3r/GUI/OptionsGroup.cpp | 12 +++++--- src/slic3r/GUI/OptionsGroup.hpp | 1 + src/slic3r/GUI/Tab.cpp | 1 - 6 files changed, 60 insertions(+), 27 deletions(-) diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index a462b8894..d29e87a93 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -332,6 +332,13 @@ void Control::SetTicksValues(const CustomGCode::Info& custom_gcode_per_print_z) Update(); } +void Control::SetDrawMode(bool is_sla_print, bool is_sequential_print) +{ + m_draw_mode = is_sla_print ? dmSlaPrint : + is_sequential_print ? dmSequentialFffPrint : + dmRegular; +} + void Control::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder) { m_mode = !is_one_extruder_printed_model ? t_mode::MultiExtruder : @@ -441,7 +448,7 @@ void Control::draw_info_line_with_icon(wxDC& dc, const wxPoint& pos, const Selec dc.DrawLine(pt_beg, pt_end); //draw action icon - if (m_is_enabled_tick_manipulation) + if (m_draw_mode == dmRegular) draw_action_icon(dc, pt_beg, pt_end); } } @@ -612,10 +619,10 @@ void Control::draw_thumbs(wxDC& dc, const wxCoord& lower_pos, const wxCoord& hig void Control::draw_ticks(wxDC& dc) { - if (!m_is_enabled_tick_manipulation) + if (m_draw_mode == dmSlaPrint) return; - dc.SetPen(m_is_enabled_tick_manipulation ? DARK_GREY_PEN : LIGHT_GREY_PEN ); + dc.SetPen(m_draw_mode == dmRegular ? DARK_GREY_PEN : LIGHT_GREY_PEN ); int height, width; get_size(&width, &height); const wxCoord mid = is_horizontal() ? 0.5*height : 0.5*width; @@ -633,7 +640,11 @@ void Control::draw_ticks(wxDC& dc) // get icon name if it is std::string icon_name; - if (tick.gcode == ColorChangeCode || tick.gcode == ToolChangeCode) { + + // if we have non-regular draw mode, all ticks should be marked with error icon + if (m_draw_mode != dmRegular) + icon_name = focused_tick ? "error_tick_f" : "error_tick"; + else if (tick.gcode == ColorChangeCode || tick.gcode == ToolChangeCode) { if (m_ticks.is_conflict_tick(tick, m_mode, m_only_extruder, m_values[tick.tick])) icon_name = focused_tick ? "error_tick_f" : "error_tick"; } @@ -705,7 +716,7 @@ wxRect Control::get_colored_band_rect() void Control::draw_colored_band(wxDC& dc) { - if (!m_is_enabled_tick_manipulation) + if (m_draw_mode != dmRegular) return; auto draw_band = [](wxDC& dc, const wxColour& clr, const wxRect& band_rc) @@ -771,7 +782,7 @@ void Control::draw_one_layer_icon(wxDC& dc) void Control::draw_revert_icon(wxDC& dc) { - if (m_ticks.empty() || !m_is_enabled_tick_manipulation) + if (m_ticks.empty() || m_draw_mode != dmRegular) return; int width, height; @@ -880,7 +891,7 @@ void Control::OnLeftDown(wxMouseEvent& event) m_mouse = maOneLayerIconClick; else if (is_point_in_rect(pos, m_rect_cog_icon)) m_mouse = maCogIconClick; - else if (m_is_enabled_tick_manipulation) + else if (m_draw_mode == dmRegular) { if (is_point_in_rect(pos, m_rect_tick_action)) { auto it = m_ticks.ticks.find(TickCode{ m_selection == ssLower ? m_lower_value : m_higher_value }); @@ -931,6 +942,8 @@ wxString Control::get_tooltip(int tick/*=-1*/) if (m_focus == fiColorBand) return m_mode != t_mode::SingleExtruder ? "" : _(L("Edit current color - Right click the colored slider segment")); + if (m_draw_mode == dmSlaPrint) + return ""; // no drawn ticks and no tooltips for them in SlaPrinting mode wxString tooltip; const auto tick_code_it = m_ticks.ticks.find(TickCode{tick}); @@ -953,9 +966,9 @@ wxString Control::get_tooltip(int tick/*=-1*/) // Show list of actions with new tick tooltip += ( m_mode == t_mode::MultiAsSingle ? _(L("Add extruder change - Left click")) : - m_mode == t_mode::SingleExtruder ? + m_mode == t_mode::SingleExtruder ? _(L("Add color change - Left click for predefined color or" - "Shift + Left click for custom color selection")) : + "Shift + Left click for custom color selection")) : _(L("Add color change - Left click")) ) + " " + _(L("or press \"+\" key")) + "\n" + ( is_osx ? @@ -965,17 +978,22 @@ wxString Control::get_tooltip(int tick/*=-1*/) if (tick_code_it != m_ticks.ticks.end()) // tick exists { + if (m_draw_mode == dmSequentialFffPrint) + return _(L("The sequential print is on.\n" + "It's impossible to apply any custom G-code for objects printing sequentually.\n" + "This code won't be processed during G-code generation.")); + // Show custom Gcode as a first string of tooltop tooltip = " "; - tooltip += tick_code_it->gcode == ColorChangeCode ? ( - m_mode == t_mode::SingleExtruder ? + tooltip += tick_code_it->gcode == ColorChangeCode ? ( m_mode == t_mode::SingleExtruder ? from_u8((boost::format(_utf8(L("Color change (\"%1%\")"))) % tick_code_it->gcode ).str()) : from_u8((boost::format(_utf8(L("Color change (\"%1%\") for Extruder %2%"))) % - tick_code_it->gcode % tick_code_it->extruder).str()) ) : + tick_code_it->gcode % tick_code_it->extruder).str()) ) : tick_code_it->gcode == PausePrintCode ? - from_u8((boost::format(_utf8(L("Pause print (\"%1%\")"))) % tick_code_it->gcode ).str()) : + from_u8((boost::format(_utf8(L("Pause print (\"%1%\")"))) % tick_code_it->gcode ).str()) : tick_code_it->gcode == ToolChangeCode ? - from_u8((boost::format(_utf8(L("Extruder (tool) is changed to Extruder \"%1%\""))) % tick_code_it->extruder ).str()) : + from_u8((boost::format(_utf8(L("Extruder (tool) is changed to Extruder \"%1%\""))) % + tick_code_it->extruder ).str()) : from_u8((boost::format(_utf8(L("\"%1%\""))) % tick_code_it->gcode ).str()) ; // If tick is marked as a conflict (exclamation icon), @@ -1169,7 +1187,7 @@ void Control::OnLeftUp(wxMouseEvent& event) add_current_tick(); break; case maCogIconClick : - if (m_mode == t_mode::MultiAsSingle) + if (m_mode == t_mode::MultiAsSingle && m_draw_mode == dmRegular) show_cog_icon_context_menu(); else jump_to_print_z(); @@ -1320,7 +1338,7 @@ void Control::OnRightDown(wxMouseEvent& event) const wxPoint pos = event.GetLogicalPosition(wxClientDC(this)); m_mouse = maNone; - if (m_is_enabled_tick_manipulation) { + if (m_draw_mode == dmRegular) { if (is_point_in_rect(pos, m_rect_tick_action)) { const int tick = m_selection == ssLower ? m_lower_value : m_higher_value; @@ -1766,7 +1784,7 @@ void Control::discard_all_thicks() void Control::move_current_thumb_to_pos(wxPoint pos) { const int tick_val = get_tick_near_point(pos); - const int mouse_val = tick_val >= 0 && m_is_enabled_tick_manipulation ? tick_val : + const int mouse_val = tick_val >= 0 && m_draw_mode == dmRegular ? tick_val : get_value_from_position(pos); if (mouse_val >= 0) { diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index c6c85fe0e..e5c0b4e21 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -66,6 +66,13 @@ enum MouseAction maRevertIconClick, // LeftMouseClick on "revert" icon }; +enum DrawMode +{ + dmRegular, + dmSlaPrint, + dmSequentialFffPrint, +}; + using t_mode = CustomGCode::Mode; struct TickCode @@ -197,8 +204,7 @@ public: CustomGCode::Info GetTicksValues() const; void SetTicksValues(const Slic3r::CustomGCode::Info &custom_gcode_per_print_z); - void EnableTickManipulation(bool enable = true) { m_is_enabled_tick_manipulation = enable; } - void DisableTickManipulation() { EnableTickManipulation(false); } + void SetDrawMode(bool is_sla_print, bool is_sequential_print); void SetManipulationMode(t_mode mode) { m_mode = mode; } t_mode GetManipulationMode() const { return m_mode; } @@ -323,9 +329,10 @@ private: bool m_is_right_down = false; bool m_is_one_layer = false; bool m_is_focused = false; - bool m_is_enabled_tick_manipulation = true; bool m_force_mode_apply = true; + DrawMode m_draw_mode = dmRegular; + t_mode m_mode = t_mode::SingleExtruder; int m_only_extruder = -1; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 5afdb3bb4..732e7ce15 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -586,7 +586,9 @@ void Preview::update_view_type(bool slice_completed) void Preview::create_double_slider() { m_slider = new DoubleSlider::Control(this, wxID_ANY, 0, 0, 0, 100); - m_slider->EnableTickManipulation(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptFFF); + bool sla_print_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA; + bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects"); + m_slider->SetDrawMode(sla_print_technology, sequential_print); m_double_slider_sizer->Add(m_slider, 0, wxEXPAND, 0); @@ -700,7 +702,9 @@ void Preview::update_double_slider(const std::vector& layers_z, bool kee m_slider->SetTicksValues(ticks_info_from_model); - m_slider->EnableTickManipulation(wxGetApp().plater()->printer_technology() == ptFFF); + bool sla_print_technology = wxGetApp().plater()->printer_technology() == ptSLA; + bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects"); + m_slider->SetDrawMode(sla_print_technology, sequential_print); } void Preview::update_double_slider_mode() diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 4e964ff74..444f92bf7 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -129,8 +129,11 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n m_options.emplace(opt.opt_id, opt); // Set sidetext width for a better alignment of options in line - if (option_set.size() > 1) + if (option_set.size() > 1) { sidetext_width = Field::def_width_thinner(); + if (m_show_modified_btns) // means that options groups are in tabs + sublabel_width = Field::def_width(); + } // add mode value for current line to m_options_mode if (!option_set.empty()) @@ -248,15 +251,16 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n ConfigOptionDef option = opt.opt; wxSizer* sizer_tmp = sizer; // add label if any - if (option.label != "") { + if (!option.label.empty()) { //! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1 wxString str_label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ? _CTX(option.label, "Layers") : _(option.label); - label = new wxStaticText(this->ctrl_parent(), wxID_ANY, str_label + ": ", wxDefaultPosition, wxDefaultSize); + label = new wxStaticText(this->ctrl_parent(), wxID_ANY, str_label + ": ", wxDefaultPosition, //wxDefaultSize); + wxSize(sublabel_width != -1 ? sublabel_width * wxGetApp().em_unit() : -1, -1), wxALIGN_RIGHT); label->SetBackgroundStyle(wxBG_STYLE_PAINT); label->SetFont(wxGetApp().normal_font()); - sizer_tmp->Add(label, 0, /*wxALIGN_RIGHT |*/ wxALIGN_CENTER_VERTICAL, 0); + sizer_tmp->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0); } // add field diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index 6089e18f5..536eb72a5 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -97,6 +97,7 @@ public: wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; int sidetext_width{ -1 }; + int sublabel_width{ -1 }; /// Returns a copy of the pointer of the parent wxWindow. /// Accessor function is because users are not allowed to change the parent diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c5c6dc466..836402a94 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3505,7 +3505,6 @@ void TabSLAMaterial::build() optgroup->append_single_option_line("initial_exposure_time"); optgroup = page->new_optgroup(_(L("Corrections"))); - optgroup->label_width = 19;//190; std::vector corrections = {"material_correction"}; // std::vector axes{ "X", "Y", "Z" }; std::vector axes{ "XY", "Z" };