Make sure Ternary legends also expand and renamed width method.

This commit is contained in:
Gaute Lindkvist
2018-04-06 14:35:00 +02:00
parent 38aa447dcd
commit e93f79790e
6 changed files with 26 additions and 23 deletions

View File

@@ -91,18 +91,21 @@ void RivTernarySaturationOverlayItem::renderSoftware(cvf::OpenGLContext* oglCont
//--------------------------------------------------------------------------------------------------
void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglContext,
const cvf::Vec2i& position,
const cvf::Vec2ui& size,
const cvf::Vec2ui& sizeHint,
bool software)
{
if (size.x() <= 0 || size.y() <= 0)
if (sizeHint.x() <= 0 || sizeHint.y() <= 0)
{
return;
}
float border = 0.0f;
cvf::Vec2ui sizeMatched = sizeHint;
sizeMatched.x() = this->matchedWidth(); // Match to other legends
cvf::Camera camera;
camera.setViewport(position.x(), position.y(), size.x(), size.y());
camera.setViewport(position.x(), position.y(), sizeMatched.x(), sizeMatched.y());
camera.setProjectionAsPixelExact2D();
camera.setViewMatrix(cvf::Mat4d::IDENTITY);
camera.applyOpenGL();
@@ -113,7 +116,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte
if ( software )
{
caf::InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext,
cvf::Vec2f(size),
cvf::Vec2f(sizeMatched),
this->backgroundColor(),
this->backgroundFrameColor());
}
@@ -123,7 +126,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte
caf::InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext,
matrixState,
cvf::Vec2f(size),
cvf::Vec2f(sizeMatched),
this->backgroundColor(),
this->backgroundFrameColor());
}
@@ -135,7 +138,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte
float lineHeightInPixels = (float)(this->font()->textExtent("SWAT").y() + 2);
float textPosY = static_cast<float>(size.y() - lineHeightInPixels - border);
float textPosY = static_cast<float>(sizeMatched.y() - lineHeightInPixels - border);
for (size_t it = 0; it < this->titleStrings().size(); it++)
{
cvf::Vec2f pos(border, textPosY);
@@ -151,11 +154,11 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte
{
cvf::uint sgasTextWidth = this->font()->textExtent("SGAS").x();
textDrawer.addText("SGAS", cvf::Vec2f(static_cast<float>( (size.x() / 2) - sgasTextWidth / 2 ), textPosY));
textDrawer.addText("SGAS", cvf::Vec2f(static_cast<float>( (sizeMatched.x() / 2) - sgasTextWidth / 2 ), textPosY));
cvf::uint sgasRangeTextWidth = this->font()->textExtent(m_sgasRange).x();
textPosY -= lineHeightInPixels;
textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast<float>( (size.x() / 2) - sgasRangeTextWidth / 2 ), textPosY));
textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast<float>( (sizeMatched.x() / 2) - sgasRangeTextWidth / 2 ), textPosY));
}
textDrawer.addText("SWAT", cvf::Vec2f((float)border, (float)(lineHeightInPixels + border)));
@@ -163,10 +166,10 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte
{
cvf::uint soilTextWidth = this->font()->textExtent("SOIL").x();
textDrawer.addText("SOIL", cvf::Vec2f(static_cast<float>(size.x() - soilTextWidth - border), lineHeightInPixels + border));
textDrawer.addText("SOIL", cvf::Vec2f(static_cast<float>(sizeMatched.x() - soilTextWidth - border), lineHeightInPixels + border));
cvf::uint soilRangeTextWidth = this->font()->textExtent(m_soilRange).x();
float soilRangePos = static_cast<float>(size.x()) - soilRangeTextWidth - border;
float soilRangePos = static_cast<float>(sizeMatched.x()) - soilRangeTextWidth - border;
textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, (float)border));
}

View File

@@ -623,7 +623,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend
for (auto legend : m_visibleLegends)
{
legend->setWidth(requiredLegendWidth);
legend->setMatchedWidth(requiredLegendWidth);
}
}