#3187 symbols and labels for well path attributes, initial work.

This commit is contained in:
Gaute Lindkvist
2018-08-30 14:03:58 +02:00
parent 46c5bbf4c6
commit adc9ad322a
16 changed files with 472 additions and 62 deletions

View File

@@ -29,6 +29,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttribute.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.h
${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.h
@@ -149,6 +150,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttribute.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.cpp
${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.cpp

View File

@@ -28,7 +28,6 @@
#include "RimSummaryPlot.h"
#include "RiuRimQwtPlotCurve.h"
#include "RiuLineSegmentQwtPlotCurve.h"
#include "cafPdmUiComboBoxEditor.h"
@@ -84,6 +83,7 @@ void RimPlotCurve::CurveInterpolation::setUp()
///
//--------------------------------------------------------------------------------------------------
RimPlotCurve::RimPlotCurve()
: m_symbolLabelPosition(RiuCurveQwtSymbol::LabelAboveSymbol)
{
CAF_PDM_InitObject("Curve", ":/WellLogCurve16x16.png", "", "");
@@ -476,7 +476,7 @@ void RimPlotCurve::updateCurveAppearance()
}
// QwtPlotCurve will take ownership of the symbol
symbol = new RiuCurveQwtSymbol(style, m_symbolLabel);
symbol = new RiuCurveQwtSymbol(style, m_symbolLabel, m_symbolLabelPosition);
symbol->setSize(m_symbolSize, m_symbolSize);
symbol->setColor(curveColor);
@@ -584,6 +584,44 @@ void RimPlotCurve::loadDataAndUpdate(bool updateParentPlot)
this->onLoadDataAndUpdate(updateParentPlot);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::xValueRange(double* minimumValue, double* maximumValue) const
{
CVF_ASSERT(minimumValue && maximumValue);
CVF_ASSERT(m_qwtPlotCurve);
if (m_qwtPlotCurve->data()->size() < 1)
{
return false;
}
*minimumValue = m_qwtPlotCurve->minXValue();
*maximumValue = m_qwtPlotCurve->maxXValue();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::yValueRange(double* minimumValue, double* maximumValue) const
{
CVF_ASSERT(minimumValue && maximumValue);
CVF_ASSERT(m_qwtPlotCurve);
if (m_qwtPlotCurve->data()->size() < 1)
{
return false;
}
*minimumValue = m_qwtPlotCurve->minYValue();
*maximumValue = m_qwtPlotCurve->maxYValue();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -700,16 +738,15 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
RimSummaryPlot* summaryPlot = nullptr;
this->firstAncestorOrThisOfType(summaryPlot);
bool showLegendInQwt = m_showLegend();
if (summaryPlot)
{
bool showLegendInQwt = m_showLegend();
if (summaryPlot->ensembleCurveSetCollection()->curveSets().empty() && summaryPlot->curveCount() == 1)
{
// Disable display of legend if the summary plot has only one single curve
showLegendInQwt = false;
}
m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt);
}
m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt);
}

View File

@@ -18,6 +18,7 @@
#pragma once
#include "RifEclipseSummaryAddress.h"
#include "RiuLineSegmentQwtPlotCurve.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
@@ -25,8 +26,6 @@
#include <QPointer>
class RiuLineSegmentQwtPlotCurve;
class QwtPlot;
class QwtPlotCurve;
@@ -73,6 +72,9 @@ public:
void loadDataAndUpdate(bool updateParentPlot);
virtual bool xValueRange(double* minimumValue, double* maximumValue) const;
virtual bool yValueRange(double* minimumValue, double* maximumValue) const;
void setParentQwtPlotAndReplot(QwtPlot* plot);
void setParentQwtPlotNoReplot(QwtPlot* plot);
void detachQwtCurve();
@@ -147,9 +149,10 @@ protected:
caf::PdmField<float> m_symbolSkipPixelDistance;
caf::PdmField<bool> m_showErrorBars;
caf::PdmField< caf::AppEnum< PointSymbolEnum > > m_pointSymbol;
caf::PdmField< caf::AppEnum< LineStyleEnum > > m_lineStyle;
caf::PdmField< CurveInterpolation > m_curveInterpolation;
caf::PdmField< caf::AppEnum< PointSymbolEnum > > m_pointSymbol;
caf::PdmField< caf::AppEnum< LineStyleEnum > > m_lineStyle;
caf::PdmField< CurveInterpolation > m_curveInterpolation;
RiuCurveQwtSymbol::LabelPosition m_symbolLabelPosition;
};

View File

@@ -56,46 +56,22 @@ RimWellLogCurve::~RimWellLogCurve()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogCurve::depthRange(double* minimumDepth, double* maximumDepth) const
{
CVF_ASSERT(minimumDepth && maximumDepth);
CVF_ASSERT(m_qwtPlotCurve);
if (m_qwtPlotCurve->data()->size() < 1)
{
return false;
}
*minimumDepth = m_qwtPlotCurve->minYValue();
*maximumDepth = m_qwtPlotCurve->maxYValue();
return true;
return yValueRange(minimumDepth, maximumDepth);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogCurve::valueRange(double* minimumValue, double* maximumValue) const
{
CVF_ASSERT(minimumValue && maximumValue);
CVF_ASSERT(m_qwtPlotCurve);
if (m_qwtPlotCurve->data()->size() < 1)
{
return false;
}
*minimumValue = m_qwtPlotCurve->minXValue();
*maximumValue = m_qwtPlotCurve->maxXValue();
return true;
return xValueRange(minimumValue, maximumValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -20,6 +20,7 @@
#include "RimWellLogTrack.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaExtractionTools.h"
#include "RiaSimWellBranchTools.h"
@@ -45,6 +46,9 @@
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellPathAttribute.h"
#include "RimWellPathAttributeCurve.h"
#include "RimWellPathAttributeCollection.h"
#include "RimWellFlowRateCurve.h"
#include "RimWellLogCurve.h"
#include "RimWellLogPlotCollection.h"
@@ -174,6 +178,15 @@ RimWellLogTrack::RimWellLogTrack()
CAF_PDM_InitField(&m_showformationFluids, "ShowFormationFluids", false, "Show Fluids", "", "", "");
CAF_PDM_InitField(&m_showWellPathAttributes, "ShowWellPathAttributes", false, "Show Well Attributes", "", "", "");
CAF_PDM_InitField(&m_showWellPathAttributeBothSides, "ShowWellPathAttrBothSides", false, "Show Both Sides", "", "", "");
CAF_PDM_InitField(&m_wellPathAttributesInLegend, "WellPathAttributesInLegend", false, "Contribute to Legend", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_attributesWellPathSource, "AttributesWellPathSource", "Well Path", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_attributesCollection, "AttributesCollection", "Well Attributes", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_attributeCurves, "AttributeCurves", "", "", "", "");
m_attributeCurves.uiCapability()->setUiHidden(true);
m_attributeCurves.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault(&m_widthScaleFactor, "Width", "Track Width", "", "Set width of track. ", "");
m_formationsForCaseWithSimWellOnly = false;
@@ -404,6 +417,26 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
{
loadDataAndUpdate();
}
else if (changedField == &m_showWellPathAttributes ||
changedField == &m_showWellPathAttributeBothSides ||
changedField == &m_wellPathAttributesInLegend)
{
updateWellPathAttributesOnPlot();
}
else if (changedField == &m_attributesWellPathSource)
{
m_attributesCollection = nullptr;
if (m_attributesWellPathSource)
{
std::vector<RimWellPathAttributeCollection*> attributeCollection;
m_attributesWellPathSource->descendantsIncludingThisOfType(attributeCollection);
if (!attributeCollection.empty())
{
m_attributesCollection = attributeCollection.front();
}
}
updateWellPathAttributesOnPlot();
}
}
//--------------------------------------------------------------------------------------------------
@@ -554,7 +587,11 @@ QList<caf::PdmOptionItemInfo> RimWellLogTrack::calculateValueOptions(const caf::
}
}
}
else if (fieldNeedingOptions == &m_attributesWellPathSource)
{
RimTools::wellPathOptionItems(&options);
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
}
return options;
}
@@ -638,14 +675,17 @@ void RimWellLogTrack::availableDepthRange(double* minimumDepth, double* maximumD
double minDepth = HUGE_VAL;
double maxDepth = -HUGE_VAL;
size_t curveCount = curves.size();
for (size_t cIdx = 0; cIdx < curveCount; cIdx++)
std::vector<RimPlotCurve*> allCurves;
allCurves.insert(allCurves.end(), curves.begin(), curves.end());
allCurves.insert(allCurves.end(), m_attributeCurves.begin(), m_attributeCurves.end());
for (RimPlotCurve* curve : allCurves)
{
double minCurveDepth = HUGE_VAL;
double maxCurveDepth = -HUGE_VAL;
if (curves[cIdx]->isCurveVisible() && curves[cIdx]->depthRange(&minCurveDepth, &maxCurveDepth))
if (curve->isCurveVisible() && curve->yValueRange(&minCurveDepth, &maxCurveDepth))
{
if (minCurveDepth < minDepth)
{
@@ -696,7 +736,9 @@ void RimWellLogTrack::loadDataAndUpdate()
if ( m_wellLogTrackPlotWidget )
{
this->updateWellPathAttributesOnPlot();
m_wellLogTrackPlotWidget->updateLegend();
this->updateAxisScaleEngine();
this->updateFormationNamesOnPlot();
this->applyXZoomFromVisibleRange();
@@ -913,6 +955,16 @@ void RimWellLogTrack::applyXZoomFromVisibleRange()
if (!m_wellLogTrackPlotWidget) return;
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
// Attribute range
double posRange = 1.5 * 0.5 * RimWellPathAttribute::MAX_DIAMETER_IN_INCHES;
double negRange = 0.0;
if (m_showWellPathAttributeBothSides)
{
negRange = -posRange;
}
m_wellLogTrackPlotWidget->setXRange(negRange, posRange, QwtPlot::xBottom);
m_wellLogTrackPlotWidget->replot();
}
@@ -936,15 +988,15 @@ void RimWellLogTrack::calculateXZoomRange()
double maxValue = -HUGE_VAL;
size_t visibleCurves = 0u;
for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
for (auto curve : curves)
{
double minCurveValue = HUGE_VAL;
double maxCurveValue = -HUGE_VAL;
if (curves[cIdx]->isCurveVisible())
if (curve->isCurveVisible())
{
visibleCurves++;
if (curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue))
if (curve->xValueRange(&minCurveValue, &maxCurveValue))
{
if (minCurveValue < minValue)
{
@@ -1131,6 +1183,12 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
}
}
caf::PdmUiGroup* attributeGroup = uiOrdering.addNewGroup("Well Attributes");
attributeGroup->add(&m_showWellPathAttributes);
attributeGroup->add(&m_showWellPathAttributeBothSides);
attributeGroup->add(&m_wellPathAttributesInLegend);
attributeGroup->add(&m_attributesWellPathSource);
uiOrderingForXAxisSettings(uiOrdering);
caf::PdmUiGroup* trackSettingsGroup = uiOrdering.addNewGroup("Track Settings");
@@ -1602,6 +1660,65 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateWellPathAttributesOnPlot()
{
for (RimWellPathAttributeCurve* curve : m_attributeCurves)
{
curve->detachQwtCurve();
}
m_attributeCurves.deleteAllChildObjects();
if (m_showWellPathAttributes)
{
if (m_attributesCollection)
{
int index = 0;
for (RimWellPathAttribute* attribute : m_attributesCollection->attributes())
{
cvf::Color3f curveColor = RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index++);
{
RimWellPathAttributeCurve* positiveCurve = new RimWellPathAttributeCurve(
attribute, RimWellPathAttributeCurve::PositiveSide, RimWellPathAttributeCurve::LineCurve);
RimWellPathAttributeCurve* negativeCurve = new RimWellPathAttributeCurve(
attribute, RimWellPathAttributeCurve::NegativeSide, RimWellPathAttributeCurve::LineCurve);
positiveCurve->setColor(curveColor);
negativeCurve->setColor(curveColor);
positiveCurve->showLegend(m_wellPathAttributesInLegend());
negativeCurve->showLegend(false);
m_attributeCurves.push_back(positiveCurve);
m_attributeCurves.push_back(negativeCurve);
}
if (attribute->type() == RimWellPathAttribute::AttributeCasing)
{
RimWellPathAttributeCurve* positiveSymbol = new RimWellPathAttributeCurve(
attribute, RimWellPathAttributeCurve::PositiveSide, RimWellPathAttributeCurve::MarkerSymbol);
RimWellPathAttributeCurve* negativeSymbol = new RimWellPathAttributeCurve(
attribute, RimWellPathAttributeCurve::NegativeSide, RimWellPathAttributeCurve::MarkerSymbol);
positiveSymbol->setColor(curveColor);
negativeSymbol->setColor(curveColor);
positiveSymbol->showLegend(false);
negativeSymbol->showLegend(false);
m_attributeCurves.push_back(positiveSymbol);
m_attributeCurves.push_back(negativeSymbol);
}
}
}
for (RimWellPathAttributeCurve* curve : m_attributeCurves)
{
curve->loadDataAndUpdate(false);
if (m_wellLogTrackPlotWidget)
{
curve->setParentQwtPlotNoReplot(m_wellLogTrackPlotWidget);
}
}
applyXZoomFromVisibleRange();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -36,6 +36,8 @@
class RigWellPath;
class RimCase;
class RimWellPathAttributeCurve;
class RimWellPathAttributeCollection;
class RimWellFlowRateCurve;
class RimWellLogCurve;
class RimWellPath;
@@ -164,6 +166,7 @@ private:
void setFormationFieldsUiReadOnly(bool readOnly = true);
void updateFormationNamesOnPlot();
void updateWellPathAttributesOnPlot();
void removeFormationNames();
void updateAxisScaleEngine();
bool isFirstVisibleTrackInPlot() const;
@@ -198,6 +201,12 @@ private:
caf::PdmField<bool> m_showformationFluids;
caf::PdmField<caf::AppEnum<WidthScaleFactor>> m_widthScaleFactor;
caf::PdmField<bool> m_formationBranchDetection;
caf::PdmField<bool> m_showWellPathAttributes;
caf::PdmField<bool> m_showWellPathAttributeBothSides;
caf::PdmField<bool> m_wellPathAttributesInLegend;
caf::PdmPtrField<RimWellPath*> m_attributesWellPathSource;
caf::PdmPtrField<RimWellPathAttributeCollection*> m_attributesCollection;
caf::PdmChildArrayField<RimWellPathAttributeCurve*> m_attributeCurves;
bool m_formationsForCaseWithSimWellOnly;

View File

@@ -23,6 +23,8 @@
#include "cafPdmUiComboBoxEditor.h"
#include <cmath>
CAF_PDM_SOURCE_INIT(RimWellPathAttribute, "WellPathAttribute");
namespace caf
@@ -146,7 +148,7 @@ QString RimWellPathAttribute::generateInchesLabel(double diameter)
double integerPart = 0.0;
double fraction = modf(diameter, &integerPart);
int numerator = static_cast<int>(std::round(fraction / 0.125));
int numerator = static_cast<int>(std::round(8.0 * fraction));
if (numerator > 0)
{

View File

@@ -49,13 +49,13 @@ public:
QString label() const;
QString diameterLabel() const;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
static QString generateInchesLabel(double diameter);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
private:
caf::PdmField<AttributeTypeEnum> m_type;
caf::PdmField<double> m_depthStart;
caf::PdmField<double> m_depthEnd;

View File

@@ -17,6 +17,9 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellPathAttributeCollection.h"
#include "RimWellPathAttribute.h"
#include "RimWellLogTrack.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTableViewEditor.h"
@@ -43,6 +46,21 @@ RimWellPathAttributeCollection::~RimWellPathAttributeCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathAttributeCollection::updateAllReferringTracks()
{
std::vector<RimWellLogTrack*> wellLogTracks;
this->objectsWithReferringPtrFieldsOfType(wellLogTracks);
for (RimWellLogTrack* track : wellLogTracks)
{
track->loadDataAndUpdate();
}
this->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -17,14 +17,14 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimWellPathAttribute.h"
#include "cafAppEnum.h"
#include "cvfBase.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
class RimWellPathAttribute;
class RimWellPathAttributeCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
@@ -32,6 +32,7 @@ public:
RimWellPathAttributeCollection();
~RimWellPathAttributeCollection();
void updateAllReferringTracks();
std::vector<RimWellPathAttribute*> attributes() const;
void insertAttribute(RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute);
void deleteAttribute(RimWellPathAttribute* attributeToDelete);

View File

@@ -0,0 +1,152 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "RimWellPathAttributeCurve.h"
#include "RimWellPathAttribute.h"
#include "RiuLineSegmentQwtPlotCurve.h"
#include "qwt_plot.h"
//==================================================================================================
///
///
//==================================================================================================
CAF_PDM_SOURCE_INIT(RimWellPathAttributeCurve, "RimWellPathAttributeCurve");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathAttributeCurve::RimWellPathAttributeCurve(RimWellPathAttribute* wellPathAttribute,
CurvePlotPosition plotPosition,
CurvePlotItem curvePlotItem)
: m_curvePlotPosition(plotPosition)
, m_curvePlotItem(curvePlotItem)
{
CAF_PDM_InitObject("Well Attribute Curve", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellPathAttribute, "WellPathAttribute", "Well Attribute", "", "", "");
m_wellPathAttribute.xmlCapability()->disableIO();
m_wellPathAttribute = wellPathAttribute;
m_symbolLabelPosition = RiuCurveQwtSymbol::LabelRightOfSymbol;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathAttributeCurve::~RimWellPathAttributeCurve()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathAttributeCurve::updateZoomInParentPlot()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellPathAttributeCurve::createCurveAutoName()
{
CVF_ASSERT(m_wellPathAttribute);
return m_wellPathAttribute->label();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathAttributeCurve::onLoadDataAndUpdate(bool updateParentPlot)
{
m_qwtPlotCurve->setXAxis(QwtPlot::xBottom);
std::vector<double> xValues;
std::vector<double> yValues;
if (m_wellPathAttribute)
{
setCustomName(m_wellPathAttribute->label());
double sign = m_curvePlotPosition == PositiveSide ? 1.0 : -1.0;
double radius = 0.5 * sign * m_wellPathAttribute->diameterInInches();
if (m_wellPathAttribute->type() == RimWellPathAttribute::AttributeCasing)
{
if (m_curvePlotItem == LineCurve)
{
setLineStyle(RimPlotCurve::STYLE_SOLID);
setLineThickness(4);
setSymbol(RimPlotCurve::SYMBOL_NONE);
xValues = { radius, radius };
yValues = { 0.0, m_wellPathAttribute->depthEnd() };
}
else if (m_curvePlotItem == MarkerSymbol)
{
setLineStyle(RimPlotCurve::STYLE_NONE);
setLineThickness(0);
setSymbol(RimPlotCurve::SYMBOL_TRIANGLE);
setSymbolSize(16);
if (m_curvePlotPosition == PositiveSide)
{
setSymbolLabel(m_wellPathAttribute->diameterLabel());
}
xValues = { radius };
yValues = { m_wellPathAttribute->depthEnd() };
}
}
else if (m_wellPathAttribute->type() == RimWellPathAttribute::AttributeLiner)
{
setLineStyle(RimPlotCurve::STYLE_DASH);
setLineThickness(2);
xValues = { radius, radius};
yValues = { m_wellPathAttribute->depthStart(), m_wellPathAttribute->depthEnd() };
}
}
if (!xValues.empty())
{
CVF_ASSERT(xValues.size() == yValues.size());
m_qwtPlotCurve->setSamples(&xValues[0], &yValues[0], static_cast<int>(xValues.size()));
RimPlotCurve::updateCurvePresentation(updateParentPlot);
}
if (updateParentPlot)
{
m_parentQwtPlot->replot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPathAttributeCurve::yValueRange(double* minimumValue, double* maximumValue) const
{
if (m_wellPathAttribute)
{
*minimumValue = m_wellPathAttribute->depthStart();
*maximumValue = m_wellPathAttribute->depthEnd();
return true;
}
return false;
}

View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "RimPlotCurve.h"
#include "cafPdmBase.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
class RigWellLogCurveData;
class RimWellPathAttribute;
//==================================================================================================
///
///
//==================================================================================================
class RimWellPathAttributeCurve : public RimPlotCurve
{
CAF_PDM_HEADER_INIT;
enum CurvePlotPosition
{
NegativeSide,
PositiveSide
};
enum CurvePlotItem
{
LineCurve,
MarkerSymbol
};
public:
RimWellPathAttributeCurve(RimWellPathAttribute* wellPathAttribute = nullptr, CurvePlotPosition plotPosition = PositiveSide, CurvePlotItem curvePlotItem = LineCurve);
~RimWellPathAttributeCurve();
void updateZoomInParentPlot();
QString createCurveAutoName();
void onLoadDataAndUpdate(bool updateParentPlot);
virtual bool yValueRange(double* minimumValue, double* maximumValue) const override;
private:
caf::PdmPtrField<RimWellPathAttribute*> m_wellPathAttribute;
CurvePlotPosition m_curvePlotPosition;
CurvePlotItem m_curvePlotItem;
};

View File

@@ -243,8 +243,7 @@ void RiuLineSegmentQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol
{
for (auto& pt : pointsToDisplay)
{
int width = painter->fontMetrics().width(sym->label());
painter->drawText(pt.x() - width / 2, pt.y() - 5, sym->label());
sym->renderSymbolLabel(painter, pt);
}
}
}
@@ -358,7 +357,8 @@ std::vector<double> RiuLineSegmentQwtPlotCurve::fromTime_t(const std::vector<tim
//--------------------------------------------------------------------------------------------------
/// Internal class to support labels on symbols
//--------------------------------------------------------------------------------------------------
RiuCurveQwtSymbol::RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label) : QwtSymbol(style), m_label(label)
RiuCurveQwtSymbol::RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label, LabelPosition labelPosition)
: QwtSymbol(style), m_label(label), m_labelPosition(labelPosition)
{
}
@@ -370,9 +370,33 @@ void RiuCurveQwtSymbol::renderSymbols(QPainter *painter, const QPointF *points,
{
for (int i = 0; i < numPoints; i++)
{
auto pt = points[i];
int width = painter->fontMetrics().width(m_label);
painter->drawText(pt.x() - width / 2, pt.y() - 5, m_label);
auto position = points[i];
renderSymbolLabel(painter, position);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuCurveQwtSymbol::renderSymbolLabel(QPainter *painter, const QPointF& position) const
{
int symbolWidth = this->size().width();
int labelWidth = painter->fontMetrics().width(m_label);
if (m_labelPosition == LabelAboveSymbol)
{
painter->drawText(position.x() - labelWidth / 2, position.y() - 5, m_label);
}
else if (m_labelPosition == LabelRightOfSymbol)
{
painter->drawText(position.x() + symbolWidth / 2 + 1, position.y(), m_label);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuCurveQwtSymbol::setLabelPosition(LabelPosition labelPosition)
{
m_labelPosition = labelPosition;
}

View File

@@ -118,12 +118,20 @@ private:
class RiuCurveQwtSymbol : public QwtSymbol
{
public:
RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label);
enum LabelPosition
{
LabelAboveSymbol,
LabelRightOfSymbol
};
RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label, LabelPosition labelPosition = LabelAboveSymbol);
virtual 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 setLabelPosition(LabelPosition labelPosition);
private:
QString m_label;
QString m_label;
LabelPosition m_labelPosition;
};

View File

@@ -106,10 +106,9 @@ void RiuWellLogTrack::setDepthZoom(double minDepth, double maxDepth)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setXRange(double min, double max)
void RiuWellLogTrack::setXRange(double min, double max, QwtPlot::Axis axis)
{
setAxisScale(QwtPlot::xTop, min, max);
setAxisScale(QwtPlot::xBottom, min, max);
setAxisScale(axis, min, max);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -49,7 +49,7 @@ public:
void setDepthTitle(const QString& title);
void setXTitle(const QString& title);
void setXRange(double min, double max);
void setXRange(double min, double max, QwtPlot::Axis axis = QwtPlot::xTop);
bool isRimTrackVisible();
void enableDepthAxisLabelsAndTitle(bool enable);