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

@ -8,7 +8,7 @@ namespace Slic3r {
namespace GUI {
PreferencesDialog::PreferencesDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
DPIDialog(parent, wxID_ANY, _L("Preferences"), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{
#ifdef __WXOSX__
@ -20,7 +20,7 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) :
void PreferencesDialog::build()
{
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->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -36,81 +36,96 @@ void PreferencesDialog::build()
// readonly = > !wxTheApp->have_version_check,
// ));
#if ENABLE_GCODE_APP_CONFIG
bool is_editor = wxGetApp().is_editor();
#endif // ENABLE_GCODE_APP_CONFIG
ConfigOptionDef def;
def.label = L("Remember output directory");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory "
"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 });
Option option(def, "remember_output_path");
m_optgroup_general->append_single_option_line(option);
def.label = L("Auto-center parts");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will auto-center objects "
"around the print bed center.");
def.set_default_value(new ConfigOptionBool{ app_config->get("autocenter") == "1" });
option = Option (def,"autocenter");
m_optgroup_general->append_single_option_line(option);
def.label = L("Background processing");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will pre-process objects as soon "
"as they\'re loaded in order to save time when exporting G-code.");
def.set_default_value(new ConfigOptionBool{ app_config->get("background_processing") == "1" });
option = Option (def,"background_processing");
m_optgroup_general->append_single_option_line(option);
// Please keep in sync with ConfigWizard
def.label = L("Check for application updates");
def.type = coBool;
def.tooltip = L("If enabled, PrusaSlicer will check for the new versions of itself online. When a new version becomes available a notification is displayed at the next application startup (never during program usage). This is only a notification mechanisms, no automatic installation is done.");
def.set_default_value(new ConfigOptionBool(app_config->get("version_check") == "1"));
option = Option (def, "version_check");
m_optgroup_general->append_single_option_line(option);
// Please keep in sync with ConfigWizard
def.label = L("Export sources full pathnames to 3mf and amf");
def.type = coBool;
def.tooltip = L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked.");
def.set_default_value(new ConfigOptionBool(app_config->get("export_sources_full_pathnames") == "1"));
option = Option(def, "export_sources_full_pathnames");
m_optgroup_general->append_single_option_line(option);
// Please keep in sync with ConfigWizard
def.label = L("Update built-in Presets automatically");
def.type = coBool;
def.tooltip = L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup.");
def.set_default_value(new ConfigOptionBool(app_config->get("preset_update") == "1"));
option = Option (def, "preset_update");
m_optgroup_general->append_single_option_line(option);
def.label = L("Suppress \" - default - \" presets");
def.type = coBool;
def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer "
"selections once there are any other valid presets available.");
def.set_default_value(new ConfigOptionBool{ app_config->get("no_defaults") == "1" });
option = Option (def,"no_defaults");
m_optgroup_general->append_single_option_line(option);
def.label = L("Show incompatible print and filament presets");
def.type = coBool;
def.tooltip = L("When checked, the print and filament presets are shown in the preset editor "
"even if they are marked as incompatible with the active printer");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" });
option = Option (def,"show_incompatible_presets");
m_optgroup_general->append_single_option_line(option);
def.label = L("Single Instance");
def.type = coBool;
#if __APPLE__
def.tooltip = L("On OSX there is always only one instance of app running by default. However it is allowed to run multiple instances of same app from the command line. In such case this settings will allow only one instance.");
#if ENABLE_GCODE_APP_CONFIG
Option option(def, "");
if (is_editor) {
#endif // ENABLE_GCODE_APP_CONFIG
def.label = L("Remember output directory");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory "
"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 });
#if ENABLE_GCODE_APP_CONFIG
option = Option(def, "remember_output_path");
#else
def.tooltip = L("If this is enabled, when staring PrusaSlicer and another instance of same PrusaSlicer is running, that instance will be reactivated instead.");
Option option(def, "remember_output_path");
#endif // ENABLE_GCODE_APP_CONFIG
m_optgroup_general->append_single_option_line(option);
def.label = L("Auto-center parts");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will auto-center objects "
"around the print bed center.");
def.set_default_value(new ConfigOptionBool{ app_config->get("autocenter") == "1" });
option = Option(def, "autocenter");
m_optgroup_general->append_single_option_line(option);
def.label = L("Background processing");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will pre-process objects as soon "
"as they\'re loaded in order to save time when exporting G-code.");
def.set_default_value(new ConfigOptionBool{ app_config->get("background_processing") == "1" });
option = Option(def, "background_processing");
m_optgroup_general->append_single_option_line(option);
// Please keep in sync with ConfigWizard
def.label = L("Check for application updates");
def.type = coBool;
def.tooltip = L("If enabled, PrusaSlicer will check for the new versions of itself online. When a new version becomes available a notification is displayed at the next application startup (never during program usage). This is only a notification mechanisms, no automatic installation is done.");
def.set_default_value(new ConfigOptionBool(app_config->get("version_check") == "1"));
option = Option(def, "version_check");
m_optgroup_general->append_single_option_line(option);
// Please keep in sync with ConfigWizard
def.label = L("Export sources full pathnames to 3mf and amf");
def.type = coBool;
def.tooltip = L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked.");
def.set_default_value(new ConfigOptionBool(app_config->get("export_sources_full_pathnames") == "1"));
option = Option(def, "export_sources_full_pathnames");
m_optgroup_general->append_single_option_line(option);
// Please keep in sync with ConfigWizard
def.label = L("Update built-in Presets automatically");
def.type = coBool;
def.tooltip = L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup.");
def.set_default_value(new ConfigOptionBool(app_config->get("preset_update") == "1"));
option = Option(def, "preset_update");
m_optgroup_general->append_single_option_line(option);
def.label = L("Suppress \" - default - \" presets");
def.type = coBool;
def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer "
"selections once there are any other valid presets available.");
def.set_default_value(new ConfigOptionBool{ app_config->get("no_defaults") == "1" });
option = Option(def, "no_defaults");
m_optgroup_general->append_single_option_line(option);
def.label = L("Show incompatible print and filament presets");
def.type = coBool;
def.tooltip = L("When checked, the print and filament presets are shown in the preset editor "
"even if they are marked as incompatible with the active printer");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" });
option = Option(def, "show_incompatible_presets");
m_optgroup_general->append_single_option_line(option);
def.label = L("Single Instance");
def.type = coBool;
#if __APPLE__
def.tooltip = L("On OSX there is always only one instance of app running by default. However it is allowed to run multiple instances of same app from the command line. In such case this settings will allow only one instance.");
#else
def.tooltip = L("If this is enabled, when staring PrusaSlicer and another instance of same PrusaSlicer is running, that instance will be reactivated instead.");
#endif
def.set_default_value(new ConfigOptionBool{ app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false });
option = Option(def, "single_instance");
m_optgroup_general->append_single_option_line(option);
def.set_default_value(new ConfigOptionBool{ app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false });
option = Option(def, "single_instance");
m_optgroup_general->append_single_option_line(option);
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
#if __APPLE__
def.label = L("Use Retina resolution for the 3D scene");
@ -142,7 +157,7 @@ void PreferencesDialog::build()
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->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -164,60 +179,72 @@ void PreferencesDialog::build()
m_optgroup_camera->activate();
m_optgroup_gui = std::make_shared<ConfigOptionsGroup>(this, _(L("GUI")));
m_optgroup_gui->label_width = 40;
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";
if (opt_key == "use_custom_toolbar_size") {
m_icon_size_sizer->ShowItems(boost::any_cast<bool>(value));
this->layout();
}
};
#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->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
if (opt_key == "use_custom_toolbar_size") {
m_icon_size_sizer->ShowItems(boost::any_cast<bool>(value));
this->layout();
}
};
def.label = L("Show sidebar collapse/expand button");
def.type = coBool;
def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
option = Option(def, "show_collapse_button");
m_optgroup_gui->append_single_option_line(option);
def.label = L("Show sidebar collapse/expand button");
def.type = coBool;
def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
option = Option(def, "show_collapse_button");
m_optgroup_gui->append_single_option_line(option);
def.label = L("Use custom size for toolbar icons");
def.type = coBool;
def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_custom_toolbar_size") == "1" });
option = Option(def, "use_custom_toolbar_size");
m_optgroup_gui->append_single_option_line(option);
def.label = L("Use custom size for toolbar icons");
def.type = coBool;
def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_custom_toolbar_size") == "1" });
option = Option(def, "use_custom_toolbar_size");
m_optgroup_gui->append_single_option_line(option);
m_optgroup_gui->activate();
m_optgroup_gui->activate();
create_icon_size_slider();
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
create_icon_size_slider();
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
create_settings_mode_widget();
create_settings_mode_widget();
#if ENABLE_ENVIRONMENT_MAP
m_optgroup_render = std::make_shared<ConfigOptionsGroup>(this, _(L("Render")));
m_optgroup_render->label_width = 40;
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_optgroup_render = std::make_shared<ConfigOptionsGroup>(this, _L("Render"));
m_optgroup_render->label_width = 40;
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";
};
def.label = L("Use environment map");
def.type = coBool;
def.tooltip = L("If enabled, renders object using the environment map.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_environment_map") == "1" });
option = Option(def, "use_environment_map");
m_optgroup_render->append_single_option_line(option);
def.label = L("Use environment map");
def.type = coBool;
def.tooltip = L("If enabled, renders object using the environment map.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_environment_map") == "1" });
option = Option(def, "use_environment_map");
m_optgroup_render->append_single_option_line(option);
m_optgroup_render->activate();
m_optgroup_render->activate();
#endif // ENABLE_ENVIRONMENT_MAP
#if ENABLE_GCODE_APP_CONFIG
}
#endif // ENABLE_GCODE_APP_CONFIG
auto sizer = new wxBoxSizer(wxVERTICAL);
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_gui->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);
#if ENABLE_ENVIRONMENT_MAP
sizer->Add(m_optgroup_render->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
#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);
#endif // ENABLE_ENVIRONMENT_MAP
SetFont(wxGetApp().normal_font());
@ -234,7 +261,7 @@ void PreferencesDialog::build()
void PreferencesDialog::accept()
{
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();
@ -300,7 +327,7 @@ void PreferencesDialog::create_icon_size_slider()
// we should use system default background
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);
@ -315,7 +342,7 @@ void PreferencesDialog::create_icon_size_slider()
slider->SetTickFreq(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);