Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case view refactor #11291

Merged
merged 6 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ void RicNewCellIndexFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();

RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
}
}

auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();

if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) )
auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

#include "RicNewRangeFilterSliceFeature.h"

#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimCellRangeFilter.h"

#include "Riu3DMainWindowTools.h"

#include "cafCmdExecCommandManager.h"
Expand All @@ -45,13 +47,16 @@ void RicNewRangeFilterSliceFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();

int gridIndex = 0;
RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
int gridIndex = 0;
RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

#include "RicNewUserDefinedFilterFeature.h"

#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimUserDefinedFilter.h"

#include "Riu3DMainWindowTools.h"

#include "cafSelectionManagerTools.h"
Expand All @@ -41,12 +43,15 @@ void RicNewUserDefinedFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();

RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "RicNewUserDefinedIndexFilterFeature.h"

#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimUserDefinedIndexFilter.h"
Expand All @@ -42,12 +43,15 @@ void RicNewUserDefinedIndexFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();

auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo()
intersection->setName( "Azimuth and Dip" );
intersection->configureForAzimuthLine();

RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();
cvf::BoundingBox bBox = rimCase->allCellsBoundingBox();
RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
if ( !rimCase ) return;

cvf::BoundingBox bBox = rimCase->allCellsBoundingBox();
if ( bBox.isValid() )
{
intersection->setLengthUp( cvf::Math::floor( bBox.extent()[2] / 2 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimEclipseViewCollection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "RimOilField.h"
#include "RimProject.h"

#include "RiuAdvancedSnapshotExportWidget.h"
Expand Down Expand Up @@ -146,7 +148,7 @@ void RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( const QString& f

exportViewVariations( copyOfEclipseView, msd, folder );

eclCase->reservoirViews().removeChild( copyOfEclipseView );
removeViewFromViewCollection( copyOfEclipseView );

delete copyOfEclipseView;
}
Expand Down Expand Up @@ -207,7 +209,7 @@ void RicAdvancedSnapshotExportFeature::exportViewVariations( Rim3dView* rimView,
exportViewVariationsToFolder( copyOfView, msd, folder );
}

eclCase->reservoirViews().removeChild( copyOfView );
removeViewFromViewCollection( copyOfView );

delete copyOfView;
}
Expand Down Expand Up @@ -338,3 +340,19 @@ QString RicAdvancedSnapshotExportFeature::resultName( Rim3dView* rimView )

return "";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAdvancedSnapshotExportFeature::removeViewFromViewCollection( RimEclipseView* view )
{
RimProject* project = RimProject::current();
if ( !project ) return;

RimOilField* oilField = project->activeOilField();
if ( !oilField ) return;

RimEclipseViewCollection* viewColl = oilField->eclipseViewCollection();
if ( !viewColl ) return;
viewColl->removeView( view );
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RimAdvancedSnapshotExportDefinition;
class RimProject;
class Rim3dView;
class RimGridView;
class RimEclipseView;

//==================================================================================================
///
Expand All @@ -45,4 +46,5 @@ class RicAdvancedSnapshotExportFeature : public caf::CmdFeature
private:
static void exportViewVariationsToFolder( RimGridView* rimView, RimAdvancedSnapshotExportDefinition* msd, const QString& folder );
static QString resultName( Rim3dView* rimView );
static void removeViewFromViewCollection( RimEclipseView* view );
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RicPasteFeatureImpl.h"

#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilter.h"
#include "RimCellFilterCollection.h"
Expand All @@ -42,17 +43,9 @@ bool RicPasteCellFiltersFeature::isCommandEnabled() const

std::vector<caf::PdmPointer<RimCellFilter>> typedObjects;
objectGroup.objectsByType( &typedObjects );
if ( typedObjects.empty() )
{
return false;
}

if ( dynamic_cast<RimCellFilterCollection*>( caf::SelectionManager::instance()->selectedItem() ) )
{
return true;
}
if ( typedObjects.empty() ) return false;

return false;
return dynamic_cast<RimCellFilterCollection*>( caf::SelectionManager::instance()->selectedItem() ) != nullptr;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -63,7 +56,11 @@ void RicPasteCellFiltersFeature::onActionTriggered( bool isChecked )
auto cellFilterCollection = dynamic_cast<RimCellFilterCollection*>( caf::SelectionManager::instance()->selectedItem() );
if ( !cellFilterCollection ) return;

auto eclipseCase = cellFilterCollection->firstAncestorOfType<RimCase>();
auto view = cellFilterCollection->firstAncestorOfType<Rim3dView>();
if ( !view ) return;

auto eclipseCase = view->ownerCase();
if ( !eclipseCase ) return;

caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup( caf::PdmObjectGroup&

gridCaseGroup->updateConnectedEditors();

for ( size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++ )
for ( RimEclipseView* riv : rimResultReservoir->reservoirViews() )
{
RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx];
riv->loadDataAndUpdate();
}
}
Expand Down
37 changes: 23 additions & 14 deletions ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@

#include "Rim3dView.h"
#include "RimCellEdgeColors.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseContourMapProjection.h"
#include "RimEclipseContourMapView.h"
#include "RimEclipseContourMapViewCollection.h"
#include "RimEclipseView.h"
#include "RimFaultInViewCollection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechContourMapView.h"
#include "RimGeoMechContourMapViewCollection.h"
#include "RimGeoMechView.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimRegularLegendConfig.h"

#include "RimCellFilterCollection.h"
#include "RimFaultInViewCollection.h"
#include "RimSimWellInViewCollection.h"
#include "RimSurfaceInViewCollection.h"

Expand Down Expand Up @@ -86,7 +87,7 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked )
{
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseCase>();
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
RimEclipseContourMapView* eclipseContourMap = nullptr;

RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>();
Expand All @@ -97,11 +98,19 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked )
// Find case to insert into
if ( existingEclipseContourMap )
{
eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap );
eclipseCase = existingEclipseContourMap->eclipseCase();
if ( eclipseCase )
{
eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap );
}
}
else if ( reservoirView )
{
eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView );
eclipseCase = reservoirView->eclipseCase();
if ( eclipseCase )
{
eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView );
}
}
else if ( eclipseCase )
{
Expand Down Expand Up @@ -138,6 +147,12 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked )
eclipseContourMap->createDisplayModelAndRedraw();
eclipseContourMap->zoomAll();

RimProject* project = RimProject::current();

RimOilField* oilField = project->activeOilField();

oilField->eclipseContourMapCollection()->updateConnectedEditors();

Riu3DMainWindowTools::setExpanded( eclipseContourMap );
}
else if ( geoMechContourMap )
Expand Down Expand Up @@ -258,16 +273,10 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr

contourMap->synchronizeLocalAnnotationsFromGlobal();

// Resolve references after contour map has been inserted into Rim structures
std::vector<caf::PdmFieldHandle*> fieldsWithFailingResolve;
contourMap->resolveReferencesRecursively( &fieldsWithFailingResolve );

// TODO: Introduce the assert when code is stable
// If we have intersections on well paths, the resolving is now failing
// CVF_ASSERT(fieldsWithFailingResolve.empty());

contourMap->initAfterReadRecursively();

eclipseCase->contourMapCollection()->updateConnectedEditors();

return contourMap;
}

Expand Down
Loading