diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 8f7e85cf5d..92ccd3ef22 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -40,6 +40,8 @@ #include "RimWellLogPlotCollection.h" #include "RimWellLogTrack.h" #include "RimWellLogWbsCurve.h" +#include "RimWellMeasurement.h" +#include "RimWellMeasurementCurve.h" #include "RimWellPath.h" #include "RicWellLogTools.h" @@ -320,11 +322,12 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore curve->setSmoothingThreshold( 0.002 ); } - std::vector measurementNames; - measurementNames.push_back( "XLOT" ); - for ( size_t i = 0; i < measurementNames.size(); i++ ) + for ( QString measurementKind : RimWellMeasurement::measurementKindsForWellBoreStability() ) { - RicWellLogTools::addWellMeasurementCurve( stabilityCurvesTrack, wellPath, measurementNames[i] ); + RimWellMeasurementCurve* curve = RicWellLogTools::addWellMeasurementCurve( stabilityCurvesTrack, + wellPath, + measurementKind ); + curve->loadDataAndUpdate( false ); } stabilityCurvesTrack->setAutoScaleXEnabled( true ); diff --git a/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp index b3b84d5c4a..bc666fcbae 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp @@ -21,6 +21,8 @@ #include "RiaApplication.h" #include "RiaLogging.h" +#include "Rim3dView.h" +#include "RimGridView.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" #include "RimProject.h" @@ -92,6 +94,13 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked ) wellMeasurement->setQuality( measurement.quality ); wellMeasurement->setKind( measurement.kind ); wellMeasurement->setRemark( measurement.remark ); + + // Ignore values for kinds which is known to not have values + if ( !RimWellMeasurement::kindHasValue( measurement.kind ) ) + { + wellMeasurement->setValue( 0.0 ); + } + wellPathCollection->measurementCollection()->appendMeasurement( wellMeasurement ); lastWellMeasurement = wellMeasurement; } @@ -99,6 +108,17 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked ) if ( app->project() ) { + std::vector views; + app->project()->allViews( views ); + for ( auto& view : views ) + { + RimGridView* gridView = dynamic_cast( view ); + if ( gridView ) + { + gridView->updateWellMeasurements(); + } + } + app->project()->scheduleCreateDisplayModelAndRedrawAllViews(); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index c48e8426d4..26ae70efaa 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -42,6 +42,7 @@ #include "RimWellMeasurement.h" #include "RimWellMeasurementCollection.h" #include "RimWellMeasurementFilter.h" +#include "RimWellMeasurementInView.h" #include "RimWellMeasurementInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathAttribute.h" @@ -255,32 +256,6 @@ void RivWellPathPartMgr::appendWellPathAttributesToModel( cvf::ModelBasicList* } } -cvf::Color3f RivWellPathPartMgr::mapWellMeasurementToColor( const QString& measurementKind, double value ) -{ - if ( measurementKind == "TH" ) return cvf::Color3f::RED; - if ( measurementKind == "LE" ) return cvf::Color3f::BLUE; - if ( measurementKind == "BA" ) return cvf::Color3f::GREEN; - if ( measurementKind == "CORE" ) return cvf::Color3f::BLACK; - - QStringList rangeBasedMeasurements; - rangeBasedMeasurements << "XLOT" - << "LOT" - << "FIT" - << "MCF" - << "MNF" - << "PPG"; - if ( rangeBasedMeasurements.contains( measurementKind ) ) - { - cvf::ScalarMapperContinuousLinear mapper; - mapper.setColors( RiaColorTables::normalPaletteColors().color3ubArray() ); - mapper.setRange( 1.0, 3.0 ); - cvf::Color3ub color = mapper.mapToColor( value ); - return cvf::Color3f( color ); - } - - return cvf::Color3f::RED; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -301,54 +276,57 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList* if ( !gridView->measurementCollection()->isChecked() ) return; - std::vector measurementKinds = gridView->measurementCollection()->measurementKinds(); - - RivPipeGeometryGenerator geoGenerator; - std::vector wellMeasurements = - RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(), - *wellPathCollection, - *m_rimWellPath, - measurementKinds ); - - for ( RimWellMeasurement* wellMeasurement : wellMeasurements ) + for ( RimWellMeasurementInView* wellMeasurementInView : gridView->measurementCollection()->measurements() ) { - double wellPathRadius = this->wellPathRadius( characteristicCellSize, this->wellPathCollection() ); - double startMD = wellMeasurement->MD() - wellPathRadius * 0.5; - double endMD = wellMeasurement->MD() + wellPathRadius * 0.5; - - std::vector displayCoords; - displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( - m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) ); - displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( - m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) ); - displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( - m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) ); - displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( - m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) ); - - std::vector radii; - radii.push_back( wellPathRadius ); - radii.push_back( wellPathRadius * 2.5 ); - radii.push_back( wellPathRadius * 2.5 ); - radii.push_back( wellPathRadius ); - - cvf::ref objectSourceInfo = new RivObjectSourceInfo( wellMeasurement ); - - cvf::Collection parts; - cvf::Color3f color = mapWellMeasurementToColor( wellMeasurement->kind(), wellMeasurement->value() ); - - // Use the view legend config to find color, if only one type of measurement is selected. - if ( measurementKinds.size() == 1 ) + if ( wellMeasurementInView->isChecked() && wellMeasurementInView->isWellChecked( m_rimWellPath->name() ) ) { - color = cvf::Color3f( gridView->measurementCollection()->legendConfig()->scalarMapper()->mapToColor( - wellMeasurement->value() ) ); - } + std::vector measurementKinds; + measurementKinds.push_back( wellMeasurementInView->measurementKind() ); - geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color ); - for ( auto part : parts ) - { - part->setSourceInfo( objectSourceInfo.p() ); - model->addPart( part.p() ); + RivPipeGeometryGenerator geoGenerator; + std::vector wellMeasurements = + RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(), + *wellPathCollection, + *m_rimWellPath, + measurementKinds ); + + for ( RimWellMeasurement* wellMeasurement : wellMeasurements ) + { + double wellPathRadius = this->wellPathRadius( characteristicCellSize, this->wellPathCollection() ); + double startMD = wellMeasurement->MD() - wellPathRadius * 0.5; + double endMD = wellMeasurement->MD() + wellPathRadius * 0.5; + + std::vector displayCoords; + displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( + m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) ); + displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( + m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMD ) ) ); + displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( + m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) ); + displayCoords.push_back( displayCoordTransform->transformToDisplayCoord( + m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMD ) ) ); + + std::vector radii; + radii.push_back( wellPathRadius ); + radii.push_back( wellPathRadius * 2.5 ); + radii.push_back( wellPathRadius * 2.5 ); + radii.push_back( wellPathRadius ); + + cvf::ref objectSourceInfo = new RivObjectSourceInfo( wellMeasurement ); + + cvf::Collection parts; + + // Use the view legend config to find color, if only one type of measurement is selected. + cvf::Color3f color = cvf::Color3f( + wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) ); + + geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color ); + for ( auto part : parts ) + { + part->setSourceInfo( objectSourceInfo.p() ); + model->addPart( part.p() ); + } + } } } } @@ -815,7 +793,6 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel( cvf::ModelBasicList* appendFishboneSubsPartsToModel( model, displayCoordTransform, characteristicCellSize ); appendImportedFishbonesToModel( model, displayCoordTransform, characteristicCellSize ); appendWellPathAttributesToModel( model, displayCoordTransform, characteristicCellSize ); - appendWellMeasurementsToModel( model, displayCoordTransform, characteristicCellSize ); RimGridView* gridView = dynamic_cast( m_rimView.p() ); if ( !gridView ) return; @@ -880,6 +857,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* appendPerforationsToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize, false ); appendVirtualTransmissibilitiesToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize ); + appendWellMeasurementsToModel( model, displayCoordTransform, characteristicCellSize ); RimGridView* gridView = dynamic_cast( m_rimView.p() ); if ( !gridView ) return; diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index e413b23947..7ed4987178 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -146,6 +146,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.h ) @@ -296,6 +297,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 42dc04509a..3d986b77d2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -76,6 +76,7 @@ #include "RimViewLinker.h" #include "RimViewNameConfig.h" #include "RimVirtualPerforationResults.h" +#include "RimWellMeasurementInView.h" #include "RimWellMeasurementInViewCollection.h" #include "RimWellPathCollection.h" @@ -931,6 +932,8 @@ void RimEclipseView::onLoadDataAndUpdate() m_virtualPerforationResult->loadData(); } + m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection(); + this->scheduleCreateDisplayModelAndRedraw(); } @@ -1308,10 +1311,15 @@ void RimEclipseView::onUpdateLegends() isUsingOverrideViewer() ); } - if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() ) + if ( m_wellMeasurementCollection->isChecked() ) { - m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), - isUsingOverrideViewer() ); + for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() ) + { + if ( wellMeasurement->isChecked() && wellMeasurement->legendConfig()->showLegend() ) + { + wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() ); + } + } } } @@ -1859,7 +1867,10 @@ void RimEclipseView::onResetLegendsInViewer() sepInterResDef->ternaryLegendConfig()->recreateLegend(); } - m_wellMeasurementCollection->legendConfig()->recreateLegend(); + for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() ) + { + wellMeasurement->legendConfig()->recreateLegend(); + } nativeOrOverrideViewer()->removeAllColorLegends(); } @@ -2019,7 +2030,10 @@ std::vector RimEclipseView::legendConfigs() const absLegends.push_back( sepInterResDef->ternaryLegendConfig() ); } - absLegends.push_back( m_wellMeasurementCollection->legendConfig() ); + for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() ) + { + absLegends.push_back( wellMeasurement->legendConfig() ); + } return absLegends; } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 3f2f7dbc2c..441489a48a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -46,6 +46,7 @@ #include "RimTernaryLegendConfig.h" #include "RimViewLinker.h" #include "RimViewNameConfig.h" +#include "RimWellMeasurementInView.h" #include "RimWellMeasurementInViewCollection.h" #include "Riu3DMainWindowTools.h" @@ -174,6 +175,7 @@ void RimGeoMechView::onLoadDataAndUpdate() updateMdiWindowVisibility(); this->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters(); + m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection(); this->scheduleCreateDisplayModelAndRedraw(); @@ -428,7 +430,10 @@ void RimGeoMechView::onResetLegendsInViewer() sepInterResDef->ternaryLegendConfig()->recreateLegend(); } - m_wellMeasurementCollection->legendConfig()->recreateLegend(); + for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() ) + { + wellMeasurement->legendConfig()->recreateLegend(); + } nativeOrOverrideViewer()->removeAllColorLegends(); } @@ -481,10 +486,16 @@ void RimGeoMechView::onUpdateLegends() } } - if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() ) + if ( m_wellMeasurementCollection->isChecked() ) { - m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), - isUsingOverrideViewer() ); + for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() ) + { + if ( wellMeasurement->isChecked() && wellMeasurement->legendConfig()->showLegend() ) + { + wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), + isUsingOverrideViewer() ); + } + } } } } @@ -587,6 +598,11 @@ std::vector RimGeoMechView::legendConfigs() const absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() ); } + for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() ) + { + absLegendConfigs.push_back( wellMeasurement->legendConfig() ); + } + return absLegendConfigs; } @@ -715,6 +731,11 @@ bool RimGeoMechView::isTimeStepDependentDataVisible() const { return true; } + if ( m_wellMeasurementCollection->isChecked() ) + { + return true; + } + return false; } diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index c1d2250b92..09102a95c2 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -557,3 +557,11 @@ RimViewLinker* RimGridView::viewLinkerIfMasterView() const return nullptr; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::updateWellMeasurements() +{ + m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection(); +} diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h index 311115511c..f42388c7f8 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.h +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -71,6 +71,8 @@ public: int fontSize, bool forceChange = false ) override; + void updateWellMeasurements(); + protected: virtual void updateViewFollowingRangeFilterUpdates(); void onClearReservoirCellVisibilitiesIfNeccessary() override; diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index d20d3986e4..058d15f47d 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -35,6 +35,7 @@ #include "RimIntersectionCollection.h" #include "RimStimPlanColors.h" #include "RimViewLinker.h" +#include "RimWellMeasurementInView.h" #include "cafCategoryLegend.h" #include "cafCategoryMapper.h" @@ -923,12 +924,15 @@ QList this->firstAncestorOrThisOfType( gmCellColors ); RimCellEdgeColors* eclCellEdgColors = nullptr; this->firstAncestorOrThisOfType( eclCellEdgColors ); + RimWellMeasurementInView* wellMeasurementInView = nullptr; + this->firstAncestorOrThisOfType( wellMeasurementInView ); if ( ( eclCellColors && eclCellColors->hasCategoryResult() ) || ( gmCellColors && gmCellColors->hasCategoryResult() ) || ( eclCellEdgColors && eclCellEdgColors->hasCategoryResult() ) || ( ensembleCurveSet && ensembleCurveSet->currentEnsembleParameterType() == EnsembleParameter::TYPE_TEXT ) || - ( crossPlotCurveSet && crossPlotCurveSet->groupingByCategoryResult() ) ) + ( crossPlotCurveSet && crossPlotCurveSet->groupingByCategoryResult() ) || + ( wellMeasurementInView && wellMeasurementInView->hasCategoryResult() ) ) { isCategoryResult = true; } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp index e8e7e0289a..c8480f1367 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp @@ -33,6 +33,7 @@ #include "RimWellLogPlotCollection.h" #include "RimWellLogTrack.h" #include "RimWellLogWbsCurve.h" +#include "RimWellMeasurementCurve.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -436,8 +437,9 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector( curve ); - RimWellLogExtractionCurve* extractionCurve = dynamic_cast( curve ); + RimWellLogFileCurve* fileCurve = dynamic_cast( curve ); + RimWellLogExtractionCurve* extractionCurve = dynamic_cast( curve ); + RimWellMeasurementCurve* measurementCurve = dynamic_cast( curve ); if ( fileCurve ) { if ( wellPathToApply() != nullptr ) @@ -525,6 +527,13 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vectorupdateConnectedEditors(); } } + else if ( measurementCurve ) + { + if ( wellPathToApply() != nullptr ) + { + measurementCurve->setWellPath( wellPathToApply() ); + } + } } for ( RimWellLogTrack* track : tracks ) diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurement.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurement.cpp index c5fc290898..92cd684be3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurement.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurement.cpp @@ -177,3 +177,37 @@ void RimWellMeasurement::fieldChangedByUi( const caf::PdmFieldHandle* changedFie /// //-------------------------------------------------------------------------------------------------- void RimWellMeasurement::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimWellMeasurement::mapToColor( const QString& measurementKind ) +{ + if ( measurementKind == "DP" ) return cvf::Color3f::RED; + if ( measurementKind == "TH" ) return cvf::Color3f::RED; + if ( measurementKind == "LE" ) return cvf::Color3f::BLUE; + if ( measurementKind == "BA" ) return cvf::Color3f::GREEN; + if ( measurementKind == "CORE" ) return cvf::Color3f::BLACK; + + return cvf::Color3f::CRIMSON; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellMeasurement::kindHasValue( const QString& measurementKind ) +{ + QStringList valueLessKind; + valueLessKind << "DP" + << "LE" + << "TH" + << "BA" + << "CORE"; + return !valueLessKind.contains( measurementKind ); +} + +std::vector RimWellMeasurement::measurementKindsForWellBoreStability() +{ + std::vector wbsMeasurementKinds = {"XLOT", "LOT", "FIT"}; + return wbsMeasurementKinds; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurement.h b/ApplicationCode/ProjectDataModel/RimWellMeasurement.h index c9f15ebc84..76da75388f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurement.h +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurement.h @@ -22,6 +22,8 @@ #include "cafPdmField.h" +#include "cvfColor3.h" + #include #include @@ -53,6 +55,10 @@ public: QString remark() const; void setRemark( const QString& remark ); + static bool kindHasValue( const QString& measurementKind ); + static cvf::Color3f mapToColor( const QString& measurementKind ); + static std::vector measurementKindsForWellBoreStability(); + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.cpp index b01edc4b77..b5a225f516 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.cpp @@ -59,6 +59,7 @@ RimWellMeasurementCurve::RimWellMeasurementCurve() CAF_PDM_InitFieldNoDefault( &m_measurementKind, "CurveMeasurementKind", "Measurement Kind", "", "", "" ); m_measurementKind.uiCapability()->setUiTreeChildrenHidden( true ); + m_measurementKind.uiCapability()->setUiHidden( true ); m_wellPath = nullptr; } @@ -219,7 +220,6 @@ void RimWellMeasurementCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" ); curveDataGroup->add( &m_wellPath ); - curveDataGroup->add( &m_measurementKind ); caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" ); RimPlotCurve::appearanceUiOrdering( *appearanceGroup ); @@ -251,49 +251,12 @@ QList if ( fieldNeedingOptions == &m_wellPath ) { - auto wellPathColl = RimTools::wellPathCollection(); - if ( wellPathColl ) - { - caf::PdmChildArrayField& wellPaths = wellPathColl->wellPaths; - - for ( size_t i = 0; i < wellPaths.size(); i++ ) - { - options.push_back( caf::PdmOptionItemInfo( wellPaths[i]->name(), wellPaths[i] ) ); - } - - if ( options.size() > 0 ) - { - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); - } - } - } - - if ( fieldNeedingOptions == &m_measurementKind ) - { - if ( m_wellPath() ) - { - // TODO: take all options from somewhere and filter based on - // what the current well path has set. - options.push_back( caf::PdmOptionItemInfo( "XLOT", "XLOT" ) ); - options.push_back( caf::PdmOptionItemInfo( "LOT", "LOT" ) ); - options.push_back( caf::PdmOptionItemInfo( "FIT", "FIT" ) ); - options.push_back( caf::PdmOptionItemInfo( "DP", "DP" ) ); - } + RimTools::wellPathOptionItems( &options ); } return options; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellMeasurementCurve::initAfterRead() -{ - if ( !m_wellPath ) return; - - // TODO: do something here? -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -301,11 +264,7 @@ QString RimWellMeasurementCurve::createCurveAutoName() { if ( m_wellPath ) { - QStringList name; - name.push_back( wellName() ); - name.push_back( measurementKind() ); - - return name.join( ", " ); + return measurementKind(); } return "Empty curve"; diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.h b/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.h index d80122f4c0..3702fb5360 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementCurve.h @@ -63,7 +63,6 @@ protected: void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) override; - void initAfterRead() override; RiuQwtSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind ); cvf::Color3f getColorForMeasurementKind( const QString& measurementKind ); diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp new file mode 100644 index 0000000000..010a51b949 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.cpp @@ -0,0 +1,280 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimWellMeasurementInView.h" + +#include "Rim3dView.h" +#include "RimGridView.h" +#include "RimProject.h" +#include "RimRegularLegendConfig.h" +#include "RimTools.h" +#include "RimWellLogTrack.h" +#include "RimWellMeasurement.h" +#include "RimWellMeasurementCollection.h" +#include "RimWellMeasurementFilter.h" +#include "RimWellPathCollection.h" + +#include "RiuViewer.h" + +#include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiTableViewEditor.h" +#include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeSelectionEditor.h" + +#include + +CAF_PDM_SOURCE_INIT( RimWellMeasurementInView, "WellMeasurementInView" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellMeasurementInView::RimWellMeasurementInView() +{ + CAF_PDM_InitObject( "Well Measurement", "", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_measurementKind, "MeasurementKind", "Measurement Kind", "", "", "" ); + m_measurementKind.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + m_legendConfig = new RimRegularLegendConfig(); + m_legendConfig.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" ); + m_wells.uiCapability()->setAutoAddingOptionFromValue( false ); + m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + m_wells.xmlCapability()->disableIO(); + + this->setName( "Well Measurement" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellMeasurementInView::~RimWellMeasurementInView() +{ + delete m_legendConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellMeasurementInView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, + QString uiConfigName /*= ""*/ ) +{ + uiTreeOrdering.add( &m_legendConfig ); + uiTreeOrdering.skipRemainingChildren( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellMeasurementInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + updateLegendData(); + RimGridView* rimGridView = nullptr; + this->firstAncestorOrThisOfTypeAsserted( rimGridView ); + rimGridView->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig* RimWellMeasurementInView::legendConfig() +{ + return m_legendConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellMeasurementInView::updateLegendData() +{ + RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); + if ( !wellPathCollection ) return false; + + RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection(); + if ( !wellMeasurementCollection ) return false; + + if ( hasCategoryResult() ) + { + cvf::Color3ub color = cvf::Color3ub( RimWellMeasurement::mapToColor( measurementKind() ) ); + std::vector> categories; + categories.push_back( std::make_tuple( measurementKind(), 0, color ) ); + m_legendConfig->setCategoryItems( categories ); + m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + measurementKind() ); + m_legendConfig->setMappingMode( RimRegularLegendConfig::CATEGORY_INTEGER ); + return true; + } + else + { + std::vector selectedMeasurementKinds; + selectedMeasurementKinds.push_back( m_measurementKind ); + std::vector wellMeasurements = + RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(), + selectedMeasurementKinds ); + + double minValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + double posClosestToZero = HUGE_VAL; + double negClosestToZero = -HUGE_VAL; + + for ( auto& measurement : wellMeasurements ) + { + minValue = std::min( measurement->value(), minValue ); + maxValue = std::max( measurement->value(), maxValue ); + } + + if ( minValue != HUGE_VAL ) + { + m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + selectedMeasurementKinds[0] ); + m_legendConfig->setAutomaticRanges( minValue, maxValue, minValue, maxValue ); + m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero ); + return true; + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellMeasurementInView::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, + bool isUsingOverrideViewer ) +{ + bool addToViewer = updateLegendData(); + if ( addToViewer ) + { + nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( m_legendConfig->titledOverlayFrame(), + isUsingOverrideViewer ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellMeasurementInView::hasMeasurementKindForWell( const RimWellPath* wellPath, + const RimWellPathCollection* wellPathCollection, + const std::vector& measurements, + const QString& measurementKind ) +{ + for ( auto measurement : measurements ) + { + if ( measurement->kind() == measurementKind ) + { + RimWellPath* measurementWellPath = wellPathCollection->tryFindMatchingWellPath( measurement->wellName() ); + if ( wellPath && wellPath == measurementWellPath ) + { + return true; + } + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList + RimWellMeasurementInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +{ + QList options; + if ( fieldNeedingOptions == &m_wells ) + { + RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); + if ( wellPathCollection ) + { + std::vector measurements = wellPathCollection->measurementCollection()->measurements(); + + // Find wells with a given measurement. + std::set wellsWithMeasurementKind; + for ( const auto& well : wellPathCollection->wellPaths ) + { + if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) ) + wellsWithMeasurementKind.insert( well->name() ); + } + + for ( const auto& wellName : wellsWithMeasurementKind ) + { + options.push_back( caf::PdmOptionItemInfo( wellName, wellName ) ); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellMeasurementInView::measurementKind() const +{ + return m_measurementKind; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellMeasurementInView::setMeasurementKind( const QString& measurementKind ) +{ + m_measurementKind = measurementKind; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellMeasurementInView::hasCategoryResult() const +{ + return !RimWellMeasurement::kindHasValue( measurementKind() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellMeasurementInView::isWellChecked( const QString& wellName ) const +{ + return std::find( m_wells.v().begin(), m_wells.v().end(), wellName ) != m_wells.v().end(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellMeasurementInView::setAllWellsSelected() +{ + RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); + if ( wellPathCollection ) + { + std::vector measurements = wellPathCollection->measurementCollection()->measurements(); + + // Find wells with a given measurement. + std::set wellsWithMeasurementKind; + for ( const auto& well : wellPathCollection->wellPaths ) + { + if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) ) + wellsWithMeasurementKind.insert( well->name() ); + } + + for ( const auto& wellName : wellsWithMeasurementKind ) + { + m_wells.v().push_back( wellName ); + } + } +} diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h new file mode 100644 index 0000000000..7eb4e3e8ac --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInView.h @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RimCheckableNamedObject.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" + +#include + +class RimWellMeasurement; +class RimRegularLegendConfig; +class RimWellPath; +class RimWellPathCollection; +class RiuViewer; + +class RimWellMeasurementInView : public RimCheckableNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellMeasurementInView(); + ~RimWellMeasurementInView() override; + + RimRegularLegendConfig* legendConfig(); + QString measurementKind() const; + void setMeasurementKind( const QString& measurementKind ); + bool isWellChecked( const QString& wellName ) const; + void setAllWellsSelected(); + + void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer ); + + bool hasCategoryResult() const; + +protected: + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) override; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) override; + + bool updateLegendData(); + static bool hasMeasurementKindForWell( const RimWellPath* wellPath, + const RimWellPathCollection* wellPathCollection, + const std::vector& measurements, + const QString& measurementKind ); + +private: + caf::PdmChildField m_legendConfig; + caf::PdmField m_measurementKind; + caf::PdmField> m_wells; +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp index ed27b6352f..252e82d0b8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp @@ -18,6 +18,7 @@ #include "RimWellMeasurementInViewCollection.h" #include "Rim3dView.h" +#include "RimGridView.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimTools.h" @@ -25,10 +26,9 @@ #include "RimWellMeasurement.h" #include "RimWellMeasurementCollection.h" #include "RimWellMeasurementFilter.h" +#include "RimWellMeasurementInView.h" #include "RimWellPathCollection.h" -#include "RiuViewer.h" - #include "cafCmdFeatureMenuBuilder.h" #include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTreeOrdering.h" @@ -43,17 +43,12 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementInViewCollection, "WellMeasurementsInView //-------------------------------------------------------------------------------------------------- RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection() { - CAF_PDM_InitObject( "Well Measurement", "", "", "" ); + CAF_PDM_InitObject( "Well Measurements", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); - m_legendConfig = new RimRegularLegendConfig(); - m_legendConfig.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds", "", "", "" ); + m_measurementsInView.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_measurementKinds, "MeasurementKinds", "Measurent Kinds", "", "", "" ); - m_measurementKinds.uiCapability()->setAutoAddingOptionFromValue( false ); - m_measurementKinds.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - m_measurementKinds.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - m_measurementKinds.xmlCapability()->disableIO(); + m_isChecked = false; this->setName( "Well Measurements" ); } @@ -61,18 +56,31 @@ RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection() +RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellMeasurementInViewCollection::measurements() const { - delete m_legendConfig; + std::vector attrs; + + for ( auto attr : m_measurementsInView ) + { + attrs.push_back( attr.p() ); + } + return attrs; } +//-------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellMeasurementInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { - uiTreeOrdering.add( &m_legendConfig ); + uiTreeOrdering.add( &m_measurementsInView ); uiTreeOrdering.skipRemainingChildren( true ); } @@ -83,115 +91,54 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_isChecked || changedField == &m_measurementKinds || changedField == &m_legendConfig ) - { - updateLegendData(); - RimProject* proj; - this->firstAncestorOrThisOfTypeAsserted( proj ); - proj->scheduleCreateDisplayModelAndRedrawAllViews(); - } + RimGridView* rimGridView = nullptr; + this->firstAncestorOrThisOfTypeAsserted( rimGridView ); + rimGridView->scheduleCreateDisplayModelAndRedraw(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimRegularLegendConfig* RimWellMeasurementInViewCollection::legendConfig() -{ - return m_legendConfig; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimWellMeasurementInViewCollection::updateLegendData() +void RimWellMeasurementInViewCollection::syncWithChangesInWellMeasurementCollection() { RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); - if ( !wellPathCollection ) return false; - - RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection(); - if ( !wellMeasurementCollection ) return false; - - std::vector selectedMeasurementKinds = measurementKinds(); - - // Only show legend when only one measurement is selected - if ( selectedMeasurementKinds.size() == 1 ) + if ( wellPathCollection ) { - std::vector wellMeasurements = - RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(), - selectedMeasurementKinds ); + const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection(); - double minValue = HUGE_VAL; - double maxValue = -HUGE_VAL; - double posClosestToZero = HUGE_VAL; - double negClosestToZero = -HUGE_VAL; - - for ( auto& measurement : wellMeasurements ) + // Make a set of the measurement kinds already present + std::set currentMeasurementKinds; + for ( RimWellMeasurementInView* wellMeasurement : measurements() ) { - minValue = std::min( measurement->value(), minValue ); - maxValue = std::max( measurement->value(), maxValue ); + currentMeasurementKinds.insert( wellMeasurement->measurementKind() ); } - if ( minValue != HUGE_VAL ) + // Make a set of the measurements we should have after the update + std::set targetMeasurementKinds; + for ( RimWellMeasurement* wellMeasurement : measurementCollection->measurements() ) { - m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + selectedMeasurementKinds[0] ); - m_legendConfig->setAutomaticRanges( minValue, maxValue, minValue, maxValue ); - m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero ); - return true; + targetMeasurementKinds.insert( wellMeasurement->kind() ); } - } - return false; -} + // The difference between the sets is the measurement kinds to be added + std::set newMeasurementKinds; + std::set_difference( targetMeasurementKinds.begin(), + targetMeasurementKinds.end(), + currentMeasurementKinds.begin(), + currentMeasurementKinds.end(), + std::inserter( newMeasurementKinds, newMeasurementKinds.end() ) ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellMeasurementInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, - bool isUsingOverrideViewer ) -{ - bool addToViewer = updateLegendData(); - if ( addToViewer ) - { - nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( m_legendConfig->titledOverlayFrame(), - isUsingOverrideViewer ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList - RimWellMeasurementInViewCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) -{ - QList options; - if ( fieldNeedingOptions == &m_measurementKinds ) - { - RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); - if ( wellPathCollection ) + // Add the new measurement kinds + for ( QString kind : newMeasurementKinds ) { - std::vector measurements = wellPathCollection->measurementCollection()->measurements(); + RimWellMeasurementInView* measurementInView = new RimWellMeasurementInView; + measurementInView->setName( kind ); + measurementInView->setMeasurementKind( kind ); + measurementInView->setAllWellsSelected(); - std::set measurementKindsInData; - for ( auto measurement : measurements ) - { - measurementKindsInData.insert( measurement->kind() ); - } - - for ( auto measurementKind : measurementKindsInData ) - { - options.push_back( caf::PdmOptionItemInfo( measurementKind, measurementKind ) ); - } + m_measurementsInView.push_back( measurementInView ); } + + updateConnectedEditors(); } - - return options; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimWellMeasurementInViewCollection::measurementKinds() const -{ - return m_measurementKinds; } diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h index 6468d5f6f0..e848f95415 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h @@ -20,16 +20,10 @@ #include "RimCheckableNamedObject.h" #include "cafPdmChildArrayField.h" -#include "cafPdmChildField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmProxyValueField.h" #include -class RimWellMeasurement; -class RimRegularLegendConfig; -class RiuViewer; +class RimWellMeasurementInView; class RimWellMeasurementInViewCollection : public RimCheckableNamedObject { @@ -39,22 +33,16 @@ public: RimWellMeasurementInViewCollection(); ~RimWellMeasurementInViewCollection() override; - RimRegularLegendConfig* legendConfig(); - std::vector measurementKinds() const; + std::vector measurements() const; - void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer ); + void syncWithChangesInWellMeasurementCollection(); protected: void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ); - - bool updateLegendData(); private: - caf::PdmChildField m_legendConfig; - caf::PdmField> m_measurementKinds; + caf::PdmChildArrayField m_measurementsInView; };