Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_perspective_camera

This commit is contained in:
Enrico Turri 2019-05-20 08:28:34 +02:00
commit c5e4ada75b
20 changed files with 169 additions and 89 deletions

View file

@ -67,6 +67,14 @@ PrinterTechnology BackgroundSlicingProcess::current_printer_technology() const
return m_print->technology();
}
std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::filesystem::path &project_path)
{
assert(m_print != nullptr);
if (project_path.empty())
return m_print->output_filepath("");
return m_print->output_filepath(project_path.parent_path().string(), project_path.stem().string());
}
// This function may one day be merged into the Print, but historically the print was separated
// from the G-code generator.
void BackgroundSlicingProcess::process_fff()

View file

@ -6,6 +6,8 @@
#include <mutex>
#include <thread>
#include <boost/filesystem.hpp>
#include <wx/event.h>
#include "libslic3r/Print.hpp"
@ -65,6 +67,9 @@ public:
const PrintBase* current_print() const { return m_print; }
const Print* fff_print() const { return m_fff_print; }
const SLAPrint* sla_print() const { return m_sla_print; }
// Take the project path (if provided), extract the name of the project, run it through the macro processor and save it next to the project file.
// If the project_path is empty, just run output_filepath().
std::string output_filepath_for_project(const boost::filesystem::path &project_path);
// Start the background processing. Returns false if the background processing was already running.
bool start();

View file

@ -183,9 +183,13 @@ bool GUI_App::on_init_inner()
// supplied as argument to --datadir; in that case we should still run the wizard
preset_bundle->setup_directories();
app_conf_exists = app_config->exists();
// load settings
if (app_config->exists())
app_conf_exists = app_config->exists();
if (app_conf_exists) {
app_config->load();
}
app_config->set("version", SLIC3R_VERSION);
app_config->save();
@ -248,16 +252,20 @@ bool GUI_App::on_init_inner()
if (once) {
once = false;
PresetUpdater::UpdateResult updater_result;
try {
if (!preset_updater->config_update()) {
updater_result = preset_updater->config_update();
if (updater_result == PresetUpdater::R_INCOMPAT_EXIT) {
mainframe->Close();
} else if (updater_result == PresetUpdater::R_INCOMPAT_CONFIGURED) {
app_conf_exists = true;
}
} catch (const std::exception &ex) {
show_error(nullptr, from_u8(ex.what()));
}
CallAfter([this] {
if (!config_wizard_startup(app_config->exists())) {
if (!config_wizard_startup(app_conf_exists)) {
// Only notify if there was no wizard so as not to bother too much ...
preset_updater->slic3r_update_notify();
}

View file

@ -72,6 +72,7 @@ static wxString dots("…", wxConvUTF8);
class GUI_App : public wxApp
{
bool m_initialized { false };
bool app_conf_exists{ false };
wxColour m_color_label_modified;
wxColour m_color_label_sys;

View file

@ -74,7 +74,7 @@ void ImGuiWrapper::set_language(const std::string &language)
ranges = ImGui::GetIO().Fonts->GetGlyphRangesCyrillic();
} else if (lang == "jp") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese();
} else if (lang == "kr") {
} else if (lang == "ko") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean();
} else if (lang == "zh") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon();

View file

@ -5,9 +5,7 @@
#include <vector>
#include <string>
#include <regex>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem/path.hpp>
@ -671,7 +669,8 @@ Sidebar::Sidebar(Plater *parent)
auto combo_and_btn_sizer = new wxBoxSizer(wxHORIZONTAL);
combo_and_btn_sizer->Add(*combo, 1, wxEXPAND);
if ((*combo)->edit_btn)
combo_and_btn_sizer->Add((*combo)->edit_btn, 0, wxLEFT|wxRIGHT, int(0.3*wxGetApp().em_unit()));
combo_and_btn_sizer->Add((*combo)->edit_btn, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT,
int(0.3*wxGetApp().em_unit()));
auto *sizer_presets = this->p->sizer_presets;
auto *sizer_filaments = this->p->sizer_filaments;
@ -777,7 +776,8 @@ void Sidebar::init_filament_combo(PresetComboBox **combo, const int extr_idx) {
auto combo_and_btn_sizer = new wxBoxSizer(wxHORIZONTAL);
combo_and_btn_sizer->Add(*combo, 1, wxEXPAND);
combo_and_btn_sizer->Add((*combo)->edit_btn, 0, wxLEFT | wxRIGHT, int(0.3*wxGetApp().em_unit()));
combo_and_btn_sizer->Add((*combo)->edit_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
int(0.3*wxGetApp().em_unit()));
auto /***/sizer_filaments = this->p->sizer_filaments;
sizer_filaments->Add(combo_and_btn_sizer, 1, wxEXPAND | wxBOTTOM, 1);
@ -2971,9 +2971,16 @@ wxString Plater::priv::get_project_filename(const wxString& extension) const
void Plater::priv::set_project_filename(const wxString& filename)
{
boost::filesystem::path full_path = into_path(filename);
// remove extension
while (full_path.has_extension())
{
boost::filesystem::path ext = full_path.extension();
if (boost::iequals(ext.string(), ".amf")) {
// Remove the first extension.
full_path.replace_extension("");
// It may be ".zip.amf".
if (boost::iequals(full_path.extension().string(), ".zip"))
// Remove the 2nd extension.
full_path.replace_extension("");
} else {
// Remove just one extension.
full_path.replace_extension("");
}
@ -3492,7 +3499,7 @@ void Plater::export_gcode()
unsigned int state = this->p->update_restart_background_process(false, false);
if (state & priv::UPDATE_BACKGROUND_PROCESS_INVALID)
return;
default_output_file = this->p->background_process.current_print()->output_filepath(into_path(get_project_filename()).string());
default_output_file = this->p->background_process.output_filepath_for_project(into_path(get_project_filename(".3mf")));
}
catch (const std::exception &ex) {
show_error(this, ex.what());
@ -3737,7 +3744,7 @@ void Plater::send_gcode()
unsigned int state = this->p->update_restart_background_process(false, false);
if (state & priv::UPDATE_BACKGROUND_PROCESS_INVALID)
return;
default_output_file = this->p->background_process.current_print()->output_filepath(into_path(get_project_filename(".3mf")).string());
default_output_file = this->p->background_process.output_filepath_for_project(into_path(get_project_filename(".3mf")));
}
catch (const std::exception &ex) {
show_error(this, ex.what());

View file

@ -1,6 +1,7 @@
#include "wxExtensions.hpp"
#include <stdexcept>
#include <cmath>
#include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
@ -19,6 +20,7 @@
#include "libslic3r/GCode/PreviewData.hpp"
#include "I18N.hpp"
#include "GUI_Utils.hpp"
#include "../Utils/MacDarkMode.hpp"
using Slic3r::GUI::from_u8;
@ -389,7 +391,15 @@ wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name_in,
static Slic3r::GUI::BitmapCache cache;
#ifdef __APPLE__
const float scale_factor = win != nullptr ? win->GetContentScaleFactor() : 1.0f;
// Note: win->GetContentScaleFactor() is not used anymore here because it tends to
// return bogus results quite often (such as 1.0 on Retina or even 0.0).
// We're using the max scaling factor across all screens because it's very likely to be good enough.
static float max_scaling_factor = NAN;
if (std::isnan(max_scaling_factor)) {
max_scaling_factor = Slic3r::GUI::mac_max_scaling_factor();
}
const float scale_factor = win != nullptr ? max_scaling_factor : 1.0f;
#else
(void)(win);
const float scale_factor = 1.0f;
@ -2656,7 +2666,7 @@ ScalableButton::ScalableButton( wxWindow * parent,
if (style & wxNO_BORDER)
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif // __WXMSW__
SetBitmap(create_scaled_bitmap(parent, icon_name));
}

View file

@ -6,6 +6,7 @@ namespace GUI {
#if __APPLE__
extern bool mac_dark_mode();
extern double mac_max_scaling_factor();
#endif

View file

@ -1,6 +1,9 @@
#import "MacDarkMode.hpp"
#import <algorithm>
#import <Foundation/Foundation.h>
#import <AppKit/NSScreen.h>
@implementation MacDarkMode
@ -15,6 +18,17 @@ bool mac_dark_mode()
}
double mac_max_scaling_factor()
{
double scaling = 1.;
if ([NSScreen screens] == nil) {
scaling = [[NSScreen mainScreen] backingScaleFactor];
} else {
for (int i = 0; i < [[NSScreen screens] count]; ++ i)
scaling = std::max<double>(scaling, [[[NSScreen screens] objectAtIndex:0] backingScaleFactor]);
}
return scaling;
}
}
}

View file

@ -567,9 +567,9 @@ void PresetUpdater::slic3r_update_notify()
}
}
bool PresetUpdater::config_update() const
PresetUpdater::UpdateResult PresetUpdater::config_update() const
{
if (! p->enabled_config_update) { return true; }
if (! p->enabled_config_update) { return R_NOOP; }
auto updates = p->get_config_updates();
if (updates.incompats.size() > 0) {
@ -603,15 +603,15 @@ bool PresetUpdater::config_update() const
p->perform_updates(std::move(updates));
GUI::ConfigWizard wizard(nullptr, GUI::ConfigWizard::RR_DATA_INCOMPAT);
if (! wizard.run(GUI::wxGetApp().preset_bundle, this)) {
return false;
return R_INCOMPAT_EXIT;
}
GUI::wxGetApp().load_current_presets();
return R_INCOMPAT_CONFIGURED;
} else {
BOOST_LOG_TRIVIAL(info) << "User wants to exit Slic3r, bye...";
return false;
return R_INCOMPAT_EXIT;
}
}
else if (updates.updates.size() > 0) {
} else if (updates.updates.size() > 0) {
BOOST_LOG_TRIVIAL(info) << boost::format("Update of %1% bundles available. Asking for confirmation ...") % updates.updates.size();
std::vector<GUI::MsgUpdateConfig::Update> updates_msg;
@ -633,14 +633,16 @@ bool PresetUpdater::config_update() const
auto *app_config = GUI::wxGetApp().app_config;
GUI::wxGetApp().preset_bundle->load_presets(*app_config);
GUI::wxGetApp().load_current_presets();
return R_UPDATE_INSTALLED;
} else {
BOOST_LOG_TRIVIAL(info) << "User refused the update";
return R_UPDATE_REJECT;
}
} else {
BOOST_LOG_TRIVIAL(info) << "No configuration updates available.";
}
return true;
return R_NOOP;
}
void PresetUpdater::install_bundles_rsrc(std::vector<std::string> bundles, bool snapshot) const

View file

@ -28,9 +28,17 @@ public:
// If version check is enabled, check if chaced online slic3r version is newer, notify if so.
void slic3r_update_notify();
enum UpdateResult {
R_NOOP,
R_INCOMPAT_EXIT,
R_INCOMPAT_CONFIGURED,
R_UPDATE_INSTALLED,
R_UPDATE_REJECT,
};
// If updating is enabled, check if updates are available in cache, if so, ask about installation.
// A false return value implies Slic3r should exit due to incompatibility of configuration.
bool config_update() const;
UpdateResult config_update() const;
// "Update" a list of bundles from resources (behaves like an online update).
void install_bundles_rsrc(std::vector<std::string> bundles, bool snapshot = true) const;