mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8387 from OPM/qtcharts-summary-plots
Closes #8228 Major refactoring of summary plotting. Now possible to create plots both with Qwt and QtChart as plotting tool.
This commit is contained in:
committed by
GitHub
parent
d9bb82de91
commit
258fbddc10
@@ -19,27 +19,31 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "RiuPlotWidget.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <set>
|
||||
|
||||
class RiaPlotWindowRedrawScheduler;
|
||||
class RimPlot;
|
||||
class RiuDraggableOverlayFrame;
|
||||
class RimPlotCurve;
|
||||
|
||||
class RiuPlotCurve;
|
||||
class RiuPlotItem;
|
||||
|
||||
class QwtPlot;
|
||||
class QwtLegend;
|
||||
class QwtPicker;
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotGrid;
|
||||
class QwtPlotItem;
|
||||
class QwtPlotMarker;
|
||||
class QwtScaleWidget;
|
||||
|
||||
class QEvent;
|
||||
class QLabel;
|
||||
@@ -52,7 +56,7 @@ class QWheelEvent;
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuQwtPlotWidget : public QwtPlot, public RiuInterfaceToViewWindow
|
||||
class RiuQwtPlotWidget : public RiuPlotWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -60,82 +64,110 @@ public:
|
||||
RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent = nullptr );
|
||||
~RiuQwtPlotWidget() override;
|
||||
|
||||
RimPlot* plotDefinition();
|
||||
|
||||
bool isChecked() const;
|
||||
|
||||
int colSpan() const;
|
||||
int rowSpan() const;
|
||||
|
||||
int axisTitleFontSize( QwtPlot::Axis axis ) const;
|
||||
int axisValueFontSize( QwtPlot::Axis axis ) const;
|
||||
void setAxisFontsAndAlignment( QwtPlot::Axis,
|
||||
int axisTitleFontSize( RiaDefines::PlotAxis axis ) const override;
|
||||
int axisValueFontSize( RiaDefines::PlotAxis axis ) const override;
|
||||
void setAxisFontsAndAlignment( RiaDefines::PlotAxis,
|
||||
int titleFontSize,
|
||||
int valueFontSize,
|
||||
bool titleBold = false,
|
||||
int alignment = (int)Qt::AlignCenter );
|
||||
int alignment = (int)Qt::AlignCenter ) override;
|
||||
void setAxesFontsAndAlignment( int titleFontSize,
|
||||
int valueFontSize,
|
||||
bool titleBold = false,
|
||||
int alignment = (int)Qt::AlignCenter );
|
||||
int alignment = (int)Qt::AlignCenter ) override;
|
||||
|
||||
void setAxisTitleText( QwtPlot::Axis axis, const QString& title );
|
||||
void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable );
|
||||
void enableAxis( RiaDefines::PlotAxis axis, bool isEnabled ) override;
|
||||
bool axisEnabled( RiaDefines::PlotAxis axis ) const override;
|
||||
|
||||
void setPlotTitle( const QString& plotTitle );
|
||||
void setAxisScale( RiaDefines::PlotAxis axis, double min, double max ) override;
|
||||
void setAxisAutoScale( RiaDefines::PlotAxis axis, bool enable ) override;
|
||||
|
||||
void setAxisMaxMinor( RiaDefines::PlotAxis axis, int maxMinor ) override;
|
||||
void setAxisMaxMajor( RiaDefines::PlotAxis axis, int maxMajor ) override;
|
||||
|
||||
RiuPlotWidget::AxisScaleType axisScaleType( RiaDefines::PlotAxis axis ) const override;
|
||||
void setAxisScaleType( RiaDefines::PlotAxis axis, RiuPlotWidget::AxisScaleType axisScaleType ) override;
|
||||
|
||||
void setAxisTitleText( RiaDefines::PlotAxis axis, const QString& title ) override;
|
||||
void setAxisTitleEnabled( RiaDefines::PlotAxis axis, bool enable ) override;
|
||||
|
||||
void setPlotTitle( const QString& plotTitle ) override;
|
||||
const QString& plotTitle() const;
|
||||
void setPlotTitleEnabled( bool enabled );
|
||||
bool plotTitleEnabled() const;
|
||||
void setPlotTitleFontSize( int titleFontSize );
|
||||
void setPlotTitleFontSize( int titleFontSize ) override;
|
||||
|
||||
void setLegendFontSize( int fontSize );
|
||||
void setInternalLegendVisible( bool visible );
|
||||
void setLegendFontSize( int fontSize ) override;
|
||||
void setInternalLegendVisible( bool visible ) override;
|
||||
void insertLegend( RiuPlotWidget::Legend ) override;
|
||||
void clearLegend() override;
|
||||
|
||||
QwtInterval axisRange( QwtPlot::Axis axis ) const;
|
||||
void setAxisRange( QwtPlot::Axis axis, double min, double max );
|
||||
std::pair<double, double> axisRange( RiaDefines::PlotAxis axis ) const override;
|
||||
void setAxisRange( RiaDefines::PlotAxis axis, double min, double max ) override;
|
||||
|
||||
void setAxisInverted( QwtPlot::Axis axis );
|
||||
void setAxisLabelsAndTicksEnabled( QwtPlot::Axis axis, bool enableLabels, bool enableTicks );
|
||||
void setAxisInverted( RiaDefines::PlotAxis axis, bool isInverted ) override;
|
||||
void setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis axis, bool enableLabels, bool enableTicks ) override;
|
||||
|
||||
void enableGridLines( QwtPlot::Axis axis, bool majorGridLines, bool minorGridLines );
|
||||
void enableGridLines( RiaDefines::PlotAxis axis, bool majorGridLines, bool minorGridLines ) override;
|
||||
|
||||
void setMajorAndMinorTickIntervals( QwtPlot::Axis axis,
|
||||
double majorTickInterval,
|
||||
double minorTickInterval,
|
||||
double minValue,
|
||||
double maxValue );
|
||||
void setMajorAndMinorTickIntervalsAndRange( QwtPlot::Axis axis,
|
||||
double majorTickInterval,
|
||||
double minorTickInterval,
|
||||
double minTickValue,
|
||||
double maxTickValue,
|
||||
double rangeMin,
|
||||
double rangeMax );
|
||||
void setAutoTickIntervalCounts( QwtPlot::Axis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount );
|
||||
double majorTickInterval( QwtPlot::Axis axis ) const;
|
||||
double minorTickInterval( QwtPlot::Axis axis ) const;
|
||||
void setMajorAndMinorTickIntervals( RiaDefines::PlotAxis axis,
|
||||
double majorTickInterval,
|
||||
double minorTickInterval,
|
||||
double minValue,
|
||||
double maxValue ) override;
|
||||
void setMajorAndMinorTickIntervalsAndRange( RiaDefines::PlotAxis axis,
|
||||
double majorTickInterval,
|
||||
double minorTickInterval,
|
||||
double minTickValue,
|
||||
double maxTickValue,
|
||||
double rangeMin,
|
||||
double rangeMax ) override;
|
||||
void setAutoTickIntervalCounts( RiaDefines::PlotAxis axis,
|
||||
int maxMajorTickIntervalCount,
|
||||
int maxMinorTickIntervalCount ) override;
|
||||
double majorTickInterval( RiaDefines::PlotAxis axis ) const override;
|
||||
double minorTickInterval( RiaDefines::PlotAxis axis ) const override;
|
||||
|
||||
int axisExtent( QwtPlot::Axis axis ) const;
|
||||
int axisExtent( RiaDefines::PlotAxis axis ) const override;
|
||||
|
||||
bool frameIsInFrontOfThis( const QRect& frameGeometry );
|
||||
QPoint dragStartPosition() const;
|
||||
|
||||
void scheduleReplot();
|
||||
|
||||
void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void updateLayout() override;
|
||||
|
||||
void renderTo( QPainter* painter, const QRect& targetRect, double scaling );
|
||||
void renderTo( QPaintDevice* painter, const QRect& targetRect );
|
||||
void renderTo( QPainter* painter, const QRect& targetRect, double scaling ) override;
|
||||
void renderTo( QPaintDevice* painter, const QRect& targetRect ) override;
|
||||
int overlayMargins() const;
|
||||
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
QwtPlot* qwtPlot() const;
|
||||
|
||||
void removeEventFilter() override;
|
||||
|
||||
void updateLegend() override;
|
||||
void updateAxes() override;
|
||||
|
||||
RiuPlotCurve* createPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title, const QColor& color ) override;
|
||||
|
||||
void detachItems( RiuPlotWidget::PlotItemType plotItemType ) override;
|
||||
|
||||
void findClosestPlotItem( const QPoint& pos,
|
||||
QwtPlotItem** closestItem,
|
||||
int* closestCurvePoint,
|
||||
double* distanceFromClick ) const;
|
||||
|
||||
const QColor& backgroundColor() const override;
|
||||
|
||||
QWidget* getParentForOverlay() const override;
|
||||
|
||||
std::pair<RiuPlotCurve*, int> findClosestCurve( const QPoint& pos, double& distanceToClick ) const override;
|
||||
|
||||
signals:
|
||||
void plotSelected( bool toggleSelection );
|
||||
void axisSelected( int axisId, bool toggleSelection );
|
||||
void plotItemSelected( QwtPlotItem* plotItem, bool toggleSelection, int sampleIndex );
|
||||
void plotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggleSelection, int sampleIndex );
|
||||
void onKeyPressEvent( QKeyEvent* event );
|
||||
void onWheelEvent( QWheelEvent* event );
|
||||
void plotZoomed();
|
||||
@@ -148,7 +180,7 @@ protected:
|
||||
void keyPressEvent( QKeyEvent* event ) override;
|
||||
|
||||
void applyPlotTitleToQwt();
|
||||
void applyAxisTitleToQwt( QwtPlot::Axis axis );
|
||||
void applyAxisTitleToQwt( RiaDefines::PlotAxis axis );
|
||||
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
@@ -156,11 +188,6 @@ protected:
|
||||
virtual bool isZoomerActive() const;
|
||||
virtual void endZoomOperations();
|
||||
|
||||
void findClosestPlotItem( const QPoint& pos,
|
||||
QwtPlotItem** closestItem,
|
||||
int* closestCurvePoint,
|
||||
double* distanceFromClick ) const;
|
||||
|
||||
private:
|
||||
void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false );
|
||||
static int defaultMinimumWidth();
|
||||
@@ -169,21 +196,9 @@ private:
|
||||
void highlightPlotItem( const QwtPlotItem* closestItem );
|
||||
void resetPlotItemHighlighting();
|
||||
void onAxisSelected( QwtScaleWidget* scale, bool toggleItemInSelection );
|
||||
void recalculateAxisExtents( QwtPlot::Axis axis );
|
||||
|
||||
void updateOverlayFrameLayout();
|
||||
void recalculateAxisExtents( RiaDefines::PlotAxis axis );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimPlot> m_plotDefinition;
|
||||
QPoint m_clickPosition;
|
||||
std::map<QwtPlot::Axis, QString> m_axisTitles;
|
||||
std::map<QwtPlot::Axis, bool> m_axisTitlesEnabled;
|
||||
const int m_overlayMargins;
|
||||
QString m_plotTitle;
|
||||
bool m_plotTitleEnabled;
|
||||
|
||||
QList<QPointer<RiuDraggableOverlayFrame>> m_overlayFrames;
|
||||
|
||||
struct CurveColors
|
||||
{
|
||||
QColor lineColor;
|
||||
@@ -194,5 +209,5 @@ private:
|
||||
std::map<QwtPlotCurve*, CurveColors> m_originalCurveColors;
|
||||
std::map<QwtPlotCurve*, double> m_originalZValues;
|
||||
|
||||
friend class RiaPlotWindowRedrawScheduler;
|
||||
QPointer<QwtPlot> m_plot;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user