mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5125 Use category legend for well measurements without values.
This commit is contained in:
parent
6efceea597
commit
66ac8fee1d
@ -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;
|
||||
}
|
||||
|
@ -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(
|
||||
cvf::Color3f color = cvf::Color3f(
|
||||
wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) );
|
||||
}
|
||||
|
||||
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
|
||||
for ( auto part : parts )
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,6 +111,18 @@ bool RimWellMeasurementInView::updateLegendData()
|
||||
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 =
|
||||
@ -136,6 +147,7 @@ bool RimWellMeasurementInView::updateLegendData()
|
||||
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,11 +201,13 @@ 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 )
|
||||
{
|
||||
if ( hasMeasurementKindForWell( well, wellPathCollection, measurements, m_measurementKind ) )
|
||||
wellsWithMeasurementKind.insert( well->name() );
|
||||
}
|
||||
|
||||
@ -199,3 +236,11 @@ void RimWellMeasurementInView::setMeasurementKind( const QString& measurementKin
|
||||
{
|
||||
m_measurementKind = measurementKind;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellMeasurementInView::hasCategoryResult() const
|
||||
{
|
||||
return !RimWellMeasurement::kindHasValue( measurementKind() );
|
||||
}
|
||||
|
@ -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,
|
||||
@ -54,6 +58,10 @@ protected:
|
||||
bool* useOptionsOnly );
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user