#3098 Show depth axis only for left-most plot. They all share the same depth axis anyway.

This commit is contained in:
Gaute Lindkvist 2018-06-26 10:38:44 +02:00
parent f0bd7c726a
commit 405d470eda
5 changed files with 34 additions and 4 deletions

View File

@ -628,6 +628,16 @@ void RimWellLogTrack::setXAxisTitle(const QString& text)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogTrack::depthPlotTitle() const
{
RimWellLogPlot* parent;
this->firstAncestorOrThisOfTypeAsserted(parent);
return parent->depthPlotTitle();
}
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setFormationWellPath(RimWellPath* wellPath)

View File

@ -81,6 +81,7 @@ public:
size_t curveIndex(RimWellLogCurve* curve);
size_t curveCount() { return curves.size(); }
void setXAxisTitle(const QString& text);
QString depthPlotTitle() const;
void setFormationWellPath(RimWellPath* wellPath);
void setFormationSimWellName(const QString& simWellName);

View File

@ -319,6 +319,8 @@ void RiuWellLogPlot::placeChildWidgets(int height, int width)
int trackCount = m_trackPlots.size();
CVF_ASSERT(m_legends.size() == trackCount);
const int trackPadding = 4;
int visibleTrackCount = 0;
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
{
@ -366,9 +368,8 @@ void RiuWellLogPlot::placeChildWidgets(int height, int width)
realTrackWidth += 1;
--trackWidthExtra;
}
int realLegendWidth = std::max(realTrackWidth, m_legends[tIdx]->sizeHint().width());
m_legends[tIdx]->setGeometry(trackX, titleHeight, realLegendWidth, maxLegendHeight);
m_trackPlots[tIdx]->setGeometry(trackX, titleHeight + maxLegendHeight, realTrackWidth, trackHeight);
m_legends[tIdx]->setGeometry(trackX + trackPadding, titleHeight, realTrackWidth - 2 * trackPadding, maxLegendHeight);
m_trackPlots[tIdx]->setGeometry(trackX + trackPadding, titleHeight + maxLegendHeight, realTrackWidth - 2 * trackPadding, trackHeight);
trackX += realTrackWidth;
}
@ -398,16 +399,19 @@ void RiuWellLogPlot::updateChildrenLayout()
int trackCount = m_trackPlots.size();
int numTracksAlreadyShown = 0;
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
{
if (m_trackPlots[tIdx]->isVisible())
{
m_legends[tIdx]->show();
m_trackPlots[tIdx]->enableVerticalAxisLabelsAndTitle(numTracksAlreadyShown == 0);
numTracksAlreadyShown++;
}
else
{
m_legends[tIdx]->hide();
}
}
}
placeChildWidgets(this->height(), this->width());

View File

@ -261,3 +261,17 @@ bool RiuWellLogTrack::isRimTrackVisible()
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::enableVerticalAxisLabelsAndTitle(bool enable)
{
QString depthAxisTitle("");
if (enable && m_plotTrackDefinition)
{
depthAxisTitle = m_plotTrackDefinition->depthPlotTitle();
}
this->setAxisTitle(QwtPlot::yLeft, depthAxisTitle);
this->axisScaleDraw(QwtPlot::yLeft)->enableComponent(
QwtAbstractScaleDraw::Labels, enable);
}

View File

@ -52,6 +52,7 @@ public:
void setXRange(double min, double max);
bool isRimTrackVisible();
void enableVerticalAxisLabelsAndTitle(bool enable);
protected:
virtual bool eventFilter(QObject* watched, QEvent* event);