Merge branch 'main' into enh-update-wxwidgets

This commit is contained in:
Ocraftyone
2023-11-30 02:44:22 -05:00
committed by GitHub
96 changed files with 1913 additions and 390 deletions
+21 -5
View File
@@ -446,6 +446,24 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
RegionExpansionParameters::build(expansion_top, expansion_step, max_nr_expansion_steps),
sparse, expansion_params_into_sparse_infill, closing_radius);
// turn too small internal regions into solid regions according to the user setting
if (!this->layer()->object()->print()->config().spiral_mode && this->region().config().sparse_infill_density.value > 0) {
// scaling an area requires two calls!
double min_area = scale_(scale_(this->region().config().minimum_sparse_infill_area.value));
ExPolygons small_regions{};
sparse.erase(std::remove_if(sparse.begin(), sparse.end(), [min_area, &small_regions](ExPolygon& ex_polygon) {
if (ex_polygon.area() <= min_area) {
small_regions.push_back(ex_polygon);
return true;
}
return false;
}), sparse.end());
if (!small_regions.empty()) {
shells = union_ex(shells, small_regions);
}
}
// m_fill_surfaces.remove_types({ stBottomBridge, stBottom, stTop, stInternal, stInternalSolid });
this->fill_surfaces.clear();
reserve_more(this->fill_surfaces.surfaces, shells.size() + sparse.size() + bridges.size() + bottoms.size() + tops.size());
@@ -792,12 +810,10 @@ void LayerRegion::prepare_fill_surfaces()
surface.surface_type = stInternal;
}
// turn too small internal regions into solid regions according to the user setting
if (! spiral_mode && this->region().config().sparse_infill_density.value > 0) {
// scaling an area requires two calls!
double min_area = scale_(scale_(this->region().config().minimum_sparse_infill_area.value));
if (!spiral_mode && fabs(this->region().config().sparse_infill_density.value - 100.) < EPSILON) {
// Turn all internal sparse infill into solid infill, if sparse_infill_density is 100%
for (Surface &surface : this->fill_surfaces.surfaces)
if (surface.surface_type == stInternal && surface.area() <= min_area)
if (surface.surface_type == stInternal)
surface.surface_type = stInternalSolid;
}
+1 -7
View File
@@ -1726,7 +1726,7 @@ def = this->add("filament_loading_speed", coFloats);
def = this->add("sparse_infill_density", coPercent);
def->label = L("Sparse infill density");
def->category = L("Strength");
def->tooltip = L("Density of internal sparse infill, 100% means solid throughout");
def->tooltip = L("Density of internal sparse infill, 100% turns all sparse infill into solid infill and internal solid infill pattern will be used");
def->sidetext = L("%");
def->min = 0;
def->max = 100;
@@ -5711,12 +5711,6 @@ std::map<std::string, std::string> validate(const FullPrintConfig &cfg, bool und
error_message.emplace("internal_solid_infill_pattern", L("invalid value ") + cfg.internal_solid_infill_pattern.serialize());
}
// --fill-density
if (fabs(cfg.sparse_infill_density.value - 100.) < EPSILON &&
! print_config_def.get("top_surface_pattern")->has_enum_value(cfg.sparse_infill_pattern.serialize())) {
error_message.emplace("sparse_infill_pattern", cfg.sparse_infill_pattern.serialize() + L(" doesn't work at 100%% density "));
}
// --skirt-height
if (cfg.skirt_height < 0) {
error_message.emplace("skirt_height", L("invalid value ") + std::to_string(cfg.skirt_height));
+18 -11
View File
@@ -3315,6 +3315,13 @@ void PrintObject::combine_infill()
const bool enable_combine_infill = region.config().infill_combination.value;
if (enable_combine_infill == false || region.config().sparse_infill_density == 0.)
continue;
// Support internal solid infill when sparse_infill_density is 100%
const bool use_solid_infill = fabs(region.config().sparse_infill_density.value - 100.) < EPSILON;
const SurfaceType surface_type = use_solid_infill ? stInternalSolid : stInternal;
const InfillPattern infill_pattern = use_solid_infill ? region.config().internal_solid_infill_pattern :
region.config().sparse_infill_pattern;
// Limit the number of combined layers to the maximum height allowed by this regions' nozzle.
//FIXME limit the layer height to max_layer_height
double nozzle_diameter = std::min(
@@ -3361,10 +3368,10 @@ void PrintObject::combine_infill()
layerms.emplace_back(m_layers[i]->regions()[region_id]);
// We need to perform a multi-layer intersection, so let's split it in pairs.
// Initialize the intersection with the candidates of the lowest layer.
ExPolygons intersection = to_expolygons(layerms.front()->fill_surfaces.filter_by_type(stInternal));
ExPolygons intersection = to_expolygons(layerms.front()->fill_surfaces.filter_by_type(surface_type));
// Start looping from the second layer and intersect the current intersection with it.
for (size_t i = 1; i < layerms.size(); ++ i)
intersection = intersection_ex(layerms[i]->fill_surfaces.filter_by_type(stInternal), intersection);
intersection = intersection_ex(layerms[i]->fill_surfaces.filter_by_type(surface_type), intersection);
double area_threshold = layerms.front()->infill_area_threshold();
if (! intersection.empty() && area_threshold > 0.)
intersection.erase(std::remove_if(intersection.begin(), intersection.end(),
@@ -3384,21 +3391,21 @@ void PrintObject::combine_infill()
0.5f * layerms.back()->flow(frPerimeter).scaled_width() +
// Because fill areas for rectilinear and honeycomb are grown
// later to overlap perimeters, we need to counteract that too.
((region.config().sparse_infill_pattern == ipRectilinear ||
region.config().sparse_infill_pattern == ipMonotonic ||
region.config().sparse_infill_pattern == ipGrid ||
region.config().sparse_infill_pattern == ipLine ||
region.config().sparse_infill_pattern == ipHoneycomb) ? 1.5f : 0.5f) *
((infill_pattern == ipRectilinear ||
infill_pattern == ipMonotonic ||
infill_pattern == ipGrid ||
infill_pattern == ipLine ||
infill_pattern == ipHoneycomb) ? 1.5f : 0.5f) *
layerms.back()->flow(frSolidInfill).scaled_width();
for (ExPolygon &expoly : intersection)
polygons_append(intersection_with_clearance, offset(expoly, clearance_offset));
for (LayerRegion *layerm : layerms) {
Polygons internal = to_polygons(std::move(layerm->fill_surfaces.filter_by_type(stInternal)));
layerm->fill_surfaces.remove_type(stInternal);
layerm->fill_surfaces.append(diff_ex(internal, intersection_with_clearance), stInternal);
Polygons internal = to_polygons(std::move(layerm->fill_surfaces.filter_by_type(surface_type)));
layerm->fill_surfaces.remove_type(surface_type);
layerm->fill_surfaces.append(diff_ex(internal, intersection_with_clearance), surface_type);
if (layerm == layerms.back()) {
// Apply surfaces back with adjusted depth to the uppermost layer.
Surface templ(stInternal, ExPolygon());
Surface templ(surface_type, ExPolygon());
templ.thickness = 0.;
for (LayerRegion *layerm2 : layerms)
templ.thickness += layerm2->layer()->height;
+1 -51
View File
@@ -852,70 +852,20 @@ CopyFileResult copy_file(const std::string &from, const std::string &to, std::st
::MultiByteToWideChar(CP_UTF8, NULL, dest_str, strlen(dest_str), dst_wstr, dst_wlen);
dst_wstr[dst_wlen] = '\0';
BOOL result;
char* buff = nullptr;
HANDLE handlesrc = nullptr;
HANDLE handledst = nullptr;
CopyFileResult ret = SUCCESS;
handlesrc = CreateFile(src_wstr,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_TEMPORARY,
0);
if(handlesrc==INVALID_HANDLE_VALUE){
error_message = "Error: open src file";
ret = FAIL_COPY_FILE;
goto __finished;
}
handledst=CreateFile(dst_wstr,
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY,
0);
if(handledst==INVALID_HANDLE_VALUE){
error_message = "Error: create dest file";
ret = FAIL_COPY_FILE;
goto __finished;
}
DWORD size=GetFileSize(handlesrc,NULL);
buff = new char[size+1];
DWORD dwRead=0,dwWrite;
result = ReadFile(handlesrc, buff, size, &dwRead, NULL);
BOOL result = CopyFileW(src_wstr, dst_wstr, FALSE);
if (!result) {
DWORD errCode = GetLastError();
error_message = "Error: " + errCode;
ret = FAIL_COPY_FILE;
goto __finished;
}
buff[size]=0;
result = WriteFile(handledst,buff,size,&dwWrite,NULL);
if (!result) {
DWORD errCode = GetLastError();
error_message = "Error: " + errCode;
ret = FAIL_COPY_FILE;
goto __finished;
}
FlushFileBuffers(handledst);
__finished:
if (src_wstr)
delete[] src_wstr;
if (dst_wstr)
delete[] dst_wstr;
if (handlesrc)
CloseHandle(handlesrc);
if (handledst)
CloseHandle(handledst);
if (buff)
delete[] buff;
return ret;
#else
-37
View File
@@ -419,43 +419,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
}
}
if (config->option<ConfigOptionPercent>("sparse_infill_density")->value == 100) {
std::string sparse_infill_pattern = config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->serialize();
const auto &top_fill_pattern_values = config->def()->get("top_surface_pattern")->enum_values;
bool correct_100p_fill = std::find(top_fill_pattern_values.begin(), top_fill_pattern_values.end(), sparse_infill_pattern) != top_fill_pattern_values.end();
if (!correct_100p_fill) {
// get sparse_infill_pattern name from enum_labels for using this one at dialog_msg
const ConfigOptionDef *fill_pattern_def = config->def()->get("sparse_infill_pattern");
assert(fill_pattern_def != nullptr);
auto it_pattern = std::find(fill_pattern_def->enum_values.begin(), fill_pattern_def->enum_values.end(), sparse_infill_pattern);
assert(it_pattern != fill_pattern_def->enum_values.end());
if (it_pattern != fill_pattern_def->enum_values.end()) {
wxString msg_text = GUI::format_wxstr(_L("%1% infill pattern doesn't support 100%% density."),
_(fill_pattern_def->enum_labels[it_pattern - fill_pattern_def->enum_values.begin()]));
if (is_global_config)
msg_text += "\n" + _L("Switch to rectilinear pattern?\n"
"Yes - switch to rectilinear pattern automaticlly\n"
"No - reset density to default non 100% value automaticlly") + "\n";
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK) );
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
auto answer = dialog.ShowModal();
if (!is_global_config || answer == wxID_YES) {
new_conf.set_key_value("sparse_infill_pattern", new ConfigOptionEnum<InfillPattern>(ipRectilinear));
sparse_infill_density = 100;
}
else
sparse_infill_density = wxGetApp().preset_bundle->prints.get_selected_preset().config.option<ConfigOptionPercent>("sparse_infill_density")->value;
new_conf.set_key_value("sparse_infill_density", new ConfigOptionPercent(sparse_infill_density));
apply(config, &new_conf);
if (cb_value_change)
cb_value_change("sparse_infill_density", sparse_infill_density);
is_msg_dlg_already_exist = false;
}
}
}
// BBS
static const char* keys[] = { "support_filament", "support_interface_filament"};
for (int i = 0; i < sizeof(keys) / sizeof(keys[0]); i++) {
+11 -13
View File
@@ -550,7 +550,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, f
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
if (!m_visible || !wxGetApp().show_gcode_window() || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
if (!wxGetApp().show_gcode_window() || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
return;
// window height
@@ -675,8 +675,12 @@ void GCodeViewer::SequentialView::GCodeWindow::stop_mapping_file()
}
void GCodeViewer::SequentialView::render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type)
{
if (has_render_path)
marker.render(canvas_width, canvas_height, view_type);
if (has_render_path && m_show_marker) {
marker.set_world_position(current_position);
marker.set_world_offset(current_offset);
marker.render(canvas_width, canvas_height, view_type);
}
//float bottom = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size().get_height();
// BBS
@@ -973,7 +977,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
m_settings_ids = gcode_result.settings_ids;
m_filament_diameters = gcode_result.filament_diameters;
m_filament_densities = gcode_result.filament_densities;
m_sequential_view.m_show_gcode_window = false;
m_sequential_view.m_show_marker = false;
//BBS: always load shell at preview
/*if (wxGetApp().is_editor())
@@ -1254,15 +1258,9 @@ void GCodeViewer::render(int canvas_width, int canvas_height, int right_margin)
//BBS fixed bottom_margin for space to render horiz slider
int bottom_margin = SLIDER_BOTTOM_MARGIN * GCODE_VIEWER_SLIDER_SCALE;
m_sequential_view.m_show_gcode_window =
m_sequential_view.m_show_gcode_window ||
(m_sequential_view.current.last != m_sequential_view.endpoints.last && !m_no_render_path);
if (m_sequential_view.m_show_gcode_window) {
m_sequential_view.marker.set_world_position(m_sequential_view.current_position);
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
//BBS fixed buttom margin. m_moves_slider.pos_y
m_sequential_view.render(!m_no_render_path, legend_height, canvas_width, canvas_height - bottom_margin * m_scale, right_margin * m_scale, m_view_type);
}
m_sequential_view.m_show_marker = m_sequential_view.m_show_marker || (m_sequential_view.current.last != m_sequential_view.endpoints.last && !m_no_render_path);
// BBS fixed buttom margin. m_moves_slider.pos_y
m_sequential_view.render(!m_no_render_path, legend_height, canvas_width, canvas_height - bottom_margin * m_scale, right_margin * m_scale, m_view_type);
#if ENABLE_GCODE_VIEWER_STATISTICS
render_statistics();
#endif // ENABLE_GCODE_VIEWER_STATISTICS
+1 -6
View File
@@ -650,7 +650,6 @@ public:
std::string comment;
};
bool m_is_dark = false;
bool m_visible{ true };
uint64_t m_selected_line_id{ 0 };
size_t m_last_lines_size{ 0 };
std::string m_filename;
@@ -674,8 +673,6 @@ public:
m_filename.shrink_to_fit();
}
void toggle_visibility() { m_visible = !m_visible; }
//BBS: GUI refactor: add canvas size
//void render(float top, float bottom, uint64_t curr_line_id) const;
void render(float top, float bottom, float right, uint64_t curr_line_id) const;
@@ -701,7 +698,7 @@ public:
GCodeWindow gcode_window;
std::vector<unsigned int> gcode_ids;
float m_scale = 1.0;
bool m_show_gcode_window = false;
bool m_show_marker = false;
void render(const bool has_render_path, float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type);
};
@@ -883,8 +880,6 @@ public:
void export_toolpaths_to_obj(const char* filename) const;
void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); }
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
size_t get_extruders_count() { return m_extruders_count; }
void push_combo_style();
+1 -1
View File
@@ -3196,7 +3196,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
//case 'B':
//case 'b': { zoom_to_bed(); break; }
case 'C':
case 'c': { m_gcode_viewer.toggle_gcode_window_visibility(); m_dirty = true; request_extra_frame(); break; }
case 'c': { wxGetApp().toggle_show_gcode_window(); m_dirty = true; request_extra_frame(); break; }
//case 'G':
//case 'g': {
// if ((evt.GetModifiers() & shiftMask) != 0) {
+7 -1
View File
@@ -988,6 +988,12 @@ static void generic_exception_handle()
//#endif
}
void GUI_App::toggle_show_gcode_window()
{
m_show_gcode_window = !m_show_gcode_window;
app_config->set_bool("show_gcode_window", m_show_gcode_window);
}
std::vector<std::string> GUI_App::split_str(std::string src, std::string separator)
{
std::string::size_type pos;
@@ -1165,7 +1171,7 @@ void GUI_App::post_init()
if (app_config->get("stealth_mode") == "false")
hms_query = new HMSQuery();
m_show_gcode_window = app_config->get("show_gcode_window") == "true";
m_show_gcode_window = app_config->get_bool("show_gcode_window");
if (m_networking_need_update) {
//updating networking
int ret = updating_bambu_networking();
+1 -1
View File
@@ -324,7 +324,7 @@ private:
// SoftFever
bool show_gcode_window() const { return m_show_gcode_window; }
void set_show_gcode_window(bool val) { m_show_gcode_window = val; }
void toggle_show_gcode_window();
wxString get_inf_dialog_contect () {return m_info_dialog_content;};
+9
View File
@@ -2508,6 +2508,15 @@ void MainFrame::init_menubar_as_editor()
else
viewMenu->Check(wxID_CAMERA_ORTHOGONAL + camera_id_base, true);
viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &G-code Window") + "\tC", _L("Show g-code window in Previce scene"),
[this](wxCommandEvent &) {
wxGetApp().toggle_show_gcode_window();
m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT));
},
this, [this]() { return m_plater->is_preview_shown(); },
[this]() { return wxGetApp().show_gcode_window(); }, this);
viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &Labels") + "\t" + ctrl + "E", _L("Show object labels in 3D scene"),
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT)); }, this,
-7
View File
@@ -681,11 +681,6 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
}
}
if (param == "show_gcode_window") {
bool pbool = app_config->get("show_gcode_window") == "true" ? true : false;
wxGetApp().set_show_gcode_window(pbool);
}
#endif // __WXMSW__
if (param == "developer_mode")
@@ -987,7 +982,6 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_show_splash_screen = create_item_checkbox(_L("Show splash screen"), page, _L("Show the splash screen during startup."), 50, "show_splash_screen");
auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints");
auto item_gcode_window = create_item_checkbox(_L("Show g-code window"), page, _L("If enabled, g-code window will be displayed."), 50, "show_gcode_window");
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset");
@@ -1048,7 +1042,6 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_use_free_camera_settings, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_show_splash_screen, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_gcode_window, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));
+1 -1
View File
@@ -1927,13 +1927,13 @@ void TabPrint::build()
optgroup->append_single_option_line("bottom_surface_pattern", "fill-patterns#Infill of the top surface and bottom surface");
optgroup->append_single_option_line("bottom_shell_layers");
optgroup->append_single_option_line("bottom_shell_thickness");
optgroup->append_single_option_line("internal_solid_infill_pattern");
optgroup = page->new_optgroup(L("Infill"), L"param_infill");
optgroup->append_single_option_line("sparse_infill_density");
optgroup->append_single_option_line("sparse_infill_pattern", "fill-patterns#infill types and their properties of sparse");
optgroup->append_single_option_line("infill_anchor");
optgroup->append_single_option_line("infill_anchor_max");
optgroup->append_single_option_line("internal_solid_infill_pattern");
optgroup->append_single_option_line("filter_out_gap_fill");