mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-02-17 01:49:41 -07: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:
parent
e8d8fb5c7a
commit
eac358046c
1 changed files with 43 additions and 36 deletions
|
|
@ -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::vector<wxString> m_files;
|
||||
std::map<std::string, std::vector<std::string>> subseries;
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": path= " << m_resource_file_path + "/printers/";
|
||||
#endif
|
||||
|
||||
wxDir dir(m_resource_file_path + "/printers/");
|
||||
if (!dir.IsOpened()) { return subseries; }
|
||||
|
||||
wxString filename;
|
||||
bool hasFile = dir.GetFirst(&filename, "*.json", wxDIR_FILES);
|
||||
while (hasFile)
|
||||
try
|
||||
{
|
||||
m_files.push_back(filename);
|
||||
hasFile = dir.GetNext(&filename);
|
||||
}
|
||||
|
||||
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
|
||||
const auto& from_dir = m_resource_file_path + "/printers/";
|
||||
if (!boost::filesystem::exists(from_dir))
|
||||
{
|
||||
json jj;
|
||||
if (json_file.is_open())
|
||||
{
|
||||
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;
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": direction does not exist ";
|
||||
return subseries;
|
||||
}
|
||||
|
||||
std::string model_id = printer["model_id"].get<std::string>();
|
||||
if (model_id == type_str || type_str.empty())
|
||||
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")
|
||||
{
|
||||
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 (...)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to load " << file;
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue