本文整理汇总了C++中base::Reference::GetGroups方法的典型用法代码示例。如果您正苦于以下问题:C++ Reference::GetGroups方法的具体用法?C++ Reference::GetGroups怎么用?C++ Reference::GetGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::Reference
的用法示例。
在下文中一共展示了Reference::GetGroups方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupCustomToolbars
void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Reference<ParameterGrp>& hGrp) const
{
std::vector<Base::Reference<ParameterGrp> > hGrps = hGrp->GetGroups();
CommandManager& rMgr = Application::Instance->commandManager();
std::string separator = "Separator";
for (std::vector<Base::Reference<ParameterGrp> >::iterator it = hGrps.begin(); it != hGrps.end(); ++it) {
bool active = (*it)->GetBool("Active", true);
if (!active) // ignore this toolbar
continue;
ToolBarItem* bar = new ToolBarItem(root);
bar->setCommand("Custom");
// get the elements of the subgroups
std::vector<std::pair<std::string,std::string> > items = hGrp->GetGroup((*it)->GetGroupName())->GetASCIIMap();
for (std::vector<std::pair<std::string,std::string> >::iterator it2 = items.begin(); it2 != items.end(); ++it2) {
if (it2->first.substr(0, separator.size()) == separator) {
*bar << "Separator";
}
else if (it2->first == "Name") {
bar->setCommand(it2->second);
}
else {
Command* pCmd = rMgr.getCommandByName(it2->first.c_str());
if (!pCmd) { // unknown command
// first try the module name as is
std::string pyMod = it2->second;
try {
Base::Interpreter().loadModule(pyMod.c_str());
// Try again
pCmd = rMgr.getCommandByName(it2->first.c_str());
}
catch(const Base::Exception&) {
}
}
// still not there?
if (!pCmd) {
// add the 'Gui' suffix
std::string pyMod = it2->second + "Gui";
try {
Base::Interpreter().loadModule(pyMod.c_str());
// Try again
pCmd = rMgr.getCommandByName(it2->first.c_str());
}
catch(const Base::Exception&) {
}
}
if (pCmd) {
*bar << it2->first; // command name
}
}
}
}
}