Filling the Print's Tab. Finished. It's need to adding functions to work with presets
This commit is contained in:
parent
281fd26e06
commit
67f2469e70
5 changed files with 100 additions and 24 deletions
|
@ -193,23 +193,7 @@ void create_preset_tab(const char *name)
|
|||
{
|
||||
CTabPrint* panel = new CTabPrint(g_wxTabPanel, name);
|
||||
panel->create_preset_tab();
|
||||
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
|
||||
|
||||
g_wxTabPanel->AddPage(panel, name);
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "OptionsGroup.hpp"
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "ConfigExceptions.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
@ -127,7 +127,7 @@ void OptionsGroup::append_line(const Line& line) {
|
|||
|
||||
// add sidetext if any
|
||||
if (option.sidetext != "") {
|
||||
auto sidetext = new wxStaticText(parent(), wxID_ANY, option.sidetext, wxDefaultPosition, wxDefaultSize);
|
||||
auto sidetext = new wxStaticText(parent(), wxID_ANY, wxString::FromUTF8(option.sidetext.c_str()), wxDefaultPosition, wxDefaultSize);
|
||||
sidetext->SetFont(sidetext_font);
|
||||
sizer->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
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 widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>;
|
||||
using column_t = std::function<wxSizer*(const Line&)>;
|
||||
|
||||
class StaticText;
|
||||
|
@ -65,7 +65,6 @@ private:
|
|||
};
|
||||
|
||||
using t_optionfield_map = std::map<t_config_option_key, t_field>;
|
||||
using t_optionoption_map = std::map<t_config_option_key, t_option>; //!
|
||||
|
||||
class OptionsGroup {
|
||||
public:
|
||||
|
@ -114,7 +113,7 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
/*const t_optionoption_map& options; //*/const t_optiondef_map& options; //!
|
||||
const t_optiondef_map& options;
|
||||
wxWindow* _parent {nullptr};
|
||||
|
||||
/// Field list, contains unique_ptrs of the derived type.
|
||||
|
|
|
@ -316,7 +316,7 @@ void CTabPrint::build()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
page = add_options_page("Notes", "note.png");
|
||||
optgroup = page->new_optgroup("Notes"); //! label_width = > 0,
|
||||
optgroup = page->new_optgroup("Notes");
|
||||
option = get_option_("notes");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 250;
|
||||
|
@ -325,7 +325,7 @@ void CTabPrint::build()
|
|||
page = add_options_page("Dependencies", "wrench.png");
|
||||
optgroup = page->new_optgroup("Profile dependencies");
|
||||
line = Line{ "Compatible printers", "" };
|
||||
// line.widget = ? ? ? ; //! widget = > $self->_compatible_printers_widget,
|
||||
line.widget = compatible_printers_widget_;
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
|
@ -387,6 +387,94 @@ void CTab::save_preset(wxCommandEvent &event){};
|
|||
void CTab::delete_preset(wxCommandEvent &event){};
|
||||
void CTab::_toggle_show_hide_incompatible(wxCommandEvent &event){};
|
||||
|
||||
// # Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer.
|
||||
wxSizer* CTab::compatible_printers_widget_(wxWindow* parent)
|
||||
{
|
||||
auto checkbox /*= compatible_printers_checkbox*/ = new wxCheckBox(parent, wxID_ANY, "All");
|
||||
|
||||
auto btn /*= compatible_printers_btn*/ = new wxButton(parent, wxID_ANY, "Set…", wxDefaultPosition, wxDefaultSize,
|
||||
wxBU_LEFT | wxBU_EXACTFIT);
|
||||
// btn->SetFont(GUI::small_font);
|
||||
btn->SetBitmap(wxBitmap(wxT("var\\printer_empty.png"), wxBITMAP_TYPE_PNG));
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(checkbox, 0, wxALIGN_CENTER_VERTICAL);
|
||||
sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
checkbox->Bind(wxEVT_CHECKBOX, ([=](wxCommandEvent e)
|
||||
{
|
||||
btn->Enable(!checkbox->GetValue());
|
||||
// # All printers have been made compatible with this preset.
|
||||
// _load_key_value('compatible_printers', []) if checkbox->GetValue();
|
||||
}) );
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, ([=](wxCommandEvent e)
|
||||
{
|
||||
PresetCollection *prints = new PresetCollection(Preset::TYPE_PRINT, Preset::print_options());
|
||||
prints->preset(0).config.opt_string("print_settings_id", true);
|
||||
prints->preset(0).config.optptr("compatible_printers", true);
|
||||
DynamicPrintConfig config_ = prints->get_edited_preset().config;
|
||||
|
||||
// # Collect names of non-default non-external printer profiles.
|
||||
PresetCollection *printers = new PresetCollection(Preset::TYPE_PRINTER, Preset::print_options());
|
||||
printers->preset(0).config.opt_string("print_settings_id", true);
|
||||
wxArrayString presets;
|
||||
for (size_t idx = 0; idx < printers->size(); ++idx)
|
||||
{
|
||||
Preset& preset = printers->preset(idx);
|
||||
if (!preset.is_default && !preset.is_external)
|
||||
presets.Add(preset.name);
|
||||
}
|
||||
|
||||
auto dlg = new wxMultiChoiceDialog(parent,
|
||||
"Select the printers this profile is compatible with.",
|
||||
"Compatible printers", presets);
|
||||
// # Collect and set indices of printers marked as compatible.
|
||||
wxArrayInt selections;
|
||||
auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(config_.option("compatible_printers"));
|
||||
if (compatible_printers != nullptr || !compatible_printers->values.empty())
|
||||
for (auto preset_name : compatible_printers->values)
|
||||
for (size_t idx = 0; idx < presets.GetCount(); ++idx)
|
||||
if (presets[idx].compare(preset_name) == 0)
|
||||
{
|
||||
selections.Add(idx);
|
||||
break;
|
||||
}
|
||||
dlg->SetSelections(selections);
|
||||
// # Show the dialog.
|
||||
if (dlg->ShowModal() == wxID_OK) {
|
||||
selections.Clear();
|
||||
selections = dlg->GetSelections();
|
||||
std::vector<std::string> value;
|
||||
for (auto idx : selections)
|
||||
value.push_back(presets[idx].ToStdString());
|
||||
if (/*!@$value*/value.empty()) {
|
||||
checkbox->SetValue(1);
|
||||
btn->Disable();
|
||||
}
|
||||
// # All printers have been made compatible with this preset.
|
||||
// _load_key_value('compatible_printers', $value);
|
||||
}
|
||||
}));
|
||||
return sizer;
|
||||
}
|
||||
|
||||
void CTab::load_key_value_(std::string opt_key, std::vector<std::string> value)
|
||||
{
|
||||
// # To be called by custom widgets, load a value into a config,
|
||||
// # update the preset selection boxes (the dirty flags)
|
||||
// $self->{config}->set($opt_key, $value);
|
||||
// # Mark the print & filament enabled if they are compatible with the currently selected preset.
|
||||
if (opt_key.compare("compatible_printers")==0) {
|
||||
// wxTheApp->{preset_bundle}->update_compatible_with_printer(0);
|
||||
// $self->{presets}->update_tab_ui($self->{presets_choice}, $self->{show_incompatible_presets});
|
||||
// } else {
|
||||
// $self->{presets}->update_dirty_ui($self->{presets_choice});
|
||||
}
|
||||
// $self->_on_presets_changed;
|
||||
// $self->_update;
|
||||
}
|
||||
|
||||
// package Slic3r::GUI::Tab::Page;
|
||||
ConfigOptionsGroupShp CPage::new_optgroup(std::string title, size_t label_width /*= 0*/)
|
||||
{
|
||||
|
|
|
@ -85,6 +85,8 @@ protected:
|
|||
wxBoxSizer* left_sizer_;
|
||||
wxTreeCtrl* treectrl_;
|
||||
wxImageList* icons_;
|
||||
wxCheckBox* compatible_printers_checkbox_;
|
||||
wxButton* compatible_printers_btn;
|
||||
int icon_count;
|
||||
std::map<wxString, size_t> icon_index_; // Map from an icon file name to its index in $self->{icons}.
|
||||
std::vector<CPageShp> pages_; // $self->{pages} = [];
|
||||
|
@ -107,6 +109,9 @@ public:
|
|||
void rebuild_page_tree();
|
||||
void select_preset(wxString preset_name){};
|
||||
|
||||
static wxSizer* compatible_printers_widget_(wxWindow* parent);
|
||||
void load_key_value_(std::string opt_key, std::vector<std::string> value);
|
||||
|
||||
void OnTreeSelChange(wxTreeEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
void OnComboBox(wxCommandEvent& event) { select_preset(presets_choice_->GetStringSelection()); }
|
||||
|
|
Loading…
Reference in a new issue