mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge branch 'dev' into annotation-items
This commit is contained in:
@@ -269,7 +269,7 @@ void RimGridCrossPlot::detachAllCurves()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateAxisScaling()
|
||||
{
|
||||
updateAxisDisplay();
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -383,13 +383,11 @@ void RimGridCrossPlot::onLoadDataAndUpdate()
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
curveSet->loadDataAndUpdate(false);
|
||||
curveSet->updateConnectedEditors();
|
||||
}
|
||||
|
||||
updateCurveNamesAndPlotTitle();
|
||||
updateAllRequiredEditors();
|
||||
|
||||
updatePlot();
|
||||
|
||||
updatePlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -525,13 +523,29 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::swapAllAxisProperties()
|
||||
void RimGridCrossPlot::swapAxes()
|
||||
{
|
||||
RimPlotAxisProperties* xAxisProperties = m_xAxisProperties();
|
||||
RimPlotAxisProperties* yAxisProperties = m_yAxisProperties();
|
||||
|
||||
QString tmpName = xAxisProperties->name();
|
||||
QwtPlot::Axis tmpAxis = xAxisProperties->qwtPlotAxisType();
|
||||
xAxisProperties->setNameAndAxis(yAxisProperties->name(), yAxisProperties->qwtPlotAxisType());
|
||||
yAxisProperties->setNameAndAxis(tmpName, tmpAxis);
|
||||
|
||||
m_xAxisProperties.removeChildObject(xAxisProperties);
|
||||
m_yAxisProperties.removeChildObject(yAxisProperties);
|
||||
m_yAxisProperties = xAxisProperties;
|
||||
m_xAxisProperties = yAxisProperties;
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
curveSet->swapAxisProperties(false);
|
||||
}
|
||||
|
||||
loadDataAndUpdate();
|
||||
|
||||
updateAxisDisplay();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -562,7 +576,6 @@ QString RimGridCrossPlot::asciiDataForPlotExport(int curveSetIndex) const
|
||||
formatter.setTableRowLineAppendText("");
|
||||
formatter.setColumnSpacing(3);
|
||||
|
||||
|
||||
m_crossPlotCurveSets[curveSetIndex]->exportFormattedData(formatter);
|
||||
formatter.tableCompleted();
|
||||
return asciiData;
|
||||
@@ -581,6 +594,22 @@ RiuGridCrossQwtPlot* RimGridCrossPlot::qwtPlot() const
|
||||
return m_qwtPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlot::isXAxisLogarithmic() const
|
||||
{
|
||||
return m_xAxisProperties->isLogarithmicScaleEnabled();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlot::isYAxisLogarithmic() const
|
||||
{
|
||||
return m_yAxisProperties->isLogarithmicScaleEnabled();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -676,6 +705,25 @@ void RimGridCrossPlot::updateAxisInQwt(RiaDefines::PlotAxis axisType)
|
||||
m_qwtPlot->setAxisScaleEngine(axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(axisProperties->qwtPlotAxisType(), 5);
|
||||
}
|
||||
|
||||
if (axisProperties->isAutoZoom())
|
||||
{
|
||||
std::vector<const QwtPlotCurve*> plotCurves = visibleQwtCurves();
|
||||
|
||||
double min, max;
|
||||
RimPlotAxisLogRangeCalculator logRangeCalculator(qwtAxisId, plotCurves);
|
||||
logRangeCalculator.computeAxisRange(&min, &max);
|
||||
if (axisProperties->isAxisInverted())
|
||||
{
|
||||
std::swap(min, max);
|
||||
}
|
||||
|
||||
m_qwtPlot->setAxisScale(qwtAxisId, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisScale(qwtAxisId, axisProperties->visibleRangeMin, axisProperties->visibleRangeMax);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -686,19 +734,17 @@ void RimGridCrossPlot::updateAxisInQwt(RiaDefines::PlotAxis axisType)
|
||||
m_qwtPlot->setAxisScaleEngine(axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(axisProperties->qwtPlotAxisType(), 3);
|
||||
}
|
||||
|
||||
if (axisProperties->isAutoZoom())
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(qwtAxisId);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisScale(qwtAxisId, axisProperties->visibleRangeMin, axisProperties->visibleRangeMax);
|
||||
}
|
||||
}
|
||||
m_qwtPlot->axisScaleEngine(axisProperties->qwtPlotAxisType())->setAttribute(QwtScaleEngine::Inverted, axisProperties->isAxisInverted());
|
||||
|
||||
if (axisProperties->isAutoZoom())
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(qwtAxisId);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisScale(qwtAxisId, axisProperties->visibleRangeMin, axisProperties->visibleRangeMax);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -731,6 +777,28 @@ void RimGridCrossPlot::updateAxisFromQwt(RiaDefines::PlotAxis axisType)
|
||||
axisProperties->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<const QwtPlotCurve*> RimGridCrossPlot::visibleQwtCurves() const
|
||||
{
|
||||
std::vector<const QwtPlotCurve*> plotCurves;
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
if (curveSet->isChecked())
|
||||
{
|
||||
for (auto curve : curveSet->curves())
|
||||
{
|
||||
if (curve->isCurveVisible())
|
||||
{
|
||||
plotCurves.push_back(curve->qwtPlotCurve());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return plotCurves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Name Configuration
|
||||
///
|
||||
|
||||
@@ -70,10 +70,12 @@ public:
|
||||
void detachAllCurves();
|
||||
void performAutoNameUpdate() override;
|
||||
void updateCurveNamesAndPlotTitle();
|
||||
void swapAllAxisProperties();
|
||||
void swapAxes();
|
||||
QString asciiTitleForPlotExport(int curveSetIndex) const;
|
||||
QString asciiDataForPlotExport(int curveSetIndex) const;
|
||||
RiuGridCrossQwtPlot* qwtPlot() const;
|
||||
bool isXAxisLogarithmic() const;
|
||||
bool isYAxisLogarithmic() const;
|
||||
|
||||
public:
|
||||
// Rim2dPlotInterface overrides
|
||||
@@ -96,13 +98,13 @@ protected:
|
||||
bool* useOptionsOnly) override;
|
||||
|
||||
void updatePlot();
|
||||
void updateCurveNames();
|
||||
|
||||
QString xAxisParameterString() const;
|
||||
QString yAxisParameterString() const;
|
||||
|
||||
void updateAxisInQwt(RiaDefines::PlotAxis axisType);
|
||||
void updateAxisFromQwt(RiaDefines::PlotAxis axisType);
|
||||
std::vector<const QwtPlotCurve*> visibleQwtCurves() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
@@ -115,7 +117,7 @@ private:
|
||||
caf::PdmChildArrayField<RimGridCrossPlotCurveSet*> m_crossPlotCurveSets;
|
||||
|
||||
QPointer<RiuGridCrossQwtPlot> m_qwtPlot;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -406,6 +406,10 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
RigEclipseCrossPlotResult result = RigEclipseCrossPlotDataExtractor::extract(
|
||||
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_grouping(), groupAddress, timeStepCellVisibilityMap);
|
||||
|
||||
if (isXAxisLogarithmic() || isYAxisLogarithmic())
|
||||
{
|
||||
filterInvalidCurveValues(&result);
|
||||
}
|
||||
createCurves(result);
|
||||
|
||||
if (updateParentPlot)
|
||||
@@ -877,6 +881,26 @@ void RimGridCrossPlotCurveSet::exportFormattedData(RifEclipseDataTableFormatter&
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlotCurveSet::isXAxisLogarithmic() const
|
||||
{
|
||||
RimGridCrossPlot* parent = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(parent);
|
||||
return parent->isXAxisLogarithmic();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlotCurveSet::isYAxisLogarithmic() const
|
||||
{
|
||||
RimGridCrossPlot* parent = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(parent);
|
||||
return parent->isYAxisLogarithmic();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1001,6 +1025,42 @@ bool RimGridCrossPlotCurveSet::hasMultipleTimeSteps() const
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::filterInvalidCurveValues(RigEclipseCrossPlotResult* result)
|
||||
{
|
||||
bool xLog = isXAxisLogarithmic();
|
||||
bool yLog = isYAxisLogarithmic();
|
||||
|
||||
if (xLog || yLog)
|
||||
{
|
||||
|
||||
RigEclipseCrossPlotResult validResult;
|
||||
for (size_t i = 0; i < result->xValues.size(); ++i)
|
||||
{
|
||||
double xValue = result->xValues[i];
|
||||
double yValue = result->yValues[i];
|
||||
bool invalid = (xLog && xValue <= 0.0) || (yLog && yValue <= 0.0);
|
||||
if (!invalid)
|
||||
{
|
||||
validResult.xValues.push_back(xValue);
|
||||
validResult.yValues.push_back(yValue);
|
||||
if (i < result->groupValuesContinuous.size())
|
||||
{
|
||||
validResult.groupValuesContinuous.push_back(result->groupValuesContinuous[i]);
|
||||
}
|
||||
if (i < result->groupValuesDiscrete.size())
|
||||
{
|
||||
validResult.groupValuesDiscrete.push_back(result->groupValuesDiscrete[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*result = validResult;
|
||||
}
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSetNameConfig, "RimGridCrossPlotCurveSetNameConfig");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -117,6 +117,9 @@ public:
|
||||
void swapAxisProperties(bool updatePlot);
|
||||
void exportFormattedData(RifEclipseDataTableFormatter& formatter) const;
|
||||
|
||||
bool isXAxisLogarithmic() const;
|
||||
bool isYAxisLogarithmic() const;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
void onLoadDataAndUpdate(bool updateParentPlot);
|
||||
@@ -139,6 +142,7 @@ protected:
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
|
||||
bool hasMultipleTimeSteps() const;
|
||||
void filterInvalidCurveValues(RigEclipseCrossPlotResult* result);
|
||||
private:
|
||||
|
||||
caf::PdmPtrField<RimCase*> m_case;
|
||||
@@ -154,4 +158,5 @@ private:
|
||||
caf::PdmChildArrayField<RimGridCrossPlotCurve*> m_crossPlotCurves;
|
||||
|
||||
std::map<int, RigEclipseCrossPlotResult> m_groupedResults;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user