OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::Config Namespace Reference

Classes

class  Snapshot
class  SnapshotDB
struct  Version
class  Index

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 Snapshot * take_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)
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 = { PRESET_PRINT_NAME, PRESET_SLA_PRINT_NAME, PRESET_FILAMENT_NAME, PRESET_SLA_MATERIALS_NAME, PRESET_PRINTER_NAME, "physical_printer", PRESET_SYSTEM_DIR }

Function Documentation

◆ compare_prerelease()

int Slic3r::GUI::Config::compare_prerelease ( const char * p1,
const char * p2 )
static
32{
33 for (;;) {
34 char c1 = *p1 ++;
35 char c2 = *p2 ++;
36 bool a1 = std::isalpha(c1) && c1 != 0;
37 bool a2 = std::isalpha(c2) && c2 != 0;
38 if (a1) {
39 if (a2) {
40 if (c1 != c2)
41 return (c1 < c2) ? -1 : 1;
42 } else
43 return 1;
44 } else {
45 if (a2)
46 return -1;
47 else
48 return 0;
49 }
50 }
51 // This shall never happen.
52 return 0;
53}

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

Here is the caller graph for this function:

◆ copy_config_dir_single_level()

void Slic3r::GUI::Config::copy_config_dir_single_level ( const boost::filesystem::path & path_src,
const boost::filesystem::path & path_dst )
static
391{
392//BBS: remove snapshots function currently
393#if 0
394 if (! boost::filesystem::is_directory(path_dst) &&
395 ! boost::filesystem::create_directory(path_dst))
396 throw Slic3r::RuntimeError(std::string("OrcaSlicer was unable to create a directory at ") + path_dst.string());
397
398 for (auto &dir_entry : boost::filesystem::directory_iterator(path_src))
399 if (Slic3r::is_ini_file(dir_entry))
400 if (std::string error_message; copy_file(dir_entry.path().string(), (path_dst / dir_entry.path().filename()).string(), error_message, false) != SUCCESS)
401 throw Slic3r::RuntimeError(format("Failed copying \"%1%\" to \"%2%\": %3%", path_src.string(), path_dst.string(), error_message));
402#endif
403}
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:36
CopyFileResult copy_file(const std::string &from, const std::string &to, std::string &error_message, const bool with_check)
Definition utils.cpp:1071
@ SUCCESS
Definition Utils.hpp:260
bool is_ini_file(const boost::filesystem::directory_entry &dir_entry)
Definition utils.cpp:1197

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()

void Slic3r::GUI::Config::delete_existing_ini_files ( const boost::filesystem::path & path)
static
406{
407//BBS: remove snapshots function currently
408#if 0
409 if (! boost::filesystem::is_directory(path))
410 return;
411 for (auto &dir_entry : boost::filesystem::directory_iterator(path))
412 if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini"))
413 boost::filesystem::remove(dir_entry.path());
414#endif
415}

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
160{
161 for (; *c == ' ' || *c == '\t'; ++ c);
162 return c;
163}

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

Here is the caller graph for this function:

◆ reason_string()

std::string Slic3r::GUI::Config::reason_string ( const Snapshot::Reason reason)
static
182{
183 switch (reason) {
185 return "upgrade";
187 return "downgrade";
189 return "before_rollback";
191 return "user";
193 default:
194 return "unknown";
195 }
196}
@ SNAPSHOT_UNKNOWN
Definition Snapshot.hpp:37
@ SNAPSHOT_BEFORE_ROLLBACK
Definition Snapshot.hpp:40
@ SNAPSHOT_UPGRADE
Definition Snapshot.hpp:38
@ SNAPSHOT_DOWNGRADE
Definition Snapshot.hpp:39
@ SNAPSHOT_USER
Definition Snapshot.hpp:41

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
166{
167 char *end = start + strlen(start) - 1;
168 for (; end >= start && (*end == ' ' || *end == '\t'); -- end);
169 *(++ end) = 0;
170 return end;
171}

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 )
604{
605 try {
606 SnapshotDB::singleton().take_snapshot(app_config, reason, comment);
607 return true;
608 } catch (std::exception &err) {
609 RichMessageDialog dlg(static_cast<wxWindow*>(wxGetApp().mainframe),
610 _L("OrcaSlicer has encountered an error while taking a configuration snapshot.") + "\n\n" + from_u8(err.what()) + "\n\n" + from_u8(message),
611 _L("OrcaSlicer error"),
612 wxYES_NO);
613 dlg.SetYesNoLabels(_L("Continue"), _L("Abort"));
614 return dlg.ShowModal() == wxID_YES;
615 }
616}
#define _L(s)
Definition OBJ.cpp:34
const Snapshot & take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment="")
Definition Snapshot.cpp:417
static SnapshotDB & singleton()
Definition Snapshot.cpp:572
Definition MsgDialog.hpp:188
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References _L, Slic3r::GUI::from_u8(), Slic3r::GUI::RichMessageDialog::SetYesNoLabels(), Slic3r::GUI::RichMessageDialog::ShowModal(), Slic3r::GUI::Config::SnapshotDB::singleton(), and Slic3r::GUI::Config::SnapshotDB::take_snapshot().

Here is the call 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 )
593{
594 try {
595 return &SnapshotDB::singleton().take_snapshot(app_config, reason, comment);
596 } catch (std::exception &err) {
597 show_error(static_cast<wxWindow*>(wxGetApp().mainframe),
598 _L("Taking a configuration snapshot failed.") + "\n\n" + from_u8(err.what()));
599 return nullptr;
600 }
601}
void show_error(wxWindow *parent, const wxString &message, bool has_code_excerpts)
Definition GUI.cpp:296

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

Here is the call 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
174{
175 std::string svalue;
176 if (value == end) {
177 // Empty string is a valid string.
178 } else if (*value == '"') {
179 if (++ value > -- end || *end != '"')
180 throw file_parser_error("String not enquoted correctly", path, idx_line);
181 *end = 0;
182 if (! unescape_string_cstyle(value, svalue))
183 throw file_parser_error("Invalid escape sequence inside a quoted string", path, idx_line);
184 } else
185 svalue.assign(value, end);
186 return svalue;
187}
Definition FileParserError.hpp:16
bool unescape_string_cstyle(const std::string &str, std::string &str_out)
Definition Config.cpp:150

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
190{
191 std::string svalue;
192 if (value == end) {
193 // Empty string is a valid string.
194 } else if (*value == '"') {
195 if (++ value > -- end || *end != '"')
196 throw file_parser_error("Version comment not enquoted correctly", path, idx_line);
197 *end = 0;
198 if (! unescape_string_cstyle(value, svalue))
199 throw file_parser_error("Invalid escape sequence inside a quoted version comment", path, idx_line);
200 } else
201 svalue.assign(value, end);
202 return svalue;
203}

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

auto Slic3r::GUI::Config::snapshot_subdirs = { PRESET_PRINT_NAME, PRESET_SLA_PRINT_NAME, PRESET_FILAMENT_NAME, PRESET_SLA_MATERIALS_NAME, PRESET_PRINTER_NAME, "physical_printer", PRESET_SYSTEM_DIR }
staticconstexpr
#define PRESET_SYSTEM_DIR
Definition Preset.hpp:31
#define PRESET_SLA_PRINT_NAME
Definition Preset.hpp:36
#define PRESET_PRINTER_NAME
Definition Preset.hpp:35
#define PRESET_PRINT_NAME
Definition Preset.hpp:34
#define PRESET_SLA_MATERIALS_NAME
Definition Preset.hpp:37
#define PRESET_FILAMENT_NAME
Definition Preset.hpp:33

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