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


C++ KnobGuiPtr::getFieldContainer方法代码示例

本文整理汇总了C++中KnobGuiPtr::getFieldContainer方法的典型用法代码示例。如果您正苦于以下问题:C++ KnobGuiPtr::getFieldContainer方法的具体用法?C++ KnobGuiPtr::getFieldContainer怎么用?C++ KnobGuiPtr::getFieldContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KnobGuiPtr的用法示例。


在下文中一共展示了KnobGuiPtr::getFieldContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: KnobGuiPtr

KnobGuiPtr
DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob,
                                          bool makeNewLine,
                                          QWidget* lastRowWidget,
                                          const std::vector< boost::shared_ptr< KnobI > > & knobsOnSameLine)
{
    assert(knob);
    boost::shared_ptr<KnobGroup> isGroup = boost::dynamic_pointer_cast<KnobGroup>(knob);
    boost::shared_ptr<KnobPage> isPage = boost::dynamic_pointer_cast<KnobPage>(knob);
    for (KnobsGuiMapping::const_iterator it = _knobs.begin(); it != _knobs.end(); ++it) {
        if ( (it->first.lock() == knob) && it->second ) {
            if (isPage) {
                return it->second;
            } else if ( isGroup && ( ( !isGroup->isTab() && it->second->hasWidgetBeenCreated() ) || isGroup->isTab() ) ) {
                return it->second;
            } else if ( it->second->hasWidgetBeenCreated() ) {
                return it->second;
            } else {
                break;
            }
        }
    }


    if (isPage) {
        if ( isPage->getChildren().empty() ) {
            return KnobGuiPtr();
        }
        getOrCreatePage(isPage);
        KnobsVec children = isPage->getChildren();
        initializeKnobVector(children, lastRowWidget);

        return KnobGuiPtr();
    }

    KnobGuiPtr ret = createKnobGui(knob);
    if (!ret) {
        return KnobGuiPtr();
    }

    KnobPtr parentKnob = knob->getParentKnob();
    boost::shared_ptr<KnobGroup> parentIsGroup = boost::dynamic_pointer_cast<KnobGroup>(parentKnob);
    KnobGuiGroup* parentGui = 0;
    /// if this knob is within a group, make sure the group is created so far
    if (parentIsGroup) {
        parentGui = dynamic_cast<KnobGuiGroup*>( findKnobGuiOrCreate( parentKnob, true, ret->getFieldContainer() ).get() );
    }

    ///So far the knob could have no parent, in which case we force it to be in the default page.
    if (!parentKnob) {
        boost::shared_ptr<KnobPage> defPage = ensureDefaultPageKnobCreated();
        defPage->addKnob(knob);
        parentKnob = defPage;
    }

    ///if widgets for the KnobGui have already been created, don't do the following
    ///For group only create the gui if it is not  a tab.
    if ( isGroup  && isGroup->isTab() ) {
        boost::shared_ptr<KnobPage> parentIsPage = boost::dynamic_pointer_cast<KnobPage>(parentKnob);
        if (!parentKnob || parentIsPage) {
            PageMap::iterator page = _pages.end();
            if (!parentKnob) {
                page = getDefaultPage(knob);
            } else {
                page = getOrCreatePage(parentIsPage);
            }
            bool existed = true;
            if (!page->second.groupAsTab) {
                existed = false;
                page->second.groupAsTab = new TabGroup(_publicInterface);
            }
            page->second.groupAsTab->addTab( isGroup, QString::fromUtf8( isGroup->getLabel().c_str() ) );

            ///retrieve the form layout
            QGridLayout* layout;
            if (_useScrollAreasForTabs) {
                layout = dynamic_cast<QGridLayout*>( dynamic_cast<QScrollArea*>(page->second.tab)->widget()->layout() );
            } else {
                layout = dynamic_cast<QGridLayout*>( page->second.tab->layout() );
            }
            assert(layout);
            if (!existed) {
                layout->addWidget(page->second.groupAsTab, page->second.currentRow, 0, 1, 2);
            }

            page->second.groupAsTab->refreshTabSecretNess( isGroup.get() );
        } else {
            assert(parentIsGroup);
            assert(parentGui);
            TabGroup* groupAsTab = parentGui->getOrCreateTabWidget();

            groupAsTab->addTab( isGroup, QString::fromUtf8( isGroup->getLabel().c_str() ) );

            if ( parentIsGroup && parentIsGroup->isTab() ) {
                ///insert the tab in the layout of the parent
                ///Find the page in the parentParent group
                KnobPtr parentParent = parentKnob->getParentKnob();
                assert(parentParent);
                boost::shared_ptr<KnobGroup> parentParentIsGroup = boost::dynamic_pointer_cast<KnobGroup>(parentParent);
                boost::shared_ptr<KnobPage> parentParentIsPage = boost::dynamic_pointer_cast<KnobPage>(parentParent);
//.........这里部分代码省略.........
开发者ID:ChristianHeckl,项目名称:Natron,代码行数:101,代码来源:DockablePanelPrivate.cpp

示例2: KnobsVec

void
DockablePanelPrivate::initializeKnobVector(const KnobsVec& knobs,
                                           QWidget* lastRowWidget)
{
    std::list<boost::shared_ptr<KnobPage> > pages;
    KnobsVec regularKnobs;

    //Extract pages first
    for (U32 i = 0; i < knobs.size(); ++i) {
        KnobPage *isPage = dynamic_cast<KnobPage*>( knobs[i].get() );
        if (isPage) {
            pages.push_back( boost::dynamic_pointer_cast<KnobPage>(knobs[i]) );
            continue;
        } else {
            regularKnobs.push_back(knobs[i]);
        }
    }
    for (std::list<boost::shared_ptr<KnobPage> >::iterator it = pages.begin(); it != pages.end(); ++it) {
        //create page
        (void)findKnobGuiOrCreate( *it, true, 0, KnobsVec() );

        KnobsVec children = (*it)->getChildren();
        KnobsVec::iterator prev = children.end();
        for (KnobsVec::iterator it2 = children.begin(); it2 != children.end(); ++it2) {
            bool makeNewLine = true;
            KnobGroup *isGroup = dynamic_cast<KnobGroup*>( it2->get() );

            ////The knob  will have a vector of all other knobs on the same line.
            KnobsVec knobsOnSameLine;


            //If the knob is dynamic (i:e created after the initial creation of knobs)
            //it can be added as part of a group defined earlier hence we have to insert it at the proper index.
            KnobPtr parentKnob = (*it2)->getParentKnob();
            KnobGroup* isParentGroup = dynamic_cast<KnobGroup*>( parentKnob.get() );


            if (!isGroup) {
                if ( ( prev != children.end() ) && !(*prev)->isNewLineActivated() ) {
                    makeNewLine = false;
                }
                if (isParentGroup) {
                    KnobsVec groupsiblings = isParentGroup->getChildren();
                    findKnobsOnSameLine(groupsiblings, *it2, knobsOnSameLine);
                } else {
                    findKnobsOnSameLine(children, *it2, knobsOnSameLine);
                }
            }

            KnobGuiPtr newGui = findKnobGuiOrCreate(*it2, makeNewLine, lastRowWidget, knobsOnSameLine);

            ///childrens cannot be on the same row than their parent
            if (!isGroup && newGui) {
                lastRowWidget = newGui->getFieldContainer();
            }


            std::vector<KnobPtr>::iterator foundRegular = std::find(regularKnobs.begin(), regularKnobs.end(), *it2);
            if ( foundRegular != regularKnobs.end() ) {
                regularKnobs.erase(foundRegular);
            }


            if ( prev == children.end() ) {
                prev = children.begin();
            } else {
                ++prev;
            }
        }
    }

    //For knobs left,  create them
    KnobsVec::iterator prev = regularKnobs.end();
    for (KnobsVec::iterator it = regularKnobs.begin(); it != regularKnobs.end(); ++it) {
        bool makeNewLine = true;
        KnobGroup *isGroup = dynamic_cast<KnobGroup*>( it->get() );

        ////The knob  will have a vector of all other knobs on the same line.
        KnobsVec knobsOnSameLine;


        //If the knob is dynamic (i:e created after the initial creation of knobs)
        //it can be added as part of a group defined earlier hence we have to insert it at the proper index.
        KnobPtr parentKnob = (*it)->getParentKnob();
        KnobGroup* isParentGroup = dynamic_cast<KnobGroup*>( parentKnob.get() );


        if (!isGroup) {
            if ( ( prev != regularKnobs.end() ) && !(*prev)->isNewLineActivated() ) {
                makeNewLine = false;
            }

            KnobPage* isParentPage = dynamic_cast<KnobPage*>( parentKnob.get() );
            if (isParentPage) {
                KnobsVec children = isParentPage->getChildren();
                findKnobsOnSameLine(children, (*it), knobsOnSameLine);
            } else if (isParentGroup) {
                KnobsVec children = isParentGroup->getChildren();
                findKnobsOnSameLine(children, (*it), knobsOnSameLine);
            } else {
//.........这里部分代码省略.........
开发者ID:ChristianHeckl,项目名称:Natron,代码行数:101,代码来源:DockablePanelPrivate.cpp


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