Merge branch 'SoftFever:main' into main

This commit is contained in:
Bernhard Koppensteiner 2024-05-05 13:12:44 +02:00 committed by GitHub
commit 5ab7de1de6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 75 additions and 168 deletions

View file

@ -18,6 +18,7 @@
#include "../PrintConfig.hpp"
#include "../Surface.hpp"
#include "ExtrusionEntity.hpp"
#include "FillBase.hpp"
#include "FillRectilinear.hpp"
#include "FillLightning.hpp"
@ -40,6 +41,7 @@ struct SurfaceFillParams
coordf_t overlap = 0.;
// Angle as provided by the region config, in radians.
float angle = 0.f;
bool rotate_angle = true;
// Is bridging used for this fill? Bridging parameters may be used even if this->flow.bridge() is not set.
bool bridge;
// Non-negative for a bridge.
@ -83,6 +85,7 @@ struct SurfaceFillParams
RETURN_COMPARE_NON_EQUAL(spacing);
RETURN_COMPARE_NON_EQUAL(overlap);
RETURN_COMPARE_NON_EQUAL(angle);
RETURN_COMPARE_NON_EQUAL(rotate_angle);
RETURN_COMPARE_NON_EQUAL(density);
// RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, dont_adjust);
RETURN_COMPARE_NON_EQUAL(anchor_length);
@ -105,6 +108,7 @@ struct SurfaceFillParams
this->spacing == rhs.spacing &&
this->overlap == rhs.overlap &&
this->angle == rhs.angle &&
this->rotate_angle == rhs.rotate_angle &&
this->bridge == rhs.bridge &&
this->bridge_angle == rhs.bridge_angle &&
this->density == rhs.density &&
@ -491,9 +495,12 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
}
}
params.bridge_angle = float(surface.bridge_angle);
params.angle = float(Geometry::deg2rad(region_config.infill_direction.value));
// Calculate the actual flow we'll be using for this infill.
params.angle = float(Geometry::deg2rad(params.extrusion_role == erInternalInfill ?
region_config.infill_direction :
region_config.solid_infill_direction.value));
params.rotate_angle = (params.extrusion_role != erInternalInfill) && region_config.rotate_solid_infill_direction;
// Calculate the actual flow we'll be using for this infill.
params.bridge = is_bridge || Fill::use_bridge_flow(params.pattern);
const bool is_thick_bridge = surface.is_bridge() && (surface.is_internal_bridge() ? object_config.thick_internal_bridges : object_config.thick_bridges);
params.flow = params.bridge ?
@ -647,8 +654,9 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
else
params.pattern = ipRectilinear;
params.density = 100.f;
params.extrusion_role = erInternalInfill;
params.angle = float(Geometry::deg2rad(layerm.region().config().infill_direction.value));
params.extrusion_role = erSolidInfill;
params.angle = float(Geometry::deg2rad(layerm.region().config().solid_infill_direction.value));
params.rotate_angle = layerm.region().config().rotate_solid_infill_direction;
// calculate the actual flow we'll be using for this infill
params.flow = layerm.flow(frSolidInfill);
params.spacing = params.flow.spacing();
@ -752,6 +760,7 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
f->layer_id = this->id();
f->z = this->print_z;
f->angle = surface_fill.params.angle;
f->rotate_angle = surface_fill.params.rotate_angle;
f->adapt_fill_octree = (surface_fill.params.pattern == ipSupportCubic) ? support_fill_octree : adaptive_fill_octree;
f->print_config = &this->object()->print()->config();
f->print_object_config = &this->object()->config();

View file

@ -94,6 +94,8 @@ public:
coordf_t overlap;
// in radians, ccw, 0 = East
float angle;
// Orca: enable angle shifting for layer change
bool rotate_angle{ true };
// In scaled coordinates. Maximum lenght of a perimeter segment connecting two infill lines.
// Used by the FillRectilinear2, FillGrid2, FillTriangles, FillStars and FillCubic.
// If left to zero, the links will not be limited.
@ -150,6 +152,7 @@ protected:
overlap(0.),
// Initial angle is undefined.
angle(FLT_MAX),
rotate_angle(true),
link_max_length(0),
loop_clipping(0),
// The initial bounding box is empty, therefore undefined.
@ -171,7 +174,7 @@ protected:
ExPolygon expolygon,
ThickPolylines& thick_polylines_out) {}
virtual float _layer_angle(size_t idx) const { return (idx & 1) ? float(M_PI/2.) : 0; }
virtual float _layer_angle(size_t idx) const { return (rotate_angle && (idx & 1)) ? float(M_PI/2.) : 0; }
virtual std::pair<float, Point> _infill_direction(const Surface *surface) const;

View file

@ -772,7 +772,7 @@ static std::vector<std::string> s_Preset_print_options {
"top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness",
"extra_perimeters_on_overhangs", "ensure_vertical_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", "overhang_reverse", "overhang_reverse_threshold","overhang_reverse_internal_only", "wall_direction",
"seam_position", "staggered_inner_seams", "wall_sequence", "is_infill_first", "sparse_infill_density", "sparse_infill_pattern", "top_surface_pattern", "bottom_surface_pattern",
"infill_direction", "counterbore_hole_bridging",
"infill_direction", "solid_infill_direction", "rotate_solid_infill_direction", "counterbore_hole_bridging",
"minimum_sparse_infill_area", "reduce_infill_retraction","internal_solid_infill_pattern","gap_fill_target",
"ironing_type", "ironing_pattern", "ironing_flow", "ironing_speed", "ironing_spacing", "ironing_angle",
"max_travel_detour_distance",

View file

@ -2009,7 +2009,7 @@ def = this->add("filament_loading_speed", coFloats);
def->cli = ConfigOptionDef::nocli;
def = this->add("infill_direction", coFloat);
def->label = L("Infill direction");
def->label = L("Sparse infill direction");
def->category = L("Strength");
def->tooltip = L("Angle for sparse infill pattern, which controls the start or main direction of line");
def->sidetext = L("°");
@ -2018,6 +2018,23 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(45));
def = this->add("solid_infill_direction", coFloat);
def->label = L("Solid infill direction");
def->category = L("Strength");
def->tooltip = L("Angle for solid infill pattern, which controls the start or main direction of line");
def->sidetext = L("°");
def->min = 0;
def->max = 360;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(45));
def = this->add("rotate_solid_infill_direction", coBool);
def->label = L("Rotate solid infill direction");
def->category = L("Strength");
def->tooltip = L("Rotate the solid infill direction by 90° for each layer.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true));
def = this->add("sparse_infill_density", coPercent);
def->label = L("Sparse infill density");
def->category = L("Strength");

View file

@ -882,6 +882,8 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloatOrPercent, outer_wall_line_width))
((ConfigOptionFloat, outer_wall_speed))
((ConfigOptionFloat, infill_direction))
((ConfigOptionFloat, solid_infill_direction))
((ConfigOptionBool, rotate_solid_infill_direction))
((ConfigOptionPercent, sparse_infill_density))
((ConfigOptionEnum<InfillPattern>, sparse_infill_pattern))
((ConfigOptionEnum<FuzzySkinType>, fuzzy_skin))

View file

@ -1072,6 +1072,8 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "solid_infill_filament"
|| opt_key == "sparse_infill_line_width"
|| opt_key == "infill_direction"
|| opt_key == "solid_infill_direction"
|| opt_key == "rotate_solid_infill_direction"
|| opt_key == "ensure_vertical_shell_thickness"
|| opt_key == "bridge_angle"
//BBS

View file

@ -550,7 +550,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
toggle_field(el, has_solid_infill);
for (auto el : { "infill_direction", "sparse_infill_line_width",
"sparse_infill_speed", "bridge_speed", "internal_bridge_speed", "bridge_angle" })
"sparse_infill_speed", "bridge_speed", "internal_bridge_speed", "bridge_angle","solid_infill_direction", "rotate_solid_infill_direction" })
toggle_field(el, have_infill || has_solid_infill);
toggle_field("top_shell_thickness", ! has_spiral_vase && has_top_solid_infill);

View file

@ -83,6 +83,7 @@ wxString get_thumbnails_string(const std::vector<Vec2d>& values)
return ret_str;
}
Field::~Field()
{
if (m_on_kill_focus)
@ -93,6 +94,11 @@ Field::~Field()
m_back_to_initial_value = nullptr;
if (m_back_to_sys_value)
m_back_to_sys_value = nullptr;
if (getWindow()) {
wxWindow* win = getWindow();
win->Destroy();
win = nullptr;
}
}
void Field::PostInitialize()
@ -158,7 +164,7 @@ void Field::PostInitialize()
}
evt.Skip();
}, getWindow()->GetId());
});
}
}
@ -503,101 +509,6 @@ void Field::sys_color_changed()
#endif
}
std::vector<std::deque<wxWindow *>**> spools;
std::vector<std::deque<wxWindow *>*> spools2;
void switch_window_pools()
{
for (auto p : spools) {
spools2.push_back(*p);
*p = new std::deque<wxWindow*>;
}
}
void release_window_pools()
{
for (auto p : spools2) {
delete p;
}
spools2.clear();
}
template<typename T>
struct Builder
{
Builder()
{
pool_ = new std::deque<wxWindow*>;
spools.push_back(&pool_);
}
template<typename... Args>
T *build(wxWindow * p, Args ...args)
{
if (pool_->empty()) {
auto t = new T(p, args...);
t->SetClientData(pool_);
return t;
}
auto t = dynamic_cast<T*>(pool_->front());
pool_->pop_front();
t->Reparent(p);
t->Enable();
t->Show();
return t;
}
std::deque<wxWindow*>* pool_;
};
struct wxEventFunctorRef
{
wxEventFunctor * func;
};
wxEventFunctor & wxMakeEventFunctor(const int, wxEventFunctorRef func)
{
return *func.func;
}
struct myEvtHandler : wxEvtHandler
{
void UnbindAll()
{
size_t cookie;
for (wxDynamicEventTableEntry *entry = GetFirstDynamicEntry(cookie);
entry;
entry = GetNextDynamicEntry(cookie)) {
// In Field, All Bind has id, but for TextInput, ComboBox, SpinInput, all not
if (entry->m_id != wxID_ANY && entry->m_lastId == wxID_ANY)
Unbind(entry->m_eventType,
wxEventFunctorRef{entry->m_fn},
entry->m_id,
entry->m_lastId,
entry->m_callbackUserData);
//DoUnbind(entry->m_id, entry->m_lastId, entry->m_eventType, *entry->m_fn, entry->m_callbackUserData);
}
}
};
static void unbind_events(wxEvtHandler *h)
{
static_cast<myEvtHandler *>(h)->UnbindAll();
}
void free_window(wxWindow *win)
{
unbind_events(win);
for (auto c : win->GetChildren())
if (dynamic_cast<wxTextCtrl*>(c))
unbind_events(c);
win->Hide();
if (auto sizer = win->GetContainingSizer())
sizer->Clear();
win->Reparent(wxGetApp().mainframe);
if (win->GetClientData())
reinterpret_cast<std::deque<wxWindow *>*>(win->GetClientData())->push_back(win);
}
template<class T>
bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
{
@ -662,15 +573,10 @@ void TextCtrl::BUILD() {
// BBS: new param ui style
// const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/;
static Builder<wxTextCtrl> builder1;
static Builder<::TextInput> builder2;
auto temp = m_opt.multiline
? (wxWindow*)builder1.build(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE)
: builder2.build(m_parent, "", "", "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
temp->SetLabel(_L(m_opt.sidetext));
? (wxWindow *) new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, wxTE_MULTILINE)
: new ::TextInput(m_parent, text_value, _L(m_opt.sidetext), "", wxDefaultPosition, size, wxTE_PROCESS_ENTER);
auto text_ctrl = m_opt.multiline ? (wxTextCtrl *)temp : ((TextInput *) temp)->GetTextCtrl();
text_ctrl->SetLabel(text_value);
temp->SetSize(size);
m_combine_side_text = !m_opt.multiline;
if (parent_is_custom_ctrl && m_opt.height < 0)
opt_height = (double) text_ctrl->GetSize().GetHeight() / m_em_unit;
@ -733,7 +639,7 @@ void TextCtrl::BUILD() {
if (!bEnterPressed)
propagate_value();
}), temp->GetId());
/*
/*
// select all text using Ctrl+A
temp->Bind(wxEVT_CHAR, ([temp](wxKeyEvent& event)
{
@ -902,8 +808,7 @@ void CheckBox::BUILD() {
m_last_meaningful_value = static_cast<unsigned char>(check_value);
// BBS: use ::CheckBox
static Builder<::CheckBox> builder;
auto temp = builder.build(m_parent);
auto temp = new ::CheckBox(m_parent);
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
//temp->SetBackgroundColour(*wxWHITE);
temp->SetValue(check_value);
@ -1022,14 +927,8 @@ void SpinCtrl::BUILD() {
? 0 : m_opt.min;
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
static Builder<SpinInput> builder;
auto temp = builder.build(m_parent, "", "", wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS);
temp->SetSize(size);
temp->SetLabel(_L(m_opt.sidetext));
temp->GetTextCtrl()->SetLabel(text_value);
temp->SetRange(min_val, max_val);
temp->SetValue(default_value);
auto temp = new SpinInput(m_parent, text_value, _L(m_opt.sidetext), wxDefaultPosition, size,
wxSP_ARROW_KEYS, min_val, max_val, default_value);
m_combine_side_text = true;
#ifdef __WXGTK3__
wxSize best_sz = temp->GetBestSize();
@ -1052,7 +951,7 @@ void SpinCtrl::BUILD() {
}
propagate_value();
}), temp->GetId());
}));
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { propagate_value(); }), temp->GetId());
@ -1204,15 +1103,14 @@ void Choice::BUILD()
if (m_opt.nullable)
m_last_meaningful_value = dynamic_cast<ConfigOptionEnumsGenericNullable const *>(m_opt.default_value.get())->get_at(0);
choice_ctrl * temp;
choice_ctrl* temp;
auto dynamic_list = dynamic_lists.find(m_opt.opt_key);
if (dynamic_list != dynamic_lists.end())
m_list = dynamic_list->second;
if (m_opt.gui_type != ConfigOptionDef::GUIType::undefined && m_opt.gui_type != ConfigOptionDef::GUIType::select_open
&& m_list == nullptr) {
m_is_editable = true;
static Builder<choice_ctrl> builder1;
temp = builder1.build(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxTE_PROCESS_ENTER);
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxTE_PROCESS_ENTER);
}
else {
#ifdef UNDEIFNED__WXOSX__ // __WXOSX__ // BBS
@ -1224,12 +1122,9 @@ void Choice::BUILD()
temp->SetTextCtrlStyle(wxTE_READONLY);
temp->Create(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr);
#else
static Builder<choice_ctrl> builder2;
temp = builder2.build(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
#endif //__WXOSX__
}
// temp->SetSize(size);
temp->Clear();
temp->GetDropDown().SetUseContentWidth(true);
if (parent_is_custom_ctrl && m_opt.height < 0)
opt_height = (double) temp->GetTextCtrl()->GetSize().GetHeight() / m_em_unit;
@ -1282,9 +1177,9 @@ void Choice::BUILD()
e.StopPropagation();
else
e.Skip();
}, temp->GetId());
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; }, temp->GetId());
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; }, 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](wxCommandEvent&) { on_change_field(); }, temp->GetId());
@ -1293,12 +1188,12 @@ void Choice::BUILD()
e.Skip();
if (!bEnterPressed)
propagate_value();
}, temp->GetId() );
} );
temp->Bind(wxEVT_TEXT_ENTER, [this](wxEvent& e) {
EnterPressed enter(this);
propagate_value();
}, temp->GetId() );
} );
}
temp->SetToolTip(get_tooltip_text(temp->GetValue()));

View file

@ -3284,10 +3284,7 @@ void GUI_App::check_printer_presets()
#endif
}
void switch_window_pools();
void release_window_pools();
void GUI_App::recreate_GUI(const wxString &msg_name)
void GUI_App::recreate_GUI(const wxString& msg_name)
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "recreate_GUI enter";
m_is_recreating_gui = true;
@ -3295,18 +3292,12 @@ void GUI_App::recreate_GUI(const wxString &msg_name)
update_http_extra_header();
mainframe->shutdown();
ProgressDialog dlg(msg_name, msg_name, 100, nullptr, wxPD_AUTO_HIDE);
dlg.Pulse();
dlg.Update(10, _L("Rebuild") + dots);
MainFrame *old_main_frame = mainframe;
struct ClientData : wxClientData
{
~ClientData() { release_window_pools(); }
};
old_main_frame->SetClientObject(new ClientData);
switch_window_pools();
mainframe = new MainFrame();
if (is_editor())
// hide settings tabs after first Layout

View file

@ -110,7 +110,7 @@ std::map<std::string, std::vector<SimpleSettingData>> SettingsFactory::PART_CAT
{ L("Strength"), {{"wall_loops", "",1},{"top_shell_layers", L("Top Solid Layers"),1},{"top_shell_thickness", L("Top Minimum Shell Thickness"),1},
{"bottom_shell_layers", L("Bottom Solid Layers"),1}, {"bottom_shell_thickness", L("Bottom Minimum Shell Thickness"),1},
{"sparse_infill_density", "",1},{"sparse_infill_pattern", "",1},{"infill_anchor", "",1},{"infill_anchor_max", "",1},{"top_surface_pattern", "",1},{"bottom_surface_pattern", "",1}, {"internal_solid_infill_pattern", "",1},
{"infill_combination", "",1}, {"infill_wall_overlap", "",1}, {"infill_direction", "",1}, {"bridge_angle", "",1}, {"minimum_sparse_infill_area", "",1}
{"infill_combination", "",1}, {"infill_wall_overlap", "",1}, {"solid_infill_direction", "",1}, {"rotate_solid_infill_direction", "",1}, {"infill_direction", "",1}, {"bridge_angle", "",1}, {"minimum_sparse_infill_area", "",1}
}},
{ L("Speed"), {{"outer_wall_speed", "",1},{"inner_wall_speed", "",2},{"sparse_infill_speed", "",3},{"top_surface_speed", "",4}, {"internal_solid_infill_speed", "",5},
{"enable_overhang_speed", "",6}, {"overhang_speed_classic", "",6}, {"overhang_1_4_speed", "",7}, {"overhang_2_4_speed", "",8}, {"overhang_3_4_speed", "",9}, {"overhang_4_4_speed", "",10},

View file

@ -532,9 +532,6 @@ bool OptionsGroup::activate(std::function<void()> throw_if_canceled/* = [](){}*/
return true;
}
void free_window(wxWindow *win);
// delete all controls from the option group
void OptionsGroup::clear(bool destroy_custom_ctrl)
{
@ -563,10 +560,8 @@ void OptionsGroup::clear(bool destroy_custom_ctrl)
if (custom_ctrl) {
for (auto const &item : m_fields) {
wxWindow* win = item.second.get()->getWindow();
if (win) {
free_window(win);
if (win)
win = nullptr;
}
}
//BBS: custom_ctrl already destroyed from sizer->clear(), no need to destroy here anymore
if (destroy_custom_ctrl)

View file

@ -9533,6 +9533,8 @@ void Plater::calib_flowrate(int pass) {
_obj->config.set_key_value("top_surface_pattern", new ConfigOptionEnum<InfillPattern>(ipMonotonic));
_obj->config.set_key_value("top_solid_infill_flow_ratio", new ConfigOptionFloat(1.0f));
_obj->config.set_key_value("infill_direction", new ConfigOptionFloat(45));
_obj->config.set_key_value("solid_infill_direction", new ConfigOptionFloat(135));
_obj->config.set_key_value("rotate_solid_infill_direction", new ConfigOptionBool(true));
_obj->config.set_key_value("ironing_type", new ConfigOptionEnum<IroningType>(IroningType::NoIroning));
_obj->config.set_key_value("internal_solid_infill_speed", new ConfigOptionFloat(internal_solid_speed));
_obj->config.set_key_value("top_surface_speed", new ConfigOptionFloat(top_surface_speed));

View file

@ -2129,6 +2129,8 @@ void TabPrint::build()
optgroup = page->new_optgroup(L("Advanced"), L"param_advanced");
optgroup->append_single_option_line("infill_wall_overlap");
optgroup->append_single_option_line("infill_direction");
optgroup->append_single_option_line("solid_infill_direction");
optgroup->append_single_option_line("rotate_solid_infill_direction");
optgroup->append_single_option_line("bridge_angle");
optgroup->append_single_option_line("minimum_sparse_infill_area");
optgroup->append_single_option_line("infill_combination");
@ -4994,12 +4996,12 @@ void Tab::clear_pages()
{
// invalidated highlighter, if any exists
m_highlighter.invalidate();
// clear pages from the controlls
for (auto p : m_pages)
p->clear();
//BBS: clear page in Parent
//m_page_sizer->Clear(true);
m_parent->clear_page();
// clear pages from the controlls
for (auto p : m_pages)
p->clear();
// nulling pointers
m_parent_preset_description_line = nullptr;

View file

@ -165,7 +165,6 @@ int ComboBox::Append(const wxString &item,
void ComboBox::DoClear()
{
SetIcon("drop_down");
texts.clear();
tips.clear();
icons.clear();

View file

@ -102,14 +102,6 @@ void TextInput::SetIcon(const wxBitmap &icon)
Rescale();
}
void TextInput::SetIcon(const wxString &icon)
{
if (this->icon.name() == icon.ToStdString())
return;
this->icon = ScalableBitmap(this, icon.ToStdString(), 16);
Rescale();
}
void TextInput::SetLabelColor(StateColor const &color)
{
label_color = color;

View file

@ -42,8 +42,6 @@ public:
void SetIcon(const wxBitmap & icon);
void SetIcon(const wxString & icon);
void SetLabelColor(StateColor const &color);
void SetTextColor(StateColor const &color);