Пример #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
    caf::PdmUiSliderEditorAttribute* myAttr = static_cast<caf::PdmUiSliderEditorAttribute*>(attribute);
    if (!myAttr || !m_parentContainer)
    {
        return;
    }

    RigMainGrid* mainGrid = m_parentContainer->mainGrid();
    if (mainGrid)
    {
        cvf::Vec3st min, max;
        mainGrid->matrixModelActiveCellsBoundingBox(min, max);

        // Adjust to Eclipse indexing
        min.x() = min.x() + 1;
        min.y() = min.y() + 1;
        min.z() = min.z() + 1;

        max.x() = max.x() + 1;
        max.y() = max.y() + 1;
        max.z() = max.z() + 1;

        startIndexI.setUiName(QString("I Start (%1)").arg(min.x()));
        startIndexJ.setUiName(QString("J Start (%1)").arg(min.y()));
        startIndexK.setUiName(QString("K Start (%1)").arg(min.z()));
        cellCountI.setUiName(QString("  Width (%1)").arg(max.x() - min.x() + 1));
        cellCountJ.setUiName(QString("  Width (%1)").arg(max.y() - min.y() + 1));
        cellCountK.setUiName(QString("  Width (%1)").arg(max.z() - min.z() + 1));

        if (field == &startIndexI || field == &cellCountI)
        {
            myAttr->m_minimum = 1;
            myAttr->m_maximum = static_cast<int>(mainGrid->cellCountI());
        }
        else if (field == &startIndexJ  || field == &cellCountJ)
        {
            myAttr->m_minimum = 1;
            myAttr->m_maximum = static_cast<int>(mainGrid->cellCountJ());
        }
        else if (field == &startIndexK || field == &cellCountK)
        {
            myAttr->m_minimum = 1;
            myAttr->m_maximum = static_cast<int>(mainGrid->cellCountK());
        }
    }
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimCellRangeFilter::computeAndSetValidValues()
{
    CVF_ASSERT(m_parentContainer);

    RigMainGrid* mainGrid = m_parentContainer->mainGrid();
    if (mainGrid && mainGrid->cellCount() > 0 )
    {
        cellCountI = cvf::Math::clamp(cellCountI.v(),   1, static_cast<int>(mainGrid->cellCountI()));
        startIndexI = cvf::Math::clamp(startIndexI.v(), 1, static_cast<int>(mainGrid->cellCountI()));

        cellCountJ = cvf::Math::clamp(cellCountJ.v(),   1, static_cast<int>(mainGrid->cellCountJ()));
        startIndexJ = cvf::Math::clamp(startIndexJ.v(), 1, static_cast<int>(mainGrid->cellCountJ()));

        cellCountK = cvf::Math::clamp(cellCountK.v(),   1, static_cast<int>(mainGrid->cellCountK()));
        startIndexK = cvf::Math::clamp(startIndexK.v(), 1, static_cast<int>(mainGrid->cellCountK()));
    }
    this->updateIconState();
}