mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-21 12:15:21 +00:00
FIX: update the implementation of model series
JIRA: [STUDIO-13728] Change-Id: Ib9091a0b2b253fa4bdad11e07f8910f6045594ad (cherry picked from commit b250f817f80ea17e7c1cc37e6c98810e8cfc6cd8) (cherry picked from commit 4d00f9e32541df9817ef131dc2eb7225675e102f)
This commit is contained in:
@@ -157,32 +157,30 @@ std::string DevPrinterConfigUtil::get_fan_text(const std::string& type_str, int
|
|||||||
|
|
||||||
std::map<std::string, std::vector<std::string>> DevPrinterConfigUtil::get_all_subseries(std::string type_str)
|
std::map<std::string, std::vector<std::string>> DevPrinterConfigUtil::get_all_subseries(std::string type_str)
|
||||||
{
|
{
|
||||||
std::vector<wxString> m_files;
|
|
||||||
std::map<std::string, std::vector<std::string>> subseries;
|
std::map<std::string, std::vector<std::string>> subseries;
|
||||||
|
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": path= " << m_resource_file_path + "/printers/";
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": path= " << m_resource_file_path + "/printers/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxDir dir(m_resource_file_path + "/printers/");
|
try
|
||||||
if (!dir.IsOpened()) { return subseries; }
|
|
||||||
|
|
||||||
wxString filename;
|
|
||||||
bool hasFile = dir.GetFirst(&filename, "*.json", wxDIR_FILES);
|
|
||||||
while (hasFile)
|
|
||||||
{
|
{
|
||||||
m_files.push_back(filename);
|
const auto& from_dir = m_resource_file_path + "/printers/";
|
||||||
hasFile = dir.GetNext(&filename);
|
if (!boost::filesystem::exists(from_dir))
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": direction does not exist ";
|
||||||
|
return subseries;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (wxString file : m_files)
|
for (const auto& entry : boost::filesystem::directory_iterator(from_dir))
|
||||||
|
{
|
||||||
|
const boost::filesystem::path& file_path = entry.path();
|
||||||
|
if (boost::filesystem::is_regular_file(file_path) && file_path.extension() == ".json")
|
||||||
{
|
{
|
||||||
std::string config_file = m_resource_file_path + "/printers/" + file.ToStdString();
|
|
||||||
boost::nowide::ifstream json_file(config_file.c_str());
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
json jj;
|
json jj;
|
||||||
|
boost::nowide::ifstream json_file(file_path.string());
|
||||||
if (json_file.is_open())
|
if (json_file.is_open())
|
||||||
{
|
{
|
||||||
json_file >> jj;
|
json_file >> jj;
|
||||||
@@ -192,7 +190,6 @@ std::map<std::string, std::vector<std::string>> DevPrinterConfigUtil::get_all_su
|
|||||||
if (printer.contains("subseries"))
|
if (printer.contains("subseries"))
|
||||||
{
|
{
|
||||||
std::vector<std::string> subs;
|
std::vector<std::string> subs;
|
||||||
|
|
||||||
std::string model_id = printer["model_id"].get<std::string>();
|
std::string model_id = printer["model_id"].get<std::string>();
|
||||||
if (model_id == type_str || type_str.empty())
|
if (model_id == type_str || type_str.empty())
|
||||||
{
|
{
|
||||||
@@ -208,9 +205,19 @@ std::map<std::string, std::vector<std::string>> DevPrinterConfigUtil::get_all_su
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to load " << file;
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to load " << file_path.filename().string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": std::exception: " << e.what();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": unknown exception";
|
||||||
|
}
|
||||||
|
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
wxString result_str;
|
wxString result_str;
|
||||||
|
|||||||
Reference in New Issue
Block a user