Show properties for selected object in main project tree

There can be several project trees in a project. Ensure that the selected object in the main project tree is displayed in the property editor.
This commit is contained in:
Magne Sjaastad 2024-06-11 13:36:04 +02:00
parent 742bb5f0d2
commit 015f248dd9
2 changed files with 38 additions and 0 deletions

View File

@ -254,6 +254,25 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
activeSubWindow->showMaximized();
}
}
// Find the project tree and reselect items to trigger the selectionChanged signal. This will make sure that the property view is
// updated based on the selection in the main project tree.
if ( auto dockWidget = RiuDockWidgetTools::findDockWidget( dockManager(), RiuDockWidgetTools::mainWindowProjectTreeName() ) )
{
if ( auto tree = dynamic_cast<caf::PdmUiTreeView*>( dockWidget->widget() ) )
{
std::vector<caf::PdmUiItem*> uiItems;
tree->selectedUiItems( uiItems );
std::vector<const caf::PdmUiItem*> constSelectedItems;
for ( auto item : uiItems )
{
constSelectedItems.push_back( item );
}
tree->selectItems( constSelectedItems );
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -218,6 +218,25 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
}
refreshToolbars();
// Find the project tree and reselect items to trigger the selectionChanged signal. This will make sure that the property view is
// updated based on the selection in the main project tree.
if ( auto dockWidget = RiuDockWidgetTools::findDockWidget( dockManager(), RiuDockWidgetTools::plotMainWindowPlotsTreeName() ) )
{
if ( auto tree = dynamic_cast<caf::PdmUiTreeView*>( dockWidget->widget() ) )
{
std::vector<caf::PdmUiItem*> uiItems;
tree->selectedUiItems( uiItems );
std::vector<const caf::PdmUiItem*> constSelectedItems;
for ( auto item : uiItems )
{
constSelectedItems.push_back( item );
}
tree->selectItems( constSelectedItems );
}
}
}
//--------------------------------------------------------------------------------------------------