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:
@@ -2,18 +2,21 @@
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportSurfacesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadSurfaceFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCopySurfaceFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewGridCaseSurfaceFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportKLayerToPtlFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSurfaceCollectionFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportSurfacesFeature.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadSurfaceFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCopySurfaceFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewGridCaseSurfaceFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportKLayerToPtlFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSurfaceCollectionFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicCopySurfaceFeature.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( RicCopySurfaceFeature, "RicCopySurfaceFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCopySurfaceFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopySurfaceFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimSurfaceCollection* surfColl = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimSurfaceCollection>();
|
||||
if ( surfColl )
|
||||
{
|
||||
// get the Surfaces
|
||||
std::vector<RimSurface*> surfaces = caf::selectedObjectsByTypeStrict<RimSurface*>();
|
||||
|
||||
// ask the collection to copy them
|
||||
RimSurface* surftoselect = surfColl->copySurfaces( surfaces );
|
||||
if ( surftoselect )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( surftoselect );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopySurfaceFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/Copy.png" ) );
|
||||
actionToSetup->setText( "Create Copy" );
|
||||
}
|
||||
@@ -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 RicCopySurfaceFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -28,6 +28,9 @@
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
@@ -58,17 +61,10 @@ void RicImportSurfacesFeature::onActionTriggered( bool isChecked )
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileNames.last() ).absolutePath() );
|
||||
|
||||
// Find or create the SurfaceCollection
|
||||
|
||||
RimProject* proj = RimProject::current();
|
||||
RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection();
|
||||
|
||||
if ( !surfColl )
|
||||
{
|
||||
surfColl = new RimSurfaceCollection();
|
||||
proj->activeOilField()->surfaceCollection = surfColl;
|
||||
proj->updateConnectedEditors();
|
||||
}
|
||||
// Find the selected SurfaceCollection
|
||||
std::vector<RimSurfaceCollection*> colls = caf::selectedObjectsByTypeStrict<RimSurfaceCollection*>();
|
||||
if ( colls.empty() ) return;
|
||||
RimSurfaceCollection* surfColl = colls[0];
|
||||
|
||||
// For each file,
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewGridSurfaceFeature, "RicNewGridSurfaceFeature" );
|
||||
@@ -42,22 +45,18 @@ bool RicNewGridSurfaceFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewGridSurfaceFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection();
|
||||
|
||||
if ( !surfColl )
|
||||
{
|
||||
surfColl = new RimSurfaceCollection();
|
||||
proj->activeOilField()->surfaceCollection = surfColl;
|
||||
proj->updateConnectedEditors();
|
||||
}
|
||||
RimProject* proj = RimProject::current();
|
||||
|
||||
RimCase* sourceCase = nullptr;
|
||||
auto allCases = proj->allGridCases();
|
||||
if ( !allCases.empty() ) sourceCase = allCases.front();
|
||||
|
||||
RimSurface* lastCreatedOrUpdated = surfColl->addGridCaseSurface( sourceCase );
|
||||
// Find the selected SurfaceCollection
|
||||
std::vector<RimSurfaceCollection*> colls = caf::selectedObjectsByTypeStrict<RimSurfaceCollection*>();
|
||||
if ( colls.empty() ) return;
|
||||
RimSurfaceCollection* surfColl = colls[0];
|
||||
|
||||
RimSurface* lastCreatedOrUpdated = surfColl->addGridCaseSurface( sourceCase );
|
||||
if ( lastCreatedOrUpdated )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
|
||||
|
||||
@@ -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 "RicNewSurfaceCollectionFeature.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( RicNewSurfaceCollectionFeature, "RicNewSurfaceCollectionFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSurfaceCollectionFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSurfaceCollectionFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimSurfaceCollection*> colls = caf::selectedObjectsByTypeStrict<RimSurfaceCollection*>();
|
||||
if ( colls.empty() ) return;
|
||||
RimSurfaceCollection* surfColl = colls[0];
|
||||
|
||||
if ( surfColl )
|
||||
{
|
||||
// add a new surface collection and select it in the tree
|
||||
RimSurfaceCollection* newcoll = new RimSurfaceCollection();
|
||||
surfColl->addSubCollection( newcoll );
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( newcoll );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSurfaceCollectionFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/ReservoirSurfaces16x16.png" ) );
|
||||
actionToSetup->setText( "Add Folder" );
|
||||
}
|
||||
@@ -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 RicNewSurfaceCollectionFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -46,9 +46,7 @@ bool RicReloadSurfaceFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicReloadSurfaceFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection();
|
||||
|
||||
RimSurfaceCollection* surfColl = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimSurfaceCollection>();
|
||||
if ( surfColl )
|
||||
{
|
||||
// get the Surfaces
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSurface.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
#include "RimWellLogCurve.h"
|
||||
#include "RimWellLogFileChannel.h"
|
||||
@@ -223,7 +225,8 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
|
||||
|
||||
if ( dynamic_cast<RimEclipseCase*>( uiItem ) || dynamic_cast<RimWellLogCurve*>( uiItem ) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>( uiItem ) || dynamic_cast<RimPlot*>( uiItem ) ||
|
||||
dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCurve*>( uiItem ) )
|
||||
dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCurve*>( uiItem ) ||
|
||||
dynamic_cast<RimSurface*>( uiItem ) )
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
itemflags |= Qt::ItemIsDragEnabled;
|
||||
@@ -297,6 +300,13 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<RimSurfaceCollection*>( uiItem ) )
|
||||
{
|
||||
if ( RiuTypedPdmObjects<RimSurface>::containsTypedObjects( m_dragItems ) )
|
||||
{
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_proposedDropAction == Qt::CopyAction )
|
||||
{
|
||||
@@ -397,6 +407,13 @@ bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, in
|
||||
{
|
||||
return handleSummaryCaseMainCollectionDrop( action, draggedObjects, summaryCaseMainCollection );
|
||||
}
|
||||
|
||||
RimSurfaceCollection* surfaceCollection;
|
||||
dropTarget->firstAncestorOrThisOfType( surfaceCollection );
|
||||
if ( surfaceCollection )
|
||||
{
|
||||
return handleSurfaceCollectionDrop( action, row, draggedObjects, surfaceCollection );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -681,3 +698,33 @@ void RiuDragDrop::onProposedDropActionUpdated( Qt::DropAction action )
|
||||
{
|
||||
m_proposedDropAction = action;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuDragDrop::handleSurfaceCollectionDrop( Qt::DropAction action,
|
||||
int row,
|
||||
caf::PdmObjectGroup& objectGroup,
|
||||
RimSurfaceCollection* targetCollection )
|
||||
{
|
||||
std::vector<RimSurface*> surfaces = RiuTypedPdmObjects<RimSurface>::typedObjectsFromGroup( objectGroup );
|
||||
|
||||
if ( action != Qt::MoveAction || surfaces.size() == 0 ) return false;
|
||||
|
||||
for ( RimSurface* surface : surfaces )
|
||||
{
|
||||
RimSurfaceCollection* sourceCollection;
|
||||
surface->firstAncestorOrThisOfType( sourceCollection );
|
||||
|
||||
if ( sourceCollection )
|
||||
{
|
||||
sourceCollection->removeSurface( surface );
|
||||
sourceCollection->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
targetCollection->addSurfacesAtIndex( row, surfaces );
|
||||
targetCollection->updateConnectedEditors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class RimSummaryCaseCollection;
|
||||
class RimSummaryCaseMainCollection;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryPlot;
|
||||
class RimSurfaceCollection;
|
||||
class RimWellLogPlot;
|
||||
class RimWellLogTrack;
|
||||
class RimWellLogCurve;
|
||||
@@ -90,6 +91,11 @@ private:
|
||||
caf::PdmObjectGroup& objectGroup,
|
||||
RimSummaryCaseMainCollection* summaryCaseMainCollection );
|
||||
|
||||
bool handleSurfaceCollectionDrop( Qt::DropAction action,
|
||||
int row,
|
||||
caf::PdmObjectGroup& objectGroup,
|
||||
RimSurfaceCollection* surfaceCollection );
|
||||
|
||||
static void objectGroupFromModelIndexes( caf::PdmObjectGroup* objectGroup, const QModelIndexList& indexes );
|
||||
static std::vector<caf::PdmPointer<caf::PdmObjectHandle>> objectHandlesFromSelection();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user