stubbed out preset editor changes.

This commit is contained in:
Joseph Lenox 2018-06-14 23:16:30 -05:00
parent ec2582c4e4
commit 8340654183
9 changed files with 108 additions and 9 deletions

View File

@ -76,6 +76,11 @@ void PresetEditor::_on_value_change(std::string opt_key) {
} );
}
// TODO
void PresetEditor::_on_select_preset(bool force) {
}
void PresetEditor::select_preset(int id, bool force) {
this->_presets_choice->SetSelection(id);
this->_on_select_preset(force);
@ -117,4 +122,12 @@ void PresetEditor::reload_config() {
void PresetEditor::reload_preset() {
}
// TODO
void PresetEditor::_update_tree() {
}
// TODO
void PresetEditor::load_presets() {
}
}} // namespace Slic3r::GUI

View File

@ -14,6 +14,11 @@ PrintEditor::PrintEditor(wxWindow* parent, t_config_option_keys options) :
void PrintEditor::_update(const std::string& opt_key) {
}
// TODO
void PrintEditor::_on_preset_loaded() {
}
void PrintEditor::_build() {
}
}} // namespace Slic3r::GUI

View File

@ -23,8 +23,6 @@ namespace Slic3r { namespace GUI {
bool App::OnInit()
{
this->SetAppName("Slic3r");
// TODO: Call a logging function with channel GUI, severity info
this->notifier = std::unique_ptr<Notifier>();
datadir = decode_path(wxStandardPaths::Get().GetUserDataDir());
@ -46,7 +44,6 @@ bool App::OnInit()
}
}
// TODO: Call a logging function with channel GUI, severity info for datadir path
Slic3r::Log::info(LogChannel, (_("Data dir: ") + datadir).ToStdWstring());
ui_settings = Settings::init_settings();

View File

@ -50,7 +50,7 @@ private:
/// Quick reference to this app with its cast applied.
#define SLIC3RAPP dynamic_cast<App*>(wxTheApp)
#define SLIC3RAPP (dynamic_cast<App*>(wxTheApp))
}} // namespace Slic3r::GUI

View File

@ -14,7 +14,7 @@ wxEND_EVENT_TABLE()
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false),
tabpanel(nullptr), controller(nullptr), plater(nullptr), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>())
tabpanel(nullptr), controller(nullptr), plater(nullptr), preset_editor_tabs(std::map<preset_t, PresetEditor*>())
{
this->SetIcon(wxIcon(var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG));
@ -95,7 +95,7 @@ void MainFrame::init_tabpanel()
panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, ([=](wxAuiNotebookEvent& e)
{
if (typeid(panel) == typeid(Slic3r::GUI::PresetEditor)) {
wxDELETE(this->preset_editor_tabs[panel->GetId()]);
wxDELETE(this->preset_editor_tabs[dynamic_cast<PresetEditor*>(panel)->type()]);
}
wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); });
}), panel->GetId());

View File

@ -33,6 +33,9 @@ public:
bool has_plater_menu() { return this->plater_menu != nullptr; }
wxMenu* plater_select_menu {nullptr};
wxAuiNotebook* tabs() { return tabpanel; }
std::map<preset_t, PresetEditor*> preset_editor_tabs;
private:
wxDECLARE_EVENT_TABLE();
@ -49,7 +52,6 @@ private:
wxMenu* plater_menu {nullptr};
std::map<wxWindowID, PresetEditor*> preset_editor_tabs;
void on_plater_object_list_changed(bool force) {};
void on_plater_selection_changed(bool force) {};

View File

@ -1196,6 +1196,80 @@ void Plater::_on_change_combobox(preset_t preset, wxBitmapComboBox* choice) {
*/
}
void Plater::show_preset_editor(preset_t preset, unsigned int idx) {
std::function<void ()> cbfunc {
[this, preset, idx]() {
auto presets { this->selected_presets(preset) };
auto* mainframe {this->GetFrame()};
auto* tabpanel {mainframe->tabs()};
if (mainframe->preset_editor_tabs[preset] != nullptr) {
// editor is already open
tabpanel->SetSelection(tabpanel->GetPageIndex(mainframe->preset_editor_tabs[preset]));
return;
} else if (ui_settings->preset_editor_tabs) {
// open a tab
PresetEditor* tab {nullptr};
switch (preset) {
case preset_t::Print:
tab = new PrintEditor(this);
break;
/*
case preset_t::Material:
tab = new MaterialEditor(this);
break;
case preset_t::Printer:
tab = new PrinterEditor(this);
break;
*/
default: // do nothing
return;
}
tabpanel->AddPage(tab, wxString(tab->name()) + wxString(" Settings"));
} else {
// pop a dialog
switch (preset) {
case preset_t::Print:
break;
case preset_t::Material:
break;
case preset_t::Printer:
break;
default:; // do nothing
return;
}
}
}
};
SLIC3RAPP->CallAfter(cbfunc);
}
Preset* Plater::selected_presets(preset_t preset) {
auto& preset_list {SLIC3RAPP->presets.at(static_cast<int>(preset))};
auto sel = this->preset_choosers.at(static_cast<int>(preset))->GetSelection();
if (sel == -1) sel = 0;
// Retrieve the string associated with this
auto preset_name {this->preset_choosers.at(static_cast<int>(preset))->GetString(sel)};
auto iter = std::find(preset_list.begin(), preset_list.end(), preset_name);
if (iter == preset_list.end()) {
Slic3r::Log::warn(LogChannel, LOG_WSTRING(preset_name + LOG_WSTRING(" not found in Presets list.")));
iter = preset_list.begin(); // get the first one if not found for some reason.
}
return &(*iter);
}
std::vector<Preset*> Plater::selected_presets() {
std::vector<Preset*> tmp(static_cast<int>(preset_t::Last)); // preallocate
for (uint8_t i = 0; i < static_cast<uint8_t>(preset_t::Last); i++) {
tmp[i] = selected_presets(static_cast<preset_t>(i));
}
return tmp;
}
void Plater::load_presets() {
for (auto group : {preset_t::Printer, preset_t::Material, preset_t::Print}) {

View File

@ -98,6 +98,8 @@ public:
/// Create menu for object.
wxMenu* object_menu();
/// Retrieve the identifier for the currently selected preset.
void undo() {};
void redo() {};
@ -109,6 +111,11 @@ public:
void export_amf() {};
void export_tmf() {};
void export_stl() {};
/// Return a reference to the currently selected preset for a group.
Preset* selected_presets(preset_t preset);
/// Return a reference to all currently selected presets.
std::vector<Preset*> selected_presets();
private:
std::shared_ptr<Slic3r::Print> print {std::make_shared<Print>(Slic3r::Print())};
std::shared_ptr<Slic3r::Model> model {std::make_shared<Model>(Slic3r::Model())};
@ -253,7 +260,7 @@ private:
std::vector<wxBitmapComboBox*> preset_choosers {preset_types, nullptr};
void _on_change_combobox(preset_t preset, wxBitmapComboBox* choice);
void show_preset_editor(preset_t preset, unsigned int idx) { };
void show_preset_editor(preset_t preset, unsigned int idx);
void _on_select_preset(preset_t preset) {};
void load_presets();

View File

@ -6,7 +6,8 @@
namespace Slic3r { namespace GUI {
/// Preset types list. We assign numbers to permit static_casts and use as preset tab indices
/// Preset types list. We assign numbers to permit static_casts and use as preset tab indices.
/// Don't skip numbers in the enumeration, we use this as an index into vectors (instead of using std::map).
enum class preset_t : uint8_t {
Print = 0, Material, Printer,
Last // This MUST be the last enumeration. Don't use it for anything.