mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-04 04:30:51 -06:00
#3102 Well Log Plots: optionally align legend horizontally.
This commit is contained in:
parent
e4288972de
commit
ea2b64ef08
@ -81,6 +81,7 @@ RimWellLogPlot::RimWellLogPlot()
|
||||
m_isAutoScaleDepthEnabled.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitField(&m_showTitleInPlot, "ShowTitleInPlot", true, "Show Title in Plot", "", "", "");
|
||||
CAF_PDM_InitField(&m_showTrackLegends, "ShowTrackLegends", true, "Show Legends", "", "", "");
|
||||
CAF_PDM_InitField(&m_trackLegendsHorizontal, "TrackLegendsHorizontal", false, "Horizontal Legends", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_tracks, "Tracks", "", "", "", "");
|
||||
m_tracks.uiCapability()->setUiHidden(true);
|
||||
@ -115,7 +116,8 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
m_isAutoScaleDepthEnabled = false;
|
||||
}
|
||||
else if (changedField == &m_showTitleInPlot ||
|
||||
changedField == &m_showTrackLegends)
|
||||
changedField == &m_showTrackLegends ||
|
||||
changedField == &m_trackLegendsHorizontal)
|
||||
{
|
||||
updateTracks();
|
||||
if (m_viewer) m_viewer->updateChildrenLayout();
|
||||
@ -585,6 +587,7 @@ void RimWellLogPlot::uiOrderingForPlot(caf::PdmUiOrdering& uiOrdering)
|
||||
|
||||
uiOrdering.add(&m_showTitleInPlot);
|
||||
uiOrdering.add(&m_showTrackLegends);
|
||||
uiOrdering.add(&m_trackLegendsHorizontal);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -846,7 +849,7 @@ bool RimWellLogPlot::isPlotTitleVisible() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogPlot::isTrackLegendsVisible() const
|
||||
bool RimWellLogPlot::areTrackLegendsVisible() const
|
||||
{
|
||||
return m_showTrackLegends();
|
||||
}
|
||||
@ -859,6 +862,14 @@ void RimWellLogPlot::setTrackLegendsVisible(bool doShow)
|
||||
m_showTrackLegends = doShow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogPlot::areTrackLegendsHorizontal() const
|
||||
{
|
||||
return m_trackLegendsHorizontal;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -71,8 +71,9 @@ public:
|
||||
|
||||
QString depthPlotTitle() const;
|
||||
bool isPlotTitleVisible() const;
|
||||
bool isTrackLegendsVisible() const;
|
||||
bool areTrackLegendsVisible() const;
|
||||
void setTrackLegendsVisible(bool doShow);
|
||||
bool areTrackLegendsHorizontal() const;
|
||||
|
||||
void addTrack(RimWellLogTrack* track);
|
||||
void insertTrack(RimWellLogTrack* track, size_t index);
|
||||
@ -153,6 +154,7 @@ private:
|
||||
caf::PdmField<bool> m_isAutoScaleDepthEnabled;
|
||||
caf::PdmField<bool> m_showTitleInPlot;
|
||||
caf::PdmField<bool> m_showTrackLegends;
|
||||
caf::PdmField<bool> m_trackLegendsHorizontal;
|
||||
|
||||
double m_minAvailableDepth;
|
||||
double m_maxAvailableDepth;
|
||||
|
@ -104,14 +104,19 @@ void RiuWellLogPlot::insertTrackPlot(RiuWellLogTrack* trackPlot, size_t index)
|
||||
m_trackPlots.insert(static_cast<int>(index), trackPlot);
|
||||
|
||||
QwtLegend* legend = new QwtLegend(this);
|
||||
legend->setMaxColumns(1);
|
||||
int legendColumns = 1;
|
||||
if (m_plotDefinition->areTrackLegendsHorizontal())
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
legend->setMaxColumns(legendColumns);
|
||||
legend->connect(trackPlot, SIGNAL(legendDataChanged(const QVariant &, const QList< QwtLegendData > &)), SLOT(updateLegend(const QVariant &, const QList< QwtLegendData > &)));
|
||||
legend->contentsWidget()->layout()->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||
m_legends.insert(static_cast<int>(index), legend);
|
||||
|
||||
this->connect(trackPlot, SIGNAL(legendDataChanged(const QVariant &, const QList< QwtLegendData > &)), SLOT(scheduleUpdateChildrenLayout()));
|
||||
|
||||
if (!m_plotDefinition->isTrackLegendsVisible())
|
||||
if (!m_plotDefinition->areTrackLegendsVisible())
|
||||
{
|
||||
legend->hide();
|
||||
}
|
||||
@ -377,13 +382,13 @@ void RiuWellLogPlot::placeChildWidgets(int height, int width)
|
||||
|
||||
int maxLegendHeight = 0;
|
||||
|
||||
if (m_plotDefinition && m_plotDefinition->isTrackLegendsVisible())
|
||||
if (m_plotDefinition && m_plotDefinition->areTrackLegendsVisible())
|
||||
{
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
int legendHeight = m_legends[tIdx]->sizeHint().height();
|
||||
int legendHeight = m_legends[tIdx]->heightForWidth(trackWidths[tIdx] - 2 * trackPadding);
|
||||
if ( legendHeight > maxLegendHeight ) maxLegendHeight = legendHeight;
|
||||
}
|
||||
}
|
||||
@ -469,9 +474,16 @@ void RiuWellLogPlot::updateChildrenLayout()
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible())
|
||||
{
|
||||
m_legends[tIdx]->show();
|
||||
m_trackPlots[tIdx]->enableVerticalAxisLabelsAndTitle(numTracksAlreadyShown == 0);
|
||||
numTracksAlreadyShown++;
|
||||
int legendColumns = 1;
|
||||
if (m_plotDefinition->areTrackLegendsHorizontal())
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
m_legends[tIdx]->setMaxColumns(legendColumns);
|
||||
m_legends[tIdx]->show();
|
||||
|
||||
m_trackPlots[tIdx]->enableVerticalAxisLabelsAndTitle(numTracksAlreadyShown == 0);
|
||||
numTracksAlreadyShown++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user