//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField == &m_gridIndex) { const cvf::StructGridInterface* grid = selectedGrid(); if (grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0) { cellCountI = static_cast<int>(grid->cellCountI()); startIndexI = 1; cellCountJ = static_cast<int>(grid->cellCountJ()); startIndexJ = 1; cellCountK = static_cast<int>(grid->cellCountK()); startIndexK = 1; } parentContainer()->updateDisplayModeNotifyManagedViews(this); return; } if (changedField != &name) { computeAndSetValidValues(); parentContainer()->updateDisplayModeNotifyManagedViews(this); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { QList<caf::PdmOptionItemInfo> options; if (useOptionsOnly) (*useOptionsOnly) = true; if (&gridIndex == fieldNeedingOptions) { for (int gIdx = 0; gIdx < parentContainer()->gridCount(); ++gIdx) { QString gridName; gridName += parentContainer()->gridName(gIdx); 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; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { caf::PdmUiSliderEditorAttribute* myAttr = static_cast<caf::PdmUiSliderEditorAttribute*>(attribute); if (!myAttr || !parentContainer()) { return; } const cvf::StructGridInterface* grid = selectedGrid(); if (field == &startIndexI || field == &cellCountI) { myAttr->m_minimum = 1; myAttr->m_maximum = static_cast<int>(grid->cellCountI()); } else if (field == &startIndexJ || field == &cellCountJ) { myAttr->m_minimum = 1; myAttr->m_maximum = static_cast<int>(grid->cellCountJ()); } else if (field == &startIndexK || field == &cellCountK) { myAttr->m_minimum = 1; myAttr->m_maximum = static_cast<int>(grid->cellCountK()); } RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo(); if (grid == parentContainer()->gridByIndex(0) && actCellInfo) { cvf::Vec3st min, max; actCellInfo->IJKBoundingBox(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.uiCapability()->setUiName(QString("I Start (%1)").arg(min.x())); startIndexJ.uiCapability()->setUiName(QString("J Start (%1)").arg(min.y())); startIndexK.uiCapability()->setUiName(QString("K Start (%1)").arg(min.z())); cellCountI.uiCapability()->setUiName(QString(" Width (%1)").arg(max.x() - min.x() + 1)); cellCountJ.uiCapability()->setUiName(QString(" Width (%1)").arg(max.y() - min.y() + 1)); cellCountK.uiCapability()->setUiName(QString(" Width (%1)").arg(max.z() - min.z() + 1)); } else { startIndexI.uiCapability()->setUiName(QString("I Start")); startIndexJ.uiCapability()->setUiName(QString("J Start")); startIndexK.uiCapability()->setUiName(QString("K Start")); cellCountI.uiCapability()->setUiName(QString(" Width")); cellCountJ.uiCapability()->setUiName(QString(" Width")); cellCountK.uiCapability()->setUiName(QString(" Width")); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid() { if (gridIndex() >= parentContainer()->gridCount()) { gridIndex = 0; } const cvf::StructGridInterface* grid = parentContainer()->gridByIndex(gridIndex()); CVF_ASSERT(grid); return grid; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { caf::PdmUiSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiSliderEditorAttribute*>(attribute); if (!myAttr || !parentContainer()) { return; } const cvf::StructGridInterface* grid = selectedGrid(); if (!grid) return; if (field == &startIndexI || field == &cellCountI) { myAttr->m_minimum = 1; myAttr->m_maximum = static_cast<int>(grid->cellCountI()); } else if (field == &startIndexJ || field == &cellCountJ) { myAttr->m_minimum = 1; myAttr->m_maximum = static_cast<int>(grid->cellCountJ()); } else if (field == &startIndexK || field == &cellCountK) { myAttr->m_minimum = 1; myAttr->m_maximum = static_cast<int>(grid->cellCountK()); } }
void medSingleViewContainer2::setView (dtkAbstractView *view) { // Never replace an existing view: we are in multi, we always add a new one. // if we already have a view, we should transfer the request to the root. if (d->view) { if (medMultiViewContainer* container = qobject_cast<medMultiViewContainer*>(parentContainer())) { container->setView( view ); return; } return; } d->view = view; if (view) { d->layout->addWidget(view->widget(), 0, 0); // d->pool->appendView (view); // only difference with medSingleViewContainer: do not add the view to the pool connect (view, SIGNAL (closing()), this, SLOT (onViewClosing())); } this->setFocus(Qt::MouseFocusReason); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField != &name) { computeAndSetValidValues(); parentContainer()->updateDisplayModeNotifyManagedViews(this); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimEclipsePropertyFilter::initAfterRead() { resultDefinition->initAfterRead(); resultDefinition->setEclipseCase(parentContainer()->reservoirView()->eclipseCase()); resultDefinition->loadResult(); updateIconState(); computeResultValueRange(); updateFieldVisibility(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimEclipsePropertyFilter::computeResultValueRange() { CVF_ASSERT(parentContainer()); double min = 0.0; double max = 0.0; clearCategories(); size_t scalarIndex = resultDefinition->scalarResultIndex(); if (scalarIndex != cvf::UNDEFINED_SIZE_T) { RimReservoirCellResultsStorage* results = resultDefinition->currentGridCellResults(); if (results) { results->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); if (resultDefinition->hasCategoryResult()) { if (resultDefinition->resultType() != RimDefines::FORMATION_NAMES) { setCategoryValues(results->cellResults()->uniqueCellScalarValues(scalarIndex)); } else { CVF_ASSERT(parentContainer()->reservoirView()->eclipseCase()->reservoirData()); CVF_ASSERT(parentContainer()->reservoirView()->eclipseCase()->reservoirData()->activeFormationNames()); const std::vector<QString>& fnVector = parentContainer()->reservoirView()->eclipseCase()->reservoirData()->activeFormationNames()->formationNames(); setCategoryNames(fnVector); } } } } m_maximumResultValue = max; m_minimumResultValue = min; m_lowerBound.uiCapability()->setUiName(QString("Min (%1)").arg(min)); m_upperBound.uiCapability()->setUiName(QString("Max (%1)").arg(max)); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::setDefaultValues() { CVF_ASSERT(parentContainer()); const cvf::StructGridInterface* grid = selectedGrid(); RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo(); if (grid == parentContainer()->gridByIndex(0) && actCellInfo) { cvf::Vec3st min, max; actCellInfo->IJKBoundingBox(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 = static_cast<int>(min.x()); startIndexJ = static_cast<int>(min.y()); startIndexK = static_cast<int>(min.z()); cellCountI = static_cast<int>(max.x() - min.x() + 1); cellCountJ = static_cast<int>(max.y() - min.y() + 1); cellCountK = static_cast<int>(max.z() - min.z() + 1); } else { startIndexI = 1; startIndexJ = 1; startIndexK = 1; cellCountI = static_cast<int>(grid->cellCountI() ); cellCountJ = static_cast<int>(grid->cellCountJ() ); cellCountK = static_cast<int>(grid->cellCountK() ); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimEclipsePropertyFilter::setToDefaultValues() { CVF_ASSERT(parentContainer()); computeResultValueRange(); m_lowerBound = m_minimumResultValue; m_upperBound = m_maximumResultValue; m_selectedCategoryValues = m_categoryValues; m_categorySelection = true; updateFieldVisibility(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimGeoMechPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if ( &lowerBound == changedField || &upperBound == changedField || &isActive == changedField || &filterMode == changedField || &m_selectedCategoryValues == changedField) { this->updateIconState(); this->updateFilterName(); this->uiCapability()->updateConnectedEditors(); parentContainer()->updateDisplayModelNotifyManagedViews(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::setDefaultValues() { CVF_ASSERT(parentContainer()); const cvf::StructGridInterface* grid = selectedGrid(); if (!grid) return; Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimView); auto actCellInfo = RigReservoirGridTools::activeCellInfo(rimView); RimCase* rimCase = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimCase); const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase); if (grid == mainGrid && actCellInfo) { cvf::Vec3st min, max; actCellInfo->IJKBoundingBox(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 = static_cast<int>(min.x()); startIndexJ = static_cast<int>(min.y()); startIndexK = static_cast<int>(min.z()); cellCountI = static_cast<int>(max.x() - min.x() + 1); cellCountJ = static_cast<int>(max.y() - min.y() + 1); cellCountK = static_cast<int>(max.z() - min.z() + 1); } else { startIndexI = 1; startIndexJ = 1; startIndexK = 1; cellCountI = static_cast<int>(grid->cellCountI() ); cellCountJ = static_cast<int>(grid->cellCountJ() ); cellCountK = static_cast<int>(grid->cellCountK() ); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCellRangeFilter::computeAndSetValidValues() { CVF_ASSERT(parentContainer()); const cvf::StructGridInterface* grid = selectedGrid(); if (grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0) { cellCountI = cvf::Math::clamp(cellCountI.v(), 1, static_cast<int>(grid->cellCountI())); startIndexI = cvf::Math::clamp(startIndexI.v(), 1, static_cast<int>(grid->cellCountI())); cellCountJ = cvf::Math::clamp(cellCountJ.v(), 1, static_cast<int>(grid->cellCountJ())); startIndexJ = cvf::Math::clamp(startIndexJ.v(), 1, static_cast<int>(grid->cellCountJ())); cellCountK = cvf::Math::clamp(cellCountK.v(), 1, static_cast<int>(grid->cellCountK())); startIndexK = cvf::Math::clamp(startIndexK.v(), 1, static_cast<int>(grid->cellCountK())); } this->updateIconState(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimEclipsePropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (&m_categorySelection == changedField) { updateFieldVisibility(); } if ( &m_lowerBound == changedField || &m_upperBound == changedField || &obsoleteField_evaluationRegion == changedField || &isActive == changedField || &filterMode == changedField || &m_selectedCategoryValues == changedField || &m_categorySelection == changedField) { updateFilterName(); this->updateIconState(); this->uiCapability()->updateConnectedEditors(); parentContainer()->updateDisplayModelNotifyManagedViews(); } }