Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::GUI::Config Namespace Reference

Classes

class  Index
 
class  Snapshot
 
class  SnapshotDB
 
struct  Version
 

Functions

static std::string reason_string (const Snapshot::Reason reason)
 
static void copy_config_dir_single_level (const boost::filesystem::path &path_src, const boost::filesystem::path &path_dst)
 
static void delete_existing_ini_files (const boost::filesystem::path &path)
 
const Snapshottake_config_snapshot_report_error (const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment)
 
bool take_config_snapshot_cancel_on_error (const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment, const std::string &message, Snapshot const **psnapshot)
 
static int compare_prerelease (const char *p1, const char *p2)
 
char * left_trim (char *c)
 
char * right_trim (char *start)
 
std::string unquote_value (char *value, char *end, const std::string &path, int idx_line)
 
std::string unquote_version_comment (char *value, char *end, const std::string &path, int idx_line)
 

Variables

static constexpr auto snapshot_subdirs = { "print", "sla_print", "filament", "sla_material", "printer", "physical_printer", "vendor" }
 

Function Documentation

◆ compare_prerelease()

static int Slic3r::GUI::Config::compare_prerelease ( const char *  p1,
const char *  p2 
)
static
20{
21 for (;;) {
22 char c1 = *p1 ++;
23 char c2 = *p2 ++;
24 bool a1 = std::isalpha(c1) && c1 != 0;
25 bool a2 = std::isalpha(c2) && c2 != 0;
26 if (a1) {
27 if (a2) {
28 if (c1 != c2)
29 return (c1 < c2) ? -1 : 1;
30 } else
31 return 1;
32 } else {
33 if (a2)
34 return -1;
35 else
36 return 0;
37 }
38 }
39 // This shall never happen.
40 return 0;
41}

Referenced by Slic3r::GUI::Config::Version::is_slic3r_supported().

+ Here is the caller graph for this function:

◆ copy_config_dir_single_level()

static void Slic3r::GUI::Config::copy_config_dir_single_level ( const boost::filesystem::path &  path_src,
const boost::filesystem::path &  path_dst 
)
static
368{
369 if (! boost::filesystem::is_directory(path_dst) &&
370 ! boost::filesystem::create_directory(path_dst))
371 throw Slic3r::RuntimeError(std::string("PrusaSlicer was unable to create a directory at ") + path_dst.string());
372
373 for (auto &dir_entry : boost::filesystem::directory_iterator(path_src))
374 if (Slic3r::is_ini_file(dir_entry))
375 if (std::string error_message; copy_file(dir_entry.path().string(), (path_dst / dir_entry.path().filename()).string(), error_message, false) != SUCCESS)
376 throw Slic3r::RuntimeError(format("Failed copying \"%1%\" to \"%2%\": %3%", path_src.string(), path_dst.string(), error_message));
377}
TOKEN * string(char *text)
Definition config.c:233
if(!(yy_init))
Definition lexer.c:1190
Definition avrdude-slic3r.cpp:16
CopyFileResult copy_file(const std::string &from, const std::string &to, std::string &error_message, const bool with_check)
Definition utils.cpp:707
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:44
bool is_ini_file(const boost::filesystem::directory_entry &dir_entry)
Definition utils.cpp:773
Definition args.hpp:18
STL namespace.

References Slic3r::copy_file(), Slic3r::GUI::format(), Slic3r::is_ini_file(), and Slic3r::SUCCESS.

Referenced by Slic3r::GUI::Config::SnapshotDB::restore_snapshot(), and Slic3r::GUI::Config::SnapshotDB::take_snapshot().

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

◆ delete_existing_ini_files()

static void Slic3r::GUI::Config::delete_existing_ini_files ( const boost::filesystem::path &  path)
static
380{
381 if (! boost::filesystem::is_directory(path))
382 return;
383 for (auto &dir_entry : boost::filesystem::directory_iterator(path))
384 if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini"))
385 boost::filesystem::remove(dir_entry.path());
386}

Referenced by Slic3r::GUI::Config::SnapshotDB::restore_snapshot().

+ Here is the caller graph for this function:

◆ left_trim()

char * Slic3r::GUI::Config::left_trim ( char *  c)
inline
75{
76 for (; *c == ' ' || *c == '\t'; ++ c);
77 return c;
78}

Referenced by Slic3r::GUI::Config::Index::load().

+ Here is the caller graph for this function:

◆ reason_string()

static std::string Slic3r::GUI::Config::reason_string ( const Snapshot::Reason  reason)
static
161{
162 switch (reason) {
163 case Snapshot::SNAPSHOT_UPGRADE:
164 return "upgrade";
165 case Snapshot::SNAPSHOT_DOWNGRADE:
166 return "downgrade";
167 case Snapshot::SNAPSHOT_BEFORE_ROLLBACK:
168 return "before_rollback";
169 case Snapshot::SNAPSHOT_USER:
170 return "user";
171 case Snapshot::SNAPSHOT_UNKNOWN:
172 default:
173 return "unknown";
174 }
175}

References Slic3r::GUI::Config::Snapshot::SNAPSHOT_BEFORE_ROLLBACK, Slic3r::GUI::Config::Snapshot::SNAPSHOT_DOWNGRADE, Slic3r::GUI::Config::Snapshot::SNAPSHOT_UNKNOWN, Slic3r::GUI::Config::Snapshot::SNAPSHOT_UPGRADE, and Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER.

Referenced by Slic3r::GUI::Config::Snapshot::save_ini().

+ Here is the caller graph for this function:

◆ right_trim()

char * Slic3r::GUI::Config::right_trim ( char *  start)
inline
81{
82 char *end = start + strlen(start) - 1;
83 for (; end >= start && (*end == ' ' || *end == '\t'); -- end);
84 *(++ end) = 0;
85 return end;
86}

Referenced by Slic3r::GUI::Config::Index::load().

+ Here is the caller graph for this function:

◆ take_config_snapshot_cancel_on_error()

bool Slic3r::GUI::Config::take_config_snapshot_cancel_on_error ( const AppConfig app_config,
Snapshot::Reason  reason,
const std::string &  comment,
const std::string &  message,
Snapshot const **  psnapshot 
)
590{
591 try {
592 const Snapshot *snapshot = &SnapshotDB::singleton().take_snapshot(app_config, reason, comment);
593 if (psnapshot)
594 *psnapshot = snapshot;
595 return true;
596 } catch (std::exception &err) {
597 RichMessageDialog dlg(static_cast<wxWindow*>(wxGetApp().mainframe),
598 _L("PrusaSlicer has encountered an error while taking a configuration snapshot.") + "\n\n" + from_u8(err.what()) + "\n\n" + from_u8(message),
599 _L("PrusaSlicer error"),
600 wxYES_NO);
601 dlg.SetYesNoLabels(_L("Continue"), _L("Abort"));
602 return dlg.ShowModal() == wxID_YES;
603 }
604}
Definition Snapshot.hpp:32
Definition MsgDialog.hpp:295
#define comment
Definition lexer.c:1004
wxString from_u8(const std::string &str)
Definition GUI.cpp:437
#define _L(s)
Definition I18N.hpp:3

References _L, comment, Slic3r::GUI::from_u8(), Slic3r::GUI::Config::SnapshotDB::singleton(), and Slic3r::GUI::Config::SnapshotDB::take_snapshot().

Referenced by Slic3r::GUI::GUI_App::add_config_menu(), Slic3r::GUI::GUI_App::check_older_app_config(), and Slic3r::PresetUpdater::priv::perform_updates().

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

◆ take_config_snapshot_report_error()

const Snapshot * Slic3r::GUI::Config::take_config_snapshot_report_error ( const AppConfig app_config,
Snapshot::Reason  reason,
const std::string &  comment 
)
579{
580 try {
581 return &SnapshotDB::singleton().take_snapshot(app_config, reason, comment);
582 } catch (std::exception &err) {
583 show_error(static_cast<wxWindow*>(wxGetApp().mainframe),
584 _L("Taking a configuration snapshot failed.") + "\n\n" + from_u8(err.what()));
585 return nullptr;
586 }
587}
void show_error(wxWindow *parent, const wxString &message, bool monospaced_font)
Definition GUI.cpp:224

References _L, comment, Slic3r::GUI::from_u8(), Slic3r::GUI::show_error(), Slic3r::GUI::Config::SnapshotDB::singleton(), and Slic3r::GUI::Config::SnapshotDB::take_snapshot().

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

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

◆ unquote_value()

std::string Slic3r::GUI::Config::unquote_value ( char *  value,
char *  end,
const std::string &  path,
int  idx_line 
)
inline
89{
90 std::string svalue;
91 if (value == end) {
92 // Empty string is a valid string.
93 } else if (*value == '"') {
94 if (++ value > -- end || *end != '"')
95 throw file_parser_error("String not enquoted correctly", path, idx_line);
96 *end = 0;
97 if (! unescape_string_cstyle(value, svalue))
98 throw file_parser_error("Invalid escape sequence inside a quoted string", path, idx_line);
99 } else
100 svalue.assign(value, end);
101 return svalue;
102}
Definition FileParserError.hpp:14
bool unescape_string_cstyle(const std::string &str, std::string &str_out)
Definition Config.cpp:107

References Slic3r::unescape_string_cstyle().

Referenced by Slic3r::GUI::Config::Index::load().

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

◆ unquote_version_comment()

std::string Slic3r::GUI::Config::unquote_version_comment ( char *  value,
char *  end,
const std::string &  path,
int  idx_line 
)
inline
105{
106 std::string svalue;
107 if (value == end) {
108 // Empty string is a valid string.
109 } else if (*value == '"') {
110 if (++ value > -- end || *end != '"')
111 throw file_parser_error("Version comment not enquoted correctly", path, idx_line);
112 *end = 0;
113 if (! unescape_string_cstyle(value, svalue))
114 throw file_parser_error("Invalid escape sequence inside a quoted version comment", path, idx_line);
115 } else
116 svalue.assign(value, end);
117 return svalue;
118}

References Slic3r::unescape_string_cstyle().

Referenced by Slic3r::GUI::Config::Index::load().

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

Variable Documentation

◆ snapshot_subdirs

constexpr auto Slic3r::GUI::Config::snapshot_subdirs = { "print", "sla_print", "filament", "sla_material", "printer", "physical_printer", "vendor" }
staticconstexpr