mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Ternary legend : Added title
This commit is contained in:
parent
09f7868eb5
commit
8b04e2a2e8
@ -121,6 +121,20 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con
|
|||||||
cvf::TextDrawer textDrawer(m_font.p());
|
cvf::TextDrawer textDrawer(m_font.p());
|
||||||
textDrawer.setTextColor(m_textColor);
|
textDrawer.setTextColor(m_textColor);
|
||||||
|
|
||||||
|
float lineHeightInPixels = 10;
|
||||||
|
|
||||||
|
float textPosY = static_cast<float>(size.y() - 10);
|
||||||
|
for (size_t it = 0; it < m_titleStrings.size(); it++)
|
||||||
|
{
|
||||||
|
cvf::Vec2f pos(5, textPosY);
|
||||||
|
textDrawer.addText(m_titleStrings[it], pos);
|
||||||
|
|
||||||
|
textPosY -= lineHeightInPixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
textDrawer.addText("SGAS", cvf::Vec2f(static_cast<float>( (size.x() / 2) - 17 ), textPosY));
|
||||||
|
textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast<float>( (size.x() / 2) - 17 ), textPosY - lineHeightInPixels));
|
||||||
|
|
||||||
textDrawer.addText("SWAT", cvf::Vec2f(0.0, 10.0));
|
textDrawer.addText("SWAT", cvf::Vec2f(0.0, 10.0));
|
||||||
textDrawer.addText(m_swatRange, cvf::Vec2f(0.0, 0.0));
|
textDrawer.addText(m_swatRange, cvf::Vec2f(0.0, 0.0));
|
||||||
|
|
||||||
@ -133,12 +147,9 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con
|
|||||||
}
|
}
|
||||||
textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, 0.0));
|
textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, 0.0));
|
||||||
|
|
||||||
textDrawer.addText("SGAS", cvf::Vec2f(static_cast<float>( (size.x() / 2) - 17 ), static_cast<float>(size.y() - 10)));
|
|
||||||
textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast<float>( (size.x() / 2) - 17 ), static_cast<float>(size.y() - 20)));
|
|
||||||
|
|
||||||
textDrawer.renderSoftware(oglContext, camera);
|
textDrawer.renderSoftware(oglContext, camera);
|
||||||
|
|
||||||
renderAxisImmediateMode(oglContext);
|
renderAxisImmediateMode(textPosY - lineHeightInPixels, oglContext);
|
||||||
|
|
||||||
CVF_CHECK_OGL(oglContext);
|
CVF_CHECK_OGL(oglContext);
|
||||||
}
|
}
|
||||||
@ -148,7 +159,7 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Draw the axis using immediate mode OpenGL
|
/// Draw the axis using immediate mode OpenGL
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RivTernarySaturationOverlayItem::renderAxisImmediateMode(cvf::OpenGLContext* oglContext)
|
void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, cvf::OpenGLContext* oglContext)
|
||||||
{
|
{
|
||||||
#ifdef CVF_OPENGL_ES
|
#ifdef CVF_OPENGL_ES
|
||||||
CVF_UNUSED(layout);
|
CVF_UNUSED(layout);
|
||||||
@ -166,7 +177,7 @@ void RivTernarySaturationOverlayItem::renderAxisImmediateMode(cvf::OpenGLContext
|
|||||||
cvf::Color3ub colC(cvf::Color3::RED);
|
cvf::Color3ub colC(cvf::Color3::RED);
|
||||||
|
|
||||||
float lowerBoundY = 20;
|
float lowerBoundY = 20;
|
||||||
float upperBoundY = static_cast<float>(m_size.y() - 20);
|
//float upperBoundY = static_cast<float>(m_size.y() - 20);
|
||||||
|
|
||||||
cvf::Vec3f a(0, lowerBoundY, 0);
|
cvf::Vec3f a(0, lowerBoundY, 0);
|
||||||
cvf::Vec3f b(static_cast<float>(m_size.x()), lowerBoundY, 0);
|
cvf::Vec3f b(static_cast<float>(m_size.x()), lowerBoundY, 0);
|
||||||
@ -219,4 +230,20 @@ void RivTernarySaturationOverlayItem::setRangeText(const cvf::String& soilRange,
|
|||||||
m_swatRange = swatRange;
|
m_swatRange = swatRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RivTernarySaturationOverlayItem::setTitle(const cvf::String& title)
|
||||||
|
{
|
||||||
|
// Title
|
||||||
|
if (title.isEmpty())
|
||||||
|
{
|
||||||
|
m_titleStrings.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_titleStrings = title.split("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,12 +48,13 @@ public:
|
|||||||
virtual void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size);
|
virtual void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size);
|
||||||
|
|
||||||
void setSize(const cvf::Vec2ui& size);
|
void setSize(const cvf::Vec2ui& size);
|
||||||
|
|
||||||
void setAxisLabelsColor(const cvf::Color3f& color);
|
void setAxisLabelsColor(const cvf::Color3f& color);
|
||||||
|
void setTitle(const cvf::String& title);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software);
|
void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software);
|
||||||
void renderAxisImmediateMode(cvf::OpenGLContext* oglContext);
|
void renderAxisImmediateMode(float upperY, cvf::OpenGLContext* oglContext);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cvf::Color3f m_textColor; // Text color
|
cvf::Color3f m_textColor; // Text color
|
||||||
@ -64,5 +65,7 @@ private:
|
|||||||
cvf::String m_swatRange;
|
cvf::String m_swatRange;
|
||||||
|
|
||||||
cvf::Vec2ui m_size; // Pixel size of draw area
|
cvf::Vec2ui m_size; // Pixel size of draw area
|
||||||
|
|
||||||
|
std::vector<cvf::String> m_titleStrings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "RiuViewer.h"
|
#include "RiuViewer.h"
|
||||||
#include "RivReservoirPipesPartMgr.h"
|
#include "RivReservoirPipesPartMgr.h"
|
||||||
#include "RivWellPathCollectionPartMgr.h"
|
#include "RivWellPathCollectionPartMgr.h"
|
||||||
|
#include "RivTernarySaturationOverlayItem.h"
|
||||||
|
|
||||||
#include "cafCadNavigation.h"
|
#include "cafCadNavigation.h"
|
||||||
#include "cafCeetronPlusNavigation.h"
|
#include "cafCeetronPlusNavigation.h"
|
||||||
@ -1508,6 +1509,7 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
|
|||||||
|
|
||||||
if (resultSlot->ternaryLegendConfig->legend())
|
if (resultSlot->ternaryLegendConfig->legend())
|
||||||
{
|
{
|
||||||
|
resultSlot->ternaryLegendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel));
|
||||||
m_viewer->addColorLegendToBottomLeftCorner(resultSlot->ternaryLegendConfig->legend());
|
m_viewer->addColorLegendToBottomLeftCorner(resultSlot->ternaryLegendConfig->legend());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ void RimTernaryLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::OverlayItem* RimTernaryLegendConfig::legend()
|
RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend()
|
||||||
{
|
{
|
||||||
return m_legend.p();
|
return m_legend.p();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,8 @@ public:
|
|||||||
void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const;
|
void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const;
|
||||||
|
|
||||||
void recreateLegend();
|
void recreateLegend();
|
||||||
cvf::OverlayItem* legend();
|
|
||||||
|
RivTernarySaturationOverlayItem* legend();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user