From 899a226a38559c204374d25606581aa51e2ab2c9 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 5 Dec 2017 12:56:13 +0100 Subject: [PATCH] #2226 Well Formations: Avoid adding "Top" to the formation names --- .../ProjectDataModel/RimWellLogTrack.cpp | 16 ++--- .../UserInterface/RiuPlotAnnotationTool.cpp | 65 +++++++++++++------ .../UserInterface/RiuPlotAnnotationTool.h | 4 ++ 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index e01b4fd8c9..316ec0f739 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -1234,29 +1234,23 @@ void RimWellLogTrack::updateFormationNamesOnPlot() plot->depthType(), &formationNamesToPlot, &yValues); + + m_annotationTool->attachFormationNames(this->viewer(), formationNamesToPlot, yValues); } else { if (m_formationWellPath == nullptr) return; if (plot->depthType() != RimWellLogPlot::MEASURED_DEPTH) return; - std::vector topYValues; + std::vector yValues; const RigWellPathFormations* formations = m_formationWellPath->formationsGeometry(); if (!formations) return; - formations->measuredDepthAndFormationNamesWithoutDuplicates(formationNamesToPlot, topYValues); + formations->measuredDepthAndFormationNamesWithoutDuplicates(formationNamesToPlot, yValues); - if (topYValues.empty()) return; - - for (size_t i = 0; i < topYValues.size() - 1; i++) - { - yValues.push_back(std::pair(topYValues[i], topYValues[i + 1])); - } - yValues.push_back(std::pair(topYValues.back(), topYValues.back())); + m_annotationTool->attachWellPicks(this->viewer(), formationNamesToPlot, yValues); } - - m_annotationTool->attachFormationNames(this->viewer(), formationNamesToPlot, yValues); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuPlotAnnotationTool.cpp b/ApplicationCode/UserInterface/RiuPlotAnnotationTool.cpp index 909ccee216..02c6c39cda 100644 --- a/ApplicationCode/UserInterface/RiuPlotAnnotationTool.cpp +++ b/ApplicationCode/UserInterface/RiuPlotAnnotationTool.cpp @@ -40,49 +40,56 @@ void RiuPlotAnnotationTool::attachFormationNames(QwtPlot* plot, const std::vecto if (names.size() != yPositions.size()) return; m_plot = plot; - QPen curvePen; - curvePen.setStyle(Qt::DashLine); - curvePen.setColor(QColor(0, 0, 100)); - curvePen.setWidth(1); double delta = 0.5; for (size_t i = 0; i < names.size(); i++) { QwtPlotMarker* line(new QwtPlotMarker()); - - line->setLineStyle(QwtPlotMarker::HLine); - line->setLinePen(curvePen); - line->setYValue(yPositions[i].first); QString name = names[i]; if (names[i].toLower().indexOf("top") == -1) { name += " Top"; } - - line->setLabel(name); - line->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom); + + RiuPlotAnnotationTool::horizontalDashedLine(line, name, yPositions[i].first); line->attach(m_plot); - m_markers.push_back(std::move(line)); if ((i != names.size() - 1) && cvf::Math::abs(yPositions[i].second - yPositions[i+1].first) > delta) { - QwtPlotMarker* line(new QwtPlotMarker()); + QwtPlotMarker* bottomLine(new QwtPlotMarker()); + RiuPlotAnnotationTool::horizontalDashedLine(bottomLine, QString(), yPositions[i].second); - line->setLineStyle(QwtPlotMarker::HLine); - line->setLinePen(curvePen); - line->setYValue(yPositions[i].second); - - line->attach(m_plot); - - m_markers.push_back(std::move(line)); + bottomLine->attach(m_plot); + m_markers.push_back(std::move(bottomLine)); } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotAnnotationTool::attachWellPicks(QwtPlot* plot, const std::vector& names, const std::vector yPositions) +{ + detachAllAnnotations(); + + if (names.size() != yPositions.size()) return; + m_plot = plot; + + double delta = 0.5; + + for (size_t i = 0; i < names.size(); i++) + { + QwtPlotMarker* line(new QwtPlotMarker()); + RiuPlotAnnotationTool::horizontalDashedLine(line, names[i], yPositions[i]); + line->attach(m_plot); + m_markers.push_back(std::move(line)); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -98,3 +105,21 @@ void RiuPlotAnnotationTool::detachAllAnnotations() } m_markers.clear(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotAnnotationTool::horizontalDashedLine(QwtPlotMarker* line, const QString& name, double yValue) +{ + QPen curvePen; + curvePen.setStyle(Qt::DashLine); + curvePen.setColor(QColor(0, 0, 100)); + curvePen.setWidth(1); + + line->setLineStyle(QwtPlotMarker::HLine); + line->setLinePen(curvePen); + line->setYValue(yValue); + line->setLabel(name); + line->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom); +} + diff --git a/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h b/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h index 400387ce1b..b97b50fe88 100644 --- a/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h +++ b/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h @@ -35,8 +35,12 @@ public: ~RiuPlotAnnotationTool(); void attachFormationNames(QwtPlot* plot, const std::vector& names, const std::vector> yPositions); + void attachWellPicks(QwtPlot* plot, const std::vector& names, const std::vector yPositions); void detachAllAnnotations(); +private: + static void horizontalDashedLine(QwtPlotMarker* line, const QString& name, double yValue); + private: QPointer m_plot; std::vector m_markers;