mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
#include "RigFormationNames.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimTools.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
@@ -32,48 +32,46 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimFormationNames, "FormationNames");
|
||||
CAF_PDM_SOURCE_INIT( RimFormationNames, "FormationNames" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFormationNames::RimFormationNames()
|
||||
{
|
||||
CAF_PDM_InitObject("Formation Names", ":/Formations16x16.png", "", "");
|
||||
CAF_PDM_InitObject( "Formation Names", ":/Formations16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitField(&m_formationNamesFileName, "FormationNamesFileName", QString(""), "File Name", "", "", "");
|
||||
|
||||
m_formationNamesFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField( &m_formationNamesFileName, "FormationNamesFileName", QString( "" ), "File Name", "", "", "" );
|
||||
|
||||
m_formationNamesFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFormationNames::~RimFormationNames()
|
||||
{
|
||||
|
||||
}
|
||||
RimFormationNames::~RimFormationNames() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
void RimFormationNames::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if (&m_formationNamesFileName == changedField)
|
||||
if ( &m_formationNamesFileName == changedField )
|
||||
{
|
||||
updateUiTreeName();
|
||||
QString errorMessage;
|
||||
readFormationNamesFile(&errorMessage);
|
||||
if (!errorMessage.isEmpty())
|
||||
readFormationNamesFile( &errorMessage );
|
||||
if ( !errorMessage.isEmpty() )
|
||||
{
|
||||
QMessageBox::warning(nullptr, "Formation Names", errorMessage);
|
||||
QMessageBox::warning( nullptr, "Formation Names", errorMessage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::initAfterRead()
|
||||
{
|
||||
@@ -81,9 +79,9 @@ void RimFormationNames::initAfterRead()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::setFileName(const QString& fileName)
|
||||
void RimFormationNames::setFileName( const QString& fileName )
|
||||
{
|
||||
m_formationNamesFileName = fileName;
|
||||
|
||||
@@ -91,7 +89,7 @@ void RimFormationNames::setFileName(const QString& fileName)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RimFormationNames::fileName()
|
||||
{
|
||||
@@ -99,36 +97,36 @@ const QString& RimFormationNames::fileName()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFormationNames::fileNameWoPath()
|
||||
{
|
||||
QFileInfo fnameFileInfo(m_formationNamesFileName());
|
||||
QFileInfo fnameFileInfo( m_formationNamesFileName() );
|
||||
return fnameFileInfo.fileName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::updateConnectedViews()
|
||||
{
|
||||
std::vector<RimCase*> objects;
|
||||
this->objectsWithReferringPtrFieldsOfType(objects);
|
||||
this->objectsWithReferringPtrFieldsOfType( objects );
|
||||
|
||||
for (RimCase* caseObj : objects)
|
||||
for ( RimCase* caseObj : objects )
|
||||
{
|
||||
if (caseObj)
|
||||
if ( caseObj )
|
||||
{
|
||||
caseObj->updateFormationNamesData();
|
||||
|
||||
std::vector<RimWellLogTrack*> tracks;
|
||||
caseObj->objectsWithReferringPtrFieldsOfType(tracks);
|
||||
for (RimWellLogTrack* track : tracks)
|
||||
caseObj->objectsWithReferringPtrFieldsOfType( tracks );
|
||||
for ( RimWellLogTrack* track : tracks )
|
||||
{
|
||||
// The track may be referring to the case for other reasons than formations.
|
||||
if (track->formationNamesCase() == caseObj)
|
||||
if ( track->formationNamesCase() == caseObj )
|
||||
{
|
||||
track->loadDataAndUpdate(true);
|
||||
track->loadDataAndUpdate( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,89 +134,93 @@ void RimFormationNames::updateConnectedViews()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::readFormationNamesFile(QString* errorMessage)
|
||||
void RimFormationNames::readFormationNamesFile( QString* errorMessage )
|
||||
{
|
||||
QFile dataFile(m_formationNamesFileName());
|
||||
QFile dataFile( m_formationNamesFileName() );
|
||||
|
||||
if (!dataFile.open(QFile::ReadOnly))
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_formationNamesFileName()) + "\n";
|
||||
return;
|
||||
if ( !dataFile.open( QFile::ReadOnly ) )
|
||||
{
|
||||
if ( errorMessage ) ( *errorMessage ) += "Could not open the File: " + ( m_formationNamesFileName() ) + "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
m_formationNamesData = new RigFormationNames;
|
||||
QTextStream stream(&dataFile);
|
||||
QTextStream stream( &dataFile );
|
||||
|
||||
QFileInfo fileInfo(m_formationNamesFileName());
|
||||
|
||||
if (fileInfo.fileName() == "layer_zone_table.txt")
|
||||
QFileInfo fileInfo( m_formationNamesFileName() );
|
||||
|
||||
if ( fileInfo.fileName() == "layer_zone_table.txt" )
|
||||
{
|
||||
readFmuFormationNameFile(stream, errorMessage);
|
||||
readFmuFormationNameFile( stream, errorMessage );
|
||||
}
|
||||
else
|
||||
{
|
||||
CAF_ASSERT(fileInfo.suffix() == "lyr");
|
||||
readLyrFormationNameFile(stream, errorMessage);
|
||||
}
|
||||
CAF_ASSERT( fileInfo.suffix() == "lyr" );
|
||||
readLyrFormationNameFile( stream, errorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
void RimFormationNames::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
|
||||
{
|
||||
m_formationNamesFileName = RimTools::relocateFile(m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr);
|
||||
m_formationNamesFileName = RimTools::relocateFile( m_formationNamesFileName(),
|
||||
newProjectPath,
|
||||
oldProjectPath,
|
||||
nullptr,
|
||||
nullptr );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::updateUiTreeName()
|
||||
{
|
||||
this->uiCapability()->setUiName(fileNameWoPath());
|
||||
this->uiCapability()->setUiName( fileNameWoPath() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::readLyrFormationNameFile(QTextStream& stream, QString* errorMessage)
|
||||
void RimFormationNames::readLyrFormationNameFile( QTextStream& stream, QString* errorMessage )
|
||||
{
|
||||
int lineNumber = 1;
|
||||
while (!stream.atEnd())
|
||||
while ( !stream.atEnd() )
|
||||
{
|
||||
QString line = stream.readLine();
|
||||
QStringList lineSegs = line.split("'", QString::KeepEmptyParts);
|
||||
QStringList lineSegs = line.split( "'", QString::KeepEmptyParts );
|
||||
|
||||
if (lineSegs.size() == 0) continue; // Empty line
|
||||
if (lineSegs.size() == 1) continue; // No name present. Comment line ?
|
||||
if (lineSegs.size() == 2)
|
||||
if ( lineSegs.size() == 0 ) continue; // Empty line
|
||||
if ( lineSegs.size() == 1 ) continue; // No name present. Comment line ?
|
||||
if ( lineSegs.size() == 2 )
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Missing quote on line : " + QString::number(lineNumber) + "\n";
|
||||
if ( errorMessage ) ( *errorMessage ) += "Missing quote on line : " + QString::number( lineNumber ) + "\n";
|
||||
continue; // One quote present
|
||||
}
|
||||
|
||||
if (lineSegs.size() == 3) // Normal case
|
||||
if ( lineSegs.size() == 3 ) // Normal case
|
||||
{
|
||||
if (lineSegs[0].contains("--")) continue; // Comment line
|
||||
if ( lineSegs[0].contains( "--" ) ) continue; // Comment line
|
||||
QString formationName = lineSegs[1];
|
||||
int commentMarkPos = lineSegs[2].indexOf("--");
|
||||
int commentMarkPos = lineSegs[2].indexOf( "--" );
|
||||
QString numberString = lineSegs[2];
|
||||
if (commentMarkPos >= 0) numberString.truncate(commentMarkPos);
|
||||
if ( commentMarkPos >= 0 ) numberString.truncate( commentMarkPos );
|
||||
|
||||
QStringList numberWords = numberString.split(QRegExp("-"), QString::SkipEmptyParts);
|
||||
if (numberWords.size() == 2)
|
||||
QStringList numberWords = numberString.split( QRegExp( "-" ), QString::SkipEmptyParts );
|
||||
if ( numberWords.size() == 2 )
|
||||
{
|
||||
bool isNumber1 = false;
|
||||
bool isNumber2 = false;
|
||||
int startK = numberWords[0].toInt(&isNumber1);
|
||||
int endK = numberWords[1].toInt(&isNumber2);
|
||||
int startK = numberWords[0].toInt( &isNumber1 );
|
||||
int endK = numberWords[1].toInt( &isNumber2 );
|
||||
|
||||
if (!(isNumber2 && isNumber1))
|
||||
if ( !( isNumber2 && isNumber1 ) )
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Format error on line: " + QString::number(lineNumber) + "\n";
|
||||
if ( errorMessage )
|
||||
( *errorMessage ) += "Format error on line: " + QString::number( lineNumber ) + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -226,24 +228,26 @@ void RimFormationNames::readLyrFormationNameFile(QTextStream& stream, QString* e
|
||||
startK = tmp < endK ? tmp : endK;
|
||||
endK = tmp > endK ? tmp : endK;
|
||||
|
||||
m_formationNamesData->appendFormationRange(formationName, startK - 1, endK - 1);
|
||||
m_formationNamesData->appendFormationRange( formationName, startK - 1, endK - 1 );
|
||||
}
|
||||
else if (numberWords.size() == 1)
|
||||
else if ( numberWords.size() == 1 )
|
||||
{
|
||||
bool isNumber1 = false;
|
||||
int kLayerCount = numberWords[0].toInt(&isNumber1);
|
||||
int kLayerCount = numberWords[0].toInt( &isNumber1 );
|
||||
|
||||
if (!isNumber1)
|
||||
if ( !isNumber1 )
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Format error on line: " + QString::number(lineNumber) + "\n";
|
||||
if ( errorMessage )
|
||||
( *errorMessage ) += "Format error on line: " + QString::number( lineNumber ) + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
m_formationNamesData->appendFormationRangeHeight(formationName, kLayerCount);
|
||||
m_formationNamesData->appendFormationRangeHeight( formationName, kLayerCount );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Format error on line: " + QString::number(lineNumber) + "\n";
|
||||
if ( errorMessage )
|
||||
( *errorMessage ) += "Format error on line: " + QString::number( lineNumber ) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,47 +258,48 @@ void RimFormationNames::readLyrFormationNameFile(QTextStream& stream, QString* e
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFormationNames::readFmuFormationNameFile(QTextStream& stream, QString* errorMessage)
|
||||
void RimFormationNames::readFmuFormationNameFile( QTextStream& stream, QString* errorMessage )
|
||||
{
|
||||
int lineNumber = 1;
|
||||
|
||||
QString currentFormationName;
|
||||
int startK = -1;
|
||||
int endK = -1;
|
||||
int startK = -1;
|
||||
int endK = -1;
|
||||
|
||||
while (!stream.atEnd())
|
||||
while ( !stream.atEnd() )
|
||||
{
|
||||
QString line = stream.readLine();
|
||||
if (line.isNull())
|
||||
if ( line.isNull() )
|
||||
{
|
||||
// Make sure we append the last formation
|
||||
if (!currentFormationName.isEmpty())
|
||||
if ( !currentFormationName.isEmpty() )
|
||||
{
|
||||
m_formationNamesData->appendFormationRange(currentFormationName, startK - 1, endK - 1);
|
||||
m_formationNamesData->appendFormationRange( currentFormationName, startK - 1, endK - 1 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream lineStream(&line);
|
||||
QTextStream lineStream( &line );
|
||||
|
||||
double kLayer;
|
||||
double kLayer;
|
||||
QString formationName;
|
||||
|
||||
lineStream >> kLayer >> formationName;
|
||||
|
||||
if (lineStream.status() != QTextStream::Ok)
|
||||
if ( lineStream.status() != QTextStream::Ok )
|
||||
{
|
||||
*errorMessage = QString("Failed to parse line %1 of '%2'").arg(lineNumber).arg(m_formationNamesFileName());
|
||||
*errorMessage =
|
||||
QString( "Failed to parse line %1 of '%2'" ).arg( lineNumber ).arg( m_formationNamesFileName() );
|
||||
return;
|
||||
}
|
||||
|
||||
if (formationName != currentFormationName)
|
||||
if ( formationName != currentFormationName )
|
||||
{
|
||||
// Append previous formation
|
||||
if (!currentFormationName.isEmpty())
|
||||
if ( !currentFormationName.isEmpty() )
|
||||
{
|
||||
m_formationNamesData->appendFormationRange(currentFormationName, startK - 1, endK - 1);
|
||||
m_formationNamesData->appendFormationRange( currentFormationName, startK - 1, endK - 1 );
|
||||
}
|
||||
|
||||
// Start new formation
|
||||
|
||||
Reference in New Issue
Block a user