Update clang-tidy.yml

* Make sure clang-tidy action use .clang-tidy config file
Use add-paths to instruct create-pull-request to a sub folder to avoid diff from Qt and vcpkg

* Use empty() in macro to avoid clang-tidy warning
* Add NOLINT to CAF_ASSERT
* Add NOLINT to cvfAssert
This commit is contained in:
Magne Sjaastad
2023-10-03 09:04:08 +02:00
committed by GitHub
parent 8df4dd42eb
commit 21843820e6
51 changed files with 119 additions and 202 deletions

View File

@@ -68,17 +68,11 @@ jobs:
- name: Run clang-tidy and apply fixes, clang-format after fixes
run: |
cd build
run-clang-tidy-15 -fix files ApplicationLibCode/Application ApplicationLibCode/ProjectDataModel ApplicationLibCode/ReservoirDataModel ApplicationLibCode/Commands ApplicationLibCode/GeoMech
run-clang-tidy-15 -config-file ../ApplicationLibCode/.clang-tidy -fix files ApplicationLibCode
- name: Run clang-format after clang-tidy
run: |
cd build/ApplicationLibCode
cd ApplicationLibCode
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-15 -i
- name: Remove Qt before creating PR
run: |
rm -rf Qt
cd ThirdParty/vcpkg
git reset --hard HEAD
git clean -fxd
- uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
@@ -86,3 +80,5 @@ jobs:
title: "Fixes by clang-tidy"
branch: clang-tidy-patches
branch-suffix: random
add-paths: |
ApplicationLibCode/*

View File

@@ -512,7 +512,7 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n
{
CVF_ASSERT( o.valueCount() == 1 );
QString regressionTestPath = cvfqt::Utils::toQString( o.value( 0 ) );
RiaRegressionTestRunner::instance()->updateRegressionTest( regressionTestPath );
RiaRegressionTestRunner::updateRegressionTest( regressionTestPath );
return ApplicationStatus::EXIT_COMPLETED;
}
@@ -1544,7 +1544,7 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences*
//--------------------------------------------------------------------------------------------------
int RiaGuiApplication::applicationResolution()
{
return RiaGuiApplication::instance()->desktop()->logicalDpiX();
return QApplication::desktop()->logicalDpiX();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -309,7 +309,7 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field, QS
caf::PdmUiLineEditorAttribute* myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->validator = new RiaValidRegExpValidator( RiaPreferences::current()->defaultMultiLateralWellNamePattern() );
myAttr->validator = new RiaValidRegExpValidator( RiaPreferences::defaultMultiLateralWellNamePattern() );
}
}
else if ( field == &m_defaultScaleFactorZ )

View File

@@ -387,7 +387,7 @@ void RiaPreferencesSummary::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
if ( m_summaryReader == SummaryReaderMode::OPM_COMMON )
{
if ( RiaApplication::instance()->enableDevelopmentFeatures() )
if ( RiaApplication::enableDevelopmentFeatures() )
{
uiOrdering.add( &m_useEnhancedSummaryDataFile );
}
@@ -397,7 +397,7 @@ void RiaPreferencesSummary::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
{
uiOrdering.add( &m_createH5SummaryDataFile );
if ( RiaApplication::instance()->enableDevelopmentFeatures() )
if ( RiaApplication::enableDevelopmentFeatures() )
{
uiOrdering.add( &m_createH5SummaryFileThreadCount );
}

View File

@@ -54,7 +54,7 @@ void RiaFieldHandleTools::disableWriteAndSetFieldHidden( caf::PdmFieldHandle* fi
void RiaFieldHandleTools::updateOverrideStateAndLabel( caf::PdmFieldHandle* fieldHandle, bool isOverridden, const QString& toolTip )
{
// Get the label text as given by the init_field macro
QString labelText = fieldHandle->uiCapability()->uiName( fieldHandle->uiCapability()->uiConfigNameForStaticData() );
QString labelText = fieldHandle->uiCapability()->uiName( caf::PdmUiItem::uiConfigNameForStaticData() );
if ( isOverridden ) labelText += " (overridden)";
fieldHandle->uiCapability()->setUiToolTip( toolTip );

View File

@@ -168,9 +168,7 @@ bool RicfCreateMultipleFractures::validateArguments() const
{
bool valid = m_caseId >= 0 && m_templateId >= 0;
if ( valid ) return true;
return false;
return valid;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -35,7 +35,6 @@
#include "RiaLogging.h"
#include "RiaWellNameComparer.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmFieldScriptingCapability.h"
#include <QStringList>
@@ -90,9 +89,6 @@ caf::PdmScriptResponse RicfExportLgrForCompletions::execute()
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "LGR" );
}
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
auto feature = dynamic_cast<RicExportLgrFeature*>( commandManager->getCommandFeature( "RicExportLgrFeature" ) );
RimEclipseCase* eclipseCase = TOOLS::caseFromId( m_caseId() );
if ( !eclipseCase )
{
@@ -104,16 +100,16 @@ caf::PdmScriptResponse RicfExportLgrForCompletions::execute()
caf::VecIjk lgrCellCounts( m_refinementI, m_refinementJ, m_refinementK );
QStringList wellsIntersectingOtherLgrs;
feature->exportLgrsForWellPaths( exportFolder,
wellPaths,
eclipseCase,
m_timeStep,
lgrCellCounts,
m_splitType(),
{ RigCompletionData::CompletionType::PERFORATION,
RigCompletionData::CompletionType::FRACTURE,
RigCompletionData::CompletionType::FISHBONES },
&wellsIntersectingOtherLgrs );
RicExportLgrFeature::exportLgrsForWellPaths( exportFolder,
wellPaths,
eclipseCase,
m_timeStep,
lgrCellCounts,
m_splitType(),
{ RigCompletionData::CompletionType::PERFORATION,
RigCompletionData::CompletionType::FRACTURE,
RigCompletionData::CompletionType::FISHBONES },
&wellsIntersectingOtherLgrs );
caf::PdmScriptResponse response;
if ( !wellsIntersectingOtherLgrs.empty() )

View File

@@ -89,7 +89,7 @@ caf::PdmScriptResponse RicfExportSnapshots::execute()
QByteArray curState = mainWnd->dockManager()->saveState( 0 );
mainWnd->dockManager()->restoreState( RiuDockWidgetTools::defaultDockState( RiuDockWidgetTools::dockStateHideAll3DWindowName() ) );
RiaGuiApplication::instance()->processEvents();
QApplication::processEvents();
QString absolutePathToSnapshotDir = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::SNAPSHOTS );
@@ -131,7 +131,7 @@ caf::PdmScriptResponse RicfExportSnapshots::execute()
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( absolutePathToSnapshotDir, activateWidget, m_prefix, m_viewId(), fileSuffix );
}
RiaGuiApplication::instance()->processEvents();
QApplication::processEvents();
mainWnd->dockManager()->restoreState( curState );

View File

@@ -40,7 +40,7 @@ public:
PNG,
PDF
};
typedef caf::AppEnum<PlotOutputFormat> PreferredOutputFormatEnum;
using PreferredOutputFormatEnum = caf::AppEnum<PlotOutputFormat>;
enum class SnapshotsType
{
@@ -48,7 +48,7 @@ public:
PLOTS,
ALL
};
typedef caf::AppEnum<SnapshotsType> SnapshotsTypeEnum;
using SnapshotsTypeEnum = caf::AppEnum<SnapshotsType>;
public:
RicfExportSnapshots();

View File

@@ -54,7 +54,7 @@ public:
LAS,
ASCII
};
typedef caf::AppEnum<ExportFormat> ExportFormatEnum;
using ExportFormatEnum = caf::AppEnum<ExportFormat>;
public:
RicfExportWellLogPlotData();

View File

@@ -35,7 +35,6 @@
#include "RiaLogging.h"
#include "RiaWellNameComparer.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmFieldScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RicfExportWellPaths, "exportWellPaths" );
@@ -83,15 +82,11 @@ caf::PdmScriptResponse RicfExportWellPaths::execute()
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "wellpaths" );
}
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
auto feature =
dynamic_cast<RicExportSelectedWellPathsFeature*>( commandManager->getCommandFeature( "RicExportSelectedWellPathsFeature" ) );
for ( const auto wellPath : wellPaths )
{
if ( wellPath )
{
feature->exportWellPath( wellPath, m_mdStepSize, exportFolder, false );
RicExportSelectedWellPathsFeature::exportWellPath( wellPath, m_mdStepSize, exportFolder, false );
}
}
return caf::PdmScriptResponse();

View File

@@ -859,7 +859,7 @@ void RicRecursiveFileSearchDialog::slotCopyFileItemText()
if ( m_fileListWidget->currentItem() )
{
QString relativePathText = m_fileListWidget->currentItem()->text();
RiaGuiApplication::instance()->clipboard()->setText( relativePathText );
QApplication::clipboard()->setText( relativePathText );
}
}

View File

@@ -73,7 +73,7 @@ RicCreateWellTargetsPickEventHandler::~RicCreateWellTargetsPickEventHandler()
//--------------------------------------------------------------------------------------------------
void RicCreateWellTargetsPickEventHandler::registerAsPickEventHandler()
{
RiaGuiApplication::instance()->setOverrideCursor( Qt::CrossCursor );
QApplication::setOverrideCursor( Qt::CrossCursor );
Ric3dViewPickEventHandler::registerAsPickEventHandler();
}
@@ -82,7 +82,7 @@ void RicCreateWellTargetsPickEventHandler::registerAsPickEventHandler()
//--------------------------------------------------------------------------------------------------
void RicCreateWellTargetsPickEventHandler::notifyUnregistered()
{
RiaGuiApplication::instance()->restoreOverrideCursor();
QApplication::restoreOverrideCursor();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -20,8 +20,8 @@
#include <vector>
typedef struct ecl_grid_struct ecl_grid_type;
typedef struct ecl_file_struct ecl_file_type;
using ecl_grid_type = struct ecl_grid_struct;
using ecl_file_type = struct ecl_file_struct;
//==================================================================================================
//

View File

@@ -1106,7 +1106,7 @@ bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively( Q
int firstQuote = line.indexOf( "'" );
int lastQuote = line.lastIndexOf( "'" );
if ( !( firstQuote < 0 || lastQuote < 0 || firstQuote == lastQuote ) )
if ( firstQuote >= 0 && lastQuote >= 0 && firstQuote != lastQuote )
{
QDir currentFileFolder;
{
@@ -1231,7 +1231,7 @@ bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
int firstQuote = line.indexOf( "'" );
int lastQuote = line.lastIndexOf( "'" );
if ( !( firstQuote < 0 || lastQuote < 0 || firstQuote == lastQuote ) )
if ( firstQuote >= 0 && lastQuote >= 0 && firstQuote != lastQuote )
{
QDir currentFileFolder;
{

View File

@@ -621,12 +621,7 @@ bool RifEclipseOutputFileTools::isExportedFromIntersect( const ecl_file_type* ec
if ( !intehead_kw ) return false;
int int_value = ecl_kw_iget_int( intehead_kw, INTEHEAD_IPROG_INDEX );
if ( int_value == INTEHEAD_INTERSECT_VALUE )
{
return true;
}
return false;
return int_value == INTEHEAD_INTERSECT_VALUE;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -792,21 +792,17 @@ bool RifEclipseSummaryAddress::isValid() const
return false;
case SummaryCategory::SUMMARY_REGION:
if ( m_number0 == -1 ) return false;
return true;
return m_number0 != -1;
case SummaryCategory::SUMMARY_REGION_2_REGION:
if ( m_number0 == -1 ) return false;
if ( m_number1 == -1 ) return false;
return true;
return m_number1 != -1;
case SummaryCategory::SUMMARY_GROUP:
if ( m_name.empty() ) return false;
return true;
return !m_name.empty();
case SummaryCategory::SUMMARY_WELL:
if ( m_name.empty() ) return false;
return true;
return !m_name.empty();
case SummaryCategory::SUMMARY_WELL_COMPLETION:
if ( m_name.empty() ) return false;
@@ -817,8 +813,7 @@ bool RifEclipseSummaryAddress::isValid() const
case SummaryCategory::SUMMARY_WELL_LGR:
if ( m_lgrName.empty() ) return false;
if ( m_name.empty() ) return false;
return true;
return !m_name.empty();
case SummaryCategory::SUMMARY_WELL_COMPLETION_LGR:
if ( m_lgrName.empty() ) return false;
@@ -830,8 +825,7 @@ bool RifEclipseSummaryAddress::isValid() const
case SummaryCategory::SUMMARY_WELL_SEGMENT:
if ( m_name.empty() ) return false;
if ( m_number0 == -1 ) return false;
return true;
return m_number0 != -1;
case SummaryCategory::SUMMARY_BLOCK:
if ( m_number0 == -1 ) return false;
@@ -847,8 +841,7 @@ bool RifEclipseSummaryAddress::isValid() const
return true;
case SummaryCategory::SUMMARY_AQUIFER:
if ( m_number0 == -1 ) return false;
return true;
return m_number0 != -1;
}
return true;

View File

@@ -87,11 +87,7 @@ bool RifEclipseUserDataParserTools::isLineSkippable( const std::string& line )
//--------------------------------------------------------------------------------------------------
bool RifEclipseUserDataParserTools::isAComment( const std::string& word )
{
if ( word.find( "--" ) != std::string::npos )
{
return true;
}
return false;
return word.find( "--" ) != std::string::npos;
}
//--------------------------------------------------------------------------------------------------
@@ -185,8 +181,7 @@ bool RifEclipseUserDataParserTools::isANumber( const std::string& line )
try
{
auto value = std::stod( line );
if ( std::isinf( value ) || std::isnan( value ) ) return false;
return true;
return !( std::isinf( value ) || std::isnan( value ) );
}
catch ( ... )
{
@@ -215,12 +210,7 @@ std::vector<std::string> RifEclipseUserDataParserTools::headerReader( std::strin
//--------------------------------------------------------------------------------------------------
bool RifEclipseUserDataParserTools::hasTimeUnit( const std::string& word )
{
if ( word == "DAYS" || word == "DAY" || word == "YEARS" || word == "YEAR" || word == "DATE" || word == "DATES" )
{
return true;
}
return false;
return word == "DAYS" || word == "DAY" || word == "YEARS" || word == "YEAR" || word == "DATE" || word == "DATES";
}
//--------------------------------------------------------------------------------------------------
@@ -268,12 +258,7 @@ bool RifEclipseUserDataParserTools::isValidTableData( size_t columnCount, const
}
}
if ( columnsWithDate == 1 && doubleValues.size() == columnCount - 1 )
{
return true;
}
return false;
return columnsWithDate == 1 && doubleValues.size() == columnCount - 1;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -83,7 +83,7 @@ RifElasticProperties
// Plus one to allow trailing separator
const int expectedTokens = 13;
if ( !( tokens.size() == expectedTokens || tokens.size() == expectedTokens + 1 ) )
if ( tokens.size() != expectedTokens && tokens.size() != expectedTokens + 1 )
{
throw FileParseException( QString( "Incomplete data on line %1: %2" ).arg( lineNumber ).arg( filePath ) );
}

View File

@@ -52,7 +52,7 @@ class RifOpmHdf5Summary : public RifSummaryReaderInterface
{
public:
RifOpmHdf5Summary();
~RifOpmHdf5Summary();
~RifOpmHdf5Summary() override;
bool open( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );

View File

@@ -512,14 +512,14 @@ void RifReaderEclipseOutput::setHdf5FileName( const QString& fileName )
}
std::vector<QDateTime> sourSimTimeSteps = hdf5ReaderInterface->timeSteps();
if ( sourSimTimeSteps.size() == 0 )
if ( sourSimTimeSteps.empty() )
{
RiaLogging::error( "HDF: No data available from SourSim" );
return;
}
if ( timeStepInfos.size() > 0 )
if ( !timeStepInfos.empty() )
{
if ( allTimeSteps().size() != sourSimTimeSteps.size() )
{
@@ -1277,7 +1277,7 @@ cvf::Vec3d interpolate3DPosition( const std::vector<SegmentPositionContribution>
{
if ( positions[i].m_isFromAbove && positions[i].m_lengthFromConnection < minDistFromContribAbove )
{
if ( contrFromAbove.size() )
if ( !contrFromAbove.empty() )
contrFromAbove[0] = positions[i];
else
contrFromAbove.push_back( positions[i] );
@@ -1287,7 +1287,7 @@ cvf::Vec3d interpolate3DPosition( const std::vector<SegmentPositionContribution>
if ( !positions[i].m_isFromAbove && positions[i].m_lengthFromConnection < minDistFromContribBelow )
{
if ( contrFromBelow.size() )
if ( !contrFromBelow.empty() )
contrFromBelow[0] = positions[i];
else
contrFromBelow.push_back( positions[i] );
@@ -1446,14 +1446,7 @@ public:
size_t reservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex( gridIndex, gridCellIndex );
if ( m_gridCellsWithSubCellWellConnections.count( reservoirCellIdx ) )
{
return true;
}
else
{
return false;
}
return m_gridCellsWithSubCellWellConnections.count( reservoirCellIdx ) != 0;
}
private:
@@ -1877,7 +1870,7 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
bool isWellHead = true;
for ( const auto& wellResultBranch : wellResFrame.wellResultBranches() )
{
bool previousResultPointWasCell = isWellHead ? true : false;
bool previousResultPointWasCell = isWellHead;
// Go downwards until we find a none-cell result point just after a cell result point
// When we do, start propagating
@@ -2240,7 +2233,7 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel( RiaDefines
std::vector<double>* destinationResultValues,
const std::vector<double>& sourceResultValues )
{
if ( sourceResultValues.size() == 0 ) return;
if ( sourceResultValues.empty() ) return;
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL );

View File

@@ -326,13 +326,13 @@ cvf::Vec3d RifRoffFileTools::getCorner( const RigMainGrid& grid,
const cvf::Vec3d& scale )
{
size_t iOffset = 0;
if ( !( cornerIdx == 1 || cornerIdx == 3 || cornerIdx == 5 || cornerIdx == 7 ) )
if ( cornerIdx != 1 && cornerIdx != 3 && cornerIdx != 5 && cornerIdx != 7 )
{
iOffset = 1;
}
size_t jOffset = 0;
if ( !( cornerIdx == 2 || cornerIdx == 3 || cornerIdx == 6 || cornerIdx == 7 ) )
if ( cornerIdx != 2 && cornerIdx != 3 && cornerIdx != 6 && cornerIdx != 7 )
{
jOffset = 1;
}

View File

@@ -410,7 +410,7 @@ std::vector<double> RifStimPlanModelGeologicalFrkExporter::createPerforationValu
double bottom = depthEnd[idx];
// Layer is perforation if end points are inside the perforation interval
bool isPerforation = !( bottom < perforationTop || top > perforationBottom );
bool isPerforation = bottom >= perforationTop && top <= perforationBottom;
perfs.push_back( static_cast<double>( isPerforation ) );
}

View File

@@ -644,8 +644,7 @@ bool RifSurfaceImporter::vectorFuzzyCompare( const cvf::Vec2d& vector1, const cv
B = fabs( B );
float largest = ( B > A ) ? B : A;
if ( diff <= largest * maxRelDiff ) return true;
return false;
return diff <= largest * maxRelDiff;
};
return ( AlmostEqualRelativeAndAbs( vector1.x(), vector2.x(), epsilon ) && AlmostEqualRelativeAndAbs( vector1.y(), vector2.y(), epsilon ) );
}

View File

@@ -80,7 +80,7 @@ cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::generateSurface( bool only
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createMeshDrawable()
{
if ( !( m_vertices.notNull() && m_vertices->size() != 0 ) ) return nullptr;
if ( !m_vertices.notNull() || m_vertices->size() == 0 ) return nullptr;
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray( m_vertices.p() );
@@ -99,7 +99,7 @@ cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createMeshDrawable()
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createOutlineMeshDrawable( double creaseAngle )
{
if ( !( m_vertices.notNull() && m_vertices->size() != 0 ) ) return nullptr;
if ( !m_vertices.notNull() || m_vertices->size() == 0 ) return nullptr;
cvf::OutlineEdgeExtractor ee( creaseAngle, *m_vertices );

View File

@@ -57,14 +57,7 @@ RivBoxIntersectionGeometryGenerator::~RivBoxIntersectionGeometryGenerator()
//--------------------------------------------------------------------------------------------------
bool RivBoxIntersectionGeometryGenerator::isAnyGeometryPresent() const
{
if ( m_triangleVxes->size() == 0 )
{
return false;
}
else
{
return true;
}
return m_triangleVxes->size() != 0;
}
//--------------------------------------------------------------------------------------------------
@@ -89,7 +82,7 @@ cvf::ref<cvf::DrawableGeo> RivBoxIntersectionGeometryGenerator::generateSurface(
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivBoxIntersectionGeometryGenerator::createMeshDrawable()
{
if ( !( m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0 ) ) return nullptr;
if ( !m_cellBorderLineVxes.notNull() || m_cellBorderLineVxes->size() == 0 ) return nullptr;
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray( m_cellBorderLineVxes.p() );

View File

@@ -68,7 +68,7 @@ bool RivEclipseIntersectionGrid::useCell( size_t cellIndex ) const
{
const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex];
if ( m_showInactiveCells )
return !( cell.isInvalid() || ( cell.subGrid() != nullptr ) );
return !cell.isInvalid() && ( cell.subGrid() == nullptr );
else
return m_activeCellInfo->isActive( cellIndex ) && ( cell.subGrid() == nullptr );
}

View File

@@ -637,7 +637,7 @@ cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::genera
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::createMeshDrawable()
{
if ( !( m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0 ) ) return nullptr;
if ( !m_cellBorderLineVxes.notNull() || m_cellBorderLineVxes->size() == 0 ) return nullptr;
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray( m_cellBorderLineVxes.p() );
@@ -654,7 +654,7 @@ cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::create
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::createFaultMeshDrawable()
{
if ( !( m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0 ) ) return nullptr;
if ( !m_faultCellBorderLineVxes.notNull() || m_faultCellBorderLineVxes->size() == 0 ) return nullptr;
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray( m_faultCellBorderLineVxes.p() );
@@ -841,12 +841,7 @@ cvf::Mat4d RivExtrudedCurveIntersectionGeometryGenerator::unflattenTransformMatr
//--------------------------------------------------------------------------------------------------
bool RivExtrudedCurveIntersectionGeometryGenerator::isAnyGeometryPresent() const
{
if ( m_triangleVxes->size() == 0 )
{
return false;
}
return true;
return m_triangleVxes->size() != 0;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -110,7 +110,7 @@ void RivFemIntersectionGrid::cellCornerIndices( size_t globalCellIndex, size_t c
auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex );
RigElementType elmType = part->elementType( elementIdx );
if ( !( elmType == HEX8 || elmType == HEX8P ) ) return;
if ( elmType != HEX8 && elmType != HEX8P ) return;
int elmIdx = static_cast<int>( elementIdx );
const int partId = part->elementPartId();

View File

@@ -273,9 +273,7 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve( const cvf::Vec
}
}
if ( closestPoint->isUndefined() ) return false;
return true;
return !closestPoint->isUndefined();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -51,7 +51,7 @@ cvf::ref<cvf::Part> RivBoxGeometryGenerator::createBoxFromVertices( const std::v
cvf::ref<cvf::Vec3fArray> cvfVertices = new cvf::Vec3fArray;
cvfVertices->assign( boxVertices );
if ( !( cvfVertices.notNull() && cvfVertices->size() != 0 ) ) return nullptr;
if ( !cvfVertices.notNull() || cvfVertices->size() == 0 ) return nullptr;
geo->setVertexArray( cvfVertices.p() );

View File

@@ -275,7 +275,6 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering( cvf::Effect* effect
// Polygon offset
if ( true )
{
cvf::ref<cvf::RenderStatePolygonOffset> polyOffset = new cvf::RenderStatePolygonOffset;
polyOffset->configurePolygonPositiveOffset();

View File

@@ -78,7 +78,7 @@ void RivContourMapProjectionPartMgr::appendPickPointVisToModel( cvf::ModelBasicL
{
caf::MeshEffectGenerator meshEffectGen( cvf::Color3::MAGENTA );
meshEffectGen.setLineWidth( 1.0f );
meshEffectGen.createAndConfigurePolygonOffsetRenderState( caf::PO_2 );
caf::MeshEffectGenerator::createAndConfigurePolygonOffsetRenderState( caf::PO_2 );
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Part> part = new cvf::Part;
@@ -153,7 +153,7 @@ void RivContourMapProjectionPartMgr::appendContourLinesToModel( const cvf::Camer
{
caf::MeshEffectGenerator meshEffectGen( lineColor );
meshEffectGen.setLineWidth( 1.0f );
meshEffectGen.createAndConfigurePolygonOffsetRenderState( caf::PO_1 );
caf::MeshEffectGenerator::createAndConfigurePolygonOffsetRenderState( caf::PO_1 );
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();

View File

@@ -465,7 +465,7 @@ void RivTensorResultPartMgr::createResultColorTextureCoords( cvf::Vec2fArray*
//--------------------------------------------------------------------------------------------------
bool RivTensorResultPartMgr::isTensorAddress( RigFemResultAddress address )
{
if ( !( address.resultPosType == RIG_ELEMENT_NODAL || address.resultPosType == RIG_INTEGRATION_POINT ) )
if ( address.resultPosType != RIG_ELEMENT_NODAL && address.resultPosType != RIG_INTEGRATION_POINT )
{
return false;
}
@@ -509,12 +509,7 @@ bool RivTensorResultPartMgr::isValid( cvf::Vec3f resultVector )
//--------------------------------------------------------------------------------------------------
bool RivTensorResultPartMgr::isPressure( float principalValue )
{
if ( principalValue >= 0 )
{
return true;
}
return false;
return principalValue >= 0;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -157,10 +157,8 @@ bool RivTextAnnotationPartMgr::isTextInBoundingBox( const cvf::BoundingBox& boun
if ( !coll ) return false;
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate( boundingBox, 3 );
if ( effectiveBoundingBox.contains( getAnchorPointInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) ) ||
effectiveBoundingBox.contains( getLabelPointInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) ) )
return true;
return false;
return effectiveBoundingBox.contains( getAnchorPointInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) ) ||
effectiveBoundingBox.contains( getLabelPointInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -63,12 +63,7 @@ RivTextureCoordsCreator::RivTextureCoordsCreator( RimEclipseCellColors*
//--------------------------------------------------------------------------------------------------
bool RivTextureCoordsCreator::isValid()
{
if ( m_quadMapper.isNull() || m_resultAccessor.isNull() || m_texMapper.isNull() )
{
return false;
}
return true;
return !( m_quadMapper.isNull() || m_resultAccessor.isNull() || m_texMapper.isNull() );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -152,7 +152,7 @@ bool RivWellPathPartMgr::isWellPathEnabled( const cvf::BoundingBox& wellPathClip
if ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF ) return false;
if ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::ALL_ON && m_rimWellPath->showWellPath() == false ) return false;
if ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::ALL_ON && !m_rimWellPath->showWellPath() ) return false;
if ( !isWellPathWithinBoundingBox( wellPathClipBoundingBox ) ) return false;
@@ -236,7 +236,10 @@ void RivWellPathPartMgr::appendWellPathAttributesToModel( cvf::ModelBasicList*
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( attribute );
cvf::Collection<cvf::Part> parts;
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, attribute->defaultComponentColor() );
RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( &parts,
displayCoords,
radii,
attribute->defaultComponentColor() );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
@@ -268,7 +271,10 @@ void RivWellPathPartMgr::appendWellPathAttributesToModel( cvf::ModelBasicList*
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( attribute );
cvf::Collection<cvf::Part> parts;
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, attribute->defaultComponentColor() );
RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( &parts,
displayCoords,
radii,
attribute->defaultComponentColor() );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
@@ -352,7 +358,7 @@ void RivWellPathPartMgr::appendWellMeasurementsToModel( cvf::ModelBasicList*
// Use the view legend config to find color, if only one type of measurement is selected.
cvf::Color3f color = cvf::Color3f( wellMeasurementInView->legendConfig()->scalarMapper()->mapToColor( wellMeasurement->value() ) );
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, color );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );

View File

@@ -312,7 +312,7 @@ cvf::ref<cvf::DrawableGeo> RivSurfaceIntersectionGeometryGenerator::generateSurf
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivSurfaceIntersectionGeometryGenerator::createMeshDrawable()
{
if ( !( m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0 ) ) return nullptr;
if ( !m_cellBorderLineVxes.notNull() || m_cellBorderLineVxes->size() == 0 ) return nullptr;
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray( m_cellBorderLineVxes.p() );
@@ -329,7 +329,7 @@ cvf::ref<cvf::DrawableGeo> RivSurfaceIntersectionGeometryGenerator::createMeshDr
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivSurfaceIntersectionGeometryGenerator::createFaultMeshDrawable()
{
if ( !( m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0 ) ) return nullptr;
if ( !m_faultCellBorderLineVxes.notNull() || m_faultCellBorderLineVxes->size() == 0 ) return nullptr;
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray( m_faultCellBorderLineVxes.p() );
@@ -389,10 +389,5 @@ RimSurfaceInView* RivSurfaceIntersectionGeometryGenerator::intersection() const
//--------------------------------------------------------------------------------------------------
bool RivSurfaceIntersectionGeometryGenerator::isAnyGeometryPresent() const
{
if ( m_triangleVxes->size() == 0 )
{
return false;
}
return true;
return m_triangleVxes->size() != 0;
}

View File

@@ -603,7 +603,7 @@ void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* le
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
CVF_ASSERT( gmCase );
RigFemResultPosEnum resPos = tensorResults()->resultPositionType();
RigFemResultPosEnum resPos = RimTensorResults::resultPositionType();
QString resFieldName = tensorResults()->resultFieldName();
RigFemResultAddress resVarAddress( resPos, resFieldName.toStdString(), "" );

View File

@@ -310,11 +310,9 @@ bool RimSimWellInViewCollection::hasVisibleWellCells()
}
}
if ( !hasCells ) return false;
// Todo: Handle range filter intersection
return true;
return hasCells;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1276,12 +1276,7 @@ public:
}
// Write remaining data
if ( !RiaSocketTools::writeBlockData( server, server->currentClient(), (const char*)values.data(), valueIndex * sizeof( double ) ) )
{
return false;
}
return true;
return RiaSocketTools::writeBlockData( server, server->currentClient(), (const char*)values.data(), valueIndex * sizeof( double ) );
}
static std::vector<std::pair<size_t, size_t>> getSelectedCellsForCase( const RimCase* reservoirCase )

View File

@@ -51,4 +51,4 @@ public:
};
#include "cafFactory.h"
typedef caf::Factory<RiaSocketCommand, QString> RiaSocketCommandFactory;
using RiaSocketCommandFactory = caf::Factory<RiaSocketCommand, QString>;

View File

@@ -311,7 +311,7 @@ public:
}
protected:
virtual void drawBackbone( QPainter* ) const override {}
void drawBackbone( QPainter* ) const override {}
private:
std::map<double, RiuBarChartTick> m_posTickTypeAndTexts;

View File

@@ -35,7 +35,7 @@ class RiuComparisonViewMover : public QObject
public:
RiuComparisonViewMover( caf::Viewer* viewer );
virtual bool eventFilter( QObject* watched, QEvent* event ) override;
bool eventFilter( QObject* watched, QEvent* event ) override;
void paintMoverHandles( QPainter* painter );

View File

@@ -79,7 +79,7 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
}
if ( lineColor.isEmpty() && symbolColor.isEmpty() ) return;
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
@@ -121,7 +121,7 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
if ( !color.isEmpty() )
{
@@ -159,7 +159,7 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression colorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
if ( !color.isEmpty() )
{
@@ -196,7 +196,7 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
if ( !color.isEmpty() )
{
@@ -250,7 +250,7 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
if ( !color.isEmpty() )
{
@@ -304,7 +304,7 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
QRegularExpression textColorRegExp( "text-color:\\s*([#a-zA-Z0-9]+)" );
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
if ( !textColor.isEmpty() )
{
@@ -349,7 +349,7 @@ void RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum theme )
s_qwtPlotItemPropertiesMap.clear();
applyStyleSheet( theme );
const QWidgetList allWidgets = RiaGuiApplication::instance()->allWidgets();
const QWidgetList allWidgets = QApplication::allWidgets();
for ( QWidget* widget : allWidgets )
{
widget->style()->unpolish( widget );
@@ -503,7 +503,7 @@ bool RiuGuiTheme::writeStyleSheetToFile( RiaDefines::ThemeEnum theme, const QStr
preparseStyleSheet( theme, modifiedStyleSheet );
RiaGuiApplication* app = RiaGuiApplication::instance();
app->setStyleSheet( modifiedStyleSheet );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->allWidgets();
const QWidgetList topLevelWidgets = QApplication::allWidgets();
for ( QWidget* widget : topLevelWidgets )
{
widget->style()->unpolish( widget );
@@ -768,7 +768,7 @@ void RiuGuiTheme::preparseStyleSheet( RiaDefines::ThemeEnum theme, QString& styl
QRegularExpression paletteRegExp( regExp );
QRegularExpressionMatchIterator matchIterator = paletteRegExp.globalMatch( styleSheet );
QPalette palette = RiaGuiApplication::instance()->palette();
QPalette palette = QApplication::palette();
while ( matchIterator.hasNext() )
{

View File

@@ -70,7 +70,7 @@ void RiuMessagePanel::addMessage( RILogLevel messageLevel, const QString& msg )
QTextCharFormat form = m_textEdit->currentCharFormat();
form.setForeground( clr );
form.setFontWeight( messageLevel == RILogLevel::RI_LL_ERROR ? QFont::DemiBold : QFont::Normal );
form.setFontItalic( messageLevel == RILogLevel::RI_LL_DEBUG ? true : false );
form.setFontItalic( messageLevel == RILogLevel::RI_LL_DEBUG );
m_textEdit->setCurrentCharFormat( form );
m_textEdit->appendPlainText( msg );

View File

@@ -39,12 +39,12 @@ void RiuTools::enableAllActionsOnShow( QObject* object, QMenu* menu )
{
if ( object && menu )
{
object->connect( menu,
&QMenu::aboutToShow,
[menu]()
{
for ( auto act : menu->actions() )
act->setEnabled( true );
} );
QObject::connect( menu,
&QMenu::aboutToShow,
[menu]()
{
for ( auto act : menu->actions() )
act->setEnabled( true );
} );
}
}

View File

@@ -98,7 +98,7 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent )
, m_zScale( 1.0 )
{
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
QFont font = RiaGuiApplication::instance()->font();
QFont font = QApplication::font();
auto viewFontSize = RiaPreferences::current()->defaultSceneFontSize();
font.setPointSize( caf::FontTools::absolutePointSize( viewFontSize ) );

View File

@@ -53,7 +53,7 @@ class QTextStream;
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
\

View File

@@ -7,7 +7,7 @@
#define CAF_ASSERT( expr ) \
do \
{ \
if ( !( expr ) ) \
if ( !( expr ) ) /* NOLINT */ \
{ \
std::cout << __FILE__ << ":" << __LINE__ << ": CAF_ASSERT(" << #expr << ") failed" << std::endl; \
std::abort(); \
@@ -59,4 +59,4 @@ void assertAbort()
assertAbort(); \
} \
} while ( false )
#endif
#endif

View File

@@ -86,8 +86,8 @@ private:
// Define our assert macros
#if CVF_ENABLE_ASSERTS == 1
# define CVF_ASSERT(expr) (void)( (!!(expr)) || (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, #expr, NULL)) || (CVF_DEBUGTRAP(), 0) )
# define CVF_ASSERT_MSG(expr, msg) (void)( (!!(expr)) || (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, #expr, (msg))) || (CVF_DEBUGTRAP(), 0) )
# define CVF_ASSERT(expr) (void)( (!!(expr)) || (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, #expr, NULL)) || (CVF_DEBUGTRAP(), 0) ) /* NOLINT */
# define CVF_ASSERT_MSG(expr, msg) (void)( (!!(expr)) || (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, #expr, (msg))) || (CVF_DEBUGTRAP(), 0) ) /* NOLINT */
# define CVF_FAIL_MSG(msg) (void)( (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, NULL, (msg))) || (CVF_DEBUGTRAP(), 0) )
#else
# define CVF_ASSERT(expr) ((void)0)