From e815a02758628496e59ce41ea86d89419a7baebc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Dec 2022 10:50:26 +0100 Subject: [PATCH] Minor GUI adjustments * Select view when MDI window is activated * Update linked views when property filter is linked * Do not ask for restore of cell filters if none are present * Update tree view when linking of property filters is disabled * Add check box for multiple results in Result Info box --- .../RimMultipleEclipseResults.cpp | 4 +- .../RimMultipleEclipseResults.h | 5 +- .../ProjectDataModel/RimViewController.cpp | 40 ++++++-- .../UserInterface/RiuMainWindow.cpp | 93 ++++++++++--------- 4 files changed, 88 insertions(+), 54 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.cpp b/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.cpp index d4b85911fe..52fa3ede42 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.cpp @@ -30,7 +30,7 @@ CAF_PDM_SOURCE_INIT( RimMultipleEclipseResults, "RimMultipleEclipseResults" ); //-------------------------------------------------------------------------------------------------- RimMultipleEclipseResults::RimMultipleEclipseResults() { - CAF_PDM_InitObject( "Result Info Data", ":/TextAnnotation16x16.png" ); + CAF_PDM_InitObject( "Multiple Result Info", ":/TextAnnotation16x16.png" ); CAF_PDM_InitFieldNoDefault( &m_selectedKeywords, "SelectedProperties", "Properties" ); m_selectedKeywords.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); @@ -51,7 +51,7 @@ void RimMultipleEclipseResults::setEclipseView( RimEclipseView* eclipseView ) //-------------------------------------------------------------------------------------------------- std::vector RimMultipleEclipseResults::additionalResultAddresses() const { - if ( !m_eclipseView || !m_eclipseView->currentGridCellResults() ) return {}; + if ( !m_eclipseView || !m_eclipseView->currentGridCellResults() || !m_isChecked ) return {}; std::set selectedResults; for ( const auto& result : m_selectedKeywords() ) diff --git a/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.h b/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.h index 77c8ccd17b..1cf2497dcb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.h +++ b/ApplicationLibCode/ProjectDataModel/RimMultipleEclipseResults.h @@ -18,8 +18,7 @@ #pragma once -#include "cafPdmField.h" -#include "cafPdmObject.h" +#include "RimCheckableObject.h" #include @@ -30,7 +29,7 @@ class RimEclipseView; /// /// //================================================================================================== -class RimMultipleEclipseResults : public caf::PdmObject +class RimMultipleEclipseResults : public RimCheckableObject { CAF_PDM_HEADER_INIT; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewController.cpp b/ApplicationLibCode/ProjectDataModel/RimViewController.cpp index 6b8da7f0ae..b4c692b814 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewController.cpp @@ -499,7 +499,28 @@ void RimViewController::updateDisplayNameAndIcon() //-------------------------------------------------------------------------------------------------- void RimViewController::updateDuplicatedPropertyFilters() { - if ( !m_duplicatePropertyFilters ) return; + if ( !m_duplicatePropertyFilters ) + { + // A chain icon is used to indicate that a property filter is linked. If a property filter is unlinked, update + // the property filters to make sure the chain icon is removed + + std::vector eclipsePropertyFilters; + + RimProject::current()->descendantsIncludingThisOfType( eclipsePropertyFilters ); + for ( auto p : eclipsePropertyFilters ) + { + p->updateConnectedEditors(); + } + + std::vector geoMechPropertyFilters; + RimProject::current()->descendantsIncludingThisOfType( geoMechPropertyFilters ); + for ( auto p : geoMechPropertyFilters ) + { + p->updateConnectedEditors(); + } + + return; + } RimViewLinker* viewLinker = ownerViewLinker(); @@ -519,6 +540,9 @@ void RimViewController::updateDuplicatedPropertyFilters() manEclView->eclipsePropertyFilterCollection()->loadAndInitializePropertyFilters(); manEclView->eclipsePropertyFilterCollection()->setIsDuplicatedFromLinkedView(); manEclView->eclipsePropertyFilterCollection()->updateAllRequiredEditors(); + + manEclView->scheduleGeometryRegen( PROPERTY_FILTERED ); + manEclView->scheduleCreateDisplayModelAndRedraw(); } auto* masterGeoView = dynamic_cast( masterView ); @@ -528,8 +552,11 @@ void RimViewController::updateDuplicatedPropertyFilters() auto propertyString = masterGeoView->geoMechPropertyFilterCollection()->writeObjectToXmlString(); manGeoView->geoMechPropertyFilterCollection()->readObjectFromXmlString( propertyString, caf::PdmDefaultObjectFactory::instance() ); - managedGeoView()->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters(); - managedGeoView()->geoMechPropertyFilterCollection()->updateAllRequiredEditors(); + manGeoView->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters(); + manGeoView->geoMechPropertyFilterCollection()->updateAllRequiredEditors(); + + manGeoView->scheduleGeometryRegen( PROPERTY_FILTERED ); + manGeoView->scheduleCreateDisplayModelAndRedraw(); } } } @@ -1098,15 +1125,14 @@ void RimViewController::applyCellFilterCollectionByUserChoice() RimViewLinker* viewLinker = ownerViewLinker(); auto* masterView = dynamic_cast( viewLinker->masterView() ); - bool anyActiveFilter = false; + bool anyActiveCellFilter = false; if ( masterView ) { - anyActiveFilter = !masterView->cellFilterCollection()->filters().empty() || - masterView->propertyFilterCollection()->hasActiveFilters(); + anyActiveCellFilter = !masterView->cellFilterCollection()->filters().empty(); } - if ( anyActiveFilter && askUserToRestoreOriginalCellFilterCollection( m_managedView->name() ) ) + if ( anyActiveCellFilter && askUserToRestoreOriginalCellFilterCollection( m_managedView->name() ) ) { managedGridView->setOverrideCellFilterCollection( nullptr ); } diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 15c80347be..154afa927e 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -34,6 +34,7 @@ #include "RimCellEdgeColors.h" #include "RimCommandObject.h" #include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" #include "RimEclipseContourMapView.h" #include "RimEclipseFaultColors.h" #include "RimEclipsePropertyFilter.h" @@ -1326,62 +1327,70 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim } } - if ( is3dViewCurrentlySelected && ( previousActiveReservoirView != activatedView ) ) + auto tv = getTreeViewWithItem( activatedView ); + if ( !tv ) return; + + QModelIndex newViewModelIndex = tv->findModelIndex( activatedView ); + if ( !newViewModelIndex.isValid() ) return; + + QModelIndex newSelectionIndex = newViewModelIndex; + + if ( !is3dViewCurrentlySelected ) { - auto tv = getTreeViewWithItem( activatedView ); - if ( !tv ) return; + std::vector objects; - QModelIndex newViewModelIndex = tv->findModelIndex( activatedView ); - if ( !newViewModelIndex.isValid() ) return; - - QModelIndex newSelectionIndex = newViewModelIndex; - - if ( previousActiveReservoirView && is3dViewCurrentlySelected ) + activatedView->descendantsIncludingThisOfType( objects ); + if ( !objects.empty() ) { - // Try to select the same entry in the new View, as was selected in the previous + auto candidate = tv->findModelIndex( objects.front() ); + if ( candidate.isValid() ) newSelectionIndex = candidate; + } + } + else if ( previousActiveReservoirView && is3dViewCurrentlySelected ) + { + // Try to select the same entry in the new View, as was selected in the previous - QModelIndex previousViewModelIndex = tv->findModelIndex( previousActiveReservoirView ); - QModelIndex currentSelectionIndex = tv->treeView()->selectionModel()->currentIndex(); + QModelIndex previousViewModelIndex = tv->findModelIndex( previousActiveReservoirView ); + QModelIndex currentSelectionIndex = tv->treeView()->selectionModel()->currentIndex(); - if ( currentSelectionIndex != newViewModelIndex && currentSelectionIndex.isValid() ) + if ( currentSelectionIndex != newViewModelIndex && currentSelectionIndex.isValid() ) + { + QVector route; // Contains all model indices from current selection up to previous view + + QModelIndex tmpModelIndex = currentSelectionIndex; + + while ( tmpModelIndex.isValid() && tmpModelIndex != previousViewModelIndex ) { - QVector route; // Contains all model indices from current selection up to previous view + // NB! Add model index to front of vector to be able to do a for-loop with correct ordering + route.push_front( tmpModelIndex ); - QModelIndex tmpModelIndex = currentSelectionIndex; + tmpModelIndex = tmpModelIndex.parent(); + } - while ( tmpModelIndex.isValid() && tmpModelIndex != previousViewModelIndex ) + // Traverse model indices from new view index to currently selected item + int i; + for ( i = 0; i < route.size(); i++ ) + { + QModelIndex tmp = route[i]; + if ( newSelectionIndex.isValid() ) { - // NB! Add model index to front of vector to be able to do a for-loop with correct ordering - route.push_front( tmpModelIndex ); - - tmpModelIndex = tmpModelIndex.parent(); - } - - // Traverse model indices from new view index to currently selected item - int i; - for ( i = 0; i < route.size(); i++ ) - { - QModelIndex tmp = route[i]; - if ( newSelectionIndex.isValid() ) - { - newSelectionIndex = tv->treeView()->model()->index( tmp.row(), tmp.column(), newSelectionIndex ); - } - } - - // Use view model index if anything goes wrong - if ( !newSelectionIndex.isValid() ) - { - newSelectionIndex = newViewModelIndex; + newSelectionIndex = tv->treeView()->model()->index( tmp.row(), tmp.column(), newSelectionIndex ); } } - } - tv->treeView()->setCurrentIndex( newSelectionIndex ); - if ( newSelectionIndex != newViewModelIndex ) - { - tv->treeView()->setExpanded( newViewModelIndex, true ); + // Use view model index if anything goes wrong + if ( !newSelectionIndex.isValid() ) + { + newSelectionIndex = newViewModelIndex; + } } } + + tv->treeView()->setCurrentIndex( newSelectionIndex ); + if ( newSelectionIndex != newViewModelIndex ) + { + tv->treeView()->setExpanded( newViewModelIndex, true ); + } } //--------------------------------------------------------------------------------------------------