MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / copyTemplateParameters

Function copyTemplateParameters

src/Gui/PreferencePackManager.cpp:496–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496static void copyTemplateParameters(
497 Base::Reference<ParameterGrp> templateGroup,
498 const std::string& path,
499 Base::Reference<ParameterGrp> outputGroup
500)
501{
502 auto userParameterHandle = App::GetApplication().GetParameterGroupByPath(path.c_str());
503
504 // Ensure that the DockWindowManager has saved its current state:
505 Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
506 pDockMgr->saveState();
507
508 // Do the same for ToolBars
509 Gui::ToolBarManager* pToolbarMgr = Gui::ToolBarManager::getInstance();
510 pToolbarMgr->saveState();
511
512 auto boolMap = templateGroup->GetBoolMap();
513 for (const auto& kv : boolMap) {
514 auto currentValue = userParameterHandle->GetBool(kv.first.c_str(), kv.second);
515 outputGroup->SetBool(kv.first.c_str(), currentValue);
516 }
517
518 auto intMap = templateGroup->GetIntMap();
519 for (const auto& kv : intMap) {
520 auto currentValue = userParameterHandle->GetInt(kv.first.c_str(), kv.second);
521 outputGroup->SetInt(kv.first.c_str(), currentValue);
522 }
523
524 auto uintMap = templateGroup->GetUnsignedMap();
525 for (const auto& kv : uintMap) {
526 auto currentValue = userParameterHandle->GetUnsigned(kv.first.c_str(), kv.second);
527 outputGroup->SetUnsigned(kv.first.c_str(), currentValue);
528 }
529
530 auto floatMap = templateGroup->GetFloatMap();
531 for (const auto& kv : floatMap) {
532 auto currentValue = userParameterHandle->GetFloat(kv.first.c_str(), kv.second);
533 outputGroup->SetFloat(kv.first.c_str(), currentValue);
534 }
535
536 auto asciiMap = templateGroup->GetASCIIMap();
537 for (const auto& kv : asciiMap) {
538 auto currentValue = userParameterHandle->GetASCII(kv.first.c_str(), kv.second.c_str());
539 outputGroup->SetASCII(kv.first.c_str(), currentValue.c_str());
540 }
541
542 // Recurse...
543 auto templateSubgroups = templateGroup->GetGroups();
544 for (auto& templateSubgroup : templateSubgroups) {
545 std::string sgName = templateSubgroup->GetGroupName();
546 auto outputSubgroupHandle = outputGroup->GetGroup(sgName.c_str());
547 copyTemplateParameters(templateSubgroup, path + "/" + sgName, outputSubgroupHandle);
548 }
549}
550
551static void copyTemplateParameters(
552 /*const*/ ParameterManager& templateParameterManager,

Callers 1

saveMethod · 0.85

Calls 15

GetBoolMapMethod · 0.80
GetBoolMethod · 0.80
SetBoolMethod · 0.80
GetIntMapMethod · 0.80
GetIntMethod · 0.80
SetIntMethod · 0.80
GetUnsignedMapMethod · 0.80
GetUnsignedMethod · 0.80
SetUnsignedMethod · 0.80
GetFloatMapMethod · 0.80
GetFloatMethod · 0.80

Tested by

no test coverage detected