ConfigWizard: Suppress to select SLA printer if a multi-parts object is on a Plater
This commit is contained in:
parent
4103086a6e
commit
580f157d28
5 changed files with 64 additions and 29 deletions
src/slic3r/GUI
|
@ -30,6 +30,8 @@
|
|||
#include "libslic3r/Platform.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
|
@ -40,7 +42,6 @@
|
|||
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||
#include "format.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "UnsavedChangesDialog.hpp"
|
||||
|
||||
#if defined(__linux__) && defined(__WXGTK3__)
|
||||
|
@ -2477,6 +2478,46 @@ static std::string get_first_added_preset(const std::map<std::string, std::strin
|
|||
bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater, bool& apply_keeped_changes)
|
||||
{
|
||||
wxString header, caption = _L("Configuration is editing from ConfigWizard");
|
||||
const auto enabled_vendors = appconfig_new.vendors();
|
||||
|
||||
bool suppress_sla_printer = model_has_multi_part_objects(wxGetApp().model());
|
||||
PrinterTechnology preferred_pt = ptAny;
|
||||
auto get_preferred_printer_technology = [enabled_vendors, suppress_sla_printer](const std::string& bundle_name, const Bundle& bundle) {
|
||||
const auto config = enabled_vendors.find(bundle_name);
|
||||
PrinterTechnology pt = ptAny;
|
||||
if (config != enabled_vendors.end()) {
|
||||
for (const auto& model : bundle.vendor_profile->models) {
|
||||
if (const auto model_it = config->second.find(model.id);
|
||||
model_it != config->second.end() && model_it->second.size() > 0) {
|
||||
if (pt == ptAny)
|
||||
pt = model.technology;
|
||||
// if preferred printer model has SLA printer technology it's important to check the model for multypart state
|
||||
if (pt == ptSLA && suppress_sla_printer)
|
||||
continue;
|
||||
else
|
||||
return pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pt;
|
||||
};
|
||||
// Prusa printers are considered first, then 3rd party.
|
||||
if (preferred_pt = get_preferred_printer_technology("PrusaResearch", bundles.prusa_bundle());
|
||||
preferred_pt == ptAny || (preferred_pt == ptSLA && suppress_sla_printer)) {
|
||||
for (const auto& bundle : bundles) {
|
||||
if (bundle.second.is_prusa_bundle) { continue; }
|
||||
if (PrinterTechnology pt = get_preferred_printer_technology(bundle.first, bundle.second); pt == ptAny)
|
||||
continue;
|
||||
else if (preferred_pt == ptAny)
|
||||
preferred_pt = pt;
|
||||
if(!(preferred_pt == ptAny || (preferred_pt == ptSLA && suppress_sla_printer)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (preferred_pt == ptSLA && !wxGetApp().may_switch_to_SLA_preset(caption))
|
||||
return false;
|
||||
|
||||
bool check_unsaved_preset_changes = page_welcome->reset_user_profile();
|
||||
if (check_unsaved_preset_changes)
|
||||
header = _L("All user presets will be deleted.");
|
||||
|
@ -2484,8 +2525,6 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
|||
if (!check_unsaved_preset_changes)
|
||||
act_btns |= UnsavedChangesDialog::ActionButtons::SAVE;
|
||||
|
||||
const auto enabled_vendors = appconfig_new.vendors();
|
||||
|
||||
// Install bundles from resources if needed:
|
||||
std::vector<std::string> install_bundles;
|
||||
for (const auto &pair : bundles) {
|
||||
|
@ -2564,13 +2603,14 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
|||
std::string preferred_model;
|
||||
std::string preferred_variant;
|
||||
const auto enabled_vendors_old = app_config->vendors();
|
||||
auto get_preferred_printer_model = [enabled_vendors, enabled_vendors_old](const std::string& bundle_name, const Bundle& bundle, std::string& variant) {
|
||||
auto get_preferred_printer_model = [enabled_vendors, enabled_vendors_old, preferred_pt](const std::string& bundle_name, const Bundle& bundle, std::string& variant) {
|
||||
const auto config = enabled_vendors.find(bundle_name);
|
||||
if (config == enabled_vendors.end())
|
||||
return std::string();
|
||||
for (const auto& model : bundle.vendor_profile->models) {
|
||||
if (const auto model_it = config->second.find(model.id);
|
||||
model_it != config->second.end() && model_it->second.size() > 0) {
|
||||
model_it != config->second.end() && model_it->second.size() > 0 &&
|
||||
preferred_pt == model.technology) {
|
||||
variant = *model_it->second.begin();
|
||||
const auto config_old = enabled_vendors_old.find(bundle_name);
|
||||
if (config_old == enabled_vendors_old.end())
|
||||
|
|
|
@ -2432,6 +2432,20 @@ void GUI_App::open_web_page_localized(const std::string &http_address)
|
|||
open_browser_with_warning_dialog(http_address + "&lng=" + this->current_language_code_safe());
|
||||
}
|
||||
|
||||
// If we are switching from the FFF-preset to the SLA, we should to control the printed objects if they have a part(s).
|
||||
// Because of we can't to print the multi-part objects with SLA technology.
|
||||
bool GUI_App::may_switch_to_SLA_preset(const wxString& caption)
|
||||
{
|
||||
if (model_has_multi_part_objects(model())) {
|
||||
show_info(nullptr,
|
||||
_L("It's impossible to print multi-part object(s) with SLA technology.") + "\n\n" +
|
||||
_L("Please check your object list before preset changing."),
|
||||
caption);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage start_page)
|
||||
{
|
||||
wxCHECK_MSG(mainframe != nullptr, false, "Internal error: Main frame not created / null");
|
||||
|
@ -2447,13 +2461,9 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
|
|||
if (res) {
|
||||
load_current_presets();
|
||||
|
||||
if (preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA
|
||||
&& Slic3r::model_has_multi_part_objects(wxGetApp().model())) {
|
||||
GUI::show_info(nullptr,
|
||||
_L("It's impossible to print multi-part object(s) with SLA technology.") + "\n\n" +
|
||||
_L("Please check and fix your object list."),
|
||||
_L("Attention!"));
|
||||
}
|
||||
// #ysFIXME - delete after testing: This part of code looks redundant. All checks are inside ConfigWizard::priv::apply_config()
|
||||
if (preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA)
|
||||
may_switch_to_SLA_preset(_L("Configuration is editing from ConfigWizard"));
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -309,6 +309,7 @@ public:
|
|||
PrintHostJobQueue& printhost_job_queue() { return *m_printhost_job_queue.get(); }
|
||||
|
||||
void open_web_page_localized(const std::string &http_address);
|
||||
bool may_switch_to_SLA_preset(const wxString& caption);
|
||||
bool run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage start_page = ConfigWizard::SP_WELCOME);
|
||||
void show_desktop_integration_dialog();
|
||||
|
||||
|
|
|
@ -3236,7 +3236,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
|||
const PresetWithVendorProfile new_printer_preset_with_vendor_profile = m_presets->get_preset_with_vendor_profile(new_printer_preset);
|
||||
PrinterTechnology old_printer_technology = m_presets->get_edited_preset().printer_technology();
|
||||
PrinterTechnology new_printer_technology = new_printer_preset.printer_technology();
|
||||
if (new_printer_technology == ptSLA && old_printer_technology == ptFFF && !may_switch_to_SLA_preset())
|
||||
if (new_printer_technology == ptSLA && old_printer_technology == ptFFF && !wxGetApp().may_switch_to_SLA_preset(_L("New printer preset is selecting")))
|
||||
canceled = true;
|
||||
else {
|
||||
struct PresetUpdate {
|
||||
|
@ -3409,21 +3409,6 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
|
|||
return true;
|
||||
}
|
||||
|
||||
// If we are switching from the FFF-preset to the SLA, we should to control the printed objects if they have a part(s).
|
||||
// Because of we can't to print the multi-part objects with SLA technology.
|
||||
bool Tab::may_switch_to_SLA_preset()
|
||||
{
|
||||
if (model_has_multi_part_objects(wxGetApp().model()))
|
||||
{
|
||||
show_info( parent(),
|
||||
_(L("It's impossible to print multi-part object(s) with SLA technology.")) + "\n\n" +
|
||||
_(L("Please check your object list before preset changing.")),
|
||||
_(L("Attention!")) );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Tab::clear_pages()
|
||||
{
|
||||
// invalidated highlighter, if any exists
|
||||
|
|
|
@ -282,7 +282,6 @@ public:
|
|||
// Select a new preset, possibly delete the current one.
|
||||
void select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = "");
|
||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "");
|
||||
bool may_switch_to_SLA_preset();
|
||||
|
||||
virtual void clear_pages();
|
||||
virtual void update_description_lines();
|
||||
|
|
Loading…
Reference in a new issue