diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index e2001740fa..a64fbc2cb3 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -101,7 +101,9 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) { if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); + RivTernaryTextureCoordsCreator texturer(cellResultColors, + cellResultColors->ternaryLegendConfig()->scalarMapper(), + timeStepIndex); texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxGenerator->triangleToCellIndex()); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 445bf3c63e..9cfca35775 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -89,8 +89,12 @@ void RivIntersectionPartMgr::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) +void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper) { + CVF_ASSERT(scalarColorMapper); + if (m_crossSectionGenerator.isNull()) return; if (!m_crossSectionGenerator->isAnyGeometryPresent()) return; @@ -102,6 +106,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { RimEclipseCellColors* cellResultColors = eclipseView->cellResult(); CVF_ASSERT(cellResultColors); + CVF_ASSERT(ternaryColorMapper); RigEclipseCaseData* eclipseCase = eclipseView->eclipseCase()->eclipseCaseData(); @@ -110,14 +115,13 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); + RivTernaryTextureCoordsCreator texturer(cellResultColors, ternaryColorMapper, timeStepIndex); texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex()); - const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + ternaryColorMapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); @@ -126,7 +130,6 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { CVF_ASSERT(m_crossSectionGenerator.notNull()); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); cvf::ref resultAccessor; if (RiaDefines::isPerCellFaceResult(cellResultColors->resultVariable())) @@ -144,12 +147,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex(), resultAccessor.p(), - mapper); + scalarColorMapper); RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + scalarColorMapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); @@ -169,8 +172,6 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - if (resVarAddress.resultPosType == RIG_ELEMENT) { const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); @@ -179,7 +180,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), resultValues, triangleToCellIdx, - mapper); + scalarColorMapper); } else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) @@ -192,7 +193,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_crossSectionFacesTextureCoords.p(), triangelVxes, resVarAddress, - mapper); + scalarColorMapper); } else { @@ -204,7 +205,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) caseData, resVarAddress, (int)timeStepIndex, - mapper); + scalarColorMapper); } } else @@ -222,12 +223,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) resultValues, isElementNodalResult, femPart, - mapper); + scalarColorMapper); } RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + scalarColorMapper, 1.0, caf::FC_NONE, geoView->isLightingDisabled()); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index f1bd98d5c6..0daa56f475 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -43,6 +43,7 @@ class RigResultAccessor; class RimCellEdgeColors; class RimEclipseCellColors; class RimIntersection; +class RivTernaryScalarMapper; class RivIntersectionGeometryGenerator; class RivIntersectionHexGridInterface; class RivIntersectionVertexWeights; @@ -59,7 +60,9 @@ public: explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false); void applySingleColorEffect(); - void updateCellResultColor(size_t timeStepIndex); + void updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper); void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index 54c74bb5af..fdbf6a1f4b 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -87,7 +87,7 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultColors, cellEdgeResultColors, quadToCellFaceMapper, dg, gridIndex, opacityLevel); - RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + const RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); cellFaceEffectGen.setTernaryScalarMapper(ternaryCellScalarMapper); } else diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp index 37d6c3434f..9e443bf675 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp @@ -79,7 +79,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( //-------------------------------------------------------------------------------------------------- RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, - RimTernaryLegendConfig* ternaryLegendConfig, + const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex) : m_quadMapper(NULL) { @@ -99,10 +99,8 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( m_resultAccessor = new RigTernaryResultAccessor(); m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p()); - const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper(); - // Create a texture mapper without detecting transparency using RigPipeInCellEvaluator - m_texMapper = new RivTernaryResultToTextureMapper(mapper, NULL); + m_texMapper = new RivTernaryResultToTextureMapper(ternaryColorMapper, NULL); CVF_ASSERT(m_texMapper.notNull()); } diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h index d9e767ab0c..b85ea520c0 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h @@ -48,7 +48,7 @@ public: const cvf::StructGridQuadToCellFaceMapper* quadMapper); RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, - RimTernaryLegendConfig* ternaryLegendConfig, + const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex); void createTextureCoords(cvf::Vec2fArray* quadTextureCoords); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 8962e28ed2..bcb28881cf 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -23,6 +23,7 @@ #include "RiuViewer.h" #include "RimGridView.h" #include "RivIntersectionPartMgr.h" +#include "RivTernarySaturationOverlayItem.h" #include "cvfPart.h" #include "cvfModelBasicList.h" @@ -32,6 +33,8 @@ #include "RimEclipseCellColors.h" #include "RimGeoMechView.h" #include "RimGeoMechCellColors.h" +#include "RimLegendConfig.h" +#include "RimTernaryLegendConfig.h" #include @@ -52,6 +55,18 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", ""); m_intersection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + m_legendConfig.uiCapability()->setUiHidden(true); + m_legendConfig.uiCapability()->setUiTreeChildrenHidden(true); + m_legendConfig.xmlCapability()->disableIO(); + m_legendConfig = new RimLegendConfig(); + + CAF_PDM_InitFieldNoDefault(&m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Legend Definition", "", "", ""); + m_ternaryLegendConfig.uiCapability()->setUiTreeHidden(true); + m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden(true); + m_ternaryLegendConfig.xmlCapability()->disableIO(); + m_ternaryLegendConfig = new RimTernaryLegendConfig(); + m_showWindow = false; m_scaleTransform = new cvf::Transform(); m_intersectionVizModel = new cvf::ModelBasicList; @@ -274,6 +289,12 @@ void Rim2dIntersectionView::createDisplayModel() void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection* parts) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onTimeStepChanged() +{ +} //-------------------------------------------------------------------------------------------------- /// @@ -287,23 +308,88 @@ void Rim2dIntersectionView::clampCurrentTimestep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::updateCurrentTimeStep() { + updateLegends(); + if ((this->hasUserRequestedAnimation() && this->hasResults())) { - m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep); + m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep, + m_legendConfig->scalarMapper(), + m_ternaryLegendConfig()->scalarMapper()); } else { m_flatIntersectionPartMgr->applySingleColorEffect(); } + +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateLegends() +{ + if (m_viewer) + { + m_viewer->removeAllColorLegends(); + } + + if (!hasResults()) return ; + + cvf::OverlayItem* legend = nullptr; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView) + { + m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); + m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); + eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); + + if ( eclView->cellResult()->isTernarySaturationSelected() ) + { + m_ternaryLegendConfig()->setTitle("Cell Result:"); + legend = m_ternaryLegendConfig()->legend(); + } + else + { + m_legendConfig()->setTitle("Cell Result:" + eclView->cellResult()->resultVariableUiShortName()); + legend = m_legendConfig()->legend(); + } + } + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView) + { + m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); + + geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); + legend = m_legendConfig()->legend(); + } + + if ( legend ) + { + m_viewer->addColorLegendToBottomLeftCorner(legend); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::onTimeStepChanged() +void Rim2dIntersectionView::resetLegendsInViewer() { + m_viewer->showAxisCross(false); + m_viewer->showAnimationProgress(true); + m_viewer->showHistogram(false); + m_viewer->showInfoText(false); + + m_viewer->setMainScene(new cvf::Scene()); + m_viewer->enableNavigationRotation(false); + + m_ternaryLegendConfig()->recreateLegend(); + m_legendConfig()->recreateLegend(); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -332,20 +418,6 @@ cvf::Transform* Rim2dIntersectionView::scaleTransform() return m_scaleTransform.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::resetLegendsInViewer() -{ - m_viewer->showAxisCross(false); - m_viewer->showAnimationProgress(true); - m_viewer->showHistogram(false); - m_viewer->showInfoText(false); - - m_viewer->setMainScene(new cvf::Scene()); - m_viewer->enableNavigationRotation(false); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 98da585f17..ec3ec5361d 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -23,6 +23,8 @@ class RimIntersection; class RivIntersectionPartMgr; +class RimLegendConfig; +class RimTernaryLegendConfig; namespace cvf { @@ -50,7 +52,7 @@ public: virtual void selectOverlayInfoConfig() override {} virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; } - virtual RimViewController* viewController() const override { return nullptr; } + virtual RimViewController* viewController() const override { return nullptr; } virtual bool isTimeStepDependentDataVisible() const override; @@ -76,6 +78,11 @@ protected: bool hasResults(); int timeStepCount(); + void updateLegends(); + + caf::PdmChildField m_legendConfig; + caf::PdmChildField m_ternaryLegendConfig; + caf::PdmPtrField m_intersection; cvf::ref m_flatIntersectionPartMgr; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index ab9802971e..84cf383f49 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -41,6 +41,7 @@ #include "RimFlowCharacteristicsPlot.h" #include "RimFlowPlotCollection.h" #include "RimFormationNames.h" +#include "RimIntersectionCollection.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" @@ -398,6 +399,7 @@ void RimEclipseCase::updateFormationNamesData() view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); + eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index db6bf8bf95..a5af468764 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -273,135 +273,212 @@ public : //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCellColors::updateLegendData(size_t currentTimeStep) +void RimEclipseCellColors::updateLegendData(size_t currentTimeStep, + RimLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig) { - if (this->isFlowDiagOrInjectionFlooding()) + if (!legendConfig) legendConfig = this->legendConfig(); + if (!ternaryLegendConfig) ternaryLegendConfig = this->ternaryLegendConfig(); + + if ( this->hasResult() ) { - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); - RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); - - int integerTimeStep = static_cast(currentTimeStep); - - flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax); - flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero); - - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if (this->hasDynamicResult()) + if ( this->isFlowDiagOrInjectionFlooding() ) { - flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); - flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); + RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); + + int integerTimeStep = static_cast(currentTimeStep); + + flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax); + flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero); + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) + { + flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); + flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); + } + else + { + localMin = globalMin; + localMax = globalMax; + + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; + } + + CVF_ASSERT(legendConfig); + + legendConfig->disableAllTimeStepsRange(true); + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, + localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + if ( this->hasCategoryResult() ) + { + std::set, TupleCompare > categories; + //std::set > categories; + + std::vector tracerNames = this->flowDiagSolution()->tracerNames(); + int tracerIndex = 0; + for ( const auto& tracerName : tracerNames ) + { + RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName)); + cvf::Color3ub color(cvf::Color3::GRAY); + if ( well ) color = cvf::Color3ub(well->wellPipeColor()); + + categories.insert(std::make_tuple(tracerName, tracerIndex, color)); + ++tracerIndex; + } + + std::vector> reverseCategories; + for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt ) + { + reverseCategories.push_back(*tupIt); + } + + legendConfig->setCategoryItems(reverseCategories); + } } else { - localMin = globalMin; - localMax = globalMax; + RimEclipseCase* rimEclipseCase = nullptr; + this->firstAncestorOrThisOfType(rimEclipseCase); + CVF_ASSERT(rimEclipseCase); + if ( !rimEclipseCase ) return; - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } + RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); + CVF_ASSERT(eclipseCase); + if ( !eclipseCase ) return; - CVF_ASSERT(this->legendConfig()); + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); + CVF_ASSERT(cellResultsData); - this->legendConfig()->disableAllTimeStepsRange(true); - this->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - this->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), globalMin, globalMax); + cellResultsData->posNegClosestToZero(this->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); - if (this->hasCategoryResult()) - { - std::set, TupleCompare > categories; - //std::set > categories; - - std::vector tracerNames = this->flowDiagSolution()->tracerNames(); - int tracerIndex = 0; - for (const auto& tracerName : tracerNames) + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) { - RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName)); - cvf::Color3ub color(cvf::Color3::GRAY); - if (well) color = cvf::Color3ub(well->wellPipeColor()); + cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), currentTimeStep, localMin, localMax); + cellResultsData->posNegClosestToZero(this->scalarResultIndex(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); + } + else + { + localMin = globalMin; + localMax = globalMax; - categories.insert(std::make_tuple(tracerName, tracerIndex, color)); - ++tracerIndex; + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; } - std::vector> reverseCategories; - for (auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt) + CVF_ASSERT(legendConfig); + + legendConfig->disableAllTimeStepsRange(false); + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + if ( this->hasCategoryResult() ) { - reverseCategories.push_back(*tupIt); + if ( this->resultType() == RiaDefines::FORMATION_NAMES ) + { + const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); + legendConfig->setNamedCategoriesInverse(fnVector); + } + else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName() ) + { + std::vector< std::tuple > categories; + + caf::AppEnum wellPath(RiaDefines::WELL_PATH); + caf::AppEnum fishbone(RiaDefines::FISHBONES); + caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); + caf::AppEnum fracture(RiaDefines::FRACTURE); + + categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); + categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); + categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); + categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + + legendConfig->setCategoryItems(categories); + } + else + { + legendConfig->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->scalarResultIndex())); + } } - - this->legendConfig()->setCategoryItems(reverseCategories); } } - else + + // Ternary legend update { RimEclipseCase* rimEclipseCase = nullptr; this->firstAncestorOrThisOfType(rimEclipseCase); CVF_ASSERT(rimEclipseCase); - if (!rimEclipseCase) return; + if ( !rimEclipseCase ) return; RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); CVF_ASSERT(eclipseCase); - if (!eclipseCase) return; + if ( !eclipseCase ) return; + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); - CVF_ASSERT(cellResultsData); - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), globalMin, globalMax); - cellResultsData->posNegClosestToZero(this->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); - - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if (this->hasDynamicResult()) + size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); + if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 ) { - cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), currentTimeStep, localMin, localMax); - cellResultsData->posNegClosestToZero(this->scalarResultIndex(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); - } - else - { - localMin = globalMin; - localMax = globalMax; - - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } - - CVF_ASSERT(this->legendConfig()); - - this->legendConfig()->disableAllTimeStepsRange(false); - this->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - this->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - - if (this->hasCategoryResult()) - { - if (this->resultType() == RiaDefines::FORMATION_NAMES) + RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); { - const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); - this->legendConfig()->setNamedCategoriesInverse(fnVector); + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); + + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); + } } - else if (this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName()) + { - std::vector< std::tuple > categories; + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; - caf::AppEnum wellPath(RiaDefines::WELL_PATH); - caf::AppEnum fishbone(RiaDefines::FISHBONES); - caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); - caf::AppEnum fracture(RiaDefines::FRACTURE); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); - categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); - categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); - categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); - categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); - - legendConfig()->setCategoryItems(categories); + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); + } } - else + { - this->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->scalarResultIndex())); + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); + + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); + } } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index 184be112e3..9812e8cbdb 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -43,7 +43,9 @@ public: void setReservoirView(RimEclipseView* ownerReservoirView); RimEclipseView* reservoirView(); - void updateLegendData(size_t timestep); + void updateLegendData(size_t timestep, + RimLegendConfig* legendConfig = nullptr, + RimTernaryLegendConfig* ternaryLegendConfig = nullptr); RimLegendConfig* legendConfig(); caf::PdmChildField ternaryLegendConfig; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 998992f1cb..b42f0bb858 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -33,6 +33,7 @@ #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimFlowDiagSolution.h" +#include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimReservoirCellResultsStorage.h" #include "Rim3dView.h" @@ -409,6 +410,8 @@ void RimEclipseResultDefinition::loadDataAndUpdate() { viewLinker->updateCellResult(); } + RimGridView* eclView = dynamic_cast(view); + if (eclView) eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index e03df89591..ce556d43d9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -39,6 +39,7 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTextEditor.h" #include "cafProgressInfo.h" +#include "RimIntersectionCollection.h" namespace caf { template<> @@ -691,6 +692,7 @@ void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews() // a full display model rebuild is required reservoirViews[i]->hasUserRequestedAnimation = true; reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 209e894c39..4f3b3ffea1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -656,7 +656,9 @@ void RimEclipseView::updateCurrentTimeStep() if ((this->hasUserRequestedAnimation() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected()) { - m_crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep, + this->cellResult()->legendConfig()->scalarMapper(), + this->cellResult()->ternaryLegendConfig()->scalarMapper()); } else { @@ -1035,7 +1037,7 @@ void RimEclipseView::updateLegends() } m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); - this->cellEdgeResult()->legendConfig()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName())); + this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); } else { @@ -1060,71 +1062,24 @@ void RimEclipseView::updateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData) +void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, + RimEclipseCellColors* resultColors, + RigCaseCellResultsData* cellResultsData) { + resultColors->updateLegendData(m_currentTimeStep); + if (resultColors->hasResult()) { - resultColors->updateLegendData(m_currentTimeStep); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); - resultColors->legendConfig()->setTitle(cvfqt::Utils::toString(legendLabel + resultColors->resultVariableUiShortName())); + resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); } size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - RigCaseCellResultsData* gridCellResults = resultColors->currentGridCellResults(); - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); - } - } - - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); - } - } - - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); - } - } - if (resultColors->ternaryLegendConfig->legend()) { - resultColors->ternaryLegendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel)); + resultColors->ternaryLegendConfig->setTitle(legendLabel); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 2760eac9d4..6f510952fe 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -30,6 +30,7 @@ #include "RigFormationNames.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimTools.h" @@ -499,6 +500,7 @@ void RimGeoMechCase::updateFormationNamesData() view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); + geomView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 9ff629b103..ed5f0599ee 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -30,6 +30,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilter.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimViewLinker.h" @@ -214,7 +215,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha // Get the possible property filter owner RimGeoMechPropertyFilter* propFilter = dynamic_cast(this->parentField()->ownerObject()); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); RimPlotCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); @@ -261,7 +262,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha if (view) view->scheduleGeometryRegen(PROPERTY_FILTERED); } - if (view) view->scheduleCreateDisplayModelAndRedraw(); + if ( view ) + { + view->scheduleCreateDisplayModelAndRedraw(); + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } if (dynamic_cast(this)) { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index c0cf4e57f5..1498ffde5d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -290,7 +290,9 @@ void RimGeoMechView::updateCurrentTimeStep() if (this->cellResult()->hasResult()) { - m_crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep, + this->cellResult()->legendConfig()->scalarMapper(), + nullptr); } else { @@ -344,12 +346,22 @@ void RimGeoMechView::resetLegendsInViewer() //-------------------------------------------------------------------------------------------------- void RimGeoMechView::updateLegends() { - if (m_viewer) + if ( m_viewer ) { m_viewer->removeAllColorLegends(); - } - if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() + this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); + + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex) +{ + if (!m_geomechCase || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() || !(cellResult()->resultAddress().isValid()) ) { @@ -366,16 +378,16 @@ void RimGeoMechView::updateLegends() RigFemResultAddress resVarAddress = cellResult()->resultAddress(); - gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); - gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, timeStepIndex, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero); gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); - cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + if (cellResult()->hasCategoryResult()) { std::vector fnVector; @@ -383,18 +395,16 @@ void RimGeoMechView::updateLegends() { fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames(); } - cellResult()->legendConfig->setNamedCategoriesInverse(fnVector); + legendConfig->setNamedCategoriesInverse(fnVector); } - - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); - cvf::String legendTitle = cvfqt::Utils::toString( + QString legendTitle = caf::AppEnum(cellResult->resultPositionType()).uiText() + "\n" - + cellResult->resultFieldUiName()); + + cellResult->resultFieldUiName(); if (!cellResult->resultComponentUiName().isEmpty()) { - legendTitle += ", " + cvfqt::Utils::toString(cellResult->resultComponentUiName()); + legendTitle += ", " + cellResult->resultComponentUiName(); } if ( cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" || cellResult->resultFieldName() == "POR-Bar" @@ -408,7 +418,7 @@ void RimGeoMechView::updateLegends() legendTitle += " [GPa]"; } - cellResult()->legendConfig->setTitle(legendTitle); + legendConfig->setTitle(legendTitle); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 92b9d2b4e1..f874145529 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -41,6 +41,7 @@ class RimGeoMechPropertyFilterCollection; class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; +class RimLegendConfig; namespace cvf { class CellRangeFilter; @@ -84,6 +85,8 @@ public: virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override; + void updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index a1f7eed239..4a5b47eaeb 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -20,6 +20,7 @@ #include "RimIntersectionCollection.h" #include "Rim2dIntersectionViewCollection.h" +#include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCase.h" #include "RimIntersection.h" @@ -95,7 +96,9 @@ void RimIntersectionCollection::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) +void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper) { if(!this->isActive()) return; @@ -103,7 +106,7 @@ void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) { if(cs->isActive) { - cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex); + cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex, scalarColorMapper, ternaryColorMapper); } } @@ -186,6 +189,17 @@ void RimIntersectionCollection::syncronize2dIntersectionViews() ownerCase->intersectionViewCollection()->syncFromExistingIntersections(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::scheduleCreateDisplayModelAndRedraw2dIntersectionViews() +{ + for (RimIntersection* isection: m_intersections) + { + isection->correspondingIntersectionView()->scheduleCreateDisplayModelAndRedraw(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 167338c1e7..ec46b1e714 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -27,10 +27,12 @@ class RimIntersection; class RimIntersectionBox; class RimEclipseCellColors; class RimSimWellInView; +class RivTernaryScalarMapper; namespace cvf { class ModelBasicList; class Transform; + class ScalarMapper; } //================================================================================================== @@ -59,11 +61,14 @@ public: void updateIntersectionBoxGeometry(); void syncronize2dIntersectionViews(); + void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); // Visualization interface void applySingleColorEffect(); - void updateCellResultColor(size_t timeStepIndex); + void updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper); void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); protected: diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 9cb5b85d36..6baafb6d97 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -51,6 +51,7 @@ #include "cvfqtUtils.h" #include +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); @@ -191,7 +192,7 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateLegend(); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) @@ -203,6 +204,8 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, } view->updateCurrentTimeStepAndRedraw(); + + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } #ifdef USE_PROTOTYPE_FEATURE_FRACTURES @@ -664,10 +667,11 @@ QString RimLegendConfig::categoryNameFromCategoryValue(double categoryResultValu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setTitle(const cvf::String& title) +void RimLegendConfig::setTitle(const QString& title) { - m_scalarMapperLegend->setTitle(title); - m_categoryLegend->setTitle(title); + auto cvfTitle = cvfqt::Utils::toString(title); + m_scalarMapperLegend->setTitle(cvfTitle); + m_categoryLegend->setTitle(cvfTitle); } //-------------------------------------------------------------------------------------------------- @@ -692,6 +696,7 @@ void RimLegendConfig::setUiValuesFromLegendConfig(const RimLegendConfig* otherLe { QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); + this->updateLegend(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 2755264acf..41f0da15e8 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -114,7 +114,9 @@ public: void setCategoryItems(const std::vector>& categories); QString categoryNameFromCategoryValue(double categoryResultValue) const; - void setTitle(const cvf::String& title); + void setTitle(const QString& title); + + void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } cvf::OverlayItem* legend(); @@ -134,7 +136,6 @@ private: double roundToNumSignificantDigits(double value, double precision); friend class RimViewLinker; - void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); static cvf::Color3ubArray colorArrayFromColorType(ColorRangesType colorType); diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index e2254f286f..46bbf80131 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -289,7 +289,7 @@ void RimStimPlanColors::updateLegendData() legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); } - legendConfig->setTitle(cvfqt::Utils::toString(m_resultNameAndUnit())); + legendConfig->setTitle(m_resultNameAndUnit()); } } diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 38613fde4e..b507afc267 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -23,6 +23,7 @@ #include "RiaColorTables.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimViewLinker.h" #include "RivTernarySaturationOverlayItem.h" @@ -146,7 +147,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed updateLabelText(); updateLegend(); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) @@ -158,6 +159,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed } view->updateCurrentTimeStepAndRedraw(); + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } @@ -244,6 +246,7 @@ void RimTernaryLegendConfig::setUiValuesFromLegendConfig(const RimTernaryLegendC { QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); + this->updateLegend(); } //-------------------------------------------------------------------------------------------------- @@ -316,6 +319,14 @@ void RimTernaryLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr uiOrdering.skipRemainingFields(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() const +{ + return m_legend.p(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -324,6 +335,14 @@ RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() return m_legend.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTernaryLegendConfig::setTitle(const QString& title) +{ + m_legend->setTitle(cvfqt::Utils::toString(title)); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -462,7 +481,7 @@ void RimTernaryLegendConfig::updateLabelText() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() +const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const { return m_scalarMapper.p(); } diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 544a980f36..de4bf7bb06 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -65,13 +65,17 @@ public: RimTernaryLegendConfig(); virtual ~RimTernaryLegendConfig(); + void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const; void recreateLegend(); - RivTernarySaturationOverlayItem* legend(); - RivTernaryScalarMapper* scalarMapper(); + const RivTernarySaturationOverlayItem* legend() const; + RivTernarySaturationOverlayItem* legend(); + void setTitle(const QString& title); + + const RivTernaryScalarMapper* scalarMapper() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -83,9 +87,6 @@ private: void updateLabelText(); double roundToNumSignificantDigits(double value, double precision); - friend class RimViewLinker; - void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); - private: caf::PdmField precision; caf::PdmField rangeMode; diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index 18aa3a9f90..63e3f98886 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -48,6 +48,7 @@ #include "cafPdmUiTreeOrdering.h" #include +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimViewController, "ViewController"); //-------------------------------------------------------------------------------------------------- @@ -688,6 +689,11 @@ void RimViewController::scheduleCreateDisplayModelAndRedrawForDependentView() co this->managedView()->scheduleCreateDisplayModelAndRedraw(); } } + + if (this->isResultColorControlled() && this->managedView() ) + { + this->managedView()->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index 5e992a0bea..5a05568c83 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -33,6 +33,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimLegendConfig.h" #include "RimProject.h" #include "RimTernaryLegendConfig.h" @@ -152,10 +153,10 @@ void RimViewLinker::updateCellResult() eclipseView->cellResult()->legendConfig()->updateLegend(); eclipseView->cellResult()->ternaryLegendConfig()->setUiValuesFromLegendConfig(masterEclipseView->cellResult()->ternaryLegendConfig()); - eclipseView->cellResult()->ternaryLegendConfig()->updateLegend(); } eclipseView->scheduleCreateDisplayModelAndRedraw(); + eclipseView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } eclipseView->cellResult()->updateIconState(); @@ -190,6 +191,7 @@ void RimViewLinker::updateCellResult() } geoView->scheduleCreateDisplayModelAndRedraw(); + geoView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } geoView->cellResult()->updateIconState(); diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index 2b62407c09..529f5adebe 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -39,6 +39,7 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInViewCollection.h" @@ -550,6 +551,7 @@ public: // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index ce3749ca88..3dad4c480b 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -38,6 +38,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipseInputPropertyCollection.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimGeoMechView.h" #include "RimGeoMechCase.h" @@ -690,6 +691,7 @@ public: // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } @@ -1053,6 +1055,8 @@ public: // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } } }