当前位置: 首页>>代码示例>>C++>>正文


C++ Reference::GetGroups方法代码示例

本文整理汇总了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
                }
            }
        }
    }
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:55,代码来源:Workbench.cpp


注:本文中的base::Reference::GetGroups方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。