mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Show ternary range on overlay item
This commit is contained in:
parent
cc4e9eb505
commit
bed902d005
@ -121,9 +121,15 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con
|
||||
cvf::TextDrawer textDrawer(m_font.p());
|
||||
textDrawer.setTextColor(m_textColor);
|
||||
|
||||
textDrawer.addText("SWAT", cvf::Vec2f(0.0, 0.0));
|
||||
textDrawer.addText("SOIL", cvf::Vec2f(static_cast<float>(size.x() - 28), 0.0));
|
||||
textDrawer.addText("SWAT", cvf::Vec2f(0.0, 10.0));
|
||||
textDrawer.addText(m_swatRange, cvf::Vec2f(0.0, 0.0));
|
||||
|
||||
textDrawer.addText("SOIL", cvf::Vec2f(static_cast<float>(size.x() - 40), 10.0));
|
||||
textDrawer.addText(m_soilRange, cvf::Vec2f(static_cast<float>(size.x() - 40), 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);
|
||||
|
||||
renderAxisImmediateMode(oglContext);
|
||||
@ -197,4 +203,14 @@ void RivTernarySaturationOverlayItem::renderAxisImmediateMode(cvf::OpenGLContext
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernarySaturationOverlayItem::setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange)
|
||||
{
|
||||
m_soilRange = soilRange;
|
||||
m_sgasRange = sgasRange;
|
||||
m_swatRange = swatRange;
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
RivTernarySaturationOverlayItem(cvf::Font* font);
|
||||
~RivTernarySaturationOverlayItem();
|
||||
|
||||
void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange);
|
||||
|
||||
virtual cvf::Vec2ui sizeHint();
|
||||
|
||||
virtual void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size);
|
||||
@ -56,6 +58,10 @@ private:
|
||||
private:
|
||||
cvf::Color3f m_textColor; // Text color
|
||||
cvf::ref<cvf::Font> m_font;
|
||||
|
||||
cvf::String m_soilRange;
|
||||
cvf::String m_sgasRange;
|
||||
cvf::String m_swatRange;
|
||||
|
||||
cvf::Vec2ui m_size; // Pixel size of draw area
|
||||
};
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "RivTernarySaturationOverlayItem.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig");
|
||||
@ -154,7 +155,39 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTernaryLegendConfig::updateLegend()
|
||||
{
|
||||
// TODO: Update text on ternary legend
|
||||
double soilLower = 0.0;
|
||||
double soilUpper = 1.0;
|
||||
double sgasLower = 0.0;
|
||||
double sgasUpper = 1.0;
|
||||
double swatLower = 0.0;
|
||||
double swatUpper = 1.0;
|
||||
|
||||
ternaryRanges(soilLower, soilUpper, sgasLower, sgasUpper, swatLower, swatUpper);
|
||||
|
||||
cvf::String soilRange;
|
||||
cvf::String sgasRange;
|
||||
cvf::String swatRange;
|
||||
|
||||
int numberPrecision = 1;
|
||||
{
|
||||
QString tmpString = QString::number(soilLower, 'g', numberPrecision) + " - " + QString::number(soilUpper, 'g', numberPrecision);
|
||||
soilRange = cvfqt::Utils::toString(tmpString);
|
||||
}
|
||||
|
||||
{
|
||||
QString tmpString = QString::number(sgasLower, 'g', numberPrecision) + " - " + QString::number(sgasUpper, 'g', numberPrecision);
|
||||
sgasRange = cvfqt::Utils::toString(tmpString);
|
||||
}
|
||||
|
||||
{
|
||||
QString tmpString = QString::number(swatLower, 'g', numberPrecision) + " - " + QString::number(swatUpper, 'g', numberPrecision);
|
||||
swatRange = cvfqt::Utils::toString(tmpString);
|
||||
}
|
||||
|
||||
if (!m_legend.isNull())
|
||||
{
|
||||
m_legend->setRangeText(soilRange, sgasRange, swatRange);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user