#4166 Add feature for swapping cross plot axes + tweaks to legend

* Also put x and y property side by side in property editor
This commit is contained in:
Gaute Lindkvist
2019-03-08 09:59:29 +01:00
parent 1e777eaea0
commit e00f983360
16 changed files with 210 additions and 35 deletions

View File

@@ -83,6 +83,41 @@ void RiuGridCrossQwtPlot::removeCurveSetLegend(RimGridCrossPlotCurveSet* curveSe
this->updateLegendLayout();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot()
{
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
if (!crossPlot) return;
bool anyLegendResized = false;
for (RimGridCrossPlotCurveSet* curveSet : crossPlot->curveSets())
{
if (!curveSet->isChecked() || !curveSet->legendConfig()->showLegend()) continue;
auto pairIt = m_legendWidgets.find(curveSet);
if (pairIt != m_legendWidgets.end())
{
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
if (overlayWidget->isVisible())
{
caf::TitledOverlayFrame* overlayItem = curveSet->legendConfig()->titledOverlayFrame();
if (resizeOverlayItemToFitPlot(overlayItem))
{
anyLegendResized = true;
overlayWidget->updateFromOverlayItem(overlayItem);
}
}
}
}
if (anyLegendResized)
{
updateLegendLayout();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -146,35 +181,7 @@ void RiuGridCrossQwtPlot::updateLegendLayout()
void RiuGridCrossQwtPlot::resizeEvent(QResizeEvent* e)
{
QwtPlot::resizeEvent(e);
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
if (!crossPlot) return;
bool anyLegendResized = false;
for (RimGridCrossPlotCurveSet* curveSet : crossPlot->curveSets())
{
if (!curveSet->isChecked() || !curveSet->legendConfig()->showLegend()) continue;
auto pairIt = m_legendWidgets.find(curveSet);
if (pairIt != m_legendWidgets.end())
{
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
if (overlayWidget->isVisible())
{
caf::TitledOverlayFrame* overlayItem = curveSet->legendConfig()->titledOverlayFrame();
if (resizeOverlayItemToFitPlot(overlayItem))
{
anyLegendResized = true;
overlayWidget->updateFromOverlayItem(overlayItem);
}
}
}
}
if (anyLegendResized)
{
updateLegendLayout();
}
updateLegendSizesToMatchPlot();
}
//--------------------------------------------------------------------------------------------------