Fixed conflicts after merge with master

This commit is contained in:
enricoturri1966 2020-11-25 12:42:26 +01:00
commit f0aa4de20a
39 changed files with 467 additions and 402 deletions

View file

@ -87,7 +87,7 @@ void Bed_2D::repaint(const std::vector<Vec2d>& shape)
for (auto y = bb.min(1) - fmod(bb.min(1), step) + step; y < bb.max(1); y += step) {
polylines.push_back(Polyline::new_scale({ Vec2d(bb.min(0), y), Vec2d(bb.max(0), y) }));
}
polylines = intersection_pl(polylines, bed_polygon);
polylines = intersection_pl(polylines, (Polygons)bed_polygon);
dc.SetPen(wxPen(wxColour(230, 230, 230), 1, wxPENSTYLE_SOLID));
for (auto pl : polylines)

View file

@ -237,8 +237,11 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
bool have_infill = config->option<ConfigOptionPercent>("fill_density")->value > 0;
// infill_extruder uses the same logic as in Print::extruders()
for (auto el : { "fill_pattern", "infill_every_layers", "infill_only_where_needed",
"solid_infill_every_layers", "solid_infill_below_area", "infill_extruder" })
"solid_infill_every_layers", "solid_infill_below_area", "infill_extruder", "infill_anchor_max" })
toggle_field(el, have_infill);
// Only allow configuration of open anchors if the anchoring is enabled.
bool has_infill_anchors = have_infill && config->option<ConfigOptionFloatOrPercent>("infill_anchor_max")->value > 0;
toggle_field("infill_anchor", has_infill_anchors);
bool has_spiral_vase = config->opt_bool("spiral_vase");
bool has_top_solid_infill = config->opt_int("top_solid_layers") > 0;

View file

@ -569,7 +569,7 @@ void Control::draw_tick_on_mouse_position(wxDC& dc)
if (m_extra_style & wxSL_VALUE_LABEL) {
wxColour old_clr = dc.GetTextForeground();
dc.SetTextForeground(LIGHT_GREY_PEN.GetColour());
dc.SetTextForeground(GREY_PEN.GetColour());
draw_tick_text(dc, pos, tick, ltEstimatedTime, false);
dc.SetTextForeground(old_clr);
}
@ -893,6 +893,11 @@ void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, do
int DPI = GUI::get_dpi_for_window(win);
int pixels_per_sm = lround((double)(DPI) * 5.0/25.4);
if (lround(scroll_step) > pixels_per_sm) {
long_step = -1.0;
return;
}
int pow = -2;
int step = 0;
auto end_it = count == 1 ? values.end() : values.begin() + lround(values.size() / count);
@ -907,15 +912,15 @@ void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, do
break;
int tick = val_it - values.begin();
if (lround(tick * scroll_step) > pixels_per_sm) {
step = istep;
// find next tick with istep
val *= 2;
val_it = std::lower_bound(values.begin(), end_it, val - epsilon());
// count of short ticks between ticks
int short_ticks_cnt = val_it == values.end() ? tick : val_it - values.begin() - tick;
// find next tick with istep
val *= 2;
val_it = std::lower_bound(values.begin(), end_it, val - epsilon());
// count of short ticks between ticks
int short_ticks_cnt = val_it == values.end() ? tick : val_it - values.begin() - tick;
// there couldn't be more then 10 short ticks between thicks
if (lround(short_ticks_cnt * scroll_step) > pixels_per_sm) {
step = istep;
// there couldn't be more then 10 short ticks between ticks
short_step = 0.1 * short_ticks_cnt;
break;
}
@ -931,71 +936,77 @@ void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, do
void Control::draw_ruler(wxDC& dc)
{
m_ruler.update(this->GetParent(), m_values, get_scroll_step());
if (!m_ruler.is_ok())
return;
int height, width;
get_size(&width, &height);
const wxCoord mid = is_horizontal() ? 0.5 * height : 0.5 * width;
const wxCoord mid = is_horizontal() ? 0.5 * height : 0.5 * width;
auto draw_short_ticks = [this, mid](wxDC& dc, double& current_tick, int max_tick) {
while (current_tick < max_tick) {
wxCoord pos = get_position_from_value(lround(current_tick));
draw_ticks_pair(dc, pos, mid, 2);
current_tick += m_ruler.short_step;
if (current_tick > m_max_value)
break;
}
};
dc.SetPen(LIGHT_GREY_PEN);
dc.SetPen(GREY_PEN);
wxColour old_clr = dc.GetTextForeground();
dc.SetTextForeground(LIGHT_GREY_PEN.GetColour());
dc.SetTextForeground(GREY_PEN.GetColour());
double short_tick;
int tick = 0;
double value = 0.0;
int sequence = 0;
while (tick <= m_max_value) {
value += m_ruler.long_step;
if (value > m_values.back() && sequence < m_ruler.count) {
value = m_ruler.long_step;
for (tick; tick < m_values.size(); tick++)
if (m_values[tick] < value)
break;
// short ticks from the last tick to the end of current sequence
draw_short_ticks(dc, short_tick, tick);
sequence++;
if (m_ruler.long_step < 0)
for (int tick = 1; tick < m_values.size(); tick++) {
wxCoord pos = get_position_from_value(tick);
draw_ticks_pair(dc, pos, mid, 5);
draw_tick_text(dc, wxPoint(mid, pos), tick);
}
short_tick = tick;
else {
auto draw_short_ticks = [this, mid](wxDC& dc, double& current_tick, int max_tick) {
while (current_tick < max_tick) {
wxCoord pos = get_position_from_value(lround(current_tick));
draw_ticks_pair(dc, pos, mid, 2);
current_tick += m_ruler.short_step;
if (current_tick > m_max_value)
break;
}
};
for (tick; tick < m_values.size(); tick++) {
if (m_values[tick] == value)
break;
if (m_values[tick] > value) {
if (tick > 0)
tick--;
double short_tick;
int tick = 0;
double value = 0.0;
int sequence = 0;
while (tick <= m_max_value) {
value += m_ruler.long_step;
if (value > m_values.back() && sequence < m_ruler.count) {
value = m_ruler.long_step;
for (tick; tick < m_values.size(); tick++)
if (m_values[tick] < value)
break;
// short ticks from the last tick to the end of current sequence
draw_short_ticks(dc, short_tick, tick);
sequence++;
}
short_tick = tick;
for (tick; tick < m_values.size(); tick++) {
if (m_values[tick] == value)
break;
if (m_values[tick] > value) {
if (tick > 0)
tick--;
break;
}
}
if (tick > m_max_value)
break;
wxCoord pos = get_position_from_value(tick);
draw_ticks_pair(dc, pos, mid, 5);
draw_tick_text(dc, wxPoint(mid, pos), tick);
draw_short_ticks(dc, short_tick, tick);
if (value == m_values.back() && sequence < m_ruler.count) {
value = 0.0;
sequence++;
tick++;
}
}
if (tick > m_max_value)
break;
wxCoord pos = get_position_from_value(tick);
draw_ticks_pair(dc, pos, mid, 5);
draw_tick_text(dc, wxPoint(mid, pos), tick);
draw_short_ticks(dc, short_tick, tick);
if (value == m_values.back() && sequence < m_ruler.count) {
value = 0.0;
sequence++;
tick++;
}
// short ticks from the last tick to the end
draw_short_ticks(dc, short_tick, m_max_value);
}
// short ticks from the last tick to the end
draw_short_ticks(dc, short_tick, m_max_value);
dc.SetTextForeground(old_clr);
}

View file

@ -862,7 +862,19 @@ void Choice::BUILD() {
#endif
// temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; });
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; });
temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent evt) {
if (m_suppress_scroll) {
if (!m_is_dropped) {
temp->SetSelection(m_last_selected);
return;
}
m_last_selected = evt.GetSelection();
}
on_change_field();
}), temp->GetId());
if (m_is_editable) {
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
@ -876,8 +888,7 @@ void Choice::BUILD() {
if (is_defined_input_value<choice_ctrl>(window, m_opt.type)) {
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
return;
else
on_change_field();
on_change_field();
}
else
on_kill_focus();
@ -887,6 +898,13 @@ void Choice::BUILD() {
temp->SetToolTip(get_tooltip_text(temp->GetValue()));
}
void Choice::suppress_scroll()
{
m_suppress_scroll = true;
choice_ctrl* ctrl = dynamic_cast<choice_ctrl*>(window);
m_last_selected = ctrl->GetSelection();
}
void Choice::set_selection()
{
/* To prevent earlier control updating under OSX set m_disable_change_event to true
@ -901,6 +919,7 @@ void Choice::set_selection()
case coEnum:{
int id_value = m_opt.get_default_value<ConfigOptionEnum<SeamPosition>>()->value; //!!
field->SetSelection(id_value);
if (m_suppress_scroll) m_last_selected = id_value;
break;
}
case coFloat:
@ -934,6 +953,8 @@ void Choice::set_selection()
++idx;
}
idx == m_opt.enum_values.size() ? field->SetValue(text_value) : field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
}
}
@ -953,6 +974,7 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda
idx == m_opt.enum_values.size() ?
field->SetValue(value) :
field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
m_disable_change_event = false;
}
@ -990,6 +1012,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
}
else
field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
break;
}
case coEnum: {
@ -1020,6 +1043,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
val = 0;
}
field->SetSelection(val);
if (m_suppress_scroll) m_last_selected = val;
break;
}
default:
@ -1179,6 +1203,7 @@ void Choice::msw_rescale()
idx == m_opt.enum_values.size() ?
field->SetValue(selection) :
field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
#else
auto size = wxSize(def_width_wider() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);

View file

@ -385,7 +385,10 @@ public:
/* Under OSX: wxBitmapComboBox->GetWindowStyle() returns some weard value,
* so let use a flag, which has TRUE value for a control without wxCB_READONLY style
*/
bool m_is_editable { false };
bool m_is_editable { false };
bool m_is_dropped { false };
bool m_suppress_scroll { false };
int m_last_selected { wxNOT_FOUND };
void set_selection();
void set_value(const std::string& value, bool change_event = false);
@ -399,6 +402,8 @@ public:
void enable() override ;//{ dynamic_cast<wxBitmapComboBox*>(window)->Enable(); };
void disable() override;//{ dynamic_cast<wxBitmapComboBox*>(window)->Disable(); };
wxWindow* getWindow() override { return window; }
void suppress_scroll();
};
class ColourPicker : public Field {

View file

@ -3892,7 +3892,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
settings_changed = true;
}
if (imgui->checkbox(_(L("Enable rotations")), settings.enable_rotation)) {
if (imgui->checkbox(_(L("Enable rotations (slow)")), settings.enable_rotation)) {
m_arrange_settings.enable_rotation = settings.enable_rotation;
settings_changed = true;
}

View file

@ -158,14 +158,14 @@ void ArrangeJob::process()
params.stopcondition = [this]() { return was_canceled(); };
try {
params.progressind = [this, count](unsigned st) {
params.progressind = [this, count](unsigned st, unsigned) {
st += m_unprintable.size();
if (st > 0) update_status(int(count - st), arrangestr);
};
arrangement::arrange(m_selected, m_unselected, bedpts, params);
params.progressind = [this, count](unsigned st) {
params.progressind = [this, count](unsigned st, unsigned) {
if (st > 0) update_status(int(count - st), arrangestr);
};

View file

@ -90,9 +90,13 @@ void FillBedJob::process()
params.min_obj_distance = scaled(settings.distance);
params.allow_rotations = settings.enable_rotation;
params.stopcondition = [this]() { return was_canceled(); };
unsigned curr_bed = 0;
params.stopcondition = [this, &curr_bed]() {
return was_canceled() || curr_bed > 0;
};
params.progressind = [this](unsigned st) {
params.progressind = [this, &curr_bed](unsigned st, unsigned bed) {
curr_bed = bed;
if (st > 0)
update_status(int(m_status_range - st), _(L("Filling bed")));
};

View file

@ -439,6 +439,9 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
m_og->activate();
Choice* choice = dynamic_cast<Choice*>(m_og->get_field("support"));
choice->suppress_scroll();
// Frequently changed parameters for SLA_technology
m_og_sla = std::make_shared<ConfigOptionsGroup>(parent, "");
m_og_sla->hide_labels();

View file

@ -256,8 +256,8 @@ void PreferencesDialog::build()
create_settings_mode_widget();
}
if (is_editor) {
#if ENABLE_ENVIRONMENT_MAP
if (is_editor) {
m_optgroup_render = std::make_shared<ConfigOptionsGroup>(this, _L("Render"));
m_optgroup_render->label_width = 40;
m_optgroup_render->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
@ -272,8 +272,8 @@ void PreferencesDialog::build()
m_optgroup_render->append_single_option_line(option);
m_optgroup_render->activate();
#endif // ENABLE_ENVIRONMENT_MAP
}
#endif // ENABLE_ENVIRONMENT_MAP
auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_optgroup_general->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
@ -293,13 +293,13 @@ void PreferencesDialog::build()
SetSizer(sizer);
sizer->SetSizeHints(this);
this->CenterOnParent();
}
void PreferencesDialog::accept()
{
if (m_values.find("no_defaults") != m_values.end()) {
if (m_values.find("no_defaults") != m_values.end())
warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
}
auto app_config = get_app_config();
@ -308,9 +308,9 @@ void PreferencesDialog::accept()
m_seq_top_layer_only_changed = app_config->get("seq_top_layer_only") != it->second;
m_settings_layout_changed = false;
for (const std::string& key : {"old_settings_layout_mode",
"new_settings_layout_mode",
"dlg_settings_layout_mode" })
for (const std::string& key : { "old_settings_layout_mode",
"new_settings_layout_mode",
"dlg_settings_layout_mode" })
{
auto it = m_values.find(key);
if (it != m_values.end() && app_config->get(key) != it->second) {
@ -319,8 +319,7 @@ void PreferencesDialog::accept()
}
}
for (const std::string& key : {"default_action_on_close_application", "default_action_on_select_preset"})
{
for (const std::string& key : {"default_action_on_close_application", "default_action_on_select_preset"}) {
auto it = m_values.find(key);
if (it != m_values.end() && it->second != "none" && app_config->get(key) != "none")
m_values.erase(it); // we shouldn't change value, if some of those parameters was selected, and then deselected
@ -421,9 +420,9 @@ void PreferencesDialog::create_icon_size_slider()
void PreferencesDialog::create_settings_mode_widget()
{
wxString choices[] = { _L("Old regular layout with the tab bar"),
_L("New layout, access via settings button in the top menu"),
_L("Settings in non-modal window") };
wxString choices[] = { _L("Old regular layout with the tab bar"),
_L("New layout, access via settings button in the top menu"),
_L("Settings in non-modal window") };
auto app_config = get_app_config();
int selection = app_config->get("old_settings_layout_mode") == "1" ? 0 :
@ -432,14 +431,13 @@ void PreferencesDialog::create_settings_mode_widget()
wxWindow* parent = m_optgroup_gui->ctrl_parent();
m_layout_mode_box = new wxRadioBox(parent, wxID_ANY, _L("Layout Options"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(choices), choices,
3, wxRA_SPECIFY_ROWS);
m_layout_mode_box = new wxRadioBox(parent, wxID_ANY, _L("Layout Options"), wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices), choices, 3, wxRA_SPECIFY_ROWS);
m_layout_mode_box->SetFont(wxGetApp().normal_font());
m_layout_mode_box->SetSelection(selection);
m_layout_mode_box->Bind(wxEVT_RADIOBOX, [this](wxCommandEvent& e) {
int selection = e.GetSelection();
m_values["old_settings_layout_mode"] = boost::any_cast<bool>(selection == 0) ? "1" : "0";
m_values["new_settings_layout_mode"] = boost::any_cast<bool>(selection == 1) ? "1" : "0";
m_values["dlg_settings_layout_mode"] = boost::any_cast<bool>(selection == 2) ? "1" : "0";
@ -447,7 +445,6 @@ void PreferencesDialog::create_settings_mode_widget()
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_layout_mode_box, 1, wxALIGN_CENTER_VERTICAL);
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND);
}

View file

@ -103,6 +103,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
// parameters for an icon's drawing
fill_width_height();
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent& evt) { m_suppress_change = false; });
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent& evt) { m_suppress_change = true ; });
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
@ -147,6 +149,15 @@ bool PresetComboBox::set_printer_technology(PrinterTechnology pt)
return false;
}
bool PresetComboBox::check_event_for_suppress_change(wxCommandEvent& evt)
{
if (m_suppress_change) {
evt.StopPropagation();
SetSelection(m_last_selected);
}
return m_suppress_change;
}
void PresetComboBox::invalidate_selection()
{
m_last_selected = INT_MAX; // this value means that no one item is selected
@ -534,6 +545,8 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
PresetComboBox(parent, preset_type, wxSize(15 * wxGetApp().em_unit(), -1))
{
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
if (check_event_for_suppress_change(evt))
return;
auto selected_item = evt.GetSelection();
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
@ -871,6 +884,8 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type)
PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1))
{
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
if (check_event_for_suppress_change(evt))
return;
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender")
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.

View file

@ -86,6 +86,7 @@ protected:
int m_last_selected;
int m_em_unit;
bool m_suppress_change { true };
// parameters for an icon's drawing
int icon_height;
@ -98,6 +99,7 @@ protected:
PrinterTechnology printer_technology {ptAny};
bool check_event_for_suppress_change(wxCommandEvent& evt);
void invalidate_selection();
void validate_selection(bool predicate = false);
void update_selection();

View file

@ -1423,6 +1423,7 @@ void TabPrint::build()
optgroup->append_single_option_line("fill_density", category_path + "fill-density");
optgroup->append_single_option_line("fill_pattern", category_path + "fill-pattern");
optgroup->append_single_option_line("infill_anchor", category_path + "fill-pattern");
optgroup->append_single_option_line("infill_anchor_max", category_path + "fill-pattern");
optgroup->append_single_option_line("top_fill_pattern", category_path + "top-fill-pattern");
optgroup->append_single_option_line("bottom_fill_pattern", category_path + "bottom-fill-pattern");