mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#14600 Write a compatibility window controller section to the project file
The MDI to dock widget refactoring renamed the PDM class RimMdiWindowController to RimDockWindowController, and with it the class keyword written to the project file. Previous versions of ResInsight have no factory entry for DockWindowController, so the window controller of a plot is never created and the plot is silently invisible when the project file is opened by such a version. Keep DockWindowController as the keyword written for the window controller in use, and write the main window id a second time using the old keyword. RimViewWindow now has two child fields, the previous keyword WindowController holds the compatibility object and the new keyword DockWindow holds the window controller in use. Previous versions read the compatibility section and ignore the unknown DockWindow field, current versions read both and keep them in sync in dockInWindow(). RimMdiWindowController_OBSOLETE owns the keyword MdiWindowController and is derived from RimDockWindowController, so project files written by intermediate development versions using DockWindowController in the compatibility section are read into the same field without a type mismatch. RimDockWindowController::initAfterRead() restores the window controller in use from the compatibility section, covering both file layouts. The dropped geometry fields are harmless, RimMdiWindowGeometry::isValid() returns false and the previous version falls back to a default subwindow size, which is the same path the 3D views already take.
This commit is contained in:
1 parent
74ffc822f2
commit
eda6d465e9
7 files changed
+99
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -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<RimViewWindow>();
|
||||
if ( !viewWindow || viewWindow->m_legacyWindowController != this ) return;
|
||||
|
||||
viewWindow->dockInWindow( m_mainWindowID() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
void removeWindowFromDock();
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
RimViewWindow* viewPdmObject();
|
||||
QWidget* viewWidget();
|
||||
RiuMainWindowBase* getMainWindow();
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimMdiWindowController.h"
|
||||
|
||||
CAF_PDM_XML_SOURCE_INIT( RimMdiWindowController_OBSOLETE, "MdiWindowController" );
|
||||
@@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// 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;
|
||||
};
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -114,6 +114,10 @@ private:
|
||||
protected:
|
||||
caf::PdmChildField<RimDockWindowController*> m_windowController;
|
||||
|
||||
// Compatibility section making the project file readable by ResInsight 2026.06 and older, holds a
|
||||
// RimMdiWindowController_OBSOLETE
|
||||
caf::PdmChildField<RimDockWindowController*> m_legacyWindowController;
|
||||
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
ads::CDockWidget* m_dockWidget;
|
||||
caf::PdmField<QString> m_dockWindowId;
|
||||
|
||||
Reference in new issue
Block a user