Added menu command Configuration/Language to standalone gcode viewer

This commit is contained in:
enricoturri1966 2020-10-12 08:39:40 +02:00
parent f16ef0643c
commit 21366f56e7
6 changed files with 53 additions and 25 deletions

View file

@ -1530,7 +1530,7 @@ bool GLCanvas3D::init()
if (m_initialized)
return true;
if ((m_canvas == nullptr) || (m_context == nullptr))
if (m_canvas == nullptr || m_context == nullptr)
return false;
glsafe(::glClearColor(1.0f, 1.0f, 1.0f, 1.0f));
@ -1580,8 +1580,7 @@ bool GLCanvas3D::init()
m_layers_editing.init();
#if ENABLE_GCODE_VIEWER
if (!m_main_toolbar.is_enabled())
{
if (!m_main_toolbar.is_enabled()) {
if (!m_gcode_viewer.init())
return false;
}
@ -5128,7 +5127,7 @@ bool GLCanvas3D::_set_current()
void GLCanvas3D::_resize(unsigned int w, unsigned int h)
{
if ((m_canvas == nullptr) && (m_context == nullptr))
if (m_canvas == nullptr && m_context == nullptr)
return;
auto *imgui = wxGetApp().imgui();

View file

@ -647,8 +647,8 @@ void GUI_App::init_app_config()
#endif // ENABLE_GCODE_VIEWER
// load settings
app_conf_exists = app_config->exists();
if (app_conf_exists) {
m_app_conf_exists = app_config->exists();
if (m_app_conf_exists) {
std::string error = app_config->load();
#if ENABLE_GCODE_APP_CONFIG
if (!error.empty()) {
@ -1079,6 +1079,10 @@ void GUI_App::check_printer_presets()
void GUI_App::recreate_GUI(const wxString& msg_name)
{
#if ENABLE_GCODE_APP_CONFIG
m_is_recreating_gui = true;
#endif // ENABLE_GCODE_APP_CONFIG
mainframe->shutdown();
wxProgressDialog dlg(msg_name, msg_name, 100, nullptr, wxPD_AUTO_HIDE);
@ -1087,8 +1091,11 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
MainFrame *old_main_frame = mainframe;
mainframe = new MainFrame();
// hide settings tabs after first Layout
mainframe->select_tab(size_t(0));
#if ENABLE_GCODE_APP_CONFIG
if (is_editor())
#endif // ENABLE_GCODE_APP_CONFIG
// hide settings tabs after first Layout
mainframe->select_tab(size_t(0));
// Propagate model objects to object list.
sidebar().obj_list()->init_objects();
SetTopWindow(mainframe);
@ -1118,6 +1125,10 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
// // Run the config wizard, don't offer the "reset user profile" checkbox.
// config_wizard_startup(true);
// });
#if ENABLE_GCODE_APP_CONFIG
m_is_recreating_gui = false;
#endif // ENABLE_GCODE_APP_CONFIG
}
void GUI_App::system_info()
@ -1487,8 +1498,14 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert);
local_menu->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s View Mode"), SLIC3R_APP_NAME));
local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuLanguage, _L("&Language"));
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuLanguage, _L("&Language"));
#if ENABLE_GCODE_APP_CONFIG
if (is_editor()) {
#endif // ENABLE_GCODE_APP_CONFIG
local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _L("Flash printer &firmware"), _L("Upload a firmware image into an Arduino based printer"));
// TODO: for when we're able to flash dictionaries
@ -1567,11 +1584,19 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
// the dialog needs to be destroyed before the call to switch_language()
// or sometimes the application crashes into wxDialogBase() destructor
// so we put it into an inner scope
#if ENABLE_GCODE_APP_CONFIG
wxString title = is_editor() ? wxString(SLIC3R_APP_NAME) : wxString(GCODEVIEWER_APP_NAME);
title += " - " + _L("Language selection");
#endif // ENABLE_GCODE_APP_CONFIG
wxMessageDialog dialog(nullptr,
_L("Switching the language will trigger application restart.\n"
"You will lose content of the plater.") + "\n\n" +
_L("Do you want to proceed?"),
#if ENABLE_GCODE_APP_CONFIG
title,
#else
wxString(SLIC3R_APP_NAME) + " - " + _L("Language selection"),
#endif // ENABLE_GCODE_APP_CONFIG
wxICON_QUESTION | wxOK | wxCANCEL);
if (dialog.ShowModal() == wxID_CANCEL)
return;
@ -1948,7 +1973,7 @@ void GUI_App::window_pos_sanitize(wxTopLevelWindow* window)
bool GUI_App::config_wizard_startup()
{
if (!app_conf_exists || preset_bundle->printers.size() <= 1) {
if (!m_app_conf_exists || preset_bundle->printers.size() <= 1) {
run_wizard(ConfigWizard::RR_DATA_EMPTY);
return true;
} else if (get_app_config()->legacy_datadir()) {
@ -1965,8 +1990,7 @@ bool GUI_App::config_wizard_startup()
}
void GUI_App::check_updates(const bool verbose)
{
{
PresetUpdater::UpdateResult updater_result;
try {
updater_result = preset_updater->config_update(app_config->orig_version(), verbose);
@ -1974,10 +1998,9 @@ void GUI_App::check_updates(const bool verbose)
mainframe->Close();
}
else if (updater_result == PresetUpdater::R_INCOMPAT_CONFIGURED) {
app_conf_exists = true;
m_app_conf_exists = true;
}
else if(verbose && updater_result == PresetUpdater::R_NOOP)
{
else if (verbose && updater_result == PresetUpdater::R_NOOP) {
MsgNoUpdates dlg;
dlg.ShowModal();
}
@ -1985,9 +2008,8 @@ void GUI_App::check_updates(const bool verbose)
catch (const std::exception & ex) {
show_error(nullptr, ex.what());
}
}
// static method accepting a wxWindow object as first parameter
// void warning_catcher{
// my($self, $message_dialog) = @_;

View file

@ -106,9 +106,12 @@ private:
#endif // ENABLE_GCODE_VIEWER
bool m_initialized { false };
bool app_conf_exists{ false };
bool m_app_conf_exists{ false };
#if ENABLE_GCODE_VIEWER
EAppMode m_app_mode{ EAppMode::Editor };
#if ENABLE_GCODE_APP_CONFIG
bool m_is_recreating_gui{ false };
#endif // ENABLE_GCODE_APP_CONFIG
#endif // ENABLE_GCODE_VIEWER
wxColour m_color_label_modified;
@ -184,6 +187,9 @@ public:
EAppMode get_app_mode() const { return m_app_mode; }
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
#if ENABLE_GCODE_APP_CONFIG
bool is_recreating_gui() const { return m_is_recreating_gui; }
#endif // ENABLE_GCODE_APP_CONFIG
#endif // ENABLE_GCODE_VIEWER
static std::string get_gl_info(bool format_as_html, bool extensions);

View file

@ -1212,8 +1212,12 @@ void Preview::update_double_slider_from_canvas(wxKeyEvent & event)
void Preview::load_print_as_fff(bool keep_z_range)
{
#if ENABLE_GCODE_VIEWER
#if ENABLE_GCODE_APP_CONFIG
if (wxGetApp().mainframe == nullptr || wxGetApp().is_recreating_gui())
#else
if (wxGetApp().mainframe == nullptr)
// avoid proessing while mainframe is being constructed
#endif // ENABLE_GCODE_APP_CONFIG
// avoid processing while mainframe is being constructed
return;
#endif // ENABLE_GCODE_VIEWER

View file

@ -203,10 +203,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
sizer->Add(m_main_sizer, 1, wxEXPAND);
SetSizer(sizer);
// initialize layout from config
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_editor())
#endif // ENABLE_GCODE_VIEWER
update_layout();
update_layout();
sizer->SetSizeHints(this);
Fit();

View file

@ -5418,7 +5418,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
p->reset_gcode_toolpaths();
#endif // ENABLE_GCODE_VIEWER
}
else if ((opt_key == "bed_shape") || (opt_key == "bed_custom_texture") || (opt_key == "bed_custom_model")) {
else if (opt_key == "bed_shape" || opt_key == "bed_custom_texture" || opt_key == "bed_custom_model") {
bed_shape_changed = true;
update_scheduled = true;
}