Esempio n. 1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
    QList<caf::PdmOptionItemInfo> options;

    if (useOptionsOnly) (*useOptionsOnly) = true;

    if (&gridIndex == fieldNeedingOptions)
    { 
        RigMainGrid * mainGrid = NULL;

        if (parentContainer() && parentContainer()->reservoirView() && parentContainer()->reservoirView()->eclipseCase() &&  parentContainer()->reservoirView()->eclipseCase()->reservoirData())
            mainGrid = parentContainer()->reservoirView()->eclipseCase()->reservoirData()->mainGrid();

        for (size_t gIdx = 0; gIdx < mainGrid->gridCount(); ++gIdx)
        {
            RigGridBase* grid = mainGrid->gridByIndex(gIdx);
            QString gridName;

            gridName += grid->gridName().c_str();
            if (gIdx == 0)
            {
                if (gridName.isEmpty())
                    gridName += "Main Grid";
                else
                    gridName += " (Main Grid)";
            }

            caf::PdmOptionItemInfo item(gridName, (int)gIdx);
            options.push_back(item);
        }
    }
    return options;
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RigGridBase* RimCellRangeFilter::selectedGrid()
{
    RigMainGrid* mainGrid = m_parentContainer->mainGrid();
    CVF_ASSERT(mainGrid);

    RigGridBase* grid = NULL;
    if (static_cast<size_t>(gridIndex()) >= mainGrid->gridCount())
    {
        gridIndex = 0;
    }

    grid = mainGrid->gridByIndex(gridIndex());
    CVF_ASSERT(grid);
    return grid;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
int RimCellRangeFilterCollection::gridCount() const
{
    RigMainGrid* mnGrid = mainGrid();
    RigFemPartCollection* femPartColl = this->femPartColl();

    if (mnGrid)
    {
        return (int)mnGrid->gridCount();
    }
    else if (femPartColl)
    {
        return femPartColl->partCount();
    }

    return 0;
}