mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8310 Summary Plot Manager : Add data source filtering
This commit is contained in:
@@ -48,6 +48,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaValidRegExpValidator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaVec3Tools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaEnsembleNameTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -93,6 +94,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaValidRegExpValidator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaEnsembleNameTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaVec3Tools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
|
||||
|
||||
110
ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp
Normal file
110
ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021 Equinor 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaSummaryStringTools.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryStringTools::splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryCase,
|
||||
const QStringList& addressFilters,
|
||||
QStringList* summaryAddressFilters,
|
||||
QStringList* gridResultAddressFilters )
|
||||
{
|
||||
if ( summaryCase )
|
||||
{
|
||||
const std::set<RifEclipseSummaryAddress>& addrs = summaryCase->summaryReader()->allResultAddresses();
|
||||
|
||||
QRegularExpression gridAddressPattern( "^[A-Z]+:[0-9]+,[0-9]+,[0-9]+$" );
|
||||
|
||||
for ( int filterIdx = 0; filterIdx < addressFilters.size(); ++filterIdx )
|
||||
{
|
||||
const QString& address = addressFilters[filterIdx];
|
||||
if ( hasFilterAnyMatch( address, addrs ) )
|
||||
{
|
||||
summaryAddressFilters->push_back( address );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( gridAddressPattern.match( address ).hasMatch() )
|
||||
{
|
||||
gridResultAddressFilters->push_back( address );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaLogging::warning( "No summary or restart vectors matched \"" + address + "\"" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaSummaryStringTools::hasFilterAnyMatch( const QString& curveFilter,
|
||||
const std::set<RifEclipseSummaryAddress>& summaryAddresses )
|
||||
{
|
||||
for ( const auto& addr : summaryAddresses )
|
||||
{
|
||||
if ( addr.isUiTextMatchingFilterText( curveFilter ) ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Sort filters into curve and data source filters
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryStringTools::splitIntoAddressAndDataSourceFilters( const QStringList& filters,
|
||||
const QStringList& dataSourceNames,
|
||||
QStringList& addressFilters,
|
||||
QStringList& dataSourceFilters )
|
||||
{
|
||||
for ( const auto& s : filters )
|
||||
{
|
||||
// Strip off realization filter from ensemble search string
|
||||
|
||||
QString pureDataSourceCandidate = s.left( s.indexOf( ':' ) );
|
||||
|
||||
bool foundDataSource = false;
|
||||
|
||||
QRegExp searcher( pureDataSourceCandidate, Qt::CaseInsensitive, QRegExp::WildcardUnix );
|
||||
|
||||
for ( const auto& ds : dataSourceNames )
|
||||
{
|
||||
if ( !foundDataSource && searcher.exactMatch( ds ) )
|
||||
{
|
||||
dataSourceFilters.push_back( s );
|
||||
foundDataSource = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !foundDataSource )
|
||||
{
|
||||
addressFilters.push_back( s );
|
||||
}
|
||||
}
|
||||
}
|
||||
46
ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h
Normal file
46
ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021 Equinor 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 <set>
|
||||
|
||||
class RimSummaryCase;
|
||||
class RifEclipseSummaryAddress;
|
||||
|
||||
class QString;
|
||||
class QStringList;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiaSummaryStringTools
|
||||
{
|
||||
public:
|
||||
static void splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryCase,
|
||||
const QStringList& addressFilters,
|
||||
QStringList* summaryAddressFilters,
|
||||
QStringList* gridResultAddressFilters );
|
||||
|
||||
static bool hasFilterAnyMatch( const QString& curveFilter, const std::set<RifEclipseSummaryAddress>& summaryAddresses );
|
||||
|
||||
static void splitIntoAddressAndDataSourceFilters( const QStringList& filters,
|
||||
const QStringList& dataSourceNames,
|
||||
QStringList& addressFilters,
|
||||
QStringList& dataSourceFilters );
|
||||
};
|
||||
Reference in New Issue
Block a user