#3337 Make sure well log plots maintain legend order if you hide and show items.

This commit is contained in:
Gaute Lindkvist 2018-09-07 13:39:50 +02:00
parent bdcdf49269
commit 612409ac59
8 changed files with 83 additions and 16 deletions

View File

@ -323,6 +323,18 @@ void RimPlotCurve::detachQwtCurve()
m_qwtPlotCurve->detach();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::reattachQwtCurve()
{
detachQwtCurve();
if (m_parentQwtPlot && m_showCurve)
{
m_qwtPlotCurve->attach(m_parentQwtPlot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -405,6 +417,17 @@ void RimPlotCurve::updatePlotTitle()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateLegendsInPlot()
{
if (m_parentQwtPlot != nullptr)
{
m_parentQwtPlot->updateLegend();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -641,11 +664,7 @@ void RimPlotCurve::setZOrder(double z)
void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend()
{
updateLegendEntryVisibilityNoPlotUpdate();
if (m_parentQwtPlot != nullptr)
{
m_parentQwtPlot->updateLegend();
}
updateLegendsInPlot();
}
//--------------------------------------------------------------------------------------------------

View File

@ -54,6 +54,7 @@ public:
void setParentQwtPlotAndReplot(QwtPlot* plot);
void setParentQwtPlotNoReplot(QwtPlot* plot);
void detachQwtCurve();
void reattachQwtCurve();
QwtPlotCurve* qwtPlotCurve() const;
void setColor(const cvf::Color3f& color);
@ -97,7 +98,7 @@ protected:
void updateOptionSensitivity();
void updatePlotTitle();
virtual void updateLegendsInPlot();
protected:
// Overridden PDM methods
@ -110,7 +111,7 @@ protected:
protected:
QPointer<QwtPlot> m_parentQwtPlot;
RiuQwtPlotCurve* m_qwtPlotCurve;
RiuQwtPlotCurve* m_qwtPlotCurve;
caf::PdmField<bool> m_showCurve;
caf::PdmField<QString> m_curveName;
@ -128,7 +129,7 @@ protected:
caf::PdmField<PointSymbol> m_pointSymbol;
caf::PdmField<LineStyle> m_lineStyle;
caf::PdmField<CurveInterpolation> m_curveInterpolation;
RiuQwtSymbol::LabelPosition m_symbolLabelPosition;
RiuQwtSymbol::LabelPosition m_symbolLabelPosition;
};

View File

@ -72,6 +72,15 @@ bool RimWellLogCurve::valueRange(double* minimumValue, double* maximumValue) con
return xValueRange(minimumValue, maximumValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigWellLogCurveData* RimWellLogCurve::curveData() const
{
return m_curveData.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -95,9 +104,14 @@ void RimWellLogCurve::updateZoomInParentPlot()
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const RigWellLogCurveData* RimWellLogCurve::curveData() const
void RimWellLogCurve::updateLegendsInPlot()
{
return m_curveData.p();
RimWellLogTrack* wellLogTrack;
firstAncestorOrThisOfType(wellLogTrack);
if (wellLogTrack)
{
wellLogTrack->updateAllLegendItems();
}
}

View File

@ -49,5 +49,8 @@ public:
protected:
virtual void updateZoomInParentPlot() override;
cvf::ref<RigWellLogCurveData> m_curveData;
virtual void updateLegendsInPlot() override;
protected:
cvf::ref<RigWellLogCurveData> m_curveData;
};

View File

@ -73,7 +73,6 @@ namespace caf {
CAF_PDM_SOURCE_INIT(RimWellLogPlot, "WellLogPlot");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -141,7 +141,6 @@ protected:
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
virtual void initAfterRead() override;
private:

View File

@ -518,6 +518,15 @@ void RimWellLogTrack::updateAxisAndGridTickIntervals()
m_wellLogTrackPlotWidget->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateAllLegendItems()
{
reattachAllCurves();
m_wellLogTrackPlotWidget->updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -743,6 +752,8 @@ void RimWellLogTrack::loadDataAndUpdate()
bool emptyRange = std::abs(m_visibleXRangeMax() - m_visibleXRangeMin) < 1.0e-6 * std::max(1.0, std::max(m_visibleXRangeMax(), m_visibleXRangeMin()));
m_explicitTickIntervals.uiCapability()->setUiReadOnly(emptyRange);
m_xAxisGridVisibility.uiCapability()->setUiReadOnly(emptyRange);
updateAllLegendItems();
}
//--------------------------------------------------------------------------------------------------
@ -916,9 +927,28 @@ void RimWellLogTrack::recreateViewer()
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::detachAllCurves()
{
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
for (RimPlotCurve* curve : curves)
{
curves[cIdx]->detachQwtCurve();
curve->detachQwtCurve();
}
for (RimPlotCurve* curve : m_wellPathAttributeCurves)
{
curve->detachQwtCurve();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::reattachAllCurves()
{
for (RimPlotCurve* curve : curves)
{
curve->reattachQwtCurve();
}
for (RimPlotCurve* curve : m_wellPathAttributeCurves)
{
curve->reattachQwtCurve();
}
}

View File

@ -98,6 +98,7 @@ public:
void recreateViewer();
void detachAllCurves();
void reattachAllCurves();
void loadDataAndUpdate();
@ -141,6 +142,7 @@ public:
void setFormationsForCaseWithSimWellOnly(bool caseWithSimWellOnly);
void updateAxisAndGridTickIntervals();
void updateAllLegendItems();
private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
void updateParentPlotLayout();