mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Surface: Support for folders, copy and drag'n'drop (#6335)
* Enable surface reordering support. Automatically update surface in view ordering based on surface collection ordering * Remove obsolete code * Enable drag'n'drop support for surfaces within a surface collection. Still missing the collection update part. * Bring back code lost in prev. commit * Add code to accept drops in surface collections. Keep view in sync. * Add command for adding additional surface folders. * Make sure we use the current surface collection as our parent when importing * Enable name editing. Make sure we use the correct surface collection when importing/creating surfaces * More work on getting surface collections working. * Clean up naming * Make sure name for surfaceinviewcollection is read only * Support drawing surfaces from subcollections, too * Allow deleting subfolders. Fix legends in view * Refactor topmost flag for surface collections. * Fix reload surface to work in all subfolders, too Add copy surface skeleton. Actual copy operation is still missing * Add support for copying surfaces * Remove possibility to choose I and J slice directions for grid case surfaces. * Fix warnings. * Make sure we create the surface folder at the correct level * More warning fix * Use XML serialization for copy operation * Fix missing delete * Fix typo * Remove unnecessary method.
This commit is contained in:
@@ -900,6 +900,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
menuBuilder << "RicImportSurfacesFeature";
|
||||
menuBuilder << "RicNewGridSurfaceFeature";
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicNewSurfaceCollectionFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimSurface*>( firstUiItem ) )
|
||||
{
|
||||
@@ -910,6 +912,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
|
||||
menuBuilder << "RicExportSurfaceToTsurfFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicCopySurfaceFeature";
|
||||
menuBuilder << "RicReloadSurfaceFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimAnnotationCollection*>( firstUiItem ) ||
|
||||
|
||||
@@ -566,6 +566,7 @@ void RimGridView::updateSurfacesInViewTreeItems()
|
||||
m_surfaceCollection = new RimSurfaceInViewCollection();
|
||||
}
|
||||
|
||||
m_surfaceCollection->setSurfaceCollection( surfColl );
|
||||
m_surfaceCollection->updateFromSurfaceCollection();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
RimNamedObject( void );
|
||||
~RimNamedObject( void ) override;
|
||||
|
||||
QString name() const;
|
||||
void setName( const QString& name );
|
||||
virtual QString name() const;
|
||||
void setName( const QString& name );
|
||||
|
||||
protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
@@ -65,6 +65,7 @@ RimOilField::RimOilField( void )
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &surfaceCollection, "SurfaceCollection", "Surfaces", "", "", "" );
|
||||
surfaceCollection = new RimSurfaceCollection();
|
||||
surfaceCollection->setAsTopmostFolder();
|
||||
|
||||
completionTemplateCollection = new RimCompletionTemplateCollection;
|
||||
analysisModels = new RimEclipseCaseCollection();
|
||||
|
||||
@@ -77,6 +77,23 @@ bool RimFileSurface::onLoadData()
|
||||
return updateSurfaceData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurface* RimFileSurface::createCopy()
|
||||
{
|
||||
RimFileSurface* newSurface = dynamic_cast<RimFileSurface*>(
|
||||
xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
|
||||
if ( !newSurface->onLoadData() )
|
||||
{
|
||||
delete newSurface;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return newSurface;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -35,7 +35,8 @@ public:
|
||||
void setSurfaceFilePath( const QString& filePath );
|
||||
QString surfaceFilePath();
|
||||
|
||||
bool onLoadData() override;
|
||||
bool onLoadData() override;
|
||||
RimSurface* createCopy() override;
|
||||
|
||||
protected:
|
||||
bool updateSurfaceData() override;
|
||||
|
||||
@@ -42,15 +42,7 @@ RimGridCaseSurface::RimGridCaseSurface()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_case, "SourceCase", "Source Case", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_sliceDirection,
|
||||
"SnapShotDirection",
|
||||
caf::AppEnum<RiaDefines::GridCaseAxis>( RiaDefines::GridCaseAxis::UNDEFINED_AXIS ),
|
||||
"Range Filter Slice",
|
||||
"",
|
||||
"",
|
||||
"" );
|
||||
|
||||
CAF_PDM_InitField( &m_oneBasedSliceIndex, "SliceIndex", 1, "Slice Index", "", "", "" );
|
||||
CAF_PDM_InitField( &m_oneBasedSliceIndex, "SliceIndex", 1, "Slice Index (K)", "", "", "" );
|
||||
m_oneBasedSliceIndex.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
|
||||
}
|
||||
|
||||
@@ -72,9 +64,8 @@ void RimGridCaseSurface::setCase( RimCase* sourceCase )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCaseSurface::setSliceTypeAndOneBasedIndex( RiaDefines::GridCaseAxis sliceType, int oneBasedSliceIndex )
|
||||
void RimGridCaseSurface::setOneBasedIndex( int oneBasedSliceIndex )
|
||||
{
|
||||
m_sliceDirection = sliceType;
|
||||
m_oneBasedSliceIndex = oneBasedSliceIndex;
|
||||
}
|
||||
|
||||
@@ -86,6 +77,24 @@ bool RimGridCaseSurface::onLoadData()
|
||||
return updateSurfaceData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurface* RimGridCaseSurface::createCopy()
|
||||
{
|
||||
RimGridCaseSurface* newSurface = dynamic_cast<RimGridCaseSurface*>(
|
||||
xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
newSurface->setCase( m_case.value() ); // TODO: case seems to get lost in the xml copy, investigate later
|
||||
|
||||
if ( !newSurface->onLoadData() )
|
||||
{
|
||||
delete newSurface;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return newSurface;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -118,19 +127,7 @@ void RimGridCaseSurface::defineEditorAttribute( const caf::PdmFieldHandle* field
|
||||
if ( !grid ) return;
|
||||
|
||||
myAttr->m_minimum = 1;
|
||||
|
||||
if ( m_sliceDirection() == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
{
|
||||
myAttr->m_maximum = static_cast<int>( grid->cellCountI() );
|
||||
}
|
||||
else if ( m_sliceDirection() == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
{
|
||||
myAttr->m_maximum = static_cast<int>( grid->cellCountJ() );
|
||||
}
|
||||
else if ( m_sliceDirection() == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
{
|
||||
myAttr->m_maximum = static_cast<int>( grid->cellCountK() );
|
||||
}
|
||||
myAttr->m_maximum = static_cast<int>( grid->cellCountK() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,11 +140,10 @@ void RimGridCaseSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
|
||||
{
|
||||
RimSurface::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
|
||||
if ( changedField == &m_case || changedField == &m_sliceDirection || changedField == &m_oneBasedSliceIndex )
|
||||
if ( changedField == &m_case || changedField == &m_oneBasedSliceIndex )
|
||||
{
|
||||
clearCachedNativeData();
|
||||
updateSurfaceData();
|
||||
// updateUserDescription();
|
||||
|
||||
RimSurfaceCollection* surfColl;
|
||||
this->firstAncestorOrThisOfTypeAsserted( surfColl );
|
||||
@@ -162,7 +158,7 @@ void RimGridCaseSurface::extractDataFromGrid()
|
||||
{
|
||||
clearCachedNativeData();
|
||||
|
||||
if ( m_sliceDirection() == RiaDefines::GridCaseAxis::UNDEFINED_AXIS ) return;
|
||||
RiaDefines::GridCaseAxis sliceDirection = RiaDefines::GridCaseAxis::AXIS_K;
|
||||
|
||||
if ( m_case )
|
||||
{
|
||||
@@ -182,20 +178,20 @@ void RimGridCaseSurface::extractDataFromGrid()
|
||||
|
||||
cvf::StructGridInterface::FaceType faceType = cvf::StructGridInterface::NO_FACE;
|
||||
{
|
||||
if ( m_sliceDirection() == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
{
|
||||
faceType = cvf::StructGridInterface::NEG_K;
|
||||
|
||||
minK = zeroBasedLayerIndex;
|
||||
maxK = zeroBasedLayerIndex + 1;
|
||||
}
|
||||
else if ( m_sliceDirection() == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
else if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
{
|
||||
faceType = cvf::StructGridInterface::NEG_J;
|
||||
minJ = zeroBasedLayerIndex;
|
||||
maxJ = zeroBasedLayerIndex + 1;
|
||||
}
|
||||
else if ( m_sliceDirection() == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
else if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
{
|
||||
faceType = cvf::StructGridInterface::NEG_I;
|
||||
minI = zeroBasedLayerIndex;
|
||||
@@ -323,6 +319,8 @@ bool RimGridCaseSurface::updateSurfaceData()
|
||||
std::vector<unsigned> tringleIndices{m_tringleIndices};
|
||||
std::vector<cvf::Vec3d> vertices{m_vertices};
|
||||
|
||||
RiaDefines::GridCaseAxis sliceDirection = RiaDefines::GridCaseAxis::AXIS_K;
|
||||
|
||||
if ( !tringleIndices.empty() )
|
||||
{
|
||||
{
|
||||
@@ -333,15 +331,15 @@ bool RimGridCaseSurface::updateSurfaceData()
|
||||
|
||||
cvf::Vec3d offset = cvf::Vec3d::ZERO;
|
||||
|
||||
if ( m_sliceDirection == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
{
|
||||
offset.x() += delta;
|
||||
}
|
||||
else if ( m_sliceDirection == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
else if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
{
|
||||
offset.y() += delta;
|
||||
}
|
||||
if ( m_sliceDirection == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
{
|
||||
offset.z() += delta;
|
||||
}
|
||||
@@ -377,6 +375,8 @@ bool RimGridCaseSurface::exportStructSurfaceFromGridCase( std::vector<cvf::Vec3d
|
||||
*vertices = m_vertices;
|
||||
*structGridVertexIndices = m_structGridIndices;
|
||||
|
||||
RiaDefines::GridCaseAxis sliceDirection = RiaDefines::GridCaseAxis::AXIS_K;
|
||||
|
||||
if ( !vertices->empty() )
|
||||
{
|
||||
// Permute z-value to avoid numerical issues when surface intersects exactly at cell face
|
||||
@@ -385,15 +385,15 @@ bool RimGridCaseSurface::exportStructSurfaceFromGridCase( std::vector<cvf::Vec3d
|
||||
|
||||
cvf::Vec3d offset = cvf::Vec3d::ZERO;
|
||||
|
||||
if ( m_sliceDirection == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_I )
|
||||
{
|
||||
offset.x() += delta;
|
||||
}
|
||||
else if ( m_sliceDirection == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
else if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_J )
|
||||
{
|
||||
offset.y() += delta;
|
||||
}
|
||||
else if ( m_sliceDirection == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
else if ( sliceDirection == RiaDefines::GridCaseAxis::AXIS_K )
|
||||
{
|
||||
offset.z() += delta;
|
||||
}
|
||||
@@ -413,24 +413,7 @@ bool RimGridCaseSurface::exportStructSurfaceFromGridCase( std::vector<cvf::Vec3d
|
||||
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 += " - K:";
|
||||
retval += QString::number( m_oneBasedSliceIndex );
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,11 @@ public:
|
||||
~RimGridCaseSurface() override;
|
||||
|
||||
void setCase( RimCase* sourceCase );
|
||||
void setSliceTypeAndOneBasedIndex( RiaDefines::GridCaseAxis sliceType, int oneBasedSliceIndex );
|
||||
|
||||
bool onLoadData() override;
|
||||
void setOneBasedIndex( int oneBasedSliceIndex );
|
||||
|
||||
bool onLoadData() override;
|
||||
RimSurface* createCopy() override;
|
||||
|
||||
bool exportStructSurfaceFromGridCase( std::vector<cvf::Vec3d>* vertices,
|
||||
std::vector<std::pair<uint, uint>>* structGridVertexIndices );
|
||||
@@ -57,7 +59,6 @@ protected:
|
||||
QString fullName() const override;
|
||||
|
||||
private:
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
void extractDataFromGrid();
|
||||
@@ -65,9 +66,8 @@ private:
|
||||
std::pair<uint, uint> getStructGridIndex( cvf::StructGridInterface::FaceType cellface, cvf::ubyte localVertexIndex );
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimCase*> m_case;
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::GridCaseAxis>> m_sliceDirection;
|
||||
caf::PdmField<int> m_oneBasedSliceIndex;
|
||||
caf::PdmPtrField<RimCase*> m_case;
|
||||
caf::PdmField<int> m_oneBasedSliceIndex;
|
||||
|
||||
std::vector<unsigned> m_tringleIndices;
|
||||
std::vector<cvf::Vec3d> m_vertices;
|
||||
|
||||
@@ -40,8 +40,6 @@ 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() );
|
||||
|
||||
@@ -145,6 +143,11 @@ double RimSurface::depthOffset() const
|
||||
return m_depthOffset;
|
||||
}
|
||||
|
||||
void RimSurface::setDepthOffset( double depthoffset )
|
||||
{
|
||||
m_depthOffset.setValue( depthoffset );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -45,8 +45,9 @@ public:
|
||||
QString userDescription();
|
||||
void setUserDescription( const QString& description );
|
||||
|
||||
virtual QString fullName() const;
|
||||
virtual bool onLoadData() = 0;
|
||||
virtual QString fullName() const;
|
||||
virtual bool onLoadData() = 0;
|
||||
virtual RimSurface* createCopy() = 0;
|
||||
|
||||
void loadDataIfRequired();
|
||||
void reloadData();
|
||||
@@ -56,6 +57,7 @@ protected:
|
||||
|
||||
void applyDepthOffsetIfNeeded( std::vector<cvf::Vec3d>* vertices ) const;
|
||||
double depthOffset() const;
|
||||
void setDepthOffset( double depthoffset );
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "RimSurface.h"
|
||||
#include "RimSurfaceInView.h"
|
||||
|
||||
#include "cafPdmFieldReorderCapability.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSurfaceCollection, "SurfaceCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -37,8 +39,18 @@ RimSurfaceCollection::RimSurfaceCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_collectionname, "SurfaceUserDecription", "Name", "", "", "" );
|
||||
m_collectionname = "Surfaces";
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_subcollections, "SubCollections", "Surfaces", "", "", "" );
|
||||
m_subcollections.uiCapability()->setUiTreeHidden( true );
|
||||
auto reorderability = caf::PdmFieldReorderCapability::addToField( &m_subcollections );
|
||||
reorderability->orderChanged.connect( this, &RimSurfaceCollection::orderChanged );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_surfaces, "SurfacesField", "Surfaces", "", "", "" );
|
||||
m_surfaces.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -48,6 +60,31 @@ RimSurfaceCollection::~RimSurfaceCollection()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceCollection::setAsTopmostFolder()
|
||||
{
|
||||
m_collectionname.uiCapability()->setUiHidden( true );
|
||||
setDeletable( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSurfaceCollection::collectionname() const
|
||||
{
|
||||
return m_collectionname.value();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimSurfaceCollection::userDescriptionField()
|
||||
{
|
||||
return &m_collectionname;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -124,6 +161,39 @@ void RimSurfaceCollection::reloadSurfaces( std::vector<RimSurface*> surfaces )
|
||||
updateViews( surfaces );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurface* RimSurfaceCollection::copySurfaces( std::vector<RimSurface*> surfaces )
|
||||
{
|
||||
std::vector<RimSurface*> newsurfaces;
|
||||
|
||||
// create a copy of each surface given
|
||||
for ( RimSurface* surface : surfaces )
|
||||
{
|
||||
RimSurface* copy = surface->createCopy();
|
||||
if ( copy )
|
||||
{
|
||||
newsurfaces.push_back( copy );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaLogging::warning( "Create Surface Copy: Could not create a copy of the surface " + surface->fullName() );
|
||||
}
|
||||
}
|
||||
|
||||
RimSurface* retsurf = nullptr;
|
||||
for ( RimSurface* surface : newsurfaces )
|
||||
{
|
||||
m_surfaces.push_back( surface );
|
||||
retsurf = surface;
|
||||
}
|
||||
|
||||
this->updateConnectedEditors();
|
||||
|
||||
return retsurf;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -132,15 +202,14 @@ RimSurface* RimSurfaceCollection::addGridCaseSurface( RimCase* sourceCase )
|
||||
auto s = new RimGridCaseSurface;
|
||||
s->setCase( sourceCase );
|
||||
|
||||
int oneBasedSliceIndex = 1;
|
||||
auto sliceType = RiaDefines::GridCaseAxis::AXIS_K;
|
||||
int oneBasedSliceIndex = 1;
|
||||
|
||||
s->setSliceTypeAndOneBasedIndex( sliceType, oneBasedSliceIndex );
|
||||
s->setOneBasedIndex( oneBasedSliceIndex );
|
||||
s->setUserDescription( "Surface" );
|
||||
|
||||
if ( !s->onLoadData() )
|
||||
{
|
||||
RiaLogging::warning( "Add Grid Case Surface : Could not create the grid case surface. Don't know why." );
|
||||
RiaLogging::warning( "Add Grid Case Surface : Could not create the grid case surface." );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -163,6 +232,14 @@ std::vector<RimSurface*> RimSurfaceCollection::surfaces() const
|
||||
return m_surfaces.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSurfaceCollection*> RimSurfaceCollection::subcollections() const
|
||||
{
|
||||
return m_subcollections.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -246,3 +323,88 @@ void RimSurfaceCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* c
|
||||
{
|
||||
updateViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceCollection::orderChanged( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
updateViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceCollection::removeSurface( RimSurface* surface )
|
||||
{
|
||||
m_surfaces.removeChildObject( surface );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurface* RimSurfaceCollection::addSurfacesAtIndex( int position, std::vector<RimSurface*> surfaces )
|
||||
{
|
||||
// adjust index for number of folders we have
|
||||
position = position - static_cast<int>( m_subcollections.size() );
|
||||
|
||||
RimSurface* returnSurface = nullptr;
|
||||
if ( !surfaces.empty() ) returnSurface = surfaces[0];
|
||||
|
||||
// insert position at end?
|
||||
if ( ( position >= static_cast<int>( m_surfaces.size() ) ) || ( position < 0 ) )
|
||||
{
|
||||
for ( auto surf : surfaces )
|
||||
{
|
||||
m_surfaces.push_back( surf );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// build the new surface order
|
||||
std::vector<RimSurface*> orderedSurfs;
|
||||
|
||||
int i = 0;
|
||||
|
||||
while ( i < position )
|
||||
{
|
||||
orderedSurfs.push_back( m_surfaces[i++] );
|
||||
}
|
||||
|
||||
for ( auto surf : surfaces )
|
||||
{
|
||||
orderedSurfs.push_back( surf );
|
||||
}
|
||||
|
||||
int surfcount = static_cast<int>( m_surfaces.size() );
|
||||
while ( i < surfcount )
|
||||
{
|
||||
orderedSurfs.push_back( m_surfaces[i++] );
|
||||
}
|
||||
|
||||
// reset the surface collection and use the new order
|
||||
m_surfaces.clear();
|
||||
for ( auto surf : orderedSurfs )
|
||||
{
|
||||
m_surfaces.push_back( surf );
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the views are in sync with the collection order
|
||||
updateViews();
|
||||
|
||||
return returnSurface;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceCollection::addSubCollection( RimSurfaceCollection* subcoll )
|
||||
{
|
||||
m_subcollections.push_back( subcoll );
|
||||
this->updateConnectedEditors();
|
||||
|
||||
updateViews();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
@@ -32,21 +34,38 @@ public:
|
||||
~RimSurfaceCollection() override;
|
||||
|
||||
void addSurface( RimSurface* surface );
|
||||
void setAsTopmostFolder();
|
||||
|
||||
RimSurface* importSurfacesFromFiles( const QStringList& fileNames );
|
||||
RimSurface* addGridCaseSurface( RimCase* sourceCase );
|
||||
RimSurface* copySurfaces( std::vector<RimSurface*> surfaces );
|
||||
RimSurface* addSurfacesAtIndex( int index, std::vector<RimSurface*> surfaces );
|
||||
|
||||
void addSubCollection( RimSurfaceCollection* collection );
|
||||
|
||||
void reloadSurfaces( std::vector<RimSurface*> surfaces );
|
||||
|
||||
std::vector<RimSurface*> surfaces() const;
|
||||
void removeSurface( RimSurface* surface );
|
||||
|
||||
void loadData();
|
||||
|
||||
void updateViews();
|
||||
void updateViews( const std::vector<RimSurface*>& surfsToReload );
|
||||
|
||||
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
||||
|
||||
QString collectionname() const;
|
||||
|
||||
std::vector<RimSurface*> surfaces() const;
|
||||
std::vector<RimSurfaceCollection*> subcollections() const;
|
||||
|
||||
protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimSurface*> m_surfaces;
|
||||
void orderChanged( const caf::SignalEmitter* emitter );
|
||||
|
||||
caf::PdmField<QString> m_collectionname;
|
||||
caf::PdmChildArrayField<RimSurface*> m_surfaces;
|
||||
caf::PdmChildArrayField<RimSurfaceCollection*> m_subcollections;
|
||||
};
|
||||
|
||||
@@ -40,10 +40,26 @@ RimSurfaceInViewCollection::RimSurfaceInViewCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_collectionname, "CollectionName", "Name", "", "", "" );
|
||||
m_collectionname.registerGetMethod( this, &RimSurfaceInViewCollection::name );
|
||||
m_collectionname.uiCapability()->setUiReadOnly( true );
|
||||
m_collectionname.xmlCapability()->disableIO();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_collectionsInView,
|
||||
"SurfacesInViewFieldCollections",
|
||||
"SurfacesInViewFieldCollections",
|
||||
"",
|
||||
"",
|
||||
"" );
|
||||
m_collectionsInView.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "SurfacesInViewField", "", "", "" );
|
||||
m_surfacesInView.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
setName( "Surfaces" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_surfacecollection, "SurfaceCollectionRef", "SurfaceCollection", "", "", "" );
|
||||
m_surfacecollection.uiCapability()->setUiHidden( true );
|
||||
|
||||
nameField()->uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -56,7 +72,101 @@ RimSurfaceInViewCollection::~RimSurfaceInViewCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
||||
caf::PdmFieldHandle* RimSurfaceInViewCollection::userDescriptionField()
|
||||
{
|
||||
return &m_collectionname;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSurfaceInViewCollection::name() const
|
||||
{
|
||||
if ( m_surfacecollection ) return m_surfacecollection->collectionname();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurfaceCollection* RimSurfaceInViewCollection::surfaceCollection() const
|
||||
{
|
||||
return m_surfacecollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::setSurfaceCollection( RimSurfaceCollection* surfcoll )
|
||||
{
|
||||
m_surfacecollection = surfcoll;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::updateAllViewItems()
|
||||
{
|
||||
syncCollectionsWithView();
|
||||
syncSurfacesWithView();
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::syncCollectionsWithView()
|
||||
{
|
||||
// check that we have surface in view collections for all sub-collections
|
||||
std::vector<RimSurfaceInViewCollection*> colls = m_collectionsInView.childObjects();
|
||||
|
||||
for ( auto surfcoll : colls )
|
||||
{
|
||||
if ( !surfcoll->surfaceCollection() )
|
||||
{
|
||||
m_collectionsInView.removeChildObject( surfcoll );
|
||||
delete surfcoll;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new collection entries and reorder
|
||||
std::vector<RimSurfaceInViewCollection*> orderedColls;
|
||||
if ( m_surfacecollection )
|
||||
{
|
||||
// pick up the collections and the order from the surface collection
|
||||
std::vector<RimSurfaceCollection*> surfcolls = m_surfacecollection->subcollections();
|
||||
for ( auto surfcoll : surfcolls )
|
||||
{
|
||||
// check if this is a collection we need to create
|
||||
|
||||
RimSurfaceInViewCollection* viewSurfColl = this->getCollectionInViewForCollection( surfcoll );
|
||||
if ( viewSurfColl == nullptr )
|
||||
{
|
||||
RimSurfaceInViewCollection* newColl = new RimSurfaceInViewCollection();
|
||||
newColl->setSurfaceCollection( surfcoll );
|
||||
orderedColls.push_back( newColl );
|
||||
}
|
||||
else
|
||||
{
|
||||
orderedColls.push_back( viewSurfColl );
|
||||
}
|
||||
}
|
||||
|
||||
// make sure our view surfaces have the same order as the source surface collection
|
||||
m_collectionsInView.clear();
|
||||
for ( auto viewColl : orderedColls )
|
||||
{
|
||||
m_collectionsInView.push_back( viewColl );
|
||||
viewColl->updateAllViewItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::syncSurfacesWithView()
|
||||
{
|
||||
// Delete surfaceInView without any real Surface connection
|
||||
|
||||
@@ -71,27 +181,44 @@ void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
||||
}
|
||||
}
|
||||
|
||||
// Create new entries
|
||||
// Create new surfade entries and reorder
|
||||
std::vector<RimSurfaceInView*> orderedSurfs;
|
||||
|
||||
RimProject* proj = RimProject::current();
|
||||
RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection();
|
||||
|
||||
if ( surfColl )
|
||||
if ( m_surfacecollection )
|
||||
{
|
||||
std::vector<RimSurface*> surfs = surfColl->surfaces();
|
||||
|
||||
// pick up the surfaces and the order from the surface collection
|
||||
std::vector<RimSurface*> surfs = m_surfacecollection->surfaces();
|
||||
for ( auto surf : surfs )
|
||||
{
|
||||
if ( !this->hasSurfaceInViewForSurface( surf ) )
|
||||
// check if this is a surface we need to create
|
||||
RimSurfaceInView* viewSurf = this->getSurfaceInViewForSurface( surf );
|
||||
if ( viewSurf == nullptr )
|
||||
{
|
||||
RimSurfaceInView* newSurfInView = new RimSurfaceInView();
|
||||
newSurfInView->setSurface( surf );
|
||||
m_surfacesInView.push_back( newSurfInView );
|
||||
orderedSurfs.push_back( newSurfInView );
|
||||
}
|
||||
else
|
||||
{
|
||||
orderedSurfs.push_back( viewSurf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->updateConnectedEditors();
|
||||
// make sure our view surfaces have the same order as the source surface collection
|
||||
m_surfacesInView.clear();
|
||||
for ( auto viewSurf : orderedSurfs )
|
||||
{
|
||||
m_surfacesInView.push_back( viewSurf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
||||
{
|
||||
updateAllViewItems();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -99,6 +226,11 @@ void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::loadData()
|
||||
{
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
coll->loadData();
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->isActive() )
|
||||
@@ -113,6 +245,11 @@ void RimSurfaceInViewCollection::loadData()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::clearGeometry()
|
||||
{
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
coll->clearGeometry();
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
surf->clearGeometry();
|
||||
@@ -126,6 +263,14 @@ void RimSurfaceInViewCollection::appendPartsToModel( cvf::ModelBasicList* model,
|
||||
{
|
||||
if ( !isChecked() ) return;
|
||||
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
if ( coll->isChecked() )
|
||||
{
|
||||
coll->appendPartsToModel( model, scaleTransform );
|
||||
}
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->isActive() )
|
||||
@@ -165,17 +310,34 @@ void RimSurfaceInViewCollection::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSurfaceInViewCollection::hasSurfaceInViewForSurface( const RimSurface* surf ) const
|
||||
RimSurfaceInView* RimSurfaceInViewCollection::getSurfaceInViewForSurface( const RimSurface* surf ) const
|
||||
{
|
||||
for ( auto surfInView : m_surfacesInView )
|
||||
{
|
||||
if ( surfInView->surface() == surf )
|
||||
{
|
||||
return true;
|
||||
return surfInView;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSurfaceInViewCollection*
|
||||
RimSurfaceInViewCollection::getCollectionInViewForCollection( const RimSurfaceCollection* coll ) const
|
||||
{
|
||||
for ( auto collInView : m_collectionsInView )
|
||||
{
|
||||
if ( collInView->surfaceCollection() == coll )
|
||||
{
|
||||
return collInView;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -185,6 +347,14 @@ void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResul
|
||||
{
|
||||
if ( !this->isChecked() ) return;
|
||||
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
if ( coll->isChecked() )
|
||||
{
|
||||
coll->updateCellResultColor( hasGeneralCellResult, timeStepIndex );
|
||||
}
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->isActive() )
|
||||
@@ -224,6 +394,14 @@ void RimSurfaceInViewCollection::applySingleColorEffect()
|
||||
{
|
||||
if ( !this->isChecked() ) return;
|
||||
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
if ( coll->isChecked() )
|
||||
{
|
||||
coll->applySingleColorEffect();
|
||||
}
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->isActive() )
|
||||
@@ -240,6 +418,15 @@ bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults()
|
||||
{
|
||||
if ( !this->isChecked() ) return false;
|
||||
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
if ( coll->isChecked() )
|
||||
{
|
||||
bool found = coll->hasAnyActiveSeparateResults();
|
||||
if ( found ) return true;
|
||||
}
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->isActive() && surf->activeSeparateResultDefinition() &&
|
||||
@@ -258,6 +445,12 @@ bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults()
|
||||
void RimSurfaceInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
|
||||
bool isUsingOverrideViewer )
|
||||
{
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
if ( coll->isChecked() )
|
||||
coll->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer, isUsingOverrideViewer );
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
surf->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer, isUsingOverrideViewer );
|
||||
@@ -271,9 +464,18 @@ std::vector<RimRegularLegendConfig*> RimSurfaceInViewCollection::legendConfigs()
|
||||
{
|
||||
std::vector<RimRegularLegendConfig*> configs;
|
||||
|
||||
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
||||
{
|
||||
if ( coll->isChecked() )
|
||||
{
|
||||
std::vector<RimRegularLegendConfig*> collconfigs = coll->legendConfigs();
|
||||
configs.insert( configs.end(), collconfigs.begin(), collconfigs.end() );
|
||||
}
|
||||
}
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->surfaceResultDefinition() )
|
||||
if ( surf->isActive() && surf->surfaceResultDefinition() )
|
||||
{
|
||||
configs.push_back( surf->surfaceResultDefinition()->legendConfig() );
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@@ -32,6 +34,7 @@ class ScalarMapper;
|
||||
|
||||
class RimSurfaceInView;
|
||||
class RimSurface;
|
||||
class RimSurfaceCollection;
|
||||
class RimRegularLegendConfig;
|
||||
class RiuViewer;
|
||||
|
||||
@@ -43,6 +46,11 @@ public:
|
||||
RimSurfaceInViewCollection();
|
||||
~RimSurfaceInViewCollection() override;
|
||||
|
||||
QString name() const override;
|
||||
|
||||
RimSurfaceCollection* surfaceCollection() const;
|
||||
void setSurfaceCollection( RimSurfaceCollection* surfcoll );
|
||||
|
||||
void updateFromSurfaceCollection();
|
||||
void loadData();
|
||||
void clearGeometry();
|
||||
@@ -57,12 +65,21 @@ public:
|
||||
std::vector<RimRegularLegendConfig*> legendConfigs();
|
||||
|
||||
protected:
|
||||
virtual void initAfterRead() override;
|
||||
virtual void initAfterRead() override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
private:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
bool hasSurfaceInViewForSurface( const RimSurface* surf ) const;
|
||||
RimSurfaceInView* getSurfaceInViewForSurface( const RimSurface* surf ) const;
|
||||
RimSurfaceInViewCollection* getCollectionInViewForCollection( const RimSurfaceCollection* coll ) const;
|
||||
|
||||
caf::PdmChildArrayField<RimSurfaceInView*> m_surfacesInView;
|
||||
void updateAllViewItems();
|
||||
void syncCollectionsWithView();
|
||||
void syncSurfacesWithView();
|
||||
|
||||
caf::PdmProxyValueField<QString> m_collectionname;
|
||||
caf::PdmChildArrayField<RimSurfaceInViewCollection*> m_collectionsInView;
|
||||
caf::PdmChildArrayField<RimSurfaceInView*> m_surfacesInView;
|
||||
caf::PdmPtrField<RimSurfaceCollection*> m_surfacecollection;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user