mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
ENH: validate the config from 3mf and give some hints when there are errors
Change-Id: Ic25e5426e4e85a35a6a2413109f47b653955ec78
This commit is contained in:
parent
84eebfc729
commit
9dceb42ba3
7 changed files with 174 additions and 76 deletions
|
@ -1565,8 +1565,8 @@ NotificationManager::NotificationManager(wxEvtHandler* evt_handler) :
|
|||
|
||||
void NotificationManager::on_change_color_mode(bool is_dark) {
|
||||
m_is_dark = is_dark;
|
||||
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications){
|
||||
notification->on_change_color_mode(is_dark);
|
||||
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications){
|
||||
notification->on_change_color_mode(is_dark);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2338,7 +2338,6 @@ size_t NotificationManager::get_notification_count() const
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void NotificationManager::bbl_show_plateinfo_notification(const std::string &text)
|
||||
{
|
||||
NotificationData data{NotificationType::BBLPlateInfo, NotificationLevel::PrintInfoNotificationLevel, BBL_NOTICE_MAX_INTERVAL, text};
|
||||
|
@ -2355,6 +2354,30 @@ void NotificationManager::bbl_show_plateinfo_notification(const std::string &tex
|
|||
push_notification_data(std::move(notification), 0);
|
||||
}
|
||||
|
||||
void NotificationManager::bbl_close_3mf_warn_notification()
|
||||
{
|
||||
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications)
|
||||
if (notification->get_type() == NotificationType::BBL3MFInfo) {
|
||||
notification->close();
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationManager::bbl_show_3mf_warn_notification(const std::string &text)
|
||||
{
|
||||
NotificationData data{NotificationType::BBL3MFInfo, NotificationLevel::ErrorNotificationLevel, BBL_NOTICE_MAX_INTERVAL, text};
|
||||
|
||||
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) {
|
||||
if (notification->get_type() == NotificationType::BBL3MFInfo) {
|
||||
notification->reinit();
|
||||
notification->update(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto notification = std::make_unique<NotificationManager::PopNotification>(data, m_id_provider, m_evt_handler);
|
||||
push_notification_data(std::move(notification), 0);
|
||||
}
|
||||
|
||||
void NotificationManager::bbl_close_plateinfo_notification()
|
||||
{
|
||||
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications)
|
||||
|
@ -2363,6 +2386,7 @@ void NotificationManager::bbl_close_plateinfo_notification()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void NotificationManager::bbl_show_preview_only_notification(const std::string &text)
|
||||
{
|
||||
NotificationData data{NotificationType::BBLPreviewOnlyMode, NotificationLevel::WarningNotificationLevel, 0, text};
|
||||
|
|
|
@ -123,6 +123,8 @@ enum class NotificationType
|
|||
ArrangeOngoing,
|
||||
// BBL: Plate Info ,Design For @YangLeDuo
|
||||
BBLPlateInfo,
|
||||
// BBL: 3MF warnings
|
||||
BBL3MFInfo,
|
||||
// BBL: Some Objects Info, Design For @YangLeDuo
|
||||
BBLObjectInfo,
|
||||
// BBL: Objects have empty layer when Slicing
|
||||
|
@ -282,6 +284,10 @@ public:
|
|||
void bbl_show_plateinfo_notification(const std::string &text);
|
||||
void bbl_close_plateinfo_notification();
|
||||
|
||||
//BBS-- 3mf warning
|
||||
void bbl_show_3mf_warn_notification(const std::string &text);
|
||||
void bbl_close_3mf_warn_notification();
|
||||
|
||||
//BBS--preview only mode
|
||||
void bbl_show_preview_only_notification(const std::string &text);
|
||||
void bbl_close_preview_only_notification();
|
||||
|
|
|
@ -3197,6 +3197,21 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
config.apply(static_cast<const ConfigBase &>(FullPrintConfig::defaults()));
|
||||
// and place the loaded config over the base.
|
||||
config += std::move(config_loaded);
|
||||
std::map<std::string, std::string> validity = config.validate();
|
||||
if (!validity.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("Param values in 3mf error: ");
|
||||
for (std::map<std::string, std::string>::iterator it=validity.begin(); it!=validity.end(); ++it)
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("%1%: %2%")%it->first %it->second;
|
||||
//
|
||||
NotificationManager *notify_manager = q->get_notification_manager();
|
||||
std::string error_message = L("Invalid values found in the 3mf:");
|
||||
error_message += "\n";
|
||||
for (std::map<std::string, std::string>::iterator it=validity.begin(); it!=validity.end(); ++it)
|
||||
error_message += "-" + it->first + ": " + it->second + "\n";
|
||||
error_message += "\n";
|
||||
error_message += L("Please correct them in the param tabs");
|
||||
notify_manager->bbl_show_3mf_warn_notification(error_message);
|
||||
}
|
||||
}
|
||||
if (!config_substitutions.empty()) show_substitutions_info(config_substitutions.substitutions, filename.string());
|
||||
|
||||
|
@ -7453,6 +7468,7 @@ int Plater::new_project(bool skip_confirm, bool silent)
|
|||
m_loading_project = false;
|
||||
get_notification_manager()->bbl_close_plateinfo_notification();
|
||||
get_notification_manager()->bbl_close_preview_only_notification();
|
||||
get_notification_manager()->bbl_close_3mf_warn_notification();
|
||||
|
||||
if (!silent)
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
|
@ -7536,6 +7552,7 @@ void Plater::load_project(wxString const& filename2,
|
|||
m_exported_file = false;
|
||||
get_notification_manager()->bbl_close_plateinfo_notification();
|
||||
get_notification_manager()->bbl_close_preview_only_notification();
|
||||
get_notification_manager()->bbl_close_3mf_warn_notification();
|
||||
|
||||
auto path = into_path(filename);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue