2019-10-11 08:54:19 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-12-19 04:37:40 -06:00
|
|
|
// Copyright (C) 2019- Equinor ASA
|
2019-10-11 08:54:19 -05:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
#include "RiuMultiPlotPage.h"
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
#include "cafPdmPointer.h"
|
|
|
|
#include "cafSelectionChangedReceiver.h"
|
|
|
|
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QList>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class RiaPlotWindowRedrawScheduler;
|
2020-01-16 05:32:40 -06:00
|
|
|
class RimMultiPlot;
|
2019-12-19 04:37:40 -06:00
|
|
|
class RiuMultiPlotPage;
|
2022-01-17 06:14:21 -06:00
|
|
|
class RiuPlotWidget;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
class BookFrame;
|
2019-10-11 08:54:19 -05:00
|
|
|
class QFocusEvent;
|
|
|
|
class QLabel;
|
2019-12-19 04:37:40 -06:00
|
|
|
class QPaintDevice;
|
|
|
|
class QScrollArea;
|
2019-10-11 08:54:19 -05:00
|
|
|
class QScrollBar;
|
2019-12-18 05:25:19 -06:00
|
|
|
class QwtPlot;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
//
|
2020-01-16 05:32:40 -06:00
|
|
|
// RiuMultiPlotWindow
|
2019-10-11 08:54:19 -05:00
|
|
|
//
|
|
|
|
//==================================================================================================
|
2020-01-16 05:32:40 -06:00
|
|
|
class RiuMultiPlotBook : public QWidget, public RiuInterfaceToViewWindow
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
public:
|
|
|
|
RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent = nullptr );
|
|
|
|
~RiuMultiPlotBook() override;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
RimViewWindow* ownerViewWindow() const override;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2022-01-17 06:14:21 -06:00
|
|
|
void addPlot( RiuPlotWidget* plotWidget );
|
|
|
|
void insertPlot( RiuPlotWidget* plotWidget, size_t index );
|
|
|
|
void removePlot( RiuPlotWidget* plotWidget );
|
2022-04-01 12:23:27 -05:00
|
|
|
void removePlotNoUpdate( RiuPlotWidget* plotWidget );
|
2020-09-16 06:10:37 -05:00
|
|
|
void removeAllPlots();
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
void setPlotTitle( const QString& plotTitle );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
void setTitleVisible( bool visible );
|
|
|
|
void setSubTitlesVisible( bool visible );
|
2022-05-03 04:30:09 -05:00
|
|
|
void scheduleTitleUpdate();
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-05-09 04:23:58 -05:00
|
|
|
void setTitleFontSizes( int titleFontSize, int subTitleFontSize );
|
|
|
|
void setLegendFontSize( int legendFontSize );
|
|
|
|
void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2022-01-17 06:14:21 -06:00
|
|
|
int indexOfPlotWidget( RiuPlotWidget* plotWidget );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-06-09 06:43:22 -05:00
|
|
|
bool pagePreviewModeEnabled() const;
|
|
|
|
void setPagePreviewModeEnabled( bool previewMode );
|
2020-01-08 01:53:06 -06:00
|
|
|
|
2022-05-04 06:11:04 -05:00
|
|
|
void scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate = RiaDefines::MultiPlotPageUpdateType::ALL );
|
2019-12-19 04:37:40 -06:00
|
|
|
void scheduleReplotOfAllPlots();
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
void renderTo( QPaintDevice* painter );
|
2019-12-18 05:25:19 -06:00
|
|
|
|
2022-04-07 09:24:27 -05:00
|
|
|
void scrollToPlot( RiuPlotWidget* plotWidget );
|
|
|
|
|
2022-03-10 06:13:44 -06:00
|
|
|
void goToNextPage();
|
|
|
|
void goToPrevPage();
|
2022-03-15 09:57:15 -05:00
|
|
|
void goToLastPage();
|
2022-03-10 06:13:44 -06:00
|
|
|
|
2022-05-03 04:30:09 -05:00
|
|
|
void keepCurrentPageAfterUpdate();
|
|
|
|
|
2023-06-06 02:20:29 -05:00
|
|
|
// https://github.com/OPM/ResInsight/issues/10349
|
|
|
|
// This function is used to force an update of the plot book. It is intended to be used from RimMultiPlot::onLoadDataAndUpdate()
|
|
|
|
// The code used to be called from RiuMultiPlotBook::showEvent(), but this caused a crash when a dock widget was hidden and shown again.
|
|
|
|
void forcePerformUpdate();
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
protected:
|
2019-12-19 04:37:40 -06:00
|
|
|
void contextMenuEvent( QContextMenuEvent* ) override;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
void showEvent( QShowEvent* event ) override;
|
2022-03-30 08:54:11 -05:00
|
|
|
void hideEvent( QHideEvent* event ) override;
|
2019-12-19 04:37:40 -06:00
|
|
|
void resizeEvent( QResizeEvent* event ) override;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-06-09 06:43:22 -05:00
|
|
|
void applyPagePreviewBookSize( int frameWidth );
|
|
|
|
void applyBookSize( int frameWidth, int frameHeight );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
std::pair<int, int> rowAndColumnCount( int plotWidgetCount ) const;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
virtual bool showYAxis( int row, int column ) const;
|
|
|
|
|
2022-01-17 06:14:21 -06:00
|
|
|
QList<QPointer<RiuPlotWidget>> visiblePlotWidgets() const;
|
2019-10-31 07:48:40 -05:00
|
|
|
|
2022-03-15 09:57:15 -05:00
|
|
|
void dragEnterEvent( QDragEnterEvent* event ) override;
|
|
|
|
void dropEvent( QDropEvent* event ) override;
|
|
|
|
|
2022-03-25 05:39:12 -05:00
|
|
|
void timerEvent( QTimerEvent* event ) override;
|
|
|
|
|
2022-03-30 08:54:11 -05:00
|
|
|
bool eventFilter( QObject* obj, QEvent* ev ) override;
|
|
|
|
|
2022-04-19 05:34:40 -05:00
|
|
|
virtual void createPages();
|
|
|
|
|
|
|
|
void adjustBookFrame();
|
|
|
|
void applyPageSettings( RiuMultiPlotPage* page );
|
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
const QList<QPointer<RiuMultiPlotPage>>& pages() const;
|
2022-04-19 05:34:40 -05:00
|
|
|
|
2022-05-04 06:11:04 -05:00
|
|
|
void updatePageTitles();
|
|
|
|
|
2022-04-19 05:34:40 -05:00
|
|
|
private:
|
|
|
|
RiuMultiPlotPage* createPage();
|
|
|
|
void deleteAllPages();
|
|
|
|
void applyLook();
|
2022-03-10 06:13:44 -06:00
|
|
|
|
2022-03-15 09:57:15 -05:00
|
|
|
void changeCurrentPage( int pageNumber );
|
2022-03-10 06:13:44 -06:00
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
private slots:
|
2022-05-04 06:11:04 -05:00
|
|
|
virtual void performUpdate( RiaDefines::MultiPlotPageUpdateType updateType );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
protected:
|
2019-12-19 04:37:40 -06:00
|
|
|
friend class RiaPlotWindowRedrawScheduler;
|
2019-10-31 07:48:40 -05:00
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
QPointer<QVBoxLayout> m_layout;
|
|
|
|
QPointer<QScrollArea> m_scrollArea;
|
|
|
|
QPointer<BookFrame> m_book;
|
|
|
|
QPointer<QVBoxLayout> m_bookLayout;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
QList<QPointer<RiuMultiPlotPage>> m_pages;
|
2022-01-17 06:14:21 -06:00
|
|
|
QList<QPointer<RiuPlotWidget>> m_plotWidgets;
|
2020-01-16 05:32:40 -06:00
|
|
|
caf::PdmPointer<RimMultiPlot> m_plotDefinition;
|
|
|
|
QString m_plotTitle;
|
|
|
|
bool m_titleVisible;
|
|
|
|
bool m_subTitlesVisible;
|
|
|
|
bool m_previewMode;
|
2022-03-10 06:13:44 -06:00
|
|
|
int m_currentPageIndex;
|
2022-03-25 05:39:12 -05:00
|
|
|
|
2022-03-30 08:54:11 -05:00
|
|
|
bool m_goToPageAfterUpdate;
|
|
|
|
int m_pageToGoTo;
|
2022-03-25 05:39:12 -05:00
|
|
|
int m_pageTimerId;
|
2019-10-11 08:54:19 -05:00
|
|
|
};
|