Start filling the Print's Tab, using @lordofhyphens's Optionsgroup
This commit is contained in:
parent
c5e21c1fbf
commit
d60fac42d6
15
xs/src/slic3r/GUI/ConfigExceptions.hpp
Normal file
15
xs/src/slic3r/GUI/ConfigExceptions.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <exception>
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
class ConfigError : public std::runtime_error {
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
class ConfigGUITypeError : public ConfigError {
|
||||||
|
using ConfigError::ConfigError;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
42
xs/src/slic3r/GUI/Field.cpp
Normal file
42
xs/src/slic3r/GUI/Field.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "GUI.hpp"//"slic3r_gui.hpp"
|
||||||
|
#include "Field.hpp"
|
||||||
|
|
||||||
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
void Field::_on_kill_focus(wxFocusEvent& event) {
|
||||||
|
// Without this, there will be nasty focus bugs on Windows.
|
||||||
|
// Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all
|
||||||
|
// non-command events to allow the default handling to take place."
|
||||||
|
event.Skip(1);
|
||||||
|
|
||||||
|
// call the registered function if it is available
|
||||||
|
//! if (on_kill_focus)
|
||||||
|
//! on_kill_focus(opt_id);
|
||||||
|
}
|
||||||
|
void Field::_on_change(wxCommandEvent& event) {
|
||||||
|
std::cerr << "calling Field::_on_change \n";
|
||||||
|
//! if (on_change != nullptr && !disable_change_event)
|
||||||
|
//! on_change(opt_id, "A");
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
|
||||||
|
if (opt.tooltip.length() > 0) { temp->SetToolTip(opt.tooltip); }
|
||||||
|
|
||||||
|
temp->Bind(wxEVT_TEXT, ([=](wxCommandEvent e) { _on_change(e); }), temp->GetId());
|
||||||
|
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxFocusEvent e) { _on_kill_focus(e); }), temp->GetId());
|
||||||
|
|
||||||
|
// recast as a wxWindow to fit the calling convention
|
||||||
|
window = dynamic_cast<wxWindow*>(temp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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::set_tooltip(const wxString& tip) { }
|
||||||
|
}}
|
||||||
|
|
137
xs/src/slic3r/GUI/Field.hpp
Normal file
137
xs/src/slic3r/GUI/Field.hpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
#ifndef SLIC3R_GUI_FIELD_HPP
|
||||||
|
#define SLIC3R_GUI_FIELD_HPP
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include <boost/any.hpp>
|
||||||
|
|
||||||
|
#include "../../libslic3r/libslic3r.h"
|
||||||
|
#include "../../libslic3r/Config.hpp"
|
||||||
|
|
||||||
|
//#include "slic3r_gui.hpp"
|
||||||
|
#include "GUI.hpp"
|
||||||
|
|
||||||
|
#if SLIC3R_CPPVER==11
|
||||||
|
// C++14 has make_unique, C++11 doesn't. This is really useful so we're going to steal it.
|
||||||
|
template<class T, class...Args>
|
||||||
|
std::unique_ptr<T> make_unique(Args&&... args)
|
||||||
|
{
|
||||||
|
std::unique_ptr<T> ret (new T(std::forward<Args>(args)...));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
class Field;
|
||||||
|
using t_field = std::unique_ptr<Field>;
|
||||||
|
|
||||||
|
class Field {
|
||||||
|
protected:
|
||||||
|
// factory function to defer and enforce creation of derived type.
|
||||||
|
virtual void PostInitialize() { BUILD(); }
|
||||||
|
|
||||||
|
/// Finish constructing the Field's wxWidget-related properties, including setting its own sizer, etc.
|
||||||
|
virtual void BUILD() = 0;
|
||||||
|
|
||||||
|
/// Call the attached on_kill_focus method.
|
||||||
|
void _on_kill_focus(wxFocusEvent& event);
|
||||||
|
/// Call the attached on_change method.
|
||||||
|
void _on_change(wxCommandEvent& event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// parent wx item, opportunity to refactor (probably not necessary - data duplication)
|
||||||
|
wxWindow* parent {nullptr};
|
||||||
|
|
||||||
|
/// Function object to store callback passed in from owning object.
|
||||||
|
//! t_kill_focus on_kill_focus {nullptr};
|
||||||
|
|
||||||
|
/// Function object to store callback passed in from owning object.
|
||||||
|
//! t_change on_change {nullptr};
|
||||||
|
|
||||||
|
bool disable_change_event {false};
|
||||||
|
|
||||||
|
/// Copy of ConfigOption for deduction purposes
|
||||||
|
const ConfigOptionDef opt {ConfigOptionDef()};
|
||||||
|
const t_config_option_key opt_id;//! {""};
|
||||||
|
|
||||||
|
/// Sets a value for this control.
|
||||||
|
/// subclasses should overload with a specific version
|
||||||
|
/// Postcondition: Method does not fire the on_change event.
|
||||||
|
virtual void set_value(boost::any value) = 0;
|
||||||
|
|
||||||
|
/// Gets a boost::any representing this control.
|
||||||
|
/// subclasses should overload with a specific version
|
||||||
|
virtual boost::any get_value() = 0;
|
||||||
|
|
||||||
|
virtual void enable() = 0;
|
||||||
|
virtual void disable() = 0;
|
||||||
|
|
||||||
|
/// Fires the enable or disable function, based on the input.
|
||||||
|
inline void toggle(bool en) { en ? enable() : disable(); }
|
||||||
|
|
||||||
|
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) {};
|
||||||
|
|
||||||
|
/// If you don't know what you are getting back, check both methods for nullptr.
|
||||||
|
virtual wxSizer* getSizer() { return nullptr; }
|
||||||
|
virtual wxWindow* getWindow() { return nullptr; }
|
||||||
|
|
||||||
|
|
||||||
|
/// Factory method for generating new derived classes.
|
||||||
|
template<class T>
|
||||||
|
static t_field Create(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) // interface for creating shared objects
|
||||||
|
{
|
||||||
|
auto p = std::make_unique<T>(parent, opt, id);
|
||||||
|
p->PostInitialize();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Convenience function, accepts a const reference to t_field and checks to see whether
|
||||||
|
/// or not both wx pointers are null.
|
||||||
|
inline bool is_bad_field(const t_field& obj) { return obj->getSizer() == nullptr && obj->getWindow() == nullptr; }
|
||||||
|
|
||||||
|
/// Covenience function to determine whether this field is a valid window field.
|
||||||
|
inline bool is_window_field(const t_field& obj) { return !is_bad_field(obj) && obj->getWindow() != nullptr; }
|
||||||
|
|
||||||
|
/// Covenience function to determine whether this field is a valid sizer field.
|
||||||
|
inline bool is_sizer_field(const t_field& obj) { return !is_bad_field(obj) && obj->getSizer() != nullptr; }
|
||||||
|
|
||||||
|
class TextCtrl : public Field {
|
||||||
|
using Field::Field;
|
||||||
|
public:
|
||||||
|
void BUILD();
|
||||||
|
wxWindow* window {nullptr};
|
||||||
|
|
||||||
|
|
||||||
|
virtual void set_value(std::string value) {
|
||||||
|
dynamic_cast<wxTextCtrl*>(window)->SetValue(wxString(value));
|
||||||
|
}
|
||||||
|
virtual void set_value(boost::any value) {
|
||||||
|
dynamic_cast<wxTextCtrl*>(window)->SetValue(boost::any_cast<wxString>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::any get_value() { return boost::any(dynamic_cast<wxTextCtrl*>(window)->GetValue()); }
|
||||||
|
|
||||||
|
virtual void enable();
|
||||||
|
virtual void disable();
|
||||||
|
virtual wxWindow* getWindow() { return window; }
|
||||||
|
void set_tooltip(const wxString& tip);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}}
|
||||||
|
|
@ -9,6 +9,15 @@
|
|||||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
// Undefine min/max macros incompatible with the standard library
|
||||||
|
// For example, std::numeric_limits<std::streamsize>::max()
|
||||||
|
// produces some weird errors
|
||||||
|
#ifdef min
|
||||||
|
#undef min
|
||||||
|
#endif
|
||||||
|
#ifdef max
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
#include "boost/nowide/convert.hpp"
|
#include "boost/nowide/convert.hpp"
|
||||||
#pragma comment(lib, "user32.lib")
|
#pragma comment(lib, "user32.lib")
|
||||||
#endif
|
#endif
|
||||||
@ -20,6 +29,7 @@
|
|||||||
#include <wx/notebook.h>
|
#include <wx/notebook.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
#include "Tab.h"
|
#include "Tab.h"
|
||||||
|
|
||||||
@ -181,8 +191,25 @@ void add_debug_menu(wxMenuBar *menu)
|
|||||||
//
|
//
|
||||||
void create_preset_tab(const char *name)
|
void create_preset_tab(const char *name)
|
||||||
{
|
{
|
||||||
CTabPrint* panel = new CTabPrint(g_wxTabPanel, name/*, someParams*/);
|
CTabPrint* panel = new CTabPrint(g_wxTabPanel, name);
|
||||||
|
panel->create_preset_tab();
|
||||||
g_wxTabPanel->AddPage(panel, name);
|
g_wxTabPanel->AddPage(panel, name);
|
||||||
|
|
||||||
|
//!------------Exp
|
||||||
|
// parse all command line options into a DynamicConfig
|
||||||
|
/*
|
||||||
|
DynamicPrintConfig print_config;
|
||||||
|
//! const DynamicPrintConfig &print_config = preset_bundle.prints .get_edited_preset().config;
|
||||||
|
|
||||||
|
auto vsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
this->SetSizer(vsizer);
|
||||||
|
auto optgroup = GUI::ConfigOptionsGroup(this, "Custom GCode", &print_config);
|
||||||
|
optgroup.on_change = ON_CHANGE(= , {});
|
||||||
|
vsizer->Add(optgroup.sizer, 0, wxEXPAND | wxALL, 10);
|
||||||
|
|
||||||
|
optgroup.append_single_option_line(GUI::Option(*(config.def->get("before_layer_gcode")), "before_layer_gcode"));
|
||||||
|
*/ //!------------Exp
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
@ -1,124 +1,125 @@
|
|||||||
#include "OptionsGroup.hpp"
|
#include "OptionsGroup.hpp"
|
||||||
#include "OptionsGroup/Field.hpp"
|
#include "ConfigExceptions.hpp"
|
||||||
#include "Config.hpp"
|
|
||||||
|
|
||||||
// Translate the ifdef
|
#include <utility>
|
||||||
#ifdef __WXOSX__
|
#include <wx/tooltip.h>
|
||||||
#define wxOSX true
|
|
||||||
#else
|
|
||||||
#define wxOSX false
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BORDER(a, b) ((wxOSX ? a : b))
|
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
const t_field& OptionsGroup::build_field(const Option& opt) {
|
||||||
|
return build_field(opt.opt_id, opt.opt);
|
||||||
|
}
|
||||||
|
const t_field& OptionsGroup::build_field(const t_config_option_key& id) {
|
||||||
|
const ConfigOptionDef& opt = options.at(id);
|
||||||
|
return build_field(id, opt);
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsGroup::BUILD() {
|
const t_field& OptionsGroup::build_field(const t_config_option_key& id, const ConfigOptionDef& opt) {
|
||||||
if (staticbox) {
|
// Check the gui_type field first, fall through
|
||||||
wxStaticBox* box = new wxStaticBox(_parent, -1, title);
|
// is the normal type.
|
||||||
_sizer = new wxStaticBoxSizer(box, wxVERTICAL);
|
if (opt.gui_type.compare("select") == 0) {
|
||||||
} else {
|
} else if (opt.gui_type.compare("select_open") == 0) {
|
||||||
_sizer = new wxBoxSizer(wxVERTICAL);
|
} else if (opt.gui_type.compare("color") == 0) {
|
||||||
|
} 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) {
|
||||||
|
} 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)));
|
||||||
|
break;
|
||||||
|
case coNone: break;
|
||||||
|
default:
|
||||||
|
break;//! throw ConfigGUITypeError(""); break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
size_t num_columns = 1;
|
// Grab a reference to fields for convenience
|
||||||
if (label_width != 0) ++num_columns;
|
const t_field& field = fields[id];
|
||||||
if (extra_column != 0) ++num_columns;
|
//! field->on_change = [this](std::string id, boost::any val) { };
|
||||||
|
field->parent = parent();
|
||||||
_grid_sizer = new wxFlexGridSizer(0, num_columns, 0, 0);
|
// assign function objects for callbacks, etc.
|
||||||
_grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
return field;
|
||||||
_grid_sizer->AddGrowableCol(label_width > 0);
|
|
||||||
_sizer->Add(_grid_sizer, 0, wxEXPAND | wxALL, BORDER(0,5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::append_line(const Line& line) {
|
void OptionsGroup::append_line(const Line& line) {
|
||||||
if (line.has_sizer() || (line.has_widget() && line.full_width)) {
|
if (line.sizer != nullptr || (line.widget != nullptr && line.full_width > 0)){
|
||||||
wxASSERT(line.sizer() != nullptr);
|
if (line.sizer != nullptr) {
|
||||||
_sizer->Add( (line.has_sizer() ? line.sizer() : line.widget().sizer()), 0, wxEXPAND | wxALL, BORDER(0, 15));
|
sizer->Add(line.sizer, 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (line.widget != nullptr) {
|
||||||
|
sizer->Add(line.widget(_parent), 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wxSizer* grid_sizer = _grid_sizer;
|
|
||||||
// If we have an extra column, build it.
|
auto grid_sizer = _grid_sizer;
|
||||||
// If there's a label, build it.
|
|
||||||
|
// Build a label if we have it
|
||||||
if (label_width != 0) {
|
if (label_width != 0) {
|
||||||
wxStaticText* label = new wxStaticText(_parent, -1, (line.label) + ":", wxDefaultPosition);
|
auto label = new wxStaticText(parent(), wxID_ANY, line.label , wxDefaultPosition, wxSize(label_width, -1));
|
||||||
label->Wrap(label_width);
|
label->SetFont(label_font);
|
||||||
if (wxIsEmpty(line.tooltip())) { label->SetToolTip(line.tooltip()); }
|
label->Wrap(label_width); // avoid a Linux/GTK bug
|
||||||
grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL,0);
|
||||||
|
if (line.label_tooltip.compare("") != 0)
|
||||||
|
label->SetToolTip(line.label_tooltip);
|
||||||
}
|
}
|
||||||
// If we have a widget, add it to the sizer
|
|
||||||
if (line.has_widget()) {
|
// If there's a widget, build it and add the result to the sizer.
|
||||||
grid_sizer->Add(line.widget().sizer(), 0, wxEXPAND | wxALL, BORDER(0,15));
|
if (line.widget != nullptr) {
|
||||||
|
auto wgt = line.widget(parent());
|
||||||
|
grid_sizer->Add(wgt, 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If we have a single option with no sidetext just add it directly to the grid sizer
|
|
||||||
if (line.options().size() == 1) {
|
|
||||||
const ConfigOptionDef& opt = line.options()[0];
|
// if we have a single option with no sidetext just add it directly to the grid sizer
|
||||||
if (line.extra_widgets().size() && !wxIsEmpty(opt.sidetext) && line.extra_widgets().size() == 0) {
|
auto option_set = line.get_options();
|
||||||
Field* field = _build_field(opt);
|
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
|
||||||
if (field != nullptr) {
|
option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
|
||||||
if (field->has_sizer()) {
|
const auto& option = option_set.front();
|
||||||
grid_sizer->Add(field->sizer(), 0, (opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
const auto& field = build_field(option);
|
||||||
} else if (field->has_window()) {
|
std::cerr << "single option, no sidetext.\n";
|
||||||
grid_sizer->Add(field->window(), 0, (opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
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;
|
||||||
}
|
}
|
||||||
// Otherwise, there's more than one option or a single option with sidetext -- make
|
|
||||||
// a horizontal sizer to arrange things.
|
// if we're here, we have more than one option or a single option with sidetext
|
||||||
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
|
// so we need a horizontal sizer to arrange these things
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
grid_sizer->Add(sizer, 0, 0, 0);
|
grid_sizer->Add(sizer, 0, 0, 0);
|
||||||
for (auto& option : line.options()) {
|
for (auto opt : option_set) {
|
||||||
// add label if any
|
|
||||||
if (!wxIsEmpty(option.label)) {
|
|
||||||
wxStaticText* field_label = new wxStaticText(_parent, -1, __(option.label) + ":", wxDefaultPosition, wxDefaultSize);
|
|
||||||
sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add field
|
|
||||||
Field* field = _build_field(option);
|
|
||||||
if (field != nullptr) {
|
|
||||||
if (field->has_sizer()) {
|
|
||||||
sizer->Add(field->sizer(), 0, (option.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
|
||||||
} else if (field->has_window()) {
|
|
||||||
sizer->Add(field->window(), 0, (option.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wxIsEmpty(option.sidetext)) {
|
|
||||||
}
|
|
||||||
// !!! side_widget !!! find out the purpose
|
|
||||||
// if (option.side_widget.valid()) {
|
|
||||||
// sizer->Add(option.side_widget.sizer(), 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 1);
|
|
||||||
// }
|
|
||||||
if (&option != &line.options().back()) {
|
|
||||||
sizer->AddSpacer(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add side text if any
|
|
||||||
// add side widget if any
|
|
||||||
}
|
|
||||||
// Append extra sizers
|
|
||||||
for (auto& widget : line.extra_widgets()) {
|
|
||||||
_sizer->Add(widget.sizer(), 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Line OptionsGroup::create_single_option_line(const Option& option) const {
|
||||||
|
Line retval {option.opt.label, option.opt.tooltip};
|
||||||
|
Option tmp(option);
|
||||||
|
tmp.opt.label = std::string("");
|
||||||
|
retval.append_option(tmp);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* OptionsGroup::_build_field(const ConfigOptionDef& opt) {
|
//! void OptionsGroup::_on_change(t_config_option_key id, config_value value) {
|
||||||
Field* built_field = nullptr;
|
//! if (on_change != nullptr)
|
||||||
switch (opt.type) {
|
//! on_change(id, value);
|
||||||
case coString:
|
//! }
|
||||||
{
|
|
||||||
printf("Making new textctrl\n");
|
void OptionsGroup::_on_kill_focus (t_config_option_key id) {
|
||||||
TextCtrl* temp = new TextCtrl(_parent, opt);
|
// do nothing.
|
||||||
printf("recasting textctrl\n");
|
|
||||||
built_field = dynamic_cast<Field*>(temp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return built_field;
|
|
||||||
}
|
}
|
||||||
} }
|
|
||||||
|
|
||||||
|
}}
|
||||||
|
@ -1,109 +1,148 @@
|
|||||||
#ifndef OPTIONSGROUP_HPP
|
#include <wx/wx.h>
|
||||||
#define OPTIONSGROUP_HPP
|
#include <wx/stattext.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
//#include <wx/window.h>
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "wxinit.h"
|
#include <functional>
|
||||||
#include "Widget.hpp"
|
|
||||||
#include "OptionsGroup/Field.hpp"
|
|
||||||
#include "Config.hpp"
|
|
||||||
namespace Slic3r {
|
|
||||||
class ConfigOptionDef;
|
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
|
#include "libslic3r/Config.hpp"
|
||||||
|
#include "libslic3r/PrintConfig.hpp"
|
||||||
|
#include "libslic3r/libslic3r.h"
|
||||||
|
|
||||||
/// Enumeration class to provide flags for these GUI hints.
|
#include "Field.hpp"
|
||||||
/// they resolve to hex numbers to permit boolean masking.
|
//#include "slic3r_gui.hpp"
|
||||||
enum class GUI_Type {
|
#include "GUI.hpp"
|
||||||
i_enum_open = 0x1,
|
|
||||||
f_enum_open = 0x2,
|
// Translate the ifdef
|
||||||
select_open = 0x4
|
#ifdef __WXOSX__
|
||||||
|
#define wxOSX true
|
||||||
|
#else
|
||||||
|
#define wxOSX false
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BORDER(a, b) ((wxOSX ? a : b))
|
||||||
|
|
||||||
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
/// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window).
|
||||||
|
using widget_t = std::function<wxWindow*(wxWindow*)>;
|
||||||
|
using column_t = std::function<wxSizer*(const Line&)>;
|
||||||
|
|
||||||
|
class StaticText;
|
||||||
|
|
||||||
|
/// Wraps a ConfigOptionDef and adds function object for creating a side_widget.
|
||||||
|
struct Option {
|
||||||
|
ConfigOptionDef opt {ConfigOptionDef()};
|
||||||
|
t_config_option_key opt_id;//! {""};
|
||||||
|
widget_t side_widget {nullptr};
|
||||||
|
bool readonly {false};
|
||||||
|
|
||||||
|
Option(const ConfigOptionDef& _opt, t_config_option_key id) : opt(_opt), opt_id(id) {};
|
||||||
|
};
|
||||||
|
using t_option = std::unique_ptr<Option>; //!
|
||||||
|
|
||||||
|
/// Represents option lines
|
||||||
|
class Line {
|
||||||
|
public:
|
||||||
|
wxString label {wxString("")};
|
||||||
|
wxString label_tooltip {wxString("")};
|
||||||
|
size_t full_width {0};
|
||||||
|
wxSizer* sizer {nullptr};
|
||||||
|
widget_t widget {nullptr};
|
||||||
|
|
||||||
|
inline void append_option(const Option& option) {
|
||||||
|
_options.push_back(option);
|
||||||
|
}
|
||||||
|
Line(std::string label, std::string tooltip) : label(wxString(label)), label_tooltip(wxString(tooltip)) {} ;
|
||||||
|
|
||||||
|
const std::vector<widget_t>& get_extra_widgets() const {return _extra_widgets;}
|
||||||
|
const std::vector<Option>& get_options() const { return _options; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Option> _options;//! {std::vector<Option>()};
|
||||||
|
std::vector<widget_t> _extra_widgets;//! {std::vector<widget_t>()};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Map these flags
|
using t_optionfield_map = std::map<t_config_option_key, t_field>;
|
||||||
/*constexpr */std::map<std::string, GUI_Type>gui_type_map =
|
using t_optionoption_map = std::map<t_config_option_key, t_option>; //!
|
||||||
{ { "i_enum_open", GUI_Type::i_enum_open },
|
|
||||||
{ "f_enum_open", GUI_Type::f_enum_open },
|
class OptionsGroup {
|
||||||
{ "select_open", GUI_Type::select_open }
|
public:
|
||||||
|
|
||||||
|
const bool staticbox {true};
|
||||||
|
const wxString title {wxString("")};
|
||||||
|
size_t label_width {180};
|
||||||
|
wxSizer* sizer {nullptr};
|
||||||
|
column_t extra_column {nullptr};
|
||||||
|
// t_change on_change {nullptr};
|
||||||
|
|
||||||
|
/// Returns a copy of the pointer of the parent wxWindow.
|
||||||
|
/// Accessor function is because users are not allowed to change the parent
|
||||||
|
/// but defining it as const means a lot of const_casts to deal with wx functions.
|
||||||
|
inline wxWindow* parent() const { return _parent; }
|
||||||
|
|
||||||
|
wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
|
||||||
|
wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
|
||||||
|
|
||||||
|
|
||||||
|
void append_line(const Line& line);
|
||||||
|
virtual Line create_single_option_line(const Option& option) const;
|
||||||
|
inline void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); }
|
||||||
|
|
||||||
|
// return a non-owning pointer reference
|
||||||
|
inline const Field* get_field(t_config_option_key id) const { try { return fields.at(id).get(); } catch (std::out_of_range e) { return nullptr; } }
|
||||||
|
//! inline const Option& get_option(t_config_option_key id) const { try { return options.at(id).get(); } catch (std::out_of_range e) { return nullptr; } }
|
||||||
|
// }
|
||||||
|
//! inline void set_value(t_config_option_key id, boost::any value) { try { fields.at(id).set_value(value); } catch (std::out_of_range e) {;} }
|
||||||
|
|
||||||
|
inline void enable() { for (auto& field : fields) field.second->enable(); }
|
||||||
|
inline void disable() { for (auto& field : fields) field.second->disable(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OptionsGroup(wxWindow* _parent, std::string title, const ConfigDef& configs) : options(configs.options), _parent(_parent), title(wxString(title)) {
|
||||||
|
sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
||||||
|
auto num_columns = 1U;
|
||||||
|
if (label_width != 0) num_columns++;
|
||||||
|
if (extra_column != nullptr) num_columns++;
|
||||||
|
_grid_sizer = new wxFlexGridSizer(0, num_columns, 0,0);
|
||||||
|
static_cast<wxFlexGridSizer*>(_grid_sizer)->SetFlexibleDirection(wxHORIZONTAL);
|
||||||
|
static_cast<wxFlexGridSizer*>(_grid_sizer)->AddGrowableCol(label_width != 0);
|
||||||
|
|
||||||
|
sizer->Add(_grid_sizer, 0, wxEXPAND | wxALL, wxOSX ? 0: 5);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Abstraction cribbed from Slic3r::ConfigOptionDefGroup::Line
|
protected:
|
||||||
// Unsure if templated class or function overloading is the appropriate thing here.
|
/*const t_optionoption_map& options; //*/const t_optiondef_map& options; //!
|
||||||
class Line {
|
wxWindow* _parent {nullptr};
|
||||||
private:
|
|
||||||
std::vector<ConfigOptionDef> _options;
|
/// Field list, contains unique_ptrs of the derived type.
|
||||||
std::vector<Widget> _extra_widgets;
|
/// using types that need to know what it is beyond the public interface
|
||||||
Widget _widget;
|
/// need to cast based on the related ConfigOptionDef.
|
||||||
wxSizer* _sizer;
|
t_optionfield_map fields;
|
||||||
wxString _tooltip;
|
bool _disabled {false};
|
||||||
|
wxGridSizer* _grid_sizer {nullptr};
|
||||||
|
|
||||||
|
/// Generate a wxSizer or wxWindow from a configuration option
|
||||||
|
/// Precondition: opt resolves to a known ConfigOption
|
||||||
|
/// Postcondition: fields contains a wx gui object.
|
||||||
|
const t_field& build_field(const t_config_option_key& id, const ConfigOptionDef& opt);
|
||||||
|
const t_field& build_field(const t_config_option_key& id);
|
||||||
|
const t_field& build_field(const Option& opt);
|
||||||
|
|
||||||
|
virtual void _on_kill_focus (t_config_option_key id);
|
||||||
|
//! virtual void _on_change(t_config_option_key id, config_value value);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConfigOptionsGroup: public OptionsGroup {
|
||||||
public:
|
public:
|
||||||
wxString label;
|
/// reference to libslic3r config, non-owning pointer (?).
|
||||||
bool full_width;
|
const DynamicPrintConfig* config {nullptr};
|
||||||
wxSizer* sizer() const { return _sizer; }
|
bool full_labels {0};
|
||||||
Line() : label(wxT("")), _tooltip(wxT("")), _sizer(nullptr), full_width(false), _widget(Widget()) { }
|
ConfigOptionsGroup(wxWindow* parent, std::string title, DynamicPrintConfig* _config) : OptionsGroup(parent, title, *(_config->def())), config(_config) {}; //!OptionsGroup(parent, title, *(_config->def)), config(_config) {};
|
||||||
Line(const ConfigOptionDef& z) : label(z.label), _tooltip(z.tooltip), _sizer(nullptr), full_width(false), _widget(Widget()) { append_option(z); }
|
|
||||||
Line(const wxString& label, const wxString& tooltip) : label(label), _tooltip(tooltip), _sizer(nullptr), full_width(false), _widget(Widget()) { }
|
|
||||||
inline void append_option(const ConfigOptionDef& z) { _options.push_back(z); };
|
|
||||||
void append_widget(const Widget& wid) { _extra_widgets.push_back(wid); }
|
|
||||||
std::vector<ConfigOptionDef> options() const { return _options; }
|
|
||||||
const std::vector<Widget> extra_widgets() const { return _extra_widgets; }
|
|
||||||
bool has_sizer() const { return _sizer != nullptr; }
|
|
||||||
bool has_widget() const { return _widget.valid(); }
|
|
||||||
Widget widget() const { return _widget; }
|
|
||||||
const wxString tooltip() const { return _tooltip; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
// OptionsGroup building class, cribbed from Slic3r::OptionGroup
|
|
||||||
// Usage: Instantitate, add individual items to it, and add its sizer to another wxWidgets sizer.
|
|
||||||
class OptionsGroup {
|
|
||||||
private:
|
|
||||||
bool _disabled;
|
|
||||||
wxFlexGridSizer* _grid_sizer;
|
|
||||||
wxSizer* _sizer;
|
|
||||||
void BUILD();
|
|
||||||
const bool staticbox;
|
|
||||||
wxFrame* _parent;
|
|
||||||
std::map<size_t, Field*> fields;
|
|
||||||
Field* _build_field(const ConfigOptionDef& opt);
|
|
||||||
public:
|
|
||||||
const wxString title;
|
|
||||||
|
|
||||||
size_t label_width;
|
|
||||||
wxFont label_font;
|
|
||||||
wxFont sidetext_font;
|
|
||||||
bool extra_column;
|
|
||||||
|
|
||||||
OptionsGroup() : _parent(nullptr), title(wxT("")), staticbox(1), fields(std::map<size_t, Field*>()){};
|
|
||||||
OptionsGroup(wxFrame* parent, std::string title) :
|
|
||||||
_parent(parent),
|
|
||||||
title(title.c_str()),
|
|
||||||
staticbox(1),
|
|
||||||
extra_column(false),
|
|
||||||
label_width(0),
|
|
||||||
fields(std::map<size_t, Field*>())
|
|
||||||
{ BUILD(); }
|
|
||||||
|
|
||||||
OptionsGroup(wxFrame* parent, std::string, size_t label_width) :
|
|
||||||
_parent(parent),
|
|
||||||
title(title.c_str()),
|
|
||||||
staticbox(1),
|
|
||||||
extra_column(false),
|
|
||||||
fields(std::map<size_t, Field*>()),
|
|
||||||
label_width(label_width) { BUILD(); }
|
|
||||||
|
|
||||||
void append_line(const Line& line);
|
|
||||||
Line create_single_option_line(const ConfigOptionDef& opt) { Line a = Line(opt); append_line(a); return a; }
|
|
||||||
void append_single_option_line(const Line& line);
|
|
||||||
|
|
||||||
wxSizer* sizer() { return _sizer; }
|
|
||||||
void disable() { for (auto& f: fields) f.second->disable(); }
|
|
||||||
void enable() { for (auto& f: fields) f.second->enable(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
#include "Field.hpp"
|
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
|
||||||
|
|
||||||
void TextCtrl::BUILD() {
|
|
||||||
wxString default_value = "";
|
|
||||||
// Empty wxString object fails cast, default to "" if
|
|
||||||
// the recast fails from boost::any.
|
|
||||||
try {
|
|
||||||
if (opt.default_value != nullptr) {
|
|
||||||
default_value = boost::any_cast<wxString>(*(opt.default_value));
|
|
||||||
}
|
|
||||||
} catch (const boost::bad_any_cast& e) {
|
|
||||||
//TODO log error
|
|
||||||
}
|
|
||||||
auto size = wxSize(opt.height,opt.width);
|
|
||||||
if (opt.height == 0 || opt.width == 0) { size = wxDefaultSize; }
|
|
||||||
|
|
||||||
wxTextCtrl* temp = new wxTextCtrl(_parent, wxID_ANY, default_value, wxDefaultPosition, size, (opt.multiline ? wxTE_MULTILINE : 0));
|
|
||||||
|
|
||||||
_on_change = [=](wxCommandEvent& a) { this->__on_change(a);};
|
|
||||||
|
|
||||||
// This replaces the generic EVT_TEXT call to set the table up, it works with function objects.
|
|
||||||
temp->Bind(wxEVT_TEXT, _on_change, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixed (temporary) function. We can (and probably should) use lambdas instead.
|
|
||||||
void TextCtrl::__on_change(wxCommandEvent& a) {
|
|
||||||
printf("Calling _on_change for %d.\n", opt.label);
|
|
||||||
}
|
|
||||||
|
|
||||||
} }
|
|
@ -1,95 +0,0 @@
|
|||||||
#ifndef FIELD_HPP
|
|
||||||
#define FIELD_HPP
|
|
||||||
|
|
||||||
#include "../wxinit.h"
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <boost/any.hpp>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
// ConfigOptionDef definition
|
|
||||||
#include "Config.hpp"
|
|
||||||
|
|
||||||
namespace Slic3r {
|
|
||||||
class ConfigOptionDef;
|
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Interface class for fields
|
|
||||||
///
|
|
||||||
class Field {
|
|
||||||
protected:
|
|
||||||
wxSizer* _sizer;
|
|
||||||
wxWindow* _window;
|
|
||||||
wxWindow* _parent;
|
|
||||||
|
|
||||||
/// Instantiate the underlying wxWidgets control/window.
|
|
||||||
/// This function is expected to be called by the constructor.
|
|
||||||
virtual void BUILD() = 0;
|
|
||||||
|
|
||||||
/// Reference to underlying ConfigOptionDef this Field is
|
|
||||||
/// implementing.
|
|
||||||
/// TODO: This may not be necessary.
|
|
||||||
const ConfigOptionDef& opt;
|
|
||||||
std::string type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::function<void(wxCommandEvent&)> _on_change;
|
|
||||||
std::function<void(wxCommandEvent&)> _on_kill_focus;
|
|
||||||
// used if we need to know which ConfigOptionDef this corresponds.
|
|
||||||
Field() : opt(ConfigOptionDef()), _on_change(nullptr), _on_kill_focus(nullptr){}
|
|
||||||
Field(const ConfigOptionDef& opt) : opt(opt), type(opt.gui_type) { }
|
|
||||||
Field(wxFrame* parent, const ConfigOptionDef& opt) : opt(opt), _parent(parent) { }
|
|
||||||
wxSizer* sizer() { return _sizer; }
|
|
||||||
wxWindow* window() { return _window; }
|
|
||||||
|
|
||||||
//
|
|
||||||
bool has_sizer() { return _sizer != nullptr; }
|
|
||||||
bool has_window() { return _window != nullptr; }
|
|
||||||
|
|
||||||
/// Return the wxWidgets ID for this object.
|
|
||||||
///
|
|
||||||
wxWindowID get_id() { if (this->has_window()) return _window->GetId(); }
|
|
||||||
|
|
||||||
/// Sets a value for this control.
|
|
||||||
/// subclasses should overload with a specific version
|
|
||||||
virtual void set_value(boost::any value) = 0;
|
|
||||||
|
|
||||||
/// Gets a boost::any representing this control.
|
|
||||||
/// subclasses should overload with a specific version
|
|
||||||
virtual boost::any get_value() = 0;
|
|
||||||
|
|
||||||
/// subclasses should overload with a specific version
|
|
||||||
virtual void enable() = 0;
|
|
||||||
virtual void disable() = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class TextCtrl : public Field {
|
|
||||||
protected:
|
|
||||||
void BUILD();
|
|
||||||
public:
|
|
||||||
TextCtrl();
|
|
||||||
TextCtrl(wxFrame* parent, const ConfigOptionDef& opt) : Field(parent, opt) { BUILD(); };
|
|
||||||
|
|
||||||
void set_value(std::string value) {
|
|
||||||
dynamic_cast<wxTextCtrl*>(_window)->SetValue(wxString(value));
|
|
||||||
}
|
|
||||||
void set_value(boost::any value) {
|
|
||||||
try {
|
|
||||||
dynamic_cast<wxTextCtrl*>(_window)->SetValue(boost::any_cast<wxString>(value));
|
|
||||||
} catch (boost::bad_any_cast) {
|
|
||||||
// TODO Log error and do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boost::any get_value() { return boost::any(dynamic_cast<wxTextCtrl*>(_window)->GetValue()); }
|
|
||||||
|
|
||||||
void enable() { dynamic_cast<wxTextCtrl*>(_window)->Enable(); dynamic_cast<wxTextCtrl*>(_window)->SetEditable(1); }
|
|
||||||
void disable() { dynamic_cast<wxTextCtrl*>(_window)->Disable(); dynamic_cast<wxTextCtrl*>(_window)->SetEditable(0); }
|
|
||||||
void __on_change(wxCommandEvent&);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} }
|
|
||||||
#endif
|
|
@ -1,9 +1,7 @@
|
|||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/scrolwin.h>
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <wx/notebook.h>
|
|
||||||
#include <wx/panel.h>
|
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
|
||||||
#include <wx/bmpcbox.h>
|
#include <wx/bmpcbox.h>
|
||||||
@ -12,19 +10,11 @@
|
|||||||
#include <wx/imaglist.h>
|
#include <wx/imaglist.h>
|
||||||
|
|
||||||
#include "Tab.h"
|
#include "Tab.h"
|
||||||
|
#include "PresetBundle.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
// Declare some IDs.
|
|
||||||
/*const int BUTTON1 = 100;
|
|
||||||
|
|
||||||
// Attach the event handlers. Put this after Slis3rFrame declaration.
|
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
||||||
EVT_BUTTON(BUTTON1, MyFrame::OnButton1)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
*/
|
|
||||||
|
|
||||||
// sub new
|
// sub new
|
||||||
void CTab::create_preset_tab()
|
void CTab::create_preset_tab()
|
||||||
{
|
{
|
||||||
@ -32,136 +22,483 @@ void CTab::create_preset_tab()
|
|||||||
CTab *panel = this;
|
CTab *panel = this;
|
||||||
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
sizer->SetSizeHints(panel);
|
sizer->SetSizeHints(panel);
|
||||||
(panel)->SetSizer(sizer);
|
|
||||||
panel->SetSizer(sizer);
|
panel->SetSizer(sizer);
|
||||||
|
|
||||||
// preset chooser
|
// preset chooser
|
||||||
|
//! Add Preset from PrintPreset
|
||||||
// choice menu for Experiments
|
// choice menu for Experiments
|
||||||
wxString choices[] =
|
wxString choices[] =
|
||||||
{
|
{
|
||||||
_T("Washington"),
|
_T("First"),
|
||||||
_T("Adams"),
|
_T("Second"),
|
||||||
_T("Jefferson"),
|
_T("Third")
|
||||||
_T("Madison"),
|
|
||||||
_T("Lincoln"),
|
|
||||||
_T("One"),
|
|
||||||
_T("Two"),
|
|
||||||
_T("Three"),
|
|
||||||
_T("Four")
|
|
||||||
};
|
};
|
||||||
int nCntEl = 9;
|
|
||||||
|
|
||||||
presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), nCntEl, choices, wxCB_READONLY);
|
presets_choice_ = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1)/*, nCntEl, choices, wxCB_READONLY*/);
|
||||||
|
const wxBitmap* bmp = new wxBitmap(wxT("var\\flag-green-icon.png"), wxBITMAP_TYPE_PNG);
|
||||||
|
for (auto el:choices)
|
||||||
|
presets_choice_->Append(wxString::FromUTF8(el).c_str(), *bmp);
|
||||||
|
presets_choice_->SetSelection(presets_choice_->GetCount() - 1);
|
||||||
|
|
||||||
//buttons
|
//buttons
|
||||||
wxBitmap bmpMenu;
|
wxBitmap bmpMenu;
|
||||||
bmpMenu = wxBitmap(wxT("var\\disk.png"), wxBITMAP_TYPE_PNG);
|
bmpMenu = wxBitmap(wxT("var\\disk.png"), wxBITMAP_TYPE_PNG);
|
||||||
auto *btn_save_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
btn_save_preset_ = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||||
bmpMenu = wxBitmap(wxT("var\\delete.png"), wxBITMAP_TYPE_PNG);
|
bmpMenu = wxBitmap(wxT("var\\delete.png"), wxBITMAP_TYPE_PNG);
|
||||||
auto *btn_delete_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
btn_delete_preset_ = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||||
|
|
||||||
// $self->{show_incompatible_presets} = 0; // !!!
|
// $self->{show_incompatible_presets} = 0; // !!!
|
||||||
|
|
||||||
bmp_show_incompatible_presets = new wxBitmap(wxT("var\\flag-red-icon.png"), wxBITMAP_TYPE_PNG);
|
bmp_show_incompatible_presets_ = new wxBitmap(wxT("var\\flag-red-icon.png"), wxBITMAP_TYPE_PNG);
|
||||||
bmp_hide_incompatible_presets = new wxBitmap(wxT("var\\flag-green-icon.png"), wxBITMAP_TYPE_PNG);
|
bmp_hide_incompatible_presets_ = new wxBitmap(wxT("var\\flag-green-icon.png"), wxBITMAP_TYPE_PNG);
|
||||||
btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, *bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
btn_hide_incompatible_presets_ = new wxBitmapButton(panel, wxID_ANY, *bmp_hide_incompatible_presets_, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||||
|
|
||||||
wxString stTitle = _T("Save current ") + wxString(_title);//. lc($self->title)
|
btn_save_preset_->SetToolTip(wxT("Save current ") + wxString(title_));// (stTitle);
|
||||||
btn_save_preset->SetToolTip(stTitle);
|
btn_delete_preset_->SetToolTip(_T("Delete this preset"));
|
||||||
btn_delete_preset->SetToolTip(_T("Delete this preset"));
|
btn_delete_preset_->Disable();
|
||||||
btn_delete_preset->Disable();
|
|
||||||
|
|
||||||
hsizer = new wxBoxSizer(wxHORIZONTAL);
|
hsizer_ = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(hsizer, 0, wxBOTTOM, 3);
|
sizer->Add(hsizer_, 0, wxBOTTOM, 3);
|
||||||
hsizer->Add(presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
hsizer_->Add(presets_choice_, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
||||||
hsizer->AddSpacer(4);
|
hsizer_->AddSpacer(4);
|
||||||
hsizer->Add(btn_save_preset, 0, wxALIGN_CENTER_VERTICAL);
|
hsizer_->Add(btn_save_preset_, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
hsizer->AddSpacer(4);
|
hsizer_->AddSpacer(4);
|
||||||
hsizer->Add(btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL);
|
hsizer_->Add(btn_delete_preset_, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
hsizer->AddSpacer(16);
|
hsizer_->AddSpacer(16);
|
||||||
hsizer->Add(btn_hide_incompatible_presets, 0, wxALIGN_CENTER_VERTICAL);
|
hsizer_->Add(btn_hide_incompatible_presets_, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
//Horizontal sizer to hold the tree and the selected page.
|
//Horizontal sizer to hold the tree and the selected page.
|
||||||
hsizer = new wxBoxSizer(wxHORIZONTAL);
|
hsizer_ = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(hsizer, 1, wxEXPAND, 0);
|
sizer->Add(hsizer_, 1, wxEXPAND, 0);
|
||||||
|
|
||||||
//left vertical sizer
|
//left vertical sizer
|
||||||
left_sizer = new wxBoxSizer(wxVERTICAL);
|
left_sizer_ = new wxBoxSizer(wxVERTICAL);
|
||||||
hsizer->Add(left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
hsizer_->Add(left_sizer_, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
||||||
|
|
||||||
// tree
|
// tree
|
||||||
auto *treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(185, -1), wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
treectrl_ = new wxTreeCtrl(panel, wxID_ANY/*ID_TAB_TREE*/, wxDefaultPosition, wxSize(185, -1), wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
||||||
left_sizer->Add(treectrl, 1, wxEXPAND);
|
left_sizer_->Add(treectrl_, 1, wxEXPAND);
|
||||||
icons = new wxImageList(16, 16, 1);
|
icons_ = new wxImageList(16, 16, true, 1/*, 1*/);
|
||||||
// Map from an icon file name to its index in $self->{icons}.
|
|
||||||
// $self->{icon_index} = {};
|
|
||||||
// Index of the last icon inserted into $self->{icons}.
|
// Index of the last icon inserted into $self->{icons}.
|
||||||
icon_count = -1;
|
icon_count = -1;
|
||||||
treectrl->AssignImageList(icons);
|
treectrl_->AssignImageList(icons_);
|
||||||
treectrl->AddRoot("root");
|
treectrl_->AddRoot("root");
|
||||||
// $self->{pages} = [];
|
treectrl_->SetIndent(0);
|
||||||
treectrl->SetIndent(0);
|
disable_tree_sel_changed_event_ = 0;
|
||||||
disable_tree_sel_changed_event = 0;
|
|
||||||
|
|
||||||
/* EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
|
//!-----------------------EXP
|
||||||
return if $self->{disable_tree_sel_changed_event};
|
// Vertical sizer to hold selected page
|
||||||
my $page = first { $_->{title} eq $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) } @{$self->{pages}}
|
// auto *scrolled_win = new wxScrolledWindow(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||||
or return;
|
// wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL);
|
||||||
$_->Hide for @{$self->{pages}};
|
// scrolled_win->SetSizer(vs);
|
||||||
$page->Show;
|
// scrolled_win->SetScrollbars(1, 1, 1, 1);
|
||||||
$self->{hsizer}->Layout;
|
// hsizer_->Add(scrolled_win, 1, wxEXPAND | wxLEFT, 5);
|
||||||
$self->Refresh;
|
//
|
||||||
});
|
// wxSizer* sbs = new wxStaticBoxSizer(new wxStaticBox(scrolled_win, wxID_ANY, "Trulala"), wxVERTICAL);
|
||||||
EVT_KEY_DOWN($self->{treectrl}, sub {
|
// vs->Add(sbs, 0, wxEXPAND | wxALL, 10);
|
||||||
my ($treectrl, $event) = @_;
|
// sbs = new wxBoxSizer(wxVERTICAL);
|
||||||
if ($event->GetKeyCode == WXK_TAB) {
|
// vs->Add(sbs, 0, wxEXPAND | wxALL, 10);
|
||||||
$treectrl->Navigate($event->ShiftDown ? &Wx::wxNavigateBackward : &Wx::wxNavigateForward);
|
// sbs = new wxStaticBoxSizer(new wxStaticBox(scrolled_win, wxID_ANY, "LuTrulala"), wxVERTICAL);
|
||||||
} else {
|
// vs->Add(sbs, 0, wxEXPAND | wxALL, 10);
|
||||||
$event->Skip;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
EVT_COMBOBOX($parent, $self->{presets_choice}, sub {
|
|
||||||
$self->select_preset($self->{presets_choice}->GetStringSelection);
|
|
||||||
});
|
|
||||||
|
|
||||||
EVT_BUTTON($self, $self->{btn_save_preset}, sub { $self->save_preset });
|
// auto *page_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
EVT_BUTTON($self, $self->{btn_delete_preset}, sub { $self->delete_preset });
|
// hsizer_->Add(page_sizer, 1, wxEXPAND | wxLEFT, 5);
|
||||||
EVT_BUTTON($self, $self->{btn_hide_incompatible_presets}, sub { $self->_toggle_show_hide_incompatible });
|
|
||||||
*/
|
// 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);
|
||||||
|
|
||||||
|
btn_save_preset_->Bind(wxEVT_BUTTON, &CTab::save_preset, this);
|
||||||
|
btn_delete_preset_->Bind(wxEVT_BUTTON, &CTab::delete_preset, this);
|
||||||
|
btn_hide_incompatible_presets_->Bind(wxEVT_BUTTON, &CTab::_toggle_show_hide_incompatible, this);
|
||||||
|
|
||||||
// Initialize the DynamicPrintConfig by default keys/values.
|
// Initialize the DynamicPrintConfig by default keys/values.
|
||||||
// Possible %params keys: no_controller
|
// Possible %params keys: no_controller
|
||||||
// build(/*%params*/);
|
build();
|
||||||
// rebuild_page_tree();
|
rebuild_page_tree();
|
||||||
// _update();
|
// _update();
|
||||||
|
|
||||||
|
|
||||||
return;//$self;
|
return;//$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTab::OnTreeSelChange(wxCommandEvent& event)
|
CPageShp CTab::add_options_page(wxString title, wxString icon)
|
||||||
{
|
{
|
||||||
if (disable_tree_sel_changed_event) return;
|
// Index of icon in an icon list $self->{icons}.
|
||||||
|
auto icon_idx = 0;
|
||||||
|
if (!icon.IsEmpty()) {
|
||||||
|
try { icon_idx = icon_index_.at(icon);}
|
||||||
|
catch (std::out_of_range e) { icon_idx = -1; }
|
||||||
|
if (icon_idx == -1) {
|
||||||
|
// Add a new icon to the icon list.
|
||||||
|
const auto img_icon = new wxIcon(wxT("var\\") + icon, wxBITMAP_TYPE_PNG);
|
||||||
|
icons_->Add(*img_icon);
|
||||||
|
icon_idx = ++icon_count; // $icon_idx = $self->{icon_count} + 1; $self->{icon_count} = $icon_idx;
|
||||||
|
icon_index_[icon] = icon_idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Initialize the page.
|
||||||
|
CPageShp page(new CPage(this, title, icon_idx));
|
||||||
|
page->SetScrollbars(1, 1, 1, 1);
|
||||||
|
page->Hide();
|
||||||
|
hsizer_->Add(page.get(), 1, wxEXPAND | wxLEFT, 5);
|
||||||
|
pages_.push_back(page);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
auto page = add_options_page("Layers and perimeters", "layers.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
auto optgroup = page->new_optgroup("Layer height");
|
||||||
|
// optgroup->append_single_option_line("layer_height");
|
||||||
|
// optgroup->append_single_option_line("first_layer_height");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Vertical shells");
|
||||||
|
// $optgroup->append_single_option_line("perimeters");
|
||||||
|
// $optgroup->append_single_option_line("spiral_vase");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Horizontal shells");
|
||||||
|
// my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
||||||
|
// label = > "Solid layers",
|
||||||
|
// );
|
||||||
|
// $line->append_option($optgroup->get_option("top_solid_layers"));
|
||||||
|
// $line->append_option($optgroup->get_option("bottom_solid_layers"));
|
||||||
|
// $optgroup->append_line($line);
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Quality (slower slicing)");
|
||||||
|
// $optgroup->append_single_option_line("extra_perimeters");
|
||||||
|
// $optgroup->append_single_option_line("ensure_vertical_shell_thickness");
|
||||||
|
// $optgroup->append_single_option_line("avoid_crossing_perimeters");
|
||||||
|
// $optgroup->append_single_option_line("thin_walls");
|
||||||
|
// $optgroup->append_single_option_line("overhangs");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Advanced");
|
||||||
|
// $optgroup->append_single_option_line("seam_position");
|
||||||
|
// $optgroup->append_single_option_line("external_perimeters_first");
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Infill", "infill.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Infill");
|
||||||
|
// $optgroup->append_single_option_line("fill_density");
|
||||||
|
// $optgroup->append_single_option_line("fill_pattern");
|
||||||
|
// $optgroup->append_single_option_line("external_fill_pattern");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Reducing printing time");
|
||||||
|
// $optgroup->append_single_option_line("infill_every_layers");
|
||||||
|
// $optgroup->append_single_option_line("infill_only_where_needed");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Advanced");
|
||||||
|
// $optgroup->append_single_option_line("solid_infill_every_layers");
|
||||||
|
// $optgroup->append_single_option_line("fill_angle");
|
||||||
|
// $optgroup->append_single_option_line("solid_infill_below_area");
|
||||||
|
// $optgroup->append_single_option_line("bridge_angle");
|
||||||
|
// $optgroup->append_single_option_line("only_retract_when_crossing_perimeters");
|
||||||
|
// $optgroup->append_single_option_line("infill_first");
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Skirt and brim", "box.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Skirt");
|
||||||
|
// $optgroup->append_single_option_line("skirts");
|
||||||
|
// $optgroup->append_single_option_line("skirt_distance");
|
||||||
|
// $optgroup->append_single_option_line("skirt_height");
|
||||||
|
// $optgroup->append_single_option_line("min_skirt_length");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Brim");
|
||||||
|
// $optgroup->append_single_option_line("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("support_material");
|
||||||
|
// $optgroup->append_single_option_line("support_material_threshold");
|
||||||
|
// $optgroup->append_single_option_line("support_material_enforce_layers");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Raft");
|
||||||
|
// $optgroup->append_single_option_line("raft_layers");
|
||||||
|
// # $optgroup->append_single_option_line("raft_contact_distance");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Options for support material and raft");
|
||||||
|
// $optgroup->append_single_option_line("support_material_contact_distance");
|
||||||
|
// $optgroup->append_single_option_line("support_material_pattern");
|
||||||
|
// $optgroup->append_single_option_line("support_material_with_sheath");
|
||||||
|
// $optgroup->append_single_option_line("support_material_spacing");
|
||||||
|
// $optgroup->append_single_option_line("support_material_angle");
|
||||||
|
// $optgroup->append_single_option_line("support_material_interface_layers");
|
||||||
|
// $optgroup->append_single_option_line("support_material_interface_spacing");
|
||||||
|
// $optgroup->append_single_option_line("support_material_interface_contact_loops");
|
||||||
|
// $optgroup->append_single_option_line("support_material_buildplate_only");
|
||||||
|
// $optgroup->append_single_option_line("support_material_xy_spacing");
|
||||||
|
// $optgroup->append_single_option_line("dont_support_bridges");
|
||||||
|
// $optgroup->append_single_option_line("support_material_synchronize_layers");
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Speed", "time.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Speed for print moves");
|
||||||
|
// $optgroup->append_single_option_line("perimeter_speed");
|
||||||
|
// $optgroup->append_single_option_line("small_perimeter_speed");
|
||||||
|
// $optgroup->append_single_option_line("external_perimeter_speed");
|
||||||
|
// $optgroup->append_single_option_line("infill_speed");
|
||||||
|
// $optgroup->append_single_option_line("solid_infill_speed");
|
||||||
|
// $optgroup->append_single_option_line("top_solid_infill_speed");
|
||||||
|
// $optgroup->append_single_option_line("support_material_speed");
|
||||||
|
// $optgroup->append_single_option_line("support_material_interface_speed");
|
||||||
|
// $optgroup->append_single_option_line("bridge_speed");
|
||||||
|
// $optgroup->append_single_option_line("gap_fill_speed");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Speed for non-print moves");
|
||||||
|
// $optgroup->append_single_option_line("travel_speed");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Modifiers");
|
||||||
|
// $optgroup->append_single_option_line("first_layer_speed");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Acceleration control (advanced)");
|
||||||
|
// $optgroup->append_single_option_line("perimeter_acceleration");
|
||||||
|
// $optgroup->append_single_option_line("infill_acceleration");
|
||||||
|
// $optgroup->append_single_option_line("bridge_acceleration");
|
||||||
|
// $optgroup->append_single_option_line("first_layer_acceleration");
|
||||||
|
// $optgroup->append_single_option_line("default_acceleration");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Autospeed (advanced)");
|
||||||
|
// $optgroup->append_single_option_line("max_print_speed");
|
||||||
|
// $optgroup->append_single_option_line("max_volumetric_speed");
|
||||||
|
// $optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_positive");
|
||||||
|
// $optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_negative");
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Multiple Extruders", "funnel.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Extruders");
|
||||||
|
// $optgroup->append_single_option_line("perimeter_extruder");
|
||||||
|
// $optgroup->append_single_option_line("infill_extruder");
|
||||||
|
// $optgroup->append_single_option_line("solid_infill_extruder");
|
||||||
|
// $optgroup->append_single_option_line("support_material_extruder");
|
||||||
|
// $optgroup->append_single_option_line("support_material_interface_extruder");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Ooze prevention");
|
||||||
|
// $optgroup->append_single_option_line("ooze_prevention");
|
||||||
|
// $optgroup->append_single_option_line("standby_temperature_delta");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Wipe tower");
|
||||||
|
// $optgroup->append_single_option_line("wipe_tower");
|
||||||
|
// $optgroup->append_single_option_line("wipe_tower_x");
|
||||||
|
// $optgroup->append_single_option_line("wipe_tower_y");
|
||||||
|
// $optgroup->append_single_option_line("wipe_tower_width");
|
||||||
|
// $optgroup->append_single_option_line("wipe_tower_per_color_wipe");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Advanced");
|
||||||
|
// $optgroup->append_single_option_line("interface_shells");
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Advanced", "wrench.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Extrusion width", 180);
|
||||||
|
// $optgroup->append_single_option_line("extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("first_layer_extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("perimeter_extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("external_perimeter_extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("infill_extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("solid_infill_extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("top_infill_extrusion_width");
|
||||||
|
// $optgroup->append_single_option_line("support_material_extrusion_width");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Overlap");
|
||||||
|
// $optgroup->append_single_option_line("infill_overlap");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Flow");
|
||||||
|
// $optgroup->append_single_option_line("bridge_flow_ratio");
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Other");
|
||||||
|
// $optgroup->append_single_option_line("clip_multipart_objects");
|
||||||
|
// $optgroup->append_single_option_line("elefant_foot_compensation");
|
||||||
|
// $optgroup->append_single_option_line("xy_size_compensation");
|
||||||
|
// # $optgroup->append_single_option_line("threads");
|
||||||
|
// $optgroup->append_single_option_line("resolution");
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Output options", "page_white_go.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Sequential printing");
|
||||||
|
// $optgroup->append_single_option_line("complete_objects");
|
||||||
|
// my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
||||||
|
// label = > "Extruder clearance (mm)",
|
||||||
|
// );
|
||||||
|
// foreach my $opt_key(qw(extruder_clearance_radius extruder_clearance_height)) {
|
||||||
|
// my $option = $optgroup->get_option($opt_key);
|
||||||
|
// $option->width(60);
|
||||||
|
// $line->append_option($option);
|
||||||
|
// }
|
||||||
|
// $optgroup->append_line($line);
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Output file");
|
||||||
|
// $optgroup->append_single_option_line("gcode_comments");
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// my $option = $optgroup->get_option("output_filename_format");
|
||||||
|
// $option->full_width(1);
|
||||||
|
// $optgroup->append_single_option_line($option);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Post-processing scripts");
|
||||||
|
// label_width = > 0,
|
||||||
|
// );
|
||||||
|
// my $option = $optgroup->get_option("post_process");
|
||||||
|
// $option->full_width(1);
|
||||||
|
// $option->height(50);
|
||||||
|
// $optgroup->append_single_option_line($option);
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Notes", "note.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Notes"); //label_width = > 0,
|
||||||
|
// my $option = $optgroup->get_option("notes");
|
||||||
|
// $option->full_width(1);
|
||||||
|
// $option->height(250);
|
||||||
|
// $optgroup->append_single_option_line($option);
|
||||||
|
// }
|
||||||
|
|
||||||
|
page = add_options_page("Dependencies", "wrench.png");
|
||||||
|
page->set_config(&config_);
|
||||||
|
// {
|
||||||
|
optgroup = page->new_optgroup("Profile dependencies");
|
||||||
|
// {
|
||||||
|
// my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
||||||
|
// label = > "Compatible printers",
|
||||||
|
// widget = > $self->_compatible_printers_widget,
|
||||||
|
// );
|
||||||
|
// $optgroup->append_line($line);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Regerenerate content of the page tree.
|
||||||
|
void CTab::rebuild_page_tree()
|
||||||
|
{
|
||||||
|
Freeze();
|
||||||
|
// get label of the currently selected item
|
||||||
|
auto selected = treectrl_->GetItemText(treectrl_->GetSelection());
|
||||||
|
auto rootItem = treectrl_->GetRootItem();
|
||||||
|
treectrl_->DeleteChildren(rootItem);
|
||||||
|
auto have_selection = 0;
|
||||||
|
for (auto p : pages_)
|
||||||
|
{
|
||||||
|
auto itemId = treectrl_->AppendItem(rootItem, p->title(), p->iconID());
|
||||||
|
if (p->title() == selected) {
|
||||||
|
disable_tree_sel_changed_event_ = 1;
|
||||||
|
treectrl_->SelectItem(itemId);
|
||||||
|
disable_tree_sel_changed_event_ = 0;
|
||||||
|
have_selection = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!have_selection) {
|
||||||
|
// this is triggered on first load, so we don't disable the sel change event
|
||||||
|
treectrl_->SelectItem(treectrl_->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem));
|
||||||
|
}
|
||||||
|
Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTab::OnTreeSelChange(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
if (disable_tree_sel_changed_event_) return;
|
||||||
CPage* page = nullptr;
|
CPage* page = nullptr;
|
||||||
for (auto& el : pages)
|
auto selection = treectrl_->GetItemText(treectrl_->GetSelection());
|
||||||
if (el.title() == treectrl->GetSelection())
|
for (auto p : pages_)
|
||||||
|
if (p->title() == selection)
|
||||||
{
|
{
|
||||||
page = ⪙
|
page = p.get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (page == nullptr) return;
|
if (page == nullptr) return;
|
||||||
|
|
||||||
for (auto& el : pages)
|
for (auto& el : pages_)
|
||||||
el.Hide();
|
el.get()->Hide();
|
||||||
page->Show();
|
page->Show();
|
||||||
hsizer->Layout();
|
hsizer_->Layout();
|
||||||
this->Refresh();
|
Refresh();
|
||||||
};
|
}
|
||||||
|
|
||||||
void CTab::OnKeyDown(wxKeyEvent& event)
|
void CTab::OnKeyDown(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
event.GetKeyCode() == WXK_TAB ?
|
event.GetKeyCode() == WXK_TAB ?
|
||||||
treectrl->Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward) :
|
treectrl_->Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward) :
|
||||||
event.Skip();
|
event.Skip();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -169,5 +506,27 @@ void CTab::save_preset(wxCommandEvent &event){};
|
|||||||
void CTab::delete_preset(wxCommandEvent &event){};
|
void CTab::delete_preset(wxCommandEvent &event){};
|
||||||
void CTab::_toggle_show_hide_incompatible(wxCommandEvent &event){};
|
void CTab::_toggle_show_hide_incompatible(wxCommandEvent &event){};
|
||||||
|
|
||||||
|
// package Slic3r::GUI::Tab::Page;
|
||||||
|
ConfigOptionsGroupShp CPage::new_optgroup(std::string title, size_t label_width /*= 0*/)
|
||||||
|
{
|
||||||
|
//! config_ have to be "right"
|
||||||
|
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(/*parent()*/this, title, config_);
|
||||||
|
if (label_width != 0)
|
||||||
|
optgroup->label_width = label_width;
|
||||||
|
|
||||||
|
// on_change => sub {
|
||||||
|
// my ($opt_key, $value) = @_;
|
||||||
|
// wxTheApp->CallAfter(sub {
|
||||||
|
// $self->GetParent->update_dirty;
|
||||||
|
// $self->GetParent->_on_value_change($opt_key, $value);
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
|
||||||
|
vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||||
|
optgroups.push_back(optgroup);
|
||||||
|
|
||||||
|
return optgroup;
|
||||||
|
}
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
@ -20,89 +20,114 @@
|
|||||||
#include <wx/bmpbuttn.h>
|
#include <wx/bmpbuttn.h>
|
||||||
#include <wx/treectrl.h>
|
#include <wx/treectrl.h>
|
||||||
#include <wx/imaglist.h>
|
#include <wx/imaglist.h>
|
||||||
|
#include <wx/statbox.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "OptionsGroup.hpp"
|
||||||
|
|
||||||
|
//!enum { ID_TAB_TREE = wxID_HIGHEST + 1 };
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
// Single Tab page containing a{ vsizer } of{ optgroups }
|
// Single Tab page containing a{ vsizer } of{ optgroups }
|
||||||
// package Slic3r::GUI::Tab::Page;
|
// package Slic3r::GUI::Tab::Page;
|
||||||
|
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
|
||||||
class CPage : public wxScrolledWindow
|
class CPage : public wxScrolledWindow
|
||||||
{
|
{
|
||||||
const char* _title;
|
wxWindow* parent_;
|
||||||
wxWindow* _parent;
|
wxString title_;
|
||||||
wxBoxSizer* _vsizer;
|
size_t iconID_;
|
||||||
size_t _iconID;
|
wxBoxSizer* vsizer_;
|
||||||
// const OptionsGroup opt; // $self->{optgroups} = [];
|
|
||||||
public:
|
public:
|
||||||
CPage(){};
|
CPage(wxWindow* parent, const wxString title, const int iconID) :
|
||||||
CPage(wxWindow* parent, const char* title, int iconID) :
|
parent_(parent),
|
||||||
_parent(parent),
|
title_(title),
|
||||||
_title(title),
|
iconID_(iconID)
|
||||||
_iconID(iconID)
|
|
||||||
{
|
{
|
||||||
Create(_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
Create(parent_, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||||
this->SetScrollbars(1, 1, 1, 1);
|
vsizer_ = new wxBoxSizer(wxVERTICAL);
|
||||||
_vsizer = new wxBoxSizer(wxVERTICAL);
|
SetSizer(vsizer_);
|
||||||
this->SetSizer(_vsizer);
|
|
||||||
}
|
}
|
||||||
~CPage(){};
|
~CPage(){}
|
||||||
wxBoxSizer * vsizer(){ return this->_vsizer; }
|
|
||||||
wxString title(){ return wxString(_title); }
|
public:
|
||||||
|
std::vector <ConfigOptionsGroupShp> optgroups; // $self->{optgroups} = [];
|
||||||
|
DynamicPrintConfig* config_;
|
||||||
|
|
||||||
|
wxBoxSizer* vsizer() const { return vsizer_; }
|
||||||
|
wxWindow* parent() const { return parent_; }
|
||||||
|
wxString title() const { return title_; }
|
||||||
|
size_t iconID() const { return iconID_; }
|
||||||
|
void set_config(DynamicPrintConfig* config_in) { config_ = config_in; }
|
||||||
|
|
||||||
|
ConfigOptionsGroupShp new_optgroup(std::string title, size_t label_width = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Slic3r::GUI::Tab;
|
// Slic3r::GUI::Tab;
|
||||||
|
|
||||||
|
using CPageShp = std::shared_ptr<CPage>;
|
||||||
class CTab: public wxPanel
|
class CTab: public wxPanel
|
||||||
{
|
{
|
||||||
|
wxNotebook* parent_;
|
||||||
protected:
|
protected:
|
||||||
const char* _title;
|
const char* title_;
|
||||||
wxBitmapComboBox* presets_choice;
|
wxBitmapComboBox* presets_choice_;
|
||||||
wxBitmap* bmp_show_incompatible_presets;
|
wxBitmapButton* btn_save_preset_;
|
||||||
wxBitmap* bmp_hide_incompatible_presets;
|
wxBitmapButton* btn_delete_preset_;
|
||||||
wxBitmapButton* btn_hide_incompatible_presets;
|
wxBitmap* bmp_show_incompatible_presets_;
|
||||||
wxBoxSizer* hsizer;
|
wxBitmap* bmp_hide_incompatible_presets_;
|
||||||
wxBoxSizer* left_sizer;
|
wxBitmapButton* btn_hide_incompatible_presets_;
|
||||||
wxTreeCtrl* treectrl;
|
wxBoxSizer* hsizer_;
|
||||||
wxImageList* icons;
|
wxBoxSizer* left_sizer_;
|
||||||
int icon_count;
|
wxTreeCtrl* treectrl_;
|
||||||
// std::map<size_t, wxImageList*> icon_index;
|
wxImageList* icons_;
|
||||||
std::vector<CPage> pages;
|
int icon_count;
|
||||||
bool disable_tree_sel_changed_event;
|
std::map<wxString, size_t> icon_index_; // Map from an icon file name to its index in $self->{icons}.
|
||||||
public:
|
std::vector<CPageShp> pages_; // $self->{pages} = [];
|
||||||
CTab(){};
|
bool disable_tree_sel_changed_event_;
|
||||||
CTab(wxNotebook* parent, const char *title/*, someParams*/){}
|
|
||||||
~CTab(){};
|
|
||||||
|
|
||||||
void create_preset_tab();
|
|
||||||
void OnTreeSelChange(wxCommandEvent& event);
|
|
||||||
void OnKeyDown(wxKeyEvent& event);
|
|
||||||
void OnComboBox(wxCommandEvent& event){ /*$self->select_preset(presets_choice->GetStringSelection)*/ };
|
|
||||||
void save_preset(wxCommandEvent &event);
|
|
||||||
void delete_preset(wxCommandEvent &event);
|
|
||||||
void _toggle_show_hide_incompatible(wxCommandEvent &event);
|
|
||||||
|
|
||||||
// virtual void build(/*%params*/);
|
public:
|
||||||
// virtual void rebuild_page_tree();
|
DynamicPrintConfig config_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CTab() {}
|
||||||
|
CTab(wxNotebook* parent, const char *title) : parent_(parent), title_(title) {
|
||||||
|
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
||||||
|
}
|
||||||
|
~CTab(){}
|
||||||
|
|
||||||
|
wxWindow* parent() const { return parent_; }
|
||||||
|
|
||||||
|
void create_preset_tab();
|
||||||
|
void rebuild_page_tree();
|
||||||
|
void select_preset(wxString preset_name){};
|
||||||
|
|
||||||
|
void OnTreeSelChange(wxTreeEvent& event);
|
||||||
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
|
void OnComboBox(wxCommandEvent& event) { select_preset(presets_choice_->GetStringSelection()); }
|
||||||
|
void save_preset(wxCommandEvent &event);
|
||||||
|
void delete_preset(wxCommandEvent &event);
|
||||||
|
void _toggle_show_hide_incompatible(wxCommandEvent &event);
|
||||||
|
|
||||||
|
std::shared_ptr<CPage> add_options_page(wxString title, wxString icon);
|
||||||
|
|
||||||
|
virtual void build() = 0;
|
||||||
// virtual void _update();
|
// virtual void _update();
|
||||||
private:
|
|
||||||
// DECLARE_EVENT_TABLE()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Slic3r::GUI::Tab::Print;
|
//Slic3r::GUI::Tab::Print;
|
||||||
class CTabPrint : public CTab
|
class CTabPrint : public CTab
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTabPrint() {};
|
CTabPrint() {}
|
||||||
CTabPrint(wxNotebook* parent, const char *title/*, someParams*/)
|
CTabPrint(wxNotebook* parent, const char *title/*, someParams*/) : CTab(parent, title) {}
|
||||||
{
|
~CTabPrint(){}
|
||||||
_title = title;
|
|
||||||
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
void build() override;
|
||||||
create_preset_tab();
|
|
||||||
}
|
|
||||||
~CTabPrint(){};
|
|
||||||
// void build(/*%params*/){};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef WIDGET_HPP
|
#ifndef WIDGET_HPP
|
||||||
#define WIDGET_HPP
|
#define WIDGET_HPP
|
||||||
#include "wxinit.h"
|
#include <wx/wxprec.h>
|
||||||
|
#ifndef WX_PRECOM
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class Widget {
|
class Widget {
|
||||||
protected:
|
protected:
|
||||||
wxSizer* _sizer;
|
wxSizer* _sizer;
|
||||||
|
Loading…
Reference in New Issue
Block a user