clang-format WBS classes

This commit is contained in:
Gaute Lindkvist 2019-09-10 08:32:42 +02:00
parent 8fdb43fe26
commit 5c9622dca0
3 changed files with 157 additions and 152 deletions

View File

@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
@ -34,24 +34,24 @@
#include "cafPdmUiItem.h"
#include "cafUtils.h"
#include <QFileInfo>
#include <QDir>
#include <QDateTime>
#include <QDir>
#include <QFileInfo>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RimTools::getCacheRootDirectoryPathFromProject()
{
if (!RiaApplication::instance()->project())
if ( !RiaApplication::instance()->project() )
{
return QString();
}
QString projectFileName = RiaApplication::instance()->project()->fileName();
QString cacheRootFolderPath;
QFileInfo fileInfo(projectFileName);
QString cacheRootFolderPath;
QFileInfo fileInfo( projectFileName );
cacheRootFolderPath = fileInfo.canonicalPath();
cacheRootFolderPath += "/" + fileInfo.completeBaseName();
@ -69,49 +69,51 @@ QString RimTools::getCacheRootDirectoryPathFromProject()
/// such that the common start of oldProjectPath and m_gridFileName is removed from m_gridFileName
/// and replaced with the start of newProjectPath up to where newProjectPath starts to be equal to oldProjectPath
//--------------------------------------------------------------------------------------------------
QString RimTools::relocateFile(const QString& originalFileName,
const QString& currentProjectPath,
const QString& previousProjectPath,
bool* foundFile,
std::vector<QString>* searchedPaths)
QString RimTools::relocateFile( const QString& originalFileName,
const QString& currentProjectPath,
const QString& previousProjectPath,
bool* foundFile,
std::vector<QString>* searchedPaths )
{
if (foundFile) *foundFile = true;
if ( foundFile ) *foundFile = true;
// Make sure we have a Qt formatted path ( using "/" not "\")
QString fileName = QDir::fromNativeSeparators(originalFileName);
QString newProjectPath = QDir::fromNativeSeparators(currentProjectPath);
QString oldProjectPath = QDir::fromNativeSeparators(previousProjectPath);
QString fileName = QDir::fromNativeSeparators( originalFileName );
QString newProjectPath = QDir::fromNativeSeparators( currentProjectPath );
QString oldProjectPath = QDir::fromNativeSeparators( previousProjectPath );
// If we from a file or whatever gets a real windows path on linux, we need to manually convert it
// because Qt will not. QDir::fromNativeSeparators does nothing on linux.
bool isWindowsPath = false;
if (originalFileName.count("/")) isWindowsPath = false; // "/" are not allowed in a windows path
else if (originalFileName.count("\\")
&& !caf::Utils::fileExists(originalFileName)) // To make sure we do not convert single linux files containing "\"
if ( originalFileName.count( "/" ) )
isWindowsPath = false; // "/" are not allowed in a windows path
else if ( originalFileName.count( "\\" ) &&
!caf::Utils::fileExists(
originalFileName ) ) // To make sure we do not convert single linux files containing "\"
{
isWindowsPath = true;
}
if (isWindowsPath)
if ( isWindowsPath )
{
// Windows absolute path detected. transform.
fileName.replace(QString("\\"), QString("/"));
fileName.replace( QString( "\\" ), QString( "/" ) );
}
if (searchedPaths) searchedPaths->push_back(fileName);
if (caf::Utils::fileExists(fileName))
if ( searchedPaths ) searchedPaths->push_back( fileName );
if ( caf::Utils::fileExists( fileName ) )
{
return fileName;
}
// First check in the new project file directory
{
QString fileNameWithoutPath = QFileInfo(fileName).fileName();
QString candidate = QDir::fromNativeSeparators(newProjectPath + QDir::separator() + fileNameWithoutPath);
if (searchedPaths) searchedPaths->push_back(candidate);
QString fileNameWithoutPath = QFileInfo( fileName ).fileName();
QString candidate = QDir::fromNativeSeparators( newProjectPath + QDir::separator() + fileNameWithoutPath );
if ( searchedPaths ) searchedPaths->push_back( candidate );
if (caf::Utils::fileExists(candidate))
if ( caf::Utils::fileExists( candidate ) )
{
return candidate;
}
@ -119,23 +121,24 @@ QString RimTools::relocateFile(const QString& originalFileName,
// Then find the possible move of a directory structure where projects and files referenced are moved in "paralell"
QFileInfo fileNameFileInfo(QDir::fromNativeSeparators(fileName));
QString fileNamePath = fileNameFileInfo.path();
QString fileNameWithoutPath = fileNameFileInfo.fileName();
QStringList fileNamePathElements = fileNamePath.split("/", QString::KeepEmptyParts);
QFileInfo fileNameFileInfo( QDir::fromNativeSeparators( fileName ) );
QString fileNamePath = fileNameFileInfo.path();
QString fileNameWithoutPath = fileNameFileInfo.fileName();
QStringList fileNamePathElements = fileNamePath.split( "/", QString::KeepEmptyParts );
QString oldProjPath = QDir::fromNativeSeparators(oldProjectPath);
QStringList oldProjPathElements = oldProjPath.split("/", QString::KeepEmptyParts);
QString oldProjPath = QDir::fromNativeSeparators( oldProjectPath );
QStringList oldProjPathElements = oldProjPath.split( "/", QString::KeepEmptyParts );
QString newProjPath = QDir::fromNativeSeparators(newProjectPath);
QStringList newProjPathElements = newProjPath.split("/", QString::KeepEmptyParts);
QString newProjPath = QDir::fromNativeSeparators( newProjectPath );
QStringList newProjPathElements = newProjPath.split( "/", QString::KeepEmptyParts );
// Find the possible equal start of the old project path, and the referenced file
bool pathStartsAreEqual = false;
bool pathEndsDiffer = false;
int firstDiffIdx = 0;
for (firstDiffIdx = 0; firstDiffIdx < fileNamePathElements.size() && firstDiffIdx < oldProjPathElements.size(); ++firstDiffIdx)
bool pathEndsDiffer = false;
int firstDiffIdx = 0;
for ( firstDiffIdx = 0; firstDiffIdx < fileNamePathElements.size() && firstDiffIdx < oldProjPathElements.size();
++firstDiffIdx )
{
#ifdef WIN32
// When comparing parts of a file path, the drive letter has been seen to be a mix of
@ -145,7 +148,7 @@ QString RimTools::relocateFile(const QString& originalFileName,
#else
Qt::CaseSensitivity cs = Qt::CaseSensitive;
#endif
if (fileNamePathElements[firstDiffIdx].compare(oldProjPathElements[firstDiffIdx], cs) == 0)
if ( fileNamePathElements[firstDiffIdx].compare( oldProjPathElements[firstDiffIdx], cs ) == 0 )
{
pathStartsAreEqual = pathStartsAreEqual || !fileNamePathElements[firstDiffIdx].isEmpty();
}
@ -156,19 +159,19 @@ QString RimTools::relocateFile(const QString& originalFileName,
}
}
if (!pathEndsDiffer && firstDiffIdx < fileNamePathElements.size() || firstDiffIdx < oldProjPathElements.size())
if ( !pathEndsDiffer && firstDiffIdx < fileNamePathElements.size() || firstDiffIdx < oldProjPathElements.size() )
{
pathEndsDiffer = true;
}
// If the path starts are equal, try to substitute it in the referenced file, with the corresponding new project path start
if (pathStartsAreEqual)
if ( pathStartsAreEqual )
{
if (pathEndsDiffer)
if ( pathEndsDiffer )
{
QString oldFileNamePathEnd;
for (int i = firstDiffIdx; i < fileNamePathElements.size(); ++i)
for ( int i = firstDiffIdx; i < fileNamePathElements.size(); ++i )
{
oldFileNamePathEnd += fileNamePathElements[i];
oldFileNamePathEnd += "/";
@ -177,18 +180,18 @@ QString RimTools::relocateFile(const QString& originalFileName,
// Find the new Project File Start Path
QStringList oldProjectFilePathEndElements;
for (int i = firstDiffIdx; i < oldProjPathElements.size(); ++i)
for ( int i = firstDiffIdx; i < oldProjPathElements.size(); ++i )
{
oldProjectFilePathEndElements.push_back(oldProjPathElements[i]);
oldProjectFilePathEndElements.push_back( oldProjPathElements[i] );
}
int lastProjectDiffIdx = newProjPathElements.size() - 1;
{
int ppIdx = oldProjectFilePathEndElements.size() - 1;
for (; lastProjectDiffIdx >= 0 && ppIdx >= 0; --lastProjectDiffIdx, --ppIdx)
for ( ; lastProjectDiffIdx >= 0 && ppIdx >= 0; --lastProjectDiffIdx, --ppIdx )
{
if (oldProjectFilePathEndElements[ppIdx] != newProjPathElements[lastProjectDiffIdx])
if ( oldProjectFilePathEndElements[ppIdx] != newProjPathElements[lastProjectDiffIdx] )
{
break;
}
@ -196,7 +199,7 @@ QString RimTools::relocateFile(const QString& originalFileName,
}
QString newProjectFileStartPath;
for (int i = 0; i <= lastProjectDiffIdx; ++i)
for ( int i = 0; i <= lastProjectDiffIdx; ++i )
{
newProjectFileStartPath += newProjPathElements[i];
newProjectFileStartPath += "/";
@ -206,9 +209,9 @@ QString RimTools::relocateFile(const QString& originalFileName,
QString relocatedFileName = relocationPath + fileNameWithoutPath;
if (searchedPaths) searchedPaths->push_back(relocatedFileName);
if ( searchedPaths ) searchedPaths->push_back( relocatedFileName );
if (caf::Utils::fileExists(relocatedFileName))
if ( caf::Utils::fileExists( relocatedFileName ) )
{
return relocatedFileName;
}
@ -221,111 +224,65 @@ QString RimTools::relocateFile(const QString& originalFileName,
}
// return the unchanged filename, if we could not find a valid relocation file
if (foundFile) *foundFile = false;
if ( foundFile ) *foundFile = false;
return fileName;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimTools::wellPathOptionItems(QList<caf::PdmOptionItemInfo>* options)
void RimTools::wellPathOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
CVF_ASSERT(options);
if (!options) return;
CVF_ASSERT( options );
if ( !options ) return;
auto wellPathColl = RimTools::wellPathCollection();
if (wellPathColl)
if ( wellPathColl )
{
caf::PdmChildArrayField<RimWellPath*>& wellPaths = wellPathColl->wellPaths;
caf::QIconProvider wellIcon(":/Well.png");
for (RimWellPath* wellPath : wellPaths)
caf::QIconProvider wellIcon( ":/Well.png" );
for ( RimWellPath* wellPath : wellPaths )
{
options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon));
options->push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false, wellIcon ) );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimTools::wellPathWithFormationsOptionItems(QList<caf::PdmOptionItemInfo>* options)
void RimTools::wellPathWithFormationsOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
CVF_ASSERT(options);
if (!options) return;
CVF_ASSERT( options );
if ( !options ) return;
std::vector<RimWellPath*> wellPaths;
RimTools::wellPathWithFormations(&wellPaths);
RimTools::wellPathWithFormations( &wellPaths );
caf::QIconProvider wellIcon(":/Well.png");
for (RimWellPath* wellPath : wellPaths)
caf::QIconProvider wellIcon( ":/Well.png" );
for ( RimWellPath* wellPath : wellPaths )
{
options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon));
options->push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false, wellIcon ) );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimTools::wellPathWithFormations(std::vector<RimWellPath*>* wellPaths)
void RimTools::wellPathWithFormations( std::vector<RimWellPath*>* wellPaths )
{
auto wellPathColl = RimTools::wellPathCollection();
if (wellPathColl)
if ( wellPathColl )
{
caf::PdmChildArrayField<RimWellPath*>& allWellPaths = wellPathColl->wellPaths;
for (RimWellPath* wellPath : allWellPaths)
for ( RimWellPath* wellPath : allWellPaths )
{
if (wellPath->hasFormations())
if ( wellPath->hasFormations() )
{
wellPaths->push_back(wellPath);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTools::caseOptionItems(QList<caf::PdmOptionItemInfo>* options)
{
CVF_ASSERT(options);
if (!options) return;
RimProject* proj = RiaApplication::instance()->project();
if (proj)
{
std::vector<RimCase*> cases;
proj->allCases(cases);
for (RimCase* c : cases)
{
options->push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, false, c->uiIconProvider()));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTools::eclipseCaseOptionItems(QList<caf::PdmOptionItemInfo>* options)
{
CVF_ASSERT(options);
if (!options) return;
RimProject* proj = RiaApplication::instance()->project();
if (proj)
{
std::vector<RimCase*> cases;
proj->allCases(cases);
for (RimCase* c : cases)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(c);
if (eclipseCase)
{
options->push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, false, c->uiIconProvider()));
wellPaths->push_back( wellPath );
}
}
}
@ -334,35 +291,81 @@ void RimTools::eclipseCaseOptionItems(QList<caf::PdmOptionItemInfo>* options)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTools::geoMechCaseOptionItems(QList<caf::PdmOptionItemInfo>* options)
void RimTools::caseOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
CVF_ASSERT(options);
if (!options) return;
CVF_ASSERT( options );
if ( !options ) return;
RimProject* proj = RiaApplication::instance()->project();
if (proj)
if ( proj )
{
std::vector<RimCase*> cases;
proj->allCases(cases);
proj->allCases( cases );
for (RimCase* c : cases)
for ( RimCase* c : cases )
{
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(c);
if (geoMechCase)
options->push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTools::eclipseCaseOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
CVF_ASSERT( options );
if ( !options ) return;
RimProject* proj = RiaApplication::instance()->project();
if ( proj )
{
std::vector<RimCase*> cases;
proj->allCases( cases );
for ( RimCase* c : cases )
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( c );
if ( eclipseCase )
{
options->push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, false, c->uiIconProvider()));
options->push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimTools::geoMechCaseOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
CVF_ASSERT( options );
if ( !options ) return;
RimProject* proj = RiaApplication::instance()->project();
if ( proj )
{
std::vector<RimCase*> cases;
proj->allCases( cases );
for ( RimCase* c : cases )
{
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>( c );
if ( geoMechCase )
{
options->push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathCollection* RimTools::wellPathCollection()
{
RimProject* proj = RiaApplication::instance()->project();
if (proj && proj->activeOilField())
if ( proj && proj->activeOilField() )
{
return proj->activeOilField()->wellPathCollection();
}

View File

@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
@ -29,31 +29,32 @@
class QDateTime;
namespace caf {
class PdmOptionItemInfo;
namespace caf
{
class PdmOptionItemInfo;
}
class RimWellPathCollection;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RimTools
{
public:
static QString getCacheRootDirectoryPathFromProject();
static QString relocateFile(const QString& originalFileName,
const QString& currentProjectPath,
const QString& previousProjectPath,
bool* foundFile,
std::vector<QString>* searchedPaths);
static QString relocateFile( const QString& originalFileName,
const QString& currentProjectPath,
const QString& previousProjectPath,
bool* foundFile,
std::vector<QString>* searchedPaths );
static void wellPathOptionItems(QList<caf::PdmOptionItemInfo>* options);
static void wellPathWithFormationsOptionItems(QList<caf::PdmOptionItemInfo>* options);
static void wellPathWithFormations(std::vector<RimWellPath*>* wellPaths);
static void caseOptionItems(QList<caf::PdmOptionItemInfo>* options);
static void eclipseCaseOptionItems(QList<caf::PdmOptionItemInfo>* options);
static void geoMechCaseOptionItems(QList<caf::PdmOptionItemInfo>* options);
static void wellPathOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void wellPathWithFormationsOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void wellPathWithFormations( std::vector<RimWellPath*>* wellPaths );
static void caseOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void eclipseCaseOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void geoMechCaseOptionItems( QList<caf::PdmOptionItemInfo>* options );
static RimWellPathCollection* wellPathCollection();
};

View File

@ -749,7 +749,8 @@ void RigGeoMechWellLogExtractor::calculateIntersection()
hexCorners[6] = cvf::Vec3d( nodeCoords[cornerIndices[6]] );
hexCorners[7] = cvf::Vec3d( nodeCoords[cornerIndices[7]] );
// int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners, closeCells[ccIdx], &intersections);
// int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners, closeCells[ccIdx],
// &intersections);
RigHexIntersectionTools::lineHexCellIntersection( p1, p2, hexCorners, closeCells[ccIdx], &intersections );
}