Added Preference dialog to standalone gcode viewer

This commit is contained in:
enricoturri1966 2020-10-06 15:11:08 +02:00
parent b42a12db66
commit 7bee5b5479
6 changed files with 246 additions and 188 deletions

View file

@ -73,10 +73,8 @@ void AppConfig::set_defaults()
set("use_retina_opengl", "1"); set("use_retina_opengl", "1");
#endif #endif
#if !ENABLE_GCODE_APP_CONFIG
if (get("single_instance").empty()) if (get("single_instance").empty())
set("single_instance", "0"); set("single_instance", "0");
#endif // !ENABLE_GCODE_APP_CONFIG
if (get("remember_output_path").empty()) if (get("remember_output_path").empty())
set("remember_output_path", "1"); set("remember_output_path", "1");
@ -84,7 +82,6 @@ void AppConfig::set_defaults()
if (get("remember_output_path_removable").empty()) if (get("remember_output_path_removable").empty())
set("remember_output_path_removable", "1"); set("remember_output_path_removable", "1");
#if !ENABLE_GCODE_APP_CONFIG
if (get("use_custom_toolbar_size").empty()) if (get("use_custom_toolbar_size").empty())
set("use_custom_toolbar_size", "0"); set("use_custom_toolbar_size", "0");
@ -94,6 +91,7 @@ void AppConfig::set_defaults()
if (get("auto_toolbar_size").empty()) if (get("auto_toolbar_size").empty())
set("auto_toolbar_size", "100"); set("auto_toolbar_size", "100");
#if !ENABLE_GCODE_APP_CONFIG
if (get("use_perspective_camera").empty()) if (get("use_perspective_camera").empty())
set("use_perspective_camera", "1"); set("use_perspective_camera", "1");
@ -111,18 +109,6 @@ void AppConfig::set_defaults()
#if ENABLE_GCODE_APP_CONFIG #if ENABLE_GCODE_APP_CONFIG
} }
if (get("single_instance").empty())
set("single_instance", "0");
if (get("use_custom_toolbar_size").empty())
set("use_custom_toolbar_size", "0");
if (get("custom_toolbar_size").empty())
set("custom_toolbar_size", "100");
if (get("auto_toolbar_size").empty())
set("auto_toolbar_size", "100");
if (get("use_perspective_camera").empty()) if (get("use_perspective_camera").empty())
set("use_perspective_camera", "1"); set("use_perspective_camera", "1");

View file

@ -1946,6 +1946,9 @@ void GLCanvas3D::render()
} }
#if ENABLE_ENVIRONMENT_MAP #if ENABLE_ENVIRONMENT_MAP
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_editor())
#endif // ENABLE_GCODE_VIEWER
wxGetApp().plater()->init_environment_texture(); wxGetApp().plater()->init_environment_texture();
#endif // ENABLE_ENVIRONMENT_MAP #endif // ENABLE_ENVIRONMENT_MAP
@ -4241,7 +4244,7 @@ void GLCanvas3D::update_ui_from_settings()
#if ENABLE_GCODE_VIEWER #if ENABLE_GCODE_VIEWER
if (wxGetApp().is_editor()) if (wxGetApp().is_editor())
wxGetApp().plater()->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1"); wxGetApp().plater()->enable_collapse_toolbar(wxGetApp().app_config->get("show_collapse_button") == "1");
#else #else
bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1"; bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1";
wxGetApp().plater()->get_collapse_toolbar().set_enabled(enable_collapse); wxGetApp().plater()->get_collapse_toolbar().set_enabled(enable_collapse);

View file

@ -506,10 +506,10 @@ static void generic_exception_handle()
} catch (const std::bad_alloc& ex) { } catch (const std::bad_alloc& ex) {
// bad_alloc in main thread is most likely fatal. Report immediately to the user (wxLogError would be delayed) // bad_alloc in main thread is most likely fatal. Report immediately to the user (wxLogError would be delayed)
// and terminate the app so it is at least certain to happen now. // and terminate the app so it is at least certain to happen now.
wxString errmsg = wxString::Format(_(L("%s has encountered an error. It was likely caused by running out of memory. " wxString errmsg = wxString::Format(_L("%s has encountered an error. It was likely caused by running out of memory. "
"If you are sure you have enough RAM on your system, this may also be a bug and we would " "If you are sure you have enough RAM on your system, this may also be a bug and we would "
"be glad if you reported it.\n\nThe application will now terminate.")), SLIC3R_APP_NAME); "be glad if you reported it.\n\nThe application will now terminate."), SLIC3R_APP_NAME);
wxMessageBox(errmsg + "\n\n" + wxString(ex.what()), _(L("Fatal error")), wxOK | wxICON_ERROR); wxMessageBox(errmsg + "\n\n" + wxString(ex.what()), _L("Fatal error"), wxOK | wxICON_ERROR);
BOOST_LOG_TRIVIAL(error) << boost::format("std::bad_alloc exception: %1%") % ex.what(); BOOST_LOG_TRIVIAL(error) << boost::format("std::bad_alloc exception: %1%") % ex.what();
std::terminate(); std::terminate();
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
@ -701,9 +701,9 @@ bool GUI_App::on_init_inner()
if (!msg.empty() && !ssl_accept) { if (!msg.empty() && !ssl_accept) {
wxRichMessageDialog wxRichMessageDialog
dlg(nullptr, dlg(nullptr,
wxString::Format(_(L("%s\nDo you want to continue?")), msg), wxString::Format(_L("%s\nDo you want to continue?"), msg),
"PrusaSlicer", wxICON_QUESTION | wxYES_NO); "PrusaSlicer", wxICON_QUESTION | wxYES_NO);
dlg.ShowCheckBox(_(L("Remember my choice"))); dlg.ShowCheckBox(_L("Remember my choice"));
if (dlg.ShowModal() != wxID_YES) return false; if (dlg.ShowModal() != wxID_YES) return false;
app_config->set("tls_cert_store_accepted", app_config->set("tls_cert_store_accepted",
@ -1157,7 +1157,7 @@ void GUI_App::load_project(wxWindow *parent, wxString& input_file) const
{ {
input_file.Clear(); input_file.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(), wxFileDialog dialog(parent ? parent : GetTopWindow(),
_(L("Choose one file (3MF/AMF):")), _L("Choose one file (3MF/AMF):"),
app_config->get_last_dir(), "", app_config->get_last_dir(), "",
file_wildcards(FT_PROJECT), wxFD_OPEN | wxFD_FILE_MUST_EXIST); file_wildcards(FT_PROJECT), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
@ -1169,7 +1169,7 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
{ {
input_files.Clear(); input_files.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(), wxFileDialog dialog(parent ? parent : GetTopWindow(),
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")), _L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):"),
from_u8(app_config->get_last_dir()), "", from_u8(app_config->get_last_dir()), "",
file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST); file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
@ -1182,7 +1182,7 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
{ {
input_file.Clear(); input_file.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(), wxFileDialog dialog(parent ? parent : GetTopWindow(),
_(L("Choose one file (GCODE/.GCO/.G/.ngc/NGC):")), _L("Choose one file (GCODE/.GCO/.G/.ngc/NGC):"),
app_config->get_last_dir(), "", app_config->get_last_dir(), "",
file_wildcards(FT_GCODE), wxFD_OPEN | wxFD_FILE_MUST_EXIST); file_wildcards(FT_GCODE), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
@ -1244,7 +1244,7 @@ bool GUI_App::select_language()
// This is the language to highlight in the choice dialog initially. // This is the language to highlight in the choice dialog initially.
init_selection_default = init_selection; init_selection_default = init_selection;
const long index = wxGetSingleChoiceIndex(_(L("Select the language")), _(L("Language")), names, init_selection_default); const long index = wxGetSingleChoiceIndex(_L("Select the language"), _L("Language"), names, init_selection_default);
// Try to load a new language. // Try to load a new language.
if (index != -1 && (init_selection == -1 || init_selection != index)) { if (index != -1 && (init_selection == -1 || init_selection != index)) {
const wxLanguageInfo *new_language_info = language_infos[index]; const wxLanguageInfo *new_language_info = language_infos[index];
@ -1425,35 +1425,52 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
const auto config_wizard_name = _(ConfigWizard::name(true)); const auto config_wizard_name = _(ConfigWizard::name(true));
const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Run %s"))) % config_wizard_name).str()); const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Run %s"))) % config_wizard_name).str());
// Cmd+, is standard on OS X - what about other operating systems? // Cmd+, is standard on OS X - what about other operating systems?
#if ENABLE_GCODE_APP_CONFIG
if (is_editor()) {
#endif // ENABLE_GCODE_APP_CONFIG
local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip); local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip);
local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("&Configuration Snapshots")) + dots, _(L("Inspect / activate configuration snapshots"))); local_menu->Append(config_id_base + ConfigMenuSnapshots, _L("&Configuration Snapshots") + dots, _L("Inspect / activate configuration snapshots"));
local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration &Snapshot")), _(L("Capture a configuration snapshot"))); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _L("Take Configuration &Snapshot"), _L("Capture a configuration snapshot"));
local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); local_menu->Append(config_id_base + ConfigMenuUpdate, _L("Check for updates"), _L("Check for configuration updates"));
local_menu->AppendSeparator(); local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("&Preferences")) + dots + #if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
local_menu->Append(config_id_base + ConfigMenuPreferences, _L("&Preferences") + dots +
#ifdef __APPLE__ #ifdef __APPLE__
"\tCtrl+,", "\tCtrl+,",
#else #else
"\tCtrl+P", "\tCtrl+P",
#endif #endif
_(L("Application preferences"))); _L("Application preferences"));
#if ENABLE_GCODE_APP_CONFIG
wxMenu* mode_menu = nullptr;
if (is_editor()) {
#endif // ENABLE_GCODE_APP_CONFIG
local_menu->AppendSeparator(); local_menu->AppendSeparator();
#if ENABLE_GCODE_APP_CONFIG
mode_menu = new wxMenu();
#else
auto mode_menu = new wxMenu(); auto mode_menu = new wxMenu();
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("Simple")), _(L("Simple View Mode"))); #endif // ENABLE_GCODE_APP_CONFIG
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _(L("Advanced")), _(L("Advanced View Mode"))); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _L("Simple"), _L("Simple View Mode"));
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _L("Advanced"), _L("Advanced View Mode"));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), _L("Advanced View Mode")); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), _L("Advanced View Mode"));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("Expert")), _(L("Expert View Mode"))); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _L("Expert"), _L("Expert View Mode"));
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert); 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->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s View Mode"), SLIC3R_APP_NAME));
local_menu->AppendSeparator(); local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("&Language"))); local_menu->Append(config_id_base + ConfigMenuLanguage, _L("&Language"));
local_menu->AppendSeparator(); local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _(L("Flash printer &firmware")), _(L("Upload a firmware image into an Arduino based printer"))); 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 // TODO: for when we're able to flash dictionaries
// local_menu->Append(config_id_base + FirmwareMenuDict, _(L("Flash language file")), _(L("Upload a language dictionary file into a Prusa printer"))); // local_menu->Append(config_id_base + FirmwareMenuDict, _L("Flash language file"), _L("Upload a language dictionary file into a Prusa printer"));
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) { local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) {
switch (event.GetId() - config_id_base) { switch (event.GetId() - config_id_base) {
@ -1466,7 +1483,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
case ConfigMenuTakeSnapshot: case ConfigMenuTakeSnapshot:
// Take a configuration snapshot. // Take a configuration snapshot.
if (check_unsaved_changes()) { if (check_unsaved_changes()) {
wxTextEntryDialog dlg(nullptr, _(L("Taking configuration snapshot")), _(L("Snapshot name"))); wxTextEntryDialog dlg(nullptr, _L("Taking configuration snapshot"), _L("Snapshot name"));
// set current normal font for dialog children, // set current normal font for dialog children,
// because of just dlg.SetFont(normal_font()) has no result; // because of just dlg.SetFont(normal_font()) has no result;
@ -1526,10 +1543,10 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
// or sometimes the application crashes into wxDialogBase() destructor // or sometimes the application crashes into wxDialogBase() destructor
// so we put it into an inner scope // so we put it into an inner scope
wxMessageDialog dialog(nullptr, wxMessageDialog dialog(nullptr,
_(L("Switching the language will trigger application restart.\n" _L("Switching the language will trigger application restart.\n"
"You will lose content of the plater.")) + "\n\n" + "You will lose content of the plater.") + "\n\n" +
_(L("Do you want to proceed?")), _L("Do you want to proceed?"),
wxString(SLIC3R_APP_NAME) + " - " + _(L("Language selection")), wxString(SLIC3R_APP_NAME) + " - " + _L("Language selection"),
wxICON_QUESTION | wxOK | wxCANCEL); wxICON_QUESTION | wxOK | wxCANCEL);
if (dialog.ShowModal() == wxID_CANCEL) if (dialog.ShowModal() == wxID_CANCEL)
return; return;
@ -1548,12 +1565,18 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
using std::placeholders::_1; using std::placeholders::_1;
#if ENABLE_GCODE_APP_CONFIG
if (mode_menu != nullptr) {
#endif // ENABLE_GCODE_APP_CONFIG
auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); }; auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); };
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple); mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced); mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert); mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert);
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
menu->Append(local_menu, _(L("&Configuration"))); menu->Append(local_menu, _L("&Configuration"));
} }
// This is called when closing the application, when loading a config file or when starting the config wizard // This is called when closing the application, when loading a config file or when starting the config wizard
@ -1763,9 +1786,9 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
if (preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA if (preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA
&& Slic3r::model_has_multi_part_objects(wxGetApp().model())) { && Slic3r::model_has_multi_part_objects(wxGetApp().model())) {
GUI::show_info(nullptr, GUI::show_info(nullptr,
_(L("It's impossible to print multi-part object(s) with SLA technology.")) + "\n\n" + _L("It's impossible to print multi-part object(s) with SLA technology.") + "\n\n" +
_(L("Please check and fix your object list.")), _L("Please check and fix your object list."),
_(L("Attention!"))); _L("Attention!"));
} }
} }
@ -1782,7 +1805,7 @@ void GUI_App::gcode_thumbnails_debug()
unsigned int width = 0; unsigned int width = 0;
unsigned int height = 0; unsigned int height = 0;
wxFileDialog dialog(GetTopWindow(), _(L("Select a gcode file:")), "", "", "G-code files (*.gcode)|*.gcode;*.GCODE;", wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxFileDialog dialog(GetTopWindow(), _L("Select a gcode file:"), "", "", "G-code files (*.gcode)|*.gcode;*.GCODE;", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (dialog.ShowModal() != wxID_OK) if (dialog.ShowModal() != wxID_OK)
return; return;

View file

@ -1413,6 +1413,10 @@ void MainFrame::init_menubar_as_gcodeviewer()
m_menubar = new wxMenuBar(); m_menubar = new wxMenuBar();
m_menubar->Append(fileMenu, _L("&File")); m_menubar->Append(fileMenu, _L("&File"));
if (viewMenu != nullptr) m_menubar->Append(viewMenu, _L("&View")); if (viewMenu != nullptr) m_menubar->Append(viewMenu, _L("&View"));
#if ENABLE_GCODE_APP_CONFIG
// Add additional menus from C++
wxGetApp().add_config_menu(m_menubar);
#endif // ENABLE_GCODE_APP_CONFIG
m_menubar->Append(helpMenu, _L("&Help")); m_menubar->Append(helpMenu, _L("&Help"));
SetMenuBar(m_menubar); SetMenuBar(m_menubar);

View file

@ -1331,6 +1331,9 @@ void Sidebar::collapse(bool collapse)
p->plater->Layout(); p->plater->Layout();
// save collapsing state to the AppConfig // save collapsing state to the AppConfig
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_editor())
#endif // ENABLE_GCODE_VIEWER
wxGetApp().app_config->set("collapsed_sidebar", collapse ? "1" : "0"); wxGetApp().app_config->set("collapsed_sidebar", collapse ? "1" : "0");
} }
@ -2056,8 +2059,14 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
wxGetApp().other_instance_message_handler()->init(this->q); wxGetApp().other_instance_message_handler()->init(this->q);
// collapse sidebar according to saved value // collapse sidebar according to saved value
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_editor()) {
#endif // ENABLE_GCODE_VIEWER
bool is_collapsed = wxGetApp().app_config->get("collapsed_sidebar") == "1"; bool is_collapsed = wxGetApp().app_config->get("collapsed_sidebar") == "1";
sidebar->collapse(is_collapsed); sidebar->collapse(is_collapsed);
#if ENABLE_GCODE_VIEWER
}
#endif // ENABLE_GCODE_VIEWER
} }
Plater::priv::~priv() Plater::priv::~priv()
@ -3988,6 +3997,11 @@ void Plater::priv::reset_canvas_volumes()
bool Plater::priv::init_view_toolbar() bool Plater::priv::init_view_toolbar()
{ {
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_gcode_viewer())
return true;
#endif // ENABLE_GCODE_VIEWER
if (view_toolbar.get_items_count() > 0) if (view_toolbar.get_items_count() > 0)
// already initialized // already initialized
return true; return true;
@ -4026,10 +4040,6 @@ bool Plater::priv::init_view_toolbar()
return false; return false;
view_toolbar.select_item("3D"); view_toolbar.select_item("3D");
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_editor())
#endif // ENABLE_GCODE_VIEWER
view_toolbar.set_enabled(true); view_toolbar.set_enabled(true);
return true; return true;
@ -4037,6 +4047,11 @@ bool Plater::priv::init_view_toolbar()
bool Plater::priv::init_collapse_toolbar() bool Plater::priv::init_collapse_toolbar()
{ {
#if ENABLE_GCODE_VIEWER
if (wxGetApp().is_gcode_viewer())
return true;
#endif // ENABLE_GCODE_VIEWER
if (collapse_toolbar.get_items_count() > 0) if (collapse_toolbar.get_items_count() > 0)
// already initialized // already initialized
return true; return true;

View file

@ -8,7 +8,7 @@ namespace Slic3r {
namespace GUI { namespace GUI {
PreferencesDialog::PreferencesDialog(wxWindow* parent) : PreferencesDialog::PreferencesDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition, DPIDialog(parent, wxID_ANY, _L("Preferences"), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE) wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{ {
#ifdef __WXOSX__ #ifdef __WXOSX__
@ -20,7 +20,7 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) :
void PreferencesDialog::build() void PreferencesDialog::build()
{ {
auto app_config = get_app_config(); auto app_config = get_app_config();
m_optgroup_general = std::make_shared<ConfigOptionsGroup>(this, _(L("General"))); m_optgroup_general = std::make_shared<ConfigOptionsGroup>(this, _L("General"));
m_optgroup_general->label_width = 40; m_optgroup_general->label_width = 40;
m_optgroup_general->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_optgroup_general->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0"; m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -36,13 +36,25 @@ void PreferencesDialog::build()
// readonly = > !wxTheApp->have_version_check, // readonly = > !wxTheApp->have_version_check,
// )); // ));
#if ENABLE_GCODE_APP_CONFIG
bool is_editor = wxGetApp().is_editor();
#endif // ENABLE_GCODE_APP_CONFIG
ConfigOptionDef def; ConfigOptionDef def;
#if ENABLE_GCODE_APP_CONFIG
Option option(def, "");
if (is_editor) {
#endif // ENABLE_GCODE_APP_CONFIG
def.label = L("Remember output directory"); def.label = L("Remember output directory");
def.type = coBool; def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory " def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory "
"instead of the one containing the input files."); "instead of the one containing the input files.");
def.set_default_value(new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true }); def.set_default_value(new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true });
#if ENABLE_GCODE_APP_CONFIG
option = Option(def, "remember_output_path");
#else
Option option(def, "remember_output_path"); Option option(def, "remember_output_path");
#endif // ENABLE_GCODE_APP_CONFIG
m_optgroup_general->append_single_option_line(option); m_optgroup_general->append_single_option_line(option);
def.label = L("Auto-center parts"); def.label = L("Auto-center parts");
@ -111,6 +123,9 @@ void PreferencesDialog::build()
def.set_default_value(new ConfigOptionBool{ app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false }); def.set_default_value(new ConfigOptionBool{ app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false });
option = Option(def, "single_instance"); option = Option(def, "single_instance");
m_optgroup_general->append_single_option_line(option); m_optgroup_general->append_single_option_line(option);
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
#if __APPLE__ #if __APPLE__
def.label = L("Use Retina resolution for the 3D scene"); def.label = L("Use Retina resolution for the 3D scene");
@ -142,7 +157,7 @@ void PreferencesDialog::build()
m_optgroup_general->activate(); m_optgroup_general->activate();
m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _(L("Camera"))); m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _L("Camera"));
m_optgroup_camera->label_width = 40; m_optgroup_camera->label_width = 40;
m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0"; m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -164,7 +179,10 @@ void PreferencesDialog::build()
m_optgroup_camera->activate(); m_optgroup_camera->activate();
m_optgroup_gui = std::make_shared<ConfigOptionsGroup>(this, _(L("GUI"))); #if ENABLE_GCODE_APP_CONFIG
if (is_editor) {
#endif // ENABLE_GCODE_APP_CONFIG
m_optgroup_gui = std::make_shared<ConfigOptionsGroup>(this, _L("GUI"));
m_optgroup_gui->label_width = 40; m_optgroup_gui->label_width = 40;
m_optgroup_gui->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_optgroup_gui->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0"; m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -196,7 +214,7 @@ void PreferencesDialog::build()
create_settings_mode_widget(); create_settings_mode_widget();
#if ENABLE_ENVIRONMENT_MAP #if ENABLE_ENVIRONMENT_MAP
m_optgroup_render = std::make_shared<ConfigOptionsGroup>(this, _(L("Render"))); m_optgroup_render = std::make_shared<ConfigOptionsGroup>(this, _L("Render"));
m_optgroup_render->label_width = 40; m_optgroup_render->label_width = 40;
m_optgroup_render->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_optgroup_render->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0"; m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -211,12 +229,21 @@ void PreferencesDialog::build()
m_optgroup_render->activate(); m_optgroup_render->activate();
#endif // ENABLE_ENVIRONMENT_MAP #endif // ENABLE_ENVIRONMENT_MAP
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
auto sizer = new wxBoxSizer(wxVERTICAL); auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_optgroup_general->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); sizer->Add(m_optgroup_general->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
sizer->Add(m_optgroup_camera->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); sizer->Add(m_optgroup_camera->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
#if ENABLE_GCODE_APP_CONFIG
if (m_optgroup_gui != nullptr)
#endif // ENABLE_GCODE_APP_CONFIG
sizer->Add(m_optgroup_gui->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); sizer->Add(m_optgroup_gui->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
#if ENABLE_ENVIRONMENT_MAP #if ENABLE_ENVIRONMENT_MAP
#if ENABLE_GCODE_APP_CONFIG
if (m_optgroup_render != nullptr)
#endif // ENABLE_GCODE_APP_CONFIG
sizer->Add(m_optgroup_render->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); sizer->Add(m_optgroup_render->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
#endif // ENABLE_ENVIRONMENT_MAP #endif // ENABLE_ENVIRONMENT_MAP
@ -234,7 +261,7 @@ void PreferencesDialog::build()
void PreferencesDialog::accept() void PreferencesDialog::accept()
{ {
if (m_values.find("no_defaults") != m_values.end()) { if (m_values.find("no_defaults") != m_values.end()) {
warning_catcher(this, wxString::Format(_(L("You need to restart %s to make the changes effective.")), SLIC3R_APP_NAME)); warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
} }
auto app_config = get_app_config(); auto app_config = get_app_config();
@ -300,7 +327,7 @@ void PreferencesDialog::create_icon_size_slider()
// we should use system default background // we should use system default background
parent->SetBackgroundStyle(wxBG_STYLE_ERASE); parent->SetBackgroundStyle(wxBG_STYLE_ERASE);
auto label = new wxStaticText(parent, wxID_ANY, _(L("Icon size in a respect to the default size")) + " (%) :"); auto label = new wxStaticText(parent, wxID_ANY, _L("Icon size in a respect to the default size") + " (%) :");
m_icon_size_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL| wxRIGHT | (isOSX ? 0 : wxLEFT), em); m_icon_size_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL| wxRIGHT | (isOSX ? 0 : wxLEFT), em);
@ -315,7 +342,7 @@ void PreferencesDialog::create_icon_size_slider()
slider->SetTickFreq(10); slider->SetTickFreq(10);
slider->SetPageSize(10); slider->SetPageSize(10);
slider->SetToolTip(_(L("Select toolbar icon size in respect to the default one."))); slider->SetToolTip(_L("Select toolbar icon size in respect to the default one."));
m_icon_size_sizer->Add(slider, 1, wxEXPAND); m_icon_size_sizer->Add(slider, 1, wxEXPAND);