mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#4336 Fix deletion of grid cross plot legends
This commit is contained in:
parent
6f7a75f5c2
commit
f9e3db6aa6
@ -112,7 +112,11 @@ void RiuGridCrossQwtPlot::removeDataSetLegend(RimGridCrossPlotDataSet* dataSetTo
|
||||
auto it = m_legendWidgets.find(dataSetToShowLegendFor);
|
||||
if (it != m_legendWidgets.end())
|
||||
{
|
||||
if (it->second != nullptr) it->second->deleteLater();
|
||||
if (it->second != nullptr)
|
||||
{
|
||||
it->second->hide();
|
||||
it->second->deleteLater();
|
||||
}
|
||||
|
||||
m_legendWidgets.erase(it);
|
||||
}
|
||||
@ -120,6 +124,29 @@ void RiuGridCrossQwtPlot::removeDataSetLegend(RimGridCrossPlotDataSet* dataSetTo
|
||||
this->updateLegendLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuGridCrossQwtPlot::removeDanglingDataSetLegends()
|
||||
{
|
||||
for (auto it = m_legendWidgets.begin(); it != m_legendWidgets.end();)
|
||||
{
|
||||
if (it->first.isNull())
|
||||
{
|
||||
if (it->second != nullptr)
|
||||
{
|
||||
it->second->hide();
|
||||
it->second->deleteLater();
|
||||
}
|
||||
m_legendWidgets.erase(it++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -248,6 +275,8 @@ void RiuGridCrossQwtPlot::updateLegendLayout()
|
||||
int ypos = startMarginY;
|
||||
int maxColumnWidth = 0;
|
||||
|
||||
removeDanglingDataSetLegends();
|
||||
|
||||
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
|
||||
|
||||
if (!crossPlot) return;
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
~RiuGridCrossQwtPlot();
|
||||
void addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* dataSetToShowLegendFor);
|
||||
void removeDataSetLegend(RimGridCrossPlotDataSet* dataSetToShowLegendFor);
|
||||
void removeDanglingDataSetLegends();
|
||||
void updateLegendSizesToMatchPlot();
|
||||
void updateAnnotationObjects(RimPlotAxisProperties* axisProperties);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user