diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index b84f87ecbe..3fede701fa 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -493,20 +493,31 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) { updateLegendTextAndTickMarkColor(legend); - legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); firstRendering->addOverlayItem(legend); m_visibleLegends.push_back(legend); } + // Category count used to switch between standard height and full height of legend + const size_t categoryThreshold = 13; + std::vector categoryLegends; std::vector overlayItems; for (auto legend : m_visibleLegends) { + legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); + caf::CategoryLegend* catLegend = dynamic_cast(legend.p()); if (catLegend) { - categoryLegends.push_back(catLegend); + if (catLegend->categoryCount() > categoryThreshold) + { + categoryLegends.push_back(catLegend); + } + else + { + catLegend->setSizeHint(cvf::Vec2ui(200, 200)); + } } else { diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index f816dce0f7..80296c4ba1 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -127,6 +127,19 @@ String CategoryLegend::title() const return title; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t CategoryLegend::categoryCount() const +{ + if (m_categoryMapper.notNull()) + { + return m_categoryMapper->categoryCount(); + } + + return 0; +} + //-------------------------------------------------------------------------------------------------- /// Hardware rendering using shader programs //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index d1f864ef8b..73a2c20920 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -49,6 +49,8 @@ public: void setTitle(const cvf::String& title); cvf::String title() const; + size_t categoryCount() const; + protected: //==================================================================================================