Filling the Print's Tab. Continued. All Controls are on they own places. It's need to adding only SideWidget
This commit is contained in:
parent
67b9b1b273
commit
281fd26e06
@ -1,6 +1,11 @@
|
||||
#include "GUI.hpp"//"slic3r_gui.hpp"
|
||||
#include "Field.hpp"
|
||||
|
||||
//#include <wx/event.h>
|
||||
#include <regex>
|
||||
#include <wx/numformatter.h>
|
||||
#include "PrintConfig.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
void Field::_on_kill_focus(wxFocusEvent& event) {
|
||||
@ -18,12 +23,62 @@ namespace Slic3r { namespace GUI {
|
||||
//! if (on_change != nullptr && !disable_change_event)
|
||||
//! on_change(opt_id, "A");
|
||||
}
|
||||
void TextCtrl::BUILD() {
|
||||
|
||||
|
||||
bool Field::is_matched(std::string string, std::string pattern)
|
||||
{
|
||||
std::regex regex_pattern(pattern, std::regex_constants::icase); // use ::icase to make the matching case insensitive like /i in perl
|
||||
return std::regex_match(string, regex_pattern);
|
||||
}
|
||||
|
||||
void TextCtrl::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (opt.height >= 0) size.SetHeight(opt.height);
|
||||
if (opt.width >= 0) size.SetWidth(opt.width);
|
||||
|
||||
auto temp = new wxTextCtrl(parent, wxID_ANY, wxString(""), wxDefaultPosition, size, (opt.multiline ? wxTE_MULTILINE : 0)); //! new wxTextCtrl(parent, wxID_ANY, wxString(opt.default_value->getString()), wxDefaultPosition, size, (opt.multiline ? wxTE_MULTILINE : 0));
|
||||
wxString text_value = wxString("");
|
||||
|
||||
switch (opt.type) {
|
||||
case coFloatOrPercent:
|
||||
{
|
||||
if (static_cast<const ConfigOptionFloatOrPercent*>(opt.default_value)->percent)
|
||||
{
|
||||
text_value = wxString::Format(_T("%i"), int(opt.default_value->getFloat()));
|
||||
text_value += "%";
|
||||
}
|
||||
else
|
||||
wxNumberFormatter::ToString(opt.default_value->getFloat(), 2);
|
||||
break;
|
||||
}
|
||||
case coPercent:
|
||||
{
|
||||
text_value = wxString::Format(_T("%i"), int(opt.default_value->getFloat()));
|
||||
text_value += "%";
|
||||
break;
|
||||
}
|
||||
case coFloat:
|
||||
{
|
||||
double val = opt.default_value->getFloat();
|
||||
text_value = (val - int(val)) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2);
|
||||
break;
|
||||
}
|
||||
case coString:
|
||||
text_value += static_cast<const ConfigOptionString*>(opt.default_value)->value;
|
||||
break;
|
||||
case coStrings:
|
||||
{
|
||||
const ConfigOptionVectorBase *vec = static_cast<const ConfigOptionVectorBase*>(opt.default_value);
|
||||
if (vec == nullptr) break;
|
||||
if (vec->empty()) break;
|
||||
for (size_t id = 0; id < vec->size(); ++id)
|
||||
text_value += static_cast<const ConfigOptionString*>(opt.default_value)->value[id];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
auto temp = new wxTextCtrl(parent, wxID_ANY, text_value, wxDefaultPosition, size, (opt.multiline ? wxTE_MULTILINE : 0));
|
||||
|
||||
if (opt.tooltip.length() > 0) { temp->SetToolTip(opt.tooltip); }
|
||||
|
||||
@ -35,8 +90,153 @@ namespace Slic3r { namespace GUI {
|
||||
|
||||
}
|
||||
|
||||
void TextCtrl::enable() { (dynamic_cast<wxTextCtrl*>(window))->Enable(); (dynamic_cast<wxTextCtrl*>(window))->SetEditable(1); }
|
||||
void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(0); }
|
||||
void TextCtrl::enable() { dynamic_cast<wxTextCtrl*>(window)->Enable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(true); }
|
||||
void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(false); }
|
||||
void TextCtrl::set_tooltip(const wxString& tip) { }
|
||||
}}
|
||||
|
||||
void CheckBox::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (opt.height >= 0) size.SetHeight(opt.height);
|
||||
if (opt.width >= 0) size.SetWidth(opt.width);
|
||||
|
||||
auto temp = new wxCheckBox(parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||
temp->SetValue(opt.default_value->getBool());
|
||||
if (opt.readonly) temp->Disable();
|
||||
|
||||
temp->Bind(wxEVT_CHECKBOX, ([this](wxCommandEvent e) { _on_change(e); }), temp->GetId());
|
||||
|
||||
if (opt.tooltip.length() > 0) { temp->SetToolTip(opt.tooltip); }
|
||||
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
int undef_spin_val = -9999; //! Probably, It's not necessary
|
||||
|
||||
void SpinCtrl::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (opt.height >= 0) size.SetHeight(opt.height);
|
||||
if (opt.width >= 0) size.SetWidth(opt.width);
|
||||
|
||||
auto temp = new wxSpinCtrl(parent, wxID_ANY, wxString::Format(_T("%i"), opt.default_value->getInt()), wxDefaultPosition, size,
|
||||
0, opt.min >0 ? opt.min : 0, opt.max < 2147483647 ? opt.max : 2147483647, opt.default_value->getInt());
|
||||
|
||||
temp->Bind(wxEVT_SPINCTRL, ([=](wxCommandEvent e) { tmp_value = undef_spin_val; _on_change(e); }), temp->GetId());
|
||||
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxFocusEvent e) { tmp_value = undef_spin_val; _on_kill_focus(e); }), temp->GetId());
|
||||
temp->Bind(wxEVT_TEXT, ([=](wxCommandEvent e)
|
||||
{
|
||||
// # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
|
||||
// # when it was changed from the text control, so the on_change callback
|
||||
// # gets the old one, and on_kill_focus resets the control to the old value.
|
||||
// # As a workaround, we get the new value from $event->GetString and store
|
||||
// # here temporarily so that we can return it from $self->get_value
|
||||
std::string value = e.GetString();
|
||||
if (is_matched(value, "^\d+$"))
|
||||
tmp_value = std::stoi(value);
|
||||
_on_change(e);
|
||||
// # We don't reset tmp_value here because _on_change might put callbacks
|
||||
// # in the CallAfter queue, and we want the tmp value to be available from
|
||||
// # them as well.
|
||||
}), temp->GetId());
|
||||
|
||||
|
||||
if (opt.tooltip.length() > 0) { temp->SetToolTip(opt.tooltip); }
|
||||
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
void Choice::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (opt.height >= 0) size.SetHeight(opt.height);
|
||||
if (opt.width >= 0) size.SetWidth(opt.width);
|
||||
|
||||
auto temp = new wxComboBox(parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||
if (opt.gui_type.compare("") != 0 && opt.gui_type.compare("select_open") == 0)
|
||||
temp->SetWindowStyle(wxCB_READONLY);
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
|
||||
if (!opt.enum_labels.empty() && !opt.enum_values.empty())
|
||||
{
|
||||
for (auto el : opt.enum_labels)
|
||||
temp->Append(wxString(el));
|
||||
// temp->SetSelection(static_cast<const ConfigOptionEnum<SeamPosition>*>(opt.default_value)->value);
|
||||
//set_value(opt.default_value);
|
||||
set_selection();
|
||||
}
|
||||
temp->Bind(wxEVT_TEXT, ([=](wxCommandEvent e) { _on_change(e); }), temp->GetId());
|
||||
temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { _on_change(e); }), temp->GetId());
|
||||
|
||||
if (opt.tooltip.length() > 0) temp->SetToolTip(opt.tooltip);
|
||||
}
|
||||
|
||||
void Choice::set_selection()
|
||||
{
|
||||
wxString text_value = wxString("");
|
||||
switch (opt.type){
|
||||
case coFloat:
|
||||
case coPercent: {
|
||||
double val = opt.default_value->getFloat();
|
||||
text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 1);
|
||||
auto idx = 0;
|
||||
for (auto el : opt.enum_values)
|
||||
{
|
||||
if (el.compare(text_value) == 0)
|
||||
break;
|
||||
++idx;
|
||||
}
|
||||
if (opt.type == coPercent) text_value += "%";
|
||||
idx == opt.enum_values.size() ?
|
||||
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
|
||||
dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
|
||||
break;
|
||||
}
|
||||
case coEnum:{
|
||||
int id_value = static_cast<const ConfigOptionEnum<SeamPosition>*>(opt.default_value)->value; //!!
|
||||
dynamic_cast<wxComboBox*>(window)->SetSelection(id_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Choice::set_value(const std::string value) //! Redundant?
|
||||
{
|
||||
disable_change_event = true;
|
||||
|
||||
auto idx=0;
|
||||
for (auto el : opt.enum_values)
|
||||
{
|
||||
if (el.compare(value) == 0)
|
||||
break;
|
||||
++idx;
|
||||
}
|
||||
|
||||
idx == opt.enum_values.size() ?
|
||||
dynamic_cast<wxComboBox*>(window)->SetValue(value) :
|
||||
dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
|
||||
|
||||
disable_change_event = false;
|
||||
}
|
||||
|
||||
//! it's needed for _update_serial_ports()
|
||||
void Choice::set_values(const std::vector<std::string> values)
|
||||
{
|
||||
disable_change_event = true;
|
||||
|
||||
// # it looks that Clear() also clears the text field in recent wxWidgets versions,
|
||||
// # but we want to preserve it
|
||||
auto ww = dynamic_cast<wxComboBox*>(window);
|
||||
auto value = ww->GetValue();
|
||||
ww->Clear();
|
||||
for (auto el : values)
|
||||
ww->Append(wxString(el));
|
||||
ww->SetValue(value);
|
||||
|
||||
disable_change_event = false;
|
||||
}
|
||||
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <functional>
|
||||
#include <boost/any.hpp>
|
||||
|
||||
#include <wx/spinctrl.h>
|
||||
|
||||
#include "../../libslic3r/libslic3r.h"
|
||||
#include "../../libslic3r/Config.hpp"
|
||||
|
||||
@ -32,7 +34,7 @@ class Field;
|
||||
using t_field = std::unique_ptr<Field>;
|
||||
|
||||
class Field {
|
||||
protected:
|
||||
protected:
|
||||
// factory function to defer and enforce creation of derived type.
|
||||
virtual void PostInitialize() { BUILD(); }
|
||||
|
||||
@ -44,8 +46,7 @@ class Field {
|
||||
/// Call the attached on_change method.
|
||||
void _on_change(wxCommandEvent& event);
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
/// parent wx item, opportunity to refactor (probably not necessary - data duplication)
|
||||
wxWindow* parent {nullptr};
|
||||
|
||||
@ -78,7 +79,6 @@ class Field {
|
||||
|
||||
virtual void set_tooltip(const wxString& tip) = 0;
|
||||
|
||||
|
||||
Field(const ConfigOptionDef& opt, const t_config_option_key& id) : opt(opt), opt_id(id) {};
|
||||
Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : parent(parent), opt(opt), opt_id(id) {};
|
||||
|
||||
@ -86,6 +86,7 @@ class Field {
|
||||
virtual wxSizer* getSizer() { return nullptr; }
|
||||
virtual wxWindow* getWindow() { return nullptr; }
|
||||
|
||||
bool is_matched(std::string string, std::string pattern);
|
||||
|
||||
/// Factory method for generating new derived classes.
|
||||
template<class T>
|
||||
@ -93,9 +94,8 @@ class Field {
|
||||
{
|
||||
auto p = std::make_unique<T>(parent, opt, id);
|
||||
p->PostInitialize();
|
||||
return p;
|
||||
return std::move(p); //!p;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// Convenience function, accepts a const reference to t_field and checks to see whether
|
||||
@ -111,10 +111,12 @@ inline bool is_sizer_field(const t_field& obj) { return !is_bad_field(obj) && ob
|
||||
class TextCtrl : public Field {
|
||||
using Field::Field;
|
||||
public:
|
||||
TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||
TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||
|
||||
void BUILD();
|
||||
wxWindow* window {nullptr};
|
||||
|
||||
|
||||
virtual void set_value(std::string value) {
|
||||
dynamic_cast<wxTextCtrl*>(window)->SetValue(wxString(value));
|
||||
}
|
||||
@ -122,7 +124,7 @@ public:
|
||||
dynamic_cast<wxTextCtrl*>(window)->SetValue(boost::any_cast<wxString>(value));
|
||||
}
|
||||
|
||||
boost::any get_value() { return boost::any(dynamic_cast<wxTextCtrl*>(window)->GetValue()); }
|
||||
boost::any get_value() override { return boost::any(dynamic_cast<wxTextCtrl*>(window)->GetValue()); }
|
||||
|
||||
virtual void enable();
|
||||
virtual void disable();
|
||||
@ -131,7 +133,87 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class CheckBox : public Field {
|
||||
using Field::Field;
|
||||
public:
|
||||
CheckBox(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||
CheckBox(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||
|
||||
wxWindow* window{ nullptr };
|
||||
void BUILD() override;
|
||||
|
||||
void set_value (const bool value) {
|
||||
dynamic_cast<wxCheckBox*>(window)->SetValue(value);
|
||||
}
|
||||
void set_value(boost::any value) {
|
||||
dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value));
|
||||
}
|
||||
boost::any get_value() override {
|
||||
return boost::any(dynamic_cast<wxCheckBox*>(window)->GetValue());
|
||||
}
|
||||
|
||||
void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
|
||||
void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }
|
||||
void set_tooltip(const wxString& tip) override {};
|
||||
wxWindow* getWindow() override { return window; }
|
||||
};
|
||||
|
||||
class SpinCtrl : public Field {
|
||||
using Field::Field;
|
||||
public:
|
||||
SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(-9999) {}
|
||||
SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(-9999) {}
|
||||
|
||||
int tmp_value;
|
||||
|
||||
wxWindow* window{ nullptr };
|
||||
void BUILD() override;
|
||||
|
||||
void set_value(const std::string value) {
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(value);
|
||||
}
|
||||
void set_value(boost::any value) {
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(boost::any_cast<std::string>(value));
|
||||
}
|
||||
boost::any get_value() override {
|
||||
return boost::any(dynamic_cast<wxSpinCtrl*>(window)->GetValue());
|
||||
}
|
||||
|
||||
void enable() override { dynamic_cast<wxSpinCtrl*>(window)->Enable(); }
|
||||
void disable() override { dynamic_cast<wxSpinCtrl*>(window)->Disable(); }
|
||||
wxWindow* getWindow() override { return window; }
|
||||
void set_tooltip(const wxString& tip) override{};
|
||||
};
|
||||
|
||||
class Choice : public Field {
|
||||
using Field::Field;
|
||||
public:
|
||||
Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||
Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||
|
||||
wxWindow* window{ nullptr };
|
||||
void BUILD() override;
|
||||
|
||||
void set_selection();
|
||||
void set_value(const std::string value);// {
|
||||
// dynamic_cast<wxComboBox*>(window)->SetValue(value);
|
||||
// }
|
||||
void set_value(boost::any value) {
|
||||
dynamic_cast<wxComboBox*>(window)->SetValue(boost::any_cast<std::string>(value));
|
||||
}
|
||||
void set_values(const std::vector<std::string> values);
|
||||
boost::any get_value() override {
|
||||
return boost::any(dynamic_cast<wxComboBox*>(window)->GetValue());
|
||||
}
|
||||
|
||||
void enable() override { dynamic_cast<wxComboBox*>(window)->Enable(); };
|
||||
void disable() override{ dynamic_cast<wxComboBox*>(window)->Disable(); };
|
||||
wxWindow* getWindow() override { return window; }
|
||||
void set_tooltip(const wxString& tip) override {}; //! Redundant
|
||||
};
|
||||
|
||||
#endif
|
||||
}}
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
||||
|
||||
|
@ -23,20 +23,32 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co
|
||||
} else if (opt.gui_type.compare("f_enum_open") == 0 ||
|
||||
opt.gui_type.compare("i_enum_open") == 0 ||
|
||||
opt.gui_type.compare("i_enum_closed") == 0) {
|
||||
fields.emplace(id, STDMOVE(Choice::Create<Choice>(_parent, opt, id)));
|
||||
} else if (opt.gui_type.compare("slider") == 0) {
|
||||
} else if (opt.gui_type.compare("i_spin") == 0) { // Spinctrl
|
||||
} else {
|
||||
switch (opt.type) {
|
||||
case coFloatOrPercent:
|
||||
case coPercent:
|
||||
case coFloat:
|
||||
case coString:
|
||||
//! fields.emplace(id, STDMOVE(TextCtrl::Create<TextCtrl>(_parent, opt, id)));
|
||||
// fields.emplace(id, std::make_unique<TextCtrl>(_parent, opt, id));
|
||||
case coPercent:
|
||||
case coString:
|
||||
case coStrings:
|
||||
fields.emplace(id, STDMOVE(TextCtrl::Create<TextCtrl>(_parent, opt, id)));
|
||||
break;
|
||||
case coBool:
|
||||
case coBools:
|
||||
fields.emplace(id, STDMOVE(CheckBox::Create<CheckBox>(_parent, opt, id)));
|
||||
break;
|
||||
case coInt:
|
||||
case coInts:
|
||||
fields.emplace(id, STDMOVE(SpinCtrl::Create<SpinCtrl>(_parent, opt, id)));
|
||||
break;
|
||||
case coEnum:
|
||||
fields.emplace(id, STDMOVE(Choice::Create<Choice>(_parent, opt, id)));
|
||||
break;
|
||||
case coNone: break;
|
||||
default:
|
||||
break;//! throw ConfigGUITypeError(""); break;
|
||||
throw /*//!ConfigGUITypeError("")*/std::logic_error("This control doesn't exist till now"); break;
|
||||
}
|
||||
}
|
||||
// Grab a reference to fields for convenience
|
||||
@ -84,14 +96,14 @@ void OptionsGroup::append_line(const Line& line) {
|
||||
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
|
||||
option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
|
||||
const auto& option = option_set.front();
|
||||
// const auto& field = build_field(option);
|
||||
// std::cerr << "single option, no sidetext.\n";
|
||||
// std::cerr << "field parent is not null?: " << (field->parent != nullptr) << "\n";
|
||||
//
|
||||
// if (is_window_field(field))
|
||||
// grid_sizer->Add(field->getWindow(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
||||
// if (is_sizer_field(field))
|
||||
// grid_sizer->Add(field->getSizer(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
||||
const auto& field = build_field(option);
|
||||
//! std::cerr << "single option, no sidetext.\n";
|
||||
//! std::cerr << "field parent is not null?: " << (field->parent != nullptr) << "\n";
|
||||
|
||||
if (is_window_field(field))
|
||||
grid_sizer->Add(field->getWindow(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
||||
if (is_sizer_field(field))
|
||||
grid_sizer->Add(field->getSizer(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -109,9 +121,9 @@ void OptionsGroup::append_line(const Line& line) {
|
||||
}
|
||||
|
||||
// add field
|
||||
// const Option& opt_ref = opt;
|
||||
// auto field = build_field(opt_ref).get(); ;
|
||||
// sizer->Add(field, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
const Option& opt_ref = opt;
|
||||
auto field = build_field(opt_ref)->getWindow(); ;
|
||||
sizer->Add(field, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
|
||||
// add sidetext if any
|
||||
if (option.sidetext != "") {
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
/// reference to libslic3r config, non-owning pointer (?).
|
||||
const DynamicPrintConfig* config {nullptr};
|
||||
bool full_labels {0};
|
||||
ConfigOptionsGroup(wxWindow* parent, std::string title, DynamicPrintConfig* _config) : OptionsGroup(parent, title, *(_config->def())), config(_config) {}; //!OptionsGroup(parent, title, *(_config->def)), config(_config) {};
|
||||
ConfigOptionsGroup(wxWindow* parent, std::string title, DynamicPrintConfig* _config) : OptionsGroup(parent, title, *(_config->def())), config(_config) {}
|
||||
};
|
||||
|
||||
}}
|
||||
|
@ -86,60 +86,6 @@ void CTab::create_preset_tab()
|
||||
treectrl_->SetIndent(0);
|
||||
disable_tree_sel_changed_event_ = 0;
|
||||
|
||||
//!-----------------------EXP
|
||||
// Vertical sizer to hold selected page
|
||||
// auto *scrolled_win = new wxScrolledWindow(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
// wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL);
|
||||
// scrolled_win->SetSizer(vs);
|
||||
// scrolled_win->SetScrollbars(1, 1, 1, 1);
|
||||
// hsizer_->Add(scrolled_win, 1, wxEXPAND | wxLEFT, 5);
|
||||
//
|
||||
// wxSizer* sbs = new wxStaticBoxSizer(new wxStaticBox(scrolled_win, wxID_ANY, "Trulala"), wxVERTICAL);
|
||||
// vs->Add(sbs, 0, wxEXPAND | wxALL, 10);
|
||||
// sbs = new wxBoxSizer(wxVERTICAL);
|
||||
// vs->Add(sbs, 0, wxEXPAND | wxALL, 10);
|
||||
// sbs = new wxStaticBoxSizer(new wxStaticBox(scrolled_win, wxID_ANY, "LuTrulala"), wxVERTICAL);
|
||||
// vs->Add(sbs, 0, wxEXPAND | wxALL, 10);
|
||||
|
||||
|
||||
// auto *page_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
// hsizer_->Add(page_sizer, 1, wxEXPAND | wxLEFT, 5);
|
||||
|
||||
// wxStaticBox* box = new wxStaticBox(panel, wxID_ANY, "Filament");
|
||||
// page_sizer->Add(new wxStaticBoxSizer(box, wxHORIZONTAL), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||
//
|
||||
// //Horizontal sizer to hold the tree and the selected page.
|
||||
// wxStaticBoxSizer* tmp_hsizer = new wxStaticBoxSizer(wxHORIZONTAL, panel, "Experimental Box");
|
||||
// page_sizer->Add(tmp_hsizer, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||
//
|
||||
// auto *grid_sizer = new wxFlexGridSizer(0, 4, 0, 0);
|
||||
// grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
||||
// tmp_hsizer->Add(grid_sizer, 0, wxEXPAND | wxALL, /*&Wx::wxMAC ? 0 :*/ 5);
|
||||
//
|
||||
// wxStaticText *label = new wxStaticText(panel, wxID_ANY, "Label1", wxDefaultPosition, wxSize(200,-1));
|
||||
// auto *textctrl = new wxTextCtrl(panel, wxID_ANY, "TruLaLa1");
|
||||
// grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
// grid_sizer->Add(textctrl, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
//
|
||||
// label = new wxStaticText(panel, wxID_ANY, "Labelszdfdghhjk2");
|
||||
// textctrl = new wxTextCtrl(panel, wxID_ANY, "TruLaLa2");
|
||||
// grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
// grid_sizer->Add(textctrl, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
//
|
||||
// label = new wxStaticText(panel, wxID_ANY, "Label3");
|
||||
// textctrl = new wxTextCtrl(panel, wxID_ANY, "TruLaLa3");
|
||||
// grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
// grid_sizer->Add(textctrl, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
//
|
||||
// label = new wxStaticText(panel, wxID_ANY, "Label4");
|
||||
// textctrl = new wxTextCtrl(panel, wxID_ANY, "TruLaLa4");
|
||||
// grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
// grid_sizer->Add(textctrl, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
//
|
||||
// box = new wxStaticBox(panel, wxID_ANY, "Print");
|
||||
// page_sizer->Add(new wxStaticBoxSizer(box, wxHORIZONTAL), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||
//!------------------------
|
||||
|
||||
treectrl_->Bind(wxEVT_TREE_SEL_CHANGED, &CTab::OnTreeSelChange, this);
|
||||
treectrl_->Bind(wxEVT_KEY_DOWN, &CTab::OnKeyDown, this);
|
||||
treectrl_->Bind(wxEVT_COMBOBOX, &CTab::OnComboBox, this);
|
||||
@ -153,9 +99,6 @@ void CTab::create_preset_tab()
|
||||
build();
|
||||
rebuild_page_tree();
|
||||
// _update();
|
||||
|
||||
|
||||
return;//$self;
|
||||
}
|
||||
|
||||
CPageShp CTab::add_options_page(wxString title, wxString icon)
|
||||
@ -188,14 +131,11 @@ CPageShp CTab::add_options_page(wxString title, wxString icon)
|
||||
void CTabPrint::build()
|
||||
{
|
||||
// $self->{presets} = wxTheApp->{preset_bundle}->print;
|
||||
// $self->{config} = $self->{presets}->get_edited_preset->config;
|
||||
|
||||
PresetCollection *prints = new PresetCollection(Preset::TYPE_PRINT, Preset::print_options());
|
||||
config_ = prints->get_edited_preset().config;
|
||||
config_def = config_.def();
|
||||
config_def = config_.def(); // initialization. It will be used in get_option_(const std::string title)
|
||||
|
||||
auto page = add_options_page("Layers and perimeters", "layers.png");
|
||||
|
||||
auto optgroup = page->new_optgroup("Layer height");
|
||||
optgroup->append_single_option_line(get_option_("layer_height"));
|
||||
optgroup->append_single_option_line(get_option_("first_layer_height"));
|
||||
@ -211,37 +151,35 @@ void CTabPrint::build()
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup = page->new_optgroup("Quality (slower slicing)");
|
||||
optgroup->append_single_option_line(get_option_("extra_perimeters"));
|
||||
optgroup->append_single_option_line(get_option_("ensure_vertical_shell_thickness"));
|
||||
optgroup->append_single_option_line(get_option_("avoid_crossing_perimeters"));
|
||||
optgroup->append_single_option_line(get_option_("thin_walls"));
|
||||
optgroup->append_single_option_line(get_option_("extra_perimeters"));
|
||||
optgroup->append_single_option_line(get_option_("ensure_vertical_shell_thickness"));
|
||||
optgroup->append_single_option_line(get_option_("avoid_crossing_perimeters"));
|
||||
optgroup->append_single_option_line(get_option_("thin_walls"));
|
||||
optgroup->append_single_option_line(get_option_("overhangs"));
|
||||
|
||||
optgroup = page->new_optgroup("Advanced");
|
||||
optgroup->append_single_option_line(get_option_("seam_position"));
|
||||
optgroup->append_single_option_line(get_option_("external_perimeters_first"));
|
||||
optgroup->append_single_option_line(get_option_("seam_position"));
|
||||
optgroup->append_single_option_line(get_option_("external_perimeters_first"));
|
||||
|
||||
page = add_options_page("Infill", "infill.png");
|
||||
|
||||
optgroup = page->new_optgroup("Infill");
|
||||
optgroup->append_single_option_line(get_option_("fill_density"));
|
||||
optgroup->append_single_option_line(get_option_("fill_density"));
|
||||
optgroup->append_single_option_line(get_option_("fill_pattern"));
|
||||
optgroup->append_single_option_line(get_option_("external_fill_pattern"));
|
||||
|
||||
optgroup = page->new_optgroup("Reducing printing time");
|
||||
optgroup->append_single_option_line(get_option_("infill_every_layers"));
|
||||
optgroup->append_single_option_line(get_option_("infill_only_where_needed"));
|
||||
optgroup->append_single_option_line(get_option_("infill_every_layers"));
|
||||
optgroup->append_single_option_line(get_option_("infill_only_where_needed"));
|
||||
|
||||
optgroup = page->new_optgroup("Advanced");
|
||||
optgroup->append_single_option_line(get_option_("solid_infill_every_layers"));
|
||||
optgroup->append_single_option_line(get_option_("fill_angle"));
|
||||
optgroup->append_single_option_line(get_option_("solid_infill_below_area"));
|
||||
optgroup->append_single_option_line(get_option_("bridge_angle"));
|
||||
optgroup->append_single_option_line(get_option_("only_retract_when_crossing_perimeters"));
|
||||
optgroup->append_single_option_line(get_option_("infill_first"));
|
||||
|
||||
page = add_options_page("Skirt and brim", "box.png");
|
||||
optgroup->append_single_option_line(get_option_("only_retract_when_crossing_perimeters"));
|
||||
optgroup->append_single_option_line(get_option_("infill_first"));
|
||||
|
||||
page = add_options_page("Skirt and brim", "box.png");
|
||||
optgroup = page->new_optgroup("Skirt");
|
||||
optgroup->append_single_option_line(get_option_("skirts"));
|
||||
optgroup->append_single_option_line(get_option_("skirt_distance"));
|
||||
@ -252,10 +190,8 @@ void CTabPrint::build()
|
||||
optgroup->append_single_option_line(get_option_("brim_width"));
|
||||
|
||||
page = add_options_page("Support material", "building.png");
|
||||
page->set_config(&config_);
|
||||
|
||||
optgroup = page->new_optgroup("Support material");
|
||||
optgroup->append_single_option_line(get_option_("support_material"));
|
||||
optgroup->append_single_option_line(get_option_("support_material"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_threshold"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_enforce_layers"));
|
||||
|
||||
@ -264,21 +200,20 @@ void CTabPrint::build()
|
||||
// # optgroup->append_single_option_line(get_option_("raft_contact_distance"));
|
||||
|
||||
optgroup = page->new_optgroup("Options for support material and raft");
|
||||
optgroup->append_single_option_line(get_option_("support_material_contact_distance"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_contact_distance"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_pattern"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_with_sheath"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_with_sheath"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_spacing"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_angle"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_interface_layers"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_interface_spacing"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_interface_contact_loops"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_buildplate_only"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_buildplate_only"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_xy_spacing"));
|
||||
optgroup->append_single_option_line(get_option_("dont_support_bridges"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_synchronize_layers"));
|
||||
optgroup->append_single_option_line(get_option_("dont_support_bridges"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_synchronize_layers"));
|
||||
|
||||
page = add_options_page("Speed", "time.png");
|
||||
|
||||
optgroup = page->new_optgroup("Speed for print moves");
|
||||
optgroup->append_single_option_line(get_option_("perimeter_speed"));
|
||||
optgroup->append_single_option_line(get_option_("small_perimeter_speed"));
|
||||
@ -311,31 +246,29 @@ void CTabPrint::build()
|
||||
optgroup->append_single_option_line(get_option_("max_volumetric_extrusion_rate_slope_negative"));
|
||||
|
||||
page = add_options_page("Multiple Extruders", "funnel.png");
|
||||
|
||||
optgroup = page->new_optgroup("Extruders");
|
||||
optgroup->append_single_option_line(get_option_("perimeter_extruder"));
|
||||
optgroup->append_single_option_line(get_option_("infill_extruder"));
|
||||
optgroup->append_single_option_line(get_option_("perimeter_extruder"));
|
||||
optgroup->append_single_option_line(get_option_("infill_extruder"));
|
||||
optgroup->append_single_option_line(get_option_("solid_infill_extruder"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_extruder"));
|
||||
optgroup->append_single_option_line(get_option_("support_material_interface_extruder"));
|
||||
|
||||
optgroup = page->new_optgroup("Ooze prevention");
|
||||
optgroup->append_single_option_line(get_option_("ooze_prevention"));
|
||||
optgroup->append_single_option_line(get_option_("ooze_prevention"));
|
||||
optgroup->append_single_option_line(get_option_("standby_temperature_delta"));
|
||||
|
||||
optgroup = page->new_optgroup("Wipe tower");
|
||||
optgroup->append_single_option_line(get_option_("wipe_tower"));
|
||||
optgroup->append_single_option_line(get_option_("wipe_tower"));
|
||||
optgroup->append_single_option_line(get_option_("wipe_tower_x"));
|
||||
optgroup->append_single_option_line(get_option_("wipe_tower_y"));
|
||||
optgroup->append_single_option_line(get_option_("wipe_tower_width"));
|
||||
optgroup->append_single_option_line(get_option_("wipe_tower_per_color_wipe"));
|
||||
|
||||
optgroup = page->new_optgroup("Advanced");
|
||||
optgroup->append_single_option_line(get_option_("interface_shells"));
|
||||
optgroup->append_single_option_line(get_option_("interface_shells"));
|
||||
|
||||
page = add_options_page("Advanced", "wrench.png");
|
||||
|
||||
optgroup = page->new_optgroup("Extrusion width", 180);
|
||||
optgroup = page->new_optgroup("Extrusion width", 200);
|
||||
optgroup->append_single_option_line(get_option_("extrusion_width"));
|
||||
optgroup->append_single_option_line(get_option_("first_layer_extrusion_width"));
|
||||
optgroup->append_single_option_line(get_option_("perimeter_extrusion_width"));
|
||||
@ -349,10 +282,10 @@ void CTabPrint::build()
|
||||
optgroup->append_single_option_line(get_option_("infill_overlap"));
|
||||
|
||||
optgroup = page->new_optgroup("Flow");
|
||||
optgroup->append_single_option_line(get_option_("bridge_flow_ratio"));
|
||||
optgroup->append_single_option_line(get_option_("bridge_flow_ratio"));
|
||||
|
||||
optgroup = page->new_optgroup("Other");
|
||||
optgroup->append_single_option_line(get_option_("clip_multipart_objects"));
|
||||
optgroup->append_single_option_line(get_option_("clip_multipart_objects"));
|
||||
optgroup->append_single_option_line(get_option_("elefant_foot_compensation"));
|
||||
optgroup->append_single_option_line(get_option_("xy_size_compensation"));
|
||||
// # optgroup->append_single_option_line(get_option_("threads"));
|
||||
@ -360,7 +293,7 @@ void CTabPrint::build()
|
||||
|
||||
page = add_options_page("Output options", "page_white_go.png");
|
||||
optgroup = page->new_optgroup("Sequential printing");
|
||||
optgroup->append_single_option_line(get_option_("complete_objects"));
|
||||
optgroup->append_single_option_line(get_option_("complete_objects"));
|
||||
line = Line{ "Extruder clearance (mm)", "" };
|
||||
Option option = get_option_("extruder_clearance_radius");
|
||||
option.opt.width = 60;
|
||||
@ -371,21 +304,21 @@ void CTabPrint::build()
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup = page->new_optgroup("Output file");
|
||||
optgroup->append_single_option_line(get_option_("gcode_comments"));
|
||||
optgroup->append_single_option_line(get_option_("gcode_comments"));
|
||||
option = get_option_("output_filename_format");
|
||||
option.opt.full_width = 1;
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup("Post-processing scripts"); //! label_width = > 0,
|
||||
option = get_option_("post_process");
|
||||
option.opt.full_width = 1;
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 50;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
page = add_options_page("Notes", "note.png");
|
||||
optgroup = page->new_optgroup("Notes"); //! label_width = > 0,
|
||||
option = get_option_("notes");
|
||||
option.opt.full_width = 1;
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 250;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
@ -396,7 +329,6 @@ void CTabPrint::build()
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
|
||||
//Regerenerate content of the page tree.
|
||||
void CTab::rebuild_page_tree()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user