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,59 +157,66 @@ 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))
|
||||||
}
|
|
||||||
|
|
||||||
for (wxString file : m_files)
|
|
||||||
{
|
|
||||||
std::string config_file = m_resource_file_path + "/printers/" + file.ToStdString();
|
|
||||||
boost::nowide::ifstream json_file(config_file.c_str());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
json jj;
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": direction does not exist ";
|
||||||
if (json_file.is_open())
|
return subseries;
|
||||||
{
|
}
|
||||||
json_file >> jj;
|
|
||||||
if (jj.contains("00.00.00.00"))
|
|
||||||
{
|
|
||||||
json const& printer = jj["00.00.00.00"];
|
|
||||||
if (printer.contains("subseries"))
|
|
||||||
{
|
|
||||||
std::vector<std::string> subs;
|
|
||||||
|
|
||||||
std::string model_id = printer["model_id"].get<std::string>();
|
for (const auto& entry : boost::filesystem::directory_iterator(from_dir))
|
||||||
if (model_id == type_str || type_str.empty())
|
{
|
||||||
|
const boost::filesystem::path& file_path = entry.path();
|
||||||
|
if (boost::filesystem::is_regular_file(file_path) && file_path.extension() == ".json")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json jj;
|
||||||
|
boost::nowide::ifstream json_file(file_path.string());
|
||||||
|
if (json_file.is_open())
|
||||||
|
{
|
||||||
|
json_file >> jj;
|
||||||
|
if (jj.contains("00.00.00.00"))
|
||||||
{
|
{
|
||||||
for (auto res : printer["subseries"])
|
json const& printer = jj["00.00.00.00"];
|
||||||
|
if (printer.contains("subseries"))
|
||||||
{
|
{
|
||||||
subs.emplace_back(res.get<std::string>());
|
std::vector<std::string> subs;
|
||||||
|
std::string model_id = printer["model_id"].get<std::string>();
|
||||||
|
if (model_id == type_str || type_str.empty())
|
||||||
|
{
|
||||||
|
for (auto res : printer["subseries"])
|
||||||
|
{
|
||||||
|
subs.emplace_back(res.get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
subseries.insert(make_pair(model_id, subs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subseries.insert(make_pair(model_id, subs));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to load " << file_path.filename().string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
}
|
||||||
{
|
catch (const std::exception& e)
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to load " << file;
|
{
|
||||||
}
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user