OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::Page Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Tab.hpp>

Inheritance diagram for Slic3r::GUI::Page:
Collaboration diagram for Slic3r::GUI::Page:

Public Member Functions

 Page (wxWindow *parent, const wxString &title, int iconID, wxPanel *tab_owner)
 ~Page ()
wxBoxSizer * vsizer () const
wxWindow * parent () const
const wxString & title () const
size_t iconID () const
void set_config (DynamicPrintConfig *config_in)
void reload_config ()
void update_visibility (ConfigOptionMode mode, bool update_contolls_visibility)
void activate (ConfigOptionMode mode, std::function< void()> throw_if_canceled)
bool build_pending () const
bool build_step (ConfigOptionMode mode)
bool visibility_pending () const
void clear ()
void msw_rescale ()
void sys_color_changed ()
void refresh ()
Field * get_field (const t_config_option_key &opt_key, int opt_index=-1) const
Line * get_line (const t_config_option_key &opt_key, int opt_index=-1)
bool set_value (const t_config_option_key &opt_key, const boost::any &value)
ConfigOptionsGroupShp new_optgroup (const wxString &title, const wxString &icon=wxEmptyString, int noncommon_label_width=-1, bool is_extruder_og=false)
const ConfigOptionsGroupShp get_optgroup (const wxString &title) const
bool set_item_colour (const wxColour *clr)
const wxColour get_item_colour ()
bool get_show () const

Public Attributes

bool m_is_modified_values { false }
bool m_is_nonsys_values { true }
bool m_split_multi_line = false
bool m_option_label_at_right = false
std::vector< ConfigOptionsGroupShp > m_optgroups
DynamicPrintConfig * m_config
std::map< std::string, std::string > m_opt_id_map

Protected Member Functions

size_t next_group_to_build () const
bool activate_group (size_t i, ConfigOptionMode mode, std::function< void()> throw_if_canceled)

Protected Attributes

const wxColour * m_item_color

Private Attributes

wxPanel * m_tab_owner
wxWindow * m_parent
wxString m_title
size_t m_iconID
wxBoxSizer * m_vsizer
wxStaticText * m_page_title
bool m_show = true
bool m_visibility_applied = false

Detailed Description

Constructor & Destructor Documentation

◆ Page()

Slic3r::GUI::Page::Page ( wxWindow * parent,
const wxString & title,
int iconID,
wxPanel * tab_owner )
9393 :
9394 m_tab_owner(tab_owner),
9396 m_title(title),
9398{
9399 m_vsizer = (wxBoxSizer*)parent->GetSizer();
9400 m_page_title = NULL;
9401 m_item_color = &wxGetApp().get_label_clr_default();
9402}
size_t iconID() const
Definition Tab.hpp:105
const wxColour * m_item_color
Definition Tab.hpp:146
wxStaticText * m_page_title
Definition Tab.hpp:84
wxBoxSizer * m_vsizer
Definition Tab.hpp:82
wxPanel * m_tab_owner
Definition Tab.hpp:78
const wxString & title() const
Definition Tab.hpp:104
wxString m_title
Definition Tab.hpp:80
wxWindow * m_parent
Definition Tab.hpp:79
wxWindow * parent() const
Definition Tab.hpp:103
size_t m_iconID
Definition Tab.hpp:81

References Page(), iconID(), m_iconID, m_item_color, m_page_title, m_parent, m_tab_owner, m_title, m_vsizer, parent(), and title().

Referenced by Page().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Page()

Slic3r::GUI::Page::~Page ( )
inline
90{}

Member Function Documentation

◆ activate()

void Slic3r::GUI::Page::activate ( ConfigOptionMode mode,
std::function< void()> throw_if_canceled )
9450{
9451#if 0 // BBS: page title
9452 if (m_page_title == NULL) {
9454 m_vsizer->AddSpacer(30);
9455 m_vsizer->Add(m_page_title, 0, wxALIGN_CENTER);
9456 m_vsizer->AddSpacer(20);
9457 }
9458#else
9459 //m_vsizer->AddSpacer(10);
9460#endif
9461 for (size_t i = 0; i < m_optgroups.size(); ++i) {
9462 activate_group(i, mode, throw_if_canceled);
9463 throw_if_canceled();
9464 }
9465
9466#ifdef __WXMSW__
9467 // BBS: fix field control position
9468 wxTheApp->CallAfter([wp = std::weak_ptr<Page>(shared_from_this())]() {
9469 auto page = wp.lock();
9470 if (!page)
9471 return;
9472
9473 for (auto group : page->m_optgroups) {
9474 if (group->custom_ctrl)
9475 group->custom_ctrl->fixup_items_positions();
9476 }
9477 });
9478#endif
9479}
#define _(s)
Definition 3mf.cpp:306
static wxFont Head_18
Definition Label.hpp:42
bool activate_group(size_t i, ConfigOptionMode mode, std::function< void()> throw_if_canceled)
Definition Tab.cpp:9482
std::vector< ConfigOptionsGroupShp > m_optgroups
Definition Tab.hpp:99

References _, activate_group(), Label::Head_18, m_optgroups, m_page_title, m_parent, m_title, and m_vsizer.

Here is the call graph for this function:

◆ activate_group()

bool Slic3r::GUI::Page::activate_group ( size_t i,
ConfigOptionMode mode,
std::function< void()> throw_if_canceled )
protected
9483{
9484 auto& group = m_optgroups[i];
9485 if (!group->activate(throw_if_canceled))
9486 return false;
9487 m_visibility_applied = false;
9488 m_vsizer->Add(group->sizer, 0, wxEXPAND | (group->is_legend_line() ? (wxLEFT|wxTOP) : wxALL), m_parent->FromDIP(5)); // ORCA use less margin on parameters section
9489 group->update_visibility(mode);
9490#if HIDE_FIRST_SPLIT_LINE
9491 // BBS: no line spliter for first group
9492 if (i == 0) group->stb->Hide();
9493#endif
9494 group->reload_config();
9495 return true;
9496}
bool m_visibility_applied
Definition Tab.hpp:86

References m_optgroups, m_parent, m_visibility_applied, and m_vsizer.

Referenced by activate(), and build_step().

Here is the caller graph for this function:

◆ build_pending()

bool Slic3r::GUI::Page::build_pending ( ) const
9505{
9506 return next_group_to_build() < m_optgroups.size();
9507}
size_t next_group_to_build() const
Definition Tab.cpp:9499

References m_optgroups, and next_group_to_build().

Referenced by build_step().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_step()

bool Slic3r::GUI::Page::build_step ( ConfigOptionMode mode)
9510{
9511 const size_t i = next_group_to_build();
9512 if (i < m_optgroups.size())
9513 activate_group(i, mode, [] {});
9514 return build_pending();
9515}
bool build_pending() const
Definition Tab.cpp:9504

References activate_group(), build_pending(), m_optgroups, and next_group_to_build().

Here is the call graph for this function:

◆ clear()

void Slic3r::GUI::Page::clear ( )
9518{
9519 for (auto group : m_optgroups)
9520 group->clear();
9521 m_page_title = NULL;
9522 m_visibility_applied = false;
9523}

References m_optgroups, m_page_title, and m_visibility_applied.

◆ get_field()

Field * Slic3r::GUI::Page::get_field ( const t_config_option_key & opt_key,
int opt_index = -1 ) const
9544{
9545 Field *field = nullptr;
9546 auto opt_key2 = opt_key;
9547 if (opt_index >= 256) {
9548 auto iter = m_opt_id_map.find(opt_key + '#' + std::to_string(opt_index - 256));
9549 if (iter != m_opt_id_map.end())
9550 opt_key2 = iter->second;
9551 }
9552 for (auto opt : m_optgroups) {
9553 field = opt->get_fieldc(opt_key2, opt_index);
9554 if (field != nullptr) return field;
9555 }
9556 return field;
9557}
std::map< std::string, std::string > m_opt_id_map
Definition Tab.hpp:140

References m_opt_id_map, and m_optgroups.

Referenced by Slic3r::GUI::TabFilament::update_filament_overrides_page().

Here is the caller graph for this function:

◆ get_item_colour()

const wxColour Slic3r::GUI::Page::get_item_colour ( )
inline
135 {
136 return *m_item_color;
137 }

References m_item_color.

◆ get_line()

Line * Slic3r::GUI::Page::get_line ( const t_config_option_key & opt_key,
int opt_index = -1 )
9560{
9561 Line *line = nullptr;
9562 auto opt_key2 = opt_key;
9563 if (opt_index >= 256) {
9564 auto iter = m_opt_id_map.find(opt_key + '#' + std::to_string(opt_index - 256));
9565 if (iter != m_opt_id_map.end())
9566 opt_key2 = iter->second;
9567 } else if (opt_index >= 0) {
9568 assert(opt_key.find('#') == std::string::npos);
9569 opt_key2 = opt_key + '#' + std::to_string(opt_index);
9570 }
9571 for (auto opt : m_optgroups) {
9572 line = opt->get_line(opt_key2);
9573 if (line != nullptr) return line;
9574 }
9575 return line;
9576}

References m_opt_id_map, and m_optgroups.

◆ get_optgroup()

const ConfigOptionsGroupShp Slic3r::GUI::Page::get_optgroup ( const wxString & title) const
9645{
9646 for (ConfigOptionsGroupShp optgroup : m_optgroups) {
9647 if (optgroup->title == title)
9648 return optgroup;
9649 }
9650
9651 return nullptr;
9652}
std::shared_ptr< ConfigOptionsGroup > ConfigOptionsGroupShp
Definition BedShapeDialog.hpp:31

References m_optgroups, and title().

Here is the call graph for this function:

◆ get_show()

bool Slic3r::GUI::Page::get_show ( ) const
inline
138{ return m_show; }
bool m_show
Definition Tab.hpp:85

References m_show.

◆ iconID()

size_t Slic3r::GUI::Page::iconID ( ) const
inline
105{ return m_iconID; }

References m_iconID.

Referenced by Page().

Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::Page::msw_rescale ( )
9526{
9527 for (auto group : m_optgroups)
9528 group->msw_rescale();
9529}

References m_optgroups.

◆ new_optgroup()

ConfigOptionsGroupShp Slic3r::GUI::Page::new_optgroup ( const wxString & title,
const wxString & icon = wxEmptyString,
int noncommon_label_width = -1,
bool is_extruder_og = false )

config_ have to be "right"

This function will be called from OptionGroup. Using of CallAfter is redundant. And in some cases it causes update() function to be recalled again wxTheApp->CallAfter([this, opt_key, value]() {

});

9590{
9592 ConfigOptionsGroupShp optgroup = is_extruder_og ? std::make_shared<ExtruderOptionsGroup>(m_parent, title, icon, m_config, true) // ORCA: add support for icons
9593 : std::make_shared<ConfigOptionsGroup>(m_parent, title, icon, m_config, true);
9594 optgroup->split_multi_line = this->m_split_multi_line;
9595 optgroup->option_label_at_right = this->m_option_label_at_right;
9596 if (noncommon_label_width >= 0)
9597 optgroup->label_width = noncommon_label_width;
9598
9599//BBS: GUI refactor
9600/*#ifdef __WXOSX__
9601 auto tab = parent()->GetParent()->GetParent();// GetParent()->GetParent();
9602#else
9603 auto tab = parent()->GetParent();// GetParent();
9604#endif*/
9605 auto tab = m_tab_owner;
9606 optgroup->set_config_category_and_type(m_title, static_cast<Tab*>(tab)->type());
9607 optgroup->m_on_change = [tab](t_config_option_key opt_key, boost::any value) {
9612 static_cast<Tab*>(tab)->update_dirty();
9613 static_cast<Tab*>(tab)->on_value_change(opt_key, value);
9615 };
9616
9617 optgroup->m_get_initial_config = [tab]() {
9618 DynamicPrintConfig config = static_cast<Tab*>(tab)->m_presets->get_selected_preset().config;
9619 return config;
9620 };
9621
9622 optgroup->m_get_sys_config = [tab]() {
9623 DynamicPrintConfig config = static_cast<Tab*>(tab)->m_presets->get_selected_preset_parent()->config;
9624 return config;
9625 };
9626
9627 optgroup->have_sys_config = [tab]() {
9628 return static_cast<Tab*>(tab)->m_presets->get_selected_preset_parent() != nullptr;
9629 };
9630
9631 optgroup->rescale_extra_column_item = [](wxWindow* win) {
9632 auto *ctrl = dynamic_cast<wxStaticBitmap*>(win);
9633 if (ctrl == nullptr)
9634 return;
9635
9636 ctrl->SetBitmap(reinterpret_cast<ScalableBitmap*>(ctrl->GetClientData())->bmp());
9637 };
9638
9639 m_optgroups.push_back(optgroup);
9640
9641 return optgroup;
9642}
DynamicPrintConfig * m_config
Definition Tab.hpp:100
bool m_split_multi_line
Definition Tab.hpp:95
bool m_option_label_at_right
Definition Tab.hpp:96
std::string t_config_option_key
Definition Config.hpp:96

References ScalableBitmap::bmp(), m_config, m_optgroups, m_option_label_at_right, m_parent, m_split_multi_line, m_tab_owner, m_title, and title().

Here is the call graph for this function:

◆ next_group_to_build()

size_t Slic3r::GUI::Page::next_group_to_build ( ) const
protected
9500{
9501 return std::find_if(m_optgroups.begin(), m_optgroups.end(), [](const auto& group) { return !group->is_activated(); }) - m_optgroups.begin();
9502}

References m_optgroups.

Referenced by build_pending(), and build_step().

Here is the caller graph for this function:

◆ parent()

wxWindow * Slic3r::GUI::Page::parent ( ) const
inline
103{ return m_parent; }

References m_parent.

Referenced by Page().

Here is the caller graph for this function:

◆ refresh()

void Slic3r::GUI::Page::refresh ( )
9538{
9539 for (auto group : m_optgroups)
9540 group->refresh();
9541}

References m_optgroups.

◆ reload_config()

void Slic3r::GUI::Page::reload_config ( )
9405{
9406 for (auto group : m_optgroups)
9407 group->reload_config();
9408}

References m_optgroups.

◆ set_config()

void Slic3r::GUI::Page::set_config ( DynamicPrintConfig * config_in)
inline
106{ m_config = config_in; }

References m_config.

◆ set_item_colour()

bool Slic3r::GUI::Page::set_item_colour ( const wxColour * clr)
inline
127 {
128 if (m_item_color != clr) {
129 m_item_color = clr;
130 return true;
131 }
132 return false;
133 }

References m_item_color.

◆ set_value()

bool Slic3r::GUI::Page::set_value ( const t_config_option_key & opt_key,
const boost::any & value )
9579{
9580 bool changed = false;
9581 for(auto optgroup: m_optgroups) {
9582 if (optgroup->set_value(opt_key, value))
9583 changed = true ;
9584 }
9585 return changed;
9586}

References m_optgroups.

◆ sys_color_changed()

void Slic3r::GUI::Page::sys_color_changed ( )
9532{
9533 for (auto group : m_optgroups)
9534 group->sys_color_changed();
9535}

References m_optgroups.

◆ title()

const wxString & Slic3r::GUI::Page::title ( ) const
inline
104{ return m_title; }

References m_title.

Referenced by Page(), get_optgroup(), Slic3r::GUI::Tab::is_printer_extruder_page(), and new_optgroup().

Here is the caller graph for this function:

◆ update_visibility()

void Slic3r::GUI::Page::update_visibility ( ConfigOptionMode mode,
bool update_contolls_visibility )
9411{
9412 bool ret_val = false;
9413#if HIDE_FIRST_SPLIT_LINE
9414 // BBS: no line spliter for first group
9415 bool first = true;
9416#endif
9417 for (auto group : m_optgroups) {
9418 ret_val = (update_contolls_visibility ?
9419 group->update_visibility(mode) : // update visibility for all controlls in group
9420 group->is_visible(mode) // just detect visibility for the group
9421 ) || ret_val;
9422#if HIDE_FIRST_SPLIT_LINE
9423 // BBS: no line spliter for first group
9424 if (update_contolls_visibility && ret_val && first) {
9425 if (group->stb) group->stb->Hide();
9426 first = false;
9427 }
9428#endif
9429 }
9430
9431 m_show = ret_val;
9432 if (update_contolls_visibility)
9433 m_visibility_applied = true;
9434#ifdef __WXMSW__
9435 if (!m_show) return;
9436 // BBS: fix field control position
9437 wxTheApp->CallAfter([wp=std::weak_ptr<Page>(shared_from_this())]() {
9438 auto page = wp.lock();
9439 if (!page)
9440 return;
9441
9442 for (auto group : page->m_optgroups) {
9443 if (group->custom_ctrl) group->custom_ctrl->fixup_items_positions();
9444 }
9445 });
9446#endif
9447}

References m_optgroups, m_show, and m_visibility_applied.

◆ visibility_pending()

bool Slic3r::GUI::Page::visibility_pending ( ) const
inline
115{ return !m_visibility_applied; }

References m_visibility_applied.

◆ vsizer()

wxBoxSizer * Slic3r::GUI::Page::vsizer ( ) const
inline
102{ return m_vsizer; }

References m_vsizer.

Member Data Documentation

◆ m_config

DynamicPrintConfig* Slic3r::GUI::Page::m_config

Referenced by new_optgroup(), and set_config().

◆ m_iconID

size_t Slic3r::GUI::Page::m_iconID
private

Referenced by Page(), and iconID().

◆ m_is_modified_values

bool Slic3r::GUI::Page::m_is_modified_values { false }

◆ m_is_nonsys_values

bool Slic3r::GUI::Page::m_is_nonsys_values { true }

◆ m_item_color

const wxColour* Slic3r::GUI::Page::m_item_color
protected

◆ m_opt_id_map

std::map<std::string, std::string> Slic3r::GUI::Page::m_opt_id_map

Referenced by get_field(), and get_line().

◆ m_optgroups

◆ m_option_label_at_right

bool Slic3r::GUI::Page::m_option_label_at_right = false

Referenced by new_optgroup().

◆ m_page_title

wxStaticText* Slic3r::GUI::Page::m_page_title
private

Referenced by Page(), activate(), and clear().

◆ m_parent

wxWindow* Slic3r::GUI::Page::m_parent
private

◆ m_show

bool Slic3r::GUI::Page::m_show = true
private

Referenced by get_show(), and update_visibility().

◆ m_split_multi_line

bool Slic3r::GUI::Page::m_split_multi_line = false

Referenced by new_optgroup().

◆ m_tab_owner

wxPanel* Slic3r::GUI::Page::m_tab_owner
private

Referenced by Page(), and new_optgroup().

◆ m_title

wxString Slic3r::GUI::Page::m_title
private

Referenced by Page(), activate(), new_optgroup(), and title().

◆ m_visibility_applied

bool Slic3r::GUI::Page::m_visibility_applied = false
private

◆ m_vsizer

wxBoxSizer* Slic3r::GUI::Page::m_vsizer
private

Referenced by Page(), activate(), activate_group(), and vsizer().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Tab.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Tab.cpp