diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 2282a7bfb0..99bdeec5f7 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -165,19 +165,11 @@ void RicNewWellBoreStabilityPlotFeature::createCasingShoeTrack(RimWellLogPlot* p casingShoeTrack->setFormationCase(geoMechCase); casingShoeTrack->setShowFormations(true); casingShoeTrack->setShowFormationLabels(false); + casingShoeTrack->setShowWellPathAttributes(true); + casingShoeTrack->setWellPathAttributesSource(wellPath); casingShoeTrack->setVisibleXRange(0.0, 0.0); - RimWellLogFile* foundLogFile = wellPath->firstWellLogFileMatchingChannelName("CASING_SIZE"); - - // foundLogFile may be nullptr. Create the curve anyway so it exists when changing well. - RimWellLogFileCurve* fileCurve = RicWellLogTools::addFileCurve(casingShoeTrack, false); - fileCurve->setWellLogFile(foundLogFile); - fileCurve->setWellPath(wellPath); - fileCurve->setWellLogChannelName("CASING_SIZE"); - fileCurve->setCustomName(QString("Casing size [in]")); - fileCurve->setLineThickness(2); - fileCurve->loadDataAndUpdate(false); casingShoeTrack->setAutoScaleXEnabled(true); - casingShoeTrack->calculateXZoomRangeAndUpdateQwt(); + casingShoeTrack->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 777d05ef1a..2fcb0b2af6 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -179,13 +179,13 @@ 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_showWellPathAttributeBothSides, "ShowWellPathAttrBothSides", true, "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_wellPathAttributeSource, "AttributesWellPathSource", "Well Path", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_wellPathAttributeCollection, "AttributesCollection", "Well Attributes", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_wellPathAttributeCurves, "AttributeCurves", "", "", "", ""); + m_wellPathAttributeCurves.uiCapability()->setUiHidden(true); + m_wellPathAttributeCurves.uiCapability()->setUiTreeChildrenHidden(true); CAF_PDM_InitFieldNoDefault(&m_widthScaleFactor, "Width", "Track Width", "", "Set width of track. ", ""); @@ -423,18 +423,9 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { updateWellPathAttributesOnPlot(); } - else if (changedField == &m_attributesWellPathSource) - { - m_attributesCollection = nullptr; - if (m_attributesWellPathSource) - { - std::vector attributeCollection; - m_attributesWellPathSource->descendantsIncludingThisOfType(attributeCollection); - if (!attributeCollection.empty()) - { - m_attributesCollection = attributeCollection.front(); - } - } + else if (changedField == &m_wellPathAttributeSource) + { + updateWellPathAttributesCollection(); updateWellPathAttributesOnPlot(); } } @@ -587,7 +578,7 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: } } } - else if (fieldNeedingOptions == &m_attributesWellPathSource) + else if (fieldNeedingOptions == &m_wellPathAttributeSource) { RimTools::wellPathOptionItems(&options); options.push_front(caf::PdmOptionItemInfo("None", nullptr)); @@ -678,7 +669,7 @@ void RimWellLogTrack::availableDepthRange(double* minimumDepth, double* maximumD std::vector allCurves; allCurves.insert(allCurves.end(), curves.begin(), curves.end()); - allCurves.insert(allCurves.end(), m_attributeCurves.begin(), m_attributeCurves.end()); + allCurves.insert(allCurves.end(), m_wellPathAttributeCurves.begin(), m_wellPathAttributeCurves.end()); for (RimPlotCurve* curve : allCurves) { @@ -736,6 +727,7 @@ void RimWellLogTrack::loadDataAndUpdate() if ( m_wellLogTrackPlotWidget ) { + this->updateWellPathAttributesCollection(); this->updateWellPathAttributesOnPlot(); m_wellLogTrackPlotWidget->updateLegend(); @@ -956,14 +948,22 @@ void RimWellLogTrack::applyXZoomFromVisibleRange() m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax); - // Attribute range - double posRange = 1.5 * 0.5 * RimWellPathAttribute::MAX_DIAMETER_IN_INCHES; - double negRange = 0.0; + // Attribute range. Double the width of the radius (thus same as diameter) to allow for labels and casing shoe. + double attributeRangeMax = RimWellPathAttribute::MAX_DIAMETER_IN_INCHES; + double attributeRangeMin = 0.0; if (m_showWellPathAttributeBothSides) { - negRange = -posRange; + attributeRangeMin = -attributeRangeMax; } - m_wellLogTrackPlotWidget->setXRange(negRange, posRange, QwtPlot::xBottom); + else if (m_wellPathAttributeCollection) + { + attributeRangeMin = attributeRangeMax; + for (const RimWellPathAttribute* attribute : m_wellPathAttributeCollection->attributes()) + { + attributeRangeMin = std::max(attributeRangeMin, attribute->diameterInInches() * 0.5); + } + } + m_wellLogTrackPlotWidget->setXRange(attributeRangeMin, attributeRangeMax, QwtPlot::xBottom); m_wellLogTrackPlotWidget->replot(); } @@ -1113,6 +1113,23 @@ void RimWellLogTrack::setShowFormationLabels(bool on) m_showFormationLabels = on; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::setShowWellPathAttributes(bool on) +{ + m_showWellPathAttributes = on; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::setWellPathAttributesSource(RimWellPath* wellPath) +{ + m_wellPathAttributeSource = wellPath; + updateWellPathAttributesCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1187,7 +1204,7 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& attributeGroup->add(&m_showWellPathAttributes); attributeGroup->add(&m_showWellPathAttributeBothSides); attributeGroup->add(&m_wellPathAttributesInLegend); - attributeGroup->add(&m_attributesWellPathSource); + attributeGroup->add(&m_wellPathAttributeSource); uiOrderingForXAxisSettings(uiOrdering); @@ -1258,6 +1275,23 @@ std::pair RimWellLogTrack::adjustXRange(double minValue, double return std::make_pair(adjustedMin, adjustedMax); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::updateWellPathAttributesCollection() +{ + m_wellPathAttributeCollection = nullptr; + if (m_wellPathAttributeSource) + { + std::vector attributeCollection; + m_wellPathAttributeSource->descendantsIncludingThisOfType(attributeCollection); + if (!attributeCollection.empty()) + { + m_wellPathAttributeCollection = attributeCollection.front(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1665,18 +1699,18 @@ void RimWellLogTrack::updateFormationNamesOnPlot() //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::updateWellPathAttributesOnPlot() { - for (RimWellPathAttributeCurve* curve : m_attributeCurves) + for (RimWellPathAttributeCurve* curve : m_wellPathAttributeCurves) { curve->detachQwtCurve(); } - m_attributeCurves.deleteAllChildObjects(); + m_wellPathAttributeCurves.deleteAllChildObjects(); if (m_showWellPathAttributes) { - if (m_attributesCollection) + if (m_wellPathAttributeCollection) { int index = 0; - for (RimWellPathAttribute* attribute : m_attributesCollection->attributes()) + for (RimWellPathAttribute* attribute : m_wellPathAttributeCollection->attributes()) { cvf::Color3f curveColor = RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index++); { @@ -1688,8 +1722,8 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot() negativeCurve->setColor(curveColor); positiveCurve->showLegend(m_wellPathAttributesInLegend()); negativeCurve->showLegend(false); - m_attributeCurves.push_back(positiveCurve); - m_attributeCurves.push_back(negativeCurve); + m_wellPathAttributeCurves.push_back(positiveCurve); + m_wellPathAttributeCurves.push_back(negativeCurve); } if (attribute->type() == RimWellPathAttribute::AttributeCasing) @@ -1702,12 +1736,12 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot() negativeSymbol->setColor(curveColor); positiveSymbol->showLegend(false); negativeSymbol->showLegend(false); - m_attributeCurves.push_back(positiveSymbol); - m_attributeCurves.push_back(negativeSymbol); + m_wellPathAttributeCurves.push_back(positiveSymbol); + m_wellPathAttributeCurves.push_back(negativeSymbol); } } } - for (RimWellPathAttributeCurve* curve : m_attributeCurves) + for (RimWellPathAttributeCurve* curve : m_wellPathAttributeCurves) { curve->loadDataAndUpdate(false); if (m_wellLogTrackPlotWidget) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 342f161a29..f6842c44cd 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -117,6 +117,8 @@ public: void setXAxisGridVisibility(RimWellLogPlot::AxisGridVisibility gridLines); void setShowFormations(bool on); void setShowFormationLabels(bool on); + void setShowWellPathAttributes(bool on); + void setWellPathAttributesSource(RimWellPath* wellPath); RiuWellLogTrack* viewer(); @@ -173,6 +175,7 @@ private: std::pair adjustXRange(double minValue, double maxValue, double tickInterval); + void updateWellPathAttributesCollection(); private: QString m_xAxisTitle; @@ -204,9 +207,9 @@ private: caf::PdmField m_showWellPathAttributes; caf::PdmField m_showWellPathAttributeBothSides; caf::PdmField m_wellPathAttributesInLegend; - caf::PdmPtrField m_attributesWellPathSource; - caf::PdmPtrField m_attributesCollection; - caf::PdmChildArrayField m_attributeCurves; + caf::PdmPtrField m_wellPathAttributeSource; + caf::PdmPtrField m_wellPathAttributeCollection; + caf::PdmChildArrayField m_wellPathAttributeCurves; bool m_formationsForCaseWithSimWellOnly; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttributeCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellPathAttributeCurve.cpp index acda005d99..a240b0073d 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathAttributeCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttributeCurve.cpp @@ -18,8 +18,11 @@ #include "RimWellPathAttributeCurve.h" +#include "RimWellLogPlot.h" #include "RimWellPathAttribute.h" +#include "RimWellPath.h" +#include "RigWellPath.h" #include "RiuQwtPlotCurve.h" #include "qwt_plot.h" @@ -81,8 +84,24 @@ void RimWellPathAttributeCurve::onLoadDataAndUpdate(bool updateParentPlot) std::vector xValues; std::vector yValues; + + RimWellLogPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted(plot); + RimWellLogPlot::DepthTypeEnum depthType = plot->depthType(); + if (m_wellPathAttribute) { + RimWellPath* wellPath = nullptr; + m_wellPathAttribute->firstAncestorOrThisOfTypeAsserted(wellPath); + cvf::Vec3d startPoint = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(m_wellPathAttribute->depthStart()); + cvf::Vec3d endPoint = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(m_wellPathAttribute->depthEnd()); + + double startTVD = -startPoint.z(); + double endTVD = -endPoint.z(); + + double startDepth = depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ? startTVD : m_wellPathAttribute->depthStart(); + double endDepth = depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ? endTVD : m_wellPathAttribute->depthEnd(); + setCustomName(m_wellPathAttribute->label()); double sign = m_curvePlotPosition == PositiveSide ? 1.0 : -1.0; @@ -96,7 +115,7 @@ void RimWellPathAttributeCurve::onLoadDataAndUpdate(bool updateParentPlot) setLineThickness(4); setSymbol(RiuQwtSymbol::SYMBOL_NONE); xValues = { radius, radius }; - yValues = { 0.0, m_wellPathAttribute->depthEnd() }; + yValues = { startDepth, endDepth }; } else if (m_curvePlotItem == MarkerSymbol) { @@ -115,7 +134,7 @@ void RimWellPathAttributeCurve::onLoadDataAndUpdate(bool updateParentPlot) } xValues = { radius }; - yValues = { m_wellPathAttribute->depthEnd() }; + yValues = { endDepth }; } } else if (m_wellPathAttribute->type() == RimWellPathAttribute::AttributeLiner) @@ -124,7 +143,7 @@ void RimWellPathAttributeCurve::onLoadDataAndUpdate(bool updateParentPlot) setLineThickness(2); xValues = { radius, radius}; - yValues = { m_wellPathAttribute->depthStart(), m_wellPathAttribute->depthEnd() }; + yValues = { startDepth, endDepth }; } } if (!xValues.empty()) @@ -147,8 +166,23 @@ bool RimWellPathAttributeCurve::yValueRange(double* minimumValue, double* maximu { if (m_wellPathAttribute) { - *minimumValue = m_wellPathAttribute->depthStart(); - *maximumValue = m_wellPathAttribute->depthEnd(); + RimWellLogPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted(plot); + RimWellLogPlot::DepthTypeEnum depthType = plot->depthType(); + + RimWellPath* wellPath = nullptr; + m_wellPathAttribute->firstAncestorOrThisOfTypeAsserted(wellPath); + cvf::Vec3d startPoint = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(m_wellPathAttribute->depthStart()); + cvf::Vec3d endPoint = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(m_wellPathAttribute->depthEnd()); + + double startTVD = -startPoint.z(); + double endTVD = -endPoint.z(); + + double startDepth = depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ? startTVD : m_wellPathAttribute->depthStart(); + double endDepth = depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ? endTVD : m_wellPathAttribute->depthEnd(); + + *minimumValue = startDepth; + *maximumValue = endDepth; return true; } return false; diff --git a/ApplicationCode/UserInterface/RiuQwtSymbol.cpp b/ApplicationCode/UserInterface/RiuQwtSymbol.cpp index ea56e3a664..eb7944c101 100644 --- a/ApplicationCode/UserInterface/RiuQwtSymbol.cpp +++ b/ApplicationCode/UserInterface/RiuQwtSymbol.cpp @@ -112,7 +112,7 @@ void RiuQwtSymbol::renderSymbolLabel(QPainter *painter, const QPointF& position) } else if (m_labelPosition == LabelRightOfSymbol) { - painter->drawText(position.x() + symbolWidth / 2 + 1, position.y(), m_label); + painter->drawText(position.x() + symbolWidth + 3, position.y(), m_label); } }