mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 04:37:52 -06:00
Override full config defs in non-preset categories
This commit is contained in:
parent
ecd20184f9
commit
4abca6a091
2 changed files with 45 additions and 20 deletions
|
@ -291,27 +291,30 @@ void EditGCodeDialog::selection_changed(wxDataViewEvent& evt)
|
||||||
if (!opt_key.empty()) {
|
if (!opt_key.empty()) {
|
||||||
const ConfigOptionDef* def { nullptr };
|
const ConfigOptionDef* def { nullptr };
|
||||||
|
|
||||||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
for (const ConfigDef* config: std::initializer_list<const ConfigDef*> {
|
||||||
if (const ConfigDef* config_def = full_config.def(); config_def && config_def->has(opt_key)) {
|
&custom_gcode_specific_config_def,
|
||||||
def = config_def->get(opt_key);
|
&cgp_ro_slicing_states_config_def,
|
||||||
|
&cgp_rw_slicing_states_config_def,
|
||||||
|
&cgp_other_slicing_states_config_def,
|
||||||
|
&cgp_print_statistics_config_def,
|
||||||
|
&cgp_objects_info_config_def,
|
||||||
|
&cgp_dimensions_config_def,
|
||||||
|
&cgp_temperatures_config_def,
|
||||||
|
&cgp_timestamps_config_def,
|
||||||
|
&cgp_other_presets_config_def
|
||||||
|
}) {
|
||||||
|
if (config->has(opt_key)) {
|
||||||
|
def = config->get(opt_key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
// Orca: move below checking for def in custom defined gcode placeholders
|
||||||
for (const ConfigDef* config: std::initializer_list<const ConfigDef*> {
|
// This allows custom placeholders to override the default ones for this dialog
|
||||||
&custom_gcode_specific_config_def,
|
// Override custom def if selection is within the preset category
|
||||||
&cgp_ro_slicing_states_config_def,
|
if (!def || unbold(m_params_list->GetSelectedTopLevelCategory()) == "Presets") {
|
||||||
&cgp_rw_slicing_states_config_def,
|
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||||
&cgp_other_slicing_states_config_def,
|
if (const ConfigDef* config_def = full_config.def(); config_def && config_def->has(opt_key)) {
|
||||||
&cgp_print_statistics_config_def,
|
def = config_def->get(opt_key);
|
||||||
&cgp_objects_info_config_def,
|
|
||||||
&cgp_dimensions_config_def,
|
|
||||||
&cgp_temperatures_config_def,
|
|
||||||
&cgp_timestamps_config_def,
|
|
||||||
&cgp_other_presets_config_def
|
|
||||||
}) {
|
|
||||||
if (config->has(opt_key)) {
|
|
||||||
def = config->get(opt_key);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,6 +593,17 @@ std::string ParamsModel::GetParamKey(wxDataViewItem item)
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ParamsModel::GetTopLevelCategory(wxDataViewItem item)
|
||||||
|
{
|
||||||
|
if (item.IsOk()) {
|
||||||
|
ParamsNode* node = static_cast<ParamsNode*>(item.GetID());
|
||||||
|
while (!node->IsGroupNode())
|
||||||
|
node = node->GetParent();
|
||||||
|
return node->text.ToStdString();
|
||||||
|
}
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
wxDataViewItem ParamsModel::Delete(const wxDataViewItem& item)
|
wxDataViewItem ParamsModel::Delete(const wxDataViewItem& item)
|
||||||
{
|
{
|
||||||
auto ret_item = wxDataViewItem(nullptr);
|
auto ret_item = wxDataViewItem(nullptr);
|
||||||
|
@ -790,6 +804,11 @@ std::string ParamsViewCtrl::GetSelectedParamKey()
|
||||||
return model->GetParamKey(this->GetSelection());
|
return model->GetParamKey(this->GetSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ParamsViewCtrl::GetSelectedTopLevelCategory()
|
||||||
|
{
|
||||||
|
return model->GetTopLevelCategory(this->GetSelection());
|
||||||
|
}
|
||||||
|
|
||||||
void ParamsViewCtrl::CheckAndDeleteIfEmpty(wxDataViewItem item)
|
void ParamsViewCtrl::CheckAndDeleteIfEmpty(wxDataViewItem item)
|
||||||
{
|
{
|
||||||
wxDataViewItemArray children;
|
wxDataViewItemArray children;
|
||||||
|
|
|
@ -174,6 +174,7 @@ public:
|
||||||
|
|
||||||
wxString GetParamName(wxDataViewItem item);
|
wxString GetParamName(wxDataViewItem item);
|
||||||
std::string GetParamKey(wxDataViewItem item);
|
std::string GetParamKey(wxDataViewItem item);
|
||||||
|
std::string GetTopLevelCategory(wxDataViewItem item);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
@ -225,6 +226,7 @@ public:
|
||||||
wxString GetValue(wxDataViewItem item);
|
wxString GetValue(wxDataViewItem item);
|
||||||
wxString GetSelectedValue();
|
wxString GetSelectedValue();
|
||||||
std::string GetSelectedParamKey();
|
std::string GetSelectedParamKey();
|
||||||
|
std::string GetSelectedTopLevelCategory();
|
||||||
|
|
||||||
void CheckAndDeleteIfEmpty(wxDataViewItem item);
|
void CheckAndDeleteIfEmpty(wxDataViewItem item);
|
||||||
|
|
||||||
|
@ -234,6 +236,10 @@ public:
|
||||||
void set_em_unit(int em) { m_em_unit = em; }
|
void set_em_unit(int em) { m_em_unit = em; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::string unbold(const std::string& text) {
|
||||||
|
return text.substr(text.find("<b>")+3, text.find("</b>")-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue