From 388dcd35524c00a814133d21bb69dc922190f11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 15 Sep 2017 11:49:09 +0200 Subject: [PATCH] #1886 curve creator. Populate curve creator and copy curves back to target plot --- .../RicSummaryCurveCreator.cpp | 87 ++++++++++++------- .../RicSummaryCurveCreator.h | 9 +- .../Summary/RimSummaryPlot.cpp | 8 ++ .../ProjectDataModel/Summary/RimSummaryPlot.h | 1 + 4 files changed, 71 insertions(+), 34 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 3c8cda1014..cddb4101b4 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -197,15 +197,24 @@ RicSummaryCurveCreator::RicSummaryCurveCreator() : m_identifierFieldsMap( //-------------------------------------------------------------------------------------------------- RicSummaryCurveCreator::~RicSummaryCurveCreator() { - for (const auto& itemTypes : m_identifierFieldsMap) + for (const auto& identifierAndFieldList : m_identifierFieldsMap) { - for (const auto& itemTypeInput : itemTypes.second) + for (const auto& identifierAndField : identifierAndFieldList.second) { - delete itemTypeInput->pdmField(); + delete identifierAndField->pdmField(); } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::setTargetPlot(RimSummaryPlot* targetPlot) +{ + m_targetPlot = targetPlot; + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -244,10 +253,6 @@ QList RicSummaryCurveCreator::calculateValueOptions(cons { options.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), rimCase)); } - } - else if (fieldNeedingOptions == &m_previewPlot) - { - } else { @@ -262,7 +267,7 @@ QList RicSummaryCurveCreator::calculateValueOptions(cons for (const auto& address : addrUnion) { - auto name = getIdentifierTextFromAddress(identifierAndField->summaryIdentifier(), address); + auto name = QString::fromStdString(address.uiText(identifierAndField->summaryIdentifier())); if (!name.isEmpty()) itemNames.insert(name); } @@ -511,27 +516,6 @@ std::vector RicSummaryCurveC return selections; } -//-------------------------------------------------------------------------------------------------- -/// Returns the stringified value for the specified value in the specfied address object -/// Todo: Move this method to RicElipseSummaryAddress class -//-------------------------------------------------------------------------------------------------- -QString RicSummaryCurveCreator::getIdentifierTextFromAddress(RifEclipseSummaryAddress::SummaryIdentifierType itemTypeInput, const RifEclipseSummaryAddress &address) -{ - switch (itemTypeInput) - { - case RifEclipseSummaryAddress::INPUT_REGION_NUMBER: return QString("%1").arg(address.regionNumber()); - case RifEclipseSummaryAddress::INPUT_REGION2_NUMBER: return QString("%1").arg(address.regionNumber2()); - case RifEclipseSummaryAddress::INPUT_WELL_NAME: return QString::fromStdString(address.wellName()); - case RifEclipseSummaryAddress::INPUT_WELL_GROUP_NAME: return QString::fromStdString(address.wellGroupName()); - case RifEclipseSummaryAddress::INPUT_CELL_IJK: return QString("%1,%2,%3").arg(QString::number(address.cellI()), - QString::number(address.cellJ()), QString::number(address.cellK())); - case RifEclipseSummaryAddress::INPUT_LGR_NAME: return QString::fromStdString(address.lgrName()); - case RifEclipseSummaryAddress::INPUT_SEGMENT_NUMBER: return QString("%1").arg(address.wellSegmentNumber()); - case RifEclipseSummaryAddress::INPUT_VECTOR_NAME: return QString::fromStdString(address.quantityName()); - } - return ""; -} - //-------------------------------------------------------------------------------------------------- /// Returns pdm field info from the specified pdm field //-------------------------------------------------------------------------------------------------- @@ -579,9 +563,9 @@ bool RicSummaryCurveCreator::isAddressSelected(const RifEclipseSummaryAddress &a for (const auto& identifierAndField : identifierAndFieldList) { bool match = false; - for (const auto& selection : identifierAndField->pdmField()->v()) + for (const auto& selectedText : identifierAndField->pdmField()->v()) { - if (QString::compare(getIdentifierTextFromAddress(identifierAndField->summaryIdentifier(), address), selection) == 0) + if (QString::compare(QString::fromStdString(address.uiText(identifierAndField->summaryIdentifier())), selectedText) == 0) { match = true; break; @@ -854,3 +838,44 @@ std::set RicSummaryCurveCreator::getAllSummaryWellNames() } return summaryWellNames; } + +//-------------------------------------------------------------------------------------------------- +/// Populate curve creator from the given curve collection +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot) +{ + for (const auto& curve : sourceSummaryPlot.summaryCurves()) + { + // Select case if not already selected + if (std::find(m_selectedCases.begin(), m_selectedCases.end(), curve->summaryCase()) != m_selectedCases.end()) + { + m_selectedCases.push_back(curve->summaryCase()); + } + + auto identifierAndFieldList = m_identifierFieldsMap[curve->summaryAddress().category()]; + for (const auto& identifierAndField : identifierAndFieldList) + { + auto& pdmField = *identifierAndField->pdmField(); + auto currentSelections = pdmField(); + currentSelections.push_back(QString::fromStdString(curve->summaryAddress().uiText(identifierAndField->summaryIdentifier()))); + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// Copy curves from +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::updateTargetPlot() +{ + // Q: What about hidden curves? + + if (m_targetPlot == nullptr) + m_targetPlot = new RimSummaryPlot(); + + for (const auto& curve : m_previewPlot->summaryCurves()) + { + m_targetPlot->addCurve(curve); + } + m_targetPlot->loadDataAndUpdate(); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index 5e2262d6e3..c3b73e1441 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -75,6 +75,8 @@ public: virtual ~RicSummaryCurveCreator(); RimSummaryPlot* previewPlot() { return m_previewPlot;} + void setTargetPlot(RimSummaryPlot* targetPlot); + private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, @@ -85,8 +87,6 @@ private: std::set findPossibleSummaryAddresses(const SummaryIdentifierAndField *identifierAndField); std::vector buildControllingFieldList(const SummaryIdentifierAndField *identifierAndField); - QString getIdentifierTextFromAddress(RifEclipseSummaryAddress::SummaryIdentifierType itemTypeInput, - const RifEclipseSummaryAddress &address); SummaryIdentifierAndField* findIdentifierAndField(const caf::PdmFieldHandle* pdmFieldHandle); SummaryIdentifierAndField* lookupControllingField(const SummaryIdentifierAndField *identifierAndField); bool isAddressSelected(const RifEclipseSummaryAddress &address, @@ -104,13 +104,16 @@ private: std::set getAllSummaryCaseNames(); std::set getAllSummaryWellNames(); + void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot); + void updateTargetPlot(); + private: caf::PdmPtrArrayField m_selectedCases; caf::PdmField> m_selectedSummaryCategory; std::map> m_identifierFieldsMap; + caf::PdmPtrField m_targetPlot; caf::PdmChildField m_previewPlot; - //caf::PdmField> m_selectedCurveTexts; caf::PdmField m_useAutoAppearanceAssignment; caf::PdmField< AppearanceTypeAppEnum > m_caseAppearanceType; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 1aec23c3ee..c7620a2d3b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -462,6 +462,14 @@ std::vector RimSummaryPlot::summaryCurves() const return curves; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::deleteAllCurves() +{ + m_summaryCurveCollection->curves().clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 5220138401..afe996bbf1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -100,6 +100,7 @@ public: QString asciiDataForPlotExport() const; std::vector summaryCurves() const; + void deleteAllCurves(); // RimViewWindow overrides public: