mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8746 from OPM/patch-fixes
Merge fixes from patch branch
This commit is contained in:
commit
64d35859a7
@ -20,6 +20,8 @@
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "RiaResultNames.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
namespace caf
|
||||
@ -162,7 +164,8 @@ void caf::AppEnum<RiaDefines::RowCount>::setUp()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaDefines::isNativeCategoryResult( const QString& resultName )
|
||||
{
|
||||
return resultName.endsWith( "NUM" );
|
||||
return resultName.endsWith( "NUM" ) || resultName == RiaResultNames::indexIResultName() ||
|
||||
resultName == RiaResultNames::indexJResultName() || resultName == RiaResultNames::indexKResultName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -23,17 +23,32 @@
|
||||
#include <cctype>
|
||||
#include <charconv>
|
||||
|
||||
const std::string WHITESPACE = " \n\r\t\f\v";
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RiaStdStringTools::leftTrimString( const std::string& s )
|
||||
{
|
||||
size_t start = s.find_first_not_of( WHITESPACE );
|
||||
return ( start == std::string::npos ) ? "" : s.substr( start );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RiaStdStringTools::rightTrimString( const std::string& s )
|
||||
{
|
||||
size_t end = s.find_last_not_of( WHITESPACE );
|
||||
return ( end == std::string::npos ) ? "" : s.substr( 0, end + 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RiaStdStringTools::trimString( const std::string& s )
|
||||
{
|
||||
if ( s.empty() ) return s;
|
||||
|
||||
auto sCopy = s.substr( 0, s.find_last_not_of( ' ' ) + 1 );
|
||||
sCopy = sCopy.substr( sCopy.find_first_not_of( ' ' ) );
|
||||
|
||||
return sCopy;
|
||||
return rightTrimString( leftTrimString( s ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -31,7 +31,10 @@ class RiaStdStringTools
|
||||
{
|
||||
public:
|
||||
static std::string trimString( const std::string& s );
|
||||
static bool isNumber( const std::string& s, char decimalPoint );
|
||||
static std::string rightTrimString( const std::string& s );
|
||||
static std::string leftTrimString( const std::string& s );
|
||||
|
||||
static bool isNumber( const std::string& s, char decimalPoint );
|
||||
|
||||
static int16_t toInt16( const std::string& s );
|
||||
static int toInt( const std::string& s );
|
||||
|
@ -78,7 +78,7 @@ void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered( bool isChecked )
|
||||
QString text = getPastedData();
|
||||
|
||||
RicPasteAsciiDataToSummaryPlotFeatureUi pasteOptions;
|
||||
caf::PdmSettings::readFieldsFromApplicationStore( &pasteOptions );
|
||||
caf::PdmSettings::readFieldsFromApplicationStore( &pasteOptions, pasteOptions.contextString() );
|
||||
if ( !summaryPlot ) pasteOptions.createNewPlot();
|
||||
pasteOptions.setUiModePasteText( text );
|
||||
|
||||
@ -101,7 +101,7 @@ void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered( bool isChecked )
|
||||
summaryPlotCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
caf::PdmSettings::writeFieldsToApplicationStore( &pasteOptions );
|
||||
caf::PdmSettings::writeFieldsToApplicationStore( &pasteOptions, pasteOptions.contextString() );
|
||||
|
||||
for ( RimAsciiDataCurve* curve : curves )
|
||||
{
|
||||
|
@ -551,3 +551,11 @@ void RicPasteAsciiDataToSummaryPlotFeatureUi::updatePreviewTextAndDateFormat()
|
||||
|
||||
m_dateFormat = df;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicPasteAsciiDataToSummaryPlotFeatureUi::contextString() const
|
||||
{
|
||||
return QString( "AsciiDataToSummarySettings" );
|
||||
}
|
@ -131,6 +131,8 @@ public:
|
||||
const AsciiDataParseOptions parseOptions() const;
|
||||
void createNewPlot();
|
||||
|
||||
QString contextString() const;
|
||||
|
||||
static DateFormat dateFormatFromString( const QString& dateString );
|
||||
|
||||
protected:
|
||||
|
@ -89,7 +89,7 @@ void RifSurfaceImporter::readGocadFile( const QString& filename, RigGocadData* g
|
||||
auto tokens = RiaStdStringTools::splitString( line, ' ' );
|
||||
|
||||
std::string firstToken;
|
||||
if ( !tokens.empty() ) firstToken = tokens.front();
|
||||
if ( !tokens.empty() ) firstToken = RiaStdStringTools::trimString( tokens.front() );
|
||||
|
||||
if ( isInTfaceSection )
|
||||
{
|
||||
|
@ -204,14 +204,16 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateSurfaceIntersection
|
||||
|
||||
cvf::Vec3d intersectionPoint;
|
||||
bool foundMatch = RigSurfaceResampler::resamplePoint( surface, pointAbove, pointBelow, intersectionPoint );
|
||||
if ( !foundMatch )
|
||||
intersectionPoint = cvf::Vec3d( point.x(), point.y(), std::numeric_limits<double>::infinity() );
|
||||
|
||||
const size_t lineIndex = 0;
|
||||
transformedSurfacePolyline.push_back(
|
||||
transformPointByPolylineSegmentIndex( intersectionPoint, lineIndex, segmentIndex ) );
|
||||
if ( foundMatch )
|
||||
{
|
||||
const size_t lineIndex = 0;
|
||||
transformedSurfacePolyline.push_back(
|
||||
transformPointByPolylineSegmentIndex( intersectionPoint, lineIndex, segmentIndex ) );
|
||||
}
|
||||
}
|
||||
m_transformedSurfaceIntersectionPolylines[rimSurface] = transformedSurfacePolyline;
|
||||
|
||||
if ( !transformedSurfacePolyline.empty() )
|
||||
m_transformedSurfaceIntersectionPolylines[rimSurface] = transformedSurfacePolyline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,9 +109,11 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicLi
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = createPart( centerColorPairs, wellResultFrame->m_isOpen );
|
||||
|
||||
model->addPart( part.p() );
|
||||
if ( !centerColorPairs.empty() )
|
||||
{
|
||||
cvf::ref<cvf::Part> part = createPart( centerColorPairs, wellResultFrame->m_isOpen );
|
||||
model->addPart( part.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -1071,7 +1071,8 @@ double RimEclipseCase::characteristicCellSize() const
|
||||
const RigEclipseCaseData* rigEclipseCase = eclipseCaseData();
|
||||
if ( rigEclipseCase && rigEclipseCase->mainGrid() )
|
||||
{
|
||||
return rigEclipseCase->mainGrid()->characteristicIJCellSize();
|
||||
double maxSize = 200.0;
|
||||
return std::min( rigEclipseCase->mainGrid()->characteristicIJCellSize(), maxSize );
|
||||
}
|
||||
|
||||
return 10.0;
|
||||
|
@ -219,8 +219,10 @@ std::vector<double> RimEclipseContourMapProjection::generateResults( int timeSte
|
||||
}
|
||||
gridResultValues = calculateColumnResult( m_resultAggregation() );
|
||||
}
|
||||
else if ( !( cellColors->hasStaticResult() && timeStep > 0 ) )
|
||||
else
|
||||
{
|
||||
if ( cellColors->hasStaticResult() && timeStep > 0 ) timeStep = 0;
|
||||
|
||||
m_currentResultName = cellColors->resultVariable();
|
||||
RigEclipseResultAddress resAddr( cellColors->resultType(),
|
||||
cellColors->resultVariable(),
|
||||
|
@ -169,6 +169,14 @@ void RimEclipseContourMapView::initAfterRead()
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseContourMapView::isTimeStepDependentDataVisible() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -552,3 +560,12 @@ void RimEclipseContourMapView::onLegendConfigChanged( const caf::SignalEmitter*
|
||||
m_contourMapProjection->clearGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurfaceInViewCollection* RimEclipseContourMapView::surfaceInViewCollection() const
|
||||
{
|
||||
// Surfaces should not be shown in contour map.
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
void setDefaultCustomName();
|
||||
void updatePickPointAndRedraw();
|
||||
|
||||
RimSurfaceInViewCollection* surfaceInViewCollection() const override;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
void onCreateDisplayModel() override;
|
||||
@ -58,6 +60,8 @@ protected:
|
||||
void onLoadDataAndUpdate() override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
bool isTimeStepDependentDataVisible() const override;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
std::set<RivCellSetEnum> allVisibleFaultGeometryTypes() const override;
|
||||
|
@ -590,9 +590,10 @@ void RimEclipseView::onCreateDisplayModel()
|
||||
// Surfaces
|
||||
|
||||
m_surfaceVizModel->removeAllParts();
|
||||
if ( m_surfaceCollection )
|
||||
if ( surfaceInViewCollection() )
|
||||
{
|
||||
m_surfaceCollection->appendPartsToModel( m_surfaceVizModel.p(), m_reservoirGridPartManager->scaleTransform() );
|
||||
surfaceInViewCollection()->appendPartsToModel( m_surfaceVizModel.p(),
|
||||
m_reservoirGridPartManager->scaleTransform() );
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
@ -905,7 +906,8 @@ void RimEclipseView::updateVisibleCellColors()
|
||||
bool hasGeneralCellResult = this->cellResult()->hasResult() || this->cellResult()->isTernarySaturationSelected();
|
||||
|
||||
m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep );
|
||||
if ( m_surfaceCollection ) m_surfaceCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep );
|
||||
if ( surfaceInViewCollection() )
|
||||
surfaceInViewCollection()->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -2284,9 +2286,9 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
|
||||
absLegends.push_back( wellMeasurement->legendConfig() );
|
||||
}
|
||||
|
||||
if ( m_surfaceCollection )
|
||||
if ( surfaceInViewCollection() )
|
||||
{
|
||||
for ( auto legendConfig : m_surfaceCollection->legendConfigs() )
|
||||
for ( auto legendConfig : surfaceInViewCollection()->legendConfigs() )
|
||||
{
|
||||
absLegends.push_back( legendConfig );
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();
|
||||
|
||||
RimIntersectionCollection* intersectionCollection() const;
|
||||
RimSurfaceInViewCollection* surfaceInViewCollection() const;
|
||||
virtual RimSurfaceInViewCollection* surfaceInViewCollection() const;
|
||||
RimIntersectionResultsDefinitionCollection* separateIntersectionResultsCollection() const;
|
||||
RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const;
|
||||
RimAnnotationInViewCollection* annotationCollection() const;
|
||||
|
@ -179,10 +179,11 @@ RimObservedSummaryData*
|
||||
|
||||
if ( useSavedFieldsValuesInDialog )
|
||||
{
|
||||
caf::PdmSettings::readFieldsFromApplicationStore( parseOptions );
|
||||
caf::PdmSettings::readFieldsFromApplicationStore( parseOptions, parseOptions->contextString() );
|
||||
}
|
||||
parseOptions->setUiModeImport( fileName );
|
||||
|
||||
bool parseOptionsChanged = false;
|
||||
if ( parseOptions->uiModeImport() != RicPasteAsciiDataToSummaryPlotFeatureUi::UI_MODE_SILENT )
|
||||
{
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( nullptr, parseOptions, "CSV Import Options", "" );
|
||||
@ -190,9 +191,14 @@ RimObservedSummaryData*
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
parseOptionsChanged = true;
|
||||
}
|
||||
|
||||
caf::PdmSettings::writeFieldsToApplicationStore( parseOptions );
|
||||
if ( useSavedFieldsValuesInDialog && parseOptionsChanged )
|
||||
{
|
||||
caf::PdmSettings::writeFieldsToApplicationStore( parseOptions, parseOptions->contextString() );
|
||||
}
|
||||
|
||||
// userData->setParseOptions(parseOptionsUi.parseOptions());
|
||||
userData->setSummaryHeaderFileName( fileName );
|
||||
|
@ -59,6 +59,72 @@ TEST( RiaStdStringToolsTest, TrimStrings )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaStdStringToolsTest, TrimString )
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> testData = {
|
||||
std::make_pair( " bla ", "bla" ),
|
||||
std::make_pair( "bla ", "bla" ),
|
||||
std::make_pair( " bla", "bla" ),
|
||||
std::make_pair( "\tbla", "bla" ),
|
||||
std::make_pair( "\tbla \n\t", "bla" ),
|
||||
std::make_pair( "\tbla\v", "bla" ),
|
||||
std::make_pair( "bla", "bla" ),
|
||||
std::make_pair( "", "" ),
|
||||
};
|
||||
|
||||
for ( auto [input, expectedText] : testData )
|
||||
{
|
||||
EXPECT_EQ( RiaStdStringTools::trimString( input ), expectedText );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaStdStringToolsTest, LeftTrimString )
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> testData = {
|
||||
std::make_pair( " bla ", "bla " ),
|
||||
std::make_pair( "bla ", "bla " ),
|
||||
std::make_pair( " bla", "bla" ),
|
||||
std::make_pair( "\tbla", "bla" ),
|
||||
std::make_pair( "\tbla \n\t", "bla \n\t" ),
|
||||
std::make_pair( "\tbla\v", "bla\v" ),
|
||||
std::make_pair( "bla", "bla" ),
|
||||
std::make_pair( "", "" ),
|
||||
};
|
||||
|
||||
for ( auto [input, expectedText] : testData )
|
||||
{
|
||||
EXPECT_EQ( RiaStdStringTools::leftTrimString( input ), expectedText );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaStdStringToolsTest, RightTrimString )
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> testData = {
|
||||
std::make_pair( " bla ", " bla" ),
|
||||
std::make_pair( "bla ", "bla" ),
|
||||
std::make_pair( " bla", " bla" ),
|
||||
std::make_pair( "\tbla", "\tbla" ),
|
||||
std::make_pair( "\tbla \n\t", "\tbla" ),
|
||||
std::make_pair( "\tbla\v", "\tbla" ),
|
||||
std::make_pair( "bla", "bla" ),
|
||||
std::make_pair( "", "" ),
|
||||
};
|
||||
|
||||
for ( auto [input, expectedText] : testData )
|
||||
{
|
||||
EXPECT_EQ( RiaStdStringTools::rightTrimString( input ), expectedText );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user