mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#779 Summary : Added display and axis control of log scale
This commit is contained in:
@@ -106,6 +106,15 @@ RimSummaryCurvesCalculator::RimSummaryCurvesCalculator(RimSummaryYAxisProperties
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurvesCalculator::RimSummaryCurvesCalculator(RimSummaryYAxisProperties* axisProperties, const std::vector<RimSummaryCurve*>& curves)
|
||||
: m_axisProperties(axisProperties),
|
||||
m_singleCurves(curves)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -151,7 +160,6 @@ void RimSummaryCurvesCalculator::applyPropertiesToPlot(RiuSummaryQwtPlot* m_qwtP
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
if (m_axisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
@@ -159,9 +167,9 @@ void RimSummaryCurvesCalculator::applyPropertiesToPlot(RiuSummaryQwtPlot* m_qwtP
|
||||
if (!currentScaleEngine)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleEngine(m_axisProperties->axis(), new QwtLogScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 5);
|
||||
}
|
||||
|
||||
m_qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,32 +177,10 @@ void RimSummaryCurvesCalculator::applyPropertiesToPlot(RiuSummaryQwtPlot* m_qwtP
|
||||
if (!currentScaleEngine)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleEngine(m_axisProperties->axis(), new QwtLinearScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 3);
|
||||
}
|
||||
|
||||
m_qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 3);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
m_qwtPlot->setAxisScale(m_axisProperties->axis(), m_axisProperties->visibleRangeMin, m_axisProperties->visibleRangeMax);
|
||||
|
||||
/*
|
||||
{
|
||||
if (m_axisProperties->isAutoScaleEnabled)
|
||||
{
|
||||
double min = HUGE_VAL;
|
||||
double max = -HUGE_VAL;
|
||||
|
||||
computeYRange(&min, &max);
|
||||
|
||||
m_qwtPlot->setAxisScale(m_axisProperties->axis(), min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisScale(m_axisProperties->axis(), m_axisProperties->visibleRangeMin, m_axisProperties->visibleRangeMax);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -36,11 +36,14 @@ public:
|
||||
const std::vector<RimSummaryCurve*>& curves,
|
||||
const std::vector<RimSummaryCurveFilter*>& curveFilters);
|
||||
|
||||
void applyPropertiesToPlot(RiuSummaryQwtPlot* qwtPlot);
|
||||
RimSummaryCurvesCalculator(RimSummaryYAxisProperties* axisProperties,
|
||||
const std::vector<RimSummaryCurve*>& curves);
|
||||
|
||||
void applyPropertiesToPlot(RiuSummaryQwtPlot* qwtPlot);
|
||||
void computeYRange(double* min, double* max) const;
|
||||
|
||||
private:
|
||||
QString autoAxisTitle() const;
|
||||
void computeYRange(double* min, double* max) const;
|
||||
bool curveValueRangeY(const QwtPlotCurve* qwtCurve, double* min, double* max) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -132,20 +132,9 @@ void RimSummaryPlot::updateAxis(RimDefines::PlotAxis plotAxis)
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
std::vector<RimSummaryCurve*> curvesForAxis;
|
||||
std::vector<RimSummaryCurve*> curves = curvesForAxis(plotAxis);
|
||||
|
||||
std::vector<RimSummaryCurveFilter*> curveFiltersForAxis;
|
||||
|
||||
std::vector<RimSummaryCurve*> childCurves;
|
||||
this->descendantsIncludingThisOfType(childCurves);
|
||||
|
||||
for (RimSummaryCurve* curve : childCurves)
|
||||
{
|
||||
if (curve->associatedPlotAxis() == plotAxis)
|
||||
{
|
||||
curvesForAxis.push_back(curve);
|
||||
}
|
||||
}
|
||||
|
||||
for (RimSummaryCurveFilter* cs : m_curveFilters)
|
||||
{
|
||||
if (cs->associatedPlotAxis() == plotAxis)
|
||||
@@ -167,11 +156,11 @@ void RimSummaryPlot::updateAxis(RimDefines::PlotAxis plotAxis)
|
||||
yAxisProperties = m_rightYAxisProperties();
|
||||
}
|
||||
|
||||
if (curvesForAxis.size() > 0)
|
||||
if (curves.size() > 0)
|
||||
{
|
||||
m_qwtPlot->enableAxis(qwtAxis, true);
|
||||
|
||||
RimSummaryCurvesCalculator calc(yAxisProperties, curvesForAxis, curveFiltersForAxis);
|
||||
RimSummaryCurvesCalculator calc(yAxisProperties, curves, curveFiltersForAxis);
|
||||
calc.applyPropertiesToPlot(m_qwtPlot);
|
||||
}
|
||||
else
|
||||
@@ -180,6 +169,27 @@ void RimSummaryPlot::updateAxis(RimDefines::PlotAxis plotAxis)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCurve*> RimSummaryPlot::curvesForAxis(RimDefines::PlotAxis plotAxis) const
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves;
|
||||
|
||||
std::vector<RimSummaryCurve*> childCurves;
|
||||
this->descendantsIncludingThisOfType(childCurves);
|
||||
|
||||
for (RimSummaryCurve* curve : childCurves)
|
||||
{
|
||||
if (curve->associatedPlotAxis() == plotAxis)
|
||||
{
|
||||
curves.push_back(curve);
|
||||
}
|
||||
}
|
||||
|
||||
return curves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -247,7 +257,40 @@ void RimSummaryPlot::zoomAll()
|
||||
{
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->zoomAll();
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true);
|
||||
|
||||
if (m_leftYAxisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves = curvesForAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
|
||||
double min, max;
|
||||
RimSummaryCurvesCalculator calc(m_leftYAxisProperties, curves);
|
||||
calc.computeYRange(&min, &max);
|
||||
|
||||
m_qwtPlot->setAxisScale(m_leftYAxisProperties->axis(), min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::yLeft, true);
|
||||
}
|
||||
|
||||
if (m_rightYAxisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves = curvesForAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
|
||||
double min, max;
|
||||
RimSummaryCurvesCalculator calc(m_rightYAxisProperties, curves);
|
||||
calc.computeYRange(&min, &max);
|
||||
|
||||
m_qwtPlot->setAxisScale(m_rightYAxisProperties->axis(), min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::yRight, true);
|
||||
}
|
||||
|
||||
m_qwtPlot->replot();
|
||||
|
||||
this->setZoomWindow(m_qwtPlot->currentVisibleWindow());
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ private:
|
||||
void deletePlotWidget();
|
||||
|
||||
void updateAxis(RimDefines::PlotAxis plotAxis);
|
||||
std::vector<RimSummaryCurve*> curvesForAxis(RimDefines::PlotAxis plotAxis) const;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
|
||||
@@ -57,7 +57,6 @@ RimSummaryYAxisProperties::RimSummaryYAxisProperties()
|
||||
CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", "");
|
||||
isLogarithmicScaleEnabled.uiCapability()->setUiHidden(true);
|
||||
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
@@ -139,7 +138,14 @@ void RimSummaryYAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chan
|
||||
rimSummaryPlot->disableAutoZoom();
|
||||
}
|
||||
|
||||
rimSummaryPlot->updateAxes();
|
||||
if (changedField == &isLogarithmicScaleEnabled)
|
||||
{
|
||||
rimSummaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
rimSummaryPlot->updateAxes();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user