#8949 Plot Update: Improve visual stability when clicking on curves

adjustSize() causes the plot to resize twice which is annoying. Cache the last child count to avoid calls to adjustSize().
This commit is contained in:
Magne Sjaastad 2022-05-31 11:51:16 +02:00
parent fe1acc93a6
commit c199f960e3
2 changed files with 20 additions and 2 deletions

View File

@ -226,6 +226,8 @@ void RiuMultiPlotPage::removePlot( RiuPlotWidget* plotWidget )
m_subTitles.removeAt( plotWidgetIdx );
delete subTitle;
m_childCountForAdjustSizeOperation.clear();
scheduleUpdate();
}
@ -733,9 +735,23 @@ int RiuMultiPlotPage::alignCanvasTops()
{
int row = visibleIndex / rowAndColumnCount.second;
qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtAxis::XTop )->setMinimumExtent( maxExtents[row] );
if ( legends[visibleIndex] )
auto legend = legends[visibleIndex];
if ( legend )
{
legends[visibleIndex]->adjustSize();
int previousChildCount = -1;
auto it = m_childCountForAdjustSizeOperation.find( legend );
if ( it != m_childCountForAdjustSizeOperation.end() )
{
previousChildCount = it->second;
}
auto legendItemCount = legend->contentsWidget()->children().size();
if ( previousChildCount != legendItemCount )
{
legends[visibleIndex]->adjustSize();
m_childCountForAdjustSizeOperation[legend] = legendItemCount;
}
}
}
}

View File

@ -147,6 +147,8 @@ protected:
bool m_previewMode;
bool m_showSubTitles;
std::map<RiuQwtPlotLegend*, int> m_childCountForAdjustSizeOperation;
private:
friend class RiaPlotWindowRedrawScheduler;
};