This commit is contained in:
Vojtech Kral 2018-04-06 13:18:12 +02:00
parent 9dcec6662e
commit 90a8ef8e9f
11 changed files with 23 additions and 73 deletions

View File

@ -644,48 +644,8 @@ sub config_wizard {
# Exit wizard if there are unsaved changes and the user cancels the action. # Exit wizard if there are unsaved changes and the user cancels the action.
return unless $self->check_unsaved_changes; return unless $self->check_unsaved_changes;
# TODO: Offer "reset user profile" ???
# TODO: Offer "reset user profile" if (Slic3r::GUI::open_config_wizard(wxTheApp->{preset_bundle})) {
Slic3r::GUI::open_config_wizard(wxTheApp->{preset_bundle});
# Load the currently selected preset into the GUI, update the preset selection box.
foreach my $tab (values %{$self->{options_tabs}}) { # XXX: only if not cancelled?
$tab->load_current_preset;
}
return;
# Enumerate the profiles bundled with the Slic3r installation under resources/profiles.
my $directory = Slic3r::resources_dir() . "/profiles";
my @profiles = ();
if (opendir(DIR, Slic3r::encode_path($directory))) {
while (my $file = readdir(DIR)) {
if ($file =~ /\.ini$/) {
$file =~ s/\.ini$//;
push @profiles, Slic3r::decode_path($file);
}
}
closedir(DIR);
}
# Open the wizard.
if (my $result = Slic3r::GUI::ConfigWizard->new($self, \@profiles, $fresh_start)->run) {
eval {
if ($result->{reset_user_profile}) {
wxTheApp->{preset_bundle}->reset(1);
}
if (defined $result->{config}) {
# Load and save the settings into print, filament and printer presets.
wxTheApp->{preset_bundle}->load_config('My Settings', $result->{config});
} else {
# Wizard returned a name of a preset bundle bundled with the installation. Unpack it.
wxTheApp->{preset_bundle}->install_vendor_configbundle($directory . '/' . $result->{preset_name} . '.ini');
# Reset the print / filament / printer selections, so that following line will select some sensible defaults.
if ($fresh_start) {
wxTheApp->{app_config}->reset_selections;
}
# Reload all presets after the vendor config bundle has been installed.
wxTheApp->{preset_bundle}->load_presets(wxTheApp->{app_config});
}
};
Slic3r::GUI::catch_error($self) and return;
# Load the currently selected preset into the GUI, update the preset selection box. # Load the currently selected preset into the GUI, update the preset selection box.
foreach my $tab (values %{$self->{options_tabs}}) { foreach my $tab (values %{$self->{options_tabs}}) {
$tab->load_current_preset; $tab->load_current_preset;

View File

@ -1017,8 +1017,3 @@ retract_lift_below = 209
start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif}
printer_model = MK3 printer_model = MK3
default_print_profile = 0.15mm OPTIMAL MK3 default_print_profile = 0.15mm OPTIMAL MK3
[presets]
print = 0.15mm OPTIMAL MK3
printer = Original Prusa i3 MK3
filament = Prusa PLA

View File

@ -412,16 +412,16 @@ void PageDiameters::apply_custom_config(DynamicPrintConfig &config)
PageTemperatures::PageTemperatures(ConfigWizard *parent) : PageTemperatures::PageTemperatures(ConfigWizard *parent) :
ConfigWizardPage(parent, _(L("Extruder and Bed Temperatures")), _(L("Temperatures"))), ConfigWizardPage(parent, _(L("Extruder and Bed Temperatures")), _(L("Temperatures"))),
spin_extr(new wxSpinCtrl(this, wxID_ANY)), spin_extr(new wxSpinCtrlDouble(this, wxID_ANY)),
spin_bed(new wxSpinCtrl(this, wxID_ANY)) spin_bed(new wxSpinCtrlDouble(this, wxID_ANY))
{ {
spin_extr->SetIncrement(5); spin_extr->SetIncrement(5.0);
const auto &def_extr = print_config_def.options["temperature"]; const auto &def_extr = print_config_def.options["temperature"];
spin_extr->SetRange(def_extr.min, def_extr.max); spin_extr->SetRange(def_extr.min, def_extr.max);
auto *default_extr = dynamic_cast<const ConfigOptionInts*>(def_extr.default_value); auto *default_extr = dynamic_cast<const ConfigOptionInts*>(def_extr.default_value);
spin_extr->SetValue(default_extr != nullptr && default_extr->size() > 0 ? default_extr->get_at(0) : 200); spin_extr->SetValue(default_extr != nullptr && default_extr->size() > 0 ? default_extr->get_at(0) : 200);
spin_bed->SetIncrement(5); spin_bed->SetIncrement(5.0);
const auto &def_bed = print_config_def.options["bed_temperature"]; const auto &def_bed = print_config_def.options["bed_temperature"];
spin_bed->SetRange(def_bed.min, def_bed.max); spin_bed->SetRange(def_bed.min, def_bed.max);
auto *default_bed = dynamic_cast<const ConfigOptionInts*>(def_bed.default_value); auto *default_bed = dynamic_cast<const ConfigOptionInts*>(def_bed.default_value);
@ -541,7 +541,7 @@ void ConfigWizard::priv::load_vendors()
const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor"; const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor";
for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) { for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) {
if (it->path().extension() == ".ini") { if (it->path().extension() == ".ini") {
bundle_vendors.load_configbundle(it->path().native(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); bundle_vendors.load_configbundle(it->path().string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY);
} }
} }
@ -688,7 +688,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent) :
ConfigWizard::~ConfigWizard() {} ConfigWizard::~ConfigWizard() {}
void ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle)
{ {
const auto profiles_dir = fs::path(resources_dir()) / "profiles"; const auto profiles_dir = fs::path(resources_dir()) / "profiles";
for (fs::directory_iterator it(profiles_dir); it != fs::directory_iterator(); ++it) { for (fs::directory_iterator it(profiles_dir); it != fs::directory_iterator(); ++it) {
@ -700,6 +700,9 @@ void ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle)
ConfigWizard wizard(parent); ConfigWizard wizard(parent);
if (wizard.ShowModal() == wxID_OK) { if (wizard.ShowModal() == wxID_OK) {
wizard.p->apply_config(GUI::get_app_config(), preset_bundle); wizard.p->apply_config(GUI::get_app_config(), preset_bundle);
return true;
} else {
return false;
} }
} }

View File

@ -15,7 +15,6 @@ namespace GUI {
class ConfigWizard: public wxDialog class ConfigWizard: public wxDialog
{ {
public: public:
// ConfigWizard(wxWindow *parent, const PresetBundle &bundle);
ConfigWizard(wxWindow *parent); ConfigWizard(wxWindow *parent);
ConfigWizard(ConfigWizard &&) = delete; ConfigWizard(ConfigWizard &&) = delete;
ConfigWizard(const ConfigWizard &) = delete; ConfigWizard(const ConfigWizard &) = delete;
@ -23,7 +22,7 @@ public:
ConfigWizard &operator=(const ConfigWizard &) = delete; ConfigWizard &operator=(const ConfigWizard &) = delete;
~ConfigWizard(); ~ConfigWizard();
static void run(wxWindow *parent, PresetBundle *preset_bundle); static bool run(wxWindow *parent, PresetBundle *preset_bundle);
private: private:
struct priv; struct priv;
std::unique_ptr<priv> p; std::unique_ptr<priv> p;

View File

@ -136,8 +136,8 @@ struct PageDiameters: ConfigWizardPage
struct PageTemperatures: ConfigWizardPage struct PageTemperatures: ConfigWizardPage
{ {
wxSpinCtrl *spin_extr; wxSpinCtrlDouble *spin_extr;
wxSpinCtrl *spin_bed; wxSpinCtrlDouble *spin_bed;
PageTemperatures(ConfigWizard *parent); PageTemperatures(ConfigWizard *parent);
virtual void apply_custom_config(DynamicPrintConfig &config); virtual void apply_custom_config(DynamicPrintConfig &config);

View File

@ -353,13 +353,13 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change)
//#endif //#endif
} }
void open_config_wizard(PresetBundle *preset_bundle) bool open_config_wizard(PresetBundle *preset_bundle)
{ {
if (g_wxMainFrame == nullptr) { if (g_wxMainFrame == nullptr) {
throw std::runtime_error("Main frame not set"); throw std::runtime_error("Main frame not set");
} }
ConfigWizard::run(g_wxMainFrame, preset_bundle); return ConfigWizard::run(g_wxMainFrame, preset_bundle);
} }
void open_preferences_dialog(int event_preferences) void open_preferences_dialog(int event_preferences)

View File

@ -73,7 +73,6 @@ void break_to_debugger();
// Passing the wxWidgets GUI classes instantiated by the Perl part to C++. // Passing the wxWidgets GUI classes instantiated by the Perl part to C++.
void set_wxapp(wxApp *app); void set_wxapp(wxApp *app);
void set_main_frame(wxFrame *main_frame); void set_main_frame(wxFrame *main_frame);
// wxFrame* get_main_frame();
void set_tab_panel(wxNotebook *tab_panel); void set_tab_panel(wxNotebook *tab_panel);
void set_app_config(AppConfig *app_config); void set_app_config(AppConfig *app_config);
void set_preset_bundle(PresetBundle *preset_bundle); void set_preset_bundle(PresetBundle *preset_bundle);
@ -85,8 +84,8 @@ wxColour* get_sys_label_clr();
void add_debug_menu(wxMenuBar *menu, int event_language_change); void add_debug_menu(wxMenuBar *menu, int event_language_change);
// Opens the first-time configuration wizard // Opens the first-time configuration wizard, returns true if wizard is finished & accepted.
void open_config_wizard(PresetBundle *preset_bundle); bool open_config_wizard(PresetBundle *preset_bundle);
// Create "Preferences" dialog after selecting menu "Preferences" in Perl part // Create "Preferences" dialog after selecting menu "Preferences" in Perl part
void open_preferences_dialog(int event_preferences); void open_preferences_dialog(int event_preferences);

View File

@ -183,7 +183,6 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
const std::string &variant = config.opt_string("printer_variant"); const std::string &variant = config.opt_string("printer_variant");
if (model.empty() || variant.empty()) { return; } if (model.empty() || variant.empty()) { return; }
is_visible = app_config.get_variant(vendor->id, model, variant); is_visible = app_config.get_variant(vendor->id, model, variant);
std::cerr << vendor->id << " / " << model << " / " << variant << ": visible: " << is_visible << std::endl;
} }
const std::vector<std::string>& Preset::print_options() const std::vector<std::string>& Preset::print_options()

View File

@ -37,14 +37,12 @@ public:
PrinterVariant() {} PrinterVariant() {}
PrinterVariant(const std::string &name) : name(name) {} PrinterVariant(const std::string &name) : name(name) {}
std::string name; std::string name;
// bool enabled = true; // TODO: remove these?
}; };
struct PrinterModel { struct PrinterModel {
PrinterModel() {} PrinterModel() {}
std::string id; std::string id;
std::string name; std::string name;
// bool enabled = true;
std::vector<PrinterVariant> variants; std::vector<PrinterVariant> variants;
PrinterVariant* variant(const std::string &name) { PrinterVariant* variant(const std::string &name) {
for (auto &v : this->variants) for (auto &v : this->variants)
@ -87,7 +85,8 @@ public:
bool is_external = false; bool is_external = false;
// System preset is read-only. // System preset is read-only.
bool is_system = false; bool is_system = false;
// Preset is visible, if it is compatible with the active Printer. TODO: fix // Preset is visible, if it is associated with a printer model / variant that is enabled in the AppConfig
// or if it has no printer model / variant association.
// Also the "default" preset is only visible, if it is the only preset in the list. // Also the "default" preset is only visible, if it is the only preset in the list.
bool is_visible = true; bool is_visible = true;
// Has this preset been modified? // Has this preset been modified?

View File

@ -4,7 +4,6 @@
#include "PresetBundle.hpp" #include "PresetBundle.hpp"
#include "BitmapCache.hpp" #include "BitmapCache.hpp"
#include <iostream> // XXX
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -201,10 +200,7 @@ static inline std::string remove_ini_suffix(const std::string &name)
// If the "vendor" section is missing, enable all models and variants of the particular vendor. // If the "vendor" section is missing, enable all models and variants of the particular vendor.
void PresetBundle::load_installed_printers(const AppConfig &config) void PresetBundle::load_installed_printers(const AppConfig &config)
{ {
std::cerr << "load_installed_printers()" << std::endl;
for (auto &preset : printers) { for (auto &preset : printers) {
std::cerr << "preset: printer: " << preset.name << std::endl;
preset.set_visible_from_appconfig(config); preset.set_visible_from_appconfig(config);
} }
} }
@ -742,7 +738,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
const VendorProfile *vendor_profile = nullptr; const VendorProfile *vendor_profile = nullptr;
if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) { if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) {
boost::filesystem::path fspath(path); boost::filesystem::path fspath(path);
VendorProfile vp(fspath.stem().native()); VendorProfile vp(fspath.stem().string());
load_vendor_profile(tree, vp); load_vendor_profile(tree, vp);
if (vp.name.empty()) if (vp.name.empty())
throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key.")); throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key."));

View File

@ -54,8 +54,8 @@ int combochecklist_get_flags(SV *ui)
void set_app_config(AppConfig *app_config) void set_app_config(AppConfig *app_config)
%code%{ Slic3r::GUI::set_app_config(app_config); %}; %code%{ Slic3r::GUI::set_app_config(app_config); %};
void open_config_wizard(PresetBundle *preset_bundle) bool open_config_wizard(PresetBundle *preset_bundle)
%code%{ Slic3r::GUI::open_config_wizard(preset_bundle); %}; %code%{ RETVAL=Slic3r::GUI::open_config_wizard(preset_bundle); %};
void open_preferences_dialog(int preferences_event) void open_preferences_dialog(int preferences_event)
%code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %};