mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2657 Made a sensible stable default layout
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "cafTitledOverlayFrame.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -164,6 +165,40 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::updateEnsembleLegendLayout()
|
||||
{
|
||||
const int startMarginX = 65;
|
||||
const int startMarginY = 35;
|
||||
const int spacing = 5;
|
||||
|
||||
int xpos = startMarginX;
|
||||
int ypos = startMarginY;
|
||||
int maxColumnWidth = 0;
|
||||
|
||||
for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSets()->curveSets())
|
||||
{
|
||||
auto pairIt = m_ensembleLegendWidgets.find(curveSet);
|
||||
if (pairIt != m_ensembleLegendWidgets.end())
|
||||
{
|
||||
if (ypos + pairIt->second->height() + spacing > this->canvas()->height())
|
||||
{
|
||||
xpos += spacing + maxColumnWidth;
|
||||
ypos = startMarginY;
|
||||
maxColumnWidth = 0;
|
||||
}
|
||||
|
||||
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
|
||||
overlayWidget->move(xpos, ypos);
|
||||
|
||||
ypos += pairIt->second->height() + spacing;
|
||||
maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -175,10 +210,11 @@ void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet *
|
||||
if (it == m_ensembleLegendWidgets.end() || it->second == nullptr)
|
||||
{
|
||||
overlayWidget = new RiuCvfOverlayItemWidget(this);
|
||||
|
||||
new RiuWidgetDragger(overlayWidget);
|
||||
|
||||
m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget;
|
||||
overlayWidget->move(65, 30);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -193,6 +229,8 @@ void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet *
|
||||
overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame());
|
||||
overlayWidget->show();
|
||||
}
|
||||
|
||||
this->updateEnsembleLegendLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -207,6 +245,8 @@ void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curve
|
||||
|
||||
m_ensembleLegendWidgets.erase(it);
|
||||
}
|
||||
|
||||
this->updateEnsembleLegendLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -237,6 +277,15 @@ void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QwtPlot::resizeEvent(e);
|
||||
updateEnsembleLegendLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user