mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#656) Added text effect to effect generator
This commit is contained in:
parent
4469d32a2d
commit
08c04f5052
@ -36,7 +36,7 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RivGridBoxGenerator::RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram)
|
RivGridBoxGenerator::RivGridBoxGenerator()
|
||||||
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
|
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
|
||||||
m_gridLegendColor(cvf::Color3f::BLACK)
|
m_gridLegendColor(cvf::Color3f::BLACK)
|
||||||
{
|
{
|
||||||
@ -44,12 +44,6 @@ RivGridBoxGenerator::RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram)
|
|||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -562,7 +556,9 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
|||||||
part->setDrawable(geo.p());
|
part->setDrawable(geo.p());
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
|
|
||||||
part->setEffect(m_textEffect.p());
|
caf::TextEffectGenerator textGen;
|
||||||
|
cvf::ref<cvf::Effect> eff = textGen.generateCachedEffect();
|
||||||
|
part->setEffect(eff.p());
|
||||||
|
|
||||||
parts->push_back(part.p());
|
parts->push_back(part.p());
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace cvf
|
|||||||
class RivGridBoxGenerator
|
class RivGridBoxGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram);
|
RivGridBoxGenerator();
|
||||||
|
|
||||||
void setScaleZ(double scaleZ);
|
void setScaleZ(double scaleZ);
|
||||||
void setDisplayModelOffset(cvf::Vec3d offset);
|
void setDisplayModelOffset(cvf::Vec3d offset);
|
||||||
@ -126,7 +126,5 @@ private:
|
|||||||
|
|
||||||
cvf::Color3f m_gridColor;
|
cvf::Color3f m_gridColor;
|
||||||
cvf::Color3f m_gridLegendColor;
|
cvf::Color3f m_gridLegendColor;
|
||||||
|
|
||||||
cvf::ref<cvf::Effect> m_textEffect;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -167,12 +167,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
|||||||
// which solves the problem
|
// which solves the problem
|
||||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
|
|
||||||
cvf::ShaderProgram* textShaderProgram = NULL;
|
m_gridBoxGenerator = new RivGridBoxGenerator;
|
||||||
if (format.directRendering())
|
|
||||||
{
|
|
||||||
textShaderProgram = cvfOpenGLContext()->resourceManager()->getLinkedTextShaderProgram(cvfOpenGLContext());
|
|
||||||
}
|
|
||||||
m_gridBoxGenerator = new RivGridBoxGenerator(textShaderProgram);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -887,4 +887,54 @@ EffectGenerator* MeshEffectGenerator::copy() const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
TextEffectGenerator::TextEffectGenerator()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool TextEffectGenerator::isEqual(const EffectGenerator* other) const
|
||||||
|
{
|
||||||
|
const TextEffectGenerator* otherSurfaceEffect = dynamic_cast<const TextEffectGenerator*>(other);
|
||||||
|
if (otherSurfaceEffect)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
EffectGenerator* TextEffectGenerator::copy() const
|
||||||
|
{
|
||||||
|
TextEffectGenerator* effGen = new TextEffectGenerator;
|
||||||
|
|
||||||
|
return effGen;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void TextEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const
|
||||||
|
{
|
||||||
|
// See OpenGLResourceManager::getLinkedTextShaderProgram for code to be used here
|
||||||
|
// Detected some issues on RHEL 6 related to text, so use an empty effect for now
|
||||||
|
// Will fall back to fixed function rendering
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void TextEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} // End namespace caf
|
} // End namespace caf
|
||||||
|
@ -253,4 +253,23 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
// MeshEffectGenerator
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
class TextEffectGenerator : public EffectGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextEffectGenerator();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool isEqual(const EffectGenerator* other) const;
|
||||||
|
virtual EffectGenerator* copy() const;
|
||||||
|
|
||||||
|
virtual void updateForShaderBasedRendering(cvf::Effect* effect) const;
|
||||||
|
virtual void updateForFixedFunctionRendering(cvf::Effect* effect) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user