Merge pull request #5173 from OPM/feature-well-measurement-reorg

This commit is contained in:
Kristian Bendiksen 2019-12-05 15:51:24 +01:00 committed by GitHub
commit 54820eb20a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 601 additions and 254 deletions

View File

@ -40,6 +40,8 @@
#include "RimWellLogPlotCollection.h" #include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RimWellLogWbsCurve.h" #include "RimWellLogWbsCurve.h"
#include "RimWellMeasurement.h"
#include "RimWellMeasurementCurve.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RicWellLogTools.h" #include "RicWellLogTools.h"
@ -320,11 +322,12 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
curve->setSmoothingThreshold( 0.002 ); curve->setSmoothingThreshold( 0.002 );
} }
std::vector<QString> measurementNames; for ( QString measurementKind : RimWellMeasurement::measurementKindsForWellBoreStability() )
measurementNames.push_back( "XLOT" );
for ( size_t i = 0; i < measurementNames.size(); i++ )
{ {
RicWellLogTools::addWellMeasurementCurve( stabilityCurvesTrack, wellPath, measurementNames[i] ); RimWellMeasurementCurve* curve = RicWellLogTools::addWellMeasurementCurve( stabilityCurvesTrack,
wellPath,
measurementKind );
curve->loadDataAndUpdate( false );
} }
stabilityCurvesTrack->setAutoScaleXEnabled( true ); stabilityCurvesTrack->setAutoScaleXEnabled( true );

View File

@ -21,6 +21,8 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaLogging.h" #include "RiaLogging.h"
#include "Rim3dView.h"
#include "RimGridView.h"
#include "RimPerforationCollection.h" #include "RimPerforationCollection.h"
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimProject.h" #include "RimProject.h"
@ -92,6 +94,13 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked )
wellMeasurement->setQuality( measurement.quality ); wellMeasurement->setQuality( measurement.quality );
wellMeasurement->setKind( measurement.kind ); wellMeasurement->setKind( measurement.kind );
wellMeasurement->setRemark( measurement.remark ); 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 ); wellPathCollection->measurementCollection()->appendMeasurement( wellMeasurement );
lastWellMeasurement = wellMeasurement; lastWellMeasurement = wellMeasurement;
} }
@ -99,6 +108,17 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked )
if ( app->project() ) if ( app->project() )
{ {
std::vector<Rim3dView*> views;
app->project()->allViews( views );
for ( auto& view : views )
{
RimGridView* gridView = dynamic_cast<RimGridView*>( view );
if ( gridView )
{
gridView->updateWellMeasurements();
}
}
app->project()->scheduleCreateDisplayModelAndRedrawAllViews(); app->project()->scheduleCreateDisplayModelAndRedrawAllViews();
} }

View File

@ -42,6 +42,7 @@
#include "RimWellMeasurement.h" #include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h" #include "RimWellMeasurementCollection.h"
#include "RimWellMeasurementFilter.h" #include "RimWellMeasurementFilter.h"
#include "RimWellMeasurementInView.h"
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathAttribute.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; if ( !gridView->measurementCollection()->isChecked() ) return;
std::vector<QString> measurementKinds = gridView->measurementCollection()->measurementKinds(); for ( RimWellMeasurementInView* wellMeasurementInView : gridView->measurementCollection()->measurements() )
RivPipeGeometryGenerator geoGenerator;
std::vector<RimWellMeasurement*> wellMeasurements =
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
*wellPathCollection,
*m_rimWellPath,
measurementKinds );
for ( RimWellMeasurement* wellMeasurement : wellMeasurements )
{ {
double wellPathRadius = this->wellPathRadius( characteristicCellSize, this->wellPathCollection() ); if ( wellMeasurementInView->isChecked() && wellMeasurementInView->isWellChecked( m_rimWellPath->name() ) )
double startMD = wellMeasurement->MD() - wellPathRadius * 0.5;
double endMD = wellMeasurement->MD() + wellPathRadius * 0.5;
std::vector<cvf::Vec3d> 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<double> radii;
radii.push_back( wellPathRadius );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius );
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wellMeasurement );
cvf::Collection<cvf::Part> 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 )
{ {
color = cvf::Color3f( gridView->measurementCollection()->legendConfig()->scalarMapper()->mapToColor( std::vector<QString> measurementKinds;
wellMeasurement->value() ) ); measurementKinds.push_back( wellMeasurementInView->measurementKind() );
}
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color ); RivPipeGeometryGenerator geoGenerator;
for ( auto part : parts ) std::vector<RimWellMeasurement*> wellMeasurements =
{ RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
part->setSourceInfo( objectSourceInfo.p() ); *wellPathCollection,
model->addPart( part.p() ); *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<cvf::Vec3d> 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<double> radii;
radii.push_back( wellPathRadius );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius * 2.5 );
radii.push_back( wellPathRadius );
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wellMeasurement );
cvf::Collection<cvf::Part> 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 ); appendFishboneSubsPartsToModel( model, displayCoordTransform, characteristicCellSize );
appendImportedFishbonesToModel( model, displayCoordTransform, characteristicCellSize ); appendImportedFishbonesToModel( model, displayCoordTransform, characteristicCellSize );
appendWellPathAttributesToModel( model, displayCoordTransform, characteristicCellSize ); appendWellPathAttributesToModel( model, displayCoordTransform, characteristicCellSize );
appendWellMeasurementsToModel( model, displayCoordTransform, characteristicCellSize );
RimGridView* gridView = dynamic_cast<RimGridView*>( m_rimView.p() ); RimGridView* gridView = dynamic_cast<RimGridView*>( m_rimView.p() );
if ( !gridView ) return; if ( !gridView ) return;
@ -880,6 +857,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList*
appendPerforationsToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize, false ); appendPerforationsToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize, false );
appendVirtualTransmissibilitiesToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize ); appendVirtualTransmissibilitiesToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize );
appendWellMeasurementsToModel( model, displayCoordTransform, characteristicCellSize );
RimGridView* gridView = dynamic_cast<RimGridView*>( m_rimView.p() ); RimGridView* gridView = dynamic_cast<RimGridView*>( m_rimView.p() );
if ( !gridView ) return; if ( !gridView ) return;

View File

@ -146,6 +146,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.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}/RimWellMeasurementCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -76,6 +76,7 @@
#include "RimViewLinker.h" #include "RimViewLinker.h"
#include "RimViewNameConfig.h" #include "RimViewNameConfig.h"
#include "RimVirtualPerforationResults.h" #include "RimVirtualPerforationResults.h"
#include "RimWellMeasurementInView.h"
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
@ -931,6 +932,8 @@ void RimEclipseView::onLoadDataAndUpdate()
m_virtualPerforationResult->loadData(); m_virtualPerforationResult->loadData();
} }
m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();
this->scheduleCreateDisplayModelAndRedraw(); this->scheduleCreateDisplayModelAndRedraw();
} }
@ -1308,10 +1311,15 @@ void RimEclipseView::onUpdateLegends()
isUsingOverrideViewer() ); isUsingOverrideViewer() );
} }
if ( m_wellMeasurementCollection->isChecked() && m_wellMeasurementCollection->legendConfig()->showLegend() ) if ( m_wellMeasurementCollection->isChecked() )
{ {
m_wellMeasurementCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
isUsingOverrideViewer() ); {
if ( wellMeasurement->isChecked() && wellMeasurement->legendConfig()->showLegend() )
{
wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() );
}
}
} }
} }
@ -1859,7 +1867,10 @@ void RimEclipseView::onResetLegendsInViewer()
sepInterResDef->ternaryLegendConfig()->recreateLegend(); sepInterResDef->ternaryLegendConfig()->recreateLegend();
} }
m_wellMeasurementCollection->legendConfig()->recreateLegend(); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
wellMeasurement->legendConfig()->recreateLegend();
}
nativeOrOverrideViewer()->removeAllColorLegends(); nativeOrOverrideViewer()->removeAllColorLegends();
} }
@ -2019,7 +2030,10 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
absLegends.push_back( sepInterResDef->ternaryLegendConfig() ); absLegends.push_back( sepInterResDef->ternaryLegendConfig() );
} }
absLegends.push_back( m_wellMeasurementCollection->legendConfig() ); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
absLegends.push_back( wellMeasurement->legendConfig() );
}
return absLegends; return absLegends;
} }

View File

@ -46,6 +46,7 @@
#include "RimTernaryLegendConfig.h" #include "RimTernaryLegendConfig.h"
#include "RimViewLinker.h" #include "RimViewLinker.h"
#include "RimViewNameConfig.h" #include "RimViewNameConfig.h"
#include "RimWellMeasurementInView.h"
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
@ -174,6 +175,7 @@ void RimGeoMechView::onLoadDataAndUpdate()
updateMdiWindowVisibility(); updateMdiWindowVisibility();
this->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters(); this->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters();
m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();
this->scheduleCreateDisplayModelAndRedraw(); this->scheduleCreateDisplayModelAndRedraw();
@ -428,7 +430,10 @@ void RimGeoMechView::onResetLegendsInViewer()
sepInterResDef->ternaryLegendConfig()->recreateLegend(); sepInterResDef->ternaryLegendConfig()->recreateLegend();
} }
m_wellMeasurementCollection->legendConfig()->recreateLegend(); for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
wellMeasurement->legendConfig()->recreateLegend();
}
nativeOrOverrideViewer()->removeAllColorLegends(); 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(), for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
isUsingOverrideViewer() ); {
if ( wellMeasurement->isChecked() && wellMeasurement->legendConfig()->showLegend() )
{
wellMeasurement->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(),
isUsingOverrideViewer() );
}
}
} }
} }
} }
@ -587,6 +598,11 @@ std::vector<RimLegendConfig*> RimGeoMechView::legendConfigs() const
absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() ); absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() );
} }
for ( RimWellMeasurementInView* wellMeasurement : m_wellMeasurementCollection->measurements() )
{
absLegendConfigs.push_back( wellMeasurement->legendConfig() );
}
return absLegendConfigs; return absLegendConfigs;
} }
@ -715,6 +731,11 @@ bool RimGeoMechView::isTimeStepDependentDataVisible() const
{ {
return true; return true;
} }
if ( m_wellMeasurementCollection->isChecked() )
{
return true;
}
return false; return false;
} }

View File

@ -557,3 +557,11 @@ RimViewLinker* RimGridView::viewLinkerIfMasterView() const
return nullptr; return nullptr;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridView::updateWellMeasurements()
{
m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();
}

View File

@ -71,6 +71,8 @@ public:
int fontSize, int fontSize,
bool forceChange = false ) override; bool forceChange = false ) override;
void updateWellMeasurements();
protected: protected:
virtual void updateViewFollowingRangeFilterUpdates(); virtual void updateViewFollowingRangeFilterUpdates();
void onClearReservoirCellVisibilitiesIfNeccessary() override; void onClearReservoirCellVisibilitiesIfNeccessary() override;

View File

@ -35,6 +35,7 @@
#include "RimIntersectionCollection.h" #include "RimIntersectionCollection.h"
#include "RimStimPlanColors.h" #include "RimStimPlanColors.h"
#include "RimViewLinker.h" #include "RimViewLinker.h"
#include "RimWellMeasurementInView.h"
#include "cafCategoryLegend.h" #include "cafCategoryLegend.h"
#include "cafCategoryMapper.h" #include "cafCategoryMapper.h"
@ -923,12 +924,15 @@ QList<caf::PdmOptionItemInfo>
this->firstAncestorOrThisOfType( gmCellColors ); this->firstAncestorOrThisOfType( gmCellColors );
RimCellEdgeColors* eclCellEdgColors = nullptr; RimCellEdgeColors* eclCellEdgColors = nullptr;
this->firstAncestorOrThisOfType( eclCellEdgColors ); this->firstAncestorOrThisOfType( eclCellEdgColors );
RimWellMeasurementInView* wellMeasurementInView = nullptr;
this->firstAncestorOrThisOfType( wellMeasurementInView );
if ( ( eclCellColors && eclCellColors->hasCategoryResult() ) || if ( ( eclCellColors && eclCellColors->hasCategoryResult() ) ||
( gmCellColors && gmCellColors->hasCategoryResult() ) || ( gmCellColors && gmCellColors->hasCategoryResult() ) ||
( eclCellEdgColors && eclCellEdgColors->hasCategoryResult() ) || ( eclCellEdgColors && eclCellEdgColors->hasCategoryResult() ) ||
( ensembleCurveSet && ensembleCurveSet->currentEnsembleParameterType() == EnsembleParameter::TYPE_TEXT ) || ( ensembleCurveSet && ensembleCurveSet->currentEnsembleParameterType() == EnsembleParameter::TYPE_TEXT ) ||
( crossPlotCurveSet && crossPlotCurveSet->groupingByCategoryResult() ) ) ( crossPlotCurveSet && crossPlotCurveSet->groupingByCategoryResult() ) ||
( wellMeasurementInView && wellMeasurementInView->hasCategoryResult() ) )
{ {
isCategoryResult = true; isCategoryResult = true;
} }

View File

@ -33,6 +33,7 @@
#include "RimWellLogPlotCollection.h" #include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RimWellLogWbsCurve.h" #include "RimWellLogWbsCurve.h"
#include "RimWellMeasurementCurve.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
@ -436,8 +437,9 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector<R
{ {
continue; continue;
} }
RimWellLogFileCurve* fileCurve = dynamic_cast<RimWellLogFileCurve*>( curve ); RimWellLogFileCurve* fileCurve = dynamic_cast<RimWellLogFileCurve*>( curve );
RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>( curve ); RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>( curve );
RimWellMeasurementCurve* measurementCurve = dynamic_cast<RimWellMeasurementCurve*>( curve );
if ( fileCurve ) if ( fileCurve )
{ {
if ( wellPathToApply() != nullptr ) if ( wellPathToApply() != nullptr )
@ -525,6 +527,13 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector<R
curve->updateConnectedEditors(); curve->updateConnectedEditors();
} }
} }
else if ( measurementCurve )
{
if ( wellPathToApply() != nullptr )
{
measurementCurve->setWellPath( wellPathToApply() );
}
}
} }
for ( RimWellLogTrack* track : tracks ) for ( RimWellLogTrack* track : tracks )

View File

@ -177,3 +177,37 @@ void RimWellMeasurement::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellMeasurement::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) {} 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<QString> RimWellMeasurement::measurementKindsForWellBoreStability()
{
std::vector<QString> wbsMeasurementKinds = {"XLOT", "LOT", "FIT"};
return wbsMeasurementKinds;
}

View File

@ -22,6 +22,8 @@
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cvfColor3.h"
#include <QDate> #include <QDate>
#include <QString> #include <QString>
@ -53,6 +55,10 @@ public:
QString remark() const; QString remark() const;
void setRemark( const QString& remark ); void setRemark( const QString& remark );
static bool kindHasValue( const QString& measurementKind );
static cvf::Color3f mapToColor( const QString& measurementKind );
static std::vector<QString> measurementKindsForWellBoreStability();
private: private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,

View File

@ -59,6 +59,7 @@ RimWellMeasurementCurve::RimWellMeasurementCurve()
CAF_PDM_InitFieldNoDefault( &m_measurementKind, "CurveMeasurementKind", "Measurement Kind", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_measurementKind, "CurveMeasurementKind", "Measurement Kind", "", "", "" );
m_measurementKind.uiCapability()->setUiTreeChildrenHidden( true ); m_measurementKind.uiCapability()->setUiTreeChildrenHidden( true );
m_measurementKind.uiCapability()->setUiHidden( true );
m_wellPath = nullptr; m_wellPath = nullptr;
} }
@ -219,7 +220,6 @@ void RimWellMeasurementCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" ); caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" );
curveDataGroup->add( &m_wellPath ); curveDataGroup->add( &m_wellPath );
curveDataGroup->add( &m_measurementKind );
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" ); caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
RimPlotCurve::appearanceUiOrdering( *appearanceGroup ); RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
@ -251,49 +251,12 @@ QList<caf::PdmOptionItemInfo>
if ( fieldNeedingOptions == &m_wellPath ) if ( fieldNeedingOptions == &m_wellPath )
{ {
auto wellPathColl = RimTools::wellPathCollection(); RimTools::wellPathOptionItems( &options );
if ( wellPathColl )
{
caf::PdmChildArrayField<RimWellPath*>& 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" ) );
}
} }
return options; return options;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementCurve::initAfterRead()
{
if ( !m_wellPath ) return;
// TODO: do something here?
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -301,11 +264,7 @@ QString RimWellMeasurementCurve::createCurveAutoName()
{ {
if ( m_wellPath ) if ( m_wellPath )
{ {
QStringList name; return measurementKind();
name.push_back( wellName() );
name.push_back( measurementKind() );
return name.join( ", " );
} }
return "Empty curve"; return "Empty curve";

View File

@ -63,7 +63,6 @@ protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override; bool* useOptionsOnly ) override;
void initAfterRead() override;
RiuQwtSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind ); RiuQwtSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind );
cvf::Color3f getColorForMeasurementKind( const QString& measurementKind ); cvf::Color3f getColorForMeasurementKind( const QString& measurementKind );

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <cmath>
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<std::tuple<QString, int, cvf::Color3ub>> 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<QString> selectedMeasurementKinds;
selectedMeasurementKinds.push_back( m_measurementKind );
std::vector<RimWellMeasurement*> 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<RimWellMeasurement*>& 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<caf::PdmOptionItemInfo>
RimWellMeasurementInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_wells )
{
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( wellPathCollection )
{
std::vector<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements();
// Find wells with a given measurement.
std::set<QString> 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<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements();
// Find wells with a given measurement.
std::set<QString> 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 );
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <vector>
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<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
bool updateLegendData();
static bool hasMeasurementKindForWell( const RimWellPath* wellPath,
const RimWellPathCollection* wellPathCollection,
const std::vector<RimWellMeasurement*>& measurements,
const QString& measurementKind );
private:
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
caf::PdmField<QString> m_measurementKind;
caf::PdmField<std::vector<QString>> m_wells;
};

View File

@ -18,6 +18,7 @@
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimGridView.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimRegularLegendConfig.h" #include "RimRegularLegendConfig.h"
#include "RimTools.h" #include "RimTools.h"
@ -25,10 +26,9 @@
#include "RimWellMeasurement.h" #include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h" #include "RimWellMeasurementCollection.h"
#include "RimWellMeasurementFilter.h" #include "RimWellMeasurementFilter.h"
#include "RimWellMeasurementInView.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RiuViewer.h"
#include "cafCmdFeatureMenuBuilder.h" #include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeOrdering.h" #include "cafPdmUiTreeOrdering.h"
@ -43,17 +43,12 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementInViewCollection, "WellMeasurementsInView
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection() RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection()
{ {
CAF_PDM_InitObject( "Well Measurement", "", "", "" ); CAF_PDM_InitObject( "Well Measurements", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds", "", "", "" );
m_legendConfig = new RimRegularLegendConfig(); m_measurementsInView.uiCapability()->setUiHidden( true );
m_legendConfig.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_measurementKinds, "MeasurementKinds", "Measurent Kinds", "", "", "" ); m_isChecked = false;
m_measurementKinds.uiCapability()->setAutoAddingOptionFromValue( false );
m_measurementKinds.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
m_measurementKinds.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_measurementKinds.xmlCapability()->disableIO();
this->setName( "Well Measurements" ); this->setName( "Well Measurements" );
} }
@ -61,18 +56,31 @@ RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection() RimWellMeasurementInViewCollection::~RimWellMeasurementInViewCollection() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellMeasurementInView*> RimWellMeasurementInViewCollection::measurements() const
{ {
delete m_legendConfig; std::vector<RimWellMeasurementInView*> attrs;
for ( auto attr : m_measurementsInView )
{
attrs.push_back( attr.p() );
}
return attrs;
} }
//--------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellMeasurementInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, void RimWellMeasurementInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
QString uiConfigName /*= ""*/ ) QString uiConfigName /*= ""*/ )
{ {
uiTreeOrdering.add( &m_legendConfig ); uiTreeOrdering.add( &m_measurementsInView );
uiTreeOrdering.skipRemainingChildren( true ); uiTreeOrdering.skipRemainingChildren( true );
} }
@ -83,115 +91,54 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
if ( changedField == &m_isChecked || changedField == &m_measurementKinds || changedField == &m_legendConfig ) RimGridView* rimGridView = nullptr;
{ this->firstAncestorOrThisOfTypeAsserted( rimGridView );
updateLegendData(); rimGridView->scheduleCreateDisplayModelAndRedraw();
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimWellMeasurementInViewCollection::legendConfig() void RimWellMeasurementInViewCollection::syncWithChangesInWellMeasurementCollection()
{
return m_legendConfig;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellMeasurementInViewCollection::updateLegendData()
{ {
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( !wellPathCollection ) return false; if ( wellPathCollection )
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
if ( !wellMeasurementCollection ) return false;
std::vector<QString> selectedMeasurementKinds = measurementKinds();
// Only show legend when only one measurement is selected
if ( selectedMeasurementKinds.size() == 1 )
{ {
std::vector<RimWellMeasurement*> wellMeasurements = const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();
RimWellMeasurementFilter::filterMeasurements( wellMeasurementCollection->measurements(),
selectedMeasurementKinds );
double minValue = HUGE_VAL; // Make a set of the measurement kinds already present
double maxValue = -HUGE_VAL; std::set<QString> currentMeasurementKinds;
double posClosestToZero = HUGE_VAL; for ( RimWellMeasurementInView* wellMeasurement : measurements() )
double negClosestToZero = -HUGE_VAL;
for ( auto& measurement : wellMeasurements )
{ {
minValue = std::min( measurement->value(), minValue ); currentMeasurementKinds.insert( wellMeasurement->measurementKind() );
maxValue = std::max( measurement->value(), maxValue );
} }
if ( minValue != HUGE_VAL ) // Make a set of the measurements we should have after the update
std::set<QString> targetMeasurementKinds;
for ( RimWellMeasurement* wellMeasurement : measurementCollection->measurements() )
{ {
m_legendConfig->setTitle( QString( "Well Measurement: \n" ) + selectedMeasurementKinds[0] ); targetMeasurementKinds.insert( wellMeasurement->kind() );
m_legendConfig->setAutomaticRanges( minValue, maxValue, minValue, maxValue );
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero );
return true;
} }
}
return false; // The difference between the sets is the measurement kinds to be added
} std::set<QString> newMeasurementKinds;
std::set_difference( targetMeasurementKinds.begin(),
targetMeasurementKinds.end(),
currentMeasurementKinds.begin(),
currentMeasurementKinds.end(),
std::inserter( newMeasurementKinds, newMeasurementKinds.end() ) );
//-------------------------------------------------------------------------------------------------- // Add the new measurement kinds
/// for ( QString kind : newMeasurementKinds )
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
bool isUsingOverrideViewer )
{
bool addToViewer = updateLegendData();
if ( addToViewer )
{
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( m_legendConfig->titledOverlayFrame(),
isUsingOverrideViewer );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimWellMeasurementInViewCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_measurementKinds )
{
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( wellPathCollection )
{ {
std::vector<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements(); RimWellMeasurementInView* measurementInView = new RimWellMeasurementInView;
measurementInView->setName( kind );
measurementInView->setMeasurementKind( kind );
measurementInView->setAllWellsSelected();
std::set<QString> measurementKindsInData; m_measurementsInView.push_back( measurementInView );
for ( auto measurement : measurements )
{
measurementKindsInData.insert( measurement->kind() );
}
for ( auto measurementKind : measurementKindsInData )
{
options.push_back( caf::PdmOptionItemInfo( measurementKind, measurementKind ) );
}
} }
updateConnectedEditors();
} }
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RimWellMeasurementInViewCollection::measurementKinds() const
{
return m_measurementKinds;
} }

View File

@ -20,16 +20,10 @@
#include "RimCheckableNamedObject.h" #include "RimCheckableNamedObject.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <vector> #include <vector>
class RimWellMeasurement; class RimWellMeasurementInView;
class RimRegularLegendConfig;
class RiuViewer;
class RimWellMeasurementInViewCollection : public RimCheckableNamedObject class RimWellMeasurementInViewCollection : public RimCheckableNamedObject
{ {
@ -39,22 +33,16 @@ public:
RimWellMeasurementInViewCollection(); RimWellMeasurementInViewCollection();
~RimWellMeasurementInViewCollection() override; ~RimWellMeasurementInViewCollection() override;
RimRegularLegendConfig* legendConfig(); std::vector<RimWellMeasurementInView*> measurements() const;
std::vector<QString> measurementKinds() const;
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer ); void syncWithChangesInWellMeasurementCollection();
protected: protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) override; const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly );
bool updateLegendData();
private: private:
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig; caf::PdmChildArrayField<RimWellMeasurementInView*> m_measurementsInView;
caf::PdmField<std::vector<QString>> m_measurementKinds;
}; };