Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_labels

This commit is contained in:
Enrico Turri 2020-02-06 09:15:15 +01:00
commit f37a31596c
22 changed files with 771 additions and 397 deletions

View file

@ -233,22 +233,27 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
"solid_infill_every_layers", "solid_infill_below_area", "infill_extruder" })
toggle_field(el, have_infill);
bool have_solid_infill = config->opt_int("top_solid_layers") > 0 || config->opt_int("bottom_solid_layers") > 0;
bool has_spiral_vase = config->opt_bool("spiral_vase");
bool has_top_solid_infill = config->opt_int("top_solid_layers") > 0;
bool has_bottom_solid_infill = config->opt_int("bottom_solid_layers") > 0;
bool has_solid_infill = has_top_solid_infill || has_bottom_solid_infill;
// solid_infill_extruder uses the same logic as in Print::extruders()
for (auto el : { "top_fill_pattern", "bottom_fill_pattern", "infill_first", "solid_infill_extruder",
"solid_infill_extrusion_width", "solid_infill_speed" })
toggle_field(el, have_solid_infill);
toggle_field(el, has_solid_infill);
for (auto el : { "fill_angle", "bridge_angle", "infill_extrusion_width",
"infill_speed", "bridge_speed" })
toggle_field(el, have_infill || have_solid_infill);
toggle_field(el, have_infill || has_solid_infill);
toggle_field("top_solid_min_thickness", ! has_spiral_vase && has_top_solid_infill);
toggle_field("bottom_solid_min_thickness", ! has_spiral_vase && has_bottom_solid_infill);
// Gap fill is newly allowed in between perimeter lines even for empty infill (see GH #1476).
toggle_field("gap_fill_speed", have_perimeters);
bool have_top_solid_infill = config->opt_int("top_solid_layers") > 0;
for (auto el : { "top_infill_extrusion_width", "top_solid_infill_speed" })
toggle_field(el, have_top_solid_infill);
toggle_field(el, has_top_solid_infill);
bool have_default_acceleration = config->opt_float("default_acceleration") > 0;
for (auto el : { "perimeter_acceleration", "infill_acceleration",

View file

@ -19,6 +19,7 @@
#include <cmath>
#include <boost/algorithm/string/replace.hpp>
#include "Field.hpp"
namespace Slic3r {
@ -293,7 +294,8 @@ CustomGCode::Info Control::GetTicksValues() const
values.emplace_back(t_custom_code{m_values[tick.tick], tick.gcode, tick.extruder, tick.color});
}
custom_gcode_per_print_z.mode = m_force_mode_apply ? m_mode : m_ticks.mode;
if (m_force_mode_apply)
custom_gcode_per_print_z.mode = m_mode;
return custom_gcode_per_print_z;
}
@ -330,6 +332,18 @@ void Control::SetTicksValues(const CustomGCode::Info& custom_gcode_per_print_z)
Update();
}
void Control::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder)
{
m_mode = !is_one_extruder_printed_model ? t_mode::MultiExtruder :
only_extruder < 0 ? t_mode::SingleExtruder :
t_mode::MultiAsSingle;
if (!m_ticks.mode)
m_ticks.mode = m_mode;
m_only_extruder = only_extruder;
UseDefaultColors(m_mode == t_mode::SingleExtruder);
}
void Control::get_lower_and_higher_position(int& lower_pos, int& higher_pos)
{
const double step = get_scroll_step();
@ -397,9 +411,9 @@ void Control::draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_
if (tick == 0)
return;
wxBitmap* icon = m_is_action_icon_focesed ? &m_bmp_add_tick_off.bmp() : &m_bmp_add_tick_on.bmp();
wxBitmap* icon = m_focus == fiActionIcon ? &m_bmp_add_tick_off.bmp() : &m_bmp_add_tick_on.bmp();
if (m_ticks.ticks.find(TickCode{tick}) != m_ticks.ticks.end())
icon = m_is_action_icon_focesed ? &m_bmp_del_tick_off.bmp() : &m_bmp_del_tick_on.bmp();
icon = m_focus == fiActionIcon ? &m_bmp_del_tick_off.bmp() : &m_bmp_del_tick_on.bmp();
wxCoord x_draw, y_draw;
is_horizontal() ? x_draw = pt_beg.x - 0.5*m_tick_icon_dim : y_draw = pt_beg.y - 0.5*m_tick_icon_dim;
@ -667,8 +681,8 @@ void Control::draw_colored_band(wxDC& dc)
void Control::draw_one_layer_icon(wxDC& dc)
{
const wxBitmap& icon = m_is_one_layer ?
m_is_one_layer_icon_focesed ? m_bmp_one_layer_lock_off.bmp() : m_bmp_one_layer_lock_on.bmp() :
m_is_one_layer_icon_focesed ? m_bmp_one_layer_unlock_off.bmp() : m_bmp_one_layer_unlock_on.bmp();
m_focus == fiOneLayerIcon ? m_bmp_one_layer_lock_off.bmp() : m_bmp_one_layer_lock_on.bmp() :
m_focus == fiOneLayerIcon ? m_bmp_one_layer_unlock_off.bmp() : m_bmp_one_layer_unlock_on.bmp();
int width, height;
get_size(&width, &height);
@ -703,9 +717,6 @@ void Control::draw_revert_icon(wxDC& dc)
void Control::draw_cog_icon(wxDC& dc)
{
if (m_mode != t_mode::MultiExtruder)
return;
int width, height;
get_size(&width, &height);
@ -788,73 +799,25 @@ void Control::OnLeftDown(wxMouseEvent& event)
return;
this->CaptureMouse();
wxClientDC dc(this);
wxPoint pos = event.GetLogicalPosition(dc);
if (is_point_in_rect(pos, m_rect_tick_action) && m_is_enabled_tick_manipulation)
{
const auto it = m_ticks.ticks.find(TickCode{ m_selection == ssLower ? m_lower_value : m_higher_value });
if (it == m_ticks.ticks.end())
m_force_add_tick = true;
else
m_force_delete_tick = true;
return;
}
m_is_left_down = true;
if (is_point_in_rect(pos, m_rect_one_layer_icon)) {
// switch on/off one layer mode
m_is_one_layer = !m_is_one_layer;
if (!m_is_one_layer) {
SetLowerValue(m_min_value);
SetHigherValue(m_max_value);
}
m_selection == ssLower ? correct_lower_value() : correct_higher_value();
if (!m_selection) m_selection = ssHigher;
}
else if (is_point_in_rect(pos, m_rect_revert_icon) && m_is_enabled_tick_manipulation) {
// discard all color changes
SetLowerValue(m_min_value);
SetHigherValue(m_max_value);
m_selection == ssLower ? correct_lower_value() : correct_higher_value();
if (!m_selection) m_selection = ssHigher;
m_ticks.ticks.clear();
post_ticks_changed_event();
}
else if (is_point_in_rect(pos, m_rect_cog_icon) && m_mode == t_mode::MultiExtruder) {
// show dialog for set extruder sequence
m_force_edit_extruder_sequence = true;
return;
}
else
detect_selected_slider(pos);
if (!m_selection) {
const int tick_val = get_tick_near_point(pos);
/* Set current thumb position to the nearest tick (if it is)
* OR to a value corresponding to the mouse click
* */
const int mouse_val = tick_val >= 0 && m_is_enabled_tick_manipulation ? tick_val :
get_value_from_position(pos.x, pos.y);
if (mouse_val >= 0)
{
// if (abs(mouse_val - m_lower_value) < abs(mouse_val - m_higher_value)) {
if ( mouse_val <= m_lower_value ) {
SetLowerValue(mouse_val);
correct_lower_value();
m_selection = ssLower;
}
else {
SetHigherValue(mouse_val);
correct_higher_value();
m_selection = ssHigher;
}
m_mouse = maNone;
wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
if (is_point_in_rect(pos, m_rect_one_layer_icon))
m_mouse = maOneLayerIconClick;
else if (is_point_in_rect(pos, m_rect_cog_icon))
m_mouse = maCogIconClick;
else if (m_is_enabled_tick_manipulation)
{
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 });
m_mouse = it == m_ticks.ticks.end() ? maAddTick : maDeleteTick;
}
else if (is_point_in_rect(pos, m_rect_revert_icon))
m_mouse = maRevertIconClick;
}
Refresh();
Update();
event.Skip();
}
@ -880,24 +843,27 @@ void Control::correct_higher_value()
m_lower_value = m_higher_value;
}
wxString Control::get_tooltip(FocusItem focused_item, int tick/*=-1*/)
wxString Control::get_tooltip(int tick/*=-1*/)
{
if (focused_item == fiNone)
if (m_focus == fiNone)
return "";
if (focused_item == fiOneLayerIcon)
if (m_focus == fiOneLayerIcon)
return _(L("One layer mode"));
if (focused_item == fiRevertIcon)
if (m_focus == fiRevertIcon)
return _(L("Discard all custom changes"));
if (focused_item == fiCogIcon)
return _(L("Set extruder sequence for whole print"));
if (focused_item == fiColorBand)
if (m_focus == fiCogIcon)
return m_mode == t_mode::MultiAsSingle ?
_(L("For jump to print Z use left mouse button click OR (Shift+G)")) + "\n" +
_(L("For set extruder sequence for whole print use right mouse button click")) :
_(L("Jump to print Z")) + " (Shift+G)";
if (m_focus == fiColorBand)
return m_mode != t_mode::SingleExtruder ? "" :
_(L("For edit current color use right mouse button click on colored band"));
wxString tooltip;
const auto tick_code_it = m_ticks.ticks.find(TickCode{tick});
if (tick_code_it == m_ticks.ticks.end() && focused_item == fiActionIcon) // tick doesn't exist
if (tick_code_it == m_ticks.ticks.end() && m_focus == fiActionIcon) // tick doesn't exist
{
// Show mode as a first string of tooltop
tooltip = " " + _(L("Slider(print) mode")) + ": ";
@ -960,7 +926,7 @@ wxString Control::get_tooltip(FocusItem focused_item, int tick/*=-1*/)
"Check your choice to avoid redundant color changes."));
// Show list of actions with existing tick
if (focused_item == fiActionIcon)
if (m_focus == fiActionIcon)
tooltip += "\n\n" + _(L("For Delete tick use left mouse button click OR pres \"-\" key")) + "\n" + (
is_osx ?
_(L("For Edit tick use Ctrl + Left mouse button click")) :
@ -991,31 +957,26 @@ void Control::OnMotion(wxMouseEvent& event)
{
bool action = false;
const wxClientDC dc(this);
const wxPoint pos = event.GetLogicalPosition(dc);
m_is_one_layer_icon_focesed = is_point_in_rect(pos, m_rect_one_layer_icon);
FocusItem focused_item = fiNone;
const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
int tick = -1;
if (!m_is_left_down && !m_is_one_layer) {
m_is_action_icon_focesed = is_point_in_rect(pos, m_rect_tick_action);
if (m_is_one_layer_icon_focesed)
focused_item = fiOneLayerIcon;
else if (m_is_action_icon_focesed) {
focused_item = fiActionIcon;
if (!m_is_left_down && !m_is_one_layer)
{
if (is_point_in_rect(pos, m_rect_one_layer_icon))
m_focus = fiOneLayerIcon;
else if (is_point_in_rect(pos, m_rect_tick_action)) {
m_focus = fiActionIcon;
tick = m_selection == ssLower ? m_lower_value : m_higher_value;
}
else if (!m_ticks.empty() && is_point_in_rect(pos, m_rect_revert_icon))
focused_item = fiRevertIcon;
m_focus = fiRevertIcon;
else if (is_point_in_rect(pos, m_rect_cog_icon))
focused_item = fiCogIcon;
m_focus = fiCogIcon;
else if (m_mode == t_mode::SingleExtruder && is_point_in_rect(pos, get_colored_band_rect()) &&
get_edited_tick_for_position(pos) >= 0 )
focused_item = fiColorBand;
m_focus = fiColorBand;
else {
focused_item = fiTick;
m_focus = fiTick;
tick = get_tick_near_point(pos);
}
}
@ -1038,7 +999,7 @@ void Control::OnMotion(wxMouseEvent& event)
event.Skip();
// Set tooltips with information for each icon
this->SetToolTip(get_tooltip(focused_item, tick));
this->SetToolTip(get_tooltip(tick));
if (action)
{
@ -1120,21 +1081,27 @@ void Control::OnLeftUp(wxMouseEvent& event)
this->ReleaseMouse();
m_is_left_down = false;
if (m_force_delete_tick)
{
switch (m_mouse) {
case maNone :
move_current_thumb_to_pos(event.GetLogicalPosition(wxClientDC(this)));
break;
case maDeleteTick :
delete_current_tick();
m_force_delete_tick = false;
}
else
if (m_force_add_tick)
{
break;
case maAddTick :
add_current_tick();
m_force_add_tick = false;
}
else
if (m_force_edit_extruder_sequence) {
edit_extruder_sequence();
m_force_edit_extruder_sequence = false;
break;
case maCogIconClick :
jump_to_print_z();
break;
case maOneLayerIconClick:
switch_one_layer_mode();
break;
case maRevertIconClick:
discard_all_thicks();
break;
default :
break;
}
Refresh();
@ -1261,6 +1228,8 @@ void Control::OnChar(wxKeyEvent& event)
delete_current_tick();
m_ticks.suppress_minus(false);
}
if (key == 'G')
jump_to_print_z();
}
void Control::OnRightDown(wxMouseEvent& event)
@ -1268,29 +1237,25 @@ void Control::OnRightDown(wxMouseEvent& event)
if (HasCapture()) return;
this->CaptureMouse();
const wxClientDC dc(this);
const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
wxPoint pos = event.GetLogicalPosition(dc);
if (m_is_enabled_tick_manipulation && is_point_in_rect(pos, m_rect_tick_action))
{
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
if (m_ticks.ticks.find(TickCode{ tick }) == m_ticks.ticks.end()) // if on this Z doesn't exist tick
// show context menu on OnRightUp()
m_show_context_menu = true;
else
// show "Edit" and "Delete" menu on OnRightUp()
m_show_edit_menu = true;
return;
m_mouse = maNone;
if (m_is_enabled_tick_manipulation) {
if (is_point_in_rect(pos, m_rect_tick_action))
{
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
m_mouse = m_ticks.ticks.find(TickCode{ tick }) == m_ticks.ticks.end() ?
maAddMenu : maEditMenu;
}
else if (m_mode == t_mode::SingleExtruder && is_point_in_rect(pos, get_colored_band_rect()))
m_mouse = maForceColorEdit;
else if (m_mode == t_mode::MultiAsSingle && is_point_in_rect(pos, m_rect_cog_icon))
m_mouse = maCogIconMenu;
}
if (m_is_enabled_tick_manipulation && m_mode == t_mode::SingleExtruder &&
is_point_in_rect(pos, get_colored_band_rect()))
{
m_force_color_edit = true;
if (m_mouse != maNone)
return;
}
detect_selected_slider(event.GetLogicalPosition(dc));
detect_selected_slider(pos);
if (!m_selection)
return;
@ -1396,6 +1361,60 @@ std::set<int> TickCodeInfo::get_used_extruders_for_tick(int tick, int only_extru
return used_extruders;
}
void Control::get_add_menu(wxMenu* menu)
{
if (m_mode == t_mode::SingleExtruder) {
append_menu_item(menu, wxID_ANY, _(L("Add color change")) + " (M600)", "",
[this](wxCommandEvent&) { add_code_as_tick(ColorChangeCode); }, "colorchange_add_m", menu);
UseDefaultColors(false);
}
else {
append_change_extruder_menu_item(menu);
append_add_color_change_menu_item(menu);
}
append_menu_item(menu, wxID_ANY, _(L("Add pause print")) + " (M601)", "",
[this](wxCommandEvent&) { add_code_as_tick(PausePrintCode); }, "pause_print", menu);
append_menu_item(menu, wxID_ANY, _(L("Add custom G-code")), "",
[this](wxCommandEvent&) { add_code_as_tick(""); }, "edit_gcode", menu);
}
void Control::get_edit_menu(wxMenu* menu)
{
std::set<TickCode>::iterator it = m_ticks.ticks.find(TickCode{ m_selection == ssLower ? m_lower_value : m_higher_value });
if (it->gcode == ToolChangeCode) {
if (m_mode == t_mode::MultiAsSingle)
append_change_extruder_menu_item(menu);
append_add_color_change_menu_item(menu, true);
}
else
append_menu_item( menu, wxID_ANY, it->gcode == ColorChangeCode ? _(L("Edit color")) :
it->gcode == PausePrintCode ? _(L("Edit pause print message")) :
_(L("Edit custom G-code")), "",
[this](wxCommandEvent&) { edit_tick(); }, "edit_uni", menu);
if (it->gcode == ColorChangeCode && m_mode == t_mode::MultiAsSingle)
append_change_extruder_menu_item(menu, true);
append_menu_item( menu, wxID_ANY, it->gcode == ColorChangeCode ? _(L("Delete color change")) :
it->gcode == ToolChangeCode ? _(L("Delete tool change")) :
it->gcode == PausePrintCode ? _(L("Delete pause print")) :
_(L("Delete custom G-code")), "",
[this](wxCommandEvent&) { delete_current_tick();}, "colorchange_del_f", menu);
}
void Control::get_cog_icon_menu(wxMenu* menu)
{
append_menu_item(menu, wxID_ANY, _(L("Jump to print Z")) + " (Shift+G)", "",
[this](wxCommandEvent&) { jump_to_print_z(); }, "", menu);
append_menu_item(menu, wxID_ANY, _(L("Set extruder sequence for whole print")), "",
[this](wxCommandEvent&) { edit_extruder_sequence(); }, "", menu);
}
void Control::OnRightUp(wxMouseEvent& event)
{
if (!HasCapture())
@ -1403,73 +1422,25 @@ void Control::OnRightUp(wxMouseEvent& event)
this->ReleaseMouse();
m_is_right_down = m_is_one_layer = false;
if (m_show_context_menu) {
wxMenu menu;
if (m_mode == t_mode::SingleExtruder) {
append_menu_item(&menu, wxID_ANY, _(L("Add color change")) + " (M600)", "",
[this](wxCommandEvent&) { add_code_as_tick(ColorChangeCode); }, "colorchange_add_m", &menu,
[](){return true;}, this);
UseDefaultColors(false);
}
else
{
append_change_extruder_menu_item(&menu);
append_add_color_change_menu_item(&menu);
}
append_menu_item(&menu, wxID_ANY, _(L("Add pause print")) + " (M601)", "",
[this](wxCommandEvent&) { add_code_as_tick(PausePrintCode); }, "pause_print", &menu,
[]() {return true; }, this);
append_menu_item(&menu, wxID_ANY, _(L("Add custom G-code")), "",
[this](wxCommandEvent&) { add_code_as_tick(""); }, "edit_gcode", &menu,
[]() {return true; }, this);
GUI::wxGetApp().plater()->PopupMenu(&menu);
m_show_context_menu = false;
}
else if (m_show_edit_menu) {
wxMenu menu;
std::set<TickCode>::iterator it = m_ticks.ticks.find(TickCode{ m_selection == ssLower ? m_lower_value : m_higher_value });
if (it->gcode == ToolChangeCode) {
if (m_mode == t_mode::MultiAsSingle)
append_change_extruder_menu_item(&menu);
append_add_color_change_menu_item(&menu, true);
}
else
append_menu_item(&menu, wxID_ANY, it->gcode == ColorChangeCode ? _(L("Edit color")) :
it->gcode == PausePrintCode ? _(L("Edit pause print message")) :
_(L("Edit custom G-code")), "",
[this](wxCommandEvent&) { edit_tick(); }, "edit_uni", &menu, []() {return true; }, this);
if (it->gcode == ColorChangeCode && m_mode == t_mode::MultiAsSingle)
append_change_extruder_menu_item(&menu, true);
append_menu_item(&menu, wxID_ANY, it->gcode == ColorChangeCode ? _(L("Delete color change")) :
it->gcode == ToolChangeCode ? _(L("Delete tool change")) :
it->gcode == PausePrintCode ? _(L("Delete pause print")) :
_(L("Delete custom G-code")), "",
[this](wxCommandEvent&) { delete_current_tick();}, "colorchange_del_f", &menu, []() {return true; }, this);
GUI::wxGetApp().plater()->PopupMenu(&menu);
m_show_edit_menu = false;
}
else if (m_force_color_edit)
if (m_mouse == maForceColorEdit)
{
const wxClientDC dc(this);
wxPoint pos = event.GetLogicalPosition(dc);
wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
int edited_tick = get_edited_tick_for_position(pos);
if (edited_tick >= 0)
edit_tick(edited_tick);
}
else
{
wxMenu menu;
m_force_color_edit = false;
if (m_mouse == maAddMenu)
get_add_menu(&menu);
else if (m_mouse == maEditMenu)
get_edit_menu(&menu);
else if (m_mouse == maCogIconMenu)
get_cog_icon_menu(&menu);
GUI::wxGetApp().plater()->PopupMenu(&menu);
}
Refresh();
@ -1494,9 +1465,11 @@ static std::string get_new_color(const std::string& color)
return "";
}
// To avoid get an empty string from wxTextEntryDialog
// Let disable OK button, if TextCtrl is empty
static void upgrade_text_entry_dialog(wxTextEntryDialog* dlg)
/* To avoid get an empty string from wxTextEntryDialog
* Let disable OK button, if TextCtrl is empty
* OR input value is our of range (min..max), when min a nd max are positive
* */
static void upgrade_text_entry_dialog(wxTextEntryDialog* dlg, double min = -1.0, double max = -1.0)
{
// detect TextCtrl and OK button
wxTextCtrl* textctrl {nullptr};
@ -1511,8 +1484,19 @@ static void upgrade_text_entry_dialog(wxTextEntryDialog* dlg)
return;
wxButton* btn_OK = static_cast<wxButton*>(dlg->FindWindowById(wxID_OK));
btn_OK->Bind(wxEVT_UPDATE_UI, [textctrl](wxUpdateUIEvent& evt) {
evt.Enable(!textctrl->IsEmpty());
btn_OK->Bind(wxEVT_UPDATE_UI, [textctrl, min, max](wxUpdateUIEvent& evt)
{
bool disable = textctrl->IsEmpty();
if (!disable && min >= 0.0 && max >= 0.0)
{
double value = -1.0;
if (!textctrl->GetValue().ToCDouble(&value)) // input value couldn't be converted to double
disable = true;
else
disable = value < min || value > max; // is input value is out of valid range ?
}
evt.Enable(!disable);
}, btn_OK->GetId());
}
@ -1548,6 +1532,23 @@ static std::string get_pause_print_msg(const std::string& msg_in, double height)
return into_u8(dlg.GetValue());
}
static double get_print_z_to_jump(double active_print_z, double min_z, double max_z)
{
wxString msg_text = _(L("Enter print z value to jump to")) + " :";
wxString msg_header = _(L("Jump to print z"));
wxString msg_in = GUI::double_to_string(active_print_z);
// get custom gcode
wxTextEntryDialog dlg(nullptr, msg_text, msg_header, msg_in, wxTextEntryDialogStyle);
upgrade_text_entry_dialog(&dlg, min_z, max_z);
if (dlg.ShowModal() != wxID_OK || dlg.GetValue().IsEmpty())
return -1.0;
double value = -1.0;
return dlg.GetValue().ToCDouble(&value) ? value : -1.0;
}
void Control::add_code_as_tick(std::string code, int selected_extruder/* = -1*/)
{
if (m_selection == ssUndef)
@ -1649,6 +1650,55 @@ void Control::edit_tick(int tick/* = -1*/)
post_ticks_changed_event(code);
}
// switch on/off one layer mode
void Control::switch_one_layer_mode()
{
m_is_one_layer = !m_is_one_layer;
if (!m_is_one_layer) {
SetLowerValue(m_min_value);
SetHigherValue(m_max_value);
}
m_selection == ssLower ? correct_lower_value() : correct_higher_value();
if (!m_selection) m_selection = ssHigher;
}
// discard all custom changes on DoubleSlider
void Control::discard_all_thicks()
{
SetLowerValue(m_min_value);
SetHigherValue(m_max_value);
m_selection == ssLower ? correct_lower_value() : correct_higher_value();
if (!m_selection) m_selection = ssHigher;
m_ticks.ticks.clear();
post_ticks_changed_event();
}
// Set current thumb position to the nearest tick (if it is)
// OR to a value corresponding to the mouse click (pos)
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 :
get_value_from_position(pos);
if (mouse_val >= 0)
{
// if (abs(mouse_val - m_lower_value) < abs(mouse_val - m_higher_value)) {
if (mouse_val <= m_lower_value) {
SetLowerValue(mouse_val);
correct_lower_value();
m_selection = ssLower;
}
else {
SetHigherValue(mouse_val);
correct_higher_value();
m_selection = ssHigher;
}
}
}
void Control::edit_extruder_sequence()
{
if (!check_ticks_changed_event(ToolChangeCode))
@ -1698,6 +1748,22 @@ void Control::edit_extruder_sequence()
post_ticks_changed_event(ToolChangeCode);
}
void Control::jump_to_print_z()
{
double print_z = get_print_z_to_jump(m_values[m_selection == ssLower ? m_lower_value : m_higher_value],
m_values[m_min_value], m_values[m_max_value]);
if (print_z < 0)
return;
auto it = std::lower_bound(m_values.begin(), m_values.end(), print_z - epsilon());
int tick_value = it - m_values.begin();
if (m_selection == ssLower)
SetLowerValue(tick_value);
else
SetHigherValue(tick_value);
}
void Control::post_ticks_changed_event(const std::string& gcode /*= ""*/)
{
m_force_mode_apply = (gcode.empty() || gcode == ColorChangeCode || gcode == ToolChangeCode);

View file

@ -33,7 +33,7 @@ enum SelectedSlider {
ssHigher
};
enum FocusItem {
enum FocusedItem {
fiNone,
fiRevertIcon,
fiOneLayerIcon,
@ -52,6 +52,20 @@ enum ConflictType
ctRedundant
};
enum MouseAction
{
maNone,
maAddMenu, // show "Add" context menu for NOTexist active tick
maEditMenu, // show "Edit" context menu for exist active tick
maCogIconMenu, // show context for "cog" icon
maForceColorEdit, // force color editing from colored band
maAddTick, // force tick adding
maDeleteTick, // force tick deleting
maCogIconClick, // LeftMouseClick on "cog" icon
maOneLayerIconClick, // LeftMouseClick on "one_layer" icon
maRevertIconClick, // LeftMouseClick on "revert" icon
};
using t_mode = CustomGCode::Mode;
struct TickCode
@ -188,17 +202,7 @@ public:
void SetManipulationMode(t_mode mode) { m_mode = mode; }
t_mode GetManipulationMode() const { return m_mode; }
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder)
{
m_mode = !is_one_extruder_printed_model ? t_mode::MultiExtruder :
only_extruder < 0 ? t_mode::SingleExtruder :
t_mode::MultiAsSingle;
if (!m_ticks.mode)
m_ticks.mode = m_mode;
m_only_extruder = only_extruder;
UseDefaultColors(m_mode == t_mode::SingleExtruder);
}
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder);
bool is_horizontal() const { return m_style == wxSL_HORIZONTAL; }
bool is_one_layer() const { return m_is_one_layer; }
@ -226,7 +230,14 @@ public:
// delete current tick, when press "-"
void delete_current_tick();
void edit_tick(int tick = -1);
void switch_one_layer_mode();
void discard_all_thicks();
void move_current_thumb_to_pos(wxPoint pos);
void edit_extruder_sequence();
void jump_to_print_z();
void get_add_menu(wxMenu *menu);
void get_edit_menu(wxMenu *menu);
void get_cog_icon_menu(wxMenu *menu);
ExtrudersSequence m_extruders_sequence;
@ -268,7 +279,7 @@ private:
wxSize get_size();
void get_size(int *w, int *h);
double get_double_value(const SelectedSlider& selection);
wxString get_tooltip(FocusItem focused_item, int tick = -1);
wxString get_tooltip(int tick = -1);
int get_edited_tick_for_position(wxPoint pos, const std::string& gcode = ColorChangeCode);
std::string get_color_for_tool_change_tick(std::set<TickCode>::const_iterator it) const;
@ -310,19 +321,15 @@ private:
bool m_is_right_down = false;
bool m_is_one_layer = false;
bool m_is_focused = false;
bool m_is_action_icon_focesed = false;
bool m_is_one_layer_icon_focesed = false;
bool m_is_enabled_tick_manipulation = true;
bool m_show_context_menu = false;
bool m_show_edit_menu = false;
bool m_force_edit_extruder_sequence = false;
bool m_force_mode_apply = true;
bool m_force_add_tick = false;
bool m_force_delete_tick = false;
bool m_force_color_edit = false;
t_mode m_mode = t_mode::SingleExtruder;
int m_only_extruder = -1;
MouseAction m_mouse = maNone;
FocusedItem m_focus = fiNone;
wxRect m_rect_lower_thumb;
wxRect m_rect_higher_thumb;
wxRect m_rect_tick_action;

View file

@ -1985,7 +1985,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
"extruder_colour", "filament_colour", "max_print_height", "printer_model", "printer_technology",
// These values are necessary to construct SlicingParameters by the Canvas3D variable layer height editor.
"layer_height", "first_layer_height", "min_layer_height", "max_layer_height",
"brim_width", "perimeters", "perimeter_extruder", "fill_density", "infill_extruder", "top_solid_layers", "bottom_solid_layers", "solid_infill_extruder",
"brim_width", "perimeters", "perimeter_extruder", "fill_density", "infill_extruder", "top_solid_layers",
"support_material", "support_material_extruder", "support_material_interface_extruder", "support_material_contact_distance", "raft_layers"
}))
, sidebar(new Sidebar(q))

View file

@ -386,7 +386,8 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
const std::vector<std::string>& Preset::print_options()
{
static std::vector<std::string> s_opts {
"layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius", "top_solid_layers", "bottom_solid_layers",
"layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius",
"top_solid_layers", "top_solid_min_thickness", "bottom_solid_layers", "bottom_solid_min_thickness",
"extra_perimeters", "ensure_vertical_shell_thickness", "avoid_crossing_perimeters", "thin_walls", "overhangs",
"seam_position", "external_perimeters_first", "fill_density", "fill_pattern", "top_fill_pattern", "bottom_fill_pattern",
"infill_every_layers", "infill_only_where_needed", "solid_infill_every_layers", "fill_angle", "bridge_angle",

View file

@ -1,6 +1,7 @@
#include <cassert>
#include "libslic3r/Flow.hpp"
#include "libslic3r/Slicing.hpp"
#include "libslic3r/libslic3r.h"
#include "PresetBundle.hpp"
@ -242,7 +243,7 @@ std::string PresetHints::recommended_thin_wall_thickness(const PresetBundle &pre
float nozzle_diameter = float(printer_config.opt_float("nozzle_diameter", 0));
std::string out;
if (layer_height <= 0.f){
if (layer_height <= 0.f) {
out += _utf8(L("Recommended object thin wall thickness: Not available due to invalid layer height."));
return out;
}
@ -272,4 +273,70 @@ std::string PresetHints::recommended_thin_wall_thickness(const PresetBundle &pre
return out;
}
// Produce a textual explanation of the combined effects of the top/bottom_solid_layers
// versus top/bottom_min_shell_thickness. Which of the two values wins depends
// on the active layer height.
std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBundle &preset_bundle)
{
const DynamicPrintConfig &print_config = preset_bundle.prints .get_edited_preset().config;
const DynamicPrintConfig &printer_config = preset_bundle.printers .get_edited_preset().config;
std::string out;
int top_solid_layers = print_config.opt_int("top_solid_layers");
int bottom_solid_layers = print_config.opt_int("bottom_solid_layers");
bool has_top_layers = top_solid_layers > 0;
bool has_bottom_layers = bottom_solid_layers > 0;
bool has_shell = has_top_layers && has_bottom_layers;
double top_solid_min_thickness = print_config.opt_float("top_solid_min_thickness");
double bottom_solid_min_thickness = print_config.opt_float("bottom_solid_min_thickness");
double layer_height = print_config.opt_float("layer_height");
bool variable_layer_height = printer_config.opt_bool("variable_layer_height");
//FIXME the following lines take into account the 1st extruder only.
double min_layer_height = (has_shell && variable_layer_height) ? Slicing::min_layer_height_from_nozzle(printer_config, 1) : layer_height;
double max_layer_height = (has_shell && variable_layer_height) ? Slicing::max_layer_height_from_nozzle(printer_config, 1) : layer_height;
if (layer_height <= 0.f) {
out += _utf8(L("Top / bottom shell thickness hint: Not available due to invalid layer height."));
return out;
}
if (has_top_layers) {
double top_shell_thickness = top_solid_layers * layer_height;
if (top_shell_thickness < top_solid_min_thickness) {
// top_solid_min_shell_thickness triggers even in case of normal layer height. Round the top_shell_thickness up
// to an integer multiply of layer_height.
double n = ceil(top_solid_min_thickness / layer_height);
top_shell_thickness = n * layer_height;
}
double top_shell_thickness_minimum = std::max(top_solid_min_thickness, top_solid_layers * min_layer_height);
out += (boost::format(_utf8(L("Top shell is %1% mm thick for layer height %2% mm."))) % top_shell_thickness % layer_height).str();
if (variable_layer_height && top_shell_thickness_minimum < top_shell_thickness) {
out += " ";
out += (boost::format(_utf8(L("Minimum top shell thickness is %1% mm."))) % top_shell_thickness_minimum).str();
}
}
if (has_bottom_layers) {
double bottom_shell_thickness = bottom_solid_layers * layer_height;
if (bottom_shell_thickness < bottom_solid_min_thickness) {
// bottom_solid_min_shell_thickness triggers even in case of normal layer height. Round the bottom_shell_thickness up
// to an integer multiply of layer_height.
double n = ceil(bottom_solid_min_thickness / layer_height);
bottom_shell_thickness = n * layer_height;
}
double bottom_shell_thickness_minimum = std::max(bottom_solid_min_thickness, bottom_solid_layers * min_layer_height);
if (! out.empty())
out += "\n";
out += (boost::format(_utf8(L("Bottom shell is %1% mm thick for layer height %2% mm."))) % bottom_shell_thickness % layer_height).str();
if (variable_layer_height && bottom_shell_thickness_minimum < bottom_shell_thickness) {
out += " ";
out += (boost::format(_utf8(L("Minimum bottom shell thickness is %1% mm."))) % bottom_shell_thickness_minimum).str();
}
}
return out;
}
}; // namespace Slic3r

View file

@ -23,6 +23,11 @@ public:
// Produce a textual description of a recommended thin wall thickness
// from the provided number of perimeters and the external / internal perimeter width.
static std::string recommended_thin_wall_thickness(const PresetBundle &preset_bundle);
// Produce a textual explanation of the combined effects of the top/bottom_solid_layers
// versus top/bottom_min_shell_thickness. Which of the two values wins depends
// on the active layer height.
static std::string top_bottom_shell_thickness_explanation(const PresetBundle &preset_bundle);
};
} // namespace Slic3r

View file

@ -1056,6 +1056,16 @@ void TabPrint::build()
line.append_option(optgroup->get_option("top_solid_layers"));
line.append_option(optgroup->get_option("bottom_solid_layers"));
optgroup->append_line(line);
line = { _(L("Minimum shell thickness")), "" };
line.append_option(optgroup->get_option("top_solid_min_thickness"));
line.append_option(optgroup->get_option("bottom_solid_min_thickness"));
optgroup->append_line(line);
line = { "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
return description_line_widget(parent, &m_top_bottom_shell_thickness_explanation);
};
optgroup->append_line(line);
optgroup = page->new_optgroup(_(L("Quality (slower slicing)")));
optgroup->append_single_option_line("extra_perimeters");
@ -1277,6 +1287,8 @@ void TabPrint::update()
m_recommended_thin_wall_thickness_description_line->SetText(
from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)));
m_top_bottom_shell_thickness_explanation->SetText(
from_u8(PresetHints::top_bottom_shell_thickness_explanation(*m_preset_bundle)));
Layout();
// Thaw();
@ -1295,6 +1307,8 @@ void TabPrint::OnActivate()
{
m_recommended_thin_wall_thickness_description_line->SetText(
from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)));
m_top_bottom_shell_thickness_explanation->SetText(
from_u8(PresetHints::top_bottom_shell_thickness_explanation(*m_preset_bundle)));
Tab::OnActivate();
}

View file

@ -327,8 +327,9 @@ public:
Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_PRINT) {}
~TabPrint() {}
ogStaticText* m_recommended_thin_wall_thickness_description_line;
bool m_support_material_overhangs_queried = false;
ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr;
ogStaticText* m_top_bottom_shell_thickness_explanation = nullptr;
bool m_support_material_overhangs_queried = false;
void build() override;
void reload_config() override;
@ -336,6 +337,7 @@ public:
void OnActivate() override;
bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptFFF; }
};
class TabFilament : public Tab
{
ogStaticText* m_volumetric_speed_description_line;