mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Unify the width of all visible legends.
* Calculate the minimum width to fit the content before the render pass.
* Set the actual width of all the legends to the largest of the minimum widths.
* This resizes the legends to always be the same size and reduces the size of you remove
the widest legend.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font)
|
||||
: TitledOverlayFrame(font, 120, 150)
|
||||
{
|
||||
this->computeLayoutAndExtents();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -53,6 +54,14 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem()
|
||||
// Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernarySaturationOverlayItem::computeLayoutAndExtents()
|
||||
{
|
||||
this->setMinimumWidth(this->sizeHint().x());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -41,6 +41,7 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame
|
||||
public:
|
||||
explicit RivTernarySaturationOverlayItem(cvf::Font* font);
|
||||
~RivTernarySaturationOverlayItem();
|
||||
virtual void computeLayoutAndExtents() override;
|
||||
|
||||
void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange);
|
||||
|
||||
|
||||
@@ -370,6 +370,7 @@ void RimLegendConfig::updateLegend()
|
||||
numDecimalDigits -= static_cast<int>(decadesInRange);
|
||||
}
|
||||
m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20));
|
||||
m_scalarMapperLegend->computeLayoutAndExtents();
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RiaPreferences* preferences = app->preferences();
|
||||
|
||||
@@ -614,6 +614,17 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend
|
||||
yPos += item->sizeHint().y() + border + edgeAxisBorderHeight;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int requiredLegendWidth = 0u;
|
||||
for (auto legend : m_visibleLegends)
|
||||
{
|
||||
requiredLegendWidth = std::max(requiredLegendWidth, legend->minimumWidth());
|
||||
}
|
||||
|
||||
for (auto legend : m_visibleLegends)
|
||||
{
|
||||
legend->setWidth(requiredLegendWidth);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user