Infill(Plater) updates with Infill (Print Settings).

*Updated some fuctions
This commit is contained in:
YuSanka 2018-03-12 16:52:21 +01:00
parent e8adbd7303
commit 5bb736daf2
3 changed files with 66 additions and 76 deletions

View File

@ -611,10 +611,44 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
//preset_sizer->RecalcSizes();
const wxArrayInt& ar = preset_sizer->GetColWidths();
m_optgroup->label_width = 90;//ar.IsEmpty() ? 90 : ar.front();
m_optgroup->m_on_change = [](t_config_option_key opt_key, boost::any value){
int i=0;// m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){
TabPrint* tab_print = nullptr;
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) {
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
if (!tab)
continue;
if (tab->name() == "print"){
tab_print = static_cast<TabPrint*>(tab);
break;
}
}
if (tab_print == nullptr)
return;
if (opt_key == "fill_density"){
value = m_optgroup->get_config_value(*config, opt_key);
tab_print->set_value(opt_key, value);
}
if (opt_key == "brim"){
if (boost::any_cast<bool>(value) == true)
{
double brim_width = config->opt_float("brim_width");// m_optgroup->get_config_value(*config, "brim_width");
if (brim_width == 0.0)
tab_print->set_value("brim_width", wxString("10"));
}
else
tab_print->set_value("brim_width", wxString("0"));
}
tab_print->update_dirty();
};
m_optgroup->append_single_option_line("fill_density");
Option option = m_optgroup->get_option("fill_density");
option.opt.sidetext = "";
option.opt.width = 200;
m_optgroup->append_single_option_line(option);
ConfigOptionDef def;
@ -626,7 +660,8 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
def.enum_labels.push_back(L("Support on build plate only"));
def.enum_labels.push_back(L("Everywhere"));
def.default_value = new ConfigOptionString(L("None"));
Option option(def, "support");
option = Option(def, "support");
option.opt.width = 200;
m_optgroup->append_single_option_line(option);
def.label = L("Brim");
@ -640,4 +675,9 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxBottom, 1);
}
ConfigOptionsGroup* get_optgroup()
{
return m_optgroup.get();
}
} }

View File

@ -44,6 +44,7 @@ class TabIface;
namespace GUI {
class Tab;
class ConfigOptionsGroup;
// Map from an file_type name to full file wildcard name.
typedef std::map<std::string, std::string> t_file_wild_card;
inline t_file_wild_card& get_file_wild_card() {
@ -130,6 +131,8 @@ wxWindow *get_widget_by_id(int id);
void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer);
ConfigOptionsGroup* get_optgroup();
}
}

View File

@ -233,83 +233,13 @@ void Tab::update_tab_ui()
m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets);
}
template<class T>
boost::any get_new_value(const DynamicPrintConfig &config_new, const DynamicPrintConfig &config_old, std::string opt_key, int &index)
{
for (int i = 0; i < config_new.option<T>(opt_key)->values.size(); i++)
if (config_new.option<T>(opt_key)->values[i] !=
config_old.option<T>(opt_key)->values[i]){
index = i;
break;
}
return config_new.option<T>(opt_key)->values[index];
}
// Load a provied DynamicConfig into the tab, modifying the active preset.
// This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
void Tab::load_config(DynamicPrintConfig config)
{
bool modified = 0;
boost::any value;
int opt_index = 0;
for(auto opt_key : m_config->diff(config)) {
switch ( config.def()->get(opt_key)->type ){
case coFloatOrPercent:{
const auto &conf_val = *config.option<ConfigOptionFloatOrPercent>(opt_key);
value = conf_val.percent ? std::to_string(int(conf_val.value)) + "%" : std::to_string(conf_val.value);
}
break;
case coPercent:
value = config.option<ConfigOptionPercent>(opt_key)->value;// std::to_string(int(config.option<ConfigOptionPercent>(opt_key)->value));
break;
case coFloat:
value = config.opt_float(opt_key);
break;
case coString:
value = config.opt_string(opt_key);
break;
case coPercents:
value = get_new_value<ConfigOptionPercents>(config, *m_config, opt_key, opt_index);
break;
case coFloats:
value = get_new_value<ConfigOptionFloats>(config, *m_config, opt_key, opt_index);
break;
case coStrings:
value = config.option<ConfigOptionStrings>(opt_key)->values.empty() ? "" :
get_new_value<ConfigOptionStrings>(config, *m_config, opt_key, opt_index);
break;
case coBool:
value = config.opt_bool(opt_key);
break;
case coBools:
value = get_new_value<ConfigOptionBools>(config, *m_config, opt_key, opt_index);
break;
case coInt:
value = config.opt_int(opt_key);
break;
case coInts:
value = get_new_value<ConfigOptionInts>(config, *m_config, opt_key, opt_index);
break;
case coEnum:{
if (opt_key.compare("external_fill_pattern") == 0 ||
opt_key.compare("fill_pattern") == 0)
value = config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value;
else if (opt_key.compare("gcode_flavor") == 0)
value = config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value;
else if (opt_key.compare("support_material_pattern") == 0)
value = config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value;
else if (opt_key.compare("seam_position") == 0)
value = config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value;
}
break;
case coPoints:
break;
case coNone:
break;
default:
break;
}
change_opt_value(*m_config, opt_key, value, opt_index);
m_config->set_key_value(opt_key, config.option(opt_key)->clone());
modified = 1;
}
if (modified) {
@ -380,6 +310,22 @@ void Tab::on_value_change(std::string opt_key, boost::any value)
}
g_wxMainFrame->ProcessWindowEvent(event);
}
if (opt_key == "fill_density")
{
value = get_optgroup()->get_config_value(*m_config, opt_key);
get_optgroup()->set_value(opt_key, value);
}
if (opt_key == "support")
{
}
if (opt_key == "brim_width")
{
bool val = m_config->opt_float("brim_width") > 0.0 ? true : false;
get_optgroup()->set_value("brim", val);
}
update();
}
@ -1418,7 +1364,8 @@ void TabPrinter::update(){
DynamicPrintConfig new_conf = *m_config;
if (dialog->ShowModal() == wxID_YES) {
auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe")->clone());
wipe->values[i] = false;
for (int w = 0; w < wipe->values.size(); w++)
wipe->values[w] = false;
new_conf.set_key_value("wipe", wipe);
}
else {