Exemplo n.º 1
0
bool DigitizerSetTreeItem::addData(const FIFFLIB::FiffDigPointSet& tDigitizer, Qt3DCore::QEntity* parent)
{
    bool state = false;

    //parsing the digitizer List
    QList<FIFFLIB::FiffDigPoint> tNasion;
    QList<FIFFLIB::FiffDigPoint> tLAP;
    QList<FIFFLIB::FiffDigPoint> tRAP;
    QList<FIFFLIB::FiffDigPoint> tHpi;
    QList<FIFFLIB::FiffDigPoint> tEeg;
    QList<FIFFLIB::FiffDigPoint> tExtra;

    for(int i = 0; i < tDigitizer.size(); ++i){
        switch (tDigitizer[i].kind) {
        case FIFFV_POINT_CARDINAL:
            switch (tDigitizer[i].ident) {
            case FIFFV_POINT_LPA:
                tLAP.append(tDigitizer[i]);
            break;
            case FIFFV_POINT_NASION:
                tNasion.append(tDigitizer[i]);
            break;
            case FIFFV_POINT_RPA:
                tRAP.append(tDigitizer[i]);
            break;
            default:
            break;
            }
            break;
        case FIFFV_POINT_HPI:
            tHpi.append(tDigitizer[i]);
            break;
        case FIFFV_POINT_EEG:
            tEeg.append(tDigitizer[i]);
            break;
        case FIFFV_POINT_EXTRA:
            tExtra.append(tDigitizer[i]);
            break;
        default:
            break;
        }
    }

    // Find the Digitizer Items
    QList<QStandardItem*> itemList = this->findChildren(Data3DTreeModelItemTypes::DigitizerItem);

    if (!tLAP.empty()){
        //Create a LAP digitizer item
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(Data3DTreeModelItemTypes::DigitizerItem,"LAP");
        state = digitizerItem->addData(tLAP, parent);
        itemList << digitizerItem;
        itemList << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemList);
        itemList.clear();
    }
    if (!tNasion.empty()){
        //Create a Nasion digitizer item
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(Data3DTreeModelItemTypes::DigitizerItem,"Nasion");
        state = digitizerItem->addData(tNasion, parent);
        itemList << digitizerItem;
        itemList << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemList);
        itemList.clear();
    }
    if (!tRAP.empty()){
        //Create a RAO digitizer item
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(Data3DTreeModelItemTypes::DigitizerItem,"RAP");
        state = digitizerItem->addData(tRAP, parent);
        itemList << digitizerItem;
        itemList << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemList);
        itemList.clear();
    }
    if (!tHpi.empty()){
        //Create a HPI digitizer item
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(Data3DTreeModelItemTypes::DigitizerItem,"HPI");
        state = digitizerItem->addData(tHpi, parent);
        itemList << digitizerItem;
        itemList << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemList);
        itemList.clear();
    }
    if (!tEeg.empty()){
        //Create a EEG digitizer item
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(Data3DTreeModelItemTypes::DigitizerItem,"EEG/ECG");
        state = digitizerItem->addData(tEeg, parent);
        itemList << digitizerItem;
        itemList << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemList);
        itemList.clear();
    }
    if (!tExtra.empty()){
        //Create a extra digitizer item
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(Data3DTreeModelItemTypes::DigitizerItem,"Extra");
        state = digitizerItem->addData(tExtra, parent);
        itemList << digitizerItem;
        itemList << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemList);
        itemList.clear();
    }
    return state;
}
Exemplo n.º 2
0
void DigitizerSetTreeItem::addData(const FIFFLIB::FiffDigPointSet& tDigitizer, Qt3DCore::QEntity* parent)
{
    //Add data
    //parsing the digitizer List
    QList<FIFFLIB::FiffDigPoint> tNasion;
    QList<FIFFLIB::FiffDigPoint> tLAP;
    QList<FIFFLIB::FiffDigPoint> tRAP;
    QList<FIFFLIB::FiffDigPoint> tHpi;
    QList<FIFFLIB::FiffDigPoint> tEeg;
    QList<FIFFLIB::FiffDigPoint> tExtra;


    for(int i = 0; i < tDigitizer.size(); ++i){

        switch (tDigitizer[i].kind) {
        case FIFFV_POINT_CARDINAL:

            switch (tDigitizer[i].ident) {
                case FIFFV_POINT_LPA:
                    tLAP.append(tDigitizer[i]);
                break;

                case FIFFV_POINT_NASION:
                    tNasion.append(tDigitizer[i]);
                break;

                case FIFFV_POINT_RPA:
                    tRAP.append(tDigitizer[i]);
                break;

                default:
                break;
                            }
            break;

        case FIFFV_POINT_HPI:
            tHpi.append(tDigitizer[i]);
            break;

        case FIFFV_POINT_EEG:
            tEeg.append(tDigitizer[i]);
            break;

        case FIFFV_POINT_EXTRA:
            tExtra.append(tDigitizer[i]);
            break;

        default:
            break;
        }
    }

//    //Create items all new - A bit more inefficient but we do not run into the problem that the QEntity
//    //is delted with deleteLater() which could let to deletion after the new Qentity has been created
//    //Delete all childs first. We do this because we always want to start fresh with the newly added digitizer data.
//    if(this->hasChildren()) {
//        this->removeRows(0, this->rowCount());
//    }

//    QList<QStandardItem*> itemList;

//    if (!tLAP.empty()){
//        //Create a LAP digitizer item
//        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"LAP");
//        digitizerItem->addData(tLAP);
//        itemList << digitizerItem;
//        itemList << new QStandardItem(digitizerItem->toolTip());
//        this->appendRow(itemList);
//        itemList.clear();
//    }
//    if (!tNasion.empty()){
//        //Create a Nasion digitizer item
//        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"Nasion");
//         digitizerItem->addData(tNasion);
//        itemList << digitizerItem;
//        itemList << new QStandardItem(digitizerItem->toolTip());
//        this->appendRow(itemList);
//        itemList.clear();
//    }
//    if (!tRAP.empty()){
//        //Create a RAO digitizer item
//        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"RAP");
//        digitizerItem->addData(tRAP);
//        itemList << digitizerItem;
//        itemList << new QStandardItem(digitizerItem->toolTip());
//        this->appendRow(itemList);
//        itemList.clear();
//    }
//    if (!tHpi.empty()){
//        //Create a HPI digitizer item
//        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"HPI");
//        digitizerItem->addData(tHpi);
//        itemList << digitizerItem;
//        itemList << new QStandardItem(digitizerItem->toolTip());
//        this->appendRow(itemList);
//        itemList.clear();
//    }
//    if (!tEeg.empty()){
//        //Create a EEG digitizer item
//        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"EEG/ECG");
//        digitizerItem->addData(tEeg);
//        itemList << digitizerItem;
//        itemList << new QStandardItem(digitizerItem->toolTip());
//        this->appendRow(itemList);
//        itemList.clear();
//    }
//    if (!tExtra.empty()){
//        //Create a extra digitizer item
//        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"Extra");
//        digitizerItem->addData(tExtra);
//        itemList << digitizerItem;
//        itemList << new QStandardItem(digitizerItem->toolTip());
//        this->appendRow(itemList);
//        itemList.clear();
//    }

    //Find exiting Digitizer Items and add data respectivley
    QList<QStandardItem*> itemList = this->findChildren(Data3DTreeModelItemTypes::DigitizerItem);
    bool bFoundNasionlItem = false;
    bool bFoundLAPItem = false;
    bool bFoundRAPItem = false;
    bool bFoundHPIItem = false;
    bool bFoundEEGItem = false;
    bool bFoundExtraItem = false;

    for(int i = 0; i < itemList.size(); ++i) {
        DigitizerTreeItem* item = dynamic_cast<DigitizerTreeItem*>(itemList.at(i));

        if(item->text() == "Nasion" && !tNasion.empty()) {
            item->addData(tNasion, 0.002f, Qt::yellow);
            bFoundNasionlItem = true;
        }

        if(item->text() == "LAP" && !tLAP.empty()) {
            item->addData(tLAP, 0.002f, Qt::green);
            bFoundLAPItem = true;
        }

        if(item->text() == "RAP" && !tRAP.empty()) {
            item->addData(tRAP, 0.002f, Qt::magenta);
            bFoundRAPItem = true;
        }

        if(item->text() == "HPI" && !tHpi.empty()) {
            item->addData(tHpi, 0.001f, Qt::red);
            bFoundHPIItem = true;
        }

        if(item->text() == "EEG/ECG" && !tEeg.empty()) {
            item->addData(tEeg, 0.001f, Qt::cyan);
            bFoundEEGItem = true;
        }

        if(item->text() == "Extra" && !tExtra.empty()) {
            item->addData(tExtra, 0.001f, Qt::magenta);
            bFoundExtraItem = true;
        }
    }

    //If not existent yet create here
    if (!bFoundNasionlItem && !tNasion.empty()){
        //Create a cardinal digitizer item
        QList<QStandardItem*> itemListCardinal;
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"Nasion");
        digitizerItem->addData(tNasion, 0.002f, Qt::yellow);
        itemListCardinal << digitizerItem;
        itemListCardinal << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemListCardinal);
    }

    if (!bFoundLAPItem && !tLAP.empty()){
        //Create a cardinal digitizer item
        QList<QStandardItem*> itemListCardinal;
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"LAP");
        digitizerItem->addData(tLAP, 0.002f, Qt::green);
        itemListCardinal << digitizerItem;
        itemListCardinal << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemListCardinal);
    }

    if (!bFoundRAPItem && !tRAP.empty()){
        //Create a cardinal digitizer item
        QList<QStandardItem*> itemListCardinal;
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"RAP");
        digitizerItem->addData(tRAP, 0.002f, Qt::magenta);
        itemListCardinal << digitizerItem;
        itemListCardinal << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemListCardinal);
    }

    if (!bFoundHPIItem && !tHpi.empty()){
        //Create a hpi digitizer item
        QList<QStandardItem*> itemListHPI;
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"HPI");
        digitizerItem->addData(tHpi, 0.001f, Qt::red);
        itemListHPI << digitizerItem;
        itemListHPI << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemListHPI);
    }

    if (!bFoundEEGItem && !tEeg.empty()){
        //Create a eeg ecg digitizer item
        QList<QStandardItem*> itemListEEG;
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"EEG/ECG");
        digitizerItem->addData(tEeg, 0.001f, Qt::cyan);
        itemListEEG << digitizerItem;
        itemListEEG << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemListEEG);
    }

    if (!bFoundExtraItem && !tExtra.empty()){
        //Create a extra digitizer item
        QList<QStandardItem*> itemListExtra;
        DigitizerTreeItem* digitizerItem = new DigitizerTreeItem(parent, Data3DTreeModelItemTypes::DigitizerItem,"Extra");
        digitizerItem->addData(tExtra, 0.001f, Qt::magenta);
        itemListExtra << digitizerItem;
        itemListExtra << new QStandardItem(digitizerItem->toolTip());
        this->appendRow(itemListExtra);
    }
}