diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.cpp index fc513a3154..6c5508e9ba 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.cpp @@ -26,6 +26,14 @@ CAF_PDM_SOURCE_INIT( RimRegularFileSurface, "RegularFileSurface" ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimRegularFileSurface::propertyName() +{ + return "Property Values in File"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -72,8 +80,7 @@ bool RimRegularFileSurface::onLoadData() if ( !values.empty() ) { - const QString propertyName = "File Property Values"; - setProperty( propertyName, values ); + setProperty( RimRegularFileSurface::propertyName(), values ); } RimRegularSurface::onLoadData(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.h index 2a969fe263..fe038aa979 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularFileSurface.h @@ -29,6 +29,8 @@ public: bool onLoadData() override; + static QString propertyName(); + // File-based surface interface (from RimSurface) bool isFileBased() const override { return true; } QString filePath() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularSurface.cpp index 7ecbe49014..166e118bdc 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimRegularSurface.cpp @@ -18,6 +18,8 @@ #include "RimRegularSurface.h" +#include "RiaLogging.h" + #include "Surface/RigSurface.h" #include "RimSurfaceCollection.h" @@ -208,6 +210,14 @@ void RimRegularSurface::clearCachedNativeData() //-------------------------------------------------------------------------------------------------- bool RimRegularSurface::updateSurfaceData() { + if ( m_depthProperty() != internal::fixedDepth() && !m_properties.contains( m_depthProperty() ) ) + { + RiaLogging::warning( QString( "Surface '%1': Depth property '%2' not found." ).arg( userDescription(), m_depthProperty() ) ); + setSurfaceData( nullptr ); + + return false; + } + // Adapted from xtgeo surf_xyz_from_ij auto computeXyzFromIj = []( int i, int j, double depth, double xori, double yori, double xinc, double yinc, double rotationDegrees ) -> cvf::Vec3d @@ -390,12 +400,9 @@ void RimRegularSurface::setProperty( const QString& key, const std::vector& values ); - bool setPropertyAsDepth( const QString& key ); + void setPropertyAsDepth( const QString& key ); int nx() const; int ny() const; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index 3d97b3dc4a..4567e17e87 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -151,6 +151,7 @@ RimSurface* RimSurfaceCollection::createSurfaceFromFile( const QString& fileName { auto regularFileSurface = new RimRegularFileSurface; regularFileSurface->setFilePath( fileName ); + regularFileSurface->setPropertyAsDepth( RimRegularFileSurface::propertyName() ); newSurface = regularFileSurface; } else diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcRegularSurface.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcRegularSurface.cpp index 6ed4ec3cdf..d63f29d14f 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcRegularSurface.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcRegularSurface.cpp @@ -94,8 +94,7 @@ std::expected RimcRegularSurface_setPropertyAsDe RimRegularSurface* surface = self(); if ( !surface ) return std::unexpected( "No surface found" ); - if ( !surface->setPropertyAsDepth( m_name ) ) return std::unexpected( "Failed to set depth property." ); - + surface->setPropertyAsDepth( m_name ); surface->onLoadData(); if ( auto coll = surface->firstAncestorOrThisOfType() ) diff --git a/GrpcInterface/Python/rips/tests/test_surfaces.py b/GrpcInterface/Python/rips/tests/test_surfaces.py index e7b6405d81..8a91304456 100644 --- a/GrpcInterface/Python/rips/tests/test_surfaces.py +++ b/GrpcInterface/Python/rips/tests/test_surfaces.py @@ -68,9 +68,6 @@ def test_create_regular_surface(rips_instance, initialize_test): assert s.nx == nx assert s.ny == ny - with pytest.raises(rips.RipsError, match="Failed to set depth property."): - s.set_property_as_depth(name="non_existing_property") - with pytest.raises( rips.RipsError, match="Failed to set property: incorrect dimensions." ): @@ -84,10 +81,6 @@ def test_create_regular_surface(rips_instance, initialize_test): s.nx = 30 s.update() - # 'depth' property is now gone - with pytest.raises(rips.RipsError, match="Failed to set depth property."): - s.set_property_as_depth(name="depth") - def test_create_regular_surface_invalid_values(rips_instance, initialize_test): case_path = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"