mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#266) Improved label display
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RivGridBoxGenerator::RivGridBoxGenerator()
|
RivGridBoxGenerator::RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram)
|
||||||
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
|
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
|
||||||
m_gridLegendColor(cvf::Color3f::BLACK)
|
m_gridLegendColor(cvf::Color3f::BLACK)
|
||||||
{
|
{
|
||||||
@@ -42,6 +42,12 @@ RivGridBoxGenerator::RivGridBoxGenerator()
|
|||||||
|
|
||||||
m_scaleZ = 1.0;
|
m_scaleZ = 1.0;
|
||||||
m_displayModelOffset = cvf::Vec3d::ZERO;
|
m_displayModelOffset = cvf::Vec3d::ZERO;
|
||||||
|
|
||||||
|
m_textEffect = new cvf::Effect;
|
||||||
|
if (textShaderProgram)
|
||||||
|
{
|
||||||
|
m_textEffect->setShaderProgram(textShaderProgram);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -93,17 +99,18 @@ void RivGridBoxGenerator::setGridBoxDomainCoordBoundingBox(const cvf::BoundingBo
|
|||||||
cvf::Vec3d max = m_domainCoordsBoundingBox.max();
|
cvf::Vec3d max = m_domainCoordsBoundingBox.max();
|
||||||
|
|
||||||
cvf::ScalarMapperDiscreteLinear m_linDiscreteScalarMapper;
|
cvf::ScalarMapperDiscreteLinear m_linDiscreteScalarMapper;
|
||||||
|
size_t levelCount = 6;
|
||||||
|
|
||||||
m_linDiscreteScalarMapper.setRange(min.x(), max.x());
|
m_linDiscreteScalarMapper.setRange(min.x(), max.x());
|
||||||
m_linDiscreteScalarMapper.setLevelCount(5, true);
|
m_linDiscreteScalarMapper.setLevelCount(levelCount, true);
|
||||||
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues);
|
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues);
|
||||||
|
|
||||||
m_linDiscreteScalarMapper.setRange(min.y(), max.y());
|
m_linDiscreteScalarMapper.setRange(min.y(), max.y());
|
||||||
m_linDiscreteScalarMapper.setLevelCount(5, true);
|
m_linDiscreteScalarMapper.setLevelCount(levelCount, true);
|
||||||
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues);
|
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues);
|
||||||
|
|
||||||
m_linDiscreteScalarMapper.setRange(min.z(), max.z());
|
m_linDiscreteScalarMapper.setRange(min.z(), max.z());
|
||||||
m_linDiscreteScalarMapper.setLevelCount(5, true);
|
m_linDiscreteScalarMapper.setLevelCount(levelCount, true);
|
||||||
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsZValues);
|
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsZValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +544,8 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
|||||||
geo->setDrawBackground(false);
|
geo->setDrawBackground(false);
|
||||||
geo->setDrawBorder(false);
|
geo->setDrawBorder(false);
|
||||||
|
|
||||||
for (size_t idx = 0; idx < domainCoordsTickValues->size(); idx++)
|
// Do not draw legend labels at first/last tick mark
|
||||||
|
for (size_t idx = 1; idx < domainCoordsTickValues->size() - 1; idx++)
|
||||||
{
|
{
|
||||||
geo->addText(cvf::String(domainCoordsTickValues->at(idx)), vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir);
|
geo->addText(cvf::String(domainCoordsTickValues->at(idx)), vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir);
|
||||||
}
|
}
|
||||||
@@ -547,8 +555,7 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
|||||||
part->setDrawable(geo.p());
|
part->setDrawable(geo.p());
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
|
|
||||||
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
part->setEffect(m_textEffect.p());
|
||||||
part->setEffect(eff.p());
|
|
||||||
|
|
||||||
parts->push_back(part.p());
|
parts->push_back(part.p());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
namespace cvf
|
namespace cvf
|
||||||
{
|
{
|
||||||
class Camera;
|
class Camera;
|
||||||
|
class ShaderProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ namespace cvf
|
|||||||
class RivGridBoxGenerator
|
class RivGridBoxGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RivGridBoxGenerator();
|
RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram);
|
||||||
|
|
||||||
void setScaleZ(double scaleZ);
|
void setScaleZ(double scaleZ);
|
||||||
void setDisplayModelOffset(cvf::Vec3d offset);
|
void setDisplayModelOffset(cvf::Vec3d offset);
|
||||||
@@ -125,5 +126,7 @@ private:
|
|||||||
|
|
||||||
cvf::Color3f m_gridColor;
|
cvf::Color3f m_gridColor;
|
||||||
cvf::Color3f m_gridLegendColor;
|
cvf::Color3f m_gridLegendColor;
|
||||||
|
|
||||||
|
cvf::ref<cvf::Effect> m_textEffect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "cafCeetronPlusNavigation.h"
|
#include "cafCeetronPlusNavigation.h"
|
||||||
#include "cafEffectGenerator.h"
|
#include "cafEffectGenerator.h"
|
||||||
|
|
||||||
#include "cvfCamera.h"
|
#include "cvfCamera.h"
|
||||||
#include "cvfFont.h"
|
#include "cvfFont.h"
|
||||||
#include "cvfOverlayAxisCross.h"
|
#include "cvfOverlayAxisCross.h"
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
#include "cvfRenderSequence.h"
|
#include "cvfRenderSequence.h"
|
||||||
#include "cvfRendering.h"
|
#include "cvfRendering.h"
|
||||||
#include "cvfScene.h"
|
#include "cvfScene.h"
|
||||||
|
#include "cvfOpenGLResourceManager.h"
|
||||||
|
|
||||||
#include <QCDEStyle>
|
#include <QCDEStyle>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -165,7 +167,12 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
|||||||
// which solves the problem
|
// which solves the problem
|
||||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
|
|
||||||
m_gridBoxGenerator = new RivGridBoxGenerator;
|
cvf::ShaderProgram* textShaderProgram = NULL;
|
||||||
|
if (format.directRendering())
|
||||||
|
{
|
||||||
|
textShaderProgram = cvfOpenGLContext()->resourceManager()->getLinkedTextShaderProgram(cvfOpenGLContext());
|
||||||
|
}
|
||||||
|
m_gridBoxGenerator = new RivGridBoxGenerator(textShaderProgram);
|
||||||
|
|
||||||
setupRenderingSequence();
|
setupRenderingSequence();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user