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

@ -412,16 +412,16 @@ void PageDiameters::apply_custom_config(DynamicPrintConfig &config)
PageTemperatures::PageTemperatures(ConfigWizard *parent) :
ConfigWizardPage(parent, _(L("Extruder and Bed Temperatures")), _(L("Temperatures"))),
spin_extr(new wxSpinCtrl(this, wxID_ANY)),
spin_bed(new wxSpinCtrl(this, wxID_ANY))
spin_extr(new wxSpinCtrlDouble(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"];
spin_extr->SetRange(def_extr.min, def_extr.max);
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_bed->SetIncrement(5);
spin_bed->SetIncrement(5.0);
const auto &def_bed = print_config_def.options["bed_temperature"];
spin_bed->SetRange(def_bed.min, def_bed.max);
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";
for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) {
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() {}
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";
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);
if (wizard.ShowModal() == wxID_OK) {
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
{
public:
// ConfigWizard(wxWindow *parent, const PresetBundle &bundle);
ConfigWizard(wxWindow *parent);
ConfigWizard(ConfigWizard &&) = delete;
ConfigWizard(const ConfigWizard &) = delete;
@ -23,7 +22,7 @@ public:
ConfigWizard &operator=(const ConfigWizard &) = delete;
~ConfigWizard();
static void run(wxWindow *parent, PresetBundle *preset_bundle);
static bool run(wxWindow *parent, PresetBundle *preset_bundle);
private:
struct priv;
std::unique_ptr<priv> p;

View file

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

View file

@ -353,13 +353,13 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change)
//#endif
}
void open_config_wizard(PresetBundle *preset_bundle)
bool open_config_wizard(PresetBundle *preset_bundle)
{
if (g_wxMainFrame == nullptr) {
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)

View file

@ -73,7 +73,6 @@ void break_to_debugger();
// Passing the wxWidgets GUI classes instantiated by the Perl part to C++.
void set_wxapp(wxApp *app);
void set_main_frame(wxFrame *main_frame);
// wxFrame* get_main_frame();
void set_tab_panel(wxNotebook *tab_panel);
void set_app_config(AppConfig *app_config);
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);
// Opens the first-time configuration wizard
void open_config_wizard(PresetBundle *preset_bundle);
// Opens the first-time configuration wizard, returns true if wizard is finished & accepted.
bool open_config_wizard(PresetBundle *preset_bundle);
// Create "Preferences" dialog after selecting menu "Preferences" in Perl part
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");
if (model.empty() || variant.empty()) { return; }
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()

View file

@ -37,14 +37,12 @@ public:
PrinterVariant() {}
PrinterVariant(const std::string &name) : name(name) {}
std::string name;
// bool enabled = true; // TODO: remove these?
};
struct PrinterModel {
PrinterModel() {}
std::string id;
std::string name;
// bool enabled = true;
std::vector<PrinterVariant> variants;
PrinterVariant* variant(const std::string &name) {
for (auto &v : this->variants)
@ -87,7 +85,8 @@ public:
bool is_external = false;
// System preset is read-only.
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.
bool is_visible = true;
// Has this preset been modified?

View file

@ -4,7 +4,6 @@
#include "PresetBundle.hpp"
#include "BitmapCache.hpp"
#include <iostream> // XXX
#include <algorithm>
#include <fstream>
#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.
void PresetBundle::load_installed_printers(const AppConfig &config)
{
std::cerr << "load_installed_printers()" << std::endl;
for (auto &preset : printers) {
std::cerr << "preset: printer: " << preset.name << std::endl;
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;
if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) {
boost::filesystem::path fspath(path);
VendorProfile vp(fspath.stem().native());
VendorProfile vp(fspath.stem().string());
load_vendor_profile(tree, vp);
if (vp.name.empty())
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)
%code%{ Slic3r::GUI::set_app_config(app_config); %};
void open_config_wizard(PresetBundle *preset_bundle)
%code%{ Slic3r::GUI::open_config_wizard(preset_bundle); %};
bool open_config_wizard(PresetBundle *preset_bundle)
%code%{ RETVAL=Slic3r::GUI::open_config_wizard(preset_bundle); %};
void open_preferences_dialog(int preferences_event)
%code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %};