Add copy/paste of Summary Multi Plot (#8942)

* Guard use of back() on empty vector
* Add "Show Data Sources" to ensemble realizations
* Update summary plot as summary curve collection is not visible in tree view
* Set selection manager root in RiaApplication
* Always close both main windows if present
* Add copy/paste of summary multi plot
* Add test for RiuMainWindow::instance() before use
* Remove duplicated code
* Multiple Tree Views : Use getTreeViewWithItem() to find correct tree view
* Minor UI adjustments
This commit is contained in:
Magne Sjaastad
2022-05-23 14:25:53 +02:00
committed by GitHub
parent 329e1e8b69
commit 01e670a3d8
30 changed files with 417 additions and 100 deletions

View File

@@ -38,10 +38,7 @@ QWidget* Riu3DMainWindowTools::mainWindowWidget()
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setActiveViewer( QWidget* subWindow )
{
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->setActiveViewer( subWindow );
}
if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->setActiveViewer( subWindow );
}
//--------------------------------------------------------------------------------------------------
@@ -49,10 +46,7 @@ void Riu3DMainWindowTools::setActiveViewer( QWidget* subWindow )
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expanded /*= true*/ )
{
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->setExpanded( uiItem, expanded );
}
if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->setExpanded( uiItem, expanded );
}
//--------------------------------------------------------------------------------------------------
@@ -60,10 +54,7 @@ void Riu3DMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expan
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ )
{
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->selectAsCurrentItem( object, allowActiveViewChange );
}
if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->selectAsCurrentItem( object, allowActiveViewChange );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -277,6 +277,8 @@ QAction* RiuDockWidgetTools::toggleActionForWidget( const QObject* parent, const
//--------------------------------------------------------------------------------------------------
void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse()
{
if ( !RiuMainWindow::instance() ) return;
RiuMainWindow* mainWindow = RiuMainWindow::instance();
auto widgetVisibilities = widgetVisibilitiesForEclipse();
@@ -288,6 +290,8 @@ void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse()
//--------------------------------------------------------------------------------------------------
void RiuDockWidgetTools::setVisibleDockingWindowsForGeoMech()
{
if ( !RiuMainWindow::instance() ) return;
RiuMainWindow* mainWindow = RiuMainWindow::instance();
auto widgetVisibilities = widgetVisibilitiesForGeoMech();
@@ -348,6 +352,8 @@ QVariant RiuDockWidgetTools::defaultDockWidgetVisibilities()
//--------------------------------------------------------------------------------------------------
void RiuDockWidgetTools::workaroundForQwtDockWidgets()
{
if ( !RiuMainWindow::instance() ) return;
RiuMainWindow* mainWindow = RiuMainWindow::instance();
QList<QDockWidget*> dockWidgets = mainWindow->findChildren<QDockWidget*>();

View File

@@ -1230,8 +1230,6 @@ void RiuMainWindow::setPdmRoot( caf::PdmObject* pdmRoot )
projPropView->setPdmItem( pdmRoot );
}
}
caf::SelectionManager::instance()->setPdmRootObject( pdmRoot );
}
//--------------------------------------------------------------------------------------------------
@@ -1343,7 +1341,10 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim
if ( is3dViewCurrentlySelected && ( previousActiveReservoirView != activatedView ) )
{
QModelIndex newViewModelIndex = projectTreeView( 0 )->findModelIndex( activatedView );
auto tv = getTreeViewWithItem( activatedView );
if ( !tv ) return;
QModelIndex newViewModelIndex = tv->findModelIndex( activatedView );
if ( !newViewModelIndex.isValid() ) return;
QModelIndex newSelectionIndex = newViewModelIndex;
@@ -1352,8 +1353,8 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim
{
// Try to select the same entry in the new View, as was selected in the previous
QModelIndex previousViewModelIndex = projectTreeView( 0 )->findModelIndex( previousActiveReservoirView );
QModelIndex currentSelectionIndex = projectTreeView( 0 )->treeView()->selectionModel()->currentIndex();
QModelIndex previousViewModelIndex = tv->findModelIndex( previousActiveReservoirView );
QModelIndex currentSelectionIndex = tv->treeView()->selectionModel()->currentIndex();
if ( currentSelectionIndex != newViewModelIndex && currentSelectionIndex.isValid() )
{
@@ -1376,8 +1377,7 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim
QModelIndex tmp = route[i];
if ( newSelectionIndex.isValid() )
{
newSelectionIndex =
projectTreeView( 0 )->treeView()->model()->index( tmp.row(), tmp.column(), newSelectionIndex );
newSelectionIndex = tv->treeView()->model()->index( tmp.row(), tmp.column(), newSelectionIndex );
}
}
@@ -1389,10 +1389,10 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim
}
}
projectTreeView( 0 )->treeView()->setCurrentIndex( newSelectionIndex );
tv->treeView()->setCurrentIndex( newSelectionIndex );
if ( newSelectionIndex != newViewModelIndex )
{
projectTreeView( 0 )->treeView()->setExpanded( newViewModelIndex, true );
tv->treeView()->setExpanded( newViewModelIndex, true );
}
}
}
@@ -1484,8 +1484,11 @@ void RiuMainWindow::slotBuildWindowActions()
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::selectedObjectsChanged()
{
caf::PdmUiTreeView* projectTree = dynamic_cast<caf::PdmUiTreeView*>( sender() );
if ( !projectTree ) return;
std::vector<caf::PdmUiItem*> uiItems;
projectTreeView( 0 )->selectedUiItems( uiItems );
projectTree->selectedUiItems( uiItems );
caf::PdmObjectHandle* firstSelectedObject = nullptr;
if ( !uiItems.empty() )
@@ -1543,7 +1546,7 @@ void RiuMainWindow::selectedObjectsChanged()
// The only way to get to this code is by selection change initiated from the project tree view
// As we are activating an MDI-window, the focus is given to this MDI-window
// Set focus back to the tree view to be able to continue keyboard tree view navigation
projectTreeView( 0 )->treeView()->setFocus();
projectTree->treeView()->setFocus();
}
}
}
@@ -1906,8 +1909,11 @@ void RiuMainWindow::slotCreateCommandObject()
RiaApplication* app = RiaApplication::instance();
if ( !app->project() ) return;
caf::PdmUiTreeView* projectTree = dynamic_cast<caf::PdmUiTreeView*>( sender() );
if ( !projectTree ) return;
std::vector<caf::PdmUiItem*> selectedUiItems;
projectTreeView( 0 )->selectedUiItems( selectedUiItems );
projectTree->selectedUiItems( selectedUiItems );
caf::PdmObjectGroup selectedObjects;
for ( auto* selectedUiItem : selectedUiItems )

View File

@@ -79,6 +79,8 @@ RiuSelectionChangedHandler::~RiuSelectionChangedHandler()
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::handleSelectionDeleted() const
{
if ( !RiuMainWindow::instance() ) return;
RiuMainWindow::instance()->resultPlot()->deleteAllCurves();
RiuRelativePermeabilityPlotUpdater* relPermPlotUpdater =
@@ -101,6 +103,8 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::handleItemAppended( const RiuSelectionItem* item ) const
{
if ( !RiuMainWindow::instance() ) return;
addCurveFromSelectionItem( item );
RiuRelativePermeabilityPlotUpdater* relPermUpdater =
@@ -123,6 +127,8 @@ void RiuSelectionChangedHandler::handleItemAppended( const RiuSelectionItem* ite
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::handleSetSelectedItem( const RiuSelectionItem* item ) const
{
if ( !RiuMainWindow::instance() ) return;
RiuMainWindow::instance()->resultPlot()->deleteAllCurves();
RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot();