Avoid regenerating gridbox when unchanged

This commit is contained in:
Jacob Støren 2019-11-04 17:04:49 +01:00
parent 03d13f668b
commit 03b44fc36f
2 changed files with 25 additions and 5 deletions

View File

@ -42,6 +42,7 @@
RivGridBoxGenerator::RivGridBoxGenerator()
: m_gridColor( cvf::Color3f::LIGHT_GRAY )
, m_gridLegendColor( cvf::Color3f::BLACK )
, m_needsRegeneration( true )
{
m_gridBoxModel = new cvf::ModelBasicList();
m_gridBoxModel->setName( "GridBoxModel" );
@ -55,6 +56,8 @@ RivGridBoxGenerator::RivGridBoxGenerator()
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setScaleZ( double scaleZ )
{
if ( m_scaleZ != scaleZ ) m_needsRegeneration = true;
m_scaleZ = scaleZ;
}
@ -63,6 +66,8 @@ void RivGridBoxGenerator::setScaleZ( double scaleZ )
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setDisplayModelOffset( cvf::Vec3d offset )
{
if ( m_displayModelOffset != offset ) m_needsRegeneration = true;
m_displayModelOffset = offset;
}
@ -183,6 +188,11 @@ void RivGridBoxGenerator::setGridBoxDomainCoordBoundingBox( const cvf::BoundingB
expandedBB.add( min );
expandedBB.add( max );
if ( m_domainCoordsBoundingBox.min() != expandedBB.min() || m_domainCoordsBoundingBox.max() != expandedBB.max() )
{
m_needsRegeneration = true;
}
m_domainCoordsBoundingBox = expandedBB;
}
@ -191,10 +201,14 @@ void RivGridBoxGenerator::setGridBoxDomainCoordBoundingBox( const cvf::BoundingB
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::createGridBoxParts()
{
computeDisplayCoords();
if ( m_needsRegeneration )
{
computeDisplayCoords();
createGridBoxFaceParts();
createGridBoxLegendParts();
createGridBoxFaceParts();
createGridBoxLegendParts();
m_needsRegeneration = false;
}
}
//--------------------------------------------------------------------------------------------------
@ -740,8 +754,12 @@ cvf::Vec3f RivGridBoxGenerator::cornerDirection( FaceType face1, FaceType face2
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::updateFromBackgroundColor( const cvf::Color3f& backgroundColor )
{
m_gridColor = RiaColorTools::computeOffsetColor( backgroundColor, 0.3f );
m_gridLegendColor = RiaColorTools::contrastColor( backgroundColor );
m_gridColor = RiaColorTools::computeOffsetColor( backgroundColor, 0.3f );
cvf::Color3f contrastColor = RiaColorTools::contrastColor( backgroundColor );
if ( contrastColor != m_gridLegendColor ) m_needsRegeneration = true;
m_gridLegendColor = contrastColor;
}
//--------------------------------------------------------------------------------------------------

View File

@ -122,4 +122,6 @@ private:
cvf::Color3f m_gridColor;
cvf::Color3f m_gridLegendColor;
bool m_needsRegeneration;
};