mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
get_option moved from Tab to ConfigOptionsGroup and extended. Added change_opt_value to changing option value in config
This commit is contained in:
parent
e62c17bddf
commit
16458e070a
7 changed files with 291 additions and 205 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if __APPLE__
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
|
@ -191,6 +192,58 @@ void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config)
|
|||
add_created_tab(new TabPrinter (g_wxTabPanel, "Printer"), preset_bundle, app_config);
|
||||
}
|
||||
|
||||
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value)
|
||||
{
|
||||
try{
|
||||
switch (config.def()->get(opt_key)->type){
|
||||
case coFloatOrPercent:
|
||||
case coPercent:
|
||||
case coFloat:
|
||||
{
|
||||
double& val = config.opt_float(opt_key);
|
||||
std::string str = boost::any_cast<std::string>(value);
|
||||
val = boost::lexical_cast<double>(str);
|
||||
break;
|
||||
}
|
||||
// case coPercents:
|
||||
// case coFloats:
|
||||
case coString:
|
||||
// opt = new ConfigOptionString(config.opt_string(opt_key));
|
||||
break;
|
||||
case coStrings:
|
||||
break;
|
||||
case coBool:
|
||||
config.set_key_value(opt_key, new ConfigOptionBool(boost::any_cast<bool>(value)));
|
||||
break;
|
||||
case coBools:
|
||||
// opt = new ConfigOptionBools(0, config.opt_bool(opt_key)); //! 0?
|
||||
break;
|
||||
case coInt:
|
||||
config.set_key_value(opt_key, new ConfigOptionInt(boost::any_cast<int>(value)));
|
||||
break;
|
||||
case coInts:
|
||||
break;
|
||||
case coEnum:
|
||||
break;
|
||||
case coPoints:
|
||||
break;
|
||||
case coNone:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
//std::string
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config)
|
||||
{
|
||||
panel->m_no_controller = app_config->get("no_controller").empty();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue