#4732 Support error bars for observed RFT data (#4760)

* #4732 Fix missing refresh for ensemble RFT

* WIP

* #4732 Fix missing refresh for ensemble RFT

* WIP

* Make sure Observed RFT data is loaded on startup

* Make error bars work for RFT plots

* #4761 Add labels with formation and value/error to observed data points

* Changes after review
This commit is contained in:
Gaute Lindkvist 2019-09-25 17:48:19 +02:00 committed by GitHub
parent 931e7dc42d
commit 2a20f84f1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 240 additions and 58 deletions

View File

@ -56,6 +56,7 @@
#include "RimIdenticalGridCaseGroup.h"
#include "RimMainPlotCollection.h"
#include "RimObservedDataCollection.h"
#include "RimObservedFmuRftData.h"
#include "RimObservedSummaryData.h"
#include "RimOilField.h"
#include "RimPltPlotCollection.h"
@ -492,6 +493,10 @@ bool RiaApplication::loadProject( const QString& projectFileName,
observedData->createRftReaderInterface();
observedData->updateMetaData();
}
for ( RimObservedFmuRftData* observedFmuData : oilField->observedDataCollection()->allObservedFmuRftData() )
{
observedFmuData->createRftReaderInterface();
}
oilField->fractureDefinitionCollection()->loadAndUpdateData();
oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit();

View File

@ -46,7 +46,8 @@ public:
PRESSURE_P10,
PRESSURE_P50,
PRESSURE_P90,
PRESSURE_MEAN
PRESSURE_MEAN,
PRESSURE_ERROR
};
public:
@ -83,4 +84,4 @@ private:
bool operator==( const RifEclipseRftAddress& first, const RifEclipseRftAddress& second );
bool operator<( const RifEclipseRftAddress& first, const RifEclipseRftAddress& second );
bool operator<( const RifEclipseRftAddress& first, const RifEclipseRftAddress& second );

View File

@ -82,7 +82,8 @@ void RifReaderEnsembleStatisticsRft::values( const RifEclipseRftAddress& rftAddr
rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_MEAN ||
rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P10 ||
rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P50 ||
rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P90 );
rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P90 ||
rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_ERROR );
auto it = m_cachedValues.find( rftAddress );
if ( it == m_cachedValues.end() )

View File

@ -138,6 +138,33 @@ bool RifReaderFmuRft::directoryContainsFmuRftData( const QString& filePath )
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RifReaderFmuRft::labels( const RifEclipseRftAddress& rftAddress )
{
std::vector<QString> formationLabels;
if ( m_allWellObservations.empty() )
{
load();
}
auto it = m_allWellObservations.find( rftAddress.wellName() );
if ( it != m_allWellObservations.end() )
{
const std::vector<Observation>& observations = it->second.observations;
for ( const Observation& observation : observations )
{
formationLabels.push_back( QString( "%1 - Pressure: %2 +/- %3" )
.arg( observation.formation )
.arg( observation.pressure )
.arg( observation.pressureError ) );
}
}
return formationLabels;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -162,9 +189,11 @@ std::set<RifEclipseRftAddress> RifReaderFmuRft::eclipseRftAddresses()
RifEclipseRftAddress tvdAddress( wellName, dateTime, RifEclipseRftAddress::TVD );
RifEclipseRftAddress mdAddress( wellName, dateTime, RifEclipseRftAddress::MD );
RifEclipseRftAddress pressureAddress( wellName, dateTime, RifEclipseRftAddress::PRESSURE );
RifEclipseRftAddress pressureErrorAddress( wellName, dateTime, RifEclipseRftAddress::PRESSURE_ERROR );
allAddresses.insert( tvdAddress );
allAddresses.insert( mdAddress );
allAddresses.insert( pressureAddress );
allAddresses.insert( pressureErrorAddress );
}
}
}
@ -202,6 +231,9 @@ void RifReaderFmuRft::values( const RifEclipseRftAddress& rftAddress, std::vecto
case RifEclipseRftAddress::PRESSURE:
values->push_back( observation.pressure );
break;
case RifEclipseRftAddress::PRESSURE_ERROR:
values->push_back( observation.pressureError );
break;
default:
CAF_ASSERT( false && "Wrong channel type sent to Fmu RFT reader" );
}

View File

@ -68,6 +68,8 @@ public:
static QStringList findSubDirectoriesWithFmuRftData( const QString& filePath );
static bool directoryContainsFmuRftData( const QString& filePath );
std::vector<QString> labels( const RifEclipseRftAddress& rftAddress );
std::set<RifEclipseRftAddress> eclipseRftAddresses() override;
void values( const RifEclipseRftAddress& rftAddress, std::vector<double>* values ) override;

View File

@ -82,6 +82,7 @@ RimWellRftPlot::RimWellRftPlot()
CAF_PDM_InitField( &m_showStatisticsCurves, "ShowStatisticsCurves", true, "Show Statistics Curves", "", "", "" );
CAF_PDM_InitField( &m_showEnsembleCurves, "ShowEnsembleCurves", true, "Show Ensemble Curves", "", "", "" );
CAF_PDM_InitField( &m_showErrorInObservedData, "ShowErrorObserved", true, "Show Observed Data Error", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellLogPlot_OBSOLETE, "WellLog", "Well Log", "", "", "" );
m_wellLogPlot_OBSOLETE.uiCapability()->setUiHidden( true );
@ -111,6 +112,11 @@ RimWellRftPlot::RimWellRftPlot()
m_selectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue( false );
CAF_PDM_InitFieldNoDefault( &m_wellPathCollection, "WellPathCollection", "Well Path Collection", "", "", "" );
m_wellPathCollection.uiCapability()->setUiHidden( true );
m_wellPathCollection.xmlCapability()->disableIO();
m_wellPathCollection = RiaApplication::instance()->project()->activeOilField()->wellPathCollection();
m_nameConfig->setCustomName( "RFT Plot" );
m_trackLegendsHorizontal = true;
@ -796,7 +802,8 @@ void RimWellRftPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
syncCurvesFromUiSelection();
this->updateConnectedEditors();
}
else if ( changedField == &m_showStatisticsCurves || changedField == &m_showEnsembleCurves )
else if ( changedField == &m_showStatisticsCurves || changedField == &m_showEnsembleCurves ||
changedField == &m_showErrorInObservedData )
{
updateFormationsOnPlot();
syncCurvesFromUiSelection();
@ -824,6 +831,7 @@ void RimWellRftPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
uiOrdering.add( &m_wellPathNameOrSimWellName );
uiOrdering.add( &m_showStatisticsCurves );
uiOrdering.add( &m_showEnsembleCurves );
uiOrdering.add( &m_showErrorInObservedData );
bool showingEnsembleData = false;
for ( const RifDataSourceForRftPlt& dataSource : m_selectedSources() )
@ -973,6 +981,14 @@ void RimWellRftPlot::initAfterRead()
RimWellLogPlot::initAfterRead();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellRftPlot::showErrorBarsForObservedData() const
{
return m_showErrorInObservedData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -42,6 +42,7 @@ class RimEclipseResultCase;
class RimWellLogCurve;
class RimWellLogFileChannel;
class RimWellPath;
class RimWellPathCollection;
class RiuWellRftPlot;
class RigEclipseCaseData;
class RiaRftPltCurveDefinition;
@ -84,6 +85,8 @@ public:
void deleteCurvesAssosicatedWithObservedData( const RimObservedFmuRftData* observedFmuRftData );
bool showErrorBarsForObservedData() const;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
@ -134,11 +137,14 @@ private:
caf::PdmField<bool> m_branchDetection;
caf::PdmField<bool> m_showStatisticsCurves;
caf::PdmField<bool> m_showEnsembleCurves;
caf::PdmField<bool> m_showErrorInObservedData;
caf::PdmField<std::vector<RifDataSourceForRftPlt>> m_selectedSources;
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
caf::PdmPtrField<RimWellPathCollection*> m_wellPathCollection;
caf::PdmField<bool> m_showPlotTitle_OBSOLETE;
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot_OBSOLETE;

View File

@ -97,3 +97,15 @@ std::vector<QString> RimObservedFmuRftData::wells() const
}
return std::vector<QString>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RimObservedFmuRftData::labels( const RifEclipseRftAddress& rftAddress )
{
if ( m_fmuRftReader.p() )
{
return const_cast<RifReaderFmuRft*>( m_fmuRftReader.p() )->labels( rftAddress );
}
return {};
}

View File

@ -38,8 +38,7 @@ public:
bool hasWell( const QString& wellPathName ) const;
std::vector<QString> wells() const;
std::vector<std::pair<double, double>> derivedWellPathTvdMd( const QString& wellPathName ) const;
std::vector<QString> labels( const RifEclipseRftAddress& rftAddress );
private:
cvf::ref<RifReaderFmuRft> m_fmuRftReader;

View File

@ -47,6 +47,7 @@ RimWellLogCurve::RimWellLogCurve()
CAF_PDM_InitObject( "WellLogCurve", ":/WellLogCurve16x16.png", "", "" );
m_qwtPlotCurve->setXAxis( QwtPlot::xTop );
m_qwtPlotCurve->setErrorBarsXAxis( QwtPlot::xTop );
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
}

View File

@ -47,6 +47,7 @@
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPlotTools.h"
#include "RimWellRftPlot.h"
#include "RiuQwtPlotCurve.h"
#include "RiuWellLogTrack.h"
@ -81,6 +82,7 @@ void caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::setUp()
addItem( RifEclipseRftAddress::PRESSURE_P50, "PRESSURE_P50", "P50: Pressure" );
addItem( RifEclipseRftAddress::PRESSURE_P90, "PRESSURE_P90", "P90: Pressure" );
addItem( RifEclipseRftAddress::PRESSURE_MEAN, "PRESSURE_MEAN", "Mean: Pressure" );
addItem( RifEclipseRftAddress::PRESSURE_ERROR, "PRESSURE_ERROR", "Error: Pressure" );
setDefault( RifEclipseRftAddress::NONE );
}
} // namespace caf
@ -376,9 +378,14 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
firstAncestorOrThisOfType( wellLogPlot );
CVF_ASSERT( wellLogPlot );
std::vector<double> measuredDepthVector = measuredDepthValues();
std::vector<double> tvDepthVector = tvDepthValues();
std::vector<double> values = xValues();
RimWellRftPlot* rftPlot = dynamic_cast<RimWellRftPlot*>( wellLogPlot );
bool showErrorBarsInObservedData = rftPlot ? rftPlot->showErrorBarsForObservedData() : false;
std::vector<double> measuredDepthVector = measuredDepthValues();
std::vector<double> tvDepthVector = tvDepthValues();
std::vector<double> values = xValues();
std::vector<double> errors = errorValues();
std::vector<QString> perPointLabels;
if ( values.empty() || values.size() != tvDepthVector.size() )
{
@ -402,7 +409,8 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
else if ( m_observedFmuRftData )
{
// TODO: Read unit system somewhere for FMU RFT Data
unitSystem = RiaEclipseUnitTools::UNITS_METRIC;
unitSystem = RiaEclipseUnitTools::UNITS_METRIC;
perPointLabels = this->perPointLabels();
}
else
{
@ -441,9 +449,13 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH )
{
m_qwtPlotCurve->setSamples( m_curveData->xPlotValues().data(),
m_curveData->measuredDepthPlotValues( displayUnit ).data(),
static_cast<int>( m_curveData->xPlotValues().size() ) );
m_qwtPlotCurve->showErrorBars( showErrorBarsInObservedData );
m_qwtPlotCurve->setPerPointLabels( perPointLabels );
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( m_curveData->xPlotValues(),
m_curveData->measuredDepthPlotValues( displayUnit ),
errors,
false,
RiuQwtPlotCurve::ERROR_ALONG_Y_AXIS );
RimWellLogTrack* wellLogTrack;
firstAncestorOrThisOfType( wellLogTrack );
@ -472,9 +484,13 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
}
else
{
m_qwtPlotCurve->setSamples( m_curveData->xPlotValues().data(),
m_curveData->trueDepthPlotValues( displayUnit ).data(),
static_cast<int>( m_curveData->xPlotValues().size() ) );
m_qwtPlotCurve->showErrorBars( showErrorBarsInObservedData );
m_qwtPlotCurve->setPerPointLabels( perPointLabels );
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( m_curveData->xPlotValues(),
m_curveData->trueDepthPlotValues( displayUnit ),
errors,
false,
RiuQwtPlotCurve::ERROR_ALONG_Y_AXIS );
}
m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() );
@ -648,6 +664,19 @@ void RimWellLogRftCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RimWellLogRftCurve::perPointLabels() const
{
if ( m_observedFmuRftData() )
{
RifEclipseRftAddress address( m_wellName(), m_timeStep, RifEclipseRftAddress::PRESSURE );
return m_observedFmuRftData()->labels( address );
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -833,6 +862,22 @@ std::vector<double> RimWellLogRftCurve::xValues()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimWellLogRftCurve::errorValues()
{
RifReaderRftInterface* reader = rftReader();
std::vector<double> errorValues;
if ( reader )
{
RifEclipseRftAddress errorAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::PRESSURE_ERROR );
reader->values( errorAddress, &errorValues );
}
return errorValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -95,6 +95,8 @@ protected:
const QVariant& oldValue,
const QVariant& newValue ) override;
std::vector<QString> perPointLabels() const;
private:
RifReaderRftInterface* rftReader() const;
@ -105,6 +107,7 @@ private:
std::vector<size_t> sortedIndicesInRftFile();
std::vector<double> xValues();
std::vector<double> errorValues();
std::vector<double> tvDepthValues();
std::vector<double> measuredDepthValues();

View File

@ -73,20 +73,21 @@ RiuQwtPlotCurve::~RiuQwtPlotCurve() {}
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues )
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
ErrorAxis errorAxis )
{
CVF_ASSERT( xValues.size() == yValues.size() );
CVF_ASSERT( yErrorValues.empty() || yErrorValues.size() == xValues.size() );
bool showErrorBars = m_showErrorBars && !yErrorValues.empty();
bool showErrorBars = m_showErrorBars && !errorValues.empty();
QPolygonF points;
QVector<QwtIntervalSample> errorIntervals;
std::vector<std::pair<size_t, size_t>> filteredIntervals;
{
std::vector<double> filteredYValues;
std::vector<double> filteredXValues;
std::vector<double> filteredYErrorValues;
std::vector<double> filteredErrorValues;
{
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues,
@ -96,7 +97,7 @@ void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>
RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &filteredXValues );
if ( showErrorBars )
RiaCurveDataTools::getValuesByIntervals( yErrorValues, intervalsOfValidValues, &filteredYErrorValues );
RiaCurveDataTools::getValuesByIntervals( errorValues, intervalsOfValidValues, &filteredErrorValues );
filteredIntervals = RiaCurveDataTools::computePolyLineStartStopIndices( intervalsOfValidValues );
}
@ -107,11 +108,20 @@ void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>
{
points << QPointF( filteredXValues[i], filteredYValues[i] );
if ( showErrorBars && filteredYValues[i] != DOUBLE_INF && filteredYErrorValues[i] != DOUBLE_INF )
if ( showErrorBars && filteredYValues[i] != DOUBLE_INF && filteredErrorValues[i] != DOUBLE_INF )
{
errorIntervals << QwtIntervalSample( filteredXValues[i],
filteredYValues[i] - filteredYErrorValues[i],
filteredYValues[i] + filteredYErrorValues[i] );
if ( errorAxis == ERROR_ALONG_Y_AXIS )
{
errorIntervals << QwtIntervalSample( filteredXValues[i],
filteredYValues[i] - filteredErrorValues[i],
filteredYValues[i] + filteredErrorValues[i] );
}
else
{
errorIntervals << QwtIntervalSample( filteredYValues[i],
filteredXValues[i] - filteredErrorValues[i],
filteredXValues[i] + filteredErrorValues[i] );
}
}
}
}
@ -119,7 +129,18 @@ void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>
this->setSamples( points );
this->setLineSegmentStartStopIndices( filteredIntervals );
if ( showErrorBars ) m_errorBars->setSamples( errorIntervals );
if ( showErrorBars )
{
m_errorBars->setSamples( errorIntervals );
if ( errorAxis == ERROR_ALONG_Y_AXIS )
{
m_errorBars->setOrientation( Qt::Vertical );
}
else
{
m_errorBars->setOrientation( Qt::Horizontal );
}
}
}
//--------------------------------------------------------------------------------------------------
@ -285,11 +306,21 @@ void RiuQwtPlotCurve::drawSymbols( QPainter* painter,
const RiuQwtSymbol* sym = dynamic_cast<const RiuQwtSymbol*>( &symbol );
if ( sym && !sym->label().isEmpty() )
if ( sym )
{
for ( auto& pt : pointsToDisplay )
if ( m_perPointLabels.size() == pointsToDisplay.size() )
{
sym->renderSymbolLabel( painter, pt );
for ( int i = 0; i < (int)pointsToDisplay.size(); ++i )
{
sym->renderSymbolLabel( painter, pointsToDisplay[i], m_perPointLabels[i] );
}
}
else if ( !sym->globalLabel().isEmpty() )
{
for ( auto& pt : pointsToDisplay )
{
sym->renderSymbolLabel( painter, pt, sym->globalLabel() );
}
}
}
}
@ -318,7 +349,10 @@ void RiuQwtPlotCurve::setSymbolSkipPixelDistance( float distance )
void RiuQwtPlotCurve::attach( QwtPlot* plot )
{
QwtPlotItem::attach( plot );
if ( m_showErrorBars ) m_errorBars->attach( plot );
if ( m_showErrorBars )
{
m_errorBars->attach( plot );
}
m_attachedToPlot = plot;
}
@ -362,6 +396,24 @@ void RiuQwtPlotCurve::setErrorBarsColor( QColor color )
m_errorBars->setSymbol( newSymbol );
}
//--------------------------------------------------------------------------------------------------
/// Set the Qwt X-Axis (QwtPlot::xBottom or QwtPlot::xTop).
/// This is important to make sure the x-axis interval is set correctly.
/// WellLogPlots use top-axis and Summary uses bottom axis.
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setErrorBarsXAxis( int axis )
{
m_errorBars->setXAxis( axis );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setPerPointLabels( const std::vector<QString>& labels )
{
m_perPointLabels = labels;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -48,6 +48,12 @@ class RiuErrorBarsQwtPlotCurve;
class RiuQwtPlotCurve : public QwtPlotCurve
{
public:
enum ErrorAxis
{
ERROR_ALONG_X_AXIS,
ERROR_ALONG_Y_AXIS
};
enum CurveInterpolationEnum
{
INTERPOLATION_POINT_TO_POINT,
@ -83,8 +89,9 @@ public:
void setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues );
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
ErrorAxis errorAxis = ERROR_ALONG_Y_AXIS );
void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
@ -108,6 +115,8 @@ public:
void clearErrorBars();
void showErrorBars( bool show );
void setErrorBarsColor( QColor color );
void setErrorBarsXAxis( int axis );
void setPerPointLabels( const std::vector<QString>& labels );
void setAppearance( LineStyleEnum lineStyle,
CurveInterpolationEnum interpolationType,
@ -145,4 +154,6 @@ private:
QwtPlotIntervalCurve* m_errorBars;
QwtPlot* m_attachedToPlot;
bool m_blackAndWhiteLegendIcon;
std::vector<QString> m_perPointLabels;
};

View File

@ -28,7 +28,7 @@
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition )
: QwtSymbol( QwtSymbol::NoSymbol )
, m_label( label )
, m_globalLabel( label )
, m_labelPosition( labelPosition )
{
QwtSymbol::Style style = QwtSymbol::NoSymbol;
@ -133,34 +133,33 @@ RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, Labe
void RiuQwtSymbol::renderSymbols( QPainter* painter, const QPointF* points, int numPoints ) const
{
QwtSymbol::renderSymbols( painter, points, numPoints );
if ( !m_label.isEmpty() )
{
for ( int i = 0; i < numPoints; i++ )
{
auto position = points[i];
// renderSymbolLabel(painter, position);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtSymbol::renderSymbolLabel( QPainter* painter, const QPointF& position ) const
void RiuQwtSymbol::renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const
{
QSize symbolSize = QwtSymbol::size();
QRect symbolRect( position.x(), position.y(), symbolSize.width(), symbolSize.height() );
QRect labelRect = labelBoundingRect( painter, symbolRect );
painter->drawText( labelRect.topLeft(), m_label );
QRect labelRect = labelBoundingRect( painter, symbolRect, label );
painter->drawText( labelRect.topLeft(), label );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtSymbol::setLabel( const QString& label )
QString RiuQwtSymbol::globalLabel() const
{
m_label = label;
return m_globalLabel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtSymbol::setGlobalLabel( const QString& label )
{
m_globalLabel = label;
}
//--------------------------------------------------------------------------------------------------
@ -212,7 +211,7 @@ RiuQwtSymbol::PointSymbolEnum RiuQwtSymbol::cycledSymbolStyle( int indexLevel )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QRect RiuQwtSymbol::labelBoundingRect( const QPainter* painter, const QRect& symbolRect ) const
QRect RiuQwtSymbol::labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const
{
CVF_ASSERT( painter );
@ -221,7 +220,7 @@ QRect RiuQwtSymbol::labelBoundingRect( const QPainter* painter, const QRect& sym
int symbolWidth = symbolRect.width();
int symbolHeight = symbolRect.height();
int labelWidth = painter->fontMetrics().width( m_label );
int labelWidth = painter->fontMetrics().width( label );
int labelHeight = painter->fontMetrics().height();
QPoint labelPosition;

View File

@ -61,14 +61,11 @@ public:
};
RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition = LabelAboveSymbol );
void renderSymbols( QPainter* painter, const QPointF* points, int numPoints ) const override;
void renderSymbolLabel( QPainter* painter, const QPointF& position ) const;
QString label() const
{
return m_label;
}
void setLabel( const QString& label );
void renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const;
QString globalLabel() const;
void setGlobalLabel( const QString& label );
void setLabelPosition( LabelPosition labelPosition );
@ -76,9 +73,9 @@ public:
static PointSymbolEnum cycledSymbolStyle( int indexLevel );
private:
QRect labelBoundingRect( const QPainter* painter, const QRect& symbolRect ) const;
QRect labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const;
private:
QString m_label;
QString m_globalLabel;
LabelPosition m_labelPosition;
};