OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::DevPrinterConfigUtil Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceCore/DevConfigUtil.h>

Collaboration diagram for Slic3r::DevPrinterConfigUtil:

Public Member Functions

 DevPrinterConfigUtil ()=default
 ~DevPrinterConfigUtil ()=default

Static Public Member Functions

static void InitFilePath (const std::string &res_file_path)
static std::map< std::string, std::string > get_all_model_id_with_name ()
static bool is_printer_model_compatible (const std::string &source_model, MachineObject &machine)
static bool is_optional_printer_model_id (const std::string &model_id)
static std::string get_printer_type (const std::string &type_str)
static std::string get_printer_display_name (const std::string &type_str)
static std::string get_printer_series_str (std::string type_str)
static PrinterArch get_printer_arch (std::string type_str)
static std::string get_printer_thumbnail_img (const std::string &type_str)
static std::string get_printer_connect_help_img (const std::string &type_str)
static std::string get_printer_auto_pa_cali_image (const std::string &type_str)
static std::string get_ftp_folder (std::string type_str)
static std::vector< std::string > get_resolution_supported (std::string type_str)
static std::vector< std::string > get_compatible_machine (std::string type_str)
static std::map< std::string, std::vector< std::string > > get_all_subseries (std::string type_str="")
static std::string get_printer_use_ams_type (std::string type_str)
static std::string get_printer_ams_img (const std::string &type_str)
static std::string get_printer_ext_img (const std::string &type_str, int pos)
static bool support_ams_fila_change_abort (std::string type_str)
static std::string get_filament_load_img (const std::string &type_str, int ext_id, bool has_nozzle_rack=false)
static std::string get_fan_text (const std::string &type_str, const std::string &key)
static std::vector< std::string > get_fan_text_params (const std::string &type_str, const std::string &key)
static std::string get_fan_text (const std::string &type_str, int airduct_mode, int airduct_func, int submode)
static std::string get_fan_mode_text (const std::string &type_str, int airduct_mode, const std::string &key)
static bool get_printer_can_set_nozzle (std::string type_str)
static std::string get_toolhead_display_name (const std::string &type_str, int ext_id, ToolHeadComponent component, ToolHeadNameCase name_case=ToolHeadNameCase::TitleCase, bool short_name=false)
static bool support_print_check_firmware_for_tpu_left (std::string type_str)
static bool support_user_first_setup_tpu_check (std::string type_str)
static std::string support_user_first_setup_tpu_check_url (std::string type_str)
static bool support_ams_ext_mix_print (std::string type_str)
static bool support_print_time_estimate_warning (std::string type_str)
static std::vector< std::string > get_unsupport_auto_cali_filaments (std::string type_str)
static bool support_disable_cali_flow_type (std::string type_str)
static bool support_wrapping_detection (const std::string &type_str)
static bool support_safety_options (const std::string &type_str)
static bool support_print_check_extension_fan_f000_mounted (const std::string &type_str)
static std::string air_print_detection_position (const std::string &type_str)
static int get_bed_temperature_limit (const std::string &type_str)
template<typename T>
static T get_value_from_config (const std::string &type_str, const std::string &item)
template<typename T>
static T get_value_from_config (const std::string &type_str, const std::string &item1, const std::string &item2)
static nlohmann::json get_json_from_config (const std::string &type_str, const std::string &key1, const std::string &key2=std::string())

Static Private Attributes

static std::string m_resource_file_path = ""

Detailed Description

Constructor & Destructor Documentation

◆ DevPrinterConfigUtil()

Slic3r::DevPrinterConfigUtil::DevPrinterConfigUtil ( )
default

◆ ~DevPrinterConfigUtil()

Slic3r::DevPrinterConfigUtil::~DevPrinterConfigUtil ( )
default

Member Function Documentation

◆ air_print_detection_position()

std::string Slic3r::DevPrinterConfigUtil::air_print_detection_position ( const std::string & type_str)
inlinestatic
129{ return get_value_from_config<std::string>(type_str, "air_print_detection_position"); }
static T get_value_from_config(const std::string &type_str, const std::string &item)
Definition DevConfigUtil.h:136

References get_value_from_config().

Here is the call graph for this function:

◆ get_all_model_id_with_name()

std::map< std::string, std::string > Slic3r::DevPrinterConfigUtil::get_all_model_id_with_name ( )
static
75{
76 {
77 std::map<std::string, std::string> models;
78
79 wxDir dir(m_resource_file_path + "/printers/");
80 if (!dir.IsOpened())
81 {
82 return models;
83 }
84
85 wxString filename;
86 std::vector<wxString> m_files;
87 bool hasFile = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
88 while (hasFile)
89 {
90 m_files.push_back(filename);
91 hasFile = dir.GetNext(&filename);
92 }
93
94 for (wxString file : m_files)
95 {
96 if (!file.Lower().ends_with(".json")) continue;
97
98 std::string config_file = m_resource_file_path + "/printers/" + file.ToStdString();
99 boost::nowide::ifstream json_file(config_file.c_str());
100
101 try
102 {
103 json jj;
104 if (json_file.is_open())
105 {
106 json_file >> jj;
107 if (jj.contains("00.00.00.00"))
108 {
109 json const& printer = jj["00.00.00.00"];
110
111 std::string model_id;
112 std::string display_name;
113 if (printer.contains("model_id")) { model_id = printer["model_id"].get<std::string>(); }
114 if (printer.contains("display_name")) { display_name = printer["display_name"].get<std::string>(); }
115 models[display_name] = model_id;
116 }
117 }
118 }
119 catch (...) {}
120 }
121
122 return models;
123 }
124}
static std::string m_resource_file_path
Definition DevConfigUtil.h:213
nlohmann::json json
Definition AssembleList.cpp:42

References m_resource_file_path.

Referenced by Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog().

Here is the caller graph for this function:

◆ get_all_subseries()

std::map< std::string, std::vector< std::string > > Slic3r::DevPrinterConfigUtil::get_all_subseries ( std::string type_str = "")
static
290{
291 std::map<std::string, std::vector<std::string>> subseries;
292
293#if !BBL_RELEASE_TO_PUBLIC
294 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": path= " << m_resource_file_path + "/printers/";
295#endif
296
297 try
298 {
299 const auto& from_dir = m_resource_file_path + "/printers/";
300 if (!boost::filesystem::exists(from_dir))
301 {
302 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": direction does not exist ";
303 return subseries;
304 }
305
306 for (const auto& entry : boost::filesystem::directory_iterator(from_dir))
307 {
308 const boost::filesystem::path& file_path = entry.path();
309 if (boost::filesystem::is_regular_file(file_path) && file_path.extension() == ".json")
310 {
311 try
312 {
313 json jj;
314 boost::nowide::ifstream json_file(file_path.string());
315 if (json_file.is_open())
316 {
317 json_file >> jj;
318 if (jj.contains("00.00.00.00"))
319 {
320 json const& printer = jj["00.00.00.00"];
321 if (printer.contains("subseries"))
322 {
323 std::vector<std::string> subs;
324 std::string model_id = printer["model_id"].get<std::string>();
325 if (model_id == type_str || type_str.empty())
326 {
327 for (auto res : printer["subseries"])
328 {
329 subs.emplace_back(res.get<std::string>());
330 }
331 }
332 subseries.insert(make_pair(model_id, subs));
333 }
334 }
335 }
336 }
337 catch (...)
338 {
339 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to load " << file_path.filename().string();
340 }
341 }
342 }
343 }
344 catch (const std::exception& e)
345 {
346 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": std::exception: " << e.what();
347 }
348 catch (...)
349 {
350 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": unknown exception";
351 }
352
353#if !BBL_RELEASE_TO_PUBLIC
354 wxString result_str;
355 for (auto item : subseries)
356 {
357 wxString item_str = item.first;
358 item_str += ": ";
359 for (auto to_item : item.second)
360 {
361 item_str += to_item;
362 item_str += " ";
363 }
364
365 result_str += item_str + ", ";
366 }
367
368 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": result= " << result_str;
369#endif
370
371 if (subseries.empty())
372 {
373 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": result= " << "empty";
374 }
375
376 return subseries;
377}

References m_resource_file_path.

Referenced by Slic3r::DeviceManager::parse_user_print_info().

Here is the caller graph for this function:

◆ get_bed_temperature_limit()

int Slic3r::DevPrinterConfigUtil::get_bed_temperature_limit ( const std::string & type_str)
inlinestatic
132{ return get_value_from_config<int>(type_str, "print", "bed_temperature_limit"); }

References get_value_from_config().

Here is the call graph for this function:

◆ get_compatible_machine()

std::vector< std::string > Slic3r::DevPrinterConfigUtil::get_compatible_machine ( std::string type_str)
inlinestatic
83{ return get_value_from_config<std::vector<std::string>>(type_str, "compatible_machine"); }

References get_value_from_config().

Referenced by Slic3r::GUI::_collect_sorted_machines(), and Slic3r::MachineObject::get_compatible_machine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_fan_mode_text()

std::string Slic3r::DevPrinterConfigUtil::get_fan_mode_text ( const std::string & type_str,
int airduct_mode,
const std::string & key )
static
260{
261 std::vector<std::string> filaments;
262 std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
263 boost::nowide::ifstream json_file(config_file.c_str());
264 try {
265 json jj;
266 if (json_file.is_open()) {
267 json_file >> jj;
268 if (jj.contains("00.00.00.00")) {
269 json const& printer = jj["00.00.00.00"];
270 if (!printer.contains("fan")) {
271 return std::string();
272 }
273
274 json const& fan_item = printer["fan"];
275 const auto& airduct_mode_str = std::to_string(airduct_mode);
276 if (!fan_item.contains(airduct_mode_str)) {
277 return std::string();
278 }
279
280 if (fan_item[airduct_mode_str].contains(key)) {
281 return fan_item[airduct_mode_str][key].get<std::string>();
282 }
283 }
284 }
285 } catch (...) {}
286 return std::string();
287}
bool contains(const std::vector< T > &vector, const Point &point)
Definition Geometry.cpp:55

References Slic3r::Geometry::contains(), and m_resource_file_path.

Here is the call graph for this function:

◆ get_fan_text() [1/2]

std::string Slic3r::DevPrinterConfigUtil::get_fan_text ( const std::string & type_str,
const std::string & key )
static
170{
171 std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
172 boost::nowide::ifstream json_file(config_file.c_str());
173 try
174 {
175 json jj;
176 if (json_file.is_open())
177 {
178 json_file >> jj;
179 if (jj.contains("00.00.00.00"))
180 {
181 json const& printer = jj["00.00.00.00"];
182 if (printer.contains("fan") && printer["fan"].contains(key))
183 {
184 return printer["fan"][key].get<std::string>();
185 }
186 }
187 }
188 }
189 catch (...) {}
190 return std::string();
191}

References m_resource_file_path.

Referenced by Slic3r::GUI::FanControlPopupNew::get_fan_func_name(), and Slic3r::GUI::FanControlPopupNew::init_names().

Here is the caller graph for this function:

◆ get_fan_text() [2/2]

std::string Slic3r::DevPrinterConfigUtil::get_fan_text ( const std::string & type_str,
int airduct_mode,
int airduct_func,
int submode )
static
213{
214 std::vector<std::string> filaments;
215 std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
216 boost::nowide::ifstream json_file(config_file.c_str());
217 try
218 {
219 json jj;
220 if (json_file.is_open())
221 {
222 json_file >> jj;
223 if (jj.contains("00.00.00.00"))
224 {
225 json const& printer = jj["00.00.00.00"];
226 if (!printer.contains("fan"))
227 {
228 return std::string();
229 }
230
231 json const& fan_item = printer["fan"];
232 const auto& airduct_mode_str = std::to_string(airduct_mode);
233 if (!fan_item.contains(airduct_mode_str))
234 {
235 return std::string();
236 }
237
238 json const& airduct_item = fan_item[airduct_mode_str];
239 const auto& airduct_func_str = std::to_string(airduct_func);
240 if (airduct_item.contains(airduct_func_str))
241 {
242 const auto& airduct_func_item = airduct_item[airduct_func_str];
243 if (airduct_func_item.is_object())
244 {
245 return airduct_func_item[std::to_string(submode)].get<std::string>();
246 }
247 else if (airduct_func_item.is_string())
248 {
249 return airduct_func_item.get<std::string>();
250 }
251 }
252 }
253 }
254 }
255 catch (...) {}
256 return std::string();
257}

References m_resource_file_path.

◆ get_fan_text_params()

std::vector< std::string > Slic3r::DevPrinterConfigUtil::get_fan_text_params ( const std::string & type_str,
const std::string & key )
static
194{
195 std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
196 boost::nowide::ifstream json_file(config_file.c_str());
197 try {
198 json jj;
199 if (json_file.is_open()) {
200 json_file >> jj;
201 if (jj.contains("00.00.00.00")) {
202 json const& printer = jj["00.00.00.00"];
203 if (printer.contains("fan") && printer["fan"].contains(key)) {
204 return printer["fan"][key].get<std::vector<std::string>>();
205 }
206 }
207 }
208 } catch (...) {}
209 return std::vector<std::string>();
210}

References m_resource_file_path.

◆ get_filament_load_img()

std::string Slic3r::DevPrinterConfigUtil::get_filament_load_img ( const std::string & type_str,
int ext_id,
bool has_nozzle_rack = false )
static
148{
149 if (has_nozzle_rack)
150 {
151 const auto &rack_vec = get_value_from_config<std::vector<std::string>>(type_str, "filament_load_image_nozzle_rack") ;
152 if (!rack_vec.empty())
153 {
154 if (ext_id >= 0 && static_cast<size_t>(ext_id) < rack_vec.size())
155 {
156 return rack_vec[ext_id];
157 }
158 return rack_vec[0];
159 }
160 }
161 const auto &vec = get_value_from_config<std::vector<std::string>>(type_str, "filament_load_image");
162 if (ext_id >= 0 && static_cast<size_t>(ext_id) < vec.size())
163 {
164 return vec[ext_id];
165 }
166 return vec.empty() ? std::string() : vec[0];
167}

References get_value_from_config().

Referenced by Slic3r::GUI::StatusBasePanel::expand_filament_loading().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ftp_folder()

std::string Slic3r::DevPrinterConfigUtil::get_ftp_folder ( std::string type_str)
inlinestatic
81{ return get_value_from_config<std::string>(type_str, "ftp_folder"); }

References get_value_from_config().

Referenced by Slic3r::MachineObject::get_ftp_folder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_json_from_config()

nlohmann::json Slic3r::DevPrinterConfigUtil::get_json_from_config ( const std::string & type_str,
const std::string & key1,
const std::string & key2 = std::string() )
inlinestatic
180 {
181 std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
182 boost::nowide::ifstream json_file(config_file.c_str());
183 try
184 {
185 nlohmann::json jj;
186 if (json_file.is_open())
187 {
188 json_file >> jj;
189 if (jj.contains("00.00.00.00"))
190 {
191 nlohmann::json const& printer = jj["00.00.00.00"];
192 if (printer.contains(key1))
193 {
194 nlohmann::json const& key1_item = printer[key1];
195 if (key2.empty())
196 {
197 return key1_item;
198 }
199
200 if (key1_item.contains(key2))
201 {
202 return key1_item[key2];
203 }
204 }
205 }
206 }
207 }
208 catch (...) { assert(0 && "get_json_from_config failed"); BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " failed"; }// there are file errors
209 return nlohmann::json();
210 }

References m_resource_file_path.

Referenced by Slic3r::MachineObject::get_nozzle_replace_url().

Here is the caller graph for this function:

◆ get_printer_ams_img()

std::string Slic3r::DevPrinterConfigUtil::get_printer_ams_img ( const std::string & type_str)
inlinestatic
88{ return get_value_from_config<std::string>(type_str, "printer_use_ams_image"); }

References get_value_from_config().

Referenced by Slic3r::GUI::AMSSetting::update_ams_img().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_arch()

PrinterArch Slic3r::DevPrinterConfigUtil::get_printer_arch ( std::string type_str)
static
127{
128 const std::string& arch_str = get_value_from_config<std::string>(type_str, "printer_arch");
129 if (arch_str == "i3")
130 {
132 }
133 else if (arch_str == "core_xy")
134 {
136 }
137
139}
@ ARCH_CORE_XY
Definition DevDefs.h:29
@ ARCH_I3
Definition DevDefs.h:30

References ARCH_CORE_XY, ARCH_I3, and get_value_from_config().

Referenced by Slic3r::MachineObject::get_printer_arch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_auto_pa_cali_image()

std::string Slic3r::DevPrinterConfigUtil::get_printer_auto_pa_cali_image ( const std::string & type_str)
inlinestatic
78{ return get_value_from_config<std::string>(type_str, "auto_pa_cali_thumbnail_image"); }

References get_value_from_config().

Referenced by Slic3r::MachineObject::get_auto_pa_cali_thumbnail_img_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_can_set_nozzle()

bool Slic3r::DevPrinterConfigUtil::get_printer_can_set_nozzle ( std::string type_str)
inlinestatic
100{ return get_value_from_config<bool>(type_str, "enable_set_nozzle_info"); }// can set nozzle from studio

References get_value_from_config().

Referenced by Slic3r::GUI::Plater::check_printer_initialized(), and Slic3r::GUI::PrinterPartsDialog::Show().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_connect_help_img()

std::string Slic3r::DevPrinterConfigUtil::get_printer_connect_help_img ( const std::string & type_str)
inlinestatic
77{ return get_value_from_config<std::string>(type_str, "printer_connect_help_image"); }

References get_value_from_config().

Referenced by Slic3r::GUI::ConnectPrinterDialog::init_bitmap(), and Slic3r::GUI::InputIpAddressDialog::set_machine_obj().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_display_name()

std::string Slic3r::DevPrinterConfigUtil::get_printer_display_name ( const std::string & type_str)
inlinestatic

◆ get_printer_ext_img()

std::string Slic3r::DevPrinterConfigUtil::get_printer_ext_img ( const std::string & type_str,
int pos )
static
142{
143 const auto& vec = get_value_from_config<std::vector<std::string>>(type_str, "printer_ext_image");
144 return (vec.size() > pos) ? vec[pos] : std::string();
145};
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References get_value_from_config().

Referenced by Slic3r::GUI::AMSExtImage::get_bmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_series_str()

std::string Slic3r::DevPrinterConfigUtil::get_printer_series_str ( std::string type_str)
inlinestatic
72{ return get_value_from_config<std::string>(type_str, "printer_series"); }

References get_value_from_config().

Referenced by Slic3r::MachineObject::get_printer_series(), Slic3r::MachineObject::get_printer_series_str(), Slic3r::MachineObject::is_series_n(), Slic3r::MachineObject::is_series_o(), Slic3r::MachineObject::is_series_p(), Slic3r::MachineObject::is_series_x(), and Slic3r::GUI::MediaPlayCtrl::SetMachineObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_thumbnail_img()

std::string Slic3r::DevPrinterConfigUtil::get_printer_thumbnail_img ( const std::string & type_str)
inlinestatic
76{ return get_value_from_config<std::string>(type_str, "printer_thumbnail_image"); }

References get_value_from_config().

Referenced by Slic3r::MachineObject::get_printer_thumbnail_img_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_type()

std::string Slic3r::DevPrinterConfigUtil::get_printer_type ( const std::string & type_str)
inlinestatic
70{ return get_value_from_config<std::string>(type_str, "printer_type"); }

References get_value_from_config().

Referenced by Slic3r::_parse_printer_type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_printer_use_ams_type()

std::string Slic3r::DevPrinterConfigUtil::get_printer_use_ams_type ( std::string type_str)
inlinestatic
87{ return get_value_from_config<std::string>(type_str, "use_ams_type"); }

References get_value_from_config().

Referenced by Slic3r::MachineObject::get_printer_ams_type(), and Slic3r::GUI::AMSSetting::update_insert_material_read_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_resolution_supported()

std::vector< std::string > Slic3r::DevPrinterConfigUtil::get_resolution_supported ( std::string type_str)
inlinestatic
82{ return get_value_from_config<std::vector<std::string>>(type_str, "camera_resolution"); }

References get_value_from_config().

Here is the call graph for this function:

◆ get_toolhead_display_name()

std::string Slic3r::DevPrinterConfigUtil::get_toolhead_display_name ( const std::string & type_str,
int ext_id,
ToolHeadComponent component,
ToolHeadNameCase name_case = ToolHeadNameCase::TitleCase,
bool short_name = false )
static
385{
386 static const std::map<ToolHeadComponent, std::string> comp_keys = {
387 { ToolHeadComponent::Extruder, "extruder" },
388 { ToolHeadComponent::Nozzle, "nozzle" },
389 { ToolHeadComponent::Hotend, "hotend" }
390 };
391
392 int case_index = static_cast<int>(name_case); // 0, 1, 2
393
394 // Try to read from printer config json
395 auto names_json = get_value_from_config<json>(type_str, "tool_head_display_names");
396 std::string role_key = std::to_string(ext_id); // "0" or "1"
397 const std::string& comp_key = comp_keys.at(component);
398
399 std::string result;
400
401 if (!names_json.is_null()
402 && names_json.contains(role_key)
403 && names_json[role_key].contains(comp_key))
404 {
405 auto& arr = names_json[role_key][comp_key];
406 if (arr.is_array() && case_index < static_cast<int>(arr.size())) {
407 result = arr[case_index].get<std::string>();
408 }
409 }
410
411 // Orca: models that ship no tool_head_display_names (e.g. H2D/H2S) must still get distinct
412 // per-extruder labels, so fall back to the previous programmatic Left/Right construction.
413 // Engages only when the config lookup above yields nothing, so models that ship the key
414 // behave exactly like the reference.
415 if (result.empty()) {
416 const std::string side = ext_id == DEPUTY_EXTRUDER_ID ? "Left" : "Right";
417 const std::string component_name = component == ToolHeadComponent::Extruder ? "Extruder" :
418 component == ToolHeadComponent::Hotend ? "Hotend" : "Nozzle";
419 result = side + " " + component_name;
420 if (name_case == ToolHeadNameCase::SentenceCase && result.size() > side.size() + 1)
421 result[side.size() + 1] = static_cast<char>(std::tolower(static_cast<unsigned char>(result[side.size() + 1])));
422 else if (name_case == ToolHeadNameCase::LowerCase)
423 std::transform(result.begin(), result.end(), result.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
424 }
425
426 // short_name: return only the role prefix (e.g. "Main" from "Main Nozzle")
427 if (short_name) {
428 auto sp = result.find(' ');
429 if (sp != std::string::npos) {
430 result = result.substr(0, sp);
431 }
432 }
433
434 return result;
435}
#define DEPUTY_EXTRUDER_ID
Definition DevDefs.h:102
@ Extruder
Definition DevConfigUtil.h:34
@ Hotend
Definition DevConfigUtil.h:36
@ Nozzle
Definition DevConfigUtil.h:35
@ SentenceCase
Definition DevConfigUtil.h:42
@ LowerCase
Definition DevConfigUtil.h:43

References DEPUTY_EXTRUDER_ID, Slic3r::Extruder, get_value_from_config(), Slic3r::Hotend, Slic3r::LowerCase, Slic3r::Nozzle, and Slic3r::SentenceCase.

Referenced by Slic3r::GUI::AmsMapingPopup::AmsMapingPopup(), Slic3r::GUI::EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(), Slic3r::GUI::FeedDirectionDialog::FeedDirectionDialog(), Slic3r::GUI::NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(), Slic3r::GUI::UnsavedChangesDialog::build(), Slic3r::GUI::NozzleListTable::BuildTextObjStr(), WipingDialog::BuildTextObjStr(), Slic3r::check_filaments_printable(), Slic3r::GUI::Tab::generate_extruder_options(), Slic3r::GUI::SyncAmsInfoDialog::is_nozzle_type_match(), Slic3r::GUI::HistoryWindow::on_device_connected(), Slic3r::GUI::FeedDirectionDialog::OnRadioClicked(), Slic3r::GUI::CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(), Slic3r::GUI::Tab::sync_excluder(), Slic3r::GUI::HistoryWindow::sync_history_data(), Slic3r::GUI::AmsReplaceMaterialDialog::update_machine_obj(), Slic3r::GUI::Sidebar::update_presets(), and Slic3r::GUI::AmsMapingPopup::update_title().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unsupport_auto_cali_filaments()

std::vector< std::string > Slic3r::DevPrinterConfigUtil::get_unsupport_auto_cali_filaments ( std::string type_str)
inlinestatic
118{ return get_value_from_config<std::vector<std::string>>(type_str, "auto_cali_not_support_filaments"); }

References get_value_from_config().

Referenced by Slic3r::GUI::SelectMachineDialog::can_support_pa_auto_cali().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_value_from_config() [1/2]

template<typename T>
T Slic3r::DevPrinterConfigUtil::get_value_from_config ( const std::string & type_str,
const std::string & item )
inlinestatic
137 {
138 std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
139 boost::nowide::ifstream json_file(config_file.c_str());
140 try
141 {
142 nlohmann::json jj;
143 if (json_file.is_open())
144 {
145 json_file >> jj;
146 if (jj.contains("00.00.00.00"))
147 {
148 nlohmann::json const& printer = jj["00.00.00.00"];
149 if (printer.contains(item))
150 {
151 return printer[item].get<T>();
152 }
153 }
154 }
155 }
156 catch (...) { assert(0 && "get_value_from_config failed"); BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " failed"; }// there are file errors
157 return T();
158 };

References m_resource_file_path.

Referenced by air_print_detection_position(), get_bed_temperature_limit(), get_compatible_machine(), get_filament_load_img(), get_ftp_folder(), get_printer_ams_img(), get_printer_arch(), get_printer_auto_pa_cali_image(), get_printer_can_set_nozzle(), get_printer_connect_help_img(), get_printer_display_name(), get_printer_ext_img(), get_printer_series_str(), get_printer_thumbnail_img(), get_printer_type(), get_printer_use_ams_type(), get_resolution_supported(), get_toolhead_display_name(), get_unsupport_auto_cali_filaments(), get_value_from_config(), support_ams_ext_mix_print(), support_ams_fila_change_abort(), support_disable_cali_flow_type(), support_print_check_extension_fan_f000_mounted(), support_print_check_firmware_for_tpu_left(), support_print_time_estimate_warning(), support_safety_options(), support_user_first_setup_tpu_check(), support_user_first_setup_tpu_check_url(), support_wrapping_detection(), and Slic3r::GUI::SelectMachineDialog::update_show_status().

Here is the caller graph for this function:

◆ get_value_from_config() [2/2]

template<typename T>
T Slic3r::DevPrinterConfigUtil::get_value_from_config ( const std::string & type_str,
const std::string & item1,
const std::string & item2 )
inlinestatic
162 {
163 try
164 {
165 const auto& json_item1 = get_value_from_config<nlohmann::json>(type_str, item1);
166 if (json_item1.contains(item2))
167 {
168 return json_item1[item2].get<T>();
169 }
170 }
171 catch (...)
172 {
173 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " failed to get " << item1 << ", " << item2;
174 }
175
176 return T();
177 }

References get_value_from_config().

Here is the call graph for this function:

◆ InitFilePath()

void Slic3r::DevPrinterConfigUtil::InitFilePath ( const std::string & res_file_path)
inlinestatic
61{ m_resource_file_path = res_file_path; };

References m_resource_file_path.

Referenced by Slic3r::DeviceManager::DeviceManager().

Here is the caller graph for this function:

◆ is_optional_printer_model_id()

bool Slic3r::DevPrinterConfigUtil::is_optional_printer_model_id ( const std::string & model_id)
inlinestatic

◆ is_printer_model_compatible()

bool Slic3r::DevPrinterConfigUtil::is_printer_model_compatible ( const std::string & source_model,
MachineObject & machine )
static
61{
62 const std::string& target_model = machine.printer_type;
63 if (is_optional_printer_model_id(source_model) || is_optional_printer_model_id(target_model))
64 return true;
65
66 if (source_model == target_model)
67 return true;
68
69 const auto compatible_machine = machine.get_compatible_machine();
70 return std::find(compatible_machine.begin(), compatible_machine.end(), source_model) != compatible_machine.end();
71}
static bool is_optional_printer_model_id(const std::string &model_id)
Definition DevConfigUtil.h:69

References Slic3r::MachineObject::get_compatible_machine(), is_optional_printer_model_id(), and Slic3r::MachineObject::printer_type.

Referenced by Slic3r::GUI::GUI_App::is_blocking_printing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ support_ams_ext_mix_print()

bool Slic3r::DevPrinterConfigUtil::support_ams_ext_mix_print ( std::string type_str)
inlinestatic
114{ return get_value_from_config<bool>(type_str, "print", "support_ams_ext_mix_print"); }

References get_value_from_config().

Referenced by Slic3r::GUI::SelectMachineDialog::update_show_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ support_ams_fila_change_abort()

bool Slic3r::DevPrinterConfigUtil::support_ams_fila_change_abort ( std::string type_str)
inlinestatic
90{ return get_value_from_config<bool>(type_str, "print", "support_ams_filament_change_abort"); }

References get_value_from_config().

Referenced by Slic3r::GUI::StatusPanel::update_filament_loading_panel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ support_disable_cali_flow_type()

bool Slic3r::DevPrinterConfigUtil::support_disable_cali_flow_type ( std::string type_str)
inlinestatic
119{ return get_value_from_config<bool>(type_str,"support_disable_cali_flow_type"); }

References get_value_from_config().

Here is the call graph for this function:

◆ support_print_check_extension_fan_f000_mounted()

bool Slic3r::DevPrinterConfigUtil::support_print_check_extension_fan_f000_mounted ( const std::string & type_str)
inlinestatic
128{ return get_value_from_config<bool>(type_str, "print", "support_print_check_extension_fan_f000_mounted"); }

References get_value_from_config().

Referenced by Slic3r::GUI::SelectMachineDialog::UpdateStatusCheckWarning_ExtensionTool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ support_print_check_firmware_for_tpu_left()

bool Slic3r::DevPrinterConfigUtil::support_print_check_firmware_for_tpu_left ( std::string type_str)
inlinestatic
111{ return get_value_from_config<bool>(type_str, "print", "support_print_check_firmware_for_tpu_left"); }

References get_value_from_config().

Referenced by Slic3r::MachineObject::parse_new_info(), and Slic3r::GUI::SelectMachineDialog::update_show_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ support_print_time_estimate_warning()

bool Slic3r::DevPrinterConfigUtil::support_print_time_estimate_warning ( std::string type_str)
inlinestatic
115{ return get_value_from_config<bool>(type_str, "print", "support_print_time_estimate_warning"); }

References get_value_from_config().

Here is the call graph for this function:

◆ support_safety_options()

bool Slic3r::DevPrinterConfigUtil::support_safety_options ( const std::string & type_str)
inlinestatic
125{ return get_value_from_config<bool>(type_str, "support_safety_options"); }

References get_value_from_config().

Referenced by Slic3r::GUI::StatusPanel::on_show_safety_options(), Slic3r::GUI::StatusPanel::update(), and Slic3r::GUI::PrintOptionsDialog::UpdateOptionOpenDoorCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ support_user_first_setup_tpu_check()

bool Slic3r::DevPrinterConfigUtil::support_user_first_setup_tpu_check ( std::string type_str)
inlinestatic
112{ return get_value_from_config<bool>(type_str, "print", "support_user_first_setup_tpu_check"); }

References get_value_from_config().

Here is the call graph for this function:

◆ support_user_first_setup_tpu_check_url()

std::string Slic3r::DevPrinterConfigUtil::support_user_first_setup_tpu_check_url ( std::string type_str)
inlinestatic
113{ return get_value_from_config<std::string>(type_str, "print", "support_user_first_setup_tpu_check_url"); }

References get_value_from_config().

Here is the call graph for this function:

◆ support_wrapping_detection()

bool Slic3r::DevPrinterConfigUtil::support_wrapping_detection ( const std::string & type_str)
inlinestatic
122{ return get_value_from_config<bool>(type_str, "support_wrapping_detection"); }

References get_value_from_config().

Referenced by Slic3r::GUI::TabPrinter::toggle_options(), Slic3r::GUI::ConfigManipulation::toggle_print_fff_options(), and Slic3r::GUI::ConfigManipulation::update_print_fff_config().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_resource_file_path

std::string Slic3r::DevPrinterConfigUtil::m_resource_file_path = ""
staticprivate

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceCore/DevConfigUtil.h
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp