mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-04 20:44:00 -06:00
ConfigOptions: GUI type as enum, not string.
Fixing compilation error in the new Platform code. Fixing one issue in FDM support after splitting the top/bottom interface layers.
This commit is contained in:
parent
051ba0e6f4
commit
a9c3d270e6
10 changed files with 66 additions and 55 deletions
|
@ -902,7 +902,7 @@ void Choice::BUILD() {
|
|||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
|
||||
|
||||
choice_ctrl* temp;
|
||||
if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) {
|
||||
if (m_opt.gui_type != undefined && m_opt.gui_type != ConfigOptionDef::GUIType::select_open) {
|
||||
m_is_editable = true;
|
||||
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||
}
|
||||
|
@ -1237,7 +1237,7 @@ boost::any& Choice::get_value()
|
|||
else if (m_opt_id == "brim_type")
|
||||
m_value = static_cast<BrimType>(ret_enum);
|
||||
}
|
||||
else if (m_opt.gui_type == "f_enum_open") {
|
||||
else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) {
|
||||
const int ret_enum = field->GetSelection();
|
||||
if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings ||
|
||||
(ret_str != m_opt.enum_values[ret_enum] && ret_str != _(m_opt.enum_labels[ret_enum])))
|
||||
|
@ -1245,6 +1245,8 @@ boost::any& Choice::get_value()
|
|||
get_value_by_opt_type(ret_str);
|
||||
else if (m_opt.type == coFloatOrPercent)
|
||||
m_value = m_opt.enum_values[ret_enum];
|
||||
else if (m_opt.type == coInt)
|
||||
m_value = atoi(m_opt.enum_values[ret_enum].c_str());
|
||||
else
|
||||
m_value = atof(m_opt.enum_values[ret_enum].c_str());
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ void OG_CustomCtrl::init_ctrl_lines()
|
|||
height = m_bmp_blinking_sz.GetHeight() + m_v_gap;
|
||||
ctrl_lines.emplace_back(CtrlLine(height, this, line, true));
|
||||
}
|
||||
else if (opt_group->label_width != 0 && (!line.label.IsEmpty() || option_set.front().opt.gui_type == "legend") )
|
||||
else if (opt_group->label_width != 0 && (!line.label.IsEmpty() || option_set.front().opt.gui_type == ConfigOptionDef::GUIType::legend) )
|
||||
{
|
||||
wxSize label_sz = GetTextExtent(line.label);
|
||||
height = label_sz.y * (label_sz.GetWidth() > int(opt_group->label_width * m_em_unit) ? 2 : 1) + m_v_gap;
|
||||
|
@ -186,11 +186,11 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
|
|||
#endif //__WXMSW__
|
||||
h_pos += label_w + 1 + m_h_gap;
|
||||
}
|
||||
h_pos += (opt.opt.gui_type == "legend" ? 1 : 3) * blinking_button_width;
|
||||
h_pos += (opt.opt.gui_type == ConfigOptionDef::GUIType::legend ? 1 : 3) * blinking_button_width;
|
||||
|
||||
if (field == field_in)
|
||||
break;
|
||||
if (opt.opt.gui_type == "legend")
|
||||
if (opt.opt.gui_type == ConfigOptionDef::GUIType::legend)
|
||||
h_pos += 2 * blinking_button_width;
|
||||
|
||||
h_pos += field->getWindow()->GetSize().x;
|
||||
|
@ -580,7 +580,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_mode_bmp(wxDC& dc, wxCoord v_pos)
|
|||
wxBitmap bmp = create_scaled_bitmap(bmp_name, ctrl, wxOSX ? 10 : 12);
|
||||
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp).GetHeight()) / 2);
|
||||
|
||||
if (og_line.get_options().front().opt.gui_type != "legend")
|
||||
if (og_line.get_options().front().opt.gui_type != ConfigOptionDef::GUIType::legend)
|
||||
dc.DrawBitmap(bmp, 0, y_draw);
|
||||
|
||||
return get_bitmap_size(bmp).GetWidth() + ctrl->m_h_gap;
|
||||
|
|
|
@ -25,23 +25,27 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id) {
|
|||
const t_field& OptionsGroup::build_field(const t_config_option_key& id, const ConfigOptionDef& opt) {
|
||||
// Check the gui_type field first, fall through
|
||||
// is the normal type.
|
||||
if (opt.gui_type == "select") {
|
||||
} else if (opt.gui_type == "select_open") {
|
||||
switch (opt.gui_type) {
|
||||
case ConfigOptionDef::GUIType::select_open:
|
||||
m_fields.emplace(id, Choice::Create<Choice>(this->ctrl_parent(), opt, id));
|
||||
} else if (opt.gui_type == "color") {
|
||||
break;
|
||||
case ConfigOptionDef::GUIType::color:
|
||||
m_fields.emplace(id, ColourPicker::Create<ColourPicker>(this->ctrl_parent(), opt, id));
|
||||
} else if (opt.gui_type == "f_enum_open" ||
|
||||
opt.gui_type == "i_enum_open" ||
|
||||
opt.gui_type == "i_enum_closed") {
|
||||
break;
|
||||
case ConfigOptionDef::GUIType::f_enum_open:
|
||||
case ConfigOptionDef::GUIType::i_enum_open:
|
||||
m_fields.emplace(id, Choice::Create<Choice>(this->ctrl_parent(), opt, id));
|
||||
} else if (opt.gui_type == "slider") {
|
||||
break;
|
||||
case ConfigOptionDef::GUIType::slider:
|
||||
m_fields.emplace(id, SliderCtrl::Create<SliderCtrl>(this->ctrl_parent(), opt, id));
|
||||
} else if (opt.gui_type == "i_spin") { // Spinctrl
|
||||
} else if (opt.gui_type == "legend") { // StaticText
|
||||
break;
|
||||
case ConfigOptionDef::GUIType::legend: // StaticText
|
||||
m_fields.emplace(id, StaticText::Create<StaticText>(this->ctrl_parent(), opt, id));
|
||||
} else if (opt.gui_type == "one_string") {
|
||||
break;
|
||||
case ConfigOptionDef::GUIType::one_string:
|
||||
m_fields.emplace(id, TextCtrl::Create<TextCtrl>(this->ctrl_parent(), opt, id));
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
switch (opt.type) {
|
||||
case coFloatOrPercent:
|
||||
case coFloat:
|
||||
|
@ -122,7 +126,7 @@ bool OptionsGroup::is_legend_line()
|
|||
{
|
||||
if (m_lines.size() == 1) {
|
||||
const std::vector<Option>& option_set = m_lines.front().get_options();
|
||||
return !option_set.empty() && option_set.front().opt.gui_type == "legend";
|
||||
return !option_set.empty() && option_set.front().opt.gui_type == ConfigOptionDef::GUIType::legend;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -213,7 +217,7 @@ void OptionsGroup::activate_line(Line& line)
|
|||
}
|
||||
|
||||
auto option_set = line.get_options();
|
||||
bool is_legend_line = option_set.front().opt.gui_type == "legend";
|
||||
bool is_legend_line = option_set.front().opt.gui_type == ConfigOptionDef::GUIType::legend;
|
||||
|
||||
if (!custom_ctrl && m_use_custom_ctrl) {
|
||||
custom_ctrl = new OG_CustomCtrl(is_legend_line || !staticbox ? this->parent() : static_cast<wxWindow*>(this->stb), this);
|
||||
|
|
|
@ -357,7 +357,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||
ConfigOptionDef support_def;
|
||||
support_def.label = L("Supports");
|
||||
support_def.type = coStrings;
|
||||
support_def.gui_type = "select_open";
|
||||
support_def.gui_type = ConfigOptionDef::GUIType::select_open;
|
||||
support_def.tooltip = L("Select what kind of support do you need");
|
||||
support_def.enum_labels.push_back(L("None"));
|
||||
support_def.enum_labels.push_back(L("Support on build plate only"));
|
||||
|
@ -397,7 +397,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||
def.label = L("Brim");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("This flag enables the brim that will be printed around each object on the first layer.");
|
||||
def.gui_type = "";
|
||||
def.gui_type = ConfigOptionDef::GUIType::undefined;
|
||||
def.set_default_value(new ConfigOptionBool{ m_brim_width > 0.0 ? true : false });
|
||||
option = Option(def, "brim");
|
||||
option.opt.sidetext = "";
|
||||
|
@ -500,7 +500,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||
ConfigOptionDef pad_def;
|
||||
pad_def.label = L("Pad");
|
||||
pad_def.type = coStrings;
|
||||
pad_def.gui_type = "select_open";
|
||||
pad_def.gui_type = ConfigOptionDef::GUIType::select_open;
|
||||
pad_def.tooltip = L("Select what kind of pad do you need");
|
||||
pad_def.enum_labels.push_back(L("None"));
|
||||
pad_def.enum_labels.push_back(L("Below object"));
|
||||
|
|
|
@ -2531,7 +2531,7 @@ PageShp TabPrinter::build_kinematics_page()
|
|||
ConfigOptionDef def;
|
||||
def.type = coString;
|
||||
def.width = Field::def_width();
|
||||
def.gui_type = "legend";
|
||||
def.gui_type = ConfigOptionDef::GUIType::legend;
|
||||
def.mode = comAdvanced;
|
||||
def.tooltip = L("Values in this column are for Normal mode");
|
||||
def.set_default_value(new ConfigOptionString{ _(L("Normal")).ToUTF8().data() });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue