mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-25 01:31:14 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer
This commit is contained in:
commit
00ec9cc4ed
17 changed files with 415 additions and 85 deletions
|
|
@ -31,8 +31,11 @@ void Snapshot::clear()
|
|||
this->comment.clear();
|
||||
this->reason = SNAPSHOT_UNKNOWN;
|
||||
this->print.clear();
|
||||
this->sla_print.clear();
|
||||
this->filaments.clear();
|
||||
this->sla_material.clear();
|
||||
this->printer.clear();
|
||||
this->physical_printer.clear();
|
||||
}
|
||||
|
||||
void Snapshot::load_ini(const std::string &path)
|
||||
|
|
@ -94,6 +97,8 @@ void Snapshot::load_ini(const std::string &path)
|
|||
for (auto &kvp : section.second) {
|
||||
if (kvp.first == "print") {
|
||||
this->print = kvp.second.data();
|
||||
} else if (kvp.first == "sla_print") {
|
||||
this->sla_print = kvp.second.data();
|
||||
} else if (boost::starts_with(kvp.first, "filament")) {
|
||||
int idx = 0;
|
||||
if (kvp.first == "filament" || sscanf(kvp.first.c_str(), "filament_%d", &idx) == 1) {
|
||||
|
|
@ -101,8 +106,12 @@ void Snapshot::load_ini(const std::string &path)
|
|||
this->filaments.resize(idx + 1, std::string());
|
||||
this->filaments[idx] = kvp.second.data();
|
||||
}
|
||||
} else if (kvp.first == "sla_material") {
|
||||
this->sla_material = kvp.second.data();
|
||||
} else if (kvp.first == "printer") {
|
||||
this->printer = kvp.second.data();
|
||||
} else if (kvp.first == "physical_printer") {
|
||||
this->physical_printer = kvp.second.data();
|
||||
}
|
||||
}
|
||||
} else if (boost::starts_with(section.first, group_name_vendor) && section.first.size() > group_name_vendor.size()) {
|
||||
|
|
@ -172,10 +181,13 @@ void Snapshot::save_ini(const std::string &path)
|
|||
// Export the active presets at the time of the snapshot.
|
||||
c << std::endl << "[presets]" << std::endl;
|
||||
c << "print = " << this->print << std::endl;
|
||||
c << "sla_print = " << this->sla_print << std::endl;
|
||||
c << "filament = " << this->filaments.front() << std::endl;
|
||||
for (size_t i = 1; i < this->filaments.size(); ++ i)
|
||||
c << "filament_" << std::to_string(i) << " = " << this->filaments[i] << std::endl;
|
||||
c << "sla_material = " << this->sla_material << std::endl;
|
||||
c << "printer = " << this->printer << std::endl;
|
||||
c << "physical_printer = " << this->physical_printer << std::endl;
|
||||
|
||||
// Export the vendor configs.
|
||||
for (const VendorConfig &vc : this->vendor_configs) {
|
||||
|
|
@ -199,14 +211,17 @@ void Snapshot::export_selections(AppConfig &config) const
|
|||
{
|
||||
assert(filaments.size() >= 1);
|
||||
config.clear_section("presets");
|
||||
config.set("presets", "print", print);
|
||||
config.set("presets", "filament", filaments.front());
|
||||
config.set("presets", "print", print);
|
||||
config.set("presets", "sla_print", sla_print);
|
||||
config.set("presets", "filament", filaments.front());
|
||||
for (unsigned i = 1; i < filaments.size(); ++i) {
|
||||
char name[64];
|
||||
sprintf(name, "filament_%u", i);
|
||||
config.set("presets", name, filaments[i]);
|
||||
}
|
||||
config.set("presets", "printer", printer);
|
||||
config.set("presets", "sla_material", sla_material);
|
||||
config.set("presets", "printer", printer);
|
||||
config.set("presets", "physical_printer", physical_printer);
|
||||
}
|
||||
|
||||
void Snapshot::export_vendor_configs(AppConfig &config) const
|
||||
|
|
@ -217,8 +232,10 @@ void Snapshot::export_vendor_configs(AppConfig &config) const
|
|||
config.set_vendors(std::move(vendors));
|
||||
}
|
||||
|
||||
// Perform a deep compare of the active print / filament / printer / vendor directories.
|
||||
// Return true if the content of the current print / filament / printer / vendor directories
|
||||
static constexpr auto snapshot_subdirs = { "print", "sla_print", "filament", "sla_material", "printer", "physical_printer", "vendor" };
|
||||
|
||||
// Perform a deep compare of the active print / sla_print / filament / sla_material / printer / physical_printer / vendor directories.
|
||||
// Return true if the content of the current print / sla_print / filament / sla_material / printer / physical_printer / vendor directories
|
||||
// matches the state stored in this snapshot.
|
||||
bool Snapshot::equal_to_active(const AppConfig &app_config) const
|
||||
{
|
||||
|
|
@ -243,7 +260,7 @@ bool Snapshot::equal_to_active(const AppConfig &app_config) const
|
|||
// 2) Check, whether this snapshot references the same set of ini files as the current state.
|
||||
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
|
||||
boost::filesystem::path snapshot_dir = boost::filesystem::path(Slic3r::data_dir()) / SLIC3R_SNAPSHOTS_DIR / this->id;
|
||||
for (const char *subdir : { "print", "filament", "printer", "vendor" }) {
|
||||
for (const char *subdir : snapshot_subdirs) {
|
||||
boost::filesystem::path path1 = data_dir / subdir;
|
||||
boost::filesystem::path path2 = snapshot_dir / subdir;
|
||||
std::vector<std::string> files1, files2;
|
||||
|
|
@ -369,9 +386,12 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot:
|
|||
snapshot.comment = comment;
|
||||
snapshot.reason = reason;
|
||||
// Active presets at the time of the snapshot.
|
||||
snapshot.print = app_config.get("presets", "print");
|
||||
snapshot.print = app_config.get("presets", "print");
|
||||
snapshot.sla_print = app_config.get("presets", "sla_print");
|
||||
snapshot.filaments.emplace_back(app_config.get("presets", "filament"));
|
||||
snapshot.printer = app_config.get("presets", "printer");
|
||||
snapshot.sla_material = app_config.get("presets", "sla_material");
|
||||
snapshot.printer = app_config.get("presets", "printer");
|
||||
snapshot.physical_printer = app_config.get("presets", "physical_printer");
|
||||
for (unsigned i = 1; i < 1000; ++ i) {
|
||||
char name[64];
|
||||
sprintf(name, "filament_%u", i);
|
||||
|
|
@ -414,7 +434,7 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot:
|
|||
boost::filesystem::create_directory(snapshot_dir);
|
||||
|
||||
// Backup the presets.
|
||||
for (const char *subdir : { "print", "filament", "printer", "vendor" })
|
||||
for (const char *subdir : snapshot_subdirs)
|
||||
copy_config_dir_single_level(data_dir / subdir, snapshot_dir / subdir);
|
||||
snapshot.save_ini((snapshot_dir / "snapshot.ini").string());
|
||||
assert(m_snapshots.empty() || m_snapshots.back().time_captured <= snapshot.time_captured);
|
||||
|
|
@ -438,11 +458,11 @@ void SnapshotDB::restore_snapshot(const Snapshot &snapshot, AppConfig &app_confi
|
|||
boost::filesystem::path snapshot_db_dir = SnapshotDB::create_db_dir();
|
||||
boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id;
|
||||
// Remove existing ini files and restore the ini files from the snapshot.
|
||||
for (const char *subdir : { "print", "filament", "printer", "vendor" }) {
|
||||
for (const char *subdir : snapshot_subdirs) {
|
||||
delete_existing_ini_files(data_dir / subdir);
|
||||
copy_config_dir_single_level(snapshot_dir / subdir, data_dir / subdir);
|
||||
}
|
||||
// Update AppConfig with the selections of the print / filament / printer profiles
|
||||
// Update AppConfig with the selections of the print / sla_print / filament / sla_material / printer profiles
|
||||
// and about the installed printer types and variants.
|
||||
snapshot.export_selections(app_config);
|
||||
snapshot.export_vendor_configs(app_config);
|
||||
|
|
|
|||
|
|
@ -23,8 +23,11 @@ namespace Config {
|
|||
// Slic3r.ini
|
||||
// vendor/
|
||||
// print/
|
||||
// sla_print/
|
||||
// filament/
|
||||
// sla_material
|
||||
// printer/
|
||||
// physical_printer/
|
||||
class Snapshot
|
||||
{
|
||||
public:
|
||||
|
|
@ -42,12 +45,12 @@ public:
|
|||
void load_ini(const std::string &path);
|
||||
void save_ini(const std::string &path);
|
||||
|
||||
// Export the print / filament / printer selections to be activated into the AppConfig.
|
||||
// Export the print / sla_print / filament / sla_material / printer selections to be activated into the AppConfig.
|
||||
void export_selections(AppConfig &config) const;
|
||||
void export_vendor_configs(AppConfig &config) const;
|
||||
|
||||
// Perform a deep compare of the active print / filament / printer / vendor directories.
|
||||
// Return true if the content of the current print / filament / printer / vendor directories
|
||||
// Perform a deep compare of the active print / sla_print / filament / sla_material / printer / physical_printer / vendor directories.
|
||||
// Return true if the content of the current print / sla_print / filament / sla_material / printer / physical_printer / vendor directories
|
||||
// matches the state stored in this snapshot.
|
||||
bool equal_to_active(const AppConfig &app_config) const;
|
||||
|
||||
|
|
@ -65,8 +68,11 @@ public:
|
|||
|
||||
// Active presets at the time of the snapshot.
|
||||
std::string print;
|
||||
std::string sla_print;
|
||||
std::vector<std::string> filaments;
|
||||
std::string sla_material;
|
||||
std::string printer;
|
||||
std::string physical_printer;
|
||||
|
||||
// Annotation of the vendor configuration stored in the snapshot.
|
||||
// This information is displayed to the user and used to decide compatibility
|
||||
|
|
@ -97,7 +103,7 @@ public:
|
|||
size_t load_db();
|
||||
void update_slic3r_versions(std::vector<Index> &index_db);
|
||||
|
||||
// Create a snapshot directory, copy the vendor config bundles, user print/filament/printer profiles,
|
||||
// Create a snapshot directory, copy the vendor config bundles, user print / sla_print / filament / sla_material / printer / physical_printer profiles,
|
||||
// create an index.
|
||||
const Snapshot& take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment = "");
|
||||
const Snapshot& restore_snapshot(const std::string &id, AppConfig &app_config);
|
||||
|
|
|
|||
|
|
@ -48,9 +48,17 @@ static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_eve
|
|||
text += "</b></font><br>";
|
||||
// End of row header.
|
||||
text += _(L("PrusaSlicer version")) + ": " + snapshot.slic3r_version_captured.to_string() + "<br>";
|
||||
text += _(L("print")) + ": " + snapshot.print + "<br>";
|
||||
text += _(L("filaments")) + ": " + snapshot.filaments.front() + "<br>";
|
||||
text += _(L("printer")) + ": " + snapshot.printer + "<br>";
|
||||
bool has_fff = ! snapshot.print.empty() || ! snapshot.filaments.empty();
|
||||
bool has_sla = ! snapshot.sla_print.empty() || ! snapshot.sla_material.empty();
|
||||
if (has_fff || ! has_sla) {
|
||||
text += _(L("print")) + ": " + snapshot.print + "<br>";
|
||||
text += _(L("filaments")) + ": " + snapshot.filaments.front() + "<br>";
|
||||
}
|
||||
if (has_sla) {
|
||||
text += _(L("SLA print")) + ": " + snapshot.sla_print + "<br>";
|
||||
text += _(L("SLA material")) + ": " + snapshot.sla_material + "<br>";
|
||||
}
|
||||
text += _(L("printer")) + ": " + (snapshot.physical_printer.empty() ? snapshot.printer : snapshot.physical_printer) + "<br>";
|
||||
|
||||
bool compatible = true;
|
||||
for (const Config::Snapshot::VendorConfig &vc : snapshot.vendor_configs) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@
|
|||
#include "I18N.hpp"
|
||||
#include "ExtruderSequenceDialog.hpp"
|
||||
#include "libslic3r/Print.hpp"
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
|
@ -477,8 +475,10 @@ void Control::draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_
|
|||
{
|
||||
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (!m_enable_action_icon)
|
||||
return;
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// suppress add tick on first layer
|
||||
if (tick == 0)
|
||||
|
|
|
|||
|
|
@ -717,6 +717,7 @@ void GUI_App::init_app_config()
|
|||
std::string error = app_config->load();
|
||||
if (!error.empty()) {
|
||||
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (is_editor()) {
|
||||
throw Slic3r::RuntimeError(
|
||||
_u8L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
||||
|
|
@ -724,11 +725,14 @@ void GUI_App::init_app_config()
|
|||
"\n\n" + app_config->config_path() + "\n\n" + error);
|
||||
}
|
||||
else {
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
throw Slic3r::RuntimeError(
|
||||
_u8L("Error parsing PrusaGCodeViewer config file, it is probably corrupted. "
|
||||
"Try to manually delete the file to recover from the error.") +
|
||||
"\n\n" + app_config->config_path() + "\n\n" + error);
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/bind/placeholders.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
|
|
@ -639,7 +641,7 @@ NotificationManager::NotificationManager(wxEvtHandler* evt_handler) :
|
|||
void NotificationManager::push_notification(const NotificationType type, GLCanvas3D& canvas, int timestamp)
|
||||
{
|
||||
auto it = std::find_if(basic_notifications.begin(), basic_notifications.end(),
|
||||
boost::bind(&NotificationData::type, _1) == type);
|
||||
boost::bind(&NotificationData::type, boost::placeholders::_1) == type);
|
||||
assert(it != basic_notifications.end());
|
||||
if (it != basic_notifications.end())
|
||||
push_notification_data( *it, canvas, timestamp);
|
||||
|
|
@ -825,7 +827,7 @@ void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay
|
|||
it = m_pop_notifications.erase(it);
|
||||
} else {
|
||||
(*it)->set_paused(m_hovered);
|
||||
PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay, overlay_width);
|
||||
PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay && !m_in_preview, overlay_width);
|
||||
if (res != PopNotification::RenderResult::Finished) {
|
||||
last_x = (*it)->get_top() + GAP_WIDTH;
|
||||
current_height = std::max(current_height, (*it)->get_current_top());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue