mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#831 Category legend use full height to be able to show as many category names as possible
This commit is contained in:
parent
25d5a500f0
commit
7306950d9d
@ -498,6 +498,50 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend)
|
||||
|
||||
m_visibleLegends.push_back(legend);
|
||||
}
|
||||
|
||||
std::vector<caf::CategoryLegend*> categoryLegends;
|
||||
std::vector<cvf::OverlayItem*> overlayItems;
|
||||
for (auto legend : m_visibleLegends)
|
||||
{
|
||||
caf::CategoryLegend* catLegend = dynamic_cast<caf::CategoryLegend*>(legend.p());
|
||||
if (catLegend)
|
||||
{
|
||||
categoryLegends.push_back(catLegend);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayItems.push_back(legend.p());
|
||||
}
|
||||
}
|
||||
|
||||
if (categoryLegends.size() > 0)
|
||||
{
|
||||
const int border = 3;
|
||||
const int categoryWidth = 120;
|
||||
|
||||
// This value is taken from OverlayAxisCross, as the axis cross is always shown in the lower left corner
|
||||
const int axisCrossHeight = 120;
|
||||
|
||||
int height = static_cast<int>(m_mainCamera->viewport()->height());
|
||||
int xPos = border;
|
||||
|
||||
int yPos = axisCrossHeight + 2*border;
|
||||
|
||||
for (auto catLegend : categoryLegends)
|
||||
{
|
||||
catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos));
|
||||
catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight));
|
||||
|
||||
xPos += categoryWidth + border;
|
||||
}
|
||||
|
||||
for (auto item : overlayItems)
|
||||
{
|
||||
item->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos));
|
||||
|
||||
yPos += item->sizeHint().y() + border;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -577,6 +621,29 @@ void RiuViewer::optimizeClippingPlanes()
|
||||
caf::Viewer::optimizeClippingPlanes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::resizeGL(int width, int height)
|
||||
{
|
||||
caf::Viewer::resizeGL(width, height);
|
||||
|
||||
bool hasCategoryLegend = false;
|
||||
for (size_t i = 0; i < m_visibleLegends.size(); i++)
|
||||
{
|
||||
caf::CategoryLegend* categoryLegend = dynamic_cast<caf::CategoryLegend*>(m_visibleLegends.at(i));
|
||||
if (categoryLegend)
|
||||
{
|
||||
hasCategoryLegend = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCategoryLegend)
|
||||
{
|
||||
m_rimView->updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -95,6 +95,7 @@ public slots:
|
||||
|
||||
protected:
|
||||
virtual void optimizeClippingPlanes();
|
||||
virtual void resizeGL(int width, int height);
|
||||
|
||||
private:
|
||||
void updateTextAndTickMarkColorForOverlayItems();
|
||||
|
Loading…
Reference in New Issue
Block a user