Added class ogStaticText to the static text shown among the options.

Fixed bugs in Tab.
This commit is contained in:
YuSanka 2018-01-15 12:13:05 +01:00
parent 8e0cd35c23
commit 636af8933c
5 changed files with 76 additions and 46 deletions

View file

@ -192,7 +192,8 @@ void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config)
add_created_tab(new TabPrinter (g_wxTabPanel, "Printer"), preset_bundle, app_config); add_created_tab(new TabPrinter (g_wxTabPanel, "Printer"), preset_bundle, app_config);
g_wxTabPanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, ([](wxCommandEvent e){ g_wxTabPanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, ([](wxCommandEvent e){
Tab* panel = (Tab*)g_wxTabPanel->GetCurrentPage(); Tab* panel = (Tab*)g_wxTabPanel->GetCurrentPage();
if (panel->GetName().compare("Filament")==0) if (panel->GetName().compare("Print")==0 ||
panel->GetName().compare("Filament") == 0)
panel->OnActivate(); panel->OnActivate();
}), g_wxTabPanel->GetId() ); }), g_wxTabPanel->GetId() );
} }

View file

@ -376,5 +376,12 @@ Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index
return opt_id.empty() ? nullptr : get_field(opt_id); return opt_id.empty() ? nullptr : get_field(opt_id);
} }
void ogStaticText::SetText(wxString value)
{
SetLabel(value);
Wrap(400);
GetParent()->Layout();
}
} // GUI } // GUI
} // Slic3r } // Slic3r

View file

@ -29,8 +29,6 @@ namespace Slic3r { namespace GUI {
using widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>; using widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>;
using column_t = std::function<wxSizer*(const Line&)>; using column_t = std::function<wxSizer*(const Line&)>;
class StaticText;
/// Wraps a ConfigOptionDef and adds function object for creating a side_widget. /// Wraps a ConfigOptionDef and adds function object for creating a side_widget.
struct Option { struct Option {
ConfigOptionDef opt { ConfigOptionDef() }; ConfigOptionDef opt { ConfigOptionDef() };
@ -169,4 +167,15 @@ public:
Field* get_fieldc(t_config_option_key opt_key, int opt_index); Field* get_fieldc(t_config_option_key opt_key, int opt_index);
}; };
// Static text shown among the options.
// Currently used for the filament cooling legend only.
class ogStaticText :public wxStaticText{
public:
ogStaticText() {}
ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize){}
~ogStaticText(){}
void SetText(wxString value);
};
}} }}

View file

@ -259,8 +259,15 @@ void TabPrint::build()
optgroup->append_single_option_line("perimeters"); optgroup->append_single_option_line("perimeters");
optgroup->append_single_option_line("spiral_vase"); optgroup->append_single_option_line("spiral_vase");
Line line { "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
return description_line_widget(parent, &m_recommended_thin_wall_thickness_description_line);
};
optgroup->append_line(line);
optgroup = page->new_optgroup("Horizontal shells"); optgroup = page->new_optgroup("Horizontal shells");
Line line{ "Solid layers", "" }; line = { "Solid layers", "" };
line.append_option(optgroup->get_option("top_solid_layers")); line.append_option(optgroup->get_option("top_solid_layers"));
line.append_option(optgroup->get_option("bottom_solid_layers")); line.append_option(optgroup->get_option("bottom_solid_layers"));
optgroup->append_line(line); optgroup->append_line(line);
@ -441,10 +448,7 @@ void TabPrint::build()
optgroup = page->new_optgroup("Profile dependencies"); optgroup = page->new_optgroup("Profile dependencies");
line = Line{ "Compatible printers", "" }; line = Line{ "Compatible printers", "" };
line.widget = [this](wxWindow* parent){ line.widget = [this](wxWindow* parent){
m_compatible_printers_checkbox = new wxCheckBox(parent, wxID_ANY, "All"); return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn);
m_compatible_printers_btn = new wxButton(parent, wxID_ANY, "Set…", wxDefaultPosition,
wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
return compatible_printers_widget(parent, m_compatible_printers_checkbox, m_compatible_printers_btn);
}; };
optgroup->append_line(line); optgroup->append_line(line);
@ -700,9 +704,17 @@ void TabPrint::update()
for (auto el : vec_enable) for (auto el : vec_enable)
get_field(el)->toggle(have_wipe_tower); get_field(el)->toggle(have_wipe_tower);
m_recommended_thin_wall_thickness_description_line->SetText(
PresetHints::recommended_thin_wall_thickness(*m_preset_bundle));
Thaw(); Thaw();
} }
void TabPrint::OnActivate()
{
m_recommended_thin_wall_thickness_description_line->SetText(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle));
}
void TabFilament::build() void TabFilament::build()
{ {
m_presets = &m_preset_bundle->filaments; m_presets = &m_preset_bundle->filaments;
@ -735,8 +747,7 @@ void TabFilament::build()
line = { "", "" }; line = { "", "" };
line.full_width = 1; line.full_width = 1;
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
m_cooling_description_line = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxSize(400, -1)); return description_line_widget(parent, &m_cooling_description_line);
return description_line_widget(parent, m_cooling_description_line);
}; };
optgroup->append_line(line); optgroup->append_line(line);
@ -765,8 +776,7 @@ void TabFilament::build()
line = {"",""}; line = {"",""};
line.full_width = 1; line.full_width = 1;
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
m_volumetric_speed_description_line = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxSize(400, -1)); return description_line_widget(parent, &m_volumetric_speed_description_line);
return description_line_widget(parent, m_volumetric_speed_description_line);
}; };
optgroup->append_line(line); optgroup->append_line(line);
@ -795,10 +805,7 @@ void TabFilament::build()
optgroup = page->new_optgroup("Profile dependencies"); optgroup = page->new_optgroup("Profile dependencies");
line = {"Compatible printers", ""}; line = {"Compatible printers", ""};
line.widget = [this](wxWindow* parent){ line.widget = [this](wxWindow* parent){
m_compatible_printers_checkbox = new wxCheckBox(parent, wxID_ANY, "All"); return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn);
m_compatible_printers_btn = new wxButton(parent, wxID_ANY, "Set…", wxDefaultPosition,
wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
return compatible_printers_widget(parent, m_compatible_printers_checkbox, m_compatible_printers_btn);
}; };
optgroup->append_line(line); optgroup->append_line(line);
@ -816,9 +823,9 @@ void TabFilament::reload_config(){
void TabFilament::update() void TabFilament::update()
{ {
wxString text = wxString::FromUTF8(PresetHints::cooling_description(m_presets->get_edited_preset()).c_str()); wxString text = wxString::FromUTF8(PresetHints::cooling_description(m_presets->get_edited_preset()).c_str());
m_cooling_description_line->SetLabel(text); m_cooling_description_line->SetText(text);
text = wxString::FromUTF8(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle).c_str()); text = wxString::FromUTF8(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle).c_str());
m_volumetric_speed_description_line->SetLabel(text); m_volumetric_speed_description_line->SetText(text);
bool cooling = m_config->opt_bool("cooling", 0); bool cooling = m_config->opt_bool("cooling", 0);
bool fan_always_on = cooling || m_config->opt_bool("fan_always_on", 0); bool fan_always_on = cooling || m_config->opt_bool("fan_always_on", 0);
@ -835,17 +842,18 @@ void TabFilament::update()
void TabFilament::OnActivate() void TabFilament::OnActivate()
{ {
m_volumetric_speed_description_line->SetLabel(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle)); m_volumetric_speed_description_line->SetText(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle));
} }
wxSizer* TabFilament::description_line_widget(wxWindow* parent, wxStaticText* StaticText) wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticText)
{ {
*StaticText = new ogStaticText(parent, "");
auto font = (new wxSystemSettings)->GetFont(wxSYS_DEFAULT_GUI_FONT); auto font = (new wxSystemSettings)->GetFont(wxSYS_DEFAULT_GUI_FONT);
StaticText->SetFont(font); (*StaticText)->SetFont(font);
StaticText->GetParent()->Layout();
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(StaticText); sizer->Add(*StaticText);
return sizer; return sizer;
} }
@ -1096,12 +1104,10 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){
} }
void TabPrinter::build_extruder_pages(){ void TabPrinter::build_extruder_pages(){
std::vector<PageShp> extruder_pages; for (auto extruder_idx = m_extruder_pages.size()/*0*/; extruder_idx < m_extruders_count; ++extruder_idx){
for (auto extruder_idx = 0; extruder_idx < m_extruders_count; ++extruder_idx){
//# build page //# build page
auto page = add_options_page("Extruder " + wxString::Format(_T("%i"), extruder_idx + 1), "funnel.png", true); auto page = add_options_page("Extruder " + wxString::Format(_T("%i"), extruder_idx + 1), "funnel.png", true);
extruder_pages.push_back(page); m_extruder_pages.push_back(page);
auto optgroup = page->new_optgroup("Size"); auto optgroup = page->new_optgroup("Size");
optgroup->append_single_option_line("nozzle_diameter", extruder_idx); optgroup->append_single_option_line("nozzle_diameter", extruder_idx);
@ -1139,14 +1145,16 @@ void TabPrinter::build_extruder_pages(){
} }
// # remove extra pages // # remove extra pages
if (m_extruders_count <= extruder_pages.size()) { if (m_extruders_count <= m_extruder_pages.size()) {
extruder_pages.resize(m_extruders_count); m_extruder_pages.resize(m_extruders_count);
} }
// # rebuild page list // # rebuild page list
PageShp page_note = m_pages.back(); PageShp page_note = m_pages.back();
m_pages.pop_back(); m_pages.pop_back();
for (auto page_extruder : extruder_pages) while (m_pages.back()->title().find("Extruder") != std::string::npos)
m_pages.pop_back();
for (auto page_extruder : m_extruder_pages)
m_pages.push_back(page_extruder); m_pages.push_back(page_extruder);
m_pages.push_back(page_note); m_pages.push_back(page_note);
@ -1302,24 +1310,27 @@ void Tab::delete_preset(wxCommandEvent &event){};
void Tab::toggle_show_hide_incompatible(wxCommandEvent &event){}; void Tab::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. // # Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer.
wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox* checkbox, wxButton* btn) wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn)
{ {
btn->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("printer_empty.png").c_str()), wxBITMAP_TYPE_PNG)); *checkbox = new wxCheckBox(parent, wxID_ANY, "All");
*btn = new wxButton(parent, wxID_ANY, "Set…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
(*btn)->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("printer_empty.png").c_str()), wxBITMAP_TYPE_PNG));
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(checkbox, 0, wxALIGN_CENTER_VERTICAL); sizer->Add((*checkbox), 0, wxALIGN_CENTER_VERTICAL);
sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL); sizer->Add((*btn), 0, wxALIGN_CENTER_VERTICAL);
checkbox->Bind(wxEVT_CHECKBOX, ([=](wxCommandEvent e) (*checkbox)->Bind(wxEVT_CHECKBOX, ([=](wxCommandEvent e)
{ {
btn->Enable(!checkbox->GetValue()); (*btn)->Enable(!(*checkbox)->GetValue());
// All printers have been made compatible with this preset. // All printers have been made compatible with this preset.
if (checkbox->GetValue()) if ((*checkbox)->GetValue())
load_key_value("compatible_printers", std::vector<std::string> {}); load_key_value("compatible_printers", std::vector<std::string> {});
get_field("compatible_printers_condition")->toggle(checkbox->GetValue()); get_field("compatible_printers_condition")->toggle((*checkbox)->GetValue());
}) ); }) );
btn->Bind(wxEVT_BUTTON, ([this, parent, checkbox, btn](wxCommandEvent e) (*btn)->Bind(wxEVT_BUTTON, ([this, parent, checkbox, btn](wxCommandEvent e)
{ {
// # Collect names of non-default non-external printer profiles. // # Collect names of non-default non-external printer profiles.
PresetCollection *printers = &m_preset_bundle->printers; PresetCollection *printers = &m_preset_bundle->printers;
@ -1354,8 +1365,8 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox* checkbox,
for (auto idx : selections) for (auto idx : selections)
value.push_back(presets[idx].ToStdString()); value.push_back(presets[idx].ToStdString());
if (value.empty()) { if (value.empty()) {
checkbox->SetValue(1); (*checkbox)->SetValue(1);
btn->Disable(); (*btn)->Disable();
} }
// All printers have been made compatible with this preset. // All printers have been made compatible with this preset.
load_key_value("compatible_printers", value); load_key_value("compatible_printers", value);

View file

@ -123,7 +123,7 @@ public:
void rebuild_page_tree(); void rebuild_page_tree();
void select_preset(wxString preset_name){}; void select_preset(wxString preset_name){};
wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox* checkbox, wxButton* btn); wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn);
void load_key_value(std::string opt_key, boost::any value); void load_key_value(std::string opt_key, boost::any value);
void reload_compatible_printers_widget(); void reload_compatible_printers_widget();
@ -144,6 +144,7 @@ public:
void load_config(DynamicPrintConfig config); void load_config(DynamicPrintConfig config);
virtual void reload_config(); virtual void reload_config();
Field* get_field(t_config_option_key opt_key, int opt_index = -1) const; Field* get_field(t_config_option_key opt_key, int opt_index = -1) const;
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText);
}; };
//Slic3r::GUI::Tab::Print; //Slic3r::GUI::Tab::Print;
@ -154,25 +155,25 @@ public:
TabPrint(wxNotebook* parent, const char *title) : Tab(parent, title) {} TabPrint(wxNotebook* parent, const char *title) : Tab(parent, title) {}
~TabPrint(){} ~TabPrint(){}
ogStaticText* m_recommended_thin_wall_thickness_description_line;
bool m_support_material_overhangs_queried = false; bool m_support_material_overhangs_queried = false;
void build() override; void build() override;
void reload_config() override; void reload_config() override;
void update() override; void update() override;
void OnActivate();
}; };
//Slic3r::GUI::Tab::Filament; //Slic3r::GUI::Tab::Filament;
class TabFilament : public Tab class TabFilament : public Tab
{ {
wxStaticText* m_volumetric_speed_description_line; ogStaticText* m_volumetric_speed_description_line;
wxStaticText* m_cooling_description_line; ogStaticText* m_cooling_description_line;
public: public:
TabFilament() {} TabFilament() {}
TabFilament(wxNotebook* parent, const char *title) : Tab(parent, title) {} TabFilament(wxNotebook* parent, const char *title) : Tab(parent, title) {}
~TabFilament(){} ~TabFilament(){}
wxSizer* description_line_widget(wxWindow* parent, wxStaticText* StaticText);
void build() override; void build() override;
void reload_config() override; void reload_config() override;
void update() override; void update() override;
@ -188,6 +189,7 @@ public:
wxButton* m_octoprint_host_test_btn; wxButton* m_octoprint_host_test_btn;
size_t m_extruders_count; size_t m_extruders_count;
std::vector<PageShp> m_extruder_pages;
public: public:
TabPrinter() {} TabPrinter() {}