mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
Take the view's dock widget as a parameter instead of discovering it by walking the widget parent chain, so the caller supplies it directly. Also forward declare QImage in RimViewWindow.h instead of including it, and drop now unused includes in RimViewWindow.cpp.
121 lines
3.6 KiB
C++
121 lines
3.6 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 isActive() 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 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;
|
|
|
|
caf::PdmField<bool> m_showWindow;
|
|
ads::CDockWidget* m_dockWidget;
|
|
caf::PdmField<QString> m_dockWindowId;
|
|
bool m_isActiveViewer;
|
|
};
|