Surfaces: Improve UI and usability for surfaces (#6290)

* Add reload command to surface context menus. Still missing the part that actually reloads the data.

* Add additional check for null ptr to avoid crash

* Surfaces: implements reload command in context menu to reload surface data from its source (i.e. a file).
Rename function names to better show what they are actually doing
Refactor a bit to give all RimSurface subclasses the same interface for reloading data.
Also makes sure new RimGridCaseSurface instances are shown by default in the view(s)

* Fixes by clang-format

* Include offset and slice index in surface name shown in project explorer

* Allow importing the same file multiple times

* Disable lighting for surfaces, as it doesn't look good for now. Fixes #6084

* Surfaces: Remove depth offset setting from view. Add slider to depth offset edit for surface

* Create new surfaces only on collection context menu

* Make sure tree view icon is enabled/disabled when the check box is clicked

* Fix depth offset for grid case surfaces, missing base function call.

* Make public method .. public.

* Add reload command to surface context menus. Still missing the part that actually reloads the data.

* Add additional check for null ptr to avoid crash

* Surfaces: implements reload command in context menu to reload surface data from its source (i.e. a file).
Rename function names to better show what they are actually doing
Refactor a bit to give all RimSurface subclasses the same interface for reloading data.
Also makes sure new RimGridCaseSurface instances are shown by default in the view(s)

* Fixes by clang-format

* Include offset and slice index in surface name shown in project explorer

* Allow importing the same file multiple times

* Disable lighting for surfaces, as it doesn't look good for now. Fixes #6084

* Surfaces: Remove depth offset setting from view. Add slider to depth offset edit for surface

* Create new surfaces only on collection context menu

* Make sure tree view icon is enabled/disabled when the check box is clicked

* Fix depth offset for grid case surfaces, missing base function call.

* Make public method .. public.

* Fixes by clang-format

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
jonjenssen
2020-08-11 11:34:34 +02:00
committed by GitHub
parent af44659860
commit bbc659799e
20 changed files with 30895 additions and 164 deletions

View File

@@ -1,6 +1,7 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportSurfacesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadSurfaceFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewGridCaseSurfaceFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportKLayerToPtlFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.h
@@ -8,6 +9,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.h
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportSurfacesFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReloadSurfaceFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewGridCaseSurfaceFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportKLayerToPtlFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.cpp

View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicReloadSurfaceFeature.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSurface.h"
#include "RimSurfaceCollection.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include "cafUtils.h"
#include <QAction>
#include <QFileDialog>
CAF_CMD_SOURCE_INIT( RicReloadSurfaceFeature, "RicReloadSurfaceFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicReloadSurfaceFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadSurfaceFeature::onActionTriggered( bool isChecked )
{
RimProject* proj = RimProject::current();
RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection();
if ( surfColl )
{
// get the Surfaces
std::vector<RimSurface*> surfaces = caf::selectedObjectsByTypeStrict<RimSurface*>();
// ask the collection to reload them
surfColl->reloadSurfaces( surfaces );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadSurfaceFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/Refresh-32.png" ) );
actionToSetup->setText( "Reload" );
}

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicReloadSurfaceFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -152,7 +152,6 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays()
const std::vector<cvf::Vec3d>& nativeVertices = m_usedSurfaceData->vertices();
const std::vector<unsigned>& nativeTriangleIndices = m_usedSurfaceData->triangleIndices();
cvf::Vec3d displayModelOffset = m_hexGrid->displayOffset();
double depthOffset = m_surfaceInView->depthOffset();
m_triVxToCellCornerWeights.reserve( nativeTriangleIndices.size() * 24 );
outputTriangleVertices.reserve( nativeTriangleIndices.size() * 24 );
@@ -191,10 +190,6 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays()
cvf::Vec3d p1 = nativeVertices[nativeTriangleIndices[ntVxIdx + 1]];
cvf::Vec3d p2 = nativeVertices[nativeTriangleIndices[ntVxIdx + 2]];
p0.z() = p0.z() - depthOffset;
p1.z() = p1.z() - depthOffset;
p2.z() = p2.z() - depthOffset;
cvf::BoundingBox triangleBBox;
triangleBBox.add( p0 );
triangleBBox.add( p1 );

View File

@@ -155,6 +155,7 @@ void RivSurfacePartMgr::updateNativeSurfaceColors()
auto mapper = m_surfaceInView->surfaceResultDefinition()->legendConfig()->scalarMapper();
if ( m_usedSurfaceData.notNull() )
{
QString propertyName = m_surfaceInView->surfaceResultDefinition()->propertyName();
auto values = m_usedSurfaceData->propertyValues( propertyName );
@@ -173,14 +174,7 @@ void RivSurfacePartMgr::updateNativeSurfaceColors()
}
float effectiveOpacityLevel = 1.0;
bool disableLighting = false;
Rim3dView* view = nullptr;
m_surfaceInView->firstAncestorOfType( view );
if ( view )
{
disableLighting = view->isLightingDisabled();
}
bool disableLighting = true; // always disable lighting for now, as it doesn't look good
RivScalarMapperUtils::applyTextureResultsToPart( m_nativeTrianglesPart.p(),
m_nativeTrianglesTextureCoords.p(),
@@ -333,9 +327,6 @@ void RivSurfacePartMgr::generateNativePartGeometry()
m_usedSurfaceData = m_surfaceInView->surface()->surfaceData();
if ( m_usedSurfaceData.isNull() ) return;
double depthOffset = m_surfaceInView->depthOffset();
displayModOffsett.z() = displayModOffsett.z() + depthOffset;
const std::vector<cvf::Vec3d>& vertices = m_usedSurfaceData->vertices();
cvf::ref<cvf::Vec3fArray> cvfVertices = new cvf::Vec3fArray( vertices.size() );
for ( size_t i = 0; i < vertices.size(); ++i )

View File

@@ -896,21 +896,21 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicConvertFractureTemplateUnitFeature";
}
else if ( dynamic_cast<RimSurfaceCollection*>( firstUiItem ) || dynamic_cast<RimSurface*>( firstUiItem ) )
else if ( dynamic_cast<RimSurfaceCollection*>( firstUiItem ) )
{
menuBuilder << "RicImportSurfacesFeature";
menuBuilder << "RicNewGridSurfaceFeature";
if ( dynamic_cast<RimSurface*>( firstUiItem ) )
{
menuBuilder << "RicExportSurfaceToTsurfFeature";
// menuBuilder << "RicExportKLayerToPtlFeature";
}
}
else if ( dynamic_cast<RimSurface*>( firstUiItem ) )
{
if ( dynamic_cast<RimGridCaseSurface*>( firstUiItem ) )
{
menuBuilder << "RicExportKLayerToPtlFeature";
}
menuBuilder << "RicExportSurfaceToTsurfFeature";
menuBuilder << "Separator";
menuBuilder << "RicReloadSurfaceFeature";
}
else if ( dynamic_cast<RimAnnotationCollection*>( firstUiItem ) ||
dynamic_cast<RimAnnotationGroupCollection*>( firstUiItem ) )

View File

@@ -58,7 +58,7 @@ void RimFileSurface::setSurfaceFilePath( const QString& filePath )
setUserDescription( QFileInfo( filePath ).fileName() );
}
clearCachedNativeFileData();
clearCachedNativeData();
}
//--------------------------------------------------------------------------------------------------
@@ -74,7 +74,7 @@ QString RimFileSurface::surfaceFilePath()
//--------------------------------------------------------------------------------------------------
bool RimFileSurface::onLoadData()
{
return updateSurfaceDataFromFile();
return updateSurfaceData();
}
//--------------------------------------------------------------------------------------------------
@@ -88,8 +88,8 @@ void RimFileSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
if ( changedField == &m_surfaceDefinitionFilePath )
{
clearCachedNativeFileData();
updateSurfaceDataFromFile();
clearCachedNativeData();
updateSurfaceData();
RimSurfaceCollection* surfColl;
this->firstAncestorOrThisOfTypeAsserted( surfColl );
@@ -98,9 +98,11 @@ void RimFileSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
//--------------------------------------------------------------------------------------------------
/// Regenerate the surface geometry, using the offset specified.
/// If the surface data hasn't been loaded from file yet, load it.
/// Returns false for fatal failure
//--------------------------------------------------------------------------------------------------
bool RimFileSurface::updateSurfaceDataFromFile()
bool RimFileSurface::updateSurfaceData()
{
bool result = true;
if ( m_vertices.empty() )
@@ -137,7 +139,7 @@ bool RimFileSurface::updateSurfaceDataFromFile()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileSurface::clearCachedNativeFileData()
void RimFileSurface::clearCachedNativeData()
{
m_vertices.clear();
m_tringleIndices.clear();

View File

@@ -37,9 +37,11 @@ public:
bool onLoadData() override;
protected:
bool updateSurfaceData() override;
void clearCachedNativeData() override;
private:
bool updateSurfaceDataFromFile();
void clearCachedNativeFileData();
bool loadDataFromFile();
private:

View File

@@ -83,7 +83,7 @@ void RimGridCaseSurface::setSliceTypeAndOneBasedIndex( RiaDefines::GridCaseAxis
//--------------------------------------------------------------------------------------------------
bool RimGridCaseSurface::onLoadData()
{
return updateSurfaceDataFromGridCase();
return updateSurfaceData();
}
//--------------------------------------------------------------------------------------------------
@@ -109,6 +109,8 @@ void RimGridCaseSurface::defineEditorAttribute( const caf::PdmFieldHandle* field
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
RimSurface::defineEditorAttribute( field, uiConfigName, attribute );
caf::PdmUiSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiSliderEditorAttribute*>( attribute );
if ( myAttr && m_case )
{
@@ -143,9 +145,9 @@ void RimGridCaseSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
if ( changedField == &m_case || changedField == &m_sliceDirection || changedField == &m_oneBasedSliceIndex )
{
clearNativeGridData();
updateSurfaceDataFromGridCase();
updateUserDescription();
clearCachedNativeData();
updateSurfaceData();
// updateUserDescription();
RimSurfaceCollection* surfColl;
this->firstAncestorOrThisOfTypeAsserted( surfColl );
@@ -158,7 +160,7 @@ void RimGridCaseSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
//--------------------------------------------------------------------------------------------------
void RimGridCaseSurface::extractDataFromGrid()
{
clearNativeGridData();
clearCachedNativeData();
if ( m_sliceDirection() == RiaDefines::GridCaseAxis::UNDEFINED_AXIS ) return;
@@ -270,7 +272,7 @@ void RimGridCaseSurface::extractDataFromGrid()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCaseSurface::clearNativeGridData()
void RimGridCaseSurface::clearCachedNativeData()
{
m_vertices.clear();
m_tringleIndices.clear();
@@ -306,46 +308,10 @@ std::pair<cvf::uint, cvf::uint> RimGridCaseSurface::getStructGridIndex( cvf::Str
return localIndexPair;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCaseSurface::updateUserDescription()
{
QString name;
auto dirValue = m_sliceDirection().value();
switch ( dirValue )
{
case RiaDefines::GridCaseAxis::AXIS_I:
name = "Surface I : ";
break;
case RiaDefines::GridCaseAxis::AXIS_J:
name = "Surface J : ";
break;
case RiaDefines::GridCaseAxis::AXIS_K:
name = "Surface K : ";
break;
case RiaDefines::GridCaseAxis::UNDEFINED_AXIS:
default:
name = "Surface ";
break;
}
name += QString::number( m_oneBasedSliceIndex );
const double epsilon = 1.0e-3;
if ( std::fabs( depthOffset() ) > epsilon )
{
name += ", Offset : " + QString::number( depthOffset() );
}
setUserDescription( name );
}
//--------------------------------------------------------------------------------------------------
/// Returns false for fatal failure
//--------------------------------------------------------------------------------------------------
bool RimGridCaseSurface::updateSurfaceDataFromGridCase()
bool RimGridCaseSurface::updateSurfaceData()
{
if ( m_vertices.empty() || m_tringleIndices.empty() || m_structGridIndices.empty() )
{
@@ -440,3 +406,31 @@ bool RimGridCaseSurface::exportStructSurfaceFromGridCase( std::vector<cvf::Vec3d
return true;
}
//--------------------------------------------------------------------------------------------------
/// Return the name to show in the tree selector, including the slice index
//--------------------------------------------------------------------------------------------------
QString RimGridCaseSurface::fullName() const
{
QString retval = RimSurface::fullName();
auto dirValue = m_sliceDirection().value();
switch ( dirValue )
{
case RiaDefines::GridCaseAxis::AXIS_I:
retval += " - I:";
break;
case RiaDefines::GridCaseAxis::AXIS_J:
retval += " - J:";
break;
case RiaDefines::GridCaseAxis::AXIS_K:
retval += " - K:";
break;
case RiaDefines::GridCaseAxis::UNDEFINED_AXIS:
default:
break;
}
retval += QString::number( m_oneBasedSliceIndex );
return retval;
}

View File

@@ -40,7 +40,6 @@ public:
void setSliceTypeAndOneBasedIndex( RiaDefines::GridCaseAxis sliceType, int oneBasedSliceIndex );
bool onLoadData() override;
void updateUserDescription();
bool exportStructSurfaceFromGridCase( std::vector<cvf::Vec3d>* vertices,
std::vector<std::pair<uint, uint>>* structGridVertexIndices );
@@ -53,13 +52,15 @@ protected:
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
bool updateSurfaceData() override;
void clearCachedNativeData() override;
QString fullName() const override;
private:
bool updateSurfaceDataFromGridCase();
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void extractDataFromGrid();
void clearNativeGridData();
std::pair<uint, uint> getStructGridIndex( cvf::StructGridInterface::FaceType cellface, cvf::ubyte localVertexIndex );

View File

@@ -40,7 +40,16 @@ RimSurface::RimSurface()
CAF_PDM_InitFieldNoDefault( &m_userDescription, "SurfaceUserDecription", "Name", "", "", "" );
CAF_PDM_InitField( &m_color, "SurfaceColor", cvf::Color3f( 0.5f, 0.3f, 0.2f ), "Color", "", "", "" );
// CAF_PDM_InitField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset", "", "", "" );
CAF_PDM_InitField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset", "", "", "" );
m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" );
m_nameProxy.registerGetMethod( this, &RimSurface::fullName );
m_nameProxy.uiCapability()->setUiReadOnly( true );
m_nameProxy.uiCapability()->setUiHidden( true );
m_nameProxy.xmlCapability()->disableIO();
setDeletable( true );
}
@@ -76,6 +85,14 @@ QString RimSurface::userDescription()
return m_userDescription();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSurface::userDescriptionField()
{
return &m_nameProxy;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -150,14 +167,6 @@ RigSurface* RimSurface::surfaceData()
return m_surfaceData.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSurface::userDescriptionField()
{
return &m_userDescription;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -187,3 +196,43 @@ void RimSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons
surfColl->updateViews( {this} );
}
}
//--------------------------------------------------------------------------------------------------
/// Make the surface clear its internal data and reload them from the source data (i.e. file or grid)
//--------------------------------------------------------------------------------------------------
void RimSurface::reloadData()
{
clearCachedNativeData();
updateSurfaceData();
}
//--------------------------------------------------------------------------------------------------
/// Return the name to show in the tree selector, including the depth offset if not 0
//--------------------------------------------------------------------------------------------------
QString RimSurface::fullName() const
{
if ( depthOffset() != 0.0 )
{
return QString( "%1 - Offset:%2" ).arg( m_userDescription, QString::number( depthOffset() ) );
}
return QString( "%1" ).arg( m_userDescription );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurface::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
auto doubleSliderAttrib = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( doubleSliderAttrib )
{
if ( field == &m_depthOffset )
{
doubleSliderAttrib->m_minimum = -2000;
doubleSliderAttrib->m_maximum = 2000;
}
}
}

View File

@@ -21,6 +21,7 @@
#include "cafPdmObject.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmProxyValueField.h"
#include "cvfObject.h"
#include "cvfVector3.h"
@@ -41,30 +42,38 @@ public:
cvf::Color3f color() const;
RigSurface* surfaceData();
QString userDescription();
void setUserDescription( const QString& description );
QString userDescription();
virtual QString fullName() const;
virtual bool onLoadData() = 0;
void loadDataIfRequired();
void reloadData();
protected:
void setUserDescription( const QString& description );
void setSurfaceData( RigSurface* surface );
void applyDepthOffsetIfNeeded( std::vector<cvf::Vec3d>* vertices ) const;
double depthOffset() const;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
static void applyDepthOffset( const cvf::Vec3d& offset, std::vector<cvf::Vec3d>* vertices );
virtual bool onLoadData() = 0;
private:
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmField<QString> m_userDescription;
caf::PdmField<cvf::Color3f> m_color;
caf::PdmField<double> m_depthOffset;
virtual bool updateSurfaceData() = 0;
virtual void clearCachedNativeData() = 0;
private:
caf::PdmField<QString> m_userDescription;
caf::PdmField<cvf::Color3f> m_color;
caf::PdmField<double> m_depthOffset;
caf::PdmProxyValueField<QString> m_nameProxy;
cvf::ref<RigSurface> m_surfaceData;
};

View File

@@ -61,34 +61,13 @@ void RimSurfaceCollection::addSurface( RimSurface* surface )
//--------------------------------------------------------------------------------------------------
RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fileNames )
{
QStringList newFileNames;
std::vector<RimSurface*> surfacesToReload;
for ( const QString& newFileName : fileNames )
{
bool isFound = false;
for ( RimSurface* surface : m_surfaces() )
{
RimFileSurface* fileSurface = dynamic_cast<RimFileSurface*>( surface );
if ( fileSurface && fileSurface->surfaceFilePath() == newFileName )
{
surfacesToReload.push_back( surface );
isFound = true;
break;
}
}
if ( !isFound )
{
newFileNames.push_back( newFileName );
}
}
size_t newSurfCount = 0;
size_t existingSurfCount = m_surfaces().size();
QString errorMessages;
for ( const QString& newFileName : newFileNames )
std::vector<RimSurface*> surfacesToLoad;
for ( const QString& newFileName : fileNames )
{
RimFileSurface* newSurface = new RimFileSurface;
@@ -105,8 +84,7 @@ RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fi
else
{
this->addSurface( newSurface );
surfacesToReload.push_back( newSurface );
surfacesToLoad.push_back( newSurface );
++newSurfCount;
}
}
@@ -118,7 +96,7 @@ RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fi
this->updateConnectedEditors();
updateViews( surfacesToReload );
updateViews( surfacesToLoad );
if ( newSurfCount > 0 && !m_surfaces.empty() )
{
@@ -130,6 +108,22 @@ RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fi
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceCollection::reloadSurfaces( std::vector<RimSurface*> surfaces )
{
// ask the surfaces given to reload its data
for ( RimSurface* surface : surfaces )
{
surface->reloadData();
}
this->updateConnectedEditors();
updateViews( surfaces );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -142,12 +136,22 @@ RimSurface* RimSurfaceCollection::addGridCaseSurface( RimCase* sourceCase )
auto sliceType = RiaDefines::GridCaseAxis::AXIS_K;
s->setSliceTypeAndOneBasedIndex( sliceType, oneBasedSliceIndex );
s->updateUserDescription();
s->setUserDescription( "Surface" );
if ( !s->onLoadData() )
{
RiaLogging::warning( "Add Grid Case Surface : Could not create the grid case surface. Don't know why." );
return nullptr;
}
m_surfaces.push_back( s );
this->updateConnectedEditors();
std::vector<RimSurface*> surfacesToRefresh;
surfacesToRefresh.push_back( s );
updateViews( surfacesToRefresh );
return s;
}

View File

@@ -36,6 +36,8 @@ public:
RimSurface* importSurfacesFromFiles( const QStringList& fileNames );
RimSurface* addGridCaseSurface( RimCase* sourceCase );
void reloadSurfaces( std::vector<RimSurface*> surfaces );
std::vector<RimSurface*> surfaces() const;
void loadData();

View File

@@ -51,9 +51,6 @@ RimSurfaceInView::RimSurfaceInView()
CAF_PDM_InitFieldNoDefault( &m_surface, "SurfaceRef", "Surface", "", "", "" );
m_surface.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset", "", "", "" );
m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" );
m_resultDefinition.uiCapability()->setUiHidden( true );
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
@@ -74,7 +71,7 @@ RimSurfaceInView::~RimSurfaceInView()
//--------------------------------------------------------------------------------------------------
QString RimSurfaceInView::name() const
{
if ( m_surface ) return m_surface->userDescription();
if ( m_surface ) return m_surface->fullName();
return "";
}
@@ -126,14 +123,6 @@ RimSurfaceResultDefinition* RimSurfaceInView::surfaceResultDefinition()
return m_resultDefinition();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimSurfaceInView::depthOffset() const
{
return m_depthOffset;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -203,6 +192,8 @@ void RimSurfaceInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField
const QVariant& oldValue,
const QVariant& newValue )
{
this->updateUiIconFromToggleField();
bool scheduleRedraw = false;
if ( changedField == &m_isActive || changedField == &m_useSeparateDataSource || changedField == &m_separateDataSource )
@@ -214,11 +205,6 @@ void RimSurfaceInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField
clearGeometry();
scheduleRedraw = true;
}
else if ( changedField == &m_depthOffset )
{
clearGeometry();
scheduleRedraw = true;
}
if ( scheduleRedraw )
{
@@ -235,29 +221,10 @@ void RimSurfaceInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_showInactiveCells );
uiOrdering.add( &m_depthOffset );
this->defineSeparateDataSourceUi( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInView::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
auto doubleSliderAttrib = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( doubleSliderAttrib )
{
if ( field == &m_depthOffset )
{
doubleSliderAttrib->m_minimum = -2000;
doubleSliderAttrib->m_maximum = 2000;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -275,3 +242,11 @@ caf::PdmFieldHandle* RimSurfaceInView::userDescriptionField()
{
return &m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInView::initAfterRead()
{
this->updateUiIconFromToggleField();
}

View File

@@ -51,8 +51,6 @@ public:
bool isNativeSurfaceResultsActive() const;
RimSurfaceResultDefinition* surfaceResultDefinition();
double depthOffset() const;
void clearGeometry();
RivSurfacePartMgr* surfacePartMgr();
@@ -61,9 +59,7 @@ public:
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
virtual void initAfterRead() override;
private:
virtual RimIntersectionResultsDefinitionCollection* findSeparateResultsCollection() override;
@@ -75,7 +71,6 @@ private:
caf::PdmProxyValueField<QString> m_name;
caf::PdmPtrField<RimSurface*> m_surface;
caf::PdmField<double> m_depthOffset;
caf::PdmChildField<RimSurfaceResultDefinition*> m_resultDefinition;
cvf::ref<RivSurfacePartMgr> m_surfacePartMgr;

View File

@@ -144,6 +144,8 @@ void RimSurfaceInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
const QVariant& oldValue,
const QVariant& newValue )
{
this->updateUiIconFromToggleField();
if ( changedField == &m_isChecked )
{
RimGridView* ownerView;
@@ -152,6 +154,14 @@ void RimSurfaceInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::initAfterRead()
{
this->updateUiIconFromToggleField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -56,6 +56,9 @@ public:
std::vector<RimRegularLegendConfig*> legendConfigs();
protected:
virtual void initAfterRead() override;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;