Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_copy_and_paste
This commit is contained in:
commit
e785709b91
File diff suppressed because it is too large
Load Diff
@ -323,7 +323,7 @@ PagePrinters::PagePrinters(ConfigWizard *parent, wxString title, wxString shortn
|
||||
COL_SIZE = 200,
|
||||
};
|
||||
|
||||
bool check_first_variant = wizard_p()->check_first_variant();
|
||||
bool check_first_variant = technology == T_FFF && wizard_p()->check_first_variant();
|
||||
|
||||
AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors;
|
||||
|
||||
@ -1062,7 +1062,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
||||
// Public
|
||||
|
||||
ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
||||
: DPIDialog(parent, wxID_ANY, _(name().ToStdString()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
: DPIDialog(parent, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(name().ToStdString()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, p(new priv(this))
|
||||
{
|
||||
this->SetFont(wxGetApp().normal_font());
|
||||
|
@ -3612,7 +3612,8 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||
}
|
||||
|
||||
// FIXME: calculate a tighter value for depth will improve z-fighting
|
||||
float depth = 5.0f * (float)bbox.max_size();
|
||||
// Set at least some minimum depth in case the bounding box is empty to avoid an OpenGL driver error.
|
||||
float depth = std::max(1.f, 5.0f * (float)bbox.max_size());
|
||||
m_camera.apply_ortho_projection(-w2, w2, -h2, h2, -depth, depth);
|
||||
|
||||
break;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "GUI_ObjectManipulation.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
@ -21,6 +23,7 @@
|
||||
#include <wx/sysopt.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
@ -255,7 +258,7 @@ bool GUI_App::on_init_inner()
|
||||
|
||||
CallAfter([this] {
|
||||
if (!config_wizard_startup(app_conf_exists)) {
|
||||
// Only notify if there was not wizard so as not to bother too much ...
|
||||
// Only notify if there was no wizard so as not to bother too much ...
|
||||
preset_updater->slic3r_update_notify();
|
||||
}
|
||||
preset_updater->sync(preset_bundle);
|
||||
@ -518,66 +521,105 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files)
|
||||
dialog.GetPaths(input_files);
|
||||
}
|
||||
|
||||
// select language from the list of installed languages
|
||||
bool GUI_App::select_language( wxArrayString & names,
|
||||
wxArrayLong & identifiers)
|
||||
bool GUI_App::switch_language()
|
||||
{
|
||||
wxCHECK_MSG(names.Count() == identifiers.Count(), false,
|
||||
_(L("Array of language names and identifiers should have the same size.")));
|
||||
int init_selection = 0;
|
||||
long current_language = m_wxLocale ? m_wxLocale->GetLanguage() : wxLANGUAGE_UNKNOWN;
|
||||
for (auto lang : identifiers) {
|
||||
if (lang == current_language)
|
||||
break;
|
||||
++init_selection;
|
||||
if (select_language()) {
|
||||
save_language();
|
||||
_3DScene::remove_all_canvases();
|
||||
recreate_GUI();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (init_selection == identifiers.size())
|
||||
init_selection = 0;
|
||||
long index = wxGetSingleChoiceIndex(_(L("Select the language")), _(L("Language")),
|
||||
names, init_selection);
|
||||
if (index != -1)
|
||||
{
|
||||
m_wxLocale = new wxLocale;
|
||||
m_wxLocale->Init(identifiers[index]);
|
||||
}
|
||||
|
||||
// select language from the list of installed languages
|
||||
bool GUI_App::select_language()
|
||||
{
|
||||
const auto langs = get_installed_languages();
|
||||
wxArrayString names;
|
||||
names.Alloc(langs.size());
|
||||
|
||||
int init_selection = -1;
|
||||
const auto current_language = m_wxLocale ? m_wxLocale->GetLanguage() : wxLocale::GetSystemLanguage();
|
||||
|
||||
for (size_t i = 0; i < langs.size(); i++) {
|
||||
const auto lang = langs[i]->Language;
|
||||
const bool is_english = lang >= wxLANGUAGE_ENGLISH && lang <= wxLANGUAGE_ENGLISH_ZIMBABWE;
|
||||
|
||||
if (lang == current_language || (current_language == wxLANGUAGE_UNKNOWN && is_english)) {
|
||||
init_selection = i;
|
||||
}
|
||||
|
||||
names.Add(langs[i]->Description);
|
||||
}
|
||||
|
||||
const long index = wxGetSingleChoiceIndex(
|
||||
_(L("Select the language")),
|
||||
_(L("Language")), names, init_selection >= 0 ? init_selection : 0);
|
||||
|
||||
if (index != -1) {
|
||||
const wxLanguageInfo *lang = langs[index];
|
||||
if (lang->Language == current_language) {
|
||||
// There was no change
|
||||
return false;
|
||||
}
|
||||
|
||||
m_wxLocale = new wxLocale; // FIXME: leak?
|
||||
m_wxLocale->Init(lang->Language);
|
||||
m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir()));
|
||||
m_wxLocale->AddCatalog("Slic3rPE");
|
||||
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
||||
wxSetlocale(LC_NUMERIC, "C");
|
||||
Preset::update_suffix_modified();
|
||||
m_imgui->set_language(m_wxLocale->GetCanonicalName().ToUTF8().data());
|
||||
m_imgui->set_language(into_u8(lang->CanonicalName));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// load language saved at application config
|
||||
// Load gettext translation files and activate them at the start of the application,
|
||||
// based on the "translation_language" key stored in the application config.
|
||||
bool GUI_App::load_language()
|
||||
{
|
||||
wxString language = wxEmptyString;
|
||||
if (app_config->has("translation_language"))
|
||||
language = app_config->get("translation_language");
|
||||
|
||||
if (language.IsEmpty())
|
||||
return false;
|
||||
wxArrayString names;
|
||||
wxArrayLong identifiers;
|
||||
get_installed_languages(names, identifiers);
|
||||
for (size_t i = 0; i < identifiers.Count(); i++)
|
||||
{
|
||||
if (wxLocale::GetLanguageCanonicalName(identifiers[i]) == language)
|
||||
{
|
||||
if (language.IsEmpty()) {
|
||||
int lang = wxLocale::GetSystemLanguage();
|
||||
if (lang != wxLANGUAGE_UNKNOWN) {
|
||||
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
|
||||
if (info != nullptr)
|
||||
language = info->CanonicalName;
|
||||
}
|
||||
}
|
||||
|
||||
const wxLanguageInfo *info = nullptr;
|
||||
if (! language.IsEmpty()) {
|
||||
const auto langs = get_installed_languages();
|
||||
for (const wxLanguageInfo *this_info : langs)
|
||||
if (this_info->CanonicalName == language) {
|
||||
info = this_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_wxLocale = new wxLocale;
|
||||
m_wxLocale->Init(identifiers[i]);
|
||||
if (info == nullptr) {
|
||||
m_wxLocale->Init(wxLANGUAGE_DEFAULT);
|
||||
m_imgui->set_language("en");
|
||||
} else {
|
||||
m_wxLocale->Init(info->Language);
|
||||
m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir()));
|
||||
m_wxLocale->AddCatalog("Slic3rPE");
|
||||
m_imgui->set_language(into_u8(info->CanonicalName));
|
||||
}
|
||||
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
||||
wxSetlocale(LC_NUMERIC, "C");
|
||||
Preset::update_suffix_modified();
|
||||
m_imgui->set_language(m_wxLocale->GetCanonicalName().ToUTF8().data());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// save language at application config
|
||||
@ -591,36 +633,31 @@ void GUI_App::save_language()
|
||||
app_config->save();
|
||||
}
|
||||
|
||||
// get list of installed languages
|
||||
void GUI_App::get_installed_languages(wxArrayString & names, wxArrayLong & identifiers)
|
||||
// Get a list of installed languages
|
||||
std::vector<const wxLanguageInfo*> GUI_App::get_installed_languages()
|
||||
{
|
||||
names.Clear();
|
||||
identifiers.Clear();
|
||||
std::vector<const wxLanguageInfo*> res;
|
||||
|
||||
wxDir dir(from_u8(localization_dir()));
|
||||
wxString filename;
|
||||
const wxLanguageInfo * langinfo;
|
||||
wxString name = wxLocale::GetLanguageName(wxLANGUAGE_DEFAULT);
|
||||
if (!name.IsEmpty())
|
||||
{
|
||||
names.Add(_(L("Default")));
|
||||
identifiers.Add(wxLANGUAGE_DEFAULT);
|
||||
if (!name.IsEmpty()) {
|
||||
res.push_back(wxLocale::GetLanguageInfo(wxLANGUAGE_DEFAULT));
|
||||
}
|
||||
for (bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
|
||||
cont; cont = dir.GetNext(&filename))
|
||||
{
|
||||
|
||||
for (bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS); cont; cont = dir.GetNext(&filename)) {
|
||||
langinfo = wxLocale::FindLanguageInfo(filename);
|
||||
if (langinfo != NULL)
|
||||
{
|
||||
if (langinfo != NULL) {
|
||||
auto full_file_name = dir.GetName() + wxFileName::GetPathSeparator() +
|
||||
filename + wxFileName::GetPathSeparator() + "Slic3rPE" + wxT(".mo");
|
||||
if (wxFileExists(full_file_name))
|
||||
{
|
||||
names.Add(langinfo->Description);
|
||||
identifiers.Add(langinfo->Language);
|
||||
if (wxFileExists(full_file_name)) {
|
||||
res.push_back(langinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Tab* GUI_App::get_tab(Preset::Type type)
|
||||
@ -757,14 +794,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
||||
if ( dialog.ShowModal() == wxID_CANCEL)
|
||||
return;
|
||||
|
||||
wxArrayString names;
|
||||
wxArrayLong identifiers;
|
||||
get_installed_languages(names, identifiers);
|
||||
if (select_language(names, identifiers)) {
|
||||
save_language();
|
||||
_3DScene::remove_all_canvases();// remove all canvas before recreate GUI
|
||||
recreate_GUI();
|
||||
}
|
||||
switch_language();
|
||||
break;
|
||||
}
|
||||
case ConfigMenuFlashFirmware:
|
||||
@ -790,15 +820,15 @@ bool GUI_App::check_unsaved_changes()
|
||||
for (Tab *tab : tabs_list)
|
||||
if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty())
|
||||
if (dirty.empty())
|
||||
dirty = _(tab->name());
|
||||
dirty = tab->title();
|
||||
else
|
||||
dirty += wxString(", ") + _(tab->name());
|
||||
dirty += wxString(", ") + tab->title();
|
||||
if (dirty.empty())
|
||||
// No changes, the application may close or reload presets.
|
||||
return true;
|
||||
// Ask the user.
|
||||
wxMessageDialog dialog(mainframe,
|
||||
_(L("The following presets were modified")) + ": " + dirty + "\n" + _(L("Discard changes and continue anyway?")),
|
||||
_(L("The presets on the following tabs were modified")) + ": " + dirty + "\n\n" + _(L("Discard changes and continue anyway?")),
|
||||
wxString(SLIC3R_APP_NAME) + " - " + _(L("Unsaved Presets")),
|
||||
wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT);
|
||||
return dialog.ShowModal() == wxID_YES;
|
||||
|
@ -19,6 +19,7 @@ class wxMenuItem;
|
||||
class wxMenuBar;
|
||||
class wxTopLevelWindow;
|
||||
class wxNotebook;
|
||||
struct wxLanguageInfo;
|
||||
|
||||
namespace Slic3r {
|
||||
class AppConfig;
|
||||
@ -119,18 +120,15 @@ public:
|
||||
void keyboard_shortcuts();
|
||||
void load_project(wxWindow *parent, wxString& input_file);
|
||||
void import_model(wxWindow *parent, wxArrayString& input_files);
|
||||
static bool catch_error(std::function<void()> cb,
|
||||
// wxMessageDialog* message_dialog,
|
||||
const std::string& err);
|
||||
// void notify(/*message*/);
|
||||
static bool catch_error(std::function<void()> cb, const std::string& err);
|
||||
|
||||
void persist_window_geometry(wxTopLevelWindow *window, bool default_maximized = false);
|
||||
void update_ui_from_settings();
|
||||
|
||||
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
|
||||
bool switch_language();
|
||||
// Load gettext translation files and activate them at the start of the application,
|
||||
// based on the "translation_language" key stored in the application config.
|
||||
bool load_language();
|
||||
void save_language();
|
||||
void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers);
|
||||
|
||||
Tab* get_tab(Preset::Type type);
|
||||
ConfigOptionMode get_mode();
|
||||
@ -178,6 +176,9 @@ private:
|
||||
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
||||
void window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
|
||||
void window_pos_sanitize(wxTopLevelWindow* window);
|
||||
bool select_language();
|
||||
void save_language();
|
||||
std::vector<const wxLanguageInfo*> get_installed_languages();
|
||||
#ifdef __WXMSW__
|
||||
void associate_3mf_files();
|
||||
#endif // __WXMSW__
|
||||
|
@ -554,10 +554,10 @@ void MainFrame::init_menubar()
|
||||
//# $versioncheck->Enable(wxTheApp->have_version_check);
|
||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Website")), SLIC3R_APP_NAME),
|
||||
wxString::Format(_(L("Open the %s website in your browser")), SLIC3R_APP_NAME),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://slic3r.org/"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Manual")), SLIC3R_APP_NAME),
|
||||
wxString::Format(_(L("Open the %s manual in your browser")), SLIC3R_APP_NAME),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://manual.slic3r.org/"); });
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("https://www.prusa3d.com/slic3r-prusa-edition/"); });
|
||||
// append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Manual")), SLIC3R_APP_NAME),
|
||||
// wxString::Format(_(L("Open the %s manual in your browser")), SLIC3R_APP_NAME),
|
||||
// [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://manual.slic3r.org/"); });
|
||||
helpMenu->AppendSeparator();
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L("System &Info")), _(L("Show system information")),
|
||||
[this](wxCommandEvent&) { wxGetApp().system_info(); });
|
||||
@ -917,7 +917,7 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
|
||||
#if 0
|
||||
for (auto tab : wxGetApp().tabs_list)
|
||||
if (tab->supports_printer_technology(printer_technology)) {
|
||||
if (tab->name() == "printer")
|
||||
if (tab->type() == Slic3r::Preset::TYPE_PRINTER)
|
||||
static_cast<TabPrinter*>(tab)->update_pages();
|
||||
tab->load_config(config);
|
||||
}
|
||||
|
@ -3338,7 +3338,7 @@ void Plater::remove(size_t obj_idx) { p->remove(obj_idx); }
|
||||
void Plater::reset() { p->reset(); }
|
||||
void Plater::reset_with_confirm()
|
||||
{
|
||||
if (wxMessageDialog((wxWindow*)this, _(L("All objects will be removed, continue ?")), _(L("Delete all")), wxYES_NO | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES)
|
||||
if (wxMessageDialog((wxWindow*)this, _(L("All objects will be removed, continue ?")), _(L("Delete all")), wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES)
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,13 @@ namespace GUI {
|
||||
wxDEFINE_EVENT(EVT_TAB_VALUE_CHANGED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent);
|
||||
|
||||
Tab::Tab(wxNotebook* parent, const wxString& title, const char* name) :
|
||||
m_parent(parent), m_title(title), m_name(name)
|
||||
// Tab::Tab(wxNotebook* parent, const wxString& title, const char* name) :
|
||||
// m_parent(parent), m_title(title), m_name(name)
|
||||
Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) :
|
||||
m_parent(parent), m_title(title), m_type(type)
|
||||
{
|
||||
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL, name);
|
||||
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL/*, name*/);
|
||||
this->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
set_type();
|
||||
|
||||
m_compatible_printers.type = Preset::TYPE_PRINTER;
|
||||
m_compatible_printers.key_list = "compatible_printers";
|
||||
@ -463,6 +464,7 @@ void Tab::update_changed_ui()
|
||||
// Thaw();
|
||||
|
||||
wxTheApp->CallAfter([this]() {
|
||||
if (parent()) //To avoid a crash, parent should be exist for a moment of a tree updating
|
||||
update_changed_tree_ui();
|
||||
});
|
||||
}
|
||||
|
@ -228,12 +228,14 @@ public:
|
||||
int m_update_cnt = 0;
|
||||
|
||||
public:
|
||||
Tab(wxNotebook* parent, const wxString& title, const char* name);
|
||||
// Tab(wxNotebook* parent, const wxString& title, const char* name);
|
||||
Tab(wxNotebook* parent, const wxString& title, Preset::Type type);
|
||||
~Tab() {}
|
||||
|
||||
wxWindow* parent() const { return m_parent; }
|
||||
wxString title() const { return m_title; }
|
||||
std::string name() const { return m_name; }
|
||||
// std::string name() const { return m_name; }
|
||||
std::string name() const { return m_presets->name(); }
|
||||
Preset::Type type() const { return m_type; }
|
||||
bool complited() const { return m_complited; }
|
||||
virtual bool supports_printer_technology(const PrinterTechnology tech) = 0;
|
||||
@ -312,7 +314,8 @@ class TabPrint : public Tab
|
||||
bool is_msg_dlg_already_exist {false};
|
||||
public:
|
||||
TabPrint(wxNotebook* parent) :
|
||||
Tab(parent, _(L("Print Settings")), L("print")) {}
|
||||
// Tab(parent, _(L("Print Settings")), L("print")) {}
|
||||
Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_PRINT) {}
|
||||
~TabPrint() {}
|
||||
|
||||
ogStaticText* m_recommended_thin_wall_thickness_description_line;
|
||||
@ -330,7 +333,8 @@ class TabFilament : public Tab
|
||||
ogStaticText* m_cooling_description_line;
|
||||
public:
|
||||
TabFilament(wxNotebook* parent) :
|
||||
Tab(parent, _(L("Filament Settings")), L("filament")) {}
|
||||
// Tab(parent, _(L("Filament Settings")), L("filament")) {}
|
||||
Tab(parent, _(L("Filament Settings")), Slic3r::Preset::TYPE_FILAMENT) {}
|
||||
~TabFilament() {}
|
||||
|
||||
void build() override;
|
||||
@ -363,7 +367,9 @@ public:
|
||||
|
||||
PrinterTechnology m_printer_technology = ptFFF;
|
||||
|
||||
TabPrinter(wxNotebook* parent) : Tab(parent, _(L("Printer Settings")), L("printer")) {}
|
||||
// TabPrinter(wxNotebook* parent) : Tab(parent, _(L("Printer Settings")), L("printer")) {}
|
||||
TabPrinter(wxNotebook* parent) :
|
||||
Tab(parent, _(L("Printer Settings")), Slic3r::Preset::TYPE_PRINTER) {}
|
||||
~TabPrinter() {}
|
||||
|
||||
void build() override;
|
||||
@ -386,7 +392,8 @@ class TabSLAMaterial : public Tab
|
||||
{
|
||||
public:
|
||||
TabSLAMaterial(wxNotebook* parent) :
|
||||
Tab(parent, _(L("Material Settings")), L("sla_material")) {}
|
||||
// Tab(parent, _(L("Material Settings")), L("sla_material")) {}
|
||||
Tab(parent, _(L("Material Settings")), Slic3r::Preset::TYPE_SLA_MATERIAL) {}
|
||||
~TabSLAMaterial() {}
|
||||
|
||||
void build() override;
|
||||
@ -400,7 +407,8 @@ class TabSLAPrint : public Tab
|
||||
{
|
||||
public:
|
||||
TabSLAPrint(wxNotebook* parent) :
|
||||
Tab(parent, _(L("Print Settings")), L("sla_print")) {}
|
||||
// Tab(parent, _(L("Print Settings")), L("sla_print")) {}
|
||||
Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_SLA_PRINT) {}
|
||||
~TabSLAPrint() {}
|
||||
void build() override;
|
||||
void reload_config() override;
|
||||
|
Loading…
Reference in New Issue
Block a user