mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1923 Replace int-based vector selection list with a summaryaddress based one
This removes a loop over all the adresses in the summary case for each curve, and makes the highlight of the selection more stable
This commit is contained in:
parent
f4eadc5cef
commit
f9b26ce104
@ -24,6 +24,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderSettings.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddressQMetaType.h
|
||||
${CEE_CURRENT_LIST_DIR}RifWellPathImporter.h
|
||||
${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.h
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
Q_DECLARE_METATYPE(RifEclipseSummaryAddress);
|
||||
|
@ -40,6 +40,20 @@
|
||||
|
||||
#include "qwt_date.h"
|
||||
|
||||
// See also corresponding fake implementations in RimSummaryCurveFilter
|
||||
|
||||
QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj)
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
return str;
|
||||
}
|
||||
|
||||
QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj)
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryAddress, "SummaryAddress");
|
||||
|
||||
@ -311,27 +325,21 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
|
||||
if(m_summaryCase)
|
||||
{
|
||||
RifSummaryReaderInterface* reader = summaryReader();
|
||||
int addressCount = 0;
|
||||
if(reader)
|
||||
{
|
||||
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
|
||||
addressCount = static_cast<int>(allAddresses.size());
|
||||
std::map<RifEclipseSummaryAddress, int> addrToIdxMap;
|
||||
for(int i = 0; i <addressCount; i++)
|
||||
{
|
||||
if (!m_summaryFilter->isIncludedByFilter(allAddresses[i] )) continue;
|
||||
addrToIdxMap[allAddresses[i]] = i;
|
||||
}
|
||||
|
||||
for (const auto& addrIntPair: addrToIdxMap)
|
||||
for(auto& address : allAddresses)
|
||||
{
|
||||
std::string name = addrIntPair.first.uiText();
|
||||
if (!m_summaryFilter->isIncludedByFilter(address )) continue;
|
||||
|
||||
std::string name = address.uiText();
|
||||
QString s = QString::fromStdString(name);
|
||||
options.push_back(caf::PdmOptionItemInfo(s, addrIntPair.second));
|
||||
options.push_back(caf::PdmOptionItemInfo(s, QVariant::fromValue( address)));
|
||||
}
|
||||
}
|
||||
|
||||
options.push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), addressCount));
|
||||
options.push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue( RifEclipseSummaryAddress() )));
|
||||
|
||||
if(useOptionsOnly) *useOptionsOnly = true;
|
||||
}
|
||||
@ -366,22 +374,12 @@ void RimSummaryCurve::onLoadDataAndUpdate()
|
||||
{
|
||||
this->RimPlotCurve::updateCurvePresentation();
|
||||
|
||||
updateCurveAppearance();
|
||||
|
||||
m_selectedVariableDisplayField = QString::fromStdString(m_curveVariable->address().uiText());
|
||||
|
||||
RifSummaryReaderInterface* reader = summaryReader();
|
||||
if (reader)
|
||||
{
|
||||
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
|
||||
|
||||
for (size_t i = 0; i < allAddresses.size(); i++)
|
||||
{
|
||||
if (allAddresses[i].uiText() == m_curveVariable->address().uiText())
|
||||
{
|
||||
m_uiFilterResultSelection = static_cast<int>(i);
|
||||
updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
m_uiFilterResultSelection = m_curveVariable->address();
|
||||
updateConnectedEditors();
|
||||
|
||||
if (isCurveVisible())
|
||||
{
|
||||
@ -502,21 +500,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
|
||||
if(changedField == &m_uiFilterResultSelection)
|
||||
{
|
||||
if (summaryReader())
|
||||
{
|
||||
if (0 <= m_uiFilterResultSelection() && static_cast<size_t>(m_uiFilterResultSelection()) < summaryReader()->allResultAddresses().size())
|
||||
{
|
||||
m_curveVariable->setAddress(summaryReader()->allResultAddresses()[m_uiFilterResultSelection()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curveVariable->setAddress(RifEclipseSummaryAddress());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curveVariable->setAddress(RifEclipseSummaryAddress());
|
||||
}
|
||||
m_curveVariable->setAddress(m_uiFilterResultSelection());
|
||||
|
||||
this->calculateCurveInterpolationFromAddress();
|
||||
this->loadDataAndUpdate();
|
||||
|
@ -25,19 +25,19 @@
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifEclipseSummaryAddressQMetaType.h"
|
||||
#include "RiaDefines.h"
|
||||
#include "RimPlotCurve.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
|
||||
class RifSummaryReaderInterface;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryFilter;
|
||||
class RiuLineSegmentQwtPlotCurve;
|
||||
class RimSummaryCurveAutoName;
|
||||
|
||||
|
||||
class RimSummaryAddress: public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
@ -124,5 +124,5 @@ private:
|
||||
|
||||
// Filter fields
|
||||
caf::PdmChildField<RimSummaryFilter*> m_summaryFilter;
|
||||
caf::PdmField<int> m_uiFilterResultSelection;
|
||||
caf::PdmField<RifEclipseSummaryAddress> m_uiFilterResultSelection;
|
||||
};
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
// See also corresponding fake implementations in RimSummaryCurve
|
||||
|
||||
QTextStream& operator << (QTextStream& str, const std::vector<RifEclipseSummaryAddress>& sobj)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifEclipseSummaryAddressQMetaType.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
@ -43,7 +43,7 @@ class RiuLineSegmentQwtPlotCurve;
|
||||
class RimSummaryCurveAutoName;
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(RifEclipseSummaryAddress);
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user