//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::updateIconState()
{
    bool activeIcon = true;

    RimEclipseView* view = NULL;
    this->firstAncestorOrThisOfType(view);
    RimViewController* viewController = view->viewController();
    if (viewController && (viewController->isPropertyFilterOveridden() 
                           || viewController->isVisibleCellsOveridden()))
    {
        activeIcon = false;
    }

    if (!isActive)
    {
        activeIcon = false;
    }

    updateUiIconFromState(activeIcon);

    for (size_t i = 0; i < propertyFilters.size(); i++)
    {
        RimEclipsePropertyFilter* cellFilter = propertyFilters[i];
        cellFilter->updateActiveState();
        cellFilter->updateIconState();
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::loadAndInitializePropertyFilters()
{
    for (size_t i = 0; i < propertyFilters.size(); i++)
    {
        RimEclipsePropertyFilter* propertyFilter = propertyFilters[i];
        propertyFilter->initAfterRead();
    }
}
//--------------------------------------------------------------------------------------------------
/// Returns whether any of the active property filters are based on a dynamic result
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::hasActiveDynamicFilters() const
{
    if (!active) return false;

    for (size_t i = 0; i < propertyFilters.size(); i++)
    {
        RimEclipsePropertyFilter* propertyFilter = propertyFilters[i];
        if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasDynamicResult()) return true;
    }

    return false;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::loadAndInitializePropertyFilters()
{
    for (size_t i = 0; i < propertyFilters.size(); i++)
    {
        RimEclipsePropertyFilter* propertyFilter = propertyFilters[i];

        propertyFilter->setParentContainer(this);

        propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p());
        propertyFilter->resultDefinition->loadResult();
        propertyFilter->updateIconState();
        propertyFilter->computeResultValueRange();
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::isUsingFormationNames() const
{
    if ( !isActive ) return false;

    for ( size_t i = 0; i < propertyFilters.size(); i++ )
    {
        RimEclipsePropertyFilter* propertyFilter = propertyFilters[i];
        if (   propertyFilter->isActive() 
            && propertyFilter->resultDefinition->resultType() == RimDefines::FORMATION_NAMES 
            && propertyFilter->resultDefinition->resultVariable() != RimDefines::undefinedResultName()) return true;
    }

    return false;
}
예제 #6
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::removeResult(const QString& resultName)
{
    size_t i;
    for (i = 0; i < reservoirViews().size(); i++)
    {
        RimEclipseView* reservoirView = reservoirViews()[i];
        CVF_ASSERT(reservoirView);

        RimEclipseCellColors* result = reservoirView->cellResult;
        CVF_ASSERT(result);

        bool rebuildDisplayModel = false;

        // Set cell result variable to none if displaying 
        if (result->resultVariable() == resultName)
        {
            result->setResultVariable(RimDefines::undefinedResultName());
            result->loadResult();

            rebuildDisplayModel = true;
        }

        std::list< caf::PdmPointer< RimEclipsePropertyFilter > >::iterator it;
        RimEclipsePropertyFilterCollection* propFilterCollection = reservoirView->propertyFilterCollection();

        for (size_t filter = 0; filter < propFilterCollection->propertyFilters().size(); filter++)
        {
            RimEclipsePropertyFilter* propertyFilter = propFilterCollection->propertyFilters()[filter];
            if (propertyFilter->resultDefinition->resultVariable() == resultName)
            {
                propertyFilter->resultDefinition->setResultVariable(RimDefines::undefinedResultName());
                propertyFilter->resultDefinition->loadResult();
                propertyFilter->setToDefaultValues();

                rebuildDisplayModel = true;
            }
        }

        if (rebuildDisplayModel)
        {
            reservoirViews()[i]->createDisplayModelAndRedraw();
        }


        // TODO
        // CellEdgeResults are not considered, as they do not support display of input properties yet
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimEclipsePropertyFilter* RimEclipsePropertyFilterCollection::createAndAppendPropertyFilter()
{
    RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
    
    propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p());

    propertyFilter->setParentContainer(this);
    propertyFilters.push_back(propertyFilter);

    propertyFilter->resultDefinition->setResultVariable(m_reservoirView->cellResult->resultVariable());
    propertyFilter->resultDefinition->setPorosityModel(m_reservoirView->cellResult->porosityModel());
    propertyFilter->resultDefinition->setResultType(m_reservoirView->cellResult->resultType());
    propertyFilter->resultDefinition->loadResult();
    propertyFilter->setToDefaultValues();
    propertyFilter->updateFilterName();


    return propertyFilter;
}
예제 #8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, 
    const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl)
{
    CVF_ASSERT(cellVisibility != nullptr);
    CVF_ASSERT(rangeFilterVisibility != nullptr);
    CVF_ASSERT(propFilterColl != nullptr);

    CVF_ASSERT(grid->cellCount() > 0);
    CVF_ASSERT(rangeFilterVisibility->size() == grid->cellCount());

    // Copy if not equal
    if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility;

    if (propFilterColl->hasActiveFilters())
    {
        for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++)
        {
            RimEclipsePropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i];

            if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult())
            {
                const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();

                RigEclipseCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->eclipseCaseData();

                cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createFromResultDefinition(eclipseCase, grid->gridIndex(),  timeStepIndex, propertyFilter->resultDefinition);

                CVF_ASSERT(resultAccessor.notNull());

                if (propertyFilter->isCategorySelectionActive())
                {
                    std::vector<int> integerVector = propertyFilter->selectedCategoryValues();
                    std::set<int> integerSet;
                    for (auto val : integerVector)
                    {
                        integerSet.insert(val);
                    }

                    for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
                    {
                        if ((*cellVisibility)[cellIndex])
                        {
                            size_t resultValueIndex = cellIndex;

                            double scalarValue = resultAccessor->cellScalar(resultValueIndex);
                            if (integerSet.find(scalarValue) != integerSet.end())
                            {
                                if (filterType == RimCellFilter::EXCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                            else
                            {
                                if (filterType == RimCellFilter::INCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                        }
                    }
                }
                else
                {
                    double lowerBound = 0.0;
                    double upperBound = 0.0;
                    propertyFilter->rangeValues(&lowerBound, &upperBound);

                    for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
                    {
                        if ((*cellVisibility)[cellIndex])
                        {
                            size_t resultValueIndex = cellIndex;

                            double scalarValue = resultAccessor->cellScalar(resultValueIndex);
                            if (lowerBound <= scalarValue && scalarValue <= upperBound)
                            {
                                if (filterType == RimCellFilter::EXCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                            else
                            {
                                if (filterType == RimCellFilter::INCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
    if (   &m_resultTypeUiField == changedField 
        || &m_porosityModelUiField == changedField )
    {
        QStringList varList = getResultVariableListForCurrentUIFieldSettings();

        // If the user are seeing the list with the actually selected result, select that result in the list. Otherwise select nothing.
        if (   m_resultTypeUiField() == m_resultType() 
            && m_porosityModelUiField() == m_porosityModel() 
            && varList.contains(resultVariable()))
        {
            m_resultVariableUiField = resultVariable();
        }
        else
        {
            m_resultVariableUiField = "";
        }

    }

    RimEclipsePropertyFilter* propFilter = dynamic_cast<RimEclipsePropertyFilter*>(this->parentField()->ownerObject());
    RimView* view = NULL;
    this->firstAnchestorOrThisOfType(view);
    RimWellLogCurve* curve = NULL;
    this->firstAnchestorOrThisOfType(curve);

    if (&m_resultVariableUiField == changedField)
    {
        m_porosityModel  = m_porosityModelUiField;
        m_resultType     = m_resultTypeUiField;
        m_resultVariable = m_resultVariableUiField;
        
        loadResult();

        if (propFilter)
        {
            propFilter->setToDefaultValues();
            propFilter->updateFilterName();

            if (view)
            {
                view->scheduleGeometryRegen(PROPERTY_FILTERED);
                view->scheduleCreateDisplayModelAndRedraw();
            }
        }

        if (dynamic_cast<RimEclipseCellColors*>(this))
        {
            if (view)
            {
                RimViewLinker* viewLinker = view->assosiatedViewLinker();
                if (viewLinker)
                {
                    viewLinker->updateCellResult();
                }
            }
        }

        if (curve) 
        {
            curve->updatePlotData();
        }
    }

    if (propFilter)
    {
        propFilter->updateConnectedEditors();
    }

    RimEclipseFaultColors* faultColors = dynamic_cast<RimEclipseFaultColors*>(this->parentField()->ownerObject());
    if (faultColors)
    {
        faultColors->updateConnectedEditors();
    }

    if (curve)
    {
        curve->updateConnectedEditors();
    }
 
}