mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-05 20:56:15 +08:00
Merge branch 'dk_tools'
This commit is contained in:
commit
8976250fb9
@ -4119,7 +4119,7 @@ void GUI_App::select_filament_from_connect(const std::string& msg)
|
||||
}
|
||||
// test if currently selected is same type
|
||||
size_t extruder_count = preset_bundle->extruders_filaments.size();
|
||||
if (extruder_count != materials.size()) {
|
||||
if (extruder_count < materials.size()) {
|
||||
BOOST_LOG_TRIVIAL(error) << format("Failed to select filament from Connect. Selected printer has %1% extruders while data from Connect contains %2% materials.", extruder_count, materials.size());
|
||||
plater()->get_notification_manager()->close_notification_of_type(NotificationType::SelectFilamentFromConnect);
|
||||
// TRN: Notification text.
|
||||
@ -4127,7 +4127,7 @@ void GUI_App::select_filament_from_connect(const std::string& msg)
|
||||
return;
|
||||
}
|
||||
std::string notification_text;
|
||||
for (size_t i = 0; i < extruder_count; i++) {
|
||||
for (size_t i = 0; i < materials.size(); i++) {
|
||||
search_and_select_filaments(materials[i], avoid_abrasive.size() > i ? avoid_abrasive[i] : false, i, notification_text);
|
||||
}
|
||||
|
||||
|
@ -977,38 +977,18 @@ static std::string get_connect_state_suffix_for_printer(const Preset& printer_pr
|
||||
if (auto printer_state_map = wxGetApp().plater()->get_user_account()->get_printer_state_map();
|
||||
!printer_state_map.empty()) {
|
||||
|
||||
for (const auto& [printer_model_nozzle_pair, states] : printer_state_map) {
|
||||
std::string printer_model = printer_preset.config.opt_string("printer_model");
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(printer_preset);
|
||||
printer_model = printer_preset.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
|
||||
if (printer_preset.config.has("nozzle_diameter")) {
|
||||
double nozzle_diameter = static_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"))->values[0];
|
||||
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
|
||||
nozzle_diameter_serialized.Replace(L",", L".");
|
||||
|
||||
if (printer_model_nozzle_pair.first == printer_model
|
||||
&& printer_model_nozzle_pair.second == GUI::into_u8(nozzle_diameter_serialized))
|
||||
{
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
|
||||
if (states_cnt.available_cnt > 0)
|
||||
return "_available";
|
||||
if (states_cnt.busy_cnt > 0)
|
||||
return "_busy";
|
||||
return "_offline";
|
||||
}
|
||||
} else {
|
||||
if (printer_model_nozzle_pair.first == printer_model) {
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
|
||||
if (states_cnt.available_cnt > 0)
|
||||
return "_available";
|
||||
if (states_cnt.busy_cnt > 0)
|
||||
return "_busy";
|
||||
return "_offline";
|
||||
}
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(printer_preset);
|
||||
const std::string trimmed_preset_name = printer_preset.trim_vendor_repo_prefix(printer_preset.name, printer_with_vendor.vendor);
|
||||
for (const auto& [preset_name_from_map, states] : printer_state_map) {
|
||||
if (trimmed_preset_name != preset_name_from_map) {
|
||||
continue;
|
||||
}
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
if (states_cnt.available_cnt > 0)
|
||||
return "_available";
|
||||
if (states_cnt.busy_cnt > 0)
|
||||
return "_busy";
|
||||
return "_offline";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1029,47 +1009,24 @@ static bool fill_data_to_connect_info_line( const Preset& printer_preset,
|
||||
if (auto printer_state_map = wxGetApp().plater()->get_user_account()->get_printer_state_map();
|
||||
!printer_state_map.empty()) {
|
||||
|
||||
for (const auto& [printer_model_nozzle_pair, states] : printer_state_map) {
|
||||
// get printer_model without repo prefix
|
||||
std::string printer_model = printer_preset.config.opt_string("printer_model");
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(printer_preset);
|
||||
printer_model = printer_preset.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
|
||||
if (printer_preset.config.has("nozzle_diameter")) {
|
||||
double nozzle_diameter = static_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"))->values[0];
|
||||
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
|
||||
nozzle_diameter_serialized.Replace(L",", L".");
|
||||
|
||||
if (printer_model_nozzle_pair.first == printer_model
|
||||
&& printer_model_nozzle_pair.second == GUI::into_u8(nozzle_diameter_serialized))
|
||||
{
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
#ifdef _WIN32
|
||||
connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.available_cnt), _L("available")));
|
||||
connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.offline_cnt), _L("offline")));
|
||||
connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.busy_cnt), _L("printing")));
|
||||
#else
|
||||
connect_available_info->SetLabel(format_wxstr("%1% ", states_cnt.available_cnt));
|
||||
connect_offline_info ->SetLabel(format_wxstr("%1% ", states_cnt.offline_cnt));
|
||||
connect_printing_info ->SetLabel(format_wxstr("%1% ", states_cnt.busy_cnt));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (printer_model_nozzle_pair.first == printer_model) {
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
#ifdef _WIN32
|
||||
connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.available_cnt), _L("available")));
|
||||
connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.offline_cnt), _L("offline")));
|
||||
connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.busy_cnt), _L("printing")));
|
||||
#else
|
||||
connect_available_info->SetLabel(format_wxstr("%1% ", states_cnt.available_cnt));
|
||||
connect_offline_info ->SetLabel(format_wxstr("%1% ", states_cnt.offline_cnt));
|
||||
connect_printing_info ->SetLabel(format_wxstr("%1% ", states_cnt.busy_cnt));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(printer_preset);
|
||||
const std::string trimmed_preset_name = printer_preset.trim_vendor_repo_prefix(printer_preset.name, printer_with_vendor.vendor);
|
||||
for (const auto& [preset_name_from_map, states] : printer_state_map) {
|
||||
if (trimmed_preset_name != preset_name_from_map) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
#ifdef _WIN32
|
||||
connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.available_cnt), _L("available")));
|
||||
connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.offline_cnt), _L("offline")));
|
||||
connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.busy_cnt), _L("printing")));
|
||||
#else
|
||||
connect_available_info->SetLabel(format_wxstr("%1% ", states_cnt.available_cnt));
|
||||
connect_offline_info ->SetLabel(format_wxstr("%1% ", states_cnt.offline_cnt));
|
||||
connect_printing_info ->SetLabel(format_wxstr("%1% ", states_cnt.busy_cnt));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -3,8 +3,11 @@
|
||||
#include "UserAccountUtils.hpp"
|
||||
#include "format.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
@ -210,15 +213,17 @@ bool UserAccount::on_connect_printers_success(const std::string& data, AppConfig
|
||||
BOOST_LOG_TRIVIAL(error) << "Missing printer model for printer uuid: " << *printer_uuid;
|
||||
continue;
|
||||
}
|
||||
std::pair<std::string, std::string> model_nozzle_pair = m_printer_uuid_map[*printer_uuid];
|
||||
|
||||
std::string printer_name = m_printer_uuid_map[*printer_uuid];
|
||||
|
||||
if (new_printer_map.find(model_nozzle_pair) == new_printer_map.end()) {
|
||||
new_printer_map[model_nozzle_pair].reserve(static_cast<size_t>(ConnectPrinterState::CONNECT_PRINTER_STATE_COUNT));
|
||||
if (new_printer_map.find(printer_name) == new_printer_map.end()) {
|
||||
new_printer_map[printer_name].reserve(static_cast<size_t>(ConnectPrinterState::CONNECT_PRINTER_STATE_COUNT));
|
||||
for (size_t i = 0; i < static_cast<size_t>(ConnectPrinterState::CONNECT_PRINTER_STATE_COUNT); i++) {
|
||||
new_printer_map[model_nozzle_pair].push_back(0);
|
||||
new_printer_map[printer_name].push_back(0);
|
||||
}
|
||||
}
|
||||
new_printer_map[model_nozzle_pair][static_cast<size_t>(state)] += 1;
|
||||
new_printer_map[printer_name][static_cast<size_t>(state)] += 1;
|
||||
|
||||
}
|
||||
|
||||
// compare new and old printer map and update old map into new
|
||||
@ -256,27 +261,44 @@ bool UserAccount::on_connect_uiid_map_success(const std::string& data, AppConfig
|
||||
BOOST_LOG_TRIVIAL(error) << "Could not parse prusaconnect message. " << e.what();
|
||||
return false;
|
||||
}
|
||||
pt::ptree printers_ptree;
|
||||
if (auto it = ptree.find("printers"); it != ptree.not_found()) {
|
||||
printers_ptree = it->second;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "Could not parse prusaconnect message. \"printers\" subtree is missing.";
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& printer_tree : ptree) {
|
||||
const auto printer_uuid = printer_tree.second.get_optional<std::string>("printer_uuid");
|
||||
for (const auto& printer_sub : printers_ptree) {
|
||||
const pt::ptree &printer_ptree = printer_sub.second;
|
||||
const auto printer_uuid = printer_ptree.get_optional<std::string>("uuid");
|
||||
if (!printer_uuid) {
|
||||
continue;
|
||||
}
|
||||
const auto printer_model = printer_tree.second.get_optional<std::string>("printer_model");
|
||||
const auto printer_model = printer_ptree.get_optional<std::string>("printer_model");
|
||||
if (!printer_model) {
|
||||
continue;
|
||||
}
|
||||
const auto nozzle_diameter_opt = printer_tree.second.get_optional<std::string>("nozzle_diameter");
|
||||
const std::string nozzle_diameter = (nozzle_diameter_opt && *nozzle_diameter_opt != "0.0") ? *nozzle_diameter_opt : std::string();
|
||||
std::pair<std::string, std::string> model_nozzle_pair = { *printer_model, nozzle_diameter };
|
||||
m_printer_uuid_map[*printer_uuid] = model_nozzle_pair;
|
||||
|
||||
std::map<std::string, std::vector<std::string>> config_options_to_match;
|
||||
UserAccountUtils::fill_config_options_from_json(printer_ptree, config_options_to_match);
|
||||
const Preset* printer_preset = UserAccountUtils::find_preset_by_nozzle_and_options(wxGetApp().preset_bundle->printers, *printer_model, config_options_to_match);
|
||||
if (printer_preset) {
|
||||
// Preset can have repo prefix
|
||||
std::string trimmed_name = printer_preset->name;
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(*printer_preset);
|
||||
trimmed_name = printer_preset->trim_vendor_repo_prefix(trimmed_name, printer_with_vendor.vendor);
|
||||
m_printer_uuid_map[*printer_uuid] = trimmed_name;
|
||||
BOOST_LOG_TRIVIAL(error) << trimmed_name << " " << *printer_uuid;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed to find preset for printer model: " << *printer_model;
|
||||
}
|
||||
}
|
||||
m_communication->on_uuid_map_success();
|
||||
return on_connect_printers_success(data, app_config, out_printers_changed);
|
||||
}
|
||||
|
||||
std::string UserAccount::get_current_printer_uuid_from_connect(const std::string &selected_printer_id
|
||||
) const {
|
||||
std::string UserAccount::get_current_printer_uuid_from_connect(const std::string &selected_printer_id) const {
|
||||
if (m_current_printer_data_json_from_connect.empty() || m_current_printer_uuid_from_connect.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ enum class ConnectPrinterState {
|
||||
CONNECT_PRINTER_ERROR,
|
||||
CONNECT_PRINTER_STATE_COUNT
|
||||
};
|
||||
// <std::pair<std::string, std::string> is pair of printer_model and nozzle_diameter. std::vector<size_t> is vector of ConnectPrinterState counters
|
||||
typedef std::map<std::pair<std::string, std::string>, std::vector<size_t>> ConnectPrinterStateMap;
|
||||
typedef std::map< std::string, std::pair<std::string, std::string>> ConnectUUIDToModelNozzleMap;
|
||||
// printer preset name and std::vector<size_t> is vector of ConnectPrinterState counters
|
||||
typedef std::map<std::string, std::vector<size_t>> ConnectPrinterStateMap;
|
||||
typedef std::map< std::string, std::string> ConnectUUIDToPresetName;
|
||||
// Class UserAccount should handle every request for entities outside PrusaSlicer like PrusaAuth or PrusaConnect.
|
||||
// Outside communication is implemented in class UserAccountCommunication that runs separate thread. Results come back in events to Plater.
|
||||
// All incoming data shoud be stored in UserAccount.
|
||||
@ -85,7 +85,7 @@ private:
|
||||
std::unique_ptr<Slic3r::GUI::UserAccountCommunication> m_communication;
|
||||
|
||||
ConnectPrinterStateMap m_printer_map;
|
||||
ConnectUUIDToModelNozzleMap m_printer_uuid_map;
|
||||
ConnectUUIDToPresetName m_printer_uuid_map;
|
||||
std::map<std::string, std::string> m_account_user_data;
|
||||
std::string m_username;
|
||||
size_t m_fail_counter { 0 };
|
||||
@ -104,6 +104,7 @@ private:
|
||||
{"READY" , ConnectPrinterState::CONNECT_PRINTER_READY},
|
||||
{"ATTENTION", ConnectPrinterState::CONNECT_PRINTER_ATTENTION},
|
||||
{"BUSY" , ConnectPrinterState::CONNECT_PRINTER_BUSY},
|
||||
{"ERROR" , ConnectPrinterState::CONNECT_PRINTER_ERROR},
|
||||
};
|
||||
};
|
||||
}} // namespace slic3r::GUI
|
||||
|
@ -305,6 +305,8 @@ std::string UserAccountCommunication::get_shared_session_key()
|
||||
|
||||
void UserAccountCommunication::set_polling_enabled(bool enabled)
|
||||
{
|
||||
// Here enabled sets to USER_ACCOUNT_ACTION_CONNECT_PRINTER_MODELS so it gets full list on first,
|
||||
// than it should change inside session to USER_ACCOUNT_ACTION_CONNECT_STATUS
|
||||
return m_session->set_polling_action(enabled ? UserAccountActionID::USER_ACCOUNT_ACTION_CONNECT_PRINTER_MODELS : UserAccountActionID::USER_ACCOUNT_ACTION_DUMMY);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include "UserAccountUtils.hpp"
|
||||
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "slic3r/GUI/Field.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@ -38,10 +42,10 @@ pt::ptree parse_tree_for_subtree(const pt::ptree& tree, const std::string& param
|
||||
return pt::ptree();
|
||||
}
|
||||
|
||||
void json_to_ptree(boost::property_tree::ptree& ptree, const std::string& json) {
|
||||
void json_to_ptree(boost::property_tree::ptree& out_ptree, const std::string& json) {
|
||||
try {
|
||||
std::stringstream ss(json);
|
||||
pt::read_json(ss, ptree);
|
||||
pt::read_json(ss, out_ptree);
|
||||
} catch (const std::exception &e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed to parse json to ptree. " << e.what();
|
||||
BOOST_LOG_TRIVIAL(error) << "json: " << json;
|
||||
@ -50,7 +54,7 @@ void json_to_ptree(boost::property_tree::ptree& ptree, const std::string& json)
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string get_nozzle_from_json(boost::property_tree::ptree& ptree) {
|
||||
std::string get_nozzle_from_json(const boost::property_tree::ptree& ptree) {
|
||||
assert(!ptree.empty());
|
||||
|
||||
std::string out = parse_tree_for_param(ptree, "nozzle_diameter");
|
||||
@ -74,7 +78,7 @@ std::string get_keyword_from_json(boost::property_tree::ptree& ptree, const std:
|
||||
return parse_tree_for_param(ptree, keyword);
|
||||
}
|
||||
|
||||
void fill_supported_printer_models_from_json(boost::property_tree::ptree& ptree, std::vector<std::string>& result)
|
||||
void fill_supported_printer_models_from_json(const boost::property_tree::ptree& ptree, std::vector<std::string>& result)
|
||||
{
|
||||
assert(!ptree.empty());
|
||||
std::string printer_model = parse_tree_for_param(ptree, "printer_model");
|
||||
@ -103,13 +107,20 @@ std::string json_var_to_opt_string(const std::string& json_var)
|
||||
return json_var;
|
||||
}
|
||||
|
||||
void fill_config_options_from_json_inner(boost::property_tree::ptree& ptree, std::map<std::string, std::vector<std::string>>& result, const std::map<std::string, std::string>& parameters)
|
||||
void fill_config_options_from_json_inner(const boost::property_tree::ptree& ptree, std::map<std::string, std::vector<std::string>>& result, const std::map<std::string, std::string>& parameters)
|
||||
{
|
||||
pt::ptree slots = parse_tree_for_subtree(parse_tree_for_subtree(ptree, "slot"), "slots");
|
||||
pt::ptree slots = parse_tree_for_subtree(ptree, "tools");
|
||||
for (const auto &subtree : slots) {
|
||||
size_t slot_id;
|
||||
try {
|
||||
slot_id = boost::lexical_cast<std::size_t>(subtree.first);
|
||||
// id could "1" for extruder
|
||||
// or "1.1" for MMU (than we need number after dot as id)
|
||||
size_t dot_pos = subtree.first.find('.');
|
||||
if (dot_pos != std::string::npos) {
|
||||
slot_id = boost::lexical_cast<size_t>(subtree.first.substr(dot_pos + 1));
|
||||
} else {
|
||||
slot_id = boost::lexical_cast<std::size_t>(subtree.first);
|
||||
}
|
||||
} catch (const boost::bad_lexical_cast&) {
|
||||
continue;
|
||||
}
|
||||
@ -139,7 +150,7 @@ void fill_config_options_from_json_inner(boost::property_tree::ptree& ptree, std
|
||||
}
|
||||
}
|
||||
|
||||
void fill_config_options_from_json(boost::property_tree::ptree& ptree, std::map<std::string, std::vector<std::string>>& result)
|
||||
void fill_config_options_from_json(const boost::property_tree::ptree& ptree, std::map<std::string, std::vector<std::string>>& result)
|
||||
{
|
||||
assert(!ptree.empty());
|
||||
/*
|
||||
@ -232,7 +243,7 @@ void fill_material_from_json(const std::string& json, std::vector<std::string>&
|
||||
// if not found, find "filament" subtree
|
||||
|
||||
// find "slot" subtree
|
||||
pt::ptree slot_subtree = parse_tree_for_subtree(ptree, "slot");
|
||||
pt::ptree slot_subtree = parse_tree_for_subtree(ptree, "tools");
|
||||
if (slot_subtree.empty()) {
|
||||
// if not found, find "filament" subtree
|
||||
pt::ptree filament_subtree = parse_tree_for_subtree(ptree, "filament");
|
||||
@ -282,6 +293,12 @@ void fill_material_from_json(const std::string& json, std::vector<std::string>&
|
||||
for (const std::string& val : result_map["hardened"]) {
|
||||
avoid_abrasive_result.emplace_back(val == "0" ? 1 : 0);
|
||||
}
|
||||
// MMU has "hardened" only under tool 1
|
||||
if (avoid_abrasive_result.size() == 1 && material_result.size() > avoid_abrasive_result.size()) {
|
||||
for (size_t i = 1; i < material_result.size(); i++) {
|
||||
avoid_abrasive_result.emplace_back(avoid_abrasive_result[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,6 +337,68 @@ std::string get_print_data_from_json(const std::string& json, const std::string&
|
||||
return result;
|
||||
}
|
||||
|
||||
const Preset* find_preset_by_nozzle_and_options(
|
||||
const PrinterPresetCollection& collection
|
||||
, const std::string& model_id
|
||||
, std::map<std::string, std::vector<std::string>>& options)
|
||||
{
|
||||
// find all matching presets when repo prefix is omitted
|
||||
std::vector<const Preset*> results;
|
||||
for (const Preset &preset : collection) {
|
||||
// trim repo prefix
|
||||
std::string printer_model = preset.config.opt_string("printer_model");
|
||||
const PresetWithVendorProfile& printer_with_vendor = collection.get_preset_with_vendor_profile(preset);
|
||||
printer_model = preset.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
|
||||
if (!preset.is_system || printer_model != model_id)
|
||||
continue;
|
||||
// options (including nozzle_diameter)
|
||||
bool failed = false;
|
||||
for (const auto& opt : options) {
|
||||
assert(preset.config.has(opt.first));
|
||||
// We compare only first value now, but options contains data for all (some might be empty tho)
|
||||
std::string opt_val;
|
||||
if (preset.config.option(opt.first)->is_scalar()) {
|
||||
opt_val = preset.config.option(opt.first)->serialize();
|
||||
} else {
|
||||
switch (preset.config.option(opt.first)->type()) {
|
||||
case coInts: opt_val = std::to_string(static_cast<const ConfigOptionInts*>(preset.config.option(opt.first))->values[0]); break;
|
||||
case coFloats:
|
||||
opt_val = GUI::into_u8(double_to_string(static_cast<const ConfigOptionFloats*>(preset.config.option(opt.first))->values[0]));
|
||||
if (size_t pos = opt_val.find(",") != std::string::npos)
|
||||
opt_val.replace(pos, 1, 1, '.');
|
||||
break;
|
||||
case coStrings: opt_val = static_cast<const ConfigOptionStrings*>(preset.config.option(opt.first))->values[0]; break;
|
||||
case coBools: opt_val = static_cast<const ConfigOptionBools*>(preset.config.option(opt.first))->values[0] ? "1" : "0"; break;
|
||||
default:
|
||||
assert(false);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_val != opt.second[0])
|
||||
{
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!failed) {
|
||||
results.push_back(&preset);
|
||||
}
|
||||
|
||||
}
|
||||
// find one without prefix
|
||||
for (const Preset* preset : results) {
|
||||
if (preset->config.opt_string("printer_model") == model_id) {
|
||||
return preset;
|
||||
}
|
||||
}
|
||||
if (results.size() != 0) {
|
||||
return results.front();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}}} // Slic3r::GUI::UserAccountUtils
|
||||
|
||||
|
||||
|
@ -7,22 +7,26 @@
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
namespace Slic3r {
|
||||
class Preset;
|
||||
class PrinterPresetCollection;
|
||||
namespace GUI {
|
||||
namespace UserAccountUtils {
|
||||
|
||||
// If ptree parameter is empty, json parameter needs to contain data and ptree is filled.
|
||||
// If ptree is non-epty, json parameter is not used.
|
||||
std::string get_keyword_from_json(boost::property_tree::ptree& ptree, const std::string& json, const std::string& keyword);
|
||||
// Only ptree is passed since these functions are called on places that already has the ptree from get_keyword_from_json call
|
||||
std::string get_nozzle_from_json(boost::property_tree::ptree &ptree);
|
||||
void fill_supported_printer_models_from_json(boost::property_tree::ptree& ptree, std::vector<std::string>& result);
|
||||
void fill_config_options_from_json(boost::property_tree::ptree& ptree, std::map<std::string,std::vector<std::string>>& result);
|
||||
std::string get_nozzle_from_json(const boost::property_tree::ptree &ptree);
|
||||
void fill_supported_printer_models_from_json(const boost::property_tree::ptree& ptree, std::vector<std::string>& result);
|
||||
void fill_config_options_from_json(const boost::property_tree::ptree& ptree, std::map<std::string,std::vector<std::string>>& result);
|
||||
|
||||
// Since fill_material_from_json is called only from one place where ptree doesnt need to be shared, it is not always read from json.
|
||||
void fill_material_from_json(const std::string& json, std::vector<std::string>& material_result, std::vector<bool>& avoid_abrasive_result);
|
||||
|
||||
std::string get_print_data_from_json(const std::string &json, const std::string &keyword);
|
||||
|
||||
const Preset* find_preset_by_nozzle_and_options( const PrinterPresetCollection& collection, const std::string& model_id, std::map<std::string, std::vector<std::string>>& options);
|
||||
}}} // Slic3r::GUI::UserAccountUtils
|
||||
|
||||
#endif // slic3r_UserAccountUtils_hpp_
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
const std::string& connect_url() const { return m_connect_url; }
|
||||
|
||||
std::string connect_status_url() const { return m_connect_url + "/slicer/status"; }
|
||||
std::string connect_printer_list_url() const { return m_connect_url + "/slicer/printer_list"; }
|
||||
std::string connect_printer_list_url() const { return m_connect_url + "/slicer/v1/printers"; }
|
||||
std::string connect_select_printer_url() const { return m_connect_url + "/slicer-select-printer"; }
|
||||
std::string connect_printers_url() const { return m_connect_url + "/app/printers/"; }
|
||||
std::string connect_teams_url() const { return m_connect_url + "/app/teams"; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user