mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 04:35:54 +08:00
Merge branch 'master_262' of https://github.com/Prusa-Development/PrusaSlicerPrivate into master_262
This commit is contained in:
commit
03febdccd1
@ -786,6 +786,16 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
|
|||||||
reload_presets();
|
reload_presets();
|
||||||
set_compatible_printers_html_window(std::vector<std::string>(), false);
|
set_compatible_printers_html_window(std::vector<std::string>(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageMaterials::check_and_update_presets(bool force_reload_presets /*= false*/)
|
||||||
|
{
|
||||||
|
if (presets_loaded)
|
||||||
|
return;
|
||||||
|
wizard_p()->update_materials(materials->technology);
|
||||||
|
if (force_reload_presets)
|
||||||
|
reload_presets();
|
||||||
|
}
|
||||||
|
|
||||||
void PageMaterials::on_paint()
|
void PageMaterials::on_paint()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -1299,10 +1309,7 @@ void PageMaterials::clear()
|
|||||||
|
|
||||||
void PageMaterials::on_activate()
|
void PageMaterials::on_activate()
|
||||||
{
|
{
|
||||||
if (! presets_loaded) {
|
check_and_update_presets(true);
|
||||||
wizard_p()->update_materials(materials->technology);
|
|
||||||
reload_presets();
|
|
||||||
}
|
|
||||||
first_paint = true;
|
first_paint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2507,7 +2514,7 @@ void ConfigWizard::priv::load_vendors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
appconfig_new.set_section(section_name, section_new);
|
appconfig_new.set_section(section_name, section_new);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWizard::priv::add_page(ConfigWizardPage *page)
|
void ConfigWizard::priv::add_page(ConfigWizardPage *page)
|
||||||
@ -2589,78 +2596,37 @@ void ConfigWizard::priv::set_run_reason(RunReason run_reason)
|
|||||||
|
|
||||||
void ConfigWizard::priv::update_materials(Technology technology)
|
void ConfigWizard::priv::update_materials(Technology technology)
|
||||||
{
|
{
|
||||||
|
auto add_material = [](Materials& materials, PresetAliases& aliases, const Preset& preset, const Preset* printer = nullptr) {
|
||||||
|
if (!materials.containts(&preset)) {
|
||||||
|
materials.push(&preset);
|
||||||
|
if (!preset.alias.empty())
|
||||||
|
aliases[preset.alias].emplace(&preset);
|
||||||
|
}
|
||||||
|
if (printer) {
|
||||||
|
materials.add_printer(printer);
|
||||||
|
materials.compatibility_counter[preset.alias]++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if ((any_fff_selected || custom_printer_in_bundle || custom_printer_selected) && (technology & T_FFF)) {
|
if ((any_fff_selected || custom_printer_in_bundle || custom_printer_selected) && (technology & T_FFF)) {
|
||||||
filaments.clear();
|
filaments.clear();
|
||||||
aliases_fff.clear();
|
aliases_fff.clear();
|
||||||
// Iterate filaments in all bundles
|
|
||||||
for (const auto &pair : bundles) {
|
for (const auto &[name, bundle] : bundles) {
|
||||||
for (const auto &filament : pair.second.preset_bundle->filaments) {
|
for (const auto &filament : bundle.preset_bundle->filaments) {
|
||||||
// Check if filament is already added
|
|
||||||
if (filaments.containts(&filament))
|
|
||||||
continue;
|
|
||||||
// Iterate printers in all bundles
|
// Iterate printers in all bundles
|
||||||
for (const auto &printer : pair.second.preset_bundle->printers) {
|
for (const auto &printer : bundle.preset_bundle->printers) {
|
||||||
if (!printer.is_visible || printer.printer_technology() != ptFFF)
|
if (!printer.is_visible || printer.printer_technology() != ptFFF)
|
||||||
continue;
|
continue;
|
||||||
// Filter out inapplicable printers
|
// Filter out inapplicable printers
|
||||||
if (is_compatible_with_printer(PresetWithVendorProfile(filament, filament.vendor), PresetWithVendorProfile(printer, printer.vendor))) {
|
if (is_compatible_with_printer(PresetWithVendorProfile(filament, filament.vendor), PresetWithVendorProfile(printer, printer.vendor)))
|
||||||
if (!filaments.containts(&filament)) {
|
add_material(filaments, aliases_fff, filament, &printer);
|
||||||
filaments.push(&filament);
|
|
||||||
if (!filament.alias.empty())
|
|
||||||
aliases_fff[filament.alias].insert(filament.name);
|
|
||||||
}
|
|
||||||
filaments.add_printer(&printer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// template filament bundle has no printers - filament would be never added
|
// template filament bundle has no printers - filament would be never added
|
||||||
if(pair.second.vendor_profile&& pair.second.vendor_profile->templates_profile && pair.second.preset_bundle->printers.begin() == pair.second.preset_bundle->printers.end())
|
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 (!filaments.containts(&filament)) {
|
|
||||||
filaments.push(&filament);
|
|
||||||
if (!filament.alias.empty())
|
|
||||||
aliases_fff[filament.alias].insert(filament.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// count compatible printers
|
|
||||||
for (const auto& preset : filaments.presets) {
|
|
||||||
// skip template filaments
|
|
||||||
if (preset->vendor && preset->vendor->templates_profile)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const auto filter = [preset](const std::pair<std::string, size_t> element) {
|
|
||||||
return preset->alias == element.first;
|
|
||||||
};
|
|
||||||
if (std::find_if(filaments.compatibility_counter.begin(), filaments.compatibility_counter.end(), filter) != filaments.compatibility_counter.end()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// find all aliases (except templates)
|
|
||||||
std::vector<size_t> idx_with_same_alias;
|
|
||||||
for (size_t i = 0; i < filaments.presets.size(); ++i) {
|
|
||||||
if (preset->alias == filaments.presets[i]->alias && ((filaments.presets[i]->vendor && !filaments.presets[i]->vendor->templates_profile) || !filaments.presets[i]->vendor))
|
|
||||||
idx_with_same_alias.push_back(i);
|
|
||||||
}
|
|
||||||
// check compatibility with each printer
|
|
||||||
size_t counter = 0;
|
|
||||||
for (const auto& printer : filaments.printers) {
|
|
||||||
if (!(*printer).is_visible || (*printer).printer_technology() != ptFFF)
|
|
||||||
continue;
|
|
||||||
bool compatible = false;
|
|
||||||
// Test other materials with same alias
|
|
||||||
for (size_t i = 0; i < idx_with_same_alias.size() && !compatible; ++i) {
|
|
||||||
const Preset& prst = *(filaments.presets[idx_with_same_alias[i]]);
|
|
||||||
const Preset& prntr = *printer;
|
|
||||||
if (is_compatible_with_printer(PresetWithVendorProfile(prst, prst.vendor), PresetWithVendorProfile(prntr, prntr.vendor))) {
|
|
||||||
compatible = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (compatible)
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
filaments.compatibility_counter.emplace_back(preset->alias, counter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (any_sla_selected && (technology & T_SLA)) {
|
if (any_sla_selected && (technology & T_SLA)) {
|
||||||
@ -2668,62 +2634,20 @@ void ConfigWizard::priv::update_materials(Technology technology)
|
|||||||
aliases_sla.clear();
|
aliases_sla.clear();
|
||||||
|
|
||||||
// Iterate SLA materials in all bundles
|
// Iterate SLA materials in all bundles
|
||||||
for (const auto &pair : bundles) {
|
for (const auto& [name, bundle] : bundles) {
|
||||||
for (const auto &material : pair.second.preset_bundle->sla_materials) {
|
for (const auto &material : bundle.preset_bundle->sla_materials) {
|
||||||
// Check if material is already added
|
|
||||||
if (sla_materials.containts(&material))
|
|
||||||
continue;
|
|
||||||
// Iterate printers in all bundles
|
// Iterate printers in all bundles
|
||||||
// For now, we only allow the profiles to be compatible with another profiles inside the same bundle.
|
// For now, we only allow the profiles to be compatible with another profiles inside the same bundle.
|
||||||
for (const auto& printer : pair.second.preset_bundle->printers) {
|
for (const auto& printer : bundle.preset_bundle->printers) {
|
||||||
if(!printer.is_visible || printer.printer_technology() != ptSLA)
|
if(!printer.is_visible || printer.printer_technology() != ptSLA)
|
||||||
continue;
|
continue;
|
||||||
// Filter out inapplicable printers
|
// Filter out inapplicable printers
|
||||||
if (is_compatible_with_printer(PresetWithVendorProfile(material, nullptr), PresetWithVendorProfile(printer, nullptr))) {
|
if (is_compatible_with_printer(PresetWithVendorProfile(material, nullptr), PresetWithVendorProfile(printer, nullptr)))
|
||||||
// Check if material is already added
|
// Check if material is already added
|
||||||
if(!sla_materials.containts(&material)) {
|
add_material(sla_materials, aliases_sla, material, &printer);
|
||||||
sla_materials.push(&material);
|
|
||||||
if (!material.alias.empty())
|
|
||||||
aliases_sla[material.alias].insert(material.name);
|
|
||||||
}
|
|
||||||
sla_materials.add_printer(&printer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// count compatible printers
|
|
||||||
for (const auto& preset : sla_materials.presets) {
|
|
||||||
|
|
||||||
const auto filter = [preset](const std::pair<std::string, size_t> element) {
|
|
||||||
return preset->alias == element.first;
|
|
||||||
};
|
|
||||||
if (std::find_if(sla_materials.compatibility_counter.begin(), sla_materials.compatibility_counter.end(), filter) != sla_materials.compatibility_counter.end()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::vector<size_t> idx_with_same_alias;
|
|
||||||
for (size_t i = 0; i < sla_materials.presets.size(); ++i) {
|
|
||||||
if(preset->alias == sla_materials.presets[i]->alias)
|
|
||||||
idx_with_same_alias.push_back(i);
|
|
||||||
}
|
|
||||||
size_t counter = 0;
|
|
||||||
for (const auto& printer : sla_materials.printers) {
|
|
||||||
if (!(*printer).is_visible || (*printer).printer_technology() != ptSLA)
|
|
||||||
continue;
|
|
||||||
bool compatible = false;
|
|
||||||
// Test otrher materials with same alias
|
|
||||||
for (size_t i = 0; i < idx_with_same_alias.size() && !compatible; ++i) {
|
|
||||||
const Preset& prst = *(sla_materials.presets[idx_with_same_alias[i]]);
|
|
||||||
const Preset& prntr = *printer;
|
|
||||||
if (is_compatible_with_printer(PresetWithVendorProfile(prst, prst.vendor), PresetWithVendorProfile(prntr, prntr.vendor))) {
|
|
||||||
compatible = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (compatible)
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
sla_materials.compatibility_counter.emplace_back(preset->alias, counter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2857,21 +2781,15 @@ bool ConfigWizard::priv::on_bnt_finish()
|
|||||||
index->go_to(page_downloader);
|
index->go_to(page_downloader);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* When Filaments or Sla Materials pages are activated,
|
|
||||||
* materials for this pages are automaticaly updated and presets are reloaded.
|
|
||||||
*
|
|
||||||
* But, if _Finish_ button was clicked without activation of those pages
|
|
||||||
* (for example, just some printers were added/deleted),
|
|
||||||
* than last changes wouldn't be updated for filaments/materials.
|
|
||||||
* SO, do that before close of Wizard
|
|
||||||
*/
|
|
||||||
update_materials(T_ANY);
|
|
||||||
if (any_fff_selected)
|
|
||||||
page_filaments->reload_presets();
|
|
||||||
if (any_sla_selected)
|
|
||||||
page_sla_materials->reload_presets();
|
|
||||||
|
|
||||||
// theres no need to check that filament is selected if we have only custom printer
|
/* 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()
|
||||||
|
*/
|
||||||
|
page_filaments->check_and_update_presets();
|
||||||
|
page_sla_materials->check_and_update_presets();
|
||||||
|
|
||||||
|
// there's no need to check that filament is selected if we have only custom printer
|
||||||
if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true;
|
if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true;
|
||||||
// check, that there is selected at least one filament/material
|
// check, that there is selected at least one filament/material
|
||||||
return check_and_install_missing_materials(T_ANY);
|
return check_and_install_missing_materials(T_ANY);
|
||||||
@ -3357,8 +3275,8 @@ void ConfigWizard::priv::update_presets_in_config(const std::string& section, co
|
|||||||
// add or delete presets had a same alias
|
// add or delete presets had a same alias
|
||||||
auto it = aliases.find(alias_key);
|
auto it = aliases.find(alias_key);
|
||||||
if (it != aliases.end())
|
if (it != aliases.end())
|
||||||
for (const std::string& name : it->second)
|
for (const Preset* preset : it->second)
|
||||||
update(section, name);
|
update(section, preset->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigWizard::priv::check_fff_selected()
|
bool ConfigWizard::priv::check_fff_selected()
|
||||||
|
@ -296,6 +296,7 @@ struct PageMaterials: ConfigWizardPage
|
|||||||
|
|
||||||
PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name);
|
PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name);
|
||||||
|
|
||||||
|
void check_and_update_presets(bool force_reload_presets = false);
|
||||||
void reload_presets();
|
void reload_presets();
|
||||||
void update_lists(int sel_type, int sel_vendor, int last_selected_printer = -1);
|
void update_lists(int sel_type, int sel_vendor, int last_selected_printer = -1);
|
||||||
void on_material_highlighted(int sel_material);
|
void on_material_highlighted(int sel_material);
|
||||||
@ -321,8 +322,8 @@ struct Materials
|
|||||||
Technology technology;
|
Technology technology;
|
||||||
// use vector for the presets to purpose of save of presets sorting in the bundle
|
// use vector for the presets to purpose of save of presets sorting in the bundle
|
||||||
std::vector<const Preset*> presets;
|
std::vector<const Preset*> presets;
|
||||||
// String is alias of material, size_t number of compatible counters
|
// String is alias of material, size_t number of compatible printers counters
|
||||||
std::vector<std::pair<std::string, size_t>> compatibility_counter;
|
std::map<std::string, size_t> compatibility_counter;
|
||||||
std::set<std::string> types;
|
std::set<std::string> types;
|
||||||
std::set<const Preset*> printers;
|
std::set<const Preset*> printers;
|
||||||
|
|
||||||
@ -579,7 +580,7 @@ wxDEFINE_EVENT(EVT_INDEX_PAGE, wxCommandEvent);
|
|||||||
|
|
||||||
// ConfigWizard private data
|
// ConfigWizard private data
|
||||||
|
|
||||||
typedef std::map<std::string, std::set<std::string>> PresetAliases;
|
typedef std::map<std::string, std::set<const Preset*>> PresetAliases;
|
||||||
|
|
||||||
struct ConfigWizard::priv
|
struct ConfigWizard::priv
|
||||||
{
|
{
|
||||||
@ -592,14 +593,14 @@ struct ConfigWizard::priv
|
|||||||
// PrinterPickers state.
|
// PrinterPickers state.
|
||||||
Materials filaments; // Holds available filament presets and their types & vendors
|
Materials filaments; // Holds available filament presets and their types & vendors
|
||||||
Materials sla_materials; // Ditto for SLA materials
|
Materials sla_materials; // Ditto for SLA materials
|
||||||
PresetAliases aliases_fff; // Map of aliase to preset names
|
PresetAliases aliases_fff; // Map of alias to material presets
|
||||||
PresetAliases aliases_sla; // Map of aliase to preset names
|
PresetAliases aliases_sla; // Map of alias to material presets
|
||||||
std::unique_ptr<DynamicPrintConfig> custom_config; // Backing for custom printer definition
|
std::unique_ptr<DynamicPrintConfig> custom_config; // Backing for custom printer definition
|
||||||
bool any_fff_selected; // Used to decide whether to display Filaments page
|
bool any_fff_selected; // Used to decide whether to display Filaments page
|
||||||
bool any_sla_selected; // Used to decide whether to display SLA Materials page
|
bool any_sla_selected; // Used to decide whether to display SLA Materials page
|
||||||
bool custom_printer_selected { false }; // New custom printer is requested
|
bool custom_printer_selected { false }; // New custom printer is requested
|
||||||
bool custom_printer_in_bundle { false }; // Older custom printer already exists when wizard starts
|
bool custom_printer_in_bundle { false }; // Older custom printer already exists when wizard starts
|
||||||
// Set to true if there are none FFF printers on the main FFF page. If true, only SLA printers are shown (not even custum printers)
|
// Set to true if there are none FFF printers on the main FFF page. If true, only SLA printers are shown (not even custom printers)
|
||||||
bool only_sla_mode { false };
|
bool only_sla_mode { false };
|
||||||
bool template_profile_selected { false }; // This bool has one purpose - to tell that template profile should be installed if its not (because it cannot be added to appconfig)
|
bool template_profile_selected { false }; // This bool has one purpose - to tell that template profile should be installed if its not (because it cannot be added to appconfig)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
///|/
|
///|/
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
|
#include "format.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
@ -304,8 +305,9 @@ TaskTimer::~TaskTimer()
|
|||||||
{
|
{
|
||||||
std::chrono::milliseconds stop_timer = std::chrono::duration_cast<std::chrono::milliseconds>(
|
std::chrono::milliseconds stop_timer = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
std::chrono::system_clock::now().time_since_epoch());
|
std::chrono::system_clock::now().time_since_epoch());
|
||||||
auto process_duration = std::chrono::milliseconds(stop_timer - start_timer).count();
|
const auto process_duration_ms = std::chrono::milliseconds(stop_timer - start_timer).count();
|
||||||
std::string out = (boost::format("\n!!! %1% duration = %2% ms \n\n") % task_name % process_duration).str();
|
const auto process_duration_s = long long(0.001 * process_duration_ms);
|
||||||
|
std::string out = format("\n! \"%1%\" duration = %2% s (%3% ms) \n", task_name, process_duration_s, process_duration_ms);
|
||||||
printf("%s", out.c_str());
|
printf("%s", out.c_str());
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
std::wstring stemp = std::wstring(out.begin(), out.end());
|
std::wstring stemp = std::wstring(out.begin(), out.end());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user