mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
Multiaxis: Use correct mapping from PlotAxis to QwtAxisId.
This commit is contained in:
parent
395541ebe0
commit
288269fad7
@ -143,7 +143,7 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plot
|
|||||||
auto qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
auto qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
||||||
if ( qwtPlotWidget )
|
if ( qwtPlotWidget )
|
||||||
{
|
{
|
||||||
auto qwtAxisId = RiuQwtPlotTools::toQwtPlotAxis( axis );
|
auto qwtAxisId = qwtPlotWidget->toQwtPlotAxis( axis );
|
||||||
|
|
||||||
if ( m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_AUTO &&
|
if ( m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_AUTO &&
|
||||||
m_axisProperties->scaleFactor() == 1.0 )
|
m_axisProperties->scaleFactor() == 1.0 )
|
||||||
|
@ -308,12 +308,14 @@ QSize RiuQwtPlotCurve::legendIconSize() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotCurve::attachToPlot( RiuPlotWidget* plotWidget )
|
void RiuQwtPlotCurve::attachToPlot( RiuPlotWidget* plotWidget )
|
||||||
{
|
{
|
||||||
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
m_plotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
||||||
attach( qwtPlotWidget->qwtPlot() );
|
CAF_ASSERT( m_plotWidget );
|
||||||
|
|
||||||
|
attach( m_plotWidget->qwtPlot() );
|
||||||
|
|
||||||
if ( m_showErrorBars )
|
if ( m_showErrorBars )
|
||||||
{
|
{
|
||||||
m_qwtCurveErrorBars->attach( qwtPlotWidget->qwtPlot() );
|
m_qwtCurveErrorBars->attach( m_plotWidget->qwtPlot() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,7 +481,7 @@ void RiuQwtPlotCurve::setSamplesFromXYErrorValues( const std::vector<double>&
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotCurve::setXAxis( RiuPlotAxis axis )
|
void RiuQwtPlotCurve::setXAxis( RiuPlotAxis axis )
|
||||||
{
|
{
|
||||||
QwtPlotCurve::setXAxis( RiuQwtPlotTools::toQwtPlotAxis( axis ) );
|
if ( m_plotWidget ) QwtPlotCurve::setXAxis( m_plotWidget->toQwtPlotAxis( axis ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -487,7 +489,7 @@ void RiuQwtPlotCurve::setXAxis( RiuPlotAxis axis )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotCurve::setYAxis( RiuPlotAxis axis )
|
void RiuQwtPlotCurve::setYAxis( RiuPlotAxis axis )
|
||||||
{
|
{
|
||||||
QwtPlotCurve::setYAxis( RiuQwtPlotTools::toQwtPlotAxis( axis ) );
|
if ( m_plotWidget ) QwtPlotCurve::setYAxis( m_plotWidget->toQwtPlotAxis( axis ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "qwt_plot_curve.h"
|
#include "qwt_plot_curve.h"
|
||||||
|
|
||||||
class QwtPlotIntervalCurve;
|
class QwtPlotIntervalCurve;
|
||||||
|
class RiuQwtPlotWidget;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
@ -101,4 +102,6 @@ protected:
|
|||||||
|
|
||||||
QwtPlotIntervalCurve* m_qwtCurveErrorBars;
|
QwtPlotIntervalCurve* m_qwtCurveErrorBars;
|
||||||
bool m_showErrorBars;
|
bool m_showErrorBars;
|
||||||
|
|
||||||
|
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "RiuQtChartsPlotCurveSymbol.h"
|
#include "RiuQtChartsPlotCurveSymbol.h"
|
||||||
#include "RiuQwtPlotLegend.h"
|
#include "RiuQwtPlotLegend.h"
|
||||||
|
|
||||||
|
#include "qwt_axis.h"
|
||||||
#include "qwt_date_scale_draw.h"
|
#include "qwt_date_scale_draw.h"
|
||||||
#include "qwt_date_scale_engine.h"
|
#include "qwt_date_scale_engine.h"
|
||||||
#include "qwt_graphic.h"
|
#include "qwt_graphic.h"
|
||||||
@ -39,9 +40,6 @@
|
|||||||
#include "qwt_plot_shapeitem.h"
|
#include "qwt_plot_shapeitem.h"
|
||||||
#include "qwt_scale_widget.h"
|
#include "qwt_scale_widget.h"
|
||||||
|
|
||||||
#include "qwt_axis.h"
|
|
||||||
#include <QRegExp>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -245,16 +243,6 @@ QwtPlotShapeItem* RiuQwtPlotTools::createBoxShape( const QString& label,
|
|||||||
return createBoxShapeT<QwtPlotShapeItem>( label, startX, endX, startY, endY, color, brushStyle );
|
return createBoxShapeT<QwtPlotShapeItem>( label, startX, endX, startY, endY, color, brushStyle );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
QwtAxisId RiuQwtPlotTools::toQwtPlotAxis( RiuPlotAxis axis )
|
|
||||||
{
|
|
||||||
QwtAxis::Position qwtPosition = toQwtPlotAxisEnum( axis.axis() );
|
|
||||||
|
|
||||||
return { qwtPosition, axis.index() };
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -65,10 +65,8 @@ public:
|
|||||||
QColor color,
|
QColor color,
|
||||||
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
||||||
|
|
||||||
|
|
||||||
static void updateLegendData( RiuQwtPlotLegend* legend, const std::vector<RimPlotCurve*>& curves );
|
static void updateLegendData( RiuQwtPlotLegend* legend, const std::vector<RimPlotCurve*>& curves );
|
||||||
static QList<QwtLegendData> createLegendData( const std::vector<RimPlotCurve*>& curves );
|
static QList<QwtLegendData> createLegendData( const std::vector<RimPlotCurve*>& curves );
|
||||||
static QwtAxisId toQwtPlotAxis( RiuPlotAxis riuPlotAxis );
|
|
||||||
static QwtAxis::Position toQwtPlotAxisEnum( RiaDefines::PlotAxis riaPlotAxis );
|
static QwtAxis::Position toQwtPlotAxisEnum( RiaDefines::PlotAxis riaPlotAxis );
|
||||||
|
|
||||||
static RiaDefines::PlotAxis fromQwtPlotAxis( QwtAxis::Position );
|
static RiaDefines::PlotAxis fromQwtPlotAxis( QwtAxis::Position );
|
||||||
|
@ -1060,23 +1060,26 @@ QwtPlot* RiuQwtPlotWidget::qwtPlot() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis )
|
void RiuQwtPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis )
|
||||||
{
|
{
|
||||||
|
// Check if the axis already exists
|
||||||
auto it = m_axisMapping.find( axis );
|
auto it = m_axisMapping.find( axis );
|
||||||
if ( it != m_axisMapping.end() ) return;
|
if ( it != m_axisMapping.end() ) return;
|
||||||
|
|
||||||
// Need to create the axis
|
// Special handling for default axis (index == 0):
|
||||||
auto qwtAxisId = RiuQwtPlotTools::toQwtPlotAxis( axis );
|
// These are already created by qwt.
|
||||||
|
if ( axis.index() == 0 )
|
||||||
int requiredCount = axis.index() + 1;
|
|
||||||
int count = m_plot->axesCount( qwtAxisId.pos );
|
|
||||||
if ( requiredCount > count )
|
|
||||||
{
|
{
|
||||||
m_plot->setAxesCount( qwtAxisId.pos, requiredCount );
|
QwtAxisId newQwtAxis( RiuQwtPlotTools::toQwtPlotAxisEnum( axis.axis() ), 0 );
|
||||||
QwtAxisId newQwtAxis( qwtAxisId.pos, count );
|
|
||||||
m_axisMapping.insert( std::make_pair( axis, newQwtAxis ) );
|
m_axisMapping.insert( std::make_pair( axis, newQwtAxis ) );
|
||||||
}
|
}
|
||||||
else if ( axis.index() == 0 )
|
else
|
||||||
{
|
{
|
||||||
QwtAxisId newQwtAxis( qwtAxisId.pos, 0 );
|
auto qwtAxisId = RiuQwtPlotTools::toQwtPlotAxisEnum( axis.axis() );
|
||||||
|
|
||||||
|
int count = m_plot->axesCount( qwtAxisId );
|
||||||
|
int requiredCount = count + 1;
|
||||||
|
|
||||||
|
m_plot->setAxesCount( qwtAxisId, requiredCount );
|
||||||
|
QwtAxisId newQwtAxis( qwtAxisId, count );
|
||||||
m_axisMapping.insert( std::make_pair( axis, newQwtAxis ) );
|
m_axisMapping.insert( std::make_pair( axis, newQwtAxis ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,8 @@ public:
|
|||||||
|
|
||||||
std::pair<RiuPlotCurve*, int> findClosestCurve( const QPoint& pos, double& distanceToClick ) const override;
|
std::pair<RiuPlotCurve*, int> findClosestCurve( const QPoint& pos, double& distanceToClick ) const override;
|
||||||
|
|
||||||
|
QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void plotSelected( bool toggleSelection );
|
void plotSelected( bool toggleSelection );
|
||||||
void axisSelected( int axisId, bool toggleSelection );
|
void axisSelected( int axisId, bool toggleSelection );
|
||||||
@ -195,7 +197,6 @@ protected:
|
|||||||
virtual bool isZoomerActive() const;
|
virtual bool isZoomerActive() const;
|
||||||
virtual void endZoomOperations();
|
virtual void endZoomOperations();
|
||||||
|
|
||||||
QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const;
|
|
||||||
void setAxisScaleType( QwtAxisId axis, RiuQwtPlotWidget::AxisScaleType axisScaleType );
|
void setAxisScaleType( QwtAxisId axis, RiuQwtPlotWidget::AxisScaleType axisScaleType );
|
||||||
void setAxisScale( QwtAxisId axis, double min, double max );
|
void setAxisScale( QwtAxisId axis, double min, double max );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user