Пример #1
0
bool BrainSurfaceSetTreeItem::addData(const MNESourceSpace& tSourceSpace, Qt3DCore::QEntity* p3DEntityParent)
{
    //Generate child items based on surface set input parameters
    bool state = false;

    QList<QStandardItem*> itemList = this->findChildren(BrainTreeModelItemTypes::HemisphereItem);

    //If there are more hemispheres in tSourceSpace than in the tree model
    bool hemiItemFound = false;

    //Search for already created hemi items and add source space data respectivley
    for(int i = 0; i < tSourceSpace.size(); i++) {
        for(int j = 0; j<itemList.size(); j++) {
            BrainHemisphereTreeItem* pHemiItem = dynamic_cast<BrainHemisphereTreeItem*>(itemList.at(j));

            if(pHemiItem->data(BrainHemisphereTreeItemRoles::SurfaceHemi).toInt() == i) {
                hemiItemFound = true;
                state = pHemiItem->addData(tSourceSpace[i], p3DEntityParent);
            }
        }

        if(!hemiItemFound) {
            //Item does not exist yet, create it here.
            BrainHemisphereTreeItem* pHemisphereItem = new BrainHemisphereTreeItem(BrainTreeModelItemTypes::HemisphereItem);

            state = pHemisphereItem->addData(tSourceSpace[i], p3DEntityParent);

            *this<<pHemisphereItem; //same as this->appendRow(pSurfaceItem)
        }

        hemiItemFound = false;
    }

    return state;
}
Пример #2
0
bool BrainSurfaceSetTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation, Qt3DCore::QEntity* p3DEntityParent)
{
    //Generate child items based on surface set input parameters
    bool state = false;

    QList<QStandardItem*> itemList = this->findChildren(BrainTreeModelItemTypes::HemisphereItem);

    bool hemiItemFound = false;

    //Search for already created hemi items and add source space data respectivley
    for(int j = 0; j<itemList.size(); j++) {
        BrainHemisphereTreeItem* pHemiItem = dynamic_cast<BrainHemisphereTreeItem*>(itemList.at(j));

        if(pHemiItem->data(BrainHemisphereTreeItemRoles::SurfaceHemi).toInt() == tSurface.hemi()) {
            hemiItemFound = true;

            if(tAnnotation.hemi() == tSurface.hemi()) {
                state = pHemiItem->addData(tSurface, tAnnotation, p3DEntityParent);
            } else {
                state = pHemiItem->addData(tSurface, Annotation(), p3DEntityParent);
            }
        }
    }

    if(!hemiItemFound) {
        //Item does not exist yet, create it here.
        BrainHemisphereTreeItem* pHemiItem = new BrainHemisphereTreeItem(BrainTreeModelItemTypes::HemisphereItem);

        if(tAnnotation.hemi() == tSurface.hemi()) {
            state = pHemiItem->addData(tSurface, tAnnotation, p3DEntityParent);
        } else {
            state = pHemiItem->addData(tSurface, Annotation(), p3DEntityParent);
        }

        *this<<pHemiItem; //same as this->appendRow(pSurfaceItem)
    }

    return state;
}