From bfb0cecacad74db3e6113b42992b580c13c4b192 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 24 Nov 2016 09:13:20 +0100 Subject: [PATCH] Summary : Fixed mixup of two different enums --- .../Summary/RimSummaryCurvesCalculator.cpp | 30 +++++++++---------- .../Summary/RimSummaryPlot.cpp | 4 +-- .../Summary/RimSummaryYAxisProperties.cpp | 12 +++++++- .../Summary/RimSummaryYAxisProperties.h | 5 ++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index 149b468380..047304e503 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -118,7 +118,7 @@ void RimSummaryPlotYAxisFormater::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot* QString axisTitle = m_axisProperties->customTitle; if (m_axisProperties->isAutoTitle) axisTitle = autoAxisTitle(); - QwtText axisTitleY = qwtPlot->axisTitle(m_axisProperties->axis()); + QwtText axisTitleY = qwtPlot->axisTitle(m_axisProperties->qwtPlotAxisType()); QFont axisTitleYFont = axisTitleY.font(); axisTitleYFont.setBold(true); @@ -137,28 +137,28 @@ void RimSummaryPlotYAxisFormater::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot* break; } - qwtPlot->setAxisTitle(m_axisProperties->axis(), axisTitleY); + qwtPlot->setAxisTitle(m_axisProperties->qwtPlotAxisType(), axisTitleY); } { - QFont yAxisFont = qwtPlot->axisFont(m_axisProperties->axis()); + QFont yAxisFont = qwtPlot->axisFont(m_axisProperties->qwtPlotAxisType()); yAxisFont.setBold(false); yAxisFont.setPixelSize(m_axisProperties->fontSize); - qwtPlot->setAxisFont(m_axisProperties->axis(), yAxisFont); + qwtPlot->setAxisFont(m_axisProperties->qwtPlotAxisType(), yAxisFont); } { if (m_axisProperties->numberFormat == RimSummaryYAxisProperties::NUMBER_FORMAT_AUTO) { - qwtPlot->setAxisScaleDraw(m_axisProperties->axis(), new QwtScaleDraw); + qwtPlot->setAxisScaleDraw(m_axisProperties->qwtPlotAxisType(), new QwtScaleDraw); } else if (m_axisProperties->numberFormat == RimSummaryYAxisProperties::NUMBER_FORMAT_DECIMAL) { - qwtPlot->setAxisScaleDraw(m_axisProperties->axis(), new DecimalScaleDraw); + qwtPlot->setAxisScaleDraw(m_axisProperties->qwtPlotAxisType(), new DecimalScaleDraw); } else if (m_axisProperties->numberFormat == RimSummaryYAxisProperties::NUMBER_FORMAT_SCIENTIFIC) { - qwtPlot->setAxisScaleDraw(m_axisProperties->axis(), new ScientificScaleDraw()); + qwtPlot->setAxisScaleDraw(m_axisProperties->qwtPlotAxisType(), new ScientificScaleDraw()); } } @@ -166,21 +166,21 @@ void RimSummaryPlotYAxisFormater::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot* { if (m_axisProperties->isLogarithmicScaleEnabled) { - QwtLogScaleEngine* currentScaleEngine = dynamic_cast(qwtPlot->axisScaleEngine(m_axisProperties->axis())); + QwtLogScaleEngine* currentScaleEngine = dynamic_cast(qwtPlot->axisScaleEngine(m_axisProperties->qwtPlotAxisType())); if (!currentScaleEngine) { - qwtPlot->setAxisScaleEngine(m_axisProperties->axis(), new QwtLogScaleEngine); - qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 5); + qwtPlot->setAxisScaleEngine(m_axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine); + qwtPlot->setAxisMaxMinor(m_axisProperties->qwtPlotAxisType(), 5); } } else { - QwtLinearScaleEngine* currentScaleEngine = dynamic_cast(qwtPlot->axisScaleEngine(m_axisProperties->axis())); + QwtLinearScaleEngine* currentScaleEngine = dynamic_cast(qwtPlot->axisScaleEngine(m_axisProperties->qwtPlotAxisType())); if (!currentScaleEngine) { - qwtPlot->setAxisScaleEngine(m_axisProperties->axis(), new QwtLinearScaleEngine); - qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 3); + qwtPlot->setAxisScaleEngine(m_axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine); + qwtPlot->setAxisMaxMinor(m_axisProperties->qwtPlotAxisType(), 3); } } } @@ -195,7 +195,7 @@ QString RimSummaryPlotYAxisFormater::autoAxisTitle() const for ( RimSummaryCurve* rimCurve : m_singleCurves ) { - if ( rimCurve->isCurveVisible() && rimCurve->yAxis() == this->m_axisProperties->axis() ) + if ( rimCurve->isCurveVisible() && rimCurve->yAxis() == this->m_axisProperties->plotAxisType() ) { unitToQuantityNameMap[rimCurve->unitName()].insert(rimCurve->summaryAddress().quantityName()); } @@ -209,7 +209,7 @@ QString RimSummaryPlotYAxisFormater::autoAxisTitle() const for ( RimSummaryCurve* rimCurve : curveFilterCurves ) { - if ( rimCurve->isCurveVisible() && rimCurve->yAxis() == this->m_axisProperties->axis() ) + if ( rimCurve->isCurveVisible() && rimCurve->yAxis() == this->m_axisProperties->plotAxisType() ) { unitToQuantityNameMap[rimCurve->unitName()].insert(rimCurve->summaryAddress().quantityName()); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index d05e26a016..57561354e5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -434,7 +434,7 @@ void RimSummaryPlot::zoomAll() RimSummaryPlotYAxisRangeCalculator calc(m_leftYAxisProperties, curves); calc.computeYRange(&min, &max); - m_qwtPlot->setAxisScale(m_leftYAxisProperties->axis(), min, max); + m_qwtPlot->setAxisScale(m_leftYAxisProperties->qwtPlotAxisType(), min, max); } else { @@ -449,7 +449,7 @@ void RimSummaryPlot::zoomAll() RimSummaryPlotYAxisRangeCalculator calc(m_rightYAxisProperties, curves); calc.computeYRange(&min, &max); - m_qwtPlot->setAxisScale(m_rightYAxisProperties->axis(), min, max); + m_qwtPlot->setAxisScale(m_rightYAxisProperties->qwtPlotAxisType(), min, max); } else { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.cpp index 8284fda476..af382360cf 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.cpp @@ -127,11 +127,21 @@ void RimSummaryYAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QwtPlot::Axis RimSummaryYAxisProperties::axis() const +QwtPlot::Axis RimSummaryYAxisProperties::qwtPlotAxisType() const { return m_axis; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimDefines::PlotAxis RimSummaryYAxisProperties::plotAxisType() const +{ + if (m_axis == QwtPlot::yRight) return RimDefines::PLOT_AXIS_RIGHT; + + return RimDefines::PLOT_AXIS_LEFT; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.h index b513659abb..d7c6a82736 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryYAxisProperties.h @@ -55,8 +55,9 @@ public: public: RimSummaryYAxisProperties(); - void setNameAndAxis(const QString& name, QwtPlot::Axis axis); - QwtPlot::Axis axis() const; + void setNameAndAxis(const QString& name, QwtPlot::Axis axis); + QwtPlot::Axis qwtPlotAxisType() const; + RimDefines::PlotAxis plotAxisType() const; caf::PdmField isAutoTitle; caf::PdmField customTitle;