#5125 Use category legend for well measurements without values.

This commit is contained in:
Kristian Bendiksen 2019-12-02 22:07:49 +01:00
parent 6efceea597
commit 66ac8fee1d
7 changed files with 125 additions and 58 deletions

View File

@ -92,6 +92,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;
}

View File

@ -256,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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -341,14 +315,10 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
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(
wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) );
}
cvf::Color3f color = cvf::Color3f(
wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) );
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
for ( auto part : parts )

View File

@ -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<caf::PdmOptionItemInfo>
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;
}

View File

@ -177,3 +177,31 @@ 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 );
}

View File

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

View File

@ -56,7 +56,6 @@ RimWellMeasurementInView::RimWellMeasurementInView()
CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" );
m_wells.uiCapability()->setAutoAddingOptionFromValue( false );
m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
m_wells.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_wells.xmlCapability()->disableIO();
this->setName( "Well Measurement" );
@ -112,30 +111,43 @@ bool RimWellMeasurementInView::updateLegendData()
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
if ( !wellMeasurementCollection ) return false;
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 )
if ( hasCategoryResult() )
{
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 );
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;
}
@ -154,6 +166,29 @@ void RimWellMeasurementInView::updateLegendRangesTextAndVisibility( RiuViewer* n
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -166,12 +201,14 @@ QList<caf::PdmOptionItemInfo>
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( wellPathCollection )
{
// std::vector<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements();
std::vector<RimWellMeasurement*> measurements = wellPathCollection->measurementCollection()->measurements();
// Find wells with a given measurement.
std::set<QString> wellsWithMeasurementKind;
for ( auto well : wellPathCollection->wellPaths )
{
wellsWithMeasurementKind.insert( well->name() );
if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) )
wellsWithMeasurementKind.insert( well->name() );
}
for ( auto wellName : wellsWithMeasurementKind )
@ -199,3 +236,11 @@ void RimWellMeasurementInView::setMeasurementKind( const QString& measurementKin
{
m_measurementKind = measurementKind;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellMeasurementInView::hasCategoryResult() const
{
return !RimWellMeasurement::kindHasValue( measurementKind() );
}

View File

@ -29,6 +29,8 @@
class RimWellMeasurement;
class RimRegularLegendConfig;
class RimWellPath;
class RimWellPathCollection;
class RiuViewer;
class RimWellMeasurementInView : public RimCheckableNamedObject
@ -45,6 +47,8 @@ public:
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
bool hasCategoryResult() const;
protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
@ -53,7 +57,11 @@ protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly );
bool updateLegendData();
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;