mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
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.
126 lines
3.9 KiB
C++
126 lines
3.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2016 Statoil 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 "RiaDefines.h"
|
|
|
|
#include "cafFontTools.h"
|
|
#include "cafPdmChildField.h"
|
|
#include "cafPdmField.h"
|
|
#include "cafPdmObject.h"
|
|
|
|
class QImage;
|
|
class RimDockWindowController;
|
|
|
|
namespace ads
|
|
{
|
|
class CDockWidget;
|
|
} // namespace ads
|
|
|
|
class RimViewWindow : public caf::PdmObject, public caf::FontHolderInterface
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
RimViewWindow();
|
|
~RimViewWindow() override;
|
|
|
|
virtual int id() const = 0;
|
|
|
|
bool showWindow() const;
|
|
void setShowWindow( bool showWindow );
|
|
|
|
void setAsActiveViewer( bool allowSelectionChange = false );
|
|
bool isActiveViewer() const;
|
|
|
|
bool isMainDockedWindow() const;
|
|
|
|
bool isDockedIn3DView() const;
|
|
bool isDockedInPlotView() const;
|
|
|
|
void loadDataAndUpdate();
|
|
void updateDockWindowVisibility();
|
|
|
|
void removeWindowFromDock();
|
|
|
|
void dockAs3DViewWindow();
|
|
void dockAsPlotWindow();
|
|
|
|
virtual QWidget* viewWidget() = 0;
|
|
|
|
ads::CDockWidget* dockWidget() const;
|
|
ads::CDockWidget* createDockWidget();
|
|
|
|
virtual QImage captureSnapshot( int width, int height );
|
|
|
|
virtual QImage snapshotWindowContent();
|
|
virtual void zoomAll() = 0;
|
|
|
|
void viewNavigationChanged();
|
|
|
|
virtual void updateWindowTitle();
|
|
void updateWindowTitleIcon( QString title );
|
|
|
|
void resetDockWindowId();
|
|
QString dockWindowName();
|
|
|
|
protected:
|
|
//// Interface for the Window controller
|
|
friend class RimDockWindowController;
|
|
|
|
QString windowTitle();
|
|
virtual QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) = 0;
|
|
virtual void updateViewWidgetAfterCreation() {};
|
|
virtual void deleteViewWidget() = 0;
|
|
virtual void onLoadDataAndUpdate() = 0;
|
|
virtual void onViewNavigationChanged();
|
|
virtual bool isWindowVisible() const; // Virtual To allow special visibility control
|
|
void deleteDockWidget();
|
|
void setActive( bool active );
|
|
////
|
|
|
|
// Derived classes are not supposed to override this function. The intention is to always use m_showWindow
|
|
// as the objectToggleField for this class. This way the visibility of a widget being part of a composite widget
|
|
// can be controlled from the project tree using check box toggles
|
|
caf::PdmFieldHandle* objectToggleField() final;
|
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
|
|
|
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
|
|
|
static QImage internalCaptureSnapshot( ads::CDockWidget* dockWidget, QWidget* widget, int width, int height );
|
|
|
|
private:
|
|
friend class RimProject;
|
|
|
|
void dockInWindow( int mainWindowID );
|
|
virtual void assignIdIfNecessary() = 0;
|
|
|
|
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;
|
|
bool m_isActiveViewer;
|
|
};
|