mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 15:36:09 -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 );
|
||||
if ( qwtPlotWidget )
|
||||
{
|
||||
auto qwtAxisId = RiuQwtPlotTools::toQwtPlotAxis( axis );
|
||||
auto qwtAxisId = qwtPlotWidget->toQwtPlotAxis( axis );
|
||||
|
||||
if ( m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_AUTO &&
|
||||
m_axisProperties->scaleFactor() == 1.0 )
|
||||
|
@ -308,12 +308,14 @@ QSize RiuQwtPlotCurve::legendIconSize() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotCurve::attachToPlot( RiuPlotWidget* plotWidget )
|
||||
{
|
||||
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
||||
attach( qwtPlotWidget->qwtPlot() );
|
||||
m_plotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
||||
CAF_ASSERT( m_plotWidget );
|
||||
|
||||
attach( m_plotWidget->qwtPlot() );
|
||||
|
||||
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 )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
QwtPlotCurve::setYAxis( RiuQwtPlotTools::toQwtPlotAxis( axis ) );
|
||||
if ( m_plotWidget ) QwtPlotCurve::setYAxis( m_plotWidget->toQwtPlotAxis( axis ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
class QwtPlotIntervalCurve;
|
||||
class RiuQwtPlotWidget;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -101,4 +102,6 @@ protected:
|
||||
|
||||
QwtPlotIntervalCurve* m_qwtCurveErrorBars;
|
||||
bool m_showErrorBars;
|
||||
|
||||
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||
};
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "RiuQtChartsPlotCurveSymbol.h"
|
||||
#include "RiuQwtPlotLegend.h"
|
||||
|
||||
#include "qwt_axis.h"
|
||||
#include "qwt_date_scale_draw.h"
|
||||
#include "qwt_date_scale_engine.h"
|
||||
#include "qwt_graphic.h"
|
||||
@ -39,9 +40,6 @@
|
||||
#include "qwt_plot_shapeitem.h"
|
||||
#include "qwt_scale_widget.h"
|
||||
|
||||
#include "qwt_axis.h"
|
||||
#include <QRegExp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -245,16 +243,6 @@ QwtPlotShapeItem* RiuQwtPlotTools::createBoxShape( const QString& label,
|
||||
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,11 +65,9 @@ public:
|
||||
QColor color,
|
||||
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
||||
|
||||
|
||||
static void updateLegendData( RiuQwtPlotLegend* legend, 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 );
|
||||
};
|
||||
|
@ -1060,23 +1060,26 @@ QwtPlot* RiuQwtPlotWidget::qwtPlot() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis )
|
||||
{
|
||||
// Check if the axis already exists
|
||||
auto it = m_axisMapping.find( axis );
|
||||
if ( it != m_axisMapping.end() ) return;
|
||||
|
||||
// Need to create the axis
|
||||
auto qwtAxisId = RiuQwtPlotTools::toQwtPlotAxis( axis );
|
||||
|
||||
int requiredCount = axis.index() + 1;
|
||||
int count = m_plot->axesCount( qwtAxisId.pos );
|
||||
if ( requiredCount > count )
|
||||
// Special handling for default axis (index == 0):
|
||||
// These are already created by qwt.
|
||||
if ( axis.index() == 0 )
|
||||
{
|
||||
m_plot->setAxesCount( qwtAxisId.pos, requiredCount );
|
||||
QwtAxisId newQwtAxis( qwtAxisId.pos, count );
|
||||
QwtAxisId newQwtAxis( RiuQwtPlotTools::toQwtPlotAxisEnum( axis.axis() ), 0 );
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,8 @@ public:
|
||||
|
||||
std::pair<RiuPlotCurve*, int> findClosestCurve( const QPoint& pos, double& distanceToClick ) const override;
|
||||
|
||||
QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const;
|
||||
|
||||
signals:
|
||||
void plotSelected( bool toggleSelection );
|
||||
void axisSelected( int axisId, bool toggleSelection );
|
||||
@ -195,9 +197,8 @@ protected:
|
||||
virtual bool isZoomerActive() const;
|
||||
virtual void endZoomOperations();
|
||||
|
||||
QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const;
|
||||
void setAxisScaleType( QwtAxisId axis, RiuQwtPlotWidget::AxisScaleType axisScaleType );
|
||||
void setAxisScale( QwtAxisId axis, double min, double max );
|
||||
void setAxisScaleType( QwtAxisId axis, RiuQwtPlotWidget::AxisScaleType axisScaleType );
|
||||
void setAxisScale( QwtAxisId axis, double min, double max );
|
||||
|
||||
private:
|
||||
void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false );
|
||||
|
Loading…
Reference in New Issue
Block a user