diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index d3e7a00d28..e314e8f4c0 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -63,6 +63,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimStackablePlotCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimAdvancedSnapshotExportDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RimDockWindowController.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.cpp ${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.cpp diff --git a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp index f1dd9fcfa0..d39231f0f7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp @@ -34,7 +34,9 @@ #include "DockManager.h" #include "DockWidget.h" -CAF_PDM_XML_SOURCE_INIT( RimDockWindowController, "DockWindowController", "MdiWindowController" ); +// The keyword "MdiWindowController" is owned by RimMdiWindowController_OBSOLETE, used to write a compatibility +// section readable by ResInsight 2026.06 and older. See RimViewWindow::m_legacyWindowController. +CAF_PDM_XML_SOURCE_INIT( RimDockWindowController, "DockWindowController" ); //-------------------------------------------------------------------------------------------------- /// @@ -54,6 +56,23 @@ RimDockWindowController::~RimDockWindowController() m_viewToControl = nullptr; } +//-------------------------------------------------------------------------------------------------- +/// Project files written by ResInsight 2026.06 and older, and by development versions using the class keyword +/// "DockWindowController" in the compatibility section, have no window controller outside that section. Restore the +/// window controller in use from the compatibility section, see RimMdiWindowController_OBSOLETE. +/// +/// Project files written by current versions have both sections, and they are always in sync. +//-------------------------------------------------------------------------------------------------- +void RimDockWindowController::initAfterRead() +{ + if ( m_mainWindowID() == MAIN_WINDOW_ID_UNASSIGNED ) return; + + auto viewWindow = firstAncestorOrThisOfType(); + if ( !viewWindow || viewWindow->m_legacyWindowController != this ) return; + + viewWindow->dockInWindow( m_mainWindowID() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.h b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.h index 7256f1329c..5cdf50d8d2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.h +++ b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.h @@ -56,6 +56,8 @@ public: void removeWindowFromDock(); protected: + void initAfterRead() override; + RimViewWindow* viewPdmObject(); QWidget* viewWidget(); RiuMainWindowBase* getMainWindow(); diff --git a/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp b/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp new file mode 100644 index 0000000000..245c135a0e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp @@ -0,0 +1,21 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimMdiWindowController.h" + +CAF_PDM_XML_SOURCE_INIT( RimMdiWindowController_OBSOLETE, "MdiWindowController" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.h b/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.h new file mode 100644 index 0000000000..59cbfec836 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimDockWindowController.h" + +//================================================================================================== +/// Compatibility object used to make project files readable by ResInsight 2026.06 and older. +/// +/// These versions create the window controller for a view window from the class keyword +/// "MdiWindowController". Without a section using this keyword, plot windows are never made visible +/// when the project file is opened by an older version. +/// +/// The object adds no behavior, it is only used to write the main window id using the old class +/// keyword. It is stored in RimViewWindow::m_legacyWindowController, and is kept in sync with the +/// window controller in use. Can be removed after 2-3 major releases. +//================================================================================================== +class RimMdiWindowController_OBSOLETE : public RimDockWindowController +{ + CAF_PDM_HEADER_INIT; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp index 7cd3dad2be..4fc5b10de6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp @@ -26,6 +26,7 @@ #include "RicfCommandObject.h" #include "RimDockWindowController.h" +#include "RimMdiWindowController.h" #include "RiuDockWidgetTools.h" @@ -51,9 +52,13 @@ RimViewWindow::RimViewWindow() { CAF_PDM_InitScriptableObjectWithNameAndComment( "View window", "", "", "", "ViewWindow", "The Base Class for all Views and Plots in ResInsight" ); - CAF_PDM_InitFieldNoDefault( &m_windowController, "WindowController", "" ); + CAF_PDM_InitFieldNoDefault( &m_windowController, "DockWindow", "" ); m_windowController.uiCapability()->setUiTreeChildrenHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_legacyWindowController, "WindowController", "" ); + m_legacyWindowController.uiCapability()->setUiTreeChildrenHidden( true ); + m_legacyWindowController.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_showWindow, "ShowWindow", true, "Show Window" ); m_showWindow.uiCapability()->setUiHidden( true ); @@ -67,6 +72,7 @@ RimViewWindow::RimViewWindow() RimViewWindow::~RimViewWindow() { if ( m_windowController() ) delete m_windowController(); + if ( m_legacyWindowController() ) delete m_legacyWindowController(); } //-------------------------------------------------------------------------------------------------- @@ -391,6 +397,13 @@ void RimViewWindow::dockInWindow( int mainWindowID ) } m_windowController->setViewToControl( this ); m_windowController->setMainWindowId( mainWindowID ); + + // Keep the compatibility section in sync, see RimMdiWindowController_OBSOLETE + if ( m_legacyWindowController == nullptr ) + { + m_legacyWindowController = new RimMdiWindowController_OBSOLETE(); + } + m_legacyWindowController->setMainWindowId( mainWindowID ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.h b/ApplicationLibCode/ProjectDataModel/RimViewWindow.h index 27f524d3fe..60ee11afd5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.h @@ -114,6 +114,10 @@ private: protected: caf::PdmChildField m_windowController; + // Compatibility section making the project file readable by ResInsight 2026.06 and older, holds a + // RimMdiWindowController_OBSOLETE + caf::PdmChildField m_legacyWindowController; + caf::PdmField m_showWindow; ads::CDockWidget* m_dockWidget; caf::PdmField m_dockWindowId;