mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Allow linking of contour map views
* Place copy of contour map in correct collection * Allow linking of contour maps * Improve handling of contour views and 3D views * Guard nullptr * Guard assert seen on Linux * Zoom all on contour map when unlinked to reset zoom If a contour map is linked to a 3D view, the view can get distorted. Call ZoomAll to reset to sensible defaults. * Remove default rainbow legend
This commit is contained in:
@@ -331,6 +331,8 @@ QWidget* Rim3dView::createViewWidget( QWidget* mainWindowParent )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::updateViewWidgetAfterCreation()
|
||||
{
|
||||
if ( !m_viewer ) return;
|
||||
|
||||
m_viewer->setDefaultPerspectiveNearPlaneDistance( 10 );
|
||||
|
||||
this->onResetLegendsInViewer();
|
||||
|
||||
@@ -230,8 +230,6 @@ protected:
|
||||
virtual cvf::Transform* scaleTransform() = 0;
|
||||
|
||||
protected:
|
||||
// Overridden PdmObject methods:
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmFieldHandle* backgroundColorField();
|
||||
|
||||
@@ -242,10 +240,11 @@ protected:
|
||||
|
||||
void setupBeforeSave() override;
|
||||
|
||||
// Overridden ViewWindow methods:
|
||||
void updateViewWidgetAfterCreation() override;
|
||||
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
|
||||
|
||||
void setCameraPosition( const cvf::Mat4d& cameraPosition ) override;
|
||||
|
||||
protected:
|
||||
// Timestep Field. Children clamps this differently
|
||||
caf::PdmField<int> m_currentTimeStep;
|
||||
@@ -271,8 +270,6 @@ private:
|
||||
void performAutoNameUpdate() final;
|
||||
|
||||
// Implementation of RiuViewerToViewInterface
|
||||
|
||||
void setCameraPosition( const cvf::Mat4d& cameraPosition ) override;
|
||||
void setCameraPointOfInterest( const cvf::Vec3d& cameraPointOfInterest ) override;
|
||||
|
||||
void endAnimation() override;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
@@ -72,7 +73,7 @@ RimEclipseContourMapView::RimEclipseContourMapView()
|
||||
|
||||
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection(), this );
|
||||
|
||||
( (RiuViewerToViewInterface*)this )->setCameraPosition( sm_defaultViewMatrix );
|
||||
setCameraPosition( sm_defaultViewMatrix );
|
||||
|
||||
cellResult()->setTernaryEnabled( false );
|
||||
cellResult()->legendConfigChanged.connect( this, &RimEclipseContourMapView::onLegendConfigChanged );
|
||||
@@ -410,7 +411,22 @@ void RimEclipseContourMapView::onUpdateLegends()
|
||||
}
|
||||
}
|
||||
|
||||
nativeOrOverrideViewer()->showScaleLegend( m_showScaleLegend() );
|
||||
// Hide the scale widget if any 3D views are present, as the display of the scale widget is only working for
|
||||
// default rotation. The update is triggered in RimViewLinker::updateScaleWidgetVisibility()
|
||||
|
||||
bool any3DViewsLinked = false;
|
||||
|
||||
if ( auto viewLinker = assosiatedViewLinker() )
|
||||
{
|
||||
auto views = viewLinker->allViews();
|
||||
for ( auto v : views )
|
||||
{
|
||||
if ( dynamic_cast<RimEclipseContourMapView*>( v ) ) continue;
|
||||
any3DViewsLinked = true;
|
||||
}
|
||||
}
|
||||
|
||||
nativeOrOverrideViewer()->showScaleLegend( any3DViewsLinked ? false : m_showScaleLegend() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,3 +585,18 @@ RimSurfaceInViewCollection* RimEclipseContourMapView::surfaceInViewCollection()
|
||||
// Surfaces should not be shown in contour map.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapView::zoomAll()
|
||||
{
|
||||
setCameraPosition( sm_defaultViewMatrix );
|
||||
isPerspectiveView = false;
|
||||
|
||||
// If a 3D view has been used as the primary linked view, a contour map can be rotated in 3D. Use the following
|
||||
// function to make sure view is reset to original state, with correct rotation and grid box configuration.
|
||||
updateViewWidgetAfterCreation();
|
||||
|
||||
RimEclipseView::zoomAll();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
void updatePickPointAndRedraw();
|
||||
|
||||
RimSurfaceInViewCollection* surfaceInViewCollection() const override;
|
||||
void zoomAll() override;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
@@ -755,7 +755,7 @@ void RimProject::allNotLinkedViews( std::vector<RimGridView*>& views )
|
||||
std::vector<RimGridView*> alreadyLinkedViews;
|
||||
if ( viewLinkerCollection->viewLinker() )
|
||||
{
|
||||
viewLinkerCollection->viewLinker()->allViews( alreadyLinkedViews );
|
||||
alreadyLinkedViews = viewLinkerCollection->viewLinker()->allViews();
|
||||
}
|
||||
|
||||
for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ )
|
||||
|
||||
@@ -60,34 +60,31 @@ CAF_PDM_SOURCE_INIT( RimViewController, "ViewController" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewController::RimViewController()
|
||||
{
|
||||
// clang-format off
|
||||
CAF_PDM_InitObject( "View Link" );
|
||||
|
||||
CAF_PDM_InitObject("View Link");
|
||||
|
||||
CAF_PDM_InitField(&m_isActive, "Active", true, "Active");
|
||||
m_isActive.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitField( &m_isActive, "Active", true, "Active" );
|
||||
m_isActive.uiCapability()->setUiHidden( true );
|
||||
|
||||
QString defaultName = "View Config: Empty view";
|
||||
CAF_PDM_InitField(&m_name, "Name", defaultName, "Managed View Name");
|
||||
m_name.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitField( &m_name, "Name", defaultName, "Managed View Name" );
|
||||
m_name.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_managedView, "ManagedView", "Linked View");
|
||||
m_managedView.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault( &m_managedView, "ManagedView", "Linked View" );
|
||||
m_managedView.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
|
||||
CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera");
|
||||
CAF_PDM_InitField(&m_showCursor, "ShowCursor", true, " Show Cursor");
|
||||
CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step");
|
||||
CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Result");
|
||||
CAF_PDM_InitField(&m_syncLegendDefinitions, "SyncLegendDefinitions", true, " Color Legend");
|
||||
|
||||
CAF_PDM_InitField(&m_syncVisibleCells, "SyncVisibleCells", false, "Visible Cells");
|
||||
CAF_PDM_InitField( &m_syncCamera, "SyncCamera", true, "Camera" );
|
||||
CAF_PDM_InitField( &m_showCursor, "ShowCursor", true, " Show Cursor" );
|
||||
CAF_PDM_InitField( &m_syncTimeStep, "SyncTimeStep", true, "Time Step" );
|
||||
CAF_PDM_InitField( &m_syncCellResult, "SyncCellResult", false, "Cell Result" );
|
||||
CAF_PDM_InitField( &m_syncLegendDefinitions, "SyncLegendDefinitions", true, " Color Legend" );
|
||||
|
||||
CAF_PDM_InitField( &m_syncVisibleCells, "SyncVisibleCells", false, "Visible Cells" );
|
||||
/// We do not support this. Consider to remove sometime
|
||||
m_syncVisibleCells.uiCapability()->setUiHidden(true);
|
||||
m_syncVisibleCells.uiCapability()->setUiHidden( true );
|
||||
m_syncVisibleCells.xmlCapability()->disableIO();
|
||||
|
||||
CAF_PDM_InitField(&m_syncCellFilters, "SyncRangeFilters", false, "Cell Filters");
|
||||
CAF_PDM_InitField(&m_syncPropertyFilters, "SyncPropertyFilters", false,"Property Filters");
|
||||
// clang-format on
|
||||
CAF_PDM_InitField( &m_syncCellFilters, "SyncRangeFilters", false, "Cell Filters" );
|
||||
CAF_PDM_InitField( &m_syncPropertyFilters, "SyncPropertyFilters", false, "Property Filters" );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
@@ -422,16 +419,6 @@ void RimViewController::updateOptionSensitivity()
|
||||
}
|
||||
}
|
||||
|
||||
if ( isCameraControlPossible() )
|
||||
{
|
||||
this->m_syncCamera.uiCapability()->setUiReadOnly( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_syncCamera.uiCapability()->setUiReadOnly( true );
|
||||
this->m_syncCamera = false;
|
||||
}
|
||||
|
||||
if ( isPropertyFilterControlPossible() )
|
||||
{
|
||||
this->m_syncPropertyFilters.uiCapability()->setUiReadOnly( false );
|
||||
@@ -476,7 +463,6 @@ void RimViewController::setManagedView( RimGridView* view )
|
||||
m_managedView = view;
|
||||
|
||||
updateOptionSensitivity();
|
||||
updateDefaultOptions();
|
||||
updateOverrides();
|
||||
updateResultColorsControl();
|
||||
updateCameraLink();
|
||||
@@ -574,16 +560,6 @@ void RimViewController::updateLegendDefinitions()
|
||||
viewLinker->updateCellResult();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewController::updateDefaultOptions()
|
||||
{
|
||||
m_syncCellResult = isCellResultControlAdvisable();
|
||||
m_syncCellFilters = isCellFilterControlAdvisable();
|
||||
m_syncPropertyFilters = isPropertyFilterControlAdvisable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -679,16 +655,6 @@ RimGridView* RimViewController::masterView() const
|
||||
return ownerViewLinker()->masterView();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimViewController::isCameraControlPossible() const
|
||||
{
|
||||
RimEclipseContourMapView* contourMapMasterView = dynamic_cast<RimEclipseContourMapView*>( masterView() );
|
||||
RimEclipseContourMapView* contourMapManagedView = dynamic_cast<RimEclipseContourMapView*>( managedEclipseView() );
|
||||
return !( contourMapMasterView || contourMapManagedView );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -892,7 +858,7 @@ bool RimViewController::isCellResultControlAdvisable() const
|
||||
{
|
||||
bool contourMapMasterView = dynamic_cast<RimEclipseContourMapView*>( masterView() ) != nullptr;
|
||||
bool contourMapManagedView = dynamic_cast<RimEclipseContourMapView*>( managedEclipseView() ) != nullptr;
|
||||
return !isMasterAndDepViewDifferentType() && contourMapMasterView != contourMapManagedView;
|
||||
return !isMasterAndDepViewDifferentType() && ( contourMapMasterView != contourMapManagedView );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -912,7 +878,7 @@ bool RimViewController::isPropertyFilterControlAdvisable() const
|
||||
{
|
||||
bool contourMapMasterView = dynamic_cast<RimEclipseContourMapView*>( masterView() ) != nullptr;
|
||||
bool contourMapManagedView = dynamic_cast<RimEclipseContourMapView*>( managedEclipseView() ) != nullptr;
|
||||
return isPropertyFilterControlPossible() && contourMapMasterView != contourMapManagedView;
|
||||
return isPropertyFilterControlPossible() && ( contourMapMasterView != contourMapManagedView );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1116,7 +1082,19 @@ void RimViewController::applyCellFilterCollectionByUserChoice()
|
||||
return;
|
||||
}
|
||||
|
||||
bool restoreOriginal = askUserToRestoreOriginalCellFilterCollection( m_managedView->name() );
|
||||
RimViewLinker* viewLinker = ownerViewLinker();
|
||||
RimGridView* masterView = viewLinker->masterView();
|
||||
|
||||
bool restoreOriginal = true;
|
||||
|
||||
bool anyActiveFilter = !masterView->cellFilterCollection()->filters().empty() ||
|
||||
masterView->propertyFilterCollection()->hasActiveFilters();
|
||||
|
||||
if ( anyActiveFilter )
|
||||
{
|
||||
restoreOriginal = askUserToRestoreOriginalCellFilterCollection( m_managedView->name() );
|
||||
}
|
||||
|
||||
if ( restoreOriginal )
|
||||
{
|
||||
m_managedView->setOverrideCellFilterCollection( nullptr );
|
||||
|
||||
@@ -95,9 +95,6 @@ private:
|
||||
void updateResultColorsControl();
|
||||
void updateLegendDefinitions();
|
||||
|
||||
void updateDefaultOptions();
|
||||
|
||||
bool isCameraControlPossible() const;
|
||||
bool isMasterAndDepViewDifferentType() const;
|
||||
bool isPropertyFilterControlPossible() const;
|
||||
bool isCellFilterMappingApplicable() const;
|
||||
|
||||
@@ -263,6 +263,25 @@ void RimViewLinker::removeOverrides()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::updateScaleWidgetVisibility()
|
||||
{
|
||||
// Create new display model that will call RimEclipseContourMapView::onUpdateLegends() where the visibility of scale
|
||||
// widgets is controlled
|
||||
|
||||
if ( masterView() ) masterView()->scheduleCreateDisplayModelAndRedraw();
|
||||
|
||||
for ( RimViewController* viewLink : m_viewControllers )
|
||||
{
|
||||
if ( viewLink->managedView() )
|
||||
{
|
||||
viewLink->managedView()->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -349,8 +368,10 @@ RimGridView* RimViewLinker::masterView() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::allViews( std::vector<RimGridView*>& views ) const
|
||||
std::vector<RimGridView*> RimViewLinker::allViews() const
|
||||
{
|
||||
std::vector<RimGridView*> views;
|
||||
|
||||
views.push_back( m_masterView() );
|
||||
|
||||
for ( const auto& viewController : m_viewControllers )
|
||||
@@ -360,6 +381,8 @@ void RimViewLinker::allViews( std::vector<RimGridView*>& views ) const
|
||||
views.push_back( viewController->managedView() );
|
||||
}
|
||||
}
|
||||
|
||||
return views;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -535,6 +558,8 @@ void RimViewLinker::onChildDeleted( caf::PdmChildArrayFieldHandle* childArr
|
||||
RimViewLinkerCollection* viewLinkerCollection = nullptr;
|
||||
this->firstAncestorOrThisOfType( viewLinkerCollection );
|
||||
if ( viewLinkerCollection ) viewLinkerCollection->updateConnectedEditors();
|
||||
|
||||
updateScaleWidgetVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -644,6 +669,8 @@ void RimViewLinker::addDependentView( RimGridView* view )
|
||||
|
||||
viewContr->setManagedView( view );
|
||||
}
|
||||
|
||||
updateScaleWidgetVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void scheduleGeometryRegenForDepViews( RivCellSetEnum geometryType );
|
||||
void scheduleCreateDisplayModelAndRedrawForDependentViews();
|
||||
|
||||
void allViews( std::vector<RimGridView*>& views ) const;
|
||||
std::vector<RimGridView*> allViews() const;
|
||||
|
||||
void updateUiNameAndIcon();
|
||||
|
||||
@@ -113,6 +113,7 @@ private:
|
||||
void allViewsForCameraSync( const RimGridView* source, std::vector<RimGridView*>& views ) const;
|
||||
|
||||
void removeOverrides();
|
||||
void updateScaleWidgetVisibility();
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimViewController*> m_viewControllers;
|
||||
|
||||
Reference in New Issue
Block a user