#13296 Add file-based surface interface to enable polymorphic file path handling

Add virtual methods (isFileBased, filePath, setFilePath) to RimSurface base
class. Implement these in RimFileSurface and RimRegularFileSurface to provide
a common interface for all file-based surfaces.

Replace class-specific methods (setSurfaceFilePath/surfaceFilePath) with the
common interface methods (setFilePath/filePath) in both RimFileSurface and
RimRegularFileSurface. Update RimEnsembleSurface to use the common interface.

This enables polymorphic treatment of file-based surfaces without changing
the inheritance hierarchy or breaking backward compatibility.

Fixes #13296
This commit is contained in:
Kristian Bendiksen committed 2025-12-15 12:59:32 +01:00
1 parent 4f51687715
commit 3d2449c361
8 files changed
+50 -35

No files matched your search

@@ -156,7 +156,7 @@ RimSurface* RimSurfaceCollection::createSurfaceFromFile( const QString& fileName
else
{
RimFileSurface* fileSurface = new RimFileSurface;
fileSurface->setSurfaceFilePath( fileName );
fileSurface->setFilePath( fileName );
newSurface = fileSurface;
}
@@ -446,7 +446,7 @@ void RimSurfaceCollection::removeMissingFileSurfaces()
RimFileSurface* fileSurface = dynamic_cast<RimFileSurface*>( surface );
if ( fileSurface == nullptr ) continue;
QString filename = fileSurface->surfaceFilePath();
QString filename = fileSurface->filePath();
if ( !QFile::exists( filename ) )
{
missingSurfaces.push_back( fileSurface );
@@ -579,7 +579,7 @@ bool RimSurfaceCollection::containsFileSurface( QString filename )
{
RimFileSurface* fileSurface = dynamic_cast<RimFileSurface*>( surface );
if ( fileSurface == nullptr ) continue;
if ( fileSurface->surfaceFilePath() == filename ) return true;
if ( fileSurface->filePath() == filename ) return true;
}
return false;