diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 620d09a0a4..7928a9afbc 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -576,14 +576,6 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer) m_blockSlotSubWindowActivated = false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmUiTreeView* RiuMainPlotWindow::projectTreeView() -{ - return m_projectTreeView; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -631,22 +623,22 @@ void RiuMainPlotWindow::selectedObjectsChanged() { firstSelectedObject = dynamic_cast(uiItems[0]); } + m_pdmUiPropertyView->showProperties(firstSelectedObject); - if (uiItems.size() == 1) + if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection) { // Find the reservoir view or the Plot that the selected item is within if (!firstSelectedObject) { caf::PdmFieldHandle* selectedField = dynamic_cast(uiItems[0]); - if (selectedField) - firstSelectedObject = selectedField->ownerObject(); + if (selectedField) firstSelectedObject = selectedField->ownerObject(); } - if (!firstSelectedObject) - return; + if (!firstSelectedObject) return; + RimViewWindow* selectedWindow = dynamic_cast(firstSelectedObject); if (!selectedWindow) { @@ -714,13 +706,6 @@ void RiuMainPlotWindow::restoreTreeViewState() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::selectAsCurrentItem(caf::PdmObject* object) -{ - m_projectTreeView->selectAsCurrentItem(object); -} //-------------------------------------------------------------------------------------------------- /// @@ -730,14 +715,6 @@ void RiuMainPlotWindow::setDefaultWindowSize() resize(1000, 810); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) -{ - m_projectTreeView->setExpanded(uiItem, expanded); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuMainPlotWindow.h index 214df5ef2c..2872200ee0 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.h @@ -55,7 +55,7 @@ class RiuMainPlotWindow : public RiuMainWindowBase public: RiuMainPlotWindow(); - virtual QString mainWindowName(); + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); void cleanupGuiBeforeProjectClose(); @@ -65,15 +65,10 @@ public: void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) override; void setActiveViewer(QWidget* subWindow) override; - caf::PdmUiTreeView* projectTreeView(); - void hideAllDockWindows(); - void selectAsCurrentItem(caf::PdmObject* object); - void setDefaultWindowSize(); - void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override; @@ -87,7 +82,7 @@ public: void updateSummaryPlotToolBar(); protected: - virtual void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; private: void setPdmRoot(caf::PdmObject* pdmRoot); @@ -121,7 +116,6 @@ private: QMenu* m_windowMenu; - caf::PdmUiTreeView* m_projectTreeView; caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor; std::unique_ptr m_dragDropInterface; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index ead90ed792..7beb521680 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -149,6 +149,14 @@ RiuMainWindow* RiuMainWindow::instance() return sm_mainWindowInstance; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuMainWindow::mainWindowName() +{ + return "RiuMainWindow"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1297,7 +1305,7 @@ void RiuMainWindow::selectedObjectsChanged() m_pdmUiPropertyView->showProperties(firstSelectedObject); - if (uiItems.size() == 1) + if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection) { // Find the reservoir view or the Plot that the selected item is within @@ -1619,14 +1627,6 @@ void RiuMainWindow::showProcessMonitorDockPanel() showDockPanel(DOCK_PANEL_NAME_PROCESS_MONITOR); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainWindow::selectAsCurrentItem(const caf::PdmObject* object) -{ - m_projectTreeView->selectAsCurrentItem(object); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 916a2ab5c4..8a16611012 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -78,7 +78,7 @@ public: static RiuMainWindow* instance(); - virtual QString mainWindowName() { return "RiuMainWindow"; } + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); void cleanupGuiCaseClose(); @@ -93,12 +93,10 @@ public: void refreshAnimationActions(); void updateScaleValue(); - caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} RiuProcessMonitor* processMonitor(); void hideAllDockWindows(); - void selectAsCurrentItem(const caf::PdmObject* object); void selectedCases(std::vector& cases); @@ -108,7 +106,7 @@ public: void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); - RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer); + RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override; void tileWindows(); bool isAnyMdiSubWindowVisible(); @@ -247,7 +245,6 @@ private slots: public: void setPdmRoot(caf::PdmObject* pdmRoot); private: - caf::PdmUiTreeView* m_projectTreeView; std::unique_ptr m_dragDropInterface; diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp index 0c09d6e193..709e68234c 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp @@ -21,11 +21,15 @@ #include "RiaVersionInfo.h" #include +#include "cafPdmUiTreeView.h" +#include "cafPdmObject.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuMainWindowBase::RiuMainWindowBase() + : m_projectTreeView(nullptr) + , m_allowActiveViewChangeFromSelection(true) { setDockNestingEnabled(true); } @@ -96,3 +100,21 @@ QString RiuMainWindowBase::registryFolderName() QString regFolder = QString("%1/%2").arg(versionName).arg(mainWindowName()); return regFolder; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange) +{ + m_allowActiveViewChangeFromSelection = allowActiveViewChange; + m_projectTreeView->selectAsCurrentItem(object); + m_allowActiveViewChangeFromSelection = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) +{ + m_projectTreeView->setExpanded(uiItem, expanded); +} diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.h b/ApplicationCode/UserInterface/RiuMainWindowBase.h index 2bb580509e..5ac3f39663 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.h @@ -22,6 +22,13 @@ struct RimMdiWindowGeometry; +namespace caf +{ + class PdmObject; + class PdmUiTreeView; + class PdmUiItem; +} + //================================================================================================== /// //================================================================================================== @@ -44,6 +51,16 @@ public: void saveWinGeoAndDockToolBarLayout(); void showWindow(); + caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} + void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + + void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + +protected: + caf::PdmUiTreeView* m_projectTreeView; + bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control + // whether to select the corresponding active view or not + private: QString registryFolderName(); }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index ecbe5af3ed..d15c937dbb 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -571,11 +571,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM intersectionHit = true; intersectionTriangleHit = crossSectionSourceInfo->triangle(firstPartTriangleIndex); - if (!dynamic_cast(m_viewer->ownerViewWindow())) - { - RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection()); - } - + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection(), allowActiveViewChange); } else if (intersectionBoxSourceInfo) {