#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->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;
} }

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::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wellMeasurement );
cvf::Collection<cvf::Part> parts; 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. // Use the view legend config to find color, if only one type of measurement is selected.
if ( measurementKinds.size() == 1 ) cvf::Color3f color = cvf::Color3f(
{
color = cvf::Color3f(
wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) ); wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) );
}
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color ); geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
for ( auto part : parts ) for ( auto part : parts )

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

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

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,9 @@ 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 );
private: private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,

View File

@ -56,7 +56,6 @@ RimWellMeasurementInView::RimWellMeasurementInView()
CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" );
m_wells.uiCapability()->setAutoAddingOptionFromValue( false ); m_wells.uiCapability()->setAutoAddingOptionFromValue( false );
m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
m_wells.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_wells.xmlCapability()->disableIO(); m_wells.xmlCapability()->disableIO();
this->setName( "Well Measurement" ); this->setName( "Well Measurement" );
@ -112,6 +111,18 @@ bool RimWellMeasurementInView::updateLegendData()
RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection(); RimWellMeasurementCollection* wellMeasurementCollection = wellPathCollection->measurementCollection();
if ( !wellMeasurementCollection ) return false; 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; std::vector<QString> selectedMeasurementKinds;
selectedMeasurementKinds.push_back( m_measurementKind ); selectedMeasurementKinds.push_back( m_measurementKind );
std::vector<RimWellMeasurement*> wellMeasurements = std::vector<RimWellMeasurement*> wellMeasurements =
@ -136,6 +147,7 @@ bool RimWellMeasurementInView::updateLegendData()
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero ); m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero );
return true; return true;
} }
}
return false; 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,11 +201,13 @@ QList<caf::PdmOptionItemInfo>
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( 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; std::set<QString> wellsWithMeasurementKind;
for ( auto well : wellPathCollection->wellPaths ) for ( auto well : wellPathCollection->wellPaths )
{ {
if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) )
wellsWithMeasurementKind.insert( well->name() ); wellsWithMeasurementKind.insert( well->name() );
} }
@ -199,3 +236,11 @@ void RimWellMeasurementInView::setMeasurementKind( const QString& measurementKin
{ {
m_measurementKind = measurementKind; m_measurementKind = measurementKind;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellMeasurementInView::hasCategoryResult() const
{
return !RimWellMeasurement::kindHasValue( measurementKind() );
}

View File

@ -29,6 +29,8 @@
class RimWellMeasurement; class RimWellMeasurement;
class RimRegularLegendConfig; class RimRegularLegendConfig;
class RimWellPath;
class RimWellPathCollection;
class RiuViewer; class RiuViewer;
class RimWellMeasurementInView : public RimCheckableNamedObject class RimWellMeasurementInView : public RimCheckableNamedObject
@ -45,6 +47,8 @@ public:
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer ); void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
bool hasCategoryResult() const;
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,
@ -54,6 +58,10 @@ protected:
bool* useOptionsOnly ); bool* useOptionsOnly );
bool updateLegendData(); bool updateLegendData();
static bool hasMeasurementKindForWell( const RimWellPath* wellPath,
const RimWellPathCollection* wellPathCollection,
const std::vector<RimWellMeasurement*>& measurements,
const QString& measurementKind );
private: private:
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig; caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;