improves loading of 3MFs generated by BambuStudio

This commit is contained in:
QIDI TECH
2024-04-10 13:44:24 +08:00
parent 0491f84149
commit 05e2b540ab
6 changed files with 88 additions and 59 deletions

View File

@@ -418,6 +418,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
wxGetApp().SetWindowVariantForButton(sel_all_std);
wxGetApp().SetWindowVariantForButton(sel_all);
wxGetApp().SetWindowVariantForButton(sel_none);
wxGetApp().UpdateDarkUI(sel_all_std);
wxGetApp().UpdateDarkUI(sel_all);
wxGetApp().UpdateDarkUI(sel_none);
@@ -750,6 +751,7 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
wxGetApp().SetWindowVariantForButton(sel_all);
wxGetApp().SetWindowVariantForButton(sel_none);
grid->Add(new wxBoxSizer(wxHORIZONTAL));
grid->Add(new wxBoxSizer(wxHORIZONTAL));
grid->Add(new wxBoxSizer(wxHORIZONTAL));
@@ -788,6 +790,7 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
reload_presets();
set_compatible_printers_html_window(std::vector<std::string>(), false);
}
void PageMaterials::check_and_update_presets(bool force_reload_presets /*= false*/)
{
if (presets_loaded)
@@ -796,6 +799,7 @@ void PageMaterials::check_and_update_presets(bool force_reload_presets /*= false
// if (force_reload_presets)
reload_presets();
}
void PageMaterials::on_paint()
{
}
@@ -909,7 +913,6 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
);
}
}
wxFont font = wxGetApp().normal_font();// get_default_font_for_dpi(this, get_dpi_for_window(this));
const int fs = font.GetPointSize();
@@ -2613,9 +2616,11 @@ void ConfigWizard::priv::update_materials(Technology technology)
materials.compatibility_counter[preset.alias].insert(printer);
}
};
if ((any_fff_selected || custom_printer_in_bundle || custom_printer_selected) && (technology & T_FFF)) {
filaments.clear();
aliases_fff.clear();
for (const auto &[name, bundle] : bundles) {
for (const auto &filament : bundle.preset_bundle->filaments) {
// Iterate printers in all bundles
@@ -2629,9 +2634,9 @@ void ConfigWizard::priv::update_materials(Technology technology)
// template filament bundle has no printers - filament would be never added
if(bundle.vendor_profile && bundle.vendor_profile->templates_profile && bundle.preset_bundle->printers.begin() == bundle.preset_bundle->printers.end())
add_material(filaments, aliases_fff, filament);
}
}
}
}
if (any_sla_selected && (technology & T_SLA)) {
sla_materials.clear();
@@ -2649,10 +2654,10 @@ void ConfigWizard::priv::update_materials(Technology technology)
if (is_compatible_with_printer(PresetWithVendorProfile(material, nullptr), PresetWithVendorProfile(printer, nullptr)))
// Check if material is already added
add_material(sla_materials, aliases_sla, material, &printer);
}
}
}
}
}
}
void ConfigWizard::priv::on_custom_setup(const bool custom_wanted)
@@ -2781,25 +2786,25 @@ bool ConfigWizard::priv::on_bnt_finish()
{
wxBusyCursor wait;
#if !defined(__linux__) || (defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION))
if (!page_downloader->on_finish_downloader()) {
index->go_to(page_downloader);
return false;
}
#endif
/* If some printers were added/deleted, but related MaterialPage wasn't activated,
* than last changes wouldn't be updated for filaments/materials.
* SO, do that before check_and_install_missing_materials()
*/
if (page_filaments)
page_filaments->check_and_update_presets();
page_filaments->check_and_update_presets();
if (page_sla_materials)
page_sla_materials->check_and_update_presets();
page_sla_materials->check_and_update_presets();
// Even if we have only custom printer installed, check filament selection.
// Template filaments could be selected in this case.
if (custom_printer_selected && !any_fff_selected && !any_sla_selected)
return check_and_install_missing_materials(T_FFF);
// check, that there is selected at least one filament/material
return check_and_install_missing_materials(T_ANY);
}
@@ -3235,6 +3240,7 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
wxGetApp().associate_3mf_files();
if (page_files_association->associate_stl())
wxGetApp().associate_stl_files();
//Y
if (page_files_association->associate_step())
wxGetApp().associate_step_files();
}
@@ -3414,9 +3420,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
p->add_page(p->page_update = new PageUpdate(this));
#if !defined(__linux__) || (defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION))
p->add_page(p->page_downloader = new PageDownloader(this));
#endif
p->add_page(p->page_reload_from_disk = new PageReloadFromDisk(this));
#ifdef _WIN32
p->add_page(p->page_files_association = new PageFilesAssociation(this));

View File

@@ -62,11 +62,11 @@ void open_folder(const std::string& path)
std::string filename_from_url(const std::string& url)
{
// TODO: can it be done with curl?
size_t slash = url.find_last_of("/");
if (slash == std::string::npos && slash != url.size() - 1)
std::string url_plain = std::string(url.begin(), std::find(url.begin(), url.end(), '?'));
size_t slash = url_plain.find_last_of("/");
if (slash == std::string::npos)
return std::string();
return url.substr(slash + 1, url.size() - slash + 1);
return std::string(url_plain.begin() + slash + 1, url_plain.end());
}
}

View File

@@ -822,6 +822,7 @@ void GUI_App::post_init()
// This is ugly but I honestly found no better way to do it.
// Neither wxShowEvent nor wxWindowCreateEvent work reliably.
if (this->preset_updater) { // G-Code Viewer does not initialize preset_updater.
#if 0 // This code was moved to EVT_CONFIG_UPDATER_SYNC_DONE bind - after preset_updater finishes synchronization.
if (! this->check_updates(false))
// Configuration is not compatible and reconfigure was refused by the user. Application is closing.
@@ -1097,10 +1098,12 @@ static int get_app_font_pt_size(const AppConfig* app_config)
return (font_pt_size > max_font_pt_size) ? max_font_pt_size : font_pt_size;
}
bool GUI_App::on_init_inner()
{
// TODO: remove this when all asserts are gone.
wxDisableAsserts();
// Set initialization of image handlers before any UI actions - See GH issue #7469
wxInitAllImageHandlers();
@@ -1299,6 +1302,7 @@ bool GUI_App::on_init_inner()
Bind(EVT_CONFIG_UPDATER_SYNC_DONE, [this](const wxCommandEvent& evt) {
this->check_updates(false);
});
}
else {
#ifdef __WXMSW__
@@ -1642,7 +1646,7 @@ void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
UpdateDarkUI(dvc, highlited ? dark_mode() : false);
#ifdef _MSW_DARK_MODE
if (!dvc->HasFlag(wxDV_NO_HEADER))
dvc->RefreshHeaderDarkMode(&m_normal_font);
dvc->RefreshHeaderDarkMode(&m_normal_font);
#endif //_MSW_DARK_MODE
if (dvc->HasFlag(wxDV_ROW_LINES))
dvc->SetAlternateRowColour(m_color_highlight_default);
@@ -1687,6 +1691,7 @@ int GUI_App::get_max_font_pt_size()
}
return 15;
}
void GUI_App::init_fonts()
{
m_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
@@ -3160,9 +3165,6 @@ void GUI_App::show_desktop_integration_dialog()
void GUI_App::show_downloader_registration_dialog()
{
#if defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION)
return;
#endif
InfoDialog msg(nullptr
, format_wxstr(_L("Welcome to %1% version %2%."), SLIC3R_APP_NAME, SLIC3R_VERSION)
, format_wxstr(_L(
@@ -3174,10 +3176,10 @@ void GUI_App::show_downloader_registration_dialog()
if (msg.ShowModal() == wxID_YES) {
auto downloader_worker = new DownloaderUtils::Worker(nullptr);
downloader_worker->perform_register(app_config->get("url_downloader_dest"));
#if defined(__linux__)
#if defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
if (downloader_worker->get_perform_registration_linux())
DesktopIntegrationDialog::perform_downloader_desktop_integration();
#endif //(__linux__)
#endif //(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
} else {
app_config->set("downloader_url_registered", "0");
}
@@ -3459,7 +3461,6 @@ void GUI_App::associate_bgcode_files()
{
associate_file_type(L".bgcode", L"QIDISlicer.GCodeViewer.1", L"QIDISlicerGCodeViewer", true);
}
#endif // __WXMSW__
void GUI_App::on_version_read(wxCommandEvent& evt)
@@ -3564,17 +3565,16 @@ void GUI_App::start_download(std::string url)
BOOST_LOG_TRIVIAL(error) << "Could not start URL download: plater is nullptr.";
return;
}
// Windows register and deregister executable path to registry - cant get here when not registered
// Apple registers via info.plist attached to exectable - might get here
// Linux registers via desktop integration file - might get here only if such file was created outside Slicer.
// Desktop integration is limited with SLIC3R_DESKTOP_INTEGRATION (cmake option).
#if defined(__APPLE__) || (defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION))
if (app_config && app_config->get_bool("downloader_url_registered")) {
#if defined(__APPLE__) || (defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION))
if (app_config && !app_config->get_bool("downloader_url_registered"))
{
notification_manager()->push_notification(NotificationType::URLNotRegistered);
BOOST_LOG_TRIVIAL(error) << "Recieved command to open URL, but it is not allowed in app configuration. URL: " << url;
BOOST_LOG_TRIVIAL(error) << "Received command to open URL, but it is not allowed in app configuration. URL: " << url;
return;
}
#endif //defined(__APPLE__) || (defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION))
#endif //defined(__APPLE__) || (defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION))
//lets always init so if the download dest folder was changed, new dest is used
boost::filesystem::path dest_folder(app_config->get("url_downloader_dest"));
if (dest_folder.empty() || !boost::filesystem::is_directory(dest_folder)) {
@@ -3582,7 +3582,7 @@ void GUI_App::start_download(std::string url)
BOOST_LOG_TRIVIAL(error) << msg;
show_error(nullptr, msg);
return;
}
}
m_downloader->init(dest_folder);
m_downloader->start_download(url);
}
@@ -3619,5 +3619,6 @@ void GUI_App::open_wifi_config_dialog(bool forced, const wxString& drive_path/*
}
m_wifi_config_dialog_shown = false;
}
} // GUI
} //Slic3r

View File

@@ -909,6 +909,13 @@ private:
return true;
}
},
{NotificationType::PresetUpdateAvailableNewPrinter, NotificationLevel::ImportantNotificationLevel, 20, _u8L("Configuration update is available. Update contains new printer releases."), _u8L("See more."),
[](wxEvtHandler* evnthndlr) {
if (evnthndlr != nullptr)
wxPostEvent(evnthndlr, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED));
return true;
}
},
{NotificationType::EmptyColorChangeCode, NotificationLevel::PrintInfoNotificationLevel, 10,
_u8L("You have just added a G-code for color change, but its value is empty.\n"
"To export the G-code correctly, check the \"Color Change G-code\" in \"Printer Settings > Custom G-code\"") },

View File

@@ -14,6 +14,7 @@
#include "ConfigWizard.hpp"
#include "Widgets/SpinInput.hpp"
#include <boost/dll/runtime_symbol_info.hpp>
#ifdef WIN32
@@ -23,10 +24,6 @@
#include "DesktopIntegrationDialog.hpp"
#endif //(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
#if defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION)
#include "NotificationManager.hpp"
#endif //(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
namespace Slic3r {
static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values& enum_keys_map)
@@ -88,6 +85,7 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) :
sz.x += 1;
#endif
SetSize(sz);
m_highlighter.set_timer_owner(this, 0);
}
@@ -125,11 +123,9 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
if (wxGetApp().is_editor()) {
auto app_config = get_app_config();
#if !defined(__linux__) || (defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION))
downloader->set_path_name(app_config->get("url_downloader_dest"));
downloader->allow(!app_config->has("downloader_url_registered") || app_config->get_bool("downloader_url_registered"));
#endif
for (const std::string& opt_key : {"suppress_hyperlinks", "downloader_url_registered"})
m_optgroup_other->set_value(opt_key, app_config->get_bool(opt_key));
@@ -138,6 +134,7 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
,"default_action_on_select_preset" })
m_optgroup_general->set_value(opt_key, app_config->get(opt_key) == "none");
m_optgroup_general->set_value("default_action_on_dirty_project", app_config->get("default_action_on_dirty_project").empty());
// update colors for color pickers of the labels
update_color(m_sys_colour, wxGetApp().get_label_clr_sys());
update_color(m_mod_colour, wxGetApp().get_label_clr_modified());
@@ -155,6 +152,7 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& title, wxBookCtrlBase* tabs)
{
wxPanel* tab = new wxPanel(tabs, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
tabs->AddPage(tab, _(title));
tab->SetFont(wxGetApp().normal_font());
@@ -163,6 +161,7 @@ static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& tit
// Sizer in the scrolled area
auto* scrolled_sizer = new wxBoxSizer(wxVERTICAL);
scrolled->SetSizer(scrolled_sizer);
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(scrolled, 1, wxEXPAND);
sizer->SetSizeHints(tab);
@@ -182,6 +181,7 @@ static void activate_options_tab(std::shared_ptr<ConfigOptionsGroup> optgroup)
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
optgroup->parent()->Layout();
// apply sercher
wxGetApp().sidebar().get_searcher().append_preferences_options(optgroup->get_lines());
}
@@ -323,7 +323,6 @@ void PreferencesDialog::build()
L("Associate .stl files to QIDISlicer"),
L("If enabled, sets QIDISlicer as default application to open .stl files."),
app_config->get_bool("associate_stl"));
#endif // _WIN32
m_optgroup_general->append_separator();
@@ -626,6 +625,7 @@ void PreferencesDialog::build()
L("If the 'Supports binary G-code' option is enabled in Printer Settings, "
"checking this option will result in the export of G-code in binary format."),
app_config->get_bool("use_binary_gcode_when_supported"));
append_bool_option(m_optgroup_other, "suppress_hyperlinks",
L("Suppress to open hyperlink in browser"),
L("If enabled, QIDISlicer will not open a hyperlinks in your browser."),
@@ -633,18 +633,14 @@ void PreferencesDialog::build()
// "If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks."),
app_config->get_bool("suppress_hyperlinks"));
#if !defined(__linux__) || (defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION))
append_bool_option(m_optgroup_other, "downloader_url_registered",
L("Allow downloads from Printables.com"),
L("If enabled, QIDISlicer will be allowed to download from Printables.com"),
app_config->get_bool("downloader_url_registered"));
#endif
activate_options_tab(m_optgroup_other);
#if !defined(__linux__) || (defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION))
create_downloader_path_sizer();
#endif
create_settings_font_widget();
#if ENABLE_ENVIRONMENT_MAP
@@ -749,18 +745,16 @@ void PreferencesDialog::update_ctrls_alignment()
void PreferencesDialog::accept(wxEvent&)
{
#if !defined(__linux__) || (defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION))
if(wxGetApp().is_editor()) {
if (const auto it = m_values.find("downloader_url_registered"); it != m_values.end())
downloader->allow(it->second == "1");
if (!downloader->on_finish())
return;
#if defined(__linux__)
#if defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
if( downloader->get_perform_registration_linux())
DesktopIntegrationDialog::perform_downloader_desktop_integration();
#endif
#endif //(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
}
#endif
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled", "font_pt_size", "suppress_round_corners" };