From c1537664e3b6d4d519241be82a0525467f8ed39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 1 Dec 2017 15:14:47 +0100 Subject: [PATCH 01/22] Revert "2108 summary plot. Display short name in plot for calculated curves" This reverts commit 83a272296c5c50a19dc9151573370286ae160675. --- .../SummaryPlotCommands/RicSummaryCurveCreator.cpp | 12 ------------ ApplicationCode/ProjectDataModel/RimPlotCurve.cpp | 9 --------- ApplicationCode/ProjectDataModel/RimPlotCurve.h | 1 - .../Summary/RimSummaryCurvesCalculator.cpp | 4 ++-- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 2d5f1265ed..39ad1627b3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -357,18 +357,6 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: curve->applyCurveAutoNameSettings(*m_curveNameConfig()); m_previewPlot->addCurveNoUpdate(curve); curveLookCalc.setupCurveLook(curve); - - if (curveDef.summaryAddress().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED) - { - // Use short version of calculated curves name - std::string fullName = curveDef.summaryAddress().quantityName(); - size_t firstSpace = fullName.find_first_of(' '); - QString shortName = firstSpace != std::string::npos ? - QString::fromStdString(fullName.substr(0, firstSpace)) : - QString::fromStdString(fullName); - - curve->setCustomCurveName(shortName); - } } m_previewPlot->loadDataAndUpdate(); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index cbcb93bb8e..208c921970 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -552,15 +552,6 @@ void RimPlotCurve::setZOrder(double z) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setCustomCurveName(const QString& customName) -{ - m_isUsingAutoName = false; - m_customCurveName = customName; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 89b753fa85..ee58669c7e 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -99,7 +99,6 @@ public: void showLegend(bool show); void setZOrder(double z); - void setCustomCurveName(const QString& customName); protected: diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index f9621ebde7..1bc5144875 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -206,7 +206,7 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { for (RimSummaryCurve* rimCurve : m_summaryCurves) { - unitToQuantityNameMap[rimCurve->unitNameX()].insert(rimCurve->curveName().toStdString()); + unitToQuantityNameMap[rimCurve->unitNameX()].insert(rimCurve->summaryAddressX().quantityName()); } } else @@ -215,7 +215,7 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { if ( rimCurve->axisY() == this->m_axisProperties->plotAxisType() ) { - unitToQuantityNameMap[rimCurve->unitNameY()].insert(rimCurve->curveName().toStdString()); + unitToQuantityNameMap[rimCurve->unitNameY()].insert(rimCurve->summaryAddressY().quantityName()); } } } From ffbd4cda82c386b948cc26360a5cd9e931b77e16 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Dec 2017 14:44:16 +0100 Subject: [PATCH 02/22] #2108 Summary Plot : Use calculation short name in axis title --- .../Summary/RimSummaryCurvesCalculator.cpp | 34 ++++++++++++++++--- .../Summary/RimSummaryCurvesCalculator.h | 2 ++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index 1bc5144875..ff05319bd0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -206,16 +206,28 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { for (RimSummaryCurve* rimCurve : m_summaryCurves) { - unitToQuantityNameMap[rimCurve->unitNameX()].insert(rimCurve->summaryAddressX().quantityName()); + std::string quantityName = rimCurve->summaryAddressX().quantityName(); + if (rimCurve->summaryAddressX().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED) + { + quantityName = shortCalculationName(quantityName); + } + + unitToQuantityNameMap[rimCurve->unitNameX()].insert(quantityName); } } else { - for ( RimSummaryCurve* rimCurve : m_summaryCurves ) + for (RimSummaryCurve* rimCurve : m_summaryCurves) { - if ( rimCurve->axisY() == this->m_axisProperties->plotAxisType() ) + if (rimCurve->axisY() == this->m_axisProperties->plotAxisType()) { - unitToQuantityNameMap[rimCurve->unitNameY()].insert(rimCurve->summaryAddressY().quantityName()); + std::string quantityName = rimCurve->summaryAddressY().quantityName(); + if (rimCurve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED) + { + quantityName = shortCalculationName(quantityName); + } + + unitToQuantityNameMap[rimCurve->unitNameY()].insert(quantityName); } } } @@ -258,9 +270,21 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const return assembledYAxisText; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotYAxisFormatter::shortCalculationName(const std::string& calculationName) +{ + QString calculationShortName = QString::fromStdString(calculationName); + int indexOfFirstSpace = calculationShortName.indexOf(' '); + if (indexOfFirstSpace > -1 && indexOfFirstSpace < calculationShortName.size()) + { + calculationShortName = calculationShortName.left(indexOfFirstSpace); + } - + return calculationShortName.toStdString(); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.h index 21d97cdae2..4a063e658f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.h @@ -42,6 +42,8 @@ public: private: QString autoAxisTitle() const; + + static std::string shortCalculationName(const std::string& calculationName); private: RimSummaryAxisProperties* m_axisProperties; From bc6a3676358b219fcd3fec52dbf9fc2d60468d06 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Dec 2017 14:54:54 +0100 Subject: [PATCH 03/22] #987 Summary Plot : Do not show default unit text if empty calculation unit text --- .../Summary/RimCalculatedSummaryCurveReader.cpp | 3 ++- .../ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp | 2 +- .../ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp b/ApplicationCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp index d12cbadf25..7aa87631dd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp @@ -73,7 +73,8 @@ std::string RifCalculatedSummaryCurveReader::unitName(const RifEclipseSummaryAdd { return calculation->unitName().toStdString(); } - return "Calculated Curve Unit"; + + return ""; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 82c5e60364..026e87bff9 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -63,7 +63,7 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa { text += summaryAddress.quantityName(); - if (m_unit && summaryCurve) + if (m_unit && summaryCurve && !summaryCurve->unitNameY().empty()) { text += "[" + summaryCurve->unitNameY() + "]"; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index ff05319bd0..804f00a1b8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -251,7 +251,11 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { assembledYAxisText += QString::fromStdString(quantIt) + " "; } - assembledYAxisText += "[" + QString::fromStdString(unitIt.first) + scaleFactorText + "] "; + + if (!unitIt.first.empty()) + { + assembledYAxisText += "[" + QString::fromStdString(unitIt.first) + scaleFactorText + "] "; + } } if (m_timeHistoryCurveQuantities.size() > 0) From fa3d9c4fc2905219e5778d4e763bb5bdd0c1f1e3 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 8 Dec 2017 15:46:16 +0100 Subject: [PATCH 04/22] #2227 Well Formation: Add filter. Filter options not dynamic --- .../ProjectDataModel/RimWellLogTrack.cpp | 49 ++++- .../RigWellPathFormations.cpp | 202 ++++++++++++++++-- .../RigWellPathFormations.h | 35 ++- 3 files changed, 263 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 7a684baab5..21ffad7bd2 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -80,9 +80,22 @@ namespace caf void AppEnum< RimWellLogTrack::FormationSource >::setUp() { addItem(RimWellLogTrack::CASE, "CASE", "Case"); - addItem(RimWellLogTrack::WELL_PICK, "WELLPICK", "Well Pick"); + addItem(RimWellLogTrack::WELL_PICK, "WELL_PICK", "Well Pick"); + addItem(RimWellLogTrack::WELL_PICK_FILTER, "WELL_PICK_FILTER", "Well Pick Filter"); setDefault(RimWellLogTrack::CASE); } + + template<> + void AppEnum::setUp() + { + addItem(RigWellPathFormation::ALL, "ALL", "All"); + addItem(RigWellPathFormation::GROUP, "GROUP", "Group"); + addItem(RigWellPathFormation::LEVEL0, "LEVEL0", "Main"); + addItem(RigWellPathFormation::LEVEL1, "LEVEL1", "Level 1"); + addItem(RigWellPathFormation::LEVEL2, "LEVEL2", "Level 2"); + addItem(RigWellPathFormation::LEVEL3, "LEVEL3", "Level 3"); + setDefault(RigWellPathFormation::ALL); + } } @@ -125,6 +138,10 @@ RimWellLogTrack::RimWellLogTrack() CAF_PDM_InitFieldNoDefault(&m_formationCase, "FormationCase", "Formation Case", "", "", ""); m_formationCase.uiCapability()->setUiTreeChildrenHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_formationLevel, "FormationLevel", "Formation Level", "", "", ""); + + CAF_PDM_InitField(&m_showformationFluids, "ShowFormationFluids", false, "Show Fluids", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -285,6 +302,14 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, loadDataAndUpdate(); } + else if (changedField == &m_formationLevel) + { + loadDataAndUpdate(); + } + else if (changedField == &m_showformationFluids) + { + loadDataAndUpdate(); + } } //-------------------------------------------------------------------------------------------------- @@ -302,7 +327,7 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: { RimTools::wellPathOptionItems(&options); } - else if(m_formationSource == WELL_PICK) + else if(m_formationSource == WELL_PICK || m_formationSource == WELL_PICK_FILTER) { RimTools::wellPathWithFormationsOptionItems(&options); } @@ -740,6 +765,12 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& { formationGroup->add(&m_formationWellPath); } + else if (m_formationSource() == WELL_PICK_FILTER) + { + formationGroup->add(&m_formationWellPath); + formationGroup->add(&m_formationLevel); + formationGroup->add(&m_showformationFluids); + } uiOrderingForVisibleXRange(uiOrdering); @@ -1170,6 +1201,20 @@ void RimWellLogTrack::updateFormationNamesOnPlot() formations->measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(&formationNamesToPlot, &yValues); + m_annotationTool->attachWellPicks(this->viewer(), formationNamesToPlot, yValues); + } + else if (m_formationSource() == WELL_PICK_FILTER) + { + if (m_formationWellPath == nullptr) return; + if (plot->depthType() != RimWellLogPlot::MEASURED_DEPTH) return; + + std::vector yValues; + + const RigWellPathFormations* formations = m_formationWellPath->formationsGeometry(); + if (!formations) return; + + formations->measuredDepthAndFormationNamesUpToLevel(m_formationLevel(), &formationNamesToPlot, &yValues, m_showformationFluids()); + m_annotationTool->attachWellPicks(this->viewer(), formationNamesToPlot, yValues); } } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index b91336d2b2..8f3c65906b 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017- Statoil 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -23,20 +23,32 @@ #include "cvfMath.h" //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RigWellPathFormations::RigWellPathFormations(std::vector formations, const QString& filePath, const QString& key) +RigWellPathFormations::RigWellPathFormations(std::vector formations, const QString& filePath, + const QString& key) { - m_filePath = filePath; - m_keyInFile = key; + m_filePath = filePath; + m_keyInFile = key; m_formations = formations; + m_maxLevelDetected = RigWellPathFormation::ALL; + + for (RigWellPathFormation& formation : m_formations) + { + RigWellPathFormation::FormationLevel level = detectLevel(formation.formationName); + formation.level = level; + if (level > m_maxLevelDetected) + { + m_maxLevelDetected = level; + } + } } struct MeasuredDepthComp { bool operator()(const double& md1, const double& md2) const { - if (cvf::Math::abs(md1 - md2) < 1.0) + if (cvf::Math::abs(md1 - md2) < 0.1) { return false; } @@ -45,9 +57,10 @@ struct MeasuredDepthComp }; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, std::vector* measuredDepths) const +void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, + std::vector* measuredDepths) const { names->clear(); measuredDepths->clear(); @@ -75,16 +88,102 @@ void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDep } } +struct NameAndMD +{ + NameAndMD(RigWellPathFormation::FormationLevel level, QString name, double md) : m_level(level), m_name(name), m_md(md) {} + NameAndMD() {} + RigWellPathFormation::FormationLevel m_level; + QString m_name; + double m_md; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, + std::vector* names, + std::vector* measuredDepths, bool includeFluids) const +{ + names->clear(); + measuredDepths->clear(); + + if (level == RigWellPathFormation::ALL) + { + measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); + return; + } + + std::map tempMakeVectorUniqueOnMeasuredDepth; + + for (RigWellPathFormation formation : m_formations) + { + if (formation.level == RigWellPathFormation::FLUIDS) + { + if (includeFluids) + { + tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = + NameAndMD(formation.level, formation.formationName + " Top", formation.mdTop); + } + else continue; + } + + if (level < formation.level) continue; + + if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdTop) || + tempMakeVectorUniqueOnMeasuredDepth.at(formation.mdTop).m_level < formation.level) + { + tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = + NameAndMD(formation.level, formation.formationName + " Top", formation.mdTop); + } + } + + for (RigWellPathFormation formation : m_formations) + { + if (formation.level == RigWellPathFormation::FLUIDS) + { + if (includeFluids) + { + tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = + NameAndMD(formation.level, formation.formationName + " Base", formation.mdTop); + } + else continue; + } + + if (level < formation.level) continue; + + if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdBase) || + tempMakeVectorUniqueOnMeasuredDepth.at(formation.mdBase).m_level < formation.level) + { + tempMakeVectorUniqueOnMeasuredDepth[formation.mdBase] = + NameAndMD(formation.level, formation.formationName + " Base", formation.mdBase); + } + } + + for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) + { + names->push_back(it->second.m_name); + measuredDepths->push_back(it->second.m_md); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +RigWellPathFormation::FormationLevel RigWellPathFormations::maxFormationLevel() const +{ + return m_maxLevelDetected; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- QString RigWellPathFormations::filePath() const { return m_filePath; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RigWellPathFormations::keyInFile() const { @@ -92,9 +191,86 @@ QString RigWellPathFormations::keyInFile() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigWellPathFormations::formationNamesCount() const { return m_formations.size(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString formationName) +{ + formationName = formationName.trimmed(); + + if (formationName == "OIL" || formationName == "GAS") + { + return RigWellPathFormation::FLUIDS; + } + + bool isGroupName = true; + for (QChar c : formationName) + { + if (c.isLower()) + { + isGroupName = false; + break; + } + } + if (isGroupName) + { + return RigWellPathFormation::GROUP; + } + + QStringList formationNameSplitted = formationName.split(" "); + + std::vector levelDesctiptorCandidates; + + for (QString word : formationNameSplitted) + { + for (const QChar& c : word) + { + if (c.isDigit()) + { + levelDesctiptorCandidates.push_back(word); + break; + } + } + } + if (levelDesctiptorCandidates.empty()) + { + return RigWellPathFormation::LEVEL0; + } + + if (levelDesctiptorCandidates.size() > 1) + { + for (auto it = levelDesctiptorCandidates.begin(); it != levelDesctiptorCandidates.end(); it++) + { + for (const QChar& c : *it) + { + if (c.isLetter()) + { + levelDesctiptorCandidates.erase(it); + } + } + } + } + if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormation::ALL; + + QString levelDescriptor = levelDesctiptorCandidates[0]; + + int dotCount = levelDescriptor.count('.'); + + size_t level = dotCount + 1; + + switch (dotCount) + { + case 0: return RigWellPathFormation::LEVEL1; + case 1: return RigWellPathFormation::LEVEL2; + case 2: return RigWellPathFormation::LEVEL3; + default: break; + } + return RigWellPathFormation::ALL; +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 443db152bb..11ac386949 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -29,30 +29,49 @@ struct RigWellPathFormation { - double mdTop; - double mdBase; - QString formationName; - size_t level = 0; -}; + enum FormationLevel + { + GROUP, + LEVEL0, + LEVEL1, + LEVEL2, + LEVEL3, + ALL, + FLUIDS + }; + double mdTop; + double mdBase; + QString formationName; + FormationLevel level; +}; class RigWellPathFormations : public cvf::Object { public: RigWellPathFormations(std::vector formations, const QString& filePath, const QString& key); - void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, std::vector* measuredDepths) const; + void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, + std::vector* measuredDepths) const; - void measuredDepthAndFormationNamesForLevel(size_t level, std::vector* names, std::vector* measuredDepths) const; + void measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, std::vector* names, + std::vector* measuredDepths, bool includeFluids) const; + + RigWellPathFormation::FormationLevel maxFormationLevel() const; QString filePath() const; QString keyInFile() const; size_t formationNamesCount() const; +private: + RigWellPathFormation::FormationLevel detectLevel(QString formationName); + private: QString m_filePath; QString m_keyInFile; - + + RigWellPathFormation::FormationLevel m_maxLevelDetected; + std::vector m_formations; }; From 406c371682c08135986d3cfa04f6308f8c55a982 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 10:46:29 +0100 Subject: [PATCH 05/22] #2227 Well formation: Make level filter dynamic --- .../ProjectDataModel/RimWellLogTrack.cpp | 34 +++- .../RigWellPathFormations.cpp | 149 ++++++++++-------- .../RigWellPathFormations.h | 10 +- 3 files changed, 123 insertions(+), 70 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 21ffad7bd2..58208b9618 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -94,7 +94,9 @@ namespace caf addItem(RigWellPathFormation::LEVEL1, "LEVEL1", "Level 1"); addItem(RigWellPathFormation::LEVEL2, "LEVEL2", "Level 2"); addItem(RigWellPathFormation::LEVEL3, "LEVEL3", "Level 3"); - setDefault(RigWellPathFormation::ALL); + addItem(RigWellPathFormation::LEVEL4, "LEVEL4", "Level 4"); + addItem(RigWellPathFormation::LEVEL5, "LEVEL5", "Level 5"); + addItem(RigWellPathFormation::LEVEL6, "LEVEL6", "Level 6"); } } @@ -349,6 +351,27 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: auto simulationWellBranches = RiaSimWellBranchTools::simulationWellBranches(m_formationSimWellName(), m_formationBranchDetection); options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(simulationWellBranches); } + else if (fieldNeedingOptions == &m_formationLevel) + { + if (m_formationWellPath) + { + const RigWellPathFormations* formations = m_formationWellPath->formationsGeometry(); + if (formations) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(RigWellPathFormation::ALL), + caf::AppEnum::fromText("All"))); + + for (const RigWellPathFormation::FormationLevel& level : formations->formationsLevelsPresent()) + { + size_t index = caf::AppEnum::index(level); + if (index >= caf::AppEnum::size()) continue; + + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiTextFromIndex(index), + caf::AppEnum::fromIndex(index))); + } + } + } + } return options; } @@ -768,8 +791,11 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& else if (m_formationSource() == WELL_PICK_FILTER) { formationGroup->add(&m_formationWellPath); - formationGroup->add(&m_formationLevel); - formationGroup->add(&m_showformationFluids); + if (m_formationWellPath()) + { + formationGroup->add(&m_formationLevel); + formationGroup->add(&m_showformationFluids); + } } uiOrderingForVisibleXRange(uiOrdering); @@ -1106,6 +1132,8 @@ void RimWellLogTrack::setFormationFieldsUiReadOnly(bool readOnly /*= true*/) m_formationCase.uiCapability()->setUiReadOnly(readOnly); m_formationWellPath.uiCapability()->setUiReadOnly(readOnly); m_formationBranchIndex.uiCapability()->setUiReadOnly(readOnly); + m_formationLevel.uiCapability()->setUiReadOnly(readOnly); + m_showformationFluids.uiCapability()->setUiReadOnly(readOnly); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 8f3c65906b..d0ec66879e 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -31,16 +31,12 @@ RigWellPathFormations::RigWellPathFormations(std::vector f m_filePath = filePath; m_keyInFile = key; m_formations = formations; - m_maxLevelDetected = RigWellPathFormation::ALL; for (RigWellPathFormation& formation : m_formations) { RigWellPathFormation::FormationLevel level = detectLevel(formation.formationName); - formation.level = level; - if (level > m_maxLevelDetected) - { - m_maxLevelDetected = level; - } + formation.level = level; + m_formationsLevelsPresent[level] = true; } } @@ -88,90 +84,112 @@ void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDep } } -struct NameAndMD +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +struct LevelAndName { - NameAndMD(RigWellPathFormation::FormationLevel level, QString name, double md) : m_level(level), m_name(name), m_md(md) {} - NameAndMD() {} - RigWellPathFormation::FormationLevel m_level; - QString m_name; - double m_md; + LevelAndName() {} + LevelAndName(RigWellPathFormation::FormationLevel level, QString name) : level(level), name(name) {} + + RigWellPathFormation::FormationLevel level; + QString name; }; +enum PICK_POSITION +{ + TOP, + BASE +}; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void evaluateFormations(const std::vector& formations, const RigWellPathFormation::FormationLevel& maxLevel, + bool includeFluids, const PICK_POSITION& position, + std::map* uniqueListMaker) +{ + QString postFix; + + if (position == TOP) + { + postFix = " Top"; + } + else + { + postFix = " Base"; + } + + for (const RigWellPathFormation& formation : formations) + { + double md; + if (position == TOP) + { + md = formation.mdTop; + } + else + { + md = formation.mdBase; + } + + if (formation.level == RigWellPathFormation::FLUIDS) + { + if (includeFluids) + { + (*uniqueListMaker)[md] = LevelAndName(formation.level, formation.formationName + postFix); + } + continue; + } + + if (formation.level > maxLevel) continue; + + if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.level) + { + (*uniqueListMaker)[md] = LevelAndName(formation.level, formation.formationName + postFix); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, +void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel maxLevel, std::vector* names, std::vector* measuredDepths, bool includeFluids) const { names->clear(); measuredDepths->clear(); - if (level == RigWellPathFormation::ALL) + if (maxLevel == RigWellPathFormation::ALL) { measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); return; } - std::map tempMakeVectorUniqueOnMeasuredDepth; + std::map tempMakeVectorUniqueOnMeasuredDepth; - for (RigWellPathFormation formation : m_formations) - { - if (formation.level == RigWellPathFormation::FLUIDS) - { - if (includeFluids) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = - NameAndMD(formation.level, formation.formationName + " Top", formation.mdTop); - } - else continue; - } + evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); - if (level < formation.level) continue; - - if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdTop) || - tempMakeVectorUniqueOnMeasuredDepth.at(formation.mdTop).m_level < formation.level) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = - NameAndMD(formation.level, formation.formationName + " Top", formation.mdTop); - } - } - - for (RigWellPathFormation formation : m_formations) - { - if (formation.level == RigWellPathFormation::FLUIDS) - { - if (includeFluids) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = - NameAndMD(formation.level, formation.formationName + " Base", formation.mdTop); - } - else continue; - } - - if (level < formation.level) continue; - - if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdBase) || - tempMakeVectorUniqueOnMeasuredDepth.at(formation.mdBase).m_level < formation.level) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdBase] = - NameAndMD(formation.level, formation.formationName + " Base", formation.mdBase); - } - } + evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) { - names->push_back(it->second.m_name); - measuredDepths->push_back(it->second.m_md); + measuredDepths->push_back(it->first); + names->push_back(it->second.name); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RigWellPathFormation::FormationLevel RigWellPathFormations::maxFormationLevel() const +std::vector RigWellPathFormations::formationsLevelsPresent() const { - return m_maxLevelDetected; + std::vector formationLevels; + + for (auto it = m_formationsLevelsPresent.begin(); it != m_formationsLevelsPresent.end(); it++) + { + formationLevels.push_back(it->first); + } + return formationLevels; } //-------------------------------------------------------------------------------------------------- @@ -257,7 +275,7 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString } } } - if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormation::ALL; + if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormation::UNKNOWN; QString levelDescriptor = levelDesctiptorCandidates[0]; @@ -270,7 +288,10 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString case 0: return RigWellPathFormation::LEVEL1; case 1: return RigWellPathFormation::LEVEL2; case 2: return RigWellPathFormation::LEVEL3; + case 3: return RigWellPathFormation::LEVEL4; + case 4: return RigWellPathFormation::LEVEL5; + case 5: return RigWellPathFormation::LEVEL6; default: break; } - return RigWellPathFormation::ALL; + return RigWellPathFormation::UNKNOWN; } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 11ac386949..97268081a9 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -36,8 +36,12 @@ struct RigWellPathFormation LEVEL1, LEVEL2, LEVEL3, + LEVEL4, + LEVEL5, + LEVEL6, ALL, - FLUIDS + FLUIDS, + UNKNOWN }; double mdTop; @@ -57,7 +61,7 @@ public: void measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, std::vector* names, std::vector* measuredDepths, bool includeFluids) const; - RigWellPathFormation::FormationLevel maxFormationLevel() const; + std::vector formationsLevelsPresent() const; QString filePath() const; QString keyInFile() const; @@ -71,7 +75,7 @@ private: QString m_filePath; QString m_keyInFile; - RigWellPathFormation::FormationLevel m_maxLevelDetected; + std::map m_formationsLevelsPresent; std::vector m_formations; }; From c3cd0a650ef021ada6e284f79b978b1cbd8cec36 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 12:59:03 +0100 Subject: [PATCH 06/22] #2227 Well formations: update ui. remove level from RigWellPathFormation --- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 2 +- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 4 +- .../ProjectDataModel/RimWellLogTrack.cpp | 78 +++++++-------- .../ProjectDataModel/RimWellLogTrack.h | 24 +++-- .../RigWellPathFormations.cpp | 99 ++++++++++--------- .../RigWellPathFormations.h | 41 +++----- 6 files changed, 120 insertions(+), 128 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 82d540bfe8..71561771dc 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -990,7 +990,7 @@ void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& { RimWellLogTrack* track = m_wellLogPlot->trackByIndex(0); - track->uiOrderingForShowFormationNamesAndCase(uiOrdering); + track->uiOrderingForFormations(uiOrdering); caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup("Legend and Axis"); legendAndAxisGroup->setCollapsedByDefault(true); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index ffd5e8b502..76a9930686 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -773,13 +773,11 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps"); timeStepsGroup->add(&m_selectedTimeSteps); - //uiOrdering.add(&m_showPlotTitle); - if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0) { RimWellLogTrack* track = m_wellLogPlot->trackByIndex(0); - track->uiOrderingForShowFormationNamesAndCase(uiOrdering); + track->uiOrderingForFormations(uiOrdering); caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup("Legend and Axis"); legendAndAxisGroup->setCollapsedByDefault(true); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 58208b9618..bd62c20c03 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -80,23 +80,26 @@ namespace caf void AppEnum< RimWellLogTrack::FormationSource >::setUp() { addItem(RimWellLogTrack::CASE, "CASE", "Case"); - addItem(RimWellLogTrack::WELL_PICK, "WELL_PICK", "Well Pick"); - addItem(RimWellLogTrack::WELL_PICK_FILTER, "WELL_PICK_FILTER", "Well Pick Filter"); + addItem(RimWellLogTrack::WELL_PICK_FILTER, "WELL_PICK_FILTER", "Well Path"); setDefault(RimWellLogTrack::CASE); } template<> - void AppEnum::setUp() + void AppEnum::setUp() { - addItem(RigWellPathFormation::ALL, "ALL", "All"); - addItem(RigWellPathFormation::GROUP, "GROUP", "Group"); - addItem(RigWellPathFormation::LEVEL0, "LEVEL0", "Main"); - addItem(RigWellPathFormation::LEVEL1, "LEVEL1", "Level 1"); - addItem(RigWellPathFormation::LEVEL2, "LEVEL2", "Level 2"); - addItem(RigWellPathFormation::LEVEL3, "LEVEL3", "Level 3"); - addItem(RigWellPathFormation::LEVEL4, "LEVEL4", "Level 4"); - addItem(RigWellPathFormation::LEVEL5, "LEVEL5", "Level 5"); - addItem(RigWellPathFormation::LEVEL6, "LEVEL6", "Level 6"); + addItem(RigWellPathFormations::ALL, "ALL", "All"); + addItem(RigWellPathFormations::GROUP, "GROUP", "Formation Group"); + addItem(RigWellPathFormations::LEVEL0, "LEVEL0", "Formation"); + addItem(RigWellPathFormations::LEVEL1, "LEVEL1", "Formation 1"); + addItem(RigWellPathFormations::LEVEL2, "LEVEL2", "Formation 2"); + addItem(RigWellPathFormations::LEVEL3, "LEVEL3", "Formation 3"); + addItem(RigWellPathFormations::LEVEL4, "LEVEL4", "Formation 4"); + addItem(RigWellPathFormations::LEVEL5, "LEVEL5", "Formation 5"); + addItem(RigWellPathFormations::LEVEL6, "LEVEL6", "Formation 6"); + addItem(RigWellPathFormations::LEVEL7, "LEVEL7", "Formation 7"); + addItem(RigWellPathFormations::LEVEL8, "LEVEL8", "Formation 8"); + addItem(RigWellPathFormations::LEVEL9, "LEVEL9", "Formation 9"); + addItem(RigWellPathFormations::LEVEL10, "LEVEL10", "Formation 10"); } } @@ -124,7 +127,7 @@ RimWellLogTrack::RimWellLogTrack() CAF_PDM_InitField(&m_isLogarithmicScaleEnabled, "LogarithmicScaleX", false, "Logarithmic Scale", "", "", ""); - CAF_PDM_InitField(&m_showFormations, "ShowFormations", false, "Show Formations", "", "", ""); + CAF_PDM_InitField(&m_showFormations, "ShowFormations", false, "Show", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_formationSource, "FormationSource", "Formation Source", "", "", ""); @@ -141,7 +144,7 @@ RimWellLogTrack::RimWellLogTrack() CAF_PDM_InitFieldNoDefault(&m_formationCase, "FormationCase", "Formation Case", "", "", ""); m_formationCase.uiCapability()->setUiTreeChildrenHidden(true); - CAF_PDM_InitFieldNoDefault(&m_formationLevel, "FormationLevel", "Formation Level", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_formationLevel, "FormationLevel", "Well Pick Filter", "", "", ""); CAF_PDM_InitField(&m_showformationFluids, "ShowFormationFluids", false, "Show Fluids", "", "", ""); } @@ -329,7 +332,7 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: { RimTools::wellPathOptionItems(&options); } - else if(m_formationSource == WELL_PICK || m_formationSource == WELL_PICK_FILTER) + else if(m_formationSource == WELL_PICK_FILTER) { RimTools::wellPathWithFormationsOptionItems(&options); } @@ -358,16 +361,18 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: const RigWellPathFormations* formations = m_formationWellPath->formationsGeometry(); if (formations) { - options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(RigWellPathFormation::ALL), - caf::AppEnum::fromText("All"))); + using FormationLevelEnum = caf::AppEnum; - for (const RigWellPathFormation::FormationLevel& level : formations->formationsLevelsPresent()) + options.push_back(caf::PdmOptionItemInfo(FormationLevelEnum::uiText(RigWellPathFormations::ALL), + FormationLevelEnum::fromText("All"))); + + for (const RigWellPathFormations::FormationLevel& level : formations->formationsLevelsPresent()) { - size_t index = caf::AppEnum::index(level); - if (index >= caf::AppEnum::size()) continue; + size_t index = FormationLevelEnum::index(level); + if (index >= FormationLevelEnum::size()) continue; - options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiTextFromIndex(index), - caf::AppEnum::fromIndex(index))); + options.push_back(caf::PdmOptionItemInfo(FormationLevelEnum::uiTextFromIndex(index), + FormationLevelEnum::fromIndex(index))); } } } @@ -784,10 +789,6 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& m_formationBranchIndex); } } - else if (m_formationSource() == WELL_PICK) - { - formationGroup->add(&m_formationWellPath); - } else if (m_formationSource() == WELL_PICK_FILTER) { formationGroup->add(&m_formationWellPath); @@ -924,7 +925,7 @@ std::vector RimWellLogTrack::curvesVector() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::uiOrderingForShowFormationNamesAndCase(caf::PdmUiOrdering& uiOrdering) +void RimWellLogTrack::uiOrderingForFormations(caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup("Zonation/Formation Names"); formationGroup->setCollapsedByDefault(true); @@ -934,6 +935,15 @@ void RimWellLogTrack::uiOrderingForShowFormationNamesAndCase(caf::PdmUiOrdering& { formationGroup->add(&m_formationCase); } + if (m_formationSource == WELL_PICK_FILTER) + { + formationGroup->add(&m_formationWellPath); + if (m_formationWellPath()) + { + formationGroup->add(&m_formationLevel); + formationGroup->add(&m_showformationFluids); + } + } } //-------------------------------------------------------------------------------------------------- @@ -1217,20 +1227,6 @@ void RimWellLogTrack::updateFormationNamesOnPlot() m_annotationTool->attachFormationNames(this->viewer(), formationNamesToPlot, yValues); } - else if (m_formationSource() == WELL_PICK) - { - if (m_formationWellPath == nullptr) return; - if (plot->depthType() != RimWellLogPlot::MEASURED_DEPTH) return; - - std::vector yValues; - - const RigWellPathFormations* formations = m_formationWellPath->formationsGeometry(); - if (!formations) return; - - formations->measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(&formationNamesToPlot, &yValues); - - m_annotationTool->attachWellPicks(this->viewer(), formationNamesToPlot, yValues); - } else if (m_formationSource() == WELL_PICK_FILTER) { if (m_formationWellPath == nullptr) return; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 2ae5254191..c8aac07345 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -21,6 +21,8 @@ #include "RimWellLogPlot.h" +#include "RigWellPathFormations.h" + #include "cafPdmObject.h" #include "cafPdmField.h" #include "cafPdmChildArrayField.h" @@ -67,7 +69,7 @@ public: virtual ~RimWellLogTrack(); enum TrajectoryType { WELL_PATH, SIMULATION_WELL }; - enum FormationSource { CASE, WELL_PICK }; + enum FormationSource { CASE, WELL_PICK_FILTER }; void setDescription(const QString& description); bool isVisible(); @@ -114,7 +116,7 @@ public: QString description(); std::vector curvesVector(); - void uiOrderingForShowFormationNamesAndCase(caf::PdmUiOrdering& uiOrdering); + void uiOrderingForFormations(caf::PdmUiOrdering& uiOrdering); void uiOrderingForVisibleXRange(caf::PdmUiOrdering& uiOrdering); private: @@ -163,15 +165,17 @@ private: caf::PdmField m_isAutoScaleXEnabled; caf::PdmField m_isLogarithmicScaleEnabled; - caf::PdmField m_showFormations; - caf::PdmField > m_formationSource; - caf::PdmPtrField m_formationCase; - caf::PdmField > m_formationTrajectoryType; - caf::PdmPtrField m_formationWellPath; + caf::PdmField m_showFormations; + caf::PdmField > m_formationSource; + caf::PdmPtrField m_formationCase; + caf::PdmField > m_formationTrajectoryType; + caf::PdmPtrField m_formationWellPath; + caf::PdmField m_formationSimWellName; + caf::PdmField m_formationBranchIndex; + caf::PdmField> m_formationLevel; + caf::PdmField m_showformationFluids; - caf::PdmField m_formationSimWellName; - caf::PdmField m_formationBranchIndex; - caf::PdmField m_formationBranchDetection; + caf::PdmField m_formationBranchDetection; QPointer m_wellLogTrackPlotWidget; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index d0ec66879e..5be9a0b833 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -25,18 +25,18 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigWellPathFormations::RigWellPathFormations(std::vector formations, const QString& filePath, +RigWellPathFormations::RigWellPathFormations(const std::vector& formations, const QString& filePath, const QString& key) { m_filePath = filePath; m_keyInFile = key; - m_formations = formations; - for (RigWellPathFormation& formation : m_formations) + for (const RigWellPathFormation& formation : formations) { - RigWellPathFormation::FormationLevel level = detectLevel(formation.formationName); - formation.level = level; - m_formationsLevelsPresent[level] = true; + FormationLevel level = detectLevel(formation.formationName); + m_formationsLevelsPresent[level] = true; + + m_formations.push_back(std::pair(formation, level)); } } @@ -63,23 +63,23 @@ void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDep std::map tempMakeVectorUniqueOnMeasuredDepth; - for (RigWellPathFormation formation : m_formations) + for (const std::pair& formation : m_formations) { - if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdTop)) + if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdTop)) { - measuredDepths->push_back(formation.mdTop); - names->push_back(formation.formationName + " Top"); - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = true; + measuredDepths->push_back(formation.first.mdTop); + names->push_back(formation.first.formationName + " Top"); + tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdTop] = true; } } - for (RigWellPathFormation formation : m_formations) + for (const std::pair& formation : m_formations) { - if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdBase)) + if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdBase)) { - measuredDepths->push_back(formation.mdBase); - names->push_back(formation.formationName + " Base"); - tempMakeVectorUniqueOnMeasuredDepth[formation.mdBase] = true; + measuredDepths->push_back(formation.first.mdBase); + names->push_back(formation.first.formationName + " Base"); + tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdBase] = true; } } } @@ -90,10 +90,10 @@ void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDep struct LevelAndName { LevelAndName() {} - LevelAndName(RigWellPathFormation::FormationLevel level, QString name) : level(level), name(name) {} + LevelAndName(RigWellPathFormations::FormationLevel level, QString name) : level(level), name(name) {} - RigWellPathFormation::FormationLevel level; - QString name; + RigWellPathFormations::FormationLevel level; + QString name; }; enum PICK_POSITION @@ -104,9 +104,10 @@ enum PICK_POSITION //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void evaluateFormations(const std::vector& formations, const RigWellPathFormation::FormationLevel& maxLevel, - bool includeFluids, const PICK_POSITION& position, - std::map* uniqueListMaker) +void evaluateFormations(const std::vector>& formations, + const RigWellPathFormations::FormationLevel& maxLevel, + bool includeFluids, const PICK_POSITION& position, + std::map* uniqueListMaker) { QString postFix; @@ -119,32 +120,32 @@ void evaluateFormations(const std::vector& formations, con postFix = " Base"; } - for (const RigWellPathFormation& formation : formations) + for (const std::pair& formation : formations) { double md; if (position == TOP) { - md = formation.mdTop; + md = formation.first.mdTop; } else { - md = formation.mdBase; + md = formation.first.mdBase; } - if (formation.level == RigWellPathFormation::FLUIDS) + if (formation.second == RigWellPathFormations::FLUIDS) { if (includeFluids) { - (*uniqueListMaker)[md] = LevelAndName(formation.level, formation.formationName + postFix); + (*uniqueListMaker)[md] = LevelAndName(formation.second, formation.first.formationName + postFix); } continue; } - if (formation.level > maxLevel) continue; + if (formation.second > maxLevel) continue; - if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.level) + if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.second) { - (*uniqueListMaker)[md] = LevelAndName(formation.level, formation.formationName + postFix); + (*uniqueListMaker)[md] = LevelAndName(formation.second, formation.first.formationName + postFix); } } } @@ -152,14 +153,14 @@ void evaluateFormations(const std::vector& formations, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel maxLevel, +void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(FormationLevel maxLevel, std::vector* names, std::vector* measuredDepths, bool includeFluids) const { names->clear(); measuredDepths->clear(); - if (maxLevel == RigWellPathFormation::ALL) + if (maxLevel == RigWellPathFormations::ALL) { measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); return; @@ -181,9 +182,9 @@ void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellPathFormations::formationsLevelsPresent() const +std::vector RigWellPathFormations::formationsLevelsPresent() const { - std::vector formationLevels; + std::vector formationLevels; for (auto it = m_formationsLevelsPresent.begin(); it != m_formationsLevelsPresent.end(); it++) { @@ -219,13 +220,13 @@ size_t RigWellPathFormations::formationNamesCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString formationName) +RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString formationName) { formationName = formationName.trimmed(); - if (formationName == "OIL" || formationName == "GAS") + if (formationName == "OIL" || formationName == "GAS" || formationName == "WATER") { - return RigWellPathFormation::FLUIDS; + return RigWellPathFormations::FLUIDS; } bool isGroupName = true; @@ -239,7 +240,7 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString } if (isGroupName) { - return RigWellPathFormation::GROUP; + return RigWellPathFormations::GROUP; } QStringList formationNameSplitted = formationName.split(" "); @@ -259,7 +260,7 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString } if (levelDesctiptorCandidates.empty()) { - return RigWellPathFormation::LEVEL0; + return RigWellPathFormations::LEVEL0; } if (levelDesctiptorCandidates.size() > 1) @@ -275,7 +276,7 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString } } } - if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormation::UNKNOWN; + if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormations::UNKNOWN; QString levelDescriptor = levelDesctiptorCandidates[0]; @@ -285,13 +286,17 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString switch (dotCount) { - case 0: return RigWellPathFormation::LEVEL1; - case 1: return RigWellPathFormation::LEVEL2; - case 2: return RigWellPathFormation::LEVEL3; - case 3: return RigWellPathFormation::LEVEL4; - case 4: return RigWellPathFormation::LEVEL5; - case 5: return RigWellPathFormation::LEVEL6; + case 0: return RigWellPathFormations::LEVEL1; + case 1: return RigWellPathFormations::LEVEL2; + case 2: return RigWellPathFormations::LEVEL3; + case 3: return RigWellPathFormations::LEVEL4; + case 4: return RigWellPathFormations::LEVEL5; + case 5: return RigWellPathFormations::LEVEL6; + case 6: return RigWellPathFormations::LEVEL7; + case 7: return RigWellPathFormations::LEVEL8; + case 8: return RigWellPathFormations::LEVEL9; + case 9: return RigWellPathFormations::LEVEL10; default: break; } - return RigWellPathFormation::UNKNOWN; + return RigWellPathFormations::UNKNOWN; } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 97268081a9..5d550e1d8f 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -29,53 +29,42 @@ struct RigWellPathFormation { - enum FormationLevel - { - GROUP, - LEVEL0, - LEVEL1, - LEVEL2, - LEVEL3, - LEVEL4, - LEVEL5, - LEVEL6, - ALL, - FLUIDS, - UNKNOWN - }; - - double mdTop; - double mdBase; - QString formationName; - FormationLevel level; + double mdTop; + double mdBase; + QString formationName; }; class RigWellPathFormations : public cvf::Object { public: - RigWellPathFormations(std::vector formations, const QString& filePath, const QString& key); + RigWellPathFormations(const std::vector& formations, const QString& filePath, const QString& key); void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, std::vector* measuredDepths) const; - void measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, std::vector* names, + enum FormationLevel + { + GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, FLUIDS, UNKNOWN + }; + + void measuredDepthAndFormationNamesUpToLevel(FormationLevel level, std::vector* names, std::vector* measuredDepths, bool includeFluids) const; - std::vector formationsLevelsPresent() const; + std::vector formationsLevelsPresent() const; QString filePath() const; QString keyInFile() const; - size_t formationNamesCount() const; + size_t formationNamesCount() const; private: - RigWellPathFormation::FormationLevel detectLevel(QString formationName); + FormationLevel detectLevel(QString formationName); private: QString m_filePath; QString m_keyInFile; - std::map m_formationsLevelsPresent; + std::map m_formationsLevelsPresent; - std::vector m_formations; + std::vector> m_formations; }; From 864b9466d56a920e962efe3de67380c518012a01 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 13:51:01 +0100 Subject: [PATCH 07/22] #2227 Well formations: Handle "+" in formation name file input --- .../ReservoirDataModel/RigWellPathFormations.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 5be9a0b833..3fc96aeb78 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -280,6 +280,12 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString QString levelDescriptor = levelDesctiptorCandidates[0]; + QStringList joinedLevel = levelDescriptor.split('+'); + if ( joinedLevel.size() > 1 ) + { + levelDescriptor = joinedLevel[0]; + } + int dotCount = levelDescriptor.count('.'); size_t level = dotCount + 1; From 03b03cd438ba4f86e030fd2a0bcaaf0a7831a160 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 13:58:58 +0100 Subject: [PATCH 08/22] Update plots on well pick import --- .../RicWellPathFormationsImportFileFeature.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp index da7c3b3ac7..71aeba0909 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" +#include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" #include "RimWellPath.h" @@ -65,6 +66,11 @@ void RicWellPathFormationsImportFileFeature::onActionTriggered(bool isChecked) if (project) { project->createDisplayModelAndRedrawAllViews(); + if (project->mainPlotCollection()) + { + project->mainPlotCollection->updatePlotsWithFormations(); + } + RimOilField* oilField = project->activeOilField(); if (!oilField) return; From fb876f8fdcbcf269755c0392d39ea410ce3a9a06 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 15:12:06 +0100 Subject: [PATCH 09/22] #2227 Well formations: Remove fluid annotation duplicates --- .../ProjectDataModel/RimWellLogTrack.cpp | 9 +++- .../RigWellPathFormations.cpp | 52 +++++++++++++++---- .../RigWellPathFormations.h | 2 +- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index bd62c20c03..ea2b619dc0 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -87,6 +87,7 @@ namespace caf template<> void AppEnum::setUp() { + addItem(RigWellPathFormations::NONE, "NONE", "None"); addItem(RigWellPathFormations::ALL, "ALL", "All"); addItem(RigWellPathFormations::GROUP, "GROUP", "Formation Group"); addItem(RigWellPathFormations::LEVEL0, "LEVEL0", "Formation"); @@ -100,6 +101,7 @@ namespace caf addItem(RigWellPathFormations::LEVEL8, "LEVEL8", "Formation 8"); addItem(RigWellPathFormations::LEVEL9, "LEVEL9", "Formation 9"); addItem(RigWellPathFormations::LEVEL10, "LEVEL10", "Formation 10"); + setDefault(RigWellPathFormations::ALL); } } @@ -129,7 +131,7 @@ RimWellLogTrack::RimWellLogTrack() CAF_PDM_InitField(&m_showFormations, "ShowFormations", false, "Show", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_formationSource, "FormationSource", "Formation Source", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_formationSource, "FormationSource", "Source", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_formationTrajectoryType, "FormationTrajectoryType", "Trajectory", "", "", ""); @@ -362,9 +364,12 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: if (formations) { using FormationLevelEnum = caf::AppEnum; + + options.push_back(caf::PdmOptionItemInfo(FormationLevelEnum::uiText(RigWellPathFormations::NONE), + RigWellPathFormations::NONE)); options.push_back(caf::PdmOptionItemInfo(FormationLevelEnum::uiText(RigWellPathFormations::ALL), - FormationLevelEnum::fromText("All"))); + RigWellPathFormations::ALL)); for (const RigWellPathFormations::FormationLevel& level : formations->formationsLevelsPresent()) { diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 3fc96aeb78..2732d79390 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -132,7 +132,7 @@ void evaluateFormations(const std::vector>& formations, + std::map* uniqueListMaker) +{ + for (const std::pair& formation : formations) + { + if (formation.second == RigWellPathFormations::FLUID) + { + (*uniqueListMaker)[formation.first.mdBase] = + LevelAndName(formation.second, formation.first.formationName + " Base"); + } + } + + for (const std::pair& formation : formations) + { + if (formation.second == RigWellPathFormations::FLUID) + { + (*uniqueListMaker)[formation.first.mdTop] = + LevelAndName(formation.second, formation.first.formationName + " Top"); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -160,17 +182,29 @@ void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(FormationLev names->clear(); measuredDepths->clear(); - if (maxLevel == RigWellPathFormations::ALL) + std::map tempMakeVectorUniqueOnMeasuredDepth; + + if (maxLevel == RigWellPathFormations::NONE) + { + if (includeFluids) + { + evaluateFluids(m_formations, &tempMakeVectorUniqueOnMeasuredDepth); + } + else + { + return; + } + } + else if (maxLevel == RigWellPathFormations::ALL) { measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); return; } - - std::map tempMakeVectorUniqueOnMeasuredDepth; - - evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); - - evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); + else + { + evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); + evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); + } for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) { @@ -226,7 +260,7 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString if (formationName == "OIL" || formationName == "GAS" || formationName == "WATER") { - return RigWellPathFormations::FLUIDS; + return RigWellPathFormations::FLUID; } bool isGroupName = true; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 5d550e1d8f..2b9fb2776f 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -44,7 +44,7 @@ public: enum FormationLevel { - GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, FLUIDS, UNKNOWN + GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, FLUID, UNKNOWN, NONE }; void measuredDepthAndFormationNamesUpToLevel(FormationLevel level, std::vector* names, From 3e5209d1a7f58af5fc7f6aa6bb95ef209a4c56e2 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 16:07:15 +0100 Subject: [PATCH 10/22] #2227 Well formations: Remove fluids from Level type --- .../RigWellPathFormations.cpp | 126 ++++++++++-------- .../RigWellPathFormations.h | 10 +- 2 files changed, 75 insertions(+), 61 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 2732d79390..6f33c1b5cb 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -33,10 +33,17 @@ RigWellPathFormations::RigWellPathFormations(const std::vector(formation, level)); + m_formations.push_back(std::pair(formation, level)); + } } } @@ -58,9 +65,6 @@ struct MeasuredDepthComp void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, std::vector* measuredDepths) const { - names->clear(); - measuredDepths->clear(); - std::map tempMakeVectorUniqueOnMeasuredDepth; for (const std::pair& formation : m_formations) @@ -96,18 +100,21 @@ struct LevelAndName QString name; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- enum PICK_POSITION { TOP, BASE }; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void evaluateFormations(const std::vector>& formations, - const RigWellPathFormations::FormationLevel& maxLevel, - bool includeFluids, const PICK_POSITION& position, - std::map* uniqueListMaker) +void evaluateFormationsForOnePosition(const std::vector>& formations, + const RigWellPathFormations::FormationLevel& maxLevel, const PICK_POSITION& position, + std::map* uniqueListMaker) { QString postFix; @@ -132,15 +139,6 @@ void evaluateFormations(const std::vector maxLevel) continue; if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.second) @@ -150,25 +148,42 @@ void evaluateFormations(const std::vector>& formations, - std::map* uniqueListMaker) +void evaluateFormations(const std::vector>& formations, + const RigWellPathFormations::FormationLevel& maxLevel, + std::vector* names, std::vector* measuredDepths) { - for (const std::pair& formation : formations) + std::map tempMakeVectorUniqueOnMeasuredDepth; + + evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); + evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); + + for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) { - if (formation.second == RigWellPathFormations::FLUID) - { - (*uniqueListMaker)[formation.first.mdBase] = - LevelAndName(formation.second, formation.first.formationName + " Base"); - } + measuredDepths->push_back(it->first); + names->push_back(it->second.name); + } +} + +void evaluateFluids(const std::vector& fluidFormations, + std::vector* names, std::vector* measuredDepths) +{ + + std::map uniqueListMaker; + + for (const RigWellPathFormation& formation : fluidFormations) + { + uniqueListMaker[formation.mdBase] = formation.formationName + " Base"; } - for (const std::pair& formation : formations) + for (const RigWellPathFormation& formation : fluidFormations) { - if (formation.second == RigWellPathFormations::FLUID) - { - (*uniqueListMaker)[formation.first.mdTop] = - LevelAndName(formation.second, formation.first.formationName + " Top"); - } + uniqueListMaker[formation.mdTop] = formation.formationName + " Top"; + } + + for (auto it = uniqueListMaker.begin(); it != uniqueListMaker.end(); it++) + { + measuredDepths->push_back(it->first); + names->push_back(it->second); } } @@ -182,34 +197,22 @@ void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(FormationLev names->clear(); measuredDepths->clear(); - std::map tempMakeVectorUniqueOnMeasuredDepth; + if (includeFluids) + { + evaluateFluids(m_fluids, names, measuredDepths); + } if (maxLevel == RigWellPathFormations::NONE) { - if (includeFluids) - { - evaluateFluids(m_formations, &tempMakeVectorUniqueOnMeasuredDepth); - } - else - { - return; - } + return; } else if (maxLevel == RigWellPathFormations::ALL) { measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); - return; } else { - evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); - evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); - } - - for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) - { - measuredDepths->push_back(it->first); - names->push_back(it->second.name); + evaluateFormations(m_formations, maxLevel, names, measuredDepths); } } @@ -248,7 +251,21 @@ QString RigWellPathFormations::keyInFile() const //-------------------------------------------------------------------------------------------------- size_t RigWellPathFormations::formationNamesCount() const { - return m_formations.size(); + return m_formations.size() + m_fluids.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellPathFormations::isFluid(QString formationName) +{ + formationName = formationName.trimmed(); + + if (formationName == "OIL" || formationName == "GAS" || formationName == "WATER") + { + return true; + } + return false; } //-------------------------------------------------------------------------------------------------- @@ -258,11 +275,6 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString { formationName = formationName.trimmed(); - if (formationName == "OIL" || formationName == "GAS" || formationName == "WATER") - { - return RigWellPathFormations::FLUID; - } - bool isGroupName = true; for (QChar c : formationName) { diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 2b9fb2776f..6d1909be69 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -39,12 +39,9 @@ class RigWellPathFormations : public cvf::Object public: RigWellPathFormations(const std::vector& formations, const QString& filePath, const QString& key); - void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, - std::vector* measuredDepths) const; - enum FormationLevel { - GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, FLUID, UNKNOWN, NONE + GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, UNKNOWN, NONE }; void measuredDepthAndFormationNamesUpToLevel(FormationLevel level, std::vector* names, @@ -58,6 +55,10 @@ public: size_t formationNamesCount() const; private: + void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, + std::vector* measuredDepths) const; + + bool isFluid(QString formationName); FormationLevel detectLevel(QString formationName); private: @@ -67,4 +68,5 @@ private: std::map m_formationsLevelsPresent; std::vector> m_formations; + std::vector m_fluids; }; From 01ae19ebbc654abc61a19cbfbc0b6bd15368912a Mon Sep 17 00:00:00 2001 From: sigurdp Date: Mon, 11 Dec 2017 16:00:56 +0100 Subject: [PATCH 11/22] #2235 RelPerm/PVT Plot: Added unit labels to relevant axes --- .../Application/Tools/RiaEclipseUnitTools.cpp | 16 ++ .../Application/Tools/RiaEclipseUnitTools.h | 2 + .../RigFlowDiagSolverInterface.cpp | 60 ++++++-- .../RigFlowDiagSolverInterface.h | 6 +- .../UserInterface/RiuPvtPlotPanel.cpp | 143 +++++++++++++----- .../UserInterface/RiuPvtPlotPanel.h | 7 +- .../UserInterface/RiuPvtPlotUpdater.cpp | 2 +- .../RiuRelativePermeabilityPlotPanel.cpp | 25 +-- .../RiuRelativePermeabilityPlotPanel.h | 6 +- .../RiuRelativePermeabilityPlotUpdater.cpp | 2 +- 10 files changed, 198 insertions(+), 71 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp index ce38af51c0..315a739039 100644 --- a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp +++ b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp @@ -108,3 +108,19 @@ double RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents(UnitSystem return oilEquivalentGasRate; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaEclipseUnitTools::unitStringPressure(UnitSystem unitSystem) +{ + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return "barsa"; + case RiaEclipseUnitTools::UNITS_FIELD: return "psia"; + case RiaEclipseUnitTools::UNITS_LAB: return "atma"; + case RiaEclipseUnitTools::UNITS_UNKNOWN: return ""; + default: return ""; + } +} + diff --git a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h index 9eaf37103e..0f43e97a7d 100644 --- a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h +++ b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h @@ -49,5 +49,7 @@ public: static RiaDefines::DepthUnitType depthUnit(UnitSystem unit); static double convertSurfaceGasFlowRateToOilEquivalents(UnitSystem, double eclGasFlowRate); + + static QString unitStringPressure(UnitSystem unitSystem); }; diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index fcb32c328a..58b74594b8 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -706,22 +706,56 @@ std::vector RigFlowDiagSolverInterface::ca // Requesting FVF or Viscosity - const Opm::ECLPVT::RawCurve rawCurveType = (pvtCurveType == PvtCurveType::PVT_CT_FVF) ? Opm::ECLPVT::RawCurve::FVF : Opm::ECLPVT::RawCurve::Viscosity; - - const std::array queryPhaseArr = { Opm::ECLPhaseIndex::Vapour, Opm::ECLPhaseIndex::Liquid }; - const std::array mapToPhaseArr = { PvtCurve::GAS, PvtCurve::OIL }; - - for (size_t i = 0; i < queryPhaseArr.size(); i++) + if (pvtCurveType == PvtCurveType::PVT_CT_FVF) { - const Opm::ECLPhaseIndex queryPhaseIndex = queryPhaseArr[i]; - const PvtCurve::Phase mapToPhase = mapToPhaseArr[i]; - - std::vector graphArr = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(rawCurveType, queryPhaseIndex, static_cast(activeCellIndex)); - for (Opm::ECLPVT::PVTGraph srcGraph : graphArr) + // Bo { - if (srcGraph.press.size() > 0) + std::vector graphArr = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::FVF, Opm::ECLPhaseIndex::Liquid, static_cast(activeCellIndex)); + for (Opm::ECLPVT::PVTGraph srcGraph : graphArr) { - retCurveArr.push_back({ mapToPhase, srcGraph.press, srcGraph.value}); + if (srcGraph.press.size() > 0) + { + retCurveArr.push_back({ PvtCurve::Bo, PvtCurve::OIL, srcGraph.press, srcGraph.value }); + } + } + } + + // Bg + { + std::vector graphArr = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::FVF, Opm::ECLPhaseIndex::Vapour, static_cast(activeCellIndex)); + for (Opm::ECLPVT::PVTGraph srcGraph : graphArr) + { + if (srcGraph.press.size() > 0) + { + retCurveArr.push_back({ PvtCurve::Bg, PvtCurve::GAS, srcGraph.press, srcGraph.value }); + } + } + } + } + + else if (pvtCurveType == PvtCurveType::PVT_CT_VISCOSITY) + { + // Visc_o / mu_o + { + std::vector graphArr = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::Viscosity, Opm::ECLPhaseIndex::Liquid, static_cast(activeCellIndex)); + for (Opm::ECLPVT::PVTGraph srcGraph : graphArr) + { + if (srcGraph.press.size() > 0) + { + retCurveArr.push_back({ PvtCurve::Visc_o, PvtCurve::OIL, srcGraph.press, srcGraph.value }); + } + } + } + + // Visc_g / mu_g + { + std::vector graphArr = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::Viscosity, Opm::ECLPhaseIndex::Vapour, static_cast(activeCellIndex)); + for (Opm::ECLPVT::PVTGraph srcGraph : graphArr) + { + if (srcGraph.press.size() > 0) + { + retCurveArr.push_back({ PvtCurve::Visc_g, PvtCurve::GAS, srcGraph.press, srcGraph.value }); + } } } } diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h index f2c9dc15e9..f1bbd6d964 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h @@ -83,7 +83,7 @@ public: Ident ident; std::string name; EpsMode epsMode; - std::vector xVals; + std::vector saturationVals; std::vector yVals; }; @@ -96,9 +96,11 @@ public: struct PvtCurve { enum Phase { OIL, GAS }; + enum Ident { Unknown, Bo, Bg, Visc_o, Visc_g }; + Ident ident; Phase phase; - std::vector xVals; + std::vector pressureVals; std::vector yVals; }; diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp index 59bb7f198d..78d97c9b0d 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp @@ -68,6 +68,7 @@ public: //-------------------------------------------------------------------------------------------------- RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent) : QWidget(parent), + m_unitSystem(RiaEclipseUnitTools::UNITS_UNKNOWN), m_pressure(HUGE_VAL), m_plotUpdater(new RiuPvtPlotUpdater(this)) { @@ -132,10 +133,11 @@ void RiuPvtPlotPanel::setPlotDefaults(QwtPlot* plot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotPanel::setPlotData(const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, double pressure) +void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, double pressure) { //cvf::Trace::show("RiuPvtPlotPanel::setPlotData()"); + m_unitSystem = unitSystem; m_allFvfCurvesArr = fvfCurveArr; m_allViscosityCurvesArr = viscosityCurveArr; m_fvfDynProps = fvfDynProps; @@ -157,6 +159,7 @@ void RiuPvtPlotPanel::clearPlot() return; } + m_unitSystem = RiaEclipseUnitTools::UNITS_UNKNOWN; m_allFvfCurvesArr.clear(); m_allViscosityCurvesArr.clear(); m_fvfDynProps = FvfDynProps(); @@ -179,64 +182,86 @@ RiuPvtPlotUpdater* RiuPvtPlotPanel::plotUpdater() //-------------------------------------------------------------------------------------------------- void RiuPvtPlotPanel::plotUiSelectedCurves() { - std::vector selectedFvfCurves; - std::vector selectedViscosityCurves; // Determine which curves (phase) to actually plot based on selection in GUI const int currComboIdx = m_phaseComboBox->currentIndex(); const RigFlowDiagSolverInterface::PvtCurve::Phase phaseToPlot = static_cast(m_phaseComboBox->itemData(currComboIdx).toInt()); - for (RigFlowDiagSolverInterface::PvtCurve curve : m_allFvfCurvesArr) - { - if (curve.phase == phaseToPlot) - { - selectedFvfCurves.push_back(curve); - } - } - - for (RigFlowDiagSolverInterface::PvtCurve curve : m_allViscosityCurvesArr) - { - if (curve.phase == phaseToPlot) - { - selectedViscosityCurves.push_back(curve); - } - } - QString phaseString = ""; - double fvfPointMarkerYValue = HUGE_VAL; - double viscosityPointMarkerYValue = HUGE_VAL; if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::GAS) { phaseString = "Gas "; - fvfPointMarkerYValue = m_fvfDynProps.bg; - viscosityPointMarkerYValue = m_viscosityDynProps.mu_g; } else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::OIL) { phaseString = "Oil "; - fvfPointMarkerYValue = m_fvfDynProps.bo; - viscosityPointMarkerYValue = m_viscosityDynProps.mu_o; } + // FVF plot { - const QString plotTitle = phaseString + "Formation Volume Factor"; - const QString yAxisTitle = phaseString + "Formation Volume Factor"; - plotCurvesInQwt(selectedFvfCurves, m_pressure, fvfPointMarkerYValue, plotTitle, yAxisTitle, m_fvfPlot, &m_fvfPlotMarkers); - } - - { - const QString plotTitle = phaseString + "Viscosity"; - const QString yAxisTitle = phaseString + "Viscosity"; - plotCurvesInQwt(selectedViscosityCurves, m_pressure, viscosityPointMarkerYValue, plotTitle, yAxisTitle, m_viscosityPlot, &m_viscosityPlotMarkers); - } + RigFlowDiagSolverInterface::PvtCurve::Ident curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Unknown; + double fvfPointMarkerYValue = HUGE_VAL; + if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::GAS) + { + curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Bg; + fvfPointMarkerYValue = m_fvfDynProps.bg; + } + else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::OIL) + { + curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Bo; + fvfPointMarkerYValue = m_fvfDynProps.bo; + } + + std::vector selectedFvfCurves; + for (RigFlowDiagSolverInterface::PvtCurve curve : m_allFvfCurvesArr) + { + if (curve.ident == curveIdentToPlot) + { + selectedFvfCurves.push_back(curve); + } + } + + const QString plotTitle = QString("%1 Formation Volume Factor").arg(phaseString); + const QString yAxisTitle = QString("%1 Formation Volume Factor [%2]").arg(phaseString).arg(unitStringFromCurveIdent(m_unitSystem, curveIdentToPlot)); + plotCurvesInQwt(m_unitSystem, selectedFvfCurves, m_pressure, fvfPointMarkerYValue, plotTitle, yAxisTitle, m_fvfPlot, &m_fvfPlotMarkers); + } + // Viscosity plot + { + RigFlowDiagSolverInterface::PvtCurve::Ident curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Unknown; + double viscosityPointMarkerYValue = HUGE_VAL; + + if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::GAS) + { + curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Visc_g; + viscosityPointMarkerYValue = m_viscosityDynProps.mu_g; + } + else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::OIL) + { + curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Visc_o; + viscosityPointMarkerYValue = m_viscosityDynProps.mu_o; + } + + std::vector selectedViscosityCurves; + for (RigFlowDiagSolverInterface::PvtCurve curve : m_allViscosityCurvesArr) + { + if (curve.ident == curveIdentToPlot) + { + selectedViscosityCurves.push_back(curve); + } + } + + const QString plotTitle = QString("%1 Viscosity").arg(phaseString); + const QString yAxisTitle = QString("%1 Viscosity [%2]").arg(phaseString).arg(unitStringFromCurveIdent(m_unitSystem, curveIdentToPlot)); + plotCurvesInQwt(m_unitSystem, selectedViscosityCurves, m_pressure, viscosityPointMarkerYValue, plotTitle, yAxisTitle, m_viscosityPlot, &m_viscosityPlotMarkers); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector& curveArr, double pressure, double pointMarkerYValue, QString plotTitle, QString yAxisTitle, QwtPlot* plot, std::vector* myPlotMarkers) +void RiuPvtPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& curveArr, double pressure, double pointMarkerYValue, QString plotTitle, QString yAxisTitle, QwtPlot* plot, std::vector* myPlotMarkers) { plot->detachItems(QwtPlotItem::Rtti_PlotCurve); @@ -256,8 +281,8 @@ void RiuPvtPlotPanel::plotCurvesInQwt(const std::vectorsetSamples(curve.xVals.data(), curve.yVals.data(), static_cast(curve.xVals.size())); + CVF_ASSERT(curve.pressureVals.size() == curve.yVals.size()); + qwtCurve->setSamples(curve.pressureVals.data(), curve.yVals.data(), static_cast(curve.pressureVals.size())); qwtCurve->setStyle(QwtPlotCurve::Lines); @@ -308,12 +333,52 @@ void RiuPvtPlotPanel::plotCurvesInQwt(const std::vectorsetTitle(plotTitle); - plot->setAxisTitle(QwtPlot::xBottom, "Pressure"); + plot->setAxisTitle(QwtPlot::xBottom, QString("Pressure [%1]").arg(RiaEclipseUnitTools::unitStringPressure(unitSystem))); plot->setAxisTitle(QwtPlot::yLeft, yAxisTitle); plot->replot(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuPvtPlotPanel::unitStringFromCurveIdent(RiaEclipseUnitTools::UnitSystem unitSystem, RigFlowDiagSolverInterface::PvtCurve::Ident curveIdent) +{ + if (curveIdent == RigFlowDiagSolverInterface::PvtCurve::Bo) + { + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return "rm3/sm3"; + case RiaEclipseUnitTools::UNITS_FIELD: return "rb/stb"; + case RiaEclipseUnitTools::UNITS_LAB: return "rcc/scc"; + default: return ""; + } + } + else if (curveIdent == RigFlowDiagSolverInterface::PvtCurve::Bg) + { + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return "rm3/sm3"; + case RiaEclipseUnitTools::UNITS_FIELD: return "rb/Mscf"; + case RiaEclipseUnitTools::UNITS_LAB: return "rcc/scc"; + default: return ""; + } + } + else if (curveIdent == RigFlowDiagSolverInterface::PvtCurve::Visc_o || + curveIdent == RigFlowDiagSolverInterface::PvtCurve::Visc_g) + { + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return "cP"; + case RiaEclipseUnitTools::UNITS_FIELD: return "cP"; + case RiaEclipseUnitTools::UNITS_LAB: return "cP"; + default: return ""; + } + } + + return ""; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.h b/ApplicationCode/UserInterface/RiuPvtPlotPanel.h index ebaf10bd65..3404afbd66 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.h @@ -19,6 +19,7 @@ #pragma once #include "RigFlowDiagSolverInterface.h" +#include "RiaEclipseUnitTools.h" #include @@ -58,19 +59,21 @@ public: RiuPvtPlotPanel(QDockWidget* parent); virtual ~RiuPvtPlotPanel(); - void setPlotData(const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, double pressure); + void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, double pressure); void clearPlot(); RiuPvtPlotUpdater* plotUpdater(); private: void plotUiSelectedCurves(); static void setPlotDefaults(QwtPlot* plot); - static void plotCurvesInQwt(const std::vector& curveArr, double pressure, double pointMarkerYValue, QString plotTitle, QString yAxisTitle, QwtPlot* plot, std::vector* myPlotMarkers); + static void plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& curveArr, double pressure, double pointMarkerYValue, QString plotTitle, QString yAxisTitle, QwtPlot* plot, std::vector* myPlotMarkers); + static QString unitStringFromCurveIdent(RiaEclipseUnitTools::UnitSystem unitSystem, RigFlowDiagSolverInterface::PvtCurve::Ident curveIdent); private slots: void slotPhaseComboCurrentIndexChanged(int); private: + RiaEclipseUnitTools::UnitSystem m_unitSystem; std::vector m_allFvfCurvesArr; std::vector m_allViscosityCurvesArr; FvfDynProps m_fvfDynProps; diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index 7d3a57014f..5acec7a127 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -159,7 +159,7 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView RiuPvtPlotPanel::ViscosityDynProps viscosityDynProps; eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity(activeCellIndex, cellPressure, cellRS, cellRV, &viscosityDynProps.mu_o, &viscosityDynProps.mu_g); - plotPanel->setPlotData(fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellPressure); + plotPanel->setPlotData(eclipseCaseData->unitsType(), fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellPressure); return true; } diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp index 01ec102940..b7ffeed355 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp @@ -76,6 +76,7 @@ public: //-------------------------------------------------------------------------------------------------- RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel(QDockWidget* parent) : QWidget(parent), + m_unitSystem(RiaEclipseUnitTools::UNITS_UNKNOWN), m_swat(HUGE_VAL), m_sgas(HUGE_VAL), m_plotUpdater(new RiuRelativePermeabilityPlotUpdater(this)) @@ -157,10 +158,11 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuRelativePermeabilityPlotPanel::setPlotData(const std::vector& relPermCurves, double swat, double sgas, QString cellReferenceText) +void RiuRelativePermeabilityPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& relPermCurves, double swat, double sgas, QString cellReferenceText) { //cvf::Trace::show("Set RelPerm plot data"); + m_unitSystem = unitSystem; m_allCurvesArr = relPermCurves; m_swat = swat; m_sgas = sgas; @@ -181,12 +183,13 @@ void RiuRelativePermeabilityPlotPanel::clearPlot() return; } + m_unitSystem = RiaEclipseUnitTools::UNITS_UNKNOWN; m_allCurvesArr.clear(); m_swat = HUGE_VAL; m_sgas = HUGE_VAL; m_cellReferenceText.clear(); - plotCurvesInQwt(m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, false, m_qwtPlot, &m_myPlotMarkers); + plotCurvesInQwt(m_unitSystem, m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, false, m_qwtPlot, &m_myPlotMarkers); } //-------------------------------------------------------------------------------------------------- @@ -222,13 +225,13 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves() } } - plotCurvesInQwt(selectedCurves, m_swat, m_sgas, m_cellReferenceText, useLogScale, m_qwtPlot, &m_myPlotMarkers); + plotCurvesInQwt(m_unitSystem, selectedCurves, m_swat, m_sgas, m_cellReferenceText, useLogScale, m_qwtPlot, &m_myPlotMarkers); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector& curveArr, double swat, double sgas, QString cellReferenceText, bool logScaleLeftAxis, QwtPlot* plot, std::vector* myPlotMarkers) +void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& curveArr, double swat, double sgas, QString cellReferenceText, bool logScaleLeftAxis, QwtPlot* plot, std::vector* myPlotMarkers) { plot->detachItems(QwtPlotItem::Rtti_PlotCurve); @@ -244,7 +247,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vectorsetSamples(curve.xVals.data(), curve.yVals.data(), static_cast(curve.xVals.size())); const bool includePositiveValuesOnly = (logScaleLeftAxis && plotOnWhichYAxis == LEFT_YAXIS); - qwtCurve->setSamplesFromXValuesAndYValues(curve.xVals, curve.yVals, includePositiveValuesOnly); + qwtCurve->setSamplesFromXValuesAndYValues(curve.saturationVals, curve.yVals, includePositiveValuesOnly); qwtCurve->setTitle(curve.name.c_str()); @@ -305,7 +308,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vectorsetYAxis(QwtPlot::yRight); - shouldEableRightYAxis = true; + shouldEnableRightYAxis = true; } qwtCurve->attach(plot); @@ -377,9 +380,9 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vectorsetAxisTitle(QwtPlot::xBottom, determineXAxisTitleFromCurveCollection(curveArr)); plot->setAxisTitle(QwtPlot::yLeft, "Kr"); - plot->setAxisTitle(QwtPlot::yRight, "Pc"); + plot->setAxisTitle(QwtPlot::yRight, QString("Pc [%1]").arg(RiaEclipseUnitTools::unitStringPressure(unitSystem))); - plot->enableAxis(QwtPlot::yRight, shouldEableRightYAxis); + plot->enableAxis(QwtPlot::yRight, shouldEnableRightYAxis); plot->replot(); } @@ -439,7 +442,7 @@ void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double sa //-------------------------------------------------------------------------------------------------- void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, WhichYAxis whichYAxis, QwtPlot* plot, std::vector* myPlotMarkers) { - const double yVal = interpolatedCurveYValue(curve.xVals, curve.yVals, saturationValue); + const double yVal = interpolatedCurveYValue(curve.saturationVals, curve.yVals, saturationValue); if (yVal != HUGE_VAL) { QwtPlotMarker* pointMarker = new QwtPlotMarker; diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.h b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.h index 13347fbe9c..a19248cf6c 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.h +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.h @@ -19,6 +19,7 @@ #pragma once #include "RigFlowDiagSolverInterface.h" +#include "RiaEclipseUnitTools.h" #include @@ -46,7 +47,7 @@ public: RiuRelativePermeabilityPlotPanel(QDockWidget* parent); virtual ~RiuRelativePermeabilityPlotPanel(); - void setPlotData(const std::vector& relPermCurves, double swat, double sgas, QString cellReferenceText); + void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& relPermCurves, double swat, double sgas, QString cellReferenceText); void clearPlot(); RiuRelativePermeabilityPlotUpdater* plotUpdater(); @@ -70,7 +71,7 @@ private: void plotUiSelectedCurves(); static void setPlotDefaults(QwtPlot* plot); - static void plotCurvesInQwt(const std::vector& curveArr, double swat, double sgas, QString cellReferenceText, bool logScaleLeftAxis, QwtPlot* plot, std::vector* myPlotMarkers); + static void plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& curveArr, double swat, double sgas, QString cellReferenceText, bool logScaleLeftAxis, QwtPlot* plot, std::vector* myPlotMarkers); static QString determineXAxisTitleFromCurveCollection(const std::vector& curveArr); static void addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector* myPlotMarkers); static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, WhichYAxis whichYAxis, QwtPlot* plot, std::vector* myPlotMarkers); @@ -82,6 +83,7 @@ private slots: void slotSomeCheckBoxStateChanged(int); private: + RiaEclipseUnitTools::UnitSystem m_unitSystem; std::vector m_allCurvesArr; double m_swat; double m_sgas; diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index 3407092178..1fa116ca65 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -154,7 +154,7 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse QString cellRefText = constructCellReferenceText(eclipseCaseData, gridIndex, gridLocalCellIndex, cellSATNUM); - plotPanel->setPlotData(relPermCurveArr, cellSWAT, cellSGAS, cellRefText); + plotPanel->setPlotData(eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, cellRefText); return true; } From 6e4449960f6d5e2cd36933b0e84a87185923e6a7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 12 Dec 2017 08:37:56 +0100 Subject: [PATCH 12/22] #2227 Well formatins: Clear well path if it does not have well picks --- ApplicationCode/ProjectDataModel/RimTools.cpp | 22 +++++++++++++++---- ApplicationCode/ProjectDataModel/RimTools.h | 3 +++ .../ProjectDataModel/RimWellLogTrack.cpp | 16 ++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimTools.cpp b/ApplicationCode/ProjectDataModel/RimTools.cpp index 155c84a0d6..4047cc1108 100644 --- a/ApplicationCode/ProjectDataModel/RimTools.cpp +++ b/ApplicationCode/ProjectDataModel/RimTools.cpp @@ -248,17 +248,31 @@ void RimTools::wellPathWithFormationsOptionItems(QList* CVF_ASSERT(options); if (!options) return; + std::vector wellPaths; + RimTools::wellPathWithFormations(&wellPaths); + + QIcon wellIcon(":/Well.png"); + for (RimWellPath* wellPath : wellPaths) + { + options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon)); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTools::wellPathWithFormations(std::vector* wellPaths) +{ RimProject* proj = RiaApplication::instance()->project(); if (proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection()) { - caf::PdmChildArrayField& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths; + caf::PdmChildArrayField& allWellPaths = proj->activeOilField()->wellPathCollection()->wellPaths; - QIcon wellIcon(":/Well.png"); - for (RimWellPath* wellPath : wellPaths) + for (RimWellPath* wellPath : allWellPaths) { if (wellPath->hasFormations()) { - options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon)); + wellPaths->push_back(wellPath); } } } diff --git a/ApplicationCode/ProjectDataModel/RimTools.h b/ApplicationCode/ProjectDataModel/RimTools.h index dc4d60ae89..54e5e16788 100644 --- a/ApplicationCode/ProjectDataModel/RimTools.h +++ b/ApplicationCode/ProjectDataModel/RimTools.h @@ -20,6 +20,8 @@ #pragma once +#include "RimWellPath.h" + #include #include @@ -43,6 +45,7 @@ public: static void wellPathOptionItems(QList* options); static void wellPathWithFormationsOptionItems(QList* options); + static void wellPathWithFormations(std::vector* wellPaths); static void caseOptionItems(QList* options); static QString createTimeFormatStringFromDates(const std::vector& dates); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index ea2b619dc0..c7cf0722a9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -277,6 +277,22 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, pltPlot->updateConnectedEditors(); } } + + bool validWellPathChosen = false; + std::vector wellPaths; + RimTools::wellPathWithFormations(&wellPaths); + for (RimWellPath* wellPath : wellPaths) + { + if (wellPath == m_formationWellPath) + { + validWellPathChosen = true; + break; + } + } + if (!validWellPathChosen) + { + m_formationWellPath = nullptr; + } } else if (changedField == &m_formationCase) { From e7c08223b66f3c145f6a65f9d0f2534de3d44eb9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Dec 2017 16:41:18 +0100 Subject: [PATCH 13/22] #2243 Summary Plot : Add control flags for auto title for name, acronym and unit --- .../Summary/RimSummaryAxisProperties.cpp | 56 +++++++++++++++ .../Summary/RimSummaryAxisProperties.h | 14 +++- .../Summary/RimSummaryCurvesCalculator.cpp | 70 ++++++++++++------- .../Summary/RimSummaryPlot.cpp | 7 +- 4 files changed, 116 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp index 918cd45cd5..6bd265a16a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp @@ -59,6 +59,8 @@ CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties"); //-------------------------------------------------------------------------------------------------- RimSummaryAxisProperties::RimSummaryAxisProperties() { + // clang-format off + CAF_PDM_InitObject("Y-Axis Properties", ":/LeftAxis16x16.png", "", ""); CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", ""); @@ -68,6 +70,11 @@ RimSummaryAxisProperties::RimSummaryAxisProperties() m_name.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&isAutoTitle, "AutoTitle", true, "Auto Title", "", "", ""); + + CAF_PDM_InitField(&m_displayLongName, "DisplayLongName", true, "Title Names", "", "", ""); + CAF_PDM_InitField(&m_displayShortName, "DisplayShortName", false, "Title Acronymes", "", "", ""); + CAF_PDM_InitField(&m_displayUnitText, "DisplayUnitText", true, "Title Units", "", "", ""); + CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title", "", "", ""); CAF_PDM_InitFieldNoDefault(&titlePositionEnum, "TitlePosition", "Title Position", "", "", ""); CAF_PDM_InitField(&titleFontSize, "FontSize", 11, "Font Size", "", "", ""); @@ -86,6 +93,8 @@ RimSummaryAxisProperties::RimSummaryAxisProperties() CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", ""); updateOptionSensitivity(); + + // clang-format on } //-------------------------------------------------------------------------------------------------- @@ -148,6 +157,20 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi caf::PdmUiGroup& titleGroup = *(uiOrdering.addNewGroup("Axis Title")); titleGroup.add(&isAutoTitle); titleGroup.add(&customTitle); + + if (isAutoTitle()) + { + titleGroup.add(&m_displayShortName); + titleGroup.add(&m_displayLongName); + titleGroup.add(&m_displayUnitText); + + customTitle.uiCapability()->setUiReadOnly(true); + } + else + { + customTitle.uiCapability()->setUiReadOnly(false); + } + titleGroup.add(&titlePositionEnum); titleGroup.add(&titleFontSize); @@ -164,6 +187,7 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi scaleGroup.add(&visibleRangeMin); scaleGroup.add(&visibleRangeMax); scaleGroup.add(&valuesFontSize); + uiOrdering.skipRemainingFields(true); } @@ -198,6 +222,38 @@ RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const return RiaDefines::PLOT_AXIS_LEFT; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAxisProperties::useAutoTitle() const +{ + return isAutoTitle(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAxisProperties::showDescription() const +{ + return m_displayLongName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAxisProperties::showAcronym() const +{ + return m_displayShortName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAxisProperties::showUnitText() const +{ + return m_displayUnitText(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h index b22e211c1a..94b4eb071a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h @@ -61,7 +61,11 @@ public: QwtPlot::Axis qwtPlotAxisType() const; RiaDefines::PlotAxis plotAxisType() const; - caf::PdmField isAutoTitle; + bool useAutoTitle() const; + bool showDescription() const; + bool showAcronym() const; + bool showUnitText() const; + caf::PdmField customTitle; caf::PdmField titleFontSize; caf::PdmField< caf::AppEnum< AxisTitlePositionType > > titlePositionEnum; @@ -89,7 +93,13 @@ private: void updateOptionSensitivity(); private: - caf::PdmField m_isActive; + caf::PdmField m_isActive; + + caf::PdmField isAutoTitle; + caf::PdmField m_displayShortName; + caf::PdmField m_displayLongName; + caf::PdmField m_displayUnitText; + caf::PdmField m_name; QwtPlot::Axis m_axis; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index 804f00a1b8..5e87b455d2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -26,6 +26,7 @@ #include "RimAsciiDataCurve.h" #include "RiuSummaryQwtPlot.h" +#include "RiuSummaryVectorDescriptionMap.h" #include "qwt_plot_curve.h" #include "qwt_scale_draw.h" @@ -124,7 +125,7 @@ void RimSummaryPlotYAxisFormatter::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot* { QString axisTitle = m_axisProperties->customTitle; - if (m_axisProperties->isAutoTitle) axisTitle = autoAxisTitle(); + if (m_axisProperties->useAutoTitle()) axisTitle = autoAxisTitle(); QwtText axisTitleY = qwtPlot->axisTitle(m_axisProperties->qwtPlotAxisType()); @@ -200,35 +201,55 @@ void RimSummaryPlotYAxisFormatter::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot* //-------------------------------------------------------------------------------------------------- QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { - std::map > unitToQuantityNameMap; + std::map> unitToQuantityNameMap; - if (m_axisProperties->plotAxisType() == RiaDefines::PLOT_AXIS_BOTTOM) + for (RimSummaryCurve* rimCurve : m_summaryCurves) { - for (RimSummaryCurve* rimCurve : m_summaryCurves) - { - std::string quantityName = rimCurve->summaryAddressX().quantityName(); - if (rimCurve->summaryAddressX().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED) - { - quantityName = shortCalculationName(quantityName); - } + RifEclipseSummaryAddress sumAddress; + std::string unitText; - unitToQuantityNameMap[rimCurve->unitNameX()].insert(quantityName); + if (m_axisProperties->plotAxisType() == RiaDefines::PLOT_AXIS_BOTTOM) + { + sumAddress = rimCurve->summaryAddressX(); + unitText = rimCurve->unitNameX(); } - } - else - { - for (RimSummaryCurve* rimCurve : m_summaryCurves) + else if (rimCurve->axisY() == this->m_axisProperties->plotAxisType()) { - if (rimCurve->axisY() == this->m_axisProperties->plotAxisType()) + sumAddress = rimCurve->summaryAddressY(); + unitText = rimCurve->unitNameY(); + } + else + { + continue; + } + + std::string quantityNameForDisplay; + { + std::string quantityName = sumAddress.quantityName(); + + if (sumAddress.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED) { - std::string quantityName = rimCurve->summaryAddressY().quantityName(); - if (rimCurve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED) + quantityNameForDisplay = shortCalculationName(quantityName); + } + else + { + if (m_axisProperties->showDescription()) { - quantityName = shortCalculationName(quantityName); + quantityNameForDisplay = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(quantityName); } - unitToQuantityNameMap[rimCurve->unitNameY()].insert(quantityName); + if (m_axisProperties->showAcronym()) + { + if (!quantityNameForDisplay.empty()) + { + quantityNameForDisplay += " "; + } + + quantityNameForDisplay += quantityName; + } } + + unitToQuantityNameMap[unitText].insert(quantityNameForDisplay); } } @@ -239,20 +260,19 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { if (m_axisProperties->scaleFactor() != 1.0) { - int exponent = std::log10(m_axisProperties->scaleFactor()); + int exponent = std::log10(m_axisProperties->scaleFactor()); scaleFactorText = QString(" x 10%1 ").arg(QString::number(exponent)); } } - - for ( auto unitIt : unitToQuantityNameMap ) + for (auto unitIt : unitToQuantityNameMap) { - for (const auto &quantIt: unitIt.second) + for (const auto& quantIt : unitIt.second) { assembledYAxisText += QString::fromStdString(quantIt) + " "; } - if (!unitIt.first.empty()) + if (m_axisProperties->showUnitText() && !unitIt.first.empty()) { assembledYAxisText += "[" + QString::fromStdString(unitIt.first) + scaleFactorText + "] "; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 1656f833ab..77b5e701b4 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -776,15 +776,15 @@ void RimSummaryPlot::updateBottomXAxis() QwtPlot::Axis qwtAxis = QwtPlot::xBottom; - RimSummaryAxisProperties* yAxisProperties = m_bottomAxisProperties(); + RimSummaryAxisProperties* bottomAxisProperties = m_bottomAxisProperties(); - if (yAxisProperties->isActive()) + if (bottomAxisProperties->isActive()) { m_qwtPlot->enableAxis(qwtAxis, true); std::set timeHistoryQuantities; - RimSummaryPlotYAxisFormatter calc(yAxisProperties, + RimSummaryPlotYAxisFormatter calc(bottomAxisProperties, visibleSummaryCurvesForAxis(RiaDefines::PLOT_AXIS_BOTTOM), visibleAsciiDataCurvesForAxis(RiaDefines::PLOT_AXIS_BOTTOM), timeHistoryQuantities); @@ -805,7 +805,6 @@ void RimSummaryPlot::updateCaseNameHasChanged() { m_summaryCurveCollection->updateCaseNameHasChanged(); } - } //-------------------------------------------------------------------------------------------------- From 96b1fc91609020048a90b3c61647e1762f2a0fca Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Dec 2017 07:42:16 +0100 Subject: [PATCH 14/22] Whitepace --- .../Summary/RimSummaryAxisProperties.cpp | 98 +++++++++---------- .../Summary/RimSummaryAxisProperties.h | 81 ++++++++------- 2 files changed, 86 insertions(+), 93 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp index 6bd265a16a..38673bae10 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp @@ -1,61 +1,58 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016 Statoil 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RimSummaryAxisProperties.h" -#include "RimSummaryPlot.h" #include "RiaDefines.h" +#include "RimSummaryPlot.h" #include "cafPdmUiSliderEditor.h" #include - namespace caf { - template<> - void caf::AppEnum< RimSummaryAxisProperties::NumberFormatType >::setUp() - { - addItem(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto"); - addItem(RimSummaryAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal"); - addItem(RimSummaryAxisProperties::NUMBER_FORMAT_SCIENTIFIC,"NUMBER_FORMAT_SCIENTIFIC", "Scientific"); +// clang-format off +template<> +void caf::AppEnum::setUp() +{ + addItem(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto"); + addItem(RimSummaryAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal"); + addItem(RimSummaryAxisProperties::NUMBER_FORMAT_SCIENTIFIC, "NUMBER_FORMAT_SCIENTIFIC", "Scientific"); - setDefault(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO); - } + setDefault(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO); } -namespace caf -{ template<> -void caf::AppEnum< RimSummaryAxisProperties::AxisTitlePositionType >::setUp() +void caf::AppEnum::setUp() { - addItem(RimSummaryAxisProperties::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center"); - addItem(RimSummaryAxisProperties::AXIS_TITLE_END, "AXIS_TITLE_END", "At End"); + addItem(RimSummaryAxisProperties::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center"); + addItem(RimSummaryAxisProperties::AXIS_TITLE_END, "AXIS_TITLE_END", "At End"); setDefault(RimSummaryAxisProperties::AXIS_TITLE_CENTER); } -} - +// clang-format on +} // namespace caf CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryAxisProperties::RimSummaryAxisProperties() { @@ -98,7 +95,7 @@ RimSummaryAxisProperties::RimSummaryAxisProperties() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField() { @@ -106,15 +103,15 @@ caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RimSummaryAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimSummaryAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; *useOptionsOnly = true; - if (&titleFontSize == fieldNeedingOptions || - &valuesFontSize == fieldNeedingOptions) + if (&titleFontSize == fieldNeedingOptions || &valuesFontSize == fieldNeedingOptions) { std::vector fontSizes; fontSizes.push_back(8); @@ -137,10 +134,8 @@ QList RimSummaryAxisProperties::calculateValueOptions(co { for (int exp = -12; exp <= 12; exp += 3) { - QString uiText = - exp == 0 ? "1" : - QString("10 ^ %1").arg(exp); - double value = std::pow(10, exp); + QString uiText = exp == 0 ? "1" : QString("10 ^ %1").arg(exp); + double value = std::pow(10, exp); options.push_back(caf::PdmOptionItemInfo(uiText, value)); } @@ -150,7 +145,7 @@ QList RimSummaryAxisProperties::calculateValueOptions(co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { @@ -163,7 +158,7 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi titleGroup.add(&m_displayShortName); titleGroup.add(&m_displayLongName); titleGroup.add(&m_displayUnitText); - + customTitle.uiCapability()->setUiReadOnly(true); } else @@ -174,10 +169,10 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi titleGroup.add(&titlePositionEnum); titleGroup.add(&titleFontSize); - caf::PdmUiGroup& scaleGroup = *(uiOrdering.addNewGroup("Axis Values")); + caf::PdmUiGroup& scaleGroup = *(uiOrdering.addNewGroup("Axis Values")); scaleGroup.add(&isLogarithmicScaleEnabled); scaleGroup.add(&numberFormat); - + if (numberFormat() != NUMBER_FORMAT_AUTO) { scaleGroup.add(&numberOfDecimals); @@ -192,7 +187,7 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis) { @@ -204,7 +199,7 @@ void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const { @@ -212,7 +207,7 @@ QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const { @@ -223,7 +218,7 @@ RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryAxisProperties::useAutoTitle() const { @@ -231,7 +226,7 @@ bool RimSummaryAxisProperties::useAutoTitle() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryAxisProperties::showDescription() const { @@ -239,7 +234,7 @@ bool RimSummaryAxisProperties::showDescription() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryAxisProperties::showAcronym() const { @@ -247,7 +242,7 @@ bool RimSummaryAxisProperties::showAcronym() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryAxisProperties::showUnitText() const { @@ -255,7 +250,7 @@ bool RimSummaryAxisProperties::showUnitText() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryAxisProperties::isActive() const { @@ -263,11 +258,11 @@ bool RimSummaryAxisProperties::isActive() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, + const QVariant& newValue) { - if (changedField == &isAutoTitle) { updateOptionSensitivity(); @@ -280,13 +275,13 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang if (changedField == &visibleRangeMax) { if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble(); - + rimSummaryPlot->disableAutoZoom(); } else if (changedField == &visibleRangeMin) { if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble(); - + rimSummaryPlot->disableAutoZoom(); } @@ -302,7 +297,7 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryAxisProperties::updateOptionSensitivity() { @@ -310,7 +305,7 @@ void RimSummaryAxisProperties::updateOptionSensitivity() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryAxisProperties::initAfterRead() { @@ -318,10 +313,9 @@ void RimSummaryAxisProperties::initAfterRead() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimSummaryAxisProperties::objectToggleField() { return &m_isActive; } - diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h index 94b4eb071a..8b33b27e7b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h @@ -1,40 +1,37 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016 Statoil 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// - #pragma once #include "RiaDefines.h" -#include "cafPdmObject.h" -#include "cafPdmField.h" -#include "cafPdmChildArrayField.h" #include "cafAppEnum.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" #include "qwt_plot.h" #include - - //================================================================================================== -/// -/// +/// +/// //================================================================================================== class RimSummaryAxisProperties : public caf::PdmObject { @@ -57,49 +54,51 @@ public: public: RimSummaryAxisProperties(); - void setNameAndAxis(const QString& name, QwtPlot::Axis axis); - QwtPlot::Axis qwtPlotAxisType() const; - RiaDefines::PlotAxis plotAxisType() const; + void setNameAndAxis(const QString& name, QwtPlot::Axis axis); + QwtPlot::Axis qwtPlotAxisType() const; + RiaDefines::PlotAxis plotAxisType() const; + bool useAutoTitle() const; + bool showDescription() const; + bool showAcronym() const; + bool showUnitText() const; - bool useAutoTitle() const; - bool showDescription() const; - bool showAcronym() const; - bool showUnitText() const; + caf::PdmField customTitle; + caf::PdmField titleFontSize; + caf::PdmField> titlePositionEnum; - caf::PdmField customTitle; - caf::PdmField titleFontSize; - caf::PdmField< caf::AppEnum< AxisTitlePositionType > > titlePositionEnum; + caf::PdmField visibleRangeMin; + caf::PdmField visibleRangeMax; - caf::PdmField visibleRangeMin; - caf::PdmField visibleRangeMax; + caf::PdmField> numberFormat; + caf::PdmField numberOfDecimals; + caf::PdmField scaleFactor; + caf::PdmField isLogarithmicScaleEnabled; + caf::PdmField valuesFontSize; - caf::PdmField< caf::AppEnum< NumberFormatType > > numberFormat; - caf::PdmField numberOfDecimals; - caf::PdmField scaleFactor; - caf::PdmField isLogarithmicScaleEnabled; - caf::PdmField valuesFontSize; - - bool isActive() const; + bool isActive() const; protected: - virtual void initAfterRead() override; - virtual caf::PdmFieldHandle* userDescriptionField() override; - virtual caf::PdmFieldHandle* objectToggleField() override; - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; + virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, + const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; private: - void updateOptionSensitivity(); + void updateOptionSensitivity(); private: caf::PdmField m_isActive; - + caf::PdmField isAutoTitle; caf::PdmField m_displayShortName; caf::PdmField m_displayLongName; caf::PdmField m_displayUnitText; - caf::PdmField m_name; - QwtPlot::Axis m_axis; + caf::PdmField m_name; + QwtPlot::Axis m_axis; }; From ab53135f919320b545e1547c590c3be389a52538 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Dec 2017 08:35:37 +0100 Subject: [PATCH 15/22] #2243 Summary Plot : Reorganize axis properties fields --- .../Summary/RimSummaryAxisProperties.cpp | 66 ++++++++++--------- .../Summary/RimSummaryPlot.cpp | 10 +-- .../ProjectDataModel/Summary/RimSummaryPlot.h | 2 +- 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp index 38673bae10..1dd4d328ac 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp @@ -25,9 +25,9 @@ #include +// clang-format off namespace caf { -// clang-format off template<> void caf::AppEnum::setUp() { @@ -46,7 +46,6 @@ void caf::AppEnum::setUp() setDefault(RimSummaryAxisProperties::AXIS_TITLE_CENTER); } -// clang-format on } // namespace caf CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties"); @@ -56,8 +55,6 @@ CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties"); //-------------------------------------------------------------------------------------------------- RimSummaryAxisProperties::RimSummaryAxisProperties() { - // clang-format off - CAF_PDM_InitObject("Y-Axis Properties", ":/LeftAxis16x16.png", "", ""); CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", ""); @@ -68,32 +65,31 @@ RimSummaryAxisProperties::RimSummaryAxisProperties() CAF_PDM_InitField(&isAutoTitle, "AutoTitle", true, "Auto Title", "", "", ""); - CAF_PDM_InitField(&m_displayLongName, "DisplayLongName", true, "Title Names", "", "", ""); - CAF_PDM_InitField(&m_displayShortName, "DisplayShortName", false, "Title Acronymes", "", "", ""); - CAF_PDM_InitField(&m_displayUnitText, "DisplayUnitText", true, "Title Units", "", "", ""); + CAF_PDM_InitField(&m_displayLongName, "DisplayLongName", true, " Names", "", "", ""); + CAF_PDM_InitField(&m_displayShortName, "DisplayShortName", false, " Acronymes", "", "", ""); + CAF_PDM_InitField(&m_displayUnitText, "DisplayUnitText", true, " Units", "", "", ""); - CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title", "", "", ""); - CAF_PDM_InitFieldNoDefault(&titlePositionEnum, "TitlePosition", "Title Position", "", "", ""); - CAF_PDM_InitField(&titleFontSize, "FontSize", 11, "Font Size", "", "", ""); + CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title", "", "", ""); + CAF_PDM_InitFieldNoDefault(&titlePositionEnum, "TitlePosition", "Title Position", "", "", ""); + CAF_PDM_InitField(&titleFontSize, "FontSize", 11, "Font Size", "", "", ""); CAF_PDM_InitField(&visibleRangeMax, "VisibleRangeMax", RiaDefines::maximumDefaultValuePlot(), "Max", "", "", ""); CAF_PDM_InitField(&visibleRangeMin, "VisibleRangeMin", RiaDefines::minimumDefaultValuePlot(), "Min", "", "", ""); - CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format", "", "", ""); - CAF_PDM_InitField(&numberOfDecimals, "Decimals", 2, "Number of Decimals", "", "", ""); - CAF_PDM_InitField(&scaleFactor, "ScaleFactor", 1.0, "Scale Factor", "", "", ""); - CAF_PDM_InitField(&valuesFontSize, "ValuesFontSize", 11, "Font Size", "", "", ""); + CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format", "", "", ""); + CAF_PDM_InitField(&numberOfDecimals, "Decimals", 2, "Number of Decimals", "", "", ""); + CAF_PDM_InitField(&scaleFactor, "ScaleFactor", 1.0, "Scale Factor", "", "", ""); + CAF_PDM_InitField(&valuesFontSize, "ValuesFontSize", 11, "Font Size", "", "", ""); numberOfDecimals.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", ""); updateOptionSensitivity(); - - // clang-format on } +// clang-format on + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -149,25 +145,31 @@ QList RimSummaryAxisProperties::calculateValueOptions(co //-------------------------------------------------------------------------------------------------- void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup& titleGroup = *(uiOrdering.addNewGroup("Axis Title")); - titleGroup.add(&isAutoTitle); - titleGroup.add(&customTitle); - - if (isAutoTitle()) { - titleGroup.add(&m_displayShortName); - titleGroup.add(&m_displayLongName); - titleGroup.add(&m_displayUnitText); + caf::PdmUiGroup* titleTextGroup = uiOrdering.addNewGroup("Title Text"); - customTitle.uiCapability()->setUiReadOnly(true); - } - else - { - customTitle.uiCapability()->setUiReadOnly(false); + titleTextGroup->add(&isAutoTitle); + + if (isAutoTitle()) + { + titleTextGroup->add(&m_displayLongName); + titleTextGroup->add(&m_displayShortName); + titleTextGroup->add(&m_displayUnitText); + + customTitle.uiCapability()->setUiReadOnly(true); + } + else + { + titleTextGroup->add(&customTitle); + customTitle.uiCapability()->setUiReadOnly(false); + } } - titleGroup.add(&titlePositionEnum); - titleGroup.add(&titleFontSize); + { + caf::PdmUiGroup* titleGroup = uiOrdering.addNewGroup("Title Layout"); + titleGroup->add(&titlePositionEnum); + titleGroup->add(&titleFontSize); + } caf::PdmUiGroup& scaleGroup = *(uiOrdering.addNewGroup("Axis Values")); scaleGroup.add(&isLogarithmicScaleEnabled); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 77b5e701b4..7e73169dc0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -156,7 +156,7 @@ void RimSummaryPlot::updateAxes() //-------------------------------------------------------------------------------------------------- bool RimSummaryPlot::isLogarithmicScaleEnabled(RiaDefines::PlotAxis plotAxis) const { - return yAxisPropertiesForAxis(plotAxis)->isLogarithmicScaleEnabled(); + return yAxisPropertiesLeftOrRight(plotAxis)->isLogarithmicScaleEnabled(); } //-------------------------------------------------------------------------------------------------- @@ -516,7 +516,7 @@ void RimSummaryPlot::updateAxis(RiaDefines::PlotAxis plotAxis) qwtAxis = QwtPlot::yRight; } - RimSummaryAxisProperties* yAxisProperties = yAxisPropertiesForAxis(plotAxis); + RimSummaryAxisProperties* yAxisProperties = yAxisPropertiesLeftOrRight(plotAxis); if (yAxisProperties->isActive() && hasVisibleCurvesForAxis(plotAxis)) { m_qwtPlot->enableAxis(qwtAxis, true); @@ -545,7 +545,7 @@ void RimSummaryPlot::updateAxis(RiaDefines::PlotAxis plotAxis) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateZoomForAxis(RiaDefines::PlotAxis plotAxis) { - RimSummaryAxisProperties* yAxisProps = yAxisPropertiesForAxis(plotAxis); + RimSummaryAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis); if (yAxisProps->isLogarithmicScaleEnabled) { @@ -648,11 +648,11 @@ bool RimSummaryPlot::hasVisibleCurvesForAxis(RiaDefines::PlotAxis plotAxis) cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryAxisProperties* RimSummaryPlot::yAxisPropertiesForAxis(RiaDefines::PlotAxis plotAxis) const +RimSummaryAxisProperties* RimSummaryPlot::yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const { RimSummaryAxisProperties* yAxisProps = nullptr; - if (plotAxis == RiaDefines::PLOT_AXIS_LEFT) + if (leftOrRightPlotAxis == RiaDefines::PLOT_AXIS_LEFT) { yAxisProps = m_leftYAxisProperties(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 6eb0338afe..a2cb477f28 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -134,7 +134,7 @@ private: std::vector visibleAsciiDataCurvesForAxis(RiaDefines::PlotAxis plotAxis) const; bool hasVisibleCurvesForAxis(RiaDefines::PlotAxis plotAxis) const; - RimSummaryAxisProperties* yAxisPropertiesForAxis(RiaDefines::PlotAxis plotAxis) const; + RimSummaryAxisProperties* yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const; void updateAxis(RiaDefines::PlotAxis plotAxis); void updateZoomForAxis(RiaDefines::PlotAxis plotAxis); From b7bdce1d9ead39677b75dfffd2f0c8fce0026997 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Dec 2017 08:42:09 +0100 Subject: [PATCH 16/22] Summary Plot Curve Editor : Use () instead of [] around acronyms as [] are used for unit text --- .../Summary/RimSummaryCurvesCalculator.cpp | 9 +++++++-- .../UserInterface/RiuSummaryCurveDefSelection.cpp | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index 5e87b455d2..37cba228b0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -242,10 +242,15 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const { if (!quantityNameForDisplay.empty()) { - quantityNameForDisplay += " "; + quantityNameForDisplay += " ("; + quantityNameForDisplay += quantityName; + quantityNameForDisplay += ")"; + } + else + { + quantityNameForDisplay += quantityName; } - quantityNameForDisplay += quantityName; } } diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 447ccf99f2..3449269099 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -534,22 +534,22 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions } auto itemPostfix = (isVectorField && i == OBS_DATA) ? QString(OBSERVED_DATA_AVALUE_POSTFIX) : QString(""); - for (const auto& iName : itemNames[i]) + for (const auto& itemName : itemNames[i]) { QString displayName; if (isVectorField) { - std::string descriptiveName = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(iName); - displayName = QString::fromStdString(descriptiveName); - displayName += QString(" [%1]").arg(QString::fromStdString(iName)); + std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(itemName); + displayName = QString::fromStdString(longVectorName); + displayName += QString(" (%1)").arg(QString::fromStdString(itemName)); } else { - displayName = QString::fromStdString(iName); + displayName = QString::fromStdString(itemName); } - auto optionItem = caf::PdmOptionItemInfo(displayName, QString::fromStdString(iName) + itemPostfix); + auto optionItem = caf::PdmOptionItemInfo(displayName, QString::fromStdString(itemName) + itemPostfix); if (groupItems) optionItem.setLevel(1); options.push_back(optionItem); From 9769d391e108ceaf82d2adba1b54572058346084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 12 Dec 2017 13:22:16 +0100 Subject: [PATCH 17/22] #2199, #2245 Summary plots. Add paste commands for cross plot. Add duplicate summary plots and curves --- .../Application/Tools/RiaSummaryTools.cpp | 8 ++ .../Application/Tools/RiaSummaryTools.h | 1 + .../CMakeLists_files.cmake | 12 ++ ...cDuplicateSummaryCrossPlotCurveFeature.cpp | 63 +++++++++ ...RicDuplicateSummaryCrossPlotCurveFeature.h | 40 ++++++ .../RicDuplicateSummaryCrossPlotFeature.cpp | 75 +++++++++++ .../RicDuplicateSummaryCrossPlotFeature.h | 39 ++++++ .../RicDuplicateSummaryCurveFeature.cpp | 80 ++++++++++++ .../RicDuplicateSummaryCurveFeature.h | 38 ++++++ .../RicDuplicateSummaryPlotFeature.cpp | 75 +++++++++++ .../RicDuplicateSummaryPlotFeature.h | 39 ++++++ .../RicNewSummaryCrossPlotFeature.cpp | 5 +- .../RicPasteSummaryCrossPlotCurveFeature.cpp | 91 +++++++++++++ .../RicPasteSummaryCrossPlotCurveFeature.h | 43 +++++++ .../RicPasteSummaryCrossPlotFeature.cpp | 120 ++++++++++++++++++ .../RicPasteSummaryCrossPlotFeature.h | 46 +++++++ .../RicPasteSummaryCurveFeature.cpp | 84 +++++++----- .../RicPasteSummaryCurveFeature.h | 6 +- .../RicPasteSummaryPlotFeature.cpp | 55 ++++---- .../RicPasteSummaryPlotFeature.h | 3 + .../RimContextCommandBuilder.cpp | 9 ++ .../Summary/RimSummaryCrossPlotCollection.cpp | 10 +- .../Summary/RimSummaryCrossPlotCollection.h | 3 +- 23 files changed, 880 insertions(+), 65 deletions(-) create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h diff --git a/ApplicationCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationCode/Application/Tools/RiaSummaryTools.cpp index ff9b0c4671..5d6af6a70f 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationCode/Application/Tools/RiaSummaryTools.cpp @@ -130,3 +130,11 @@ RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection(caf::P return crossPlotColl; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaSummaryTools::isSummaryCrossPlot(const RimSummaryPlot* plot) +{ + return dynamic_cast(plot); +} diff --git a/ApplicationCode/Application/Tools/RiaSummaryTools.h b/ApplicationCode/Application/Tools/RiaSummaryTools.h index 8390cfe86d..92271a4bbc 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationCode/Application/Tools/RiaSummaryTools.h @@ -44,4 +44,5 @@ public: static RimSummaryCrossPlot* parentCrossPlot(caf::PdmObject* object); static RimSummaryCrossPlotCollection* parentCrossPlotCollection(caf::PdmObject* object); + static bool isSummaryCrossPlot(const RimSummaryPlot* plot); }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 41c571f364..841ee8017a 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -9,12 +9,18 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.h ${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h ${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.h @@ -38,12 +44,18 @@ set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.cpp ${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.cpp ${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.cpp diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp new file mode 100644 index 0000000000..f8496965b4 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryCrossPlotCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicPasteSummaryCurveFeature.h" + +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RiaSummaryTools.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCrossPlotCollection.h" + +#include "RiuMainPlotWindow.h" + +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCrossPlotCurveFeature, "RicDuplicateSummaryCrossPlotCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryCrossPlotCurveFeature::isCommandEnabled() +{ + RimSummaryCrossPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject(); + return (selectedPlot); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Cross Plot Curve"); + actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h new file mode 100644 index 0000000000..58438cad7b --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicDuplicateSummaryCurveFeature.h" + +#include "cafCmdFeature.h" + +#include + +class RimSummaryCrossPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryCrossPlotCurveFeature : public RicDuplicateSummaryCurveFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void setupActionLook( QAction* actionToSetup ); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp new file mode 100644 index 0000000000..994f6176c3 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryCrossPlotFeature.h" + +#include "RiaSummaryTools.h" + +#include "RicPasteSummaryCrossPlotFeature.h" + +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCrossPlotCollection.h" + +#include "cvfAssert.h" +#include "cafSelectionManagerTools.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCrossPlotFeature, "RicDuplicateSummaryCrossPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryCrossPlotFeature::isCommandEnabled() +{ + RimSummaryCrossPlotCollection* sumPlotColl = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlotColl = RiaSummaryTools::parentCrossPlotCollection(selObj); + } + + if (sumPlotColl) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCrossPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector selectedObjects = caf::selectedObjectsByType(); + + if (selectedObjects.size() == 1) + { + RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection(selectedObjects[0]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Cross Plot"); + actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h new file mode 100644 index 0000000000..a247fa562f --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSummaryPlotCollection; +class RimSummaryCase; +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryCrossPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp new file mode 100644 index 0000000000..ad1e0b2cb3 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp @@ -0,0 +1,80 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicPasteSummaryCurveFeature.h" + +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RiaSummaryTools.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuMainPlotWindow.h" + +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCurveFeature, "RicDuplicateSummaryCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryCurveFeature::isCommandEnabled() +{ + RimSummaryPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject(); + return (selectedPlot && !RiaSummaryTools::isSummaryCrossPlot(selectedPlot)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCurveFeature::onActionTriggered(bool isChecked) +{ + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + + RimSummaryCurve* curve = caf::firstAncestorOfTypeFromSelectedObject(); + if (curve) + { + RimSummaryCurve* newCurve = RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(curve); + + RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Curve"); + actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h new file mode 100644 index 0000000000..03c9862bc0 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp new file mode 100644 index 0000000000..0efdc162e0 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryPlotFeature.h" + +#include "RiaSummaryTools.h" + +#include "RicPasteSummaryPlotFeature.h" + +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" + +#include "cvfAssert.h" +#include "cafSelectionManagerTools.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryPlotFeature, "RicDuplicateSummaryPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryPlotFeature::isCommandEnabled() +{ + RimSummaryPlotCollection* sumPlotColl = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection(selObj); + } + + if (sumPlotColl) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector selectedObjects = caf::selectedObjectsByType(); + + if (selectedObjects.size() == 1) + { + RicPasteSummaryPlotFeature::copyPlotAndAddToCollection(selectedObjects[0]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Plot"); + actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h new file mode 100644 index 0000000000..aa1e0bba11 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSummaryPlotCollection; +class RimSummaryCase; +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index 9e6ad6d126..b4ed164d33 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -57,8 +57,9 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked) CVF_ASSERT(project); RimSummaryCrossPlotCollection* summaryCrossPlotColl = project->mainPlotCollection()->summaryCrossPlotCollection(); - RimSummaryPlot* summaryPlot = summaryCrossPlotColl->addSummaryPlot(); - + RimSummaryPlot* summaryPlot = summaryCrossPlotColl->createSummaryPlot(); + + summaryCrossPlotColl->addSummaryPlot(summaryPlot); if (summaryPlot) { summaryCrossPlotColl->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp new file mode 100644 index 0000000000..e7e557a7ea --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteSummaryCrossPlotCurveFeature.h" + +#include "RiaSummaryTools.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RimSummaryCurve.h" +#include "RimSummaryCurveFilter.h" +#include "RimSummaryCrossPlot.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmDocument.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicPasteSummaryCrossPlotCurveFeature, "RicPasteSummaryCrossPlotCurveFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteSummaryCrossPlotCurveFeature::isCommandEnabled() +{ + caf::PdmObject* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + if(!RiaSummaryTools::parentCrossPlot(destinationObject)) + { + return false; + } + + if (summaryCurvesOnClipboard().size() == 0) + { + return false; + } + + for (caf::PdmPointer curve : summaryCurvesOnClipboard()) + { + // Check that owner plot is correct type + RimSummaryCrossPlot* ownerPlot = nullptr; + curve->firstAncestorOrThisOfType(ownerPlot); + + if (!ownerPlot) return false; + } + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//void RicPasteSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked) +//{ +// std::vector > sourceObjects = RicPasteSummaryCurveFeature::summaryCurves(); +// +// for (size_t i = 0; i < sourceObjects.size(); i++) +// { +// copyCurveAndAddToPlot(sourceObjects[i]); +// } +//} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste Summary Cross Plot Curve"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h new file mode 100644 index 0000000000..278ff6521e --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicPasteSummaryCurveFeature.h" + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimSummaryCurve; +class RimSummaryCurveFilter; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteSummaryCrossPlotCurveFeature : public RicPasteSummaryCurveFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + //virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp new file mode 100644 index 0000000000..ebb2cbad57 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp @@ -0,0 +1,120 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteSummaryCrossPlotFeature.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCrossPlotCollection.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmDocument.h" +#include "cafPdmObjectGroup.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicPasteSummaryCrossPlotFeature, "RicPasteSummaryCrossPlotFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection(RimSummaryCrossPlot *sourcePlot) +{ + RimSummaryCrossPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); + + if (plotColl) + { + RimSummaryCrossPlot* newSummaryPlot = dynamic_cast(sourcePlot->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newSummaryPlot); + + plotColl->addSummaryPlot(newSummaryPlot); + + // Resolve references after object has been inserted into the data model + newSummaryPlot->resolveReferencesRecursively(); + newSummaryPlot->initAfterReadRecursively(); + + QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description(); + newSummaryPlot->setDescription(nameOfCopy); + + plotColl->updateConnectedEditors(); + + newSummaryPlot->loadDataAndUpdate(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteSummaryCrossPlotFeature::isCommandEnabled() +{ + caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimSummaryCrossPlotCollection* plotColl = nullptr; + destinationObject->firstAncestorOrThisOfType(plotColl); + if (!plotColl) + { + return false; + } + + return RicPasteSummaryCrossPlotFeature::summaryPlots().size() > 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector > sourceObjects = RicPasteSummaryCrossPlotFeature::summaryPlots(); + + for (size_t i = 0; i < sourceObjects.size(); i++) + { + copyPlotAndAddToCollection(sourceObjects[i]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste Summary Cross Plot"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector > RicPasteSummaryCrossPlotFeature::summaryPlots() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector > typedObjects; + objectGroup.objectsByType(&typedObjects); + + return typedObjects; +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h new file mode 100644 index 0000000000..78a751a623 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimSummaryCrossPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteSummaryCrossPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static void copyPlotAndAddToCollection(RimSummaryCrossPlot *sourcePlot); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static std::vector > summaryPlots(); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp index 9ca814082f..cfb0f828bc 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp @@ -18,16 +18,19 @@ #include "RicPasteSummaryCurveFeature.h" +#include "RiaSummaryTools.h" + #include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" +#include "RimSummaryCrossPlot.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmDocument.h" #include "cafPdmObjectGroup.h" -#include "cafSelectionManager.h" +#include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -36,21 +39,62 @@ CAF_CMD_SOURCE_INIT(RicPasteSummaryCurveFeature, "RicPasteSummaryCurveFeature"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(RimSummaryCurve *sourceCurve) +{ + RimSummaryPlot* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject(); + + RimSummaryCurve* newCurve = dynamic_cast(sourceCurve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newCurve); + + summaryPlot->addCurveAndUpdate(newCurve); + + // Resolve references after object has been inserted into the project data model + newCurve->resolveReferencesRecursively(); + + // If source curve is part of a curve filter, resolve of references to the summary case does not + // work when pasting the new curve into a plot. Must set summary case manually. + newCurve->setSummaryCaseY(sourceCurve->summaryCaseY()); + + newCurve->initAfterReadRecursively(); + + newCurve->loadDataAndUpdate(true); + newCurve->updateConnectedEditors(); + + summaryPlot->updateConnectedEditors(); + + return newCurve; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicPasteSummaryCurveFeature::isCommandEnabled() { - caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + caf::PdmObject* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); RimSummaryPlot* summaryPlot = nullptr; destinationObject->firstAncestorOrThisOfType(summaryPlot); - if (!summaryPlot) + if(!RiaSummaryTools::parentSummaryPlot(destinationObject)) { return false; } - return RicPasteSummaryCurveFeature::summaryCurves().size() > 0; + if (summaryCurvesOnClipboard().size() == 0) + { + return false; + } + + for (caf::PdmPointer curve : summaryCurvesOnClipboard()) + { + // Check that owner plot is correct type + RimSummaryPlot* ownerPlot = RiaSummaryTools::parentSummaryPlot(curve); + + if (!ownerPlot) return false; + } + return true; } //-------------------------------------------------------------------------------------------------- @@ -58,37 +102,11 @@ bool RicPasteSummaryCurveFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicPasteSummaryCurveFeature::onActionTriggered(bool isChecked) { - caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); - - RimSummaryPlot* summaryPlot = nullptr; - destinationObject->firstAncestorOrThisOfType(summaryPlot); - if (!summaryPlot) - { - return; - } - - std::vector > sourceObjects = RicPasteSummaryCurveFeature::summaryCurves(); + std::vector > sourceObjects = RicPasteSummaryCurveFeature::summaryCurvesOnClipboard(); for (size_t i = 0; i < sourceObjects.size(); i++) { - RimSummaryCurve* newObject = dynamic_cast(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); - CVF_ASSERT(newObject); - - summaryPlot->addCurveAndUpdate(newObject); - - // Resolve references after object has been inserted into the project data model - newObject->resolveReferencesRecursively(); - - // If source curve is part of a curve filter, resolve of references to the summary case does not - // work when pasting the new curve into a plot. Must set summary case manually. - newObject->setSummaryCaseY(sourceObjects[i]->summaryCaseY()); - - newObject->initAfterReadRecursively(); - - newObject->loadDataAndUpdate(true); - newObject->updateConnectedEditors(); - - summaryPlot->updateConnectedEditors(); + copyCurveAndAddToPlot(sourceObjects[i]); } } @@ -105,7 +123,7 @@ void RicPasteSummaryCurveFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector > RicPasteSummaryCurveFeature::summaryCurves() +std::vector > RicPasteSummaryCurveFeature::summaryCurvesOnClipboard() { caf::PdmObjectGroup objectGroup; RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h index d0f85d3a3f..e73c87e907 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h @@ -33,12 +33,14 @@ class RicPasteSummaryCurveFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static RimSummaryCurve* copyCurveAndAddToPlot(RimSummaryCurve *sourceCurve); + protected: // Overrides virtual bool isCommandEnabled() override; virtual void onActionTriggered( bool isChecked ) override; virtual void setupActionLook(QAction* actionToSetup) override; -private: - static std::vector > summaryCurves(); + static std::vector > summaryCurvesOnClipboard(); }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp index 62a519e28f..1e5023fa52 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp @@ -27,7 +27,7 @@ #include "cafPdmDocument.h" #include "cafPdmObjectGroup.h" #include "cafPdmObjectGroup.h" -#include "cafSelectionManager.h" +#include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -36,6 +36,34 @@ CAF_CMD_SOURCE_INIT(RicPasteSummaryPlotFeature, "RicPasteSummaryPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryPlotFeature::copyPlotAndAddToCollection(RimSummaryPlot *sourcePlot) +{ + RimSummaryPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); + + if (plotColl) + { + RimSummaryPlot* newSummaryPlot = dynamic_cast(sourcePlot->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newSummaryPlot); + + plotColl->summaryPlots.push_back(newSummaryPlot); + + // Resolve references after object has been inserted into the data model + newSummaryPlot->resolveReferencesRecursively(); + newSummaryPlot->initAfterReadRecursively(); + + QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description(); + newSummaryPlot->setDescription(nameOfCopy); + + plotColl->updateConnectedEditors(); + + newSummaryPlot->loadDataAndUpdate(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -58,34 +86,11 @@ bool RicPasteSummaryPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicPasteSummaryPlotFeature::onActionTriggered(bool isChecked) { - caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); - - RimSummaryPlotCollection* plotColl = nullptr; - destinationObject->firstAncestorOrThisOfType(plotColl); - if (!plotColl) - { - return; - } - std::vector > sourceObjects = RicPasteSummaryPlotFeature::summaryPlots(); for (size_t i = 0; i < sourceObjects.size(); i++) { - RimSummaryPlot* newSummaryPlot = dynamic_cast(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); - CVF_ASSERT(newSummaryPlot); - - plotColl->summaryPlots.push_back(newSummaryPlot); - - // Resolve references after object has been inserted into the data model - newSummaryPlot->resolveReferencesRecursively(); - newSummaryPlot->initAfterReadRecursively(); - - QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description(); - newSummaryPlot->setDescription(nameOfCopy); - - plotColl->updateConnectedEditors(); - - newSummaryPlot->loadDataAndUpdate(); + copyPlotAndAddToCollection(sourceObjects[i]); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h index f80e50ea4d..fabd9844f0 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h @@ -32,6 +32,9 @@ class RicPasteSummaryPlotFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static void copyPlotAndAddToCollection(RimSummaryPlot *sourcePlot); + protected: // Overrides virtual bool isCommandEnabled() override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 3552051ff4..a457e05e2b 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -330,6 +330,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteSummaryCrossPlotFeature"; + menuBuilder << "Separator"; menuBuilder << "RicNewSummaryCrossPlotFeature"; } else if (dynamic_cast(uiItem)) @@ -358,12 +360,15 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) // This is also the definition for RimSummaryCrossPlot { menuBuilder << "RicPasteSummaryCurveFeature"; + menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "RicPasteSummaryPlotFeature"; menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature"; menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicDuplicateSummaryPlotFeature"; menuBuilder << "RicNewSummaryCurveFeature"; + menuBuilder << "RicDuplicateSummaryCrossPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicShowSummaryCurveCalculatorFeature"; @@ -377,9 +382,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicPasteSummaryCurveFeature"; + menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicNewSummaryCurveFeature"; + menuBuilder << "RicDuplicateSummaryCurveFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; + menuBuilder << "RicDuplicateSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicCopyReferencesToClipboardFeature"; menuBuilder << "Separator"; @@ -388,6 +396,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicPasteSummaryCurveFeature"; + menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicNewSummaryCurveFeature"; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index 0f7bc2e8a9..88d3116d25 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -86,13 +86,19 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos(QListsetDescription(QString("Summary Cross Plot %1").arg(m_summaryCrossPlots.size())); return plot; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCrossPlotCollection::addSummaryPlot(RimSummaryPlot *plot) +{ + m_summaryCrossPlots().push_back(plot); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h index dbff3ec2cd..472802f90d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h @@ -37,7 +37,8 @@ public: void deleteAllChildObjects(); std::vector summaryPlots() const; - RimSummaryPlot* addSummaryPlot(); + RimSummaryPlot* createSummaryPlot(); + void addSummaryPlot(RimSummaryPlot *plot); void updateSummaryNameHasChanged(); void summaryPlotItemInfos(QList* optionInfos) const; From 17ece2692958810e36c67bea88beee73bb41ad0b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 12 Dec 2017 14:26:06 +0100 Subject: [PATCH 18/22] Don't set activeReservoirView if selected RimView doesn't have RiuViewer --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 20fa554e77..f5d33114e7 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1283,8 +1283,8 @@ void RiuMainWindow::selectedObjectsChanged() if (selectedReservoirView->viewer()) { setActiveViewer(selectedReservoirView->viewer()->layoutWidget()); + isActiveViewChanged = true; } - isActiveViewChanged = true; } if (isActiveViewChanged) From 6ffcb703fdfa731afc982fb2e8b3aed4e404a898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 12 Dec 2017 15:09:52 +0100 Subject: [PATCH 19/22] #2249 Summary Plot Editor. Support for plotting individual aquifers --- .../RicPlotProductionRateFeature.cpp | 1 + .../RifEclipseSummaryAddress.cpp | 24 ++++++++++++++++++- .../FileInterface/RifEclipseSummaryAddress.h | 15 ++++++++---- .../RifEclipseUserDataKeywordTools.cpp | 10 +++++++- .../RifKeywordVectorUserData.cpp | 4 ++-- .../FileInterface/RifReaderEclipseSummary.cpp | 5 +++- .../FileInterface/RifReaderObservedData.cpp | 4 +++- .../Summary/RimSummaryAddress.cpp | 7 ++++-- .../Summary/RimSummaryAddress.h | 2 +- .../RiuSummaryCurveDefSelection.cpp | 11 +++++++-- 10 files changed, 68 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index f29b8f9b06..d6b19ae5fb 100644 --- a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -280,6 +280,7 @@ RimSummaryCurve* RicPlotProductionRateFeature::addSummaryCurve( RimSummaryPlot* "", -1, -1, + -1, -1); if (!gridSummaryCase->summaryReader()->hasAddress(addr)) diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp index c946d767e1..685e7e94b5 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -88,6 +88,9 @@ RifEclipseSummaryAddress::RifEclipseSummaryAddress(SummaryVarCategory category, m_cellJ = std::get<1>(ijkTuple); m_cellK = std::get<2>(ijkTuple); break; + case SUMMARY_AQUIFER: + m_aquiferNumber = RiaStdStringTools::toInt(identifiers[INPUT_AQUIFER_NUMBER]); + break; } // Set quantity for all categories @@ -195,6 +198,11 @@ std::string RifEclipseSummaryAddress::uiText() const text += ":" + formatUiTextIJK(); } break; + case RifEclipseSummaryAddress::SUMMARY_AQUIFER: + { + text += ":" + std::to_string(this->aquiferNumber()); + } + break; } return text; @@ -214,6 +222,7 @@ std::string RifEclipseSummaryAddress::uiText(RifEclipseSummaryAddress::SummaryId case RifEclipseSummaryAddress::INPUT_CELL_IJK: return formatUiTextIJK(); case RifEclipseSummaryAddress::INPUT_LGR_NAME: return lgrName(); case RifEclipseSummaryAddress::INPUT_SEGMENT_NUMBER: return std::to_string(wellSegmentNumber()); + case RifEclipseSummaryAddress::INPUT_AQUIFER_NUMBER: return std::to_string(aquiferNumber()); case RifEclipseSummaryAddress::INPUT_VECTOR_NAME: return quantityName(); } return ""; @@ -283,6 +292,10 @@ bool RifEclipseSummaryAddress::isValid() const if (m_cellJ == -1) return false; if (m_cellK == -1) return false; return true; + + case SUMMARY_AQUIFER: + if (m_aquiferNumber == -1) return false; + return true; } return true; @@ -409,7 +422,11 @@ bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAd if(first.cellK() != second.cellK()) return false; } break; - + case RifEclipseSummaryAddress::SUMMARY_AQUIFER: + { + if (first.aquiferNumber() != second.aquiferNumber()) return false; + } + break; } return true; } @@ -489,6 +506,11 @@ bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAdd if(first.cellK() != second.cellK()) return (first.cellK() < second.cellK()); } break; + case RifEclipseSummaryAddress::SUMMARY_AQUIFER: + { + if (first.aquiferNumber() != second.aquiferNumber()) return first.aquiferNumber() < second.aquiferNumber(); + } + break; } return false; diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h index 26ac94b481..6846cdedbf 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h @@ -59,7 +59,8 @@ public: INPUT_CELL_IJK, INPUT_LGR_NAME, INPUT_SEGMENT_NUMBER, - INPUT_VECTOR_NAME + INPUT_AQUIFER_NUMBER, + INPUT_VECTOR_NAME, }; public: @@ -71,7 +72,8 @@ public: m_wellSegmentNumber(-1), m_cellI(-1), m_cellJ(-1), - m_cellK(-1) + m_cellK(-1), + m_aquiferNumber(-1) { } @@ -85,7 +87,8 @@ public: const std::string& lgrName, int cellI, int cellJ, - int cellK): + int cellK, + int aquiferNumber): m_variableCategory(category), m_quantityName(quantityName), m_regionNumber(regionNumber), @@ -96,7 +99,8 @@ public: m_lgrName(lgrName), m_cellI(cellI), m_cellJ(cellJ), - m_cellK(cellK) + m_cellK(cellK), + m_aquiferNumber(aquiferNumber) { } @@ -124,6 +128,7 @@ public: int cellI() const { return m_cellI; } int cellJ() const { return m_cellJ; } int cellK() const { return m_cellK; } + int aquiferNumber() const { return m_aquiferNumber; } // Derived properties @@ -135,6 +140,7 @@ public: void setWellName(const std::string& wellName) { m_wellName = wellName; } void setWellGroupName(const std::string& wellGroupName) { m_wellGroupName = wellGroupName; } void setRegion(int region) { m_regionNumber = region; } + void setAquiferNumber(int aquiferNumber) { m_aquiferNumber = aquiferNumber; } private: @@ -154,6 +160,7 @@ private: int m_cellI; int m_cellJ; int m_cellK; + int m_aquiferNumber; }; bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second); diff --git a/ApplicationCode/FileInterface/RifEclipseUserDataKeywordTools.cpp b/ApplicationCode/FileInterface/RifEclipseUserDataKeywordTools.cpp index e319a3fe4b..f7fdb4fe78 100644 --- a/ApplicationCode/FileInterface/RifEclipseUserDataKeywordTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUserDataKeywordTools.cpp @@ -167,13 +167,20 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress(cons int cellI = -1; int cellJ = -1; int cellK = -1; + int aquiferNumber = -1; switch (category) { case RifEclipseSummaryAddress::SUMMARY_FIELD: break; case RifEclipseSummaryAddress::SUMMARY_AQUIFER: + { + if (columnHeaderText.size() > 0) + { + aquiferNumber = RiaStdStringTools::toInt(columnHeaderText[0]); + } break; + } case RifEclipseSummaryAddress::SUMMARY_NETWORK: break; case RifEclipseSummaryAddress::SUMMARY_MISC: @@ -268,7 +275,8 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress(cons lgrName, cellI, cellJ, - cellK); + cellK, + aquiferNumber); } diff --git a/ApplicationCode/FileInterface/RifKeywordVectorUserData.cpp b/ApplicationCode/FileInterface/RifKeywordVectorUserData.cpp index 98d8d5ee3f..b6c9e6403a 100644 --- a/ApplicationCode/FileInterface/RifKeywordVectorUserData.cpp +++ b/ApplicationCode/FileInterface/RifKeywordVectorUserData.cpp @@ -175,8 +175,8 @@ bool RifKeywordVectorUserData::parse(const QString& data, const QString& customW "", -1, -1, - -1 - ); + -1, + -1); m_allResultAddresses.push_back(addr); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 9cfa261ae2..a3aa42cf00 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -112,6 +112,7 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type * ertSu int cellI(-1); int cellJ(-1); int cellK(-1); + int aquiferNumber(-1); quantityName = smspec_node_get_keyword(ertSumVarNode); @@ -120,6 +121,7 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type * ertSu case ECL_SMSPEC_AQUIFER_VAR: { sumCategory = RifEclipseSummaryAddress::SUMMARY_AQUIFER; + aquiferNumber = smspec_node_get_num(ertSumVarNode); } break; case ECL_SMSPEC_WELL_VAR: @@ -230,7 +232,8 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type * ertSu wellName, wellSegmentNumber, lgrName, - cellI, cellJ, cellK); + cellI, cellJ, cellK, + aquiferNumber); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifReaderObservedData.cpp b/ApplicationCode/FileInterface/RifReaderObservedData.cpp index ac65811efa..7b512a42fe 100644 --- a/ApplicationCode/FileInterface/RifReaderObservedData.cpp +++ b/ApplicationCode/FileInterface/RifReaderObservedData.cpp @@ -143,6 +143,7 @@ RifEclipseSummaryAddress RifReaderObservedData::address(const QString& quantity, int cellI(-1); int cellJ(-1); int cellK(-1); + int aquiferNumber(-1); switch (summaryCategory) { @@ -167,7 +168,8 @@ RifEclipseSummaryAddress RifReaderObservedData::address(const QString& quantity, wellName, wellSegmentNumber, lgrName, - cellI, cellJ, cellK); + cellI, cellJ, cellK, + aquiferNumber); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.cpp index 817b2ec90b..6747f0a0b6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.cpp @@ -67,9 +67,10 @@ RimSummaryAddress::RimSummaryAddress() CAF_PDM_InitFieldNoDefault(&m_cellI, "SummaryCellI", "I", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_cellJ, "SummaryCellJ", "J", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_cellK, "SummaryCellK", "K", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_aquiferNumber, "SummaryAquifer", "Aquifer", "", "", ""); m_category = RifEclipseSummaryAddress::SUMMARY_INVALID; - m_regionNumber = m_regionNumber2 = m_wellSegmentNumber = m_cellI = m_cellJ = m_cellK = -1; + m_regionNumber = m_regionNumber2 = m_wellSegmentNumber = m_cellI = m_cellJ = m_cellK = m_aquiferNumber -1; } //-------------------------------------------------------------------------------------------------- @@ -93,6 +94,7 @@ void RimSummaryAddress::setAddress(const RifEclipseSummaryAddress& addr) m_wellName = addr.wellName().c_str(); m_wellSegmentNumber = addr.wellSegmentNumber(); m_lgrName = addr.lgrName().c_str(); + m_aquiferNumber = addr.aquiferNumber(); m_cellI = addr.cellI(); m_cellJ = addr.cellJ(); m_cellK = addr.cellK(); } @@ -110,6 +112,7 @@ RifEclipseSummaryAddress RimSummaryAddress::address() m_wellName().toStdString(), m_wellSegmentNumber(), m_lgrName().toStdString(), - m_cellI(), m_cellJ(), m_cellK()); + m_cellI(), m_cellJ(), m_cellK(), + m_aquiferNumber); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.h index c2519659e4..dfded3189e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAddress.h @@ -62,6 +62,6 @@ private: caf::PdmField m_cellI; caf::PdmField m_cellJ; caf::PdmField m_cellK; - + caf::PdmField m_aquiferNumber; }; diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 3449269099..996721946b 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -84,6 +84,7 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM { new SummaryIdentifierAndField(RifEclipseSummaryAddress::INPUT_VECTOR_NAME) } } }, { RifEclipseSummaryAddress::SUMMARY_AQUIFER, { + { new SummaryIdentifierAndField(RifEclipseSummaryAddress::INPUT_AQUIFER_NUMBER) }, { new SummaryIdentifierAndField(RifEclipseSummaryAddress::INPUT_VECTOR_NAME) } } }, { RifEclipseSummaryAddress::SUMMARY_NETWORK, { @@ -155,7 +156,8 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_FIELD][0]->pdmField(), "FieldVectors", "Field vectors", "", "", ""); - CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][0]->pdmField(), "AquiferVectors", "Aquifer Vectors", "", "", ""); + CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][0]->pdmField(), "Aquifers", "Aquifers", "", "", ""); + CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][1]->pdmField(), "AquiferVectors", "Aquifer Vectors", "", "", ""); CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_NETWORK][0]->pdmField(), "NetworkVectors", "Network Vectors", "", "", ""); @@ -586,7 +588,12 @@ void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::Pd } else if (sumCategory == RifEclipseSummaryAddress::SUMMARY_AQUIFER) { - summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][0]->pdmField(); + { + caf::PdmUiGroup* myGroup = uiOrdering.addNewGroup("Aquifers"); + myGroup->add(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][0]->pdmField()); + } + + summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][1]->pdmField(); } else if (sumCategory == RifEclipseSummaryAddress::SUMMARY_NETWORK) { From f11df61ff2e58ef4c20b2ecb75b22251da0eb0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 12 Dec 2017 15:17:04 +0100 Subject: [PATCH 20/22] Fix Linux build error --- ApplicationCode/UnitTests/ObservedDataParser-Test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp b/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp index f7a9d0eb59..a6faa68345 100644 --- a/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp +++ b/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp @@ -412,7 +412,7 @@ TEST(RifColumnBasedRsmspecParserTest, TestTableValues) RifColumnBasedUserData userData; userData.parse(data); - RifEclipseSummaryAddress adr(RifEclipseSummaryAddress::SUMMARY_WELL, "WLVP", -1, -1, "", "P-15P", -1, "", -1, -1, -1); + RifEclipseSummaryAddress adr(RifEclipseSummaryAddress::SUMMARY_WELL, "WLVP", -1, -1, "", "P-15P", -1, "", -1, -1, -1, -1); QDateTime firstTimeStep = RiaQDateTimeTools::addDays(RiaQDateTimeTools::epoch(), 1.0); auto timeSteps = userData.timeSteps(adr); From 5a0378332800797b5940c69799da2b68d6022862 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 12 Dec 2017 15:32:12 +0100 Subject: [PATCH 21/22] #2209 Use correct view in cmd "Export Visible Cells as FLUXNUM/MULTNUM" --- ...RicSaveEclipseInputVisibleCellsFeature.cpp | 78 ++++++++++++++----- .../RicSaveEclipseInputVisibleCellsFeature.h | 26 +++++-- .../UserInterface/RiuViewerCommands.cpp | 2 +- 3 files changed, 81 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp index d2982bc7bf..e05e051e98 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp @@ -43,23 +43,15 @@ #include #include +CAF_CMD_SOURCE_INIT(RicSaveEclipseInputActiveVisibleCellsFeature, "RicSaveEclipseInputActiveVisibleCellsFeature"); CAF_CMD_SOURCE_INIT(RicSaveEclipseInputVisibleCellsFeature, "RicSaveEclipseInputVisibleCellsFeature"); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicSaveEclipseInputVisibleCellsFeature::isCommandEnabled() -{ - return getSelectedEclipseView() != nullptr; -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSaveEclipseInputVisibleCellsFeature::onActionTriggered(bool isChecked) +void executeCommand(RimEclipseView* view) { - RimEclipseView* view = getEclipseActiveView(); - RicSaveEclipseInputVisibleCellsUi exportSettings; caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export FLUXNUM/MULTNUM", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); @@ -99,6 +91,23 @@ void RicSaveEclipseInputVisibleCellsFeature::onActionTriggered(bool isChecked) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSaveEclipseInputVisibleCellsFeature::isCommandEnabled() +{ + return selectedView() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveEclipseInputVisibleCellsFeature::onActionTriggered(bool isChecked) +{ + RimEclipseView* view = RicSaveEclipseInputVisibleCellsFeature::selectedView(); + executeCommand(view); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -110,17 +119,50 @@ void RicSaveEclipseInputVisibleCellsFeature::setupActionLook(QAction* actionToSe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseView* RicSaveEclipseInputVisibleCellsFeature::getEclipseActiveView() +RimEclipseView* RicSaveEclipseInputVisibleCellsFeature::selectedView() +{ + RimEclipseView* view = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + return view; +} + + + + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSaveEclipseInputActiveVisibleCellsFeature::isCommandEnabled() +{ + return getEclipseActiveView() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveEclipseInputActiveVisibleCellsFeature::onActionTriggered(bool isChecked) +{ + RimEclipseView* view = RicSaveEclipseInputActiveVisibleCellsFeature::getEclipseActiveView(); + executeCommand(view); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveEclipseInputActiveVisibleCellsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Visible Cells as FLUXNUM/MULTNUM"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RicSaveEclipseInputActiveVisibleCellsFeature::getEclipseActiveView() { RimView* activeView = RiaApplication::instance()->activeReservoirView(); return dynamic_cast(activeView); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEclipseView * RicSaveEclipseInputVisibleCellsFeature::getSelectedEclipseView() -{ - return dynamic_cast(caf::SelectionManager::instance()->selectedItem()); -} diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h index 6c7290359e..2ea5e15043 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h @@ -31,12 +31,26 @@ class RicSaveEclipseInputVisibleCellsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides - virtual bool isCommandEnabled(); - virtual void onActionTriggered( bool isChecked ); - virtual void setupActionLook( QAction* actionToSetup ); + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; private: - RimEclipseView* getEclipseActiveView(); - RimEclipseView* getSelectedEclipseView(); + RimEclipseView* selectedView(); +}; + +//================================================================================================== +/// +//================================================================================================== +class RicSaveEclipseInputActiveVisibleCellsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; + +private: + static RimEclipseView* getEclipseActiveView(); }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 3731d4f762..09583061a8 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -389,7 +389,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); menuBuilder << "RicNewGridTimeHistoryCurveFeature"; menuBuilder << "RicShowFlowCharacteristicsPlotFeature"; - menuBuilder << "RicSaveEclipseInputVisibleCellsFeature"; + menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; menuBuilder << "RicShowGridStatisticsFeature"; menuBuilder.appendToMenu(&menu); From 2b0305fcc4e42a04fa72c8043812fad14a431347 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 12 Dec 2017 16:07:02 +0100 Subject: [PATCH 22/22] #2247 Add export FLIXNUM/MULTNUM to context menu on Cell Result item in tree view --- ...RicSaveEclipseInputVisibleCellsFeature.cpp | 20 +++++++++++++++---- .../RicSaveEclipseInputVisibleCellsFeature.h | 2 +- .../RimContextCommandBuilder.cpp | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp index e05e051e98..904961b458 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp @@ -27,12 +27,13 @@ #include "RifEclipseInputFileTools.h" -#include "RimView.h" -#include "RimEclipseView.h" #include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimView.h" -#include "RigEclipseCaseData.h" #include "RigActiveCellInfo.h" +#include "RigEclipseCaseData.h" #include "RiuMainWindow.h" @@ -119,9 +120,20 @@ void RicSaveEclipseInputVisibleCellsFeature::setupActionLook(QAction* actionToSe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseView* RicSaveEclipseInputVisibleCellsFeature::selectedView() +RimEclipseView* RicSaveEclipseInputVisibleCellsFeature::selectedView() const { RimEclipseView* view = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (view) + { + return view; + } + + RimEclipseCellColors* cellResultItem = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (cellResultItem) + { + cellResultItem->firstAncestorOrThisOfType(view); + } + return view; } diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h index 2ea5e15043..35b0f38d03 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h @@ -36,7 +36,7 @@ protected: virtual void setupActionLook(QAction* actionToSetup) override; private: - RimEclipseView* selectedView(); + RimEclipseView* selectedView() const; }; //================================================================================================== diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index a457e05e2b..4c53911441 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -185,6 +185,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicSaveEclipseResultAsInputPropertyFeature"; + menuBuilder << "RicSaveEclipseInputVisibleCellsFeature"; } else if (dynamic_cast(uiItem)) {