Merge pull request #6108 from OPM/appfwk-clang-format

Use clang-format on AppFwk
This commit is contained in:
Magne Sjaastad 2020-06-19 09:01:11 +02:00 committed by GitHub
commit 6ad749030a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
409 changed files with 89072 additions and 42319 deletions

View File

@ -11,13 +11,20 @@ jobs:
sudo apt install clang-format-6.0
clang-format-6.0 --version
- uses: actions/checkout@v2
- name: Check format
- name: Check format - ApplicationCode
run: |
cd ApplicationCode
find -name "*.h" -o -name "*.cpp" -o -name "*.inl" | xargs clang-format-6.0 -i
find -name *.h -o -name *.cpp -o -name *.inl | xargs clang-format-6.0 -i
git diff
- name: Check format - AppFwk
run: |
cd Fwk/AppFwk
find -name *.h -o -name *.cpp -o -name *.inl | grep -v gtest | xargs clang-format-6.0 -i
git diff
- uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Fixes by clang-format'
title: 'Fixes by clang-format'

79
Fwk/AppFwk/.clang-format Normal file
View File

@ -0,0 +1,79 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakAssignment: 13
PenaltyBreakBeforeFirstCallParameter: 10000
PenaltyBreakComment: 20
PenaltyBreakFirstLessLess: 12
PenaltyBreakString: 100
PenaltyExcessCharacter: 5
PenaltyReturnTypeOnItsOwnLine: 30
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

View File

@ -24,22 +24,21 @@
#include "cafContourLines.h"
#include <algorithm>
#include <list>
#include <cmath>
#include <list>
const int caf::ContourLines::s_castab[3][3][3] =
{
{ {0,0,8},{0,2,5},{7,6,9} },
const int caf::ContourLines::s_castab[3][3][3] = {{{0, 0, 8}, {0, 2, 5}, {7, 6, 9}},
{{0, 3, 4}, {1, 3, 1}, {4, 3, 0}},
{ {9,6,7},{5,2,0},{8,0,0} }
};
{{9, 6, 7}, {5, 2, 0}, {8, 0, 0}}};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vector<double>& xCoords, const std::vector<double>& yCoords, const std::vector<double>& contourLevels, std::vector<std::vector<cvf::Vec2d>>* polygons)
void caf::ContourLines::create( const std::vector<double>& dataXY,
const std::vector<double>& xCoords,
const std::vector<double>& yCoords,
const std::vector<double>& contourLevels,
std::vector<std::vector<cvf::Vec2d>>* polygons )
{
CVF_ASSERT( !contourLevels.empty() );
int nContourLevels = static_cast<int>( contourLevels.size() );
@ -72,13 +71,11 @@ void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vec
double dmax = std::max( temp1, temp2 );
// Using dmax <= contourLevels[0] as a deviation from Bourke because it empirically
// Reduces gridding artifacts in our code.
if (dmax <= contourLevels[0] || dmin > contourLevels[nContourLevels - 1])
continue;
if ( dmax <= contourLevels[0] || dmin > contourLevels[nContourLevels - 1] ) continue;
for ( int k = 0; k < nContourLevels; k++ )
{
if (contourLevels[k] < dmin || contourLevels[k] > dmax)
continue;
if ( contourLevels[k] < dmin || contourLevels[k] > dmax ) continue;
for ( int m = 4; m >= 0; m-- )
{
if ( m > 0 )
@ -133,17 +130,18 @@ void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vec
vertex 1 +-------------------+ vertex 2
*/
/* Scan each triangle in the box */
for (int m = 1; m <= 4; m++) {
for ( int m = 1; m <= 4; m++ )
{
int m1 = m;
int m2 = 0;
int m3 = ( m != 4 ) ? m + 1 : 1;
double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
int case_value = s_castab[sh[m1] + 1][sh[m2] + 1][sh[m3] + 1];
if (case_value == 0)
continue;
if ( case_value == 0 ) continue;
switch (case_value) {
switch ( case_value )
{
case 1: /* Line between vertices 1 and 2 */
x1 = xh[m1];
y1 = yh[m1];
@ -234,7 +232,8 @@ std::vector<caf::ContourLines::ListOfLineSegments> caf::ContourLines::create(con
ListOfLineSegments unorderedSegments;
for ( size_t j = 0; j < contourLineSegments[i].size(); j += 2 )
{
unorderedSegments.push_back(std::make_pair(cvf::Vec3d(contourLineSegments[i][j]), cvf::Vec3d(contourLineSegments[i][j + 1])));
unorderedSegments.push_back( std::make_pair( cvf::Vec3d( contourLineSegments[i][j] ),
cvf::Vec3d( contourLineSegments[i][j + 1] ) ) );
}
listOfSegmentsPerLevel[i] = unorderedSegments;
}
@ -279,7 +278,11 @@ double caf::ContourLines::saneValue(int index, const std::vector<double>& dataXY
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double caf::ContourLines::xsect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh)
double caf::ContourLines::xsect( int p1,
int p2,
const std::vector<double>& h,
const std::vector<double>& xh,
const std::vector<double>& yh )
{
return ( h[p2] * xh[p1] - h[p1] * xh[p2] ) / ( h[p2] - h[p1] );
}
@ -287,7 +290,11 @@ double caf::ContourLines::xsect(int p1, int p2, const std::vector<double>& h, co
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double caf::ContourLines::ysect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh)
double caf::ContourLines::ysect( int p1,
int p2,
const std::vector<double>& h,
const std::vector<double>& xh,
const std::vector<double>& yh )
{
return ( h[p2] * yh[p1] - h[p1] * yh[p2] ) / ( h[p2] - h[p1] );
}

View File

@ -54,10 +54,13 @@ private:
static double contourRange( const std::vector<double>& contourLevels );
static double invalidValue( const std::vector<double>& contourLevels );
static double saneValue( int index, const std::vector<double>& dataXY, const std::vector<double>& contourLevels );
static double xsect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh);
static double ysect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh);
static double
xsect( int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh );
static double
ysect( int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh );
static int gridIndex1d( int i, int j, int nx );
private:
static const int s_castab[3][3][3];
};
}
} // namespace caf

View File

@ -34,13 +34,11 @@
//
//##################################################################################################
#include "cafEffectGenerator.h"
#include "cafEffectCache.h"
#include "cafEffectGenerator.h"
namespace caf {
namespace caf
{
//==================================================================================================
//
// EffectCache
@ -65,7 +63,6 @@ EffectCache* EffectCache::instance()
return &staticInstance;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -141,5 +138,4 @@ void EffectCache::releaseUnreferencedEffects()
m_effectCache.swap( newCache );
}
}
} // namespace caf

View File

@ -34,18 +34,16 @@
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfEffect.h"
#include "cvfObject.h"
#include "cafEffectGenerator.h"
namespace caf {
namespace caf
{
//==================================================================================================
//
// Private class. Used only by caf::EffectGenerator to cache effects (with GPU resources)
@ -70,6 +68,4 @@ private:
std::vector<std::pair<EffectGenerator*, cvf::ref<cvf::Effect>>> m_effectCache;
};
}
} // namespace caf

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#include "cafEffectGenerator.h"
#include "cafEffectCache.h"
#include "cafUtils.h"
#include "cvfMatrixState.h"
#include "cvfRenderState_FF.h"
#include "cvfRenderStateBlending.h"
#include "cvfRenderStateColorMask.h"
#include "cvfRenderStateCullFace.h"
@ -50,6 +48,7 @@
#include "cvfRenderStatePolygonMode.h"
#include "cvfRenderStatePolygonOffset.h"
#include "cvfRenderStateTextureBindings.h"
#include "cvfRenderState_FF.h"
#include "cvfSampler.h"
#include "cvfShaderProgram.h"
#include "cvfShaderProgramGenerator.h"
@ -61,8 +60,8 @@
#include <QtOpenGL/QGLFormat>
namespace caf {
namespace caf
{
//#############################################################################################################################
//#############################################################################################################################
static const char checkDiscard_Transparent_Fragments_inl[] =
@ -78,7 +77,6 @@ static const char checkDiscard_Transparent_Fragments_inl[] =
" if (color.a < 1.0) discard; \n"
"} \n";
//=============================================================================================================================
//=============================================================================================================================
static const char light_AmbientDiffuse_inl[] =
@ -122,7 +120,8 @@ cvf::String CommonShaderSources::light_AmbientDiffuse()
//--------------------------------------------------------------------------------------------------
/// Static helper to configure polygon offset render state from enum
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::RenderStatePolygonOffset> EffectGenerator::createAndConfigurePolygonOffsetRenderState(PolygonOffset polygonOffset)
cvf::ref<cvf::RenderStatePolygonOffset>
EffectGenerator::createAndConfigurePolygonOffsetRenderState( PolygonOffset polygonOffset )
{
cvf::ref<cvf::RenderStatePolygonOffset> rs = new cvf::RenderStatePolygonOffset;
if ( polygonOffset == PO_NONE )
@ -134,10 +133,22 @@ cvf::ref<cvf::RenderStatePolygonOffset> EffectGenerator::createAndConfigurePolyg
switch ( polygonOffset )
{
case PO_1: rs->setFactor(1.0f); rs->setUnits(1.0f); break;
case PO_2: rs->setFactor(2.0f); rs->setUnits(2.0f); break;
case PO_POS_LARGE: rs->setFactor(3.0f); rs->setUnits(50.0f); break;
case PO_NEG_LARGE: rs->setFactor(-1.0f); rs->setUnits(-30.0f); break;
case PO_1:
rs->setFactor( 1.0f );
rs->setUnits( 1.0f );
break;
case PO_2:
rs->setFactor( 2.0f );
rs->setUnits( 2.0f );
break;
case PO_POS_LARGE:
rs->setFactor( 3.0f );
rs->setUnits( 50.0f );
break;
case PO_NEG_LARGE:
rs->setFactor( -1.0f );
rs->setUnits( -30.0f );
break;
default:
CVF_FAIL_MSG( "Unhandled polygon offset enum" );
}
@ -145,9 +156,6 @@ cvf::ref<cvf::RenderStatePolygonOffset> EffectGenerator::createAndConfigurePolyg
return rs;
}
//==================================================================================================
//
// EffectGenerator Base class
@ -207,8 +215,6 @@ cvf::ref<cvf::Effect> EffectGenerator::generateUnCachedEffect() const
return eff;
}
//--------------------------------------------------------------------------------------------------
/// Updates the effect to the state defined by the inherited effect generator.
/// This can be used to update an effect used several places in the scene.
@ -308,13 +314,13 @@ void SurfaceEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect)
}
cvf::ref<cvf::ShaderProgram> shaderProg = gen.generate();
if (m_enableLighting) shaderProg->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
if ( m_enableLighting )
shaderProg->setDefaultUniform( new cvf::UniformFloat( "u_ecLightPosition", cvf::Vec3f( 0.5, 5.0, 7.0 ) ) );
cvf::ref<cvf::Effect> eff = effect;
eff->setShaderProgram( shaderProg.p() );
eff->setUniform( new cvf::UniformFloat( "u_color", m_color ) );
this->updateCommonEffect( effect );
}
@ -336,7 +342,6 @@ void SurfaceEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect
eff->setRenderState( lighting.p() );
this->updateCommonEffect( effect );
}
//--------------------------------------------------------------------------------------------------
@ -346,7 +351,8 @@ void SurfaceEffectGenerator::updateCommonEffect(cvf::Effect* effect) const
{
if ( m_polygonOffset != PO_NONE )
{
cvf::ref<cvf::RenderStatePolygonOffset> polyOffset = EffectGenerator::createAndConfigurePolygonOffsetRenderState(m_polygonOffset);
cvf::ref<cvf::RenderStatePolygonOffset> polyOffset =
EffectGenerator::createAndConfigurePolygonOffsetRenderState( m_polygonOffset );
effect->setRenderState( polyOffset.p() );
}
@ -402,13 +408,12 @@ bool SurfaceEffectGenerator::isEqual(const EffectGenerator* other) const
if ( otherSurfaceEffect )
{
if (m_color == otherSurfaceEffect->m_color
&& m_polygonOffset == otherSurfaceEffect->m_polygonOffset
&& m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces
&& m_enableColorMask == otherSurfaceEffect->m_enableColorMask
&& m_enableDepthTest == otherSurfaceEffect->m_enableDepthTest
&& m_enableDepthWrite == otherSurfaceEffect->m_enableDepthWrite
&& m_enableLighting == otherSurfaceEffect->m_enableLighting)
if ( m_color == otherSurfaceEffect->m_color && m_polygonOffset == otherSurfaceEffect->m_polygonOffset &&
m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces &&
m_enableColorMask == otherSurfaceEffect->m_enableColorMask &&
m_enableDepthTest == otherSurfaceEffect->m_enableDepthTest &&
m_enableDepthWrite == otherSurfaceEffect->m_enableDepthWrite &&
m_enableLighting == otherSurfaceEffect->m_enableLighting )
{
return true;
}
@ -431,17 +436,12 @@ EffectGenerator* SurfaceEffectGenerator::copy() const
return effGen;
}
//==================================================================================================
//
// ScalarMapperEffectGenerator
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -483,18 +483,19 @@ void ScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::Effect* eff
gen.addFragmentCode( cvf::ShaderSourceRepository::fs_Standard );
}
cvf::ref<cvf::ShaderProgram> prog = gen.generate();
eff->setShaderProgram( prog.p() );
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
if ( !m_disableLighting )
prog->setDefaultUniform( new cvf::UniformFloat( "u_ecLightPosition", cvf::Vec3f( 0.5, 5.0, 7.0 ) ) );
// Result mapping texture
m_textureImage = new cvf::TextureImage();
m_scalarMapper->updateTexture( m_textureImage.p() );
cvf::ref<cvf::TextureImage> modTexImg = ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_textureImage.p(), m_undefinedColor, m_opacityLevel);
cvf::ref<cvf::TextureImage> modTexImg =
ScalarMapperEffectGenerator::addAlphaAndUndefStripes( m_textureImage.p(), m_undefinedColor, m_opacityLevel );
cvf::ref<cvf::Texture> texture = new cvf::Texture( modTexImg.p() );
cvf::ref<cvf::Sampler> sampler = new cvf::Sampler;
@ -531,7 +532,8 @@ void ScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* e
m_textureImage = new cvf::TextureImage;
m_scalarMapper->updateTexture( m_textureImage.p() );
cvf::ref<cvf::TextureImage> modTexImg = ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_textureImage.p(), m_undefinedColor, m_opacityLevel);
cvf::ref<cvf::TextureImage> modTexImg =
ScalarMapperEffectGenerator::addAlphaAndUndefStripes( m_textureImage.p(), m_undefinedColor, m_opacityLevel );
cvf::ref<cvf::Texture2D_FF> texture = new cvf::Texture2D_FF( modTexImg.p() );
texture->setWrapMode( cvf::Texture2D_FF::CLAMP );
@ -543,7 +545,6 @@ void ScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* e
// Hardware independent:
updateCommonEffect( eff.p() );
}
//--------------------------------------------------------------------------------------------------
@ -556,7 +557,8 @@ void ScalarMapperEffectGenerator::updateCommonEffect(cvf::Effect* effect) const
if ( m_polygonOffset != PO_NONE )
{
cvf::ref<cvf::RenderStatePolygonOffset> polyOffset = EffectGenerator::createAndConfigurePolygonOffsetRenderState(m_polygonOffset);
cvf::ref<cvf::RenderStatePolygonOffset> polyOffset =
EffectGenerator::createAndConfigurePolygonOffsetRenderState( m_polygonOffset );
effect->setRenderState( polyOffset.p() );
}
@ -596,7 +598,6 @@ void ScalarMapperEffectGenerator::updateCommonEffect(cvf::Effect* effect) const
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -606,14 +607,14 @@ bool ScalarMapperEffectGenerator::isEqual(const EffectGenerator* other) const
if ( otherTextureResultEffect )
{
if (m_scalarMapper.p() == otherTextureResultEffect->m_scalarMapper
&& m_polygonOffset == otherTextureResultEffect->m_polygonOffset
&& m_opacityLevel == otherTextureResultEffect->m_opacityLevel
&& m_undefinedColor == otherTextureResultEffect->m_undefinedColor
&& m_faceCulling == otherTextureResultEffect->m_faceCulling
&& m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite
&& m_disableLighting == otherTextureResultEffect->m_disableLighting
&& m_discardTransparentFragments == otherTextureResultEffect->m_discardTransparentFragments)
if ( m_scalarMapper.p() == otherTextureResultEffect->m_scalarMapper &&
m_polygonOffset == otherTextureResultEffect->m_polygonOffset &&
m_opacityLevel == otherTextureResultEffect->m_opacityLevel &&
m_undefinedColor == otherTextureResultEffect->m_undefinedColor &&
m_faceCulling == otherTextureResultEffect->m_faceCulling &&
m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite &&
m_disableLighting == otherTextureResultEffect->m_disableLighting &&
m_discardTransparentFragments == otherTextureResultEffect->m_discardTransparentFragments )
{
cvf::ref<cvf::TextureImage> texImg2 = new cvf::TextureImage;
otherTextureResultEffect->m_scalarMapper->updateTexture( texImg2.p() );
@ -646,14 +647,16 @@ EffectGenerator* ScalarMapperEffectGenerator::copy() const
/// Modifies the supplied one line texture by adding two more pixel lines
/// one with a transparent version of the legend color, and one with color for undefined values
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::TextureImage>
ScalarMapperEffectGenerator::addAlphaAndUndefStripes(const cvf::TextureImage* texImg, const cvf::Color3f& undefScalarColor, float opacityLevel)
cvf::ref<cvf::TextureImage> ScalarMapperEffectGenerator::addAlphaAndUndefStripes( const cvf::TextureImage* texImg,
const cvf::Color3f& undefScalarColor,
float opacityLevel )
{
CVF_ASSERT( texImg != nullptr );
CVF_ASSERT( texImg->height() == 1 );
cvf::ref<cvf::TextureImage> modTexImg = new cvf::TextureImage;
modTexImg->allocate(texImg->width(), texImg->height() + 3); // Make the texture a power of two to avoid behind the scenes scaling and the following artefacts
modTexImg->allocate( texImg->width(), texImg->height() + 3 ); // Make the texture a power of two to avoid behind the
// scenes scaling and the following artefacts
modTexImg->fill( cvf::Color4ub( cvf::Color3ub( undefScalarColor ), 255 ) ); // Undefined color
for ( cvf::uint i = 0; i < texImg->width(); ++i )
@ -677,16 +680,17 @@ bool ScalarMapperEffectGenerator::isImagesEqual(const cvf::TextureImage* texImg1
{
if ( texImg1 == nullptr && texImg2 == nullptr ) return true;
if ( texImg1 != nullptr && texImg2 != nullptr
&& texImg1->height() == texImg2->height()
&& texImg1->width() == texImg2->width()
&& texImg1->width() > 0 && texImg1->height() > 0
&& texImg1->pixel(0,0) == texImg2->pixel(0,0)
&& texImg1->pixel( texImg1->width()-1, texImg1->height()-1) == texImg2->pixel(texImg1->width()-1, texImg1->height()-1)
&& texImg1->pixel( texImg1->width()/2, texImg1->height()/2) == texImg2->pixel(texImg1->width()/2, texImg1->height()/2)
&& texImg1->pixel( texImg1->width()/4, texImg1->height()/4) == texImg2->pixel(texImg1->width()/4, texImg1->height()/4)
&& texImg1->pixel( texImg1->width()/2 + texImg1->width()/4, texImg1->height()/2 + texImg1->height()/4) == texImg2->pixel(texImg1->width()/2 + texImg1->width()/4, texImg1->height()/2 + texImg1->height()/4 )
)
if ( texImg1 != nullptr && texImg2 != nullptr && texImg1->height() == texImg2->height() &&
texImg1->width() == texImg2->width() && texImg1->width() > 0 && texImg1->height() > 0 &&
texImg1->pixel( 0, 0 ) == texImg2->pixel( 0, 0 ) &&
texImg1->pixel( texImg1->width() - 1, texImg1->height() - 1 ) ==
texImg2->pixel( texImg1->width() - 1, texImg1->height() - 1 ) &&
texImg1->pixel( texImg1->width() / 2, texImg1->height() / 2 ) ==
texImg2->pixel( texImg1->width() / 2, texImg1->height() / 2 ) &&
texImg1->pixel( texImg1->width() / 4, texImg1->height() / 4 ) ==
texImg2->pixel( texImg1->width() / 4, texImg1->height() / 4 ) &&
texImg1->pixel( texImg1->width() / 2 + texImg1->width() / 4, texImg1->height() / 2 + texImg1->height() / 4 ) ==
texImg2->pixel( texImg1->width() / 2 + texImg1->width() / 4, texImg1->height() / 2 + texImg1->height() / 4 ) )
{
return true;
}
@ -694,16 +698,12 @@ bool ScalarMapperEffectGenerator::isImagesEqual(const cvf::TextureImage* texImg1
return false;
}
//==================================================================================================
//
// ScalarMapperMeshEffectGenerator
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -734,7 +734,8 @@ void ScalarMapperMeshEffectGenerator::updateForShaderBasedRendering(cvf::Effect*
m_textureImage = new cvf::TextureImage;
m_scalarMapper->updateTexture( m_textureImage.p() );
cvf::ref<cvf::TextureImage> modTexImg = ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_textureImage.p(), m_undefinedColor, m_opacityLevel);
cvf::ref<cvf::TextureImage> modTexImg =
ScalarMapperEffectGenerator::addAlphaAndUndefStripes( m_textureImage.p(), m_undefinedColor, m_opacityLevel );
cvf::ref<cvf::Texture> texture = new cvf::Texture( modTexImg.p() );
cvf::ref<cvf::Sampler> sampler = new cvf::Sampler;
@ -768,7 +769,8 @@ void ScalarMapperMeshEffectGenerator::updateForFixedFunctionRendering(cvf::Effec
m_textureImage = new cvf::TextureImage;
m_scalarMapper->updateTexture( m_textureImage.p() );
cvf::ref<cvf::TextureImage> modTexImg = ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_textureImage.p(), m_undefinedColor, m_opacityLevel);
cvf::ref<cvf::TextureImage> modTexImg =
ScalarMapperEffectGenerator::addAlphaAndUndefStripes( m_textureImage.p(), m_undefinedColor, m_opacityLevel );
cvf::ref<cvf::Texture2D_FF> texture = new cvf::Texture2D_FF( modTexImg.p() );
texture->setWrapMode( cvf::Texture2D_FF::CLAMP );
@ -782,7 +784,6 @@ void ScalarMapperMeshEffectGenerator::updateForFixedFunctionRendering(cvf::Effec
// Hardware independent:
updateCommonEffect( eff.p() );
}
//--------------------------------------------------------------------------------------------------
@ -802,19 +803,19 @@ void ScalarMapperMeshEffectGenerator::updateCommonEffect(cvf::Effect* effect) co
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool ScalarMapperMeshEffectGenerator::isEqual( const EffectGenerator* other ) const
{
const ScalarMapperMeshEffectGenerator* otherTextureResultEffect = dynamic_cast<const ScalarMapperMeshEffectGenerator*>(other);
const ScalarMapperMeshEffectGenerator* otherTextureResultEffect =
dynamic_cast<const ScalarMapperMeshEffectGenerator*>( other );
if ( otherTextureResultEffect )
{
if (m_scalarMapper.p() == otherTextureResultEffect->m_scalarMapper
&& m_opacityLevel == otherTextureResultEffect->m_opacityLevel
&& m_undefinedColor == otherTextureResultEffect->m_undefinedColor)
if ( m_scalarMapper.p() == otherTextureResultEffect->m_scalarMapper &&
m_opacityLevel == otherTextureResultEffect->m_opacityLevel &&
m_undefinedColor == otherTextureResultEffect->m_undefinedColor )
{
cvf::ref<cvf::TextureImage> texImg2 = new cvf::TextureImage;
otherTextureResultEffect->m_scalarMapper->updateTexture( texImg2.p() );
@ -839,7 +840,6 @@ EffectGenerator* ScalarMapperMeshEffectGenerator::copy() const
return scEffGen;
}
//==================================================================================================
//
// MeshEffectGenerator
@ -955,14 +955,11 @@ EffectGenerator* MeshEffectGenerator::copy() const
return effGen;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TextEffectGenerator::TextEffectGenerator()
{
}
//--------------------------------------------------------------------------------------------------
@ -1004,7 +1001,6 @@ void TextEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) con
//--------------------------------------------------------------------------------------------------
void TextEffectGenerator::updateForFixedFunctionRendering( cvf::Effect* effect ) const
{
}
//--------------------------------------------------------------------------------------------------
@ -1012,7 +1008,6 @@ void TextEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) c
//--------------------------------------------------------------------------------------------------
VectorEffectGenerator::VectorEffectGenerator()
{
}
//--------------------------------------------------------------------------------------------------
@ -1059,6 +1054,8 @@ void VectorEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) c
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void VectorEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) const {}
void VectorEffectGenerator::updateForFixedFunctionRendering( cvf::Effect* effect ) const
{
}
} // End namespace caf

View File

@ -34,33 +34,30 @@
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfEffect.h"
#include "cvfScalarMapper.h"
#include "cvfTextureImage.h"
#include "cvfCollection.h"
#include "cvfString.h"
#include "cvfEffect.h"
#include "cvfObject.h"
#include "cvfRenderStatePolygonOffset.h"
#include "cvfScalarMapper.h"
#include "cvfString.h"
#include "cvfTextureImage.h"
namespace cvf
{
class RenderStatePolygonOffset;
}
namespace caf {
namespace caf
{
class CommonShaderSources
{
public:
static cvf::String light_AmbientDiffuse();
};
// Enumerates different levels of polygon offsetting
enum PolygonOffset
{
@ -80,7 +77,6 @@ enum FaceCulling
FC_NONE
};
//==================================================================================================
//
//
@ -89,7 +85,11 @@ enum FaceCulling
class EffectGenerator
{
public:
enum RenderingModeType { FIXED_FUNCTION, SHADER_BASED };
enum RenderingModeType
{
FIXED_FUNCTION,
SHADER_BASED
};
EffectGenerator() {}
virtual ~EffectGenerator() {}
@ -104,10 +104,10 @@ public:
static void clearEffectCache();
static void releaseUnreferencedEffects();
static cvf::ref<cvf::RenderStatePolygonOffset> createAndConfigurePolygonOffsetRenderState(caf::PolygonOffset polygonOffset);
static cvf::ref<cvf::RenderStatePolygonOffset>
createAndConfigurePolygonOffsetRenderState( caf::PolygonOffset polygonOffset );
protected:
// Interface that must be implemented in base classes
virtual bool isEqual( const EffectGenerator* other ) const = 0;
virtual EffectGenerator* copy() const = 0;
@ -121,8 +121,6 @@ private:
static RenderingModeType sm_renderingMode;
};
//==================================================================================================
//
// SurfaceEffectGenerator
@ -161,7 +159,6 @@ private:
bool m_enableLighting;
};
//==================================================================================================
//
// ScalarMapperEffectGenerator
@ -180,7 +177,9 @@ public:
void discardTransparentFragments( bool discard ) { m_discardTransparentFragments = discard; }
public:
static cvf::ref<cvf::TextureImage> addAlphaAndUndefStripes(const cvf::TextureImage* texImg, const cvf::Color3f& undefScalarColor, float opacityLevel);
static cvf::ref<cvf::TextureImage> addAlphaAndUndefStripes( const cvf::TextureImage* texImg,
const cvf::Color3f& undefScalarColor,
float opacityLevel );
static bool isImagesEqual( const cvf::TextureImage* texImg1, const cvf::TextureImage* texImg2 );
protected:
@ -205,7 +204,6 @@ private:
bool m_discardTransparentFragments;
};
//==================================================================================================
//
// ScalarMapperMeshEffectGenerator
@ -236,7 +234,6 @@ private:
cvf::Color3f m_undefinedColor;
};
//==================================================================================================
//
// MeshEffectGenerator
@ -262,7 +259,6 @@ private:
float m_lineWidth;
};
//==================================================================================================
//
// TextEffectGenerator
@ -281,7 +277,6 @@ protected:
void updateForFixedFunctionRendering( cvf::Effect* effect ) const override;
};
//==================================================================================================
//
// VectorEffectGenerator
@ -299,4 +294,4 @@ protected:
void updateForShaderBasedRendering( cvf::Effect* effect ) const override;
void updateForFixedFunctionRendering( cvf::Effect* effect ) const override;
};
}
} // namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfTrace.h"
@ -42,9 +41,8 @@
#include "cafMessagePanel.h"
#include "cafUtils.h"
namespace caf {
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -53,7 +51,6 @@ void Log::info(const QString& msg)
infoMultiLine( msg, "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -62,7 +59,6 @@ void Log::warning(const QString& msg)
warningMultiLine( msg, "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -71,7 +67,6 @@ bool Log::error(const QString& err)
return errorMultiLine( err, "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -103,7 +98,6 @@ void Log::infoMultiLine(const QString& line1, const QString& line2Etc)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -135,7 +129,6 @@ void Log::warningMultiLine(const QString& line1, const QString& line2Etc)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -196,7 +189,6 @@ bool Log::errorMultiLine(const QString& line1, const QString& line2Etc)
return false;
}
// //--------------------------------------------------------------------------------------------------
// ///
// //--------------------------------------------------------------------------------------------------
@ -207,5 +199,4 @@ bool Log::errorMultiLine(const QString& line1, const QString& line2Etc)
//
// }
}
} // namespace caf

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
class QString;
namespace caf {
namespace caf
{
//==================================================================================================
//
//
@ -62,6 +60,4 @@ public:
static void pumpMessages();
};
}
} // namespace caf

View File

@ -34,17 +34,15 @@
//
//##################################################################################################
#include "cafMessagePanel.h"
#include <QWidget>
#include <QBoxLayout>
#include <QDockWidget>
#include <QTextEdit>
#include <QBoxLayout>
namespace caf {
#include <QWidget>
namespace caf
{
MessagePanel* MessagePanel::sm_messagePanelInstance = nullptr;
//==================================================================================================
@ -72,7 +70,6 @@ MessagePanel::MessagePanel(QDockWidget* parent)
sm_messagePanelInstance = this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -87,7 +84,6 @@ void MessagePanel::showInfo(QString info)
m_textEdit->append( str );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -102,7 +98,6 @@ void MessagePanel::showWarning(QString warn)
m_textEdit->append( str );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -117,7 +112,6 @@ void MessagePanel::showError(QString error)
m_textEdit->append( str );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -127,7 +121,6 @@ void MessagePanel::convertStringToHTML(QString* str)
str->replace( " ", "&nbsp;" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -137,7 +130,6 @@ QSize MessagePanel::sizeHint () const
return QSize( 20, 20 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -162,4 +154,4 @@ MessagePanel* MessagePanel::instance()
return sm_messagePanelInstance;
}
}
} // namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include <QWidget>
@ -42,9 +41,8 @@
class QDockWidget;
class QTextEdit;
namespace caf {
namespace caf
{
//==================================================================================================
//
//
@ -75,4 +73,4 @@ private:
QTextEdit* m_textEdit;
};
}
} // namespace caf

View File

@ -34,20 +34,17 @@
//
//##################################################################################################
#include "cafMouseState.h"
#include "cvfBase.h"
#include "cvfMath.h"
#include "cafMouseState.h"
#include <QMouseEvent>
#include <QGraphicsSceneMouseEvent>
#include <QMouseEvent>
#include <cmath>
namespace caf {
namespace caf
{
//==================================================================================================
///
/// \class cvfqt::QtMouseState
@ -68,7 +65,6 @@ QtMouseState::QtMouseState()
reset();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -78,7 +74,6 @@ void QtMouseState::updateFromMouseEvent(QMouseEvent* event)
m_mouseButtonState = event->buttons();
m_keyboardModifierFlags = event->modifiers();
// Now do the events themselves
// Mouse press events
@ -86,7 +81,8 @@ void QtMouseState::updateFromMouseEvent(QMouseEvent* event)
{
// Start by clearing them
m_cleanButtonPressButton = Qt::NoButton;
m_cleanButtonClickButton = Qt::NoButton;;
m_cleanButtonClickButton = Qt::NoButton;
;
m_cleanButtonPressPosX = cvf::UNDEFINED_INT;
m_cleanButtonPressPosY = cvf::UNDEFINED_INT;
@ -109,8 +105,7 @@ void QtMouseState::updateFromMouseEvent(QMouseEvent* event)
Qt::MouseButton buttonReleased = event->button();
// Check if we have a clean press/release sequence
if (m_cleanButtonPressButton == buttonReleased &&
m_cleanButtonPressPosX != cvf::UNDEFINED_INT &&
if ( m_cleanButtonPressButton == buttonReleased && m_cleanButtonPressPosX != cvf::UNDEFINED_INT &&
m_cleanButtonPressPosY != cvf::UNDEFINED_INT )
{
// We have a candidate, check if movement is within tolerance
@ -120,7 +115,8 @@ void QtMouseState::updateFromMouseEvent(QMouseEvent* event)
m_cleanButtonClickButton = buttonReleased;
}
m_cleanButtonPressButton = Qt::NoButton;;
m_cleanButtonPressButton = Qt::NoButton;
;
m_cleanButtonPressPosX = cvf::UNDEFINED_INT;
m_cleanButtonPressPosY = cvf::UNDEFINED_INT;
}
@ -132,8 +128,6 @@ void QtMouseState::updateFromMouseEvent(QMouseEvent* event)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -143,13 +137,13 @@ void QtMouseState::updateFromMouseEvent(QGraphicsSceneMouseEvent* event)
m_mouseButtonState = event->buttons();
m_keyboardModifierFlags = event->modifiers();
// Now do the events themselves
if ( event->type() == QEvent::GraphicsSceneMousePress )
{
// Start by clearing them
m_cleanButtonPressButton = Qt::NoButton;
m_cleanButtonClickButton = Qt::NoButton;;
m_cleanButtonClickButton = Qt::NoButton;
;
m_cleanButtonPressPosX = cvf::UNDEFINED_INT;
m_cleanButtonPressPosY = cvf::UNDEFINED_INT;
@ -172,18 +166,20 @@ void QtMouseState::updateFromMouseEvent(QGraphicsSceneMouseEvent* event)
Qt::MouseButton buttonReleased = event->button();
// Check if we have a clean press/release sequence
if (m_cleanButtonPressButton == buttonReleased &&
m_cleanButtonPressPosX != cvf::UNDEFINED_INT &&
if ( m_cleanButtonPressButton == buttonReleased && m_cleanButtonPressPosX != cvf::UNDEFINED_INT &&
m_cleanButtonPressPosY != cvf::UNDEFINED_INT )
{
// We have a candidate, check if movement is within tolerance
if (cvf::Math::abs(double((m_cleanButtonPressPosX - event->scenePos().x()))) <= m_cleanButtonClickTolerance &&
cvf::Math::abs(double((m_cleanButtonPressPosY - event->scenePos().y()))) <= m_cleanButtonClickTolerance)
if ( cvf::Math::abs( double( ( m_cleanButtonPressPosX - event->scenePos().x() ) ) ) <=
m_cleanButtonClickTolerance &&
cvf::Math::abs( double( ( m_cleanButtonPressPosY - event->scenePos().y() ) ) ) <=
m_cleanButtonClickTolerance )
{
m_cleanButtonClickButton = buttonReleased;
}
m_cleanButtonPressButton = Qt::NoButton;;
m_cleanButtonPressButton = Qt::NoButton;
;
m_cleanButtonPressPosX = cvf::UNDEFINED_INT;
m_cleanButtonPressPosY = cvf::UNDEFINED_INT;
}
@ -208,7 +204,6 @@ void QtMouseState::reset()
m_cleanButtonClickButton = Qt::NoButton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -217,7 +212,6 @@ Qt::MouseButtons QtMouseState::mouseButtonState() const
return m_mouseButtonState;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -226,7 +220,6 @@ Qt::KeyboardModifiers QtMouseState::keyboardModifierFlags() const
return m_keyboardModifierFlags;
}
//--------------------------------------------------------------------------------------------------
/// Get button that was cleanly clicked if any
//--------------------------------------------------------------------------------------------------
@ -235,7 +228,6 @@ Qt::MouseButton QtMouseState::cleanButtonClickButton() const
return m_cleanButtonClickButton;
}
//--------------------------------------------------------------------------------------------------
/// Static helper function to determine the number of mouse buttons pressed
//--------------------------------------------------------------------------------------------------
@ -250,7 +242,4 @@ int QtMouseState::numMouseButtonsInState(Qt::MouseButtons buttonState)
return iNum;
}
} // namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
class QMouseEvent;
@ -42,8 +41,8 @@ class QGraphicsSceneMouseEvent;
#include <Qt>
namespace caf {
namespace caf
{
//==================================================================================================
//
// Helper class for storing mouse positions and button states. Should be reset whenever widget looses focus.
@ -67,15 +66,18 @@ public:
private:
Qt::MouseButtons m_mouseButtonState; // Stores current mouse button state (combination of mouse buttons that are down)
Qt::KeyboardModifiers m_keyboardModifierFlags; // Stores current keyboard modifier flags (combination of keyboard modifier keys that are down)
Qt::KeyboardModifiers m_keyboardModifierFlags; // Stores current keyboard modifier flags (combination of keyboard
// modifier keys that are down)
int m_cleanButtonClickTolerance; // The movement tolerance in pixels for considering a mouse button press/release sequence a clean button click
Qt::MouseButton m_cleanButtonPressButton; // The mouse button that was last pressed 'cleanly', that is without any other mouse buttons down. Used to detect clean button clicks (for showing context menus etc)
int m_cleanButtonPressPosX; // The position of the mouse cursor in widget coordinates of the last clean button press. Used to check if cursor has moved when button is released
int m_cleanButtonClickTolerance; // The movement tolerance in pixels for considering a mouse button press/release
// sequence a clean button click
Qt::MouseButton m_cleanButtonPressButton; // The mouse button that was last pressed 'cleanly', that is without any
// other mouse buttons down. Used to detect clean button clicks (for
// showing context menus etc)
int m_cleanButtonPressPosX; // The position of the mouse cursor in widget coordinates of the last clean button
// press. Used to check if cursor has moved when button is released
int m_cleanButtonPressPosY; //
Qt::MouseButton m_cleanButtonClickButton; // The button (if any) that was last clicked 'cleanly'.
};
}
} // namespace caf

View File

@ -35,10 +35,9 @@
//##################################################################################################
#pragma once
#include <vector>
#include <cmath>
#include "cafAssert.h"
#include <cmath>
#include <vector>
namespace caf
{
@ -129,6 +128,4 @@ private:
std::vector<double> m_tickMarkValues;
};
}
} // namespace caf

View File

@ -34,11 +34,10 @@
//
//##################################################################################################
#include "cafUtils.h"
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QLineEdit>
@ -47,9 +46,8 @@
#include <QFileDialog>
#include <QMessageBox>
namespace caf {
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -70,7 +68,6 @@ double Utils::editToDouble(QLineEdit* lineEdit, double defaultVal)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -83,15 +80,13 @@ QString Utils::absoluteFileName(const QString& fileName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList Utils::getFilesInDirectory(const QString& dirPath,
const QString& nameFilter,
bool getAbsoluteFileNames)
QStringList Utils::getFilesInDirectory( const QString& dirPath, const QString& nameFilter, bool getAbsoluteFileNames )
{
QStringList nameFilters; nameFilters << nameFilter;
QStringList nameFilters;
nameFilters << nameFilter;
return getFilesInDirectory( dirPath, nameFilters, getAbsoluteFileNames );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -136,7 +131,6 @@ QString Utils::constructFullFileName(const QString& folder, const QString& baseF
return fullFileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -158,7 +152,6 @@ QString Utils::makeValidFileBasename(const QString& fileBasenameCandidate)
cleanBasename.replace( "*", "_" );
cleanBasename.replace( "\n", "_" );
cleanBasename.replace( QRegExp( "_+" ), "_" );
return cleanBasename;
@ -212,7 +205,6 @@ bool Utils::getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, st
}
msgBox.setText( message );
msgBox.setInformativeText( "Do you want to continue?" );
msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
msgBox.setDefaultButton( QMessageBox::Ok );
@ -230,13 +222,11 @@ bool Utils::getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, st
// should never be reached
break;
}
}
return overWriteFiles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -286,8 +276,10 @@ bool Utils::isStringMatch(const QString& filterString, const QString& value)
if ( filterString.isEmpty() ) return true;
if ( filterString.trimmed() == "*" )
{
if (!value.isEmpty()) return true;
else return false;
if ( !value.isEmpty() )
return true;
else
return false;
}
QRegExp searcher( filterString, Qt::CaseInsensitive, QRegExp::WildcardUnix );
@ -305,7 +297,8 @@ bool Utils::removeDirectoryAndFilesRecursively(const QString& dirName)
if ( dir.exists() )
{
QFileInfoList fileInfoList =
dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst);
dir.entryInfoList( QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files,
QDir::DirsFirst );
for ( const auto& fileInfo : fileInfoList )
{
if ( fileInfo.isDir() )

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include <vector>
@ -43,8 +42,8 @@ class QLineEdit;
class QString;
class QStringList;
namespace caf {
namespace caf
{
//==================================================================================================
//
//
@ -57,13 +56,16 @@ public:
static QString absoluteFileName( const QString& fileName );
static QStringList getFilesInDirectory( const QString& dirPath, const QString& nameFilter, bool getAbsoluteFileNames );
static QStringList getFilesInDirectory(const QString& dirPath, const QStringList& nameFilters, bool getAbsoluteFileNames);
static QStringList
getFilesInDirectory( const QString& dirPath, const QStringList& nameFilters, bool getAbsoluteFileNames );
static QString constructFullFileName( const QString& folder, const QString& baseFileName, const QString& extension );
static QString makeValidFileBasename( const QString& fileBasenameCandidate );
static QString indentString( int numSpacesToIndent, const QString& str );
static bool getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector<QString> fileNames, QString* saveDir);
static bool getSaveDirectoryAndCheckOverwriteFiles( const QString& defaultDir,
std::vector<QString> fileNames,
QString* saveDir );
static bool fileExists( const QString& fileName );
static QString fileExtension( const QString& fileName );
@ -73,4 +75,4 @@ public:
static bool removeDirectoryAndFilesRecursively( const QString& dirName );
};
}
} // namespace caf

View File

@ -36,8 +36,8 @@
#include "cafVecIjk.h"
namespace caf {
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
#include <array>
namespace caf
{
class VecIjk
{
public:
@ -55,5 +53,4 @@ private:
std::array<size_t, 3> m_values;
};
}
} // namespace caf

View File

@ -34,14 +34,10 @@
//
//##################################################################################################
#include "cvfCellRange.h"
namespace cvf {
namespace cvf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -135,6 +131,4 @@ bool CellRange::isInRange(size_t i, size_t j, size_t k) const
return true;
}
} // namespace cvf

View File

@ -34,15 +34,13 @@
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfVector3.h"
namespace cvf {
namespace cvf
{
//==================================================================================================
//
//==================================================================================================
@ -65,5 +63,4 @@ private:
cvf::Vec3st m_max;
};
} // End namespace cvf

View File

@ -34,10 +34,8 @@
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGrid.h"
#include "cvfBase.h"
namespace caf
{
@ -52,13 +50,10 @@ namespace caf
addItem( cvf::StructGridInterface::NEG_K, "NEG K", "" );
addItem( cvf::StructGridInterface::NO_FACE, "UnDef", "" );
}
}
namespace cvf {
} // namespace caf
namespace cvf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -167,12 +162,24 @@ StructGridInterface::FaceType StructGridInterface::oppositeFace(FaceType face)
switch ( face )
{
case NEG_I : opposite = POS_I; break;
case POS_I : opposite = NEG_I; break;
case NEG_J : opposite = POS_J; break;
case POS_J : opposite = NEG_J; break;
case NEG_K : opposite = POS_K; break;
case POS_K : opposite = NEG_K; break;
case NEG_I:
opposite = POS_I;
break;
case POS_I:
opposite = NEG_I;
break;
case NEG_J:
opposite = POS_J;
break;
case POS_J:
opposite = NEG_J;
break;
case NEG_K:
opposite = POS_K;
break;
case POS_K:
opposite = NEG_K;
break;
default:
opposite = POS_I;
CVF_ASSERT( false );
@ -192,18 +199,38 @@ void StructGridInterface::neighborIJKAtCellFace(size_t i, size_t j, size_t k, Fa
switch ( face )
{
case POS_I : (*ni)++; break;
case NEG_I : if (i > 0) (*ni)--; else (*ni) = cvf::UNDEFINED_SIZE_T; break;
case POS_J : (*nj)++; break;
case NEG_J : if (j > 0) (*nj)--; else (*nj) = cvf::UNDEFINED_SIZE_T; break;
case POS_K : (*nk)++; break;
case NEG_K : if (k > 0) (*nk)--; else (*nk) = cvf::UNDEFINED_SIZE_T; break;
case POS_I:
( *ni )++;
break;
case NEG_I:
if ( i > 0 )
( *ni )--;
else
( *ni ) = cvf::UNDEFINED_SIZE_T;
break;
case POS_J:
( *nj )++;
break;
case NEG_J:
if ( j > 0 )
( *nj )--;
else
( *nj ) = cvf::UNDEFINED_SIZE_T;
break;
case POS_K:
( *nk )++;
break;
case NEG_K:
if ( k > 0 )
( *nk )--;
else
( *nk ) = cvf::UNDEFINED_SIZE_T;
break;
default:
break;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -249,11 +276,9 @@ void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize,
{
CVF_ASSERT( iSize && jSize && kSize );
if (m_characteristicCellSizeI == cvf::UNDEFINED_DOUBLE
|| m_characteristicCellSizeJ == cvf::UNDEFINED_DOUBLE
|| m_characteristicCellSizeK == cvf::UNDEFINED_DOUBLE)
if ( m_characteristicCellSizeI == cvf::UNDEFINED_DOUBLE || m_characteristicCellSizeJ == cvf::UNDEFINED_DOUBLE ||
m_characteristicCellSizeK == cvf::UNDEFINED_DOUBLE )
{
ubyte faceConnPosI[4];
cellFaceVertexIndices( StructGridInterface::POS_I, faceConnPosI );
@ -293,20 +318,32 @@ void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize,
size_t cellIndex = cellIndexFromIJK( i, j, k );
cellCornerVertices( cellIndex, cornerVerts );
iLengthAccumulated += (cornerVerts[faceConnPosI[0]] - cornerVerts[faceConnNegI[0]]).lengthSquared();
iLengthAccumulated += (cornerVerts[faceConnPosI[1]] - cornerVerts[faceConnNegI[3]]).lengthSquared();
iLengthAccumulated += (cornerVerts[faceConnPosI[2]] - cornerVerts[faceConnNegI[2]]).lengthSquared();
iLengthAccumulated += (cornerVerts[faceConnPosI[3]] - cornerVerts[faceConnNegI[1]]).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[0]] - cornerVerts[faceConnNegI[0]] ).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[1]] - cornerVerts[faceConnNegI[3]] ).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[2]] - cornerVerts[faceConnNegI[2]] ).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[3]] - cornerVerts[faceConnNegI[1]] ).lengthSquared();
jLengthAccumulated += (cornerVerts[faceConnPosJ[0]] - cornerVerts[faceConnNegJ[0]]).lengthSquared();
jLengthAccumulated += (cornerVerts[faceConnPosJ[1]] - cornerVerts[faceConnNegJ[3]]).lengthSquared();
jLengthAccumulated += (cornerVerts[faceConnPosJ[2]] - cornerVerts[faceConnNegJ[2]]).lengthSquared();
jLengthAccumulated += (cornerVerts[faceConnPosJ[3]] - cornerVerts[faceConnNegJ[1]]).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[0]] - cornerVerts[faceConnNegJ[0]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[1]] - cornerVerts[faceConnNegJ[3]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[2]] - cornerVerts[faceConnNegJ[2]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[3]] - cornerVerts[faceConnNegJ[1]] ).lengthSquared();
kLengthAccumulated += (cornerVerts[faceConnPosK[0]] - cornerVerts[faceConnNegK[0]]).lengthSquared();
kLengthAccumulated += (cornerVerts[faceConnPosK[1]] - cornerVerts[faceConnNegK[3]]).lengthSquared();
kLengthAccumulated += (cornerVerts[faceConnPosK[2]] - cornerVerts[faceConnNegK[2]]).lengthSquared();
kLengthAccumulated += (cornerVerts[faceConnPosK[3]] - cornerVerts[faceConnNegK[1]]).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[0]] - cornerVerts[faceConnNegK[0]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[1]] - cornerVerts[faceConnNegK[3]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[2]] - cornerVerts[faceConnNegK[2]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[3]] - cornerVerts[faceConnNegK[1]] ).lengthSquared();
cellCount++;
}
@ -329,5 +366,4 @@ void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize,
*kSize = m_characteristicCellSizeK;
}
} // namespace cvf

View File

@ -34,19 +34,16 @@
//
//##################################################################################################
#pragma once
#include <cstddef>
#include "cvfObject.h"
#include "cvfVector3.h"
#include <cstddef>
#include "cafAppEnum.h"
namespace cvf {
namespace cvf
{
class CellFilterBase;
// Navneforslag
@ -69,7 +66,6 @@ public:
typedef caf::AppEnum<StructGridInterface::FaceType> FaceEnum;
enum class GridAxisType
{
AXIS_I,
@ -111,11 +107,16 @@ public:
virtual size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const = 0;
virtual cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const = 0;
public:
static void cellFaceVertexIndices( FaceType face, cvf::ubyte vertexIndices[4] );
static FaceType oppositeFace( FaceType face );
static void neighborIJKAtCellFace(size_t i, size_t j, size_t k, StructGridInterface::FaceType face, size_t* ni, size_t* nj, size_t* nk);
static void neighborIJKAtCellFace( size_t i,
size_t j,
size_t k,
StructGridInterface::FaceType face,
size_t* ni,
size_t* nj,
size_t* nk );
static GridAxisType gridAxisFromFace( FaceType face );

View File

@ -34,30 +34,27 @@
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGrid.h"
#include "cvfStructGridCutPlane.h"
#include "cvfStructGridScalarDataAccess.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfDebugTimer.h"
#include "cvfPlane.h"
#include "cvfScalarMapper.h"
#include "cvfEdgeKey.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfMeshEdgeExtractor.h"
#include "cvfPlane.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfScalarMapper.h"
#include <map>
#include <cstring>
#include <map>
#include <math.h>
namespace cvf {
namespace cvf
{
//==================================================================================================
///
/// \class cvf::StructGridCutPlane
@ -71,44 +68,24 @@ namespace cvf {
// http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
const uint StructGridCutPlane::sm_edgeTable[256] =
{
0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0
};
{0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0};
const int StructGridCutPlane::sm_triTable[256][16] =
{
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
const int StructGridCutPlane::sm_triTable[256][16] = {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
@ -363,24 +340,21 @@ const int StructGridCutPlane::sm_triTable[256][16] =
{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
StructGridCutPlane::StructGridCutPlane( const StructGridInterface* grid )
: m_grid(grid),
m_mapScalarSetIndex(UNDEFINED_UINT),
m_scalarMapper(NULL),
m_mapNodeAveragedScalars(false),
m_mustRecompute(true)
: m_grid( grid )
, m_mapScalarSetIndex( UNDEFINED_UINT )
, m_scalarMapper( NULL )
, m_mapNodeAveragedScalars( false )
, m_mustRecompute( true )
{
CVF_ASSERT( grid );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -388,7 +362,6 @@ StructGridCutPlane::~StructGridCutPlane()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -399,7 +372,6 @@ void StructGridCutPlane::setPlane(const Plane& plane)
m_mustRecompute = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -414,7 +386,6 @@ void StructGridCutPlane::setMapScalar(uint scalarSetIndex, const ScalarMapper* m
m_mustRecompute = true;
}
//--------------------------------------------------------------------------------------------------
/// Generate cut plane geometry from current configuration
///
@ -446,14 +417,14 @@ ref<DrawableGeo> StructGridCutPlane::generateSurface(const cvf::StructGridScalar
doMapScalar = true;
}
ref<Vec3fArray> vertexArr = new Vec3fArray( m_vertices );
ref<UIntArray> indices = new UIntArray( m_triangleIndices );
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt( PT_TRIANGLES );
primSet->setIndices( indices.p() );
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;;
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
;
geo->setVertexArray( vertexArr.p() );
geo->addPrimitiveSet( primSet.p() );
@ -479,12 +450,12 @@ ref<DrawableGeo> StructGridCutPlane::generateSurface(const cvf::StructGridScalar
geo->setTextureCoordArray( textureCoords.p() );
}
//Trace::show("generateSurface(): Vertices:%d TriConns:%d Tris:%d", vertexArr->size(), indices->size(), indices->size()/3);
// Trace::show("generateSurface(): Vertices:%d TriConns:%d Tris:%d", vertexArr->size(), indices->size(),
// indices->size()/3);
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -512,16 +483,17 @@ ref<DrawableGeo> StructGridCutPlane::generateMesh(const cvf::StructGridScalarDat
ref<Vec3fArray> vertexArr = new Vec3fArray( m_vertices );
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;;
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
;
geo->setVertexArray( vertexArr.p() );
geo->addPrimitiveSet( primSet.p() );
//Trace::show("generateMesh(): Vertices:%d LineConns:%d Lines:%d", vertexArr->size(), indices->size(), indices->size()/2);
// Trace::show("generateMesh(): Vertices:%d LineConns:%d Lines:%d", vertexArr->size(), indices->size(),
// indices->size()/2);
return geo;
}
//--------------------------------------------------------------------------------------------------
/// Generate surface representation of the specified cut plane
///
@ -549,7 +521,6 @@ void StructGridCutPlane::computeCutPlane(const cvf::StructGridScalarDataAccess*
m_triangleIndices.clear();
m_meshLineIndices.clear();
// The indexing conventions for vertices and
// edges used in the algorithm:
// edg verts
@ -567,7 +538,6 @@ void StructGridCutPlane::computeCutPlane(const cvf::StructGridScalarDataAccess*
// vertex indices edge indices 11 3 - 7
//
size_t k;
for ( k = 0; k < cellCountK; k++ )
{
@ -627,14 +597,14 @@ void StructGridCutPlane::computeCutPlane(const cvf::StructGridScalarDataAccess*
cell.p[6].set( maxCoord.x(), minCoord.y(), maxCoord.z() );
cell.p[7].set( minCoord.x(), minCoord.y(), maxCoord.z() );
// Fetch scalar values
double cellScalarValue = 0;
if ( doMapScalar )
{
cellScalarValue = dataAccessObject->cellScalar( cellIndex );
// If we're doing node averaging we must populate grid cell with scalar values interpolated to the grid points
// If we're doing node averaging we must populate grid cell with scalar values interpolated to the
// grid points
if ( m_mapNodeAveragedScalars )
{
CVF_ASSERT( false ); // This is not supported in this code.
@ -677,7 +647,6 @@ void StructGridCutPlane::computeCutPlane(const cvf::StructGridScalarDataAccess*
}
}
Triangles triangles;
uint numTriangles = polygonise( m_plane, cell, &triangles );
if ( numTriangles > 0 )
@ -728,11 +697,10 @@ void StructGridCutPlane::computeCutPlane(const cvf::StructGridScalarDataAccess*
}
}
// Trace::show("Vertices:%d TriConns:%d Tris:%d", m_vertices.size(), m_triangleIndices.size(), m_triangleIndices.size()/3);
// tim.reportTimeMS("computeCutPlane()");
// Trace::show("Vertices:%d TriConns:%d Tris:%d", m_vertices.size(), m_triangleIndices.size(),
// m_triangleIndices.size()/3); tim.reportTimeMS("computeCutPlane()");
}
//--------------------------------------------------------------------------------------------------
/// Add mesh line indices by analyzing the triangle indices and only adding 'unique' edges
//--------------------------------------------------------------------------------------------------
@ -773,7 +741,6 @@ void StructGridCutPlane::addMeshLineIndices(const uint* triangleIndices, uint tr
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -795,19 +762,42 @@ uint StructGridCutPlane::polygonise(const Plane& plane, const GridCell& cell, Tr
}
// Compute vertex coordinates on the edges where we have intersections
if (sm_edgeTable[cubeindex] & 1) triangles->vertices[0] = planeLineIntersection(plane, cell.p[0], cell.p[1], cell.s[0], cell.s[1], &triangles->scalars[0] );
if (sm_edgeTable[cubeindex] & 2) triangles->vertices[1] = planeLineIntersection(plane, cell.p[1], cell.p[2], cell.s[1], cell.s[2], &triangles->scalars[1] );
if (sm_edgeTable[cubeindex] & 4) triangles->vertices[2] = planeLineIntersection(plane, cell.p[2], cell.p[3], cell.s[2], cell.s[3], &triangles->scalars[2] );
if (sm_edgeTable[cubeindex] & 8) triangles->vertices[3] = planeLineIntersection(plane, cell.p[3], cell.p[0], cell.s[3], cell.s[0], &triangles->scalars[3] );
if (sm_edgeTable[cubeindex] & 16) triangles->vertices[4] = planeLineIntersection(plane, cell.p[4], cell.p[5], cell.s[4], cell.s[5], &triangles->scalars[4] );
if (sm_edgeTable[cubeindex] & 32) triangles->vertices[5] = planeLineIntersection(plane, cell.p[5], cell.p[6], cell.s[5], cell.s[6], &triangles->scalars[5] );
if (sm_edgeTable[cubeindex] & 64) triangles->vertices[6] = planeLineIntersection(plane, cell.p[6], cell.p[7], cell.s[6], cell.s[7], &triangles->scalars[6] );
if (sm_edgeTable[cubeindex] & 128) triangles->vertices[7] = planeLineIntersection(plane, cell.p[7], cell.p[4], cell.s[7], cell.s[4], &triangles->scalars[7] );
if (sm_edgeTable[cubeindex] & 256) triangles->vertices[8] = planeLineIntersection(plane, cell.p[0], cell.p[4], cell.s[0], cell.s[4], &triangles->scalars[8] );
if (sm_edgeTable[cubeindex] & 512) triangles->vertices[9] = planeLineIntersection(plane, cell.p[1], cell.p[5], cell.s[1], cell.s[5], &triangles->scalars[9] );
if (sm_edgeTable[cubeindex] & 1024) triangles->vertices[10] = planeLineIntersection(plane, cell.p[2], cell.p[6], cell.s[2], cell.s[6], &triangles->scalars[10]);
if (sm_edgeTable[cubeindex] & 2048) triangles->vertices[11] = planeLineIntersection(plane, cell.p[3], cell.p[7], cell.s[3], cell.s[7], &triangles->scalars[11]);
if ( sm_edgeTable[cubeindex] & 1 )
triangles->vertices[0] =
planeLineIntersection( plane, cell.p[0], cell.p[1], cell.s[0], cell.s[1], &triangles->scalars[0] );
if ( sm_edgeTable[cubeindex] & 2 )
triangles->vertices[1] =
planeLineIntersection( plane, cell.p[1], cell.p[2], cell.s[1], cell.s[2], &triangles->scalars[1] );
if ( sm_edgeTable[cubeindex] & 4 )
triangles->vertices[2] =
planeLineIntersection( plane, cell.p[2], cell.p[3], cell.s[2], cell.s[3], &triangles->scalars[2] );
if ( sm_edgeTable[cubeindex] & 8 )
triangles->vertices[3] =
planeLineIntersection( plane, cell.p[3], cell.p[0], cell.s[3], cell.s[0], &triangles->scalars[3] );
if ( sm_edgeTable[cubeindex] & 16 )
triangles->vertices[4] =
planeLineIntersection( plane, cell.p[4], cell.p[5], cell.s[4], cell.s[5], &triangles->scalars[4] );
if ( sm_edgeTable[cubeindex] & 32 )
triangles->vertices[5] =
planeLineIntersection( plane, cell.p[5], cell.p[6], cell.s[5], cell.s[6], &triangles->scalars[5] );
if ( sm_edgeTable[cubeindex] & 64 )
triangles->vertices[6] =
planeLineIntersection( plane, cell.p[6], cell.p[7], cell.s[6], cell.s[7], &triangles->scalars[6] );
if ( sm_edgeTable[cubeindex] & 128 )
triangles->vertices[7] =
planeLineIntersection( plane, cell.p[7], cell.p[4], cell.s[7], cell.s[4], &triangles->scalars[7] );
if ( sm_edgeTable[cubeindex] & 256 )
triangles->vertices[8] =
planeLineIntersection( plane, cell.p[0], cell.p[4], cell.s[0], cell.s[4], &triangles->scalars[8] );
if ( sm_edgeTable[cubeindex] & 512 )
triangles->vertices[9] =
planeLineIntersection( plane, cell.p[1], cell.p[5], cell.s[1], cell.s[5], &triangles->scalars[9] );
if ( sm_edgeTable[cubeindex] & 1024 )
triangles->vertices[10] =
planeLineIntersection( plane, cell.p[2], cell.p[6], cell.s[2], cell.s[6], &triangles->scalars[10] );
if ( sm_edgeTable[cubeindex] & 2048 )
triangles->vertices[11] =
planeLineIntersection( plane, cell.p[3], cell.p[7], cell.s[3], cell.s[7], &triangles->scalars[11] );
// Create the triangles
memset( triangles->usedVertices, 0, sizeof( triangles->usedVertices ) );
@ -825,11 +815,15 @@ uint StructGridCutPlane::polygonise(const Plane& plane, const GridCell& cell, Tr
return numTriangles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Vec3d StructGridCutPlane::planeLineIntersection(const Plane& plane, const Vec3d& p1, const Vec3d& p2, const double s1, const double s2, double* s)
Vec3d StructGridCutPlane::planeLineIntersection( const Plane& plane,
const Vec3d& p1,
const Vec3d& p2,
const double s1,
const double s2,
double* s )
{
// From http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/
//
@ -875,7 +869,6 @@ Vec3d StructGridCutPlane::planeLineIntersection(const Plane& plane, const Vec3d&
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -938,6 +931,4 @@ void StructGridCutPlane::setClippingBoundingBox(const BoundingBox& boundingBox)
m_clippingBoundingBox = boundingBox;
}
} // namespace cvf

View File

@ -34,22 +34,20 @@
//
//##################################################################################################
#pragma once
#include "cvfPlane.h"
#include "cvfBoundingBox.h"
#include "cvfPlane.h"
#include <vector>
namespace cvf {
namespace cvf
{
class DrawableGeo;
class StructGridInterface;
class ScalarMapper;
class StructGridScalarDataAccess;
//==================================================================================================
//
//
@ -79,7 +77,8 @@ private:
{
Vec3d vertices[12]; // The vertices, one on each edge in the cell
double scalars[12]; // Interpolated scalar values for the vertices
bool usedVertices[12]; // Flag to indicate which of the vertices (and scalars) are being referenced by the triangle indices
bool usedVertices[12]; // Flag to indicate which of the vertices (and scalars) are being referenced by the
// triangle indices
int triangleIndices[15]; // Triangle indices (into vertices), max 5 triangles.
};
@ -87,7 +86,12 @@ private:
void computeCutPlane( const cvf::StructGridScalarDataAccess* dataAccessObject );
void addMeshLineIndices( const uint* triangleIndices, uint triangleCount );
static uint polygonise( const Plane& plane, const GridCell& cell, Triangles* triangles );
static Vec3d planeLineIntersection(const Plane& plane, const Vec3d& p1, const Vec3d& p2, const double s1, const double s2, double* s);
static Vec3d planeLineIntersection( const Plane& plane,
const Vec3d& p1,
const Vec3d& p2,
const double s1,
const double s2,
double* s );
static bool isCellIntersectedByPlane( const Plane& plane, const Vec3d& cellMinCoord, const Vec3d& cellMaxCoord );
private:
@ -97,8 +101,10 @@ private:
BoundingBox m_clippingBoundingBox;
uint m_mapScalarSetIndex; // Index of scalar set that should be mapped onto the cut plane. -1 for no mapping
cref<ScalarMapper> m_scalarMapper; // Scalar mapper to use when mapping. Both scalar set index and mapper must be set in order to get scalar mapping
bool m_mapNodeAveragedScalars; // If true we'll compute node averaged scalars before mapping them on the cut plane. If false per cell scalars will be mapped.
cref<ScalarMapper> m_scalarMapper; // Scalar mapper to use when mapping. Both scalar set index and mapper must be
// set in order to get scalar mapping
bool m_mapNodeAveragedScalars; // If true we'll compute node averaged scalars before mapping them on the cut plane.
// If false per cell scalars will be mapped.
bool m_mustRecompute; // Flag to indicate that cut plane must be recomputed
std::vector<Vec3f> m_vertices; // Vertices of computed surface
@ -110,4 +116,4 @@ private:
static const int sm_triTable[256][16];
};
}
} // namespace cvf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGrid.h"
@ -50,29 +49,31 @@
#include "cvfOutlineEdgeExtractor.h"
#include <cmath>
namespace cvf {
namespace cvf
{
//==================================================================================================
///
/// \class CellRangeFilter
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CellRangeFilter::CellRangeFilter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CellRangeFilter::addCellIncludeRange(size_t minI, size_t minJ, size_t minK, size_t maxI, size_t maxJ, size_t maxK, bool applyToSubGridAreas)
void CellRangeFilter::addCellIncludeRange( size_t minI,
size_t minJ,
size_t minK,
size_t maxI,
size_t maxJ,
size_t maxK,
bool applyToSubGridAreas )
{
m_includeRanges.push_back( CellRange( minI, minJ, minK, maxI, maxJ, maxK, applyToSubGridAreas ) );
}
@ -88,7 +89,13 @@ void CellRangeFilter::addCellInclude(size_t i, size_t j, size_t k, bool applyToS
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CellRangeFilter::addCellExcludeRange(size_t minI, size_t minJ, size_t minK, size_t maxI, size_t maxJ, size_t maxK, bool applyToSubGridAreas)
void CellRangeFilter::addCellExcludeRange( size_t minI,
size_t minJ,
size_t minK,
size_t maxI,
size_t maxJ,
size_t maxK,
bool applyToSubGridAreas )
{
m_excludeRanges.push_back( CellRange( minI, minJ, minK, maxI, maxJ, maxK, applyToSubGridAreas ) );
}
@ -131,7 +138,6 @@ bool CellRangeFilter::isCellVisible(size_t i, size_t j, size_t k, bool isInSubGr
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -153,13 +159,12 @@ bool CellRangeFilter::isCellExcluded(size_t i, size_t j, size_t k, bool isInSubG
//--------------------------------------------------------------------------------------------------
bool CellRangeFilter::hasIncludeRanges() const
{
if (m_includeRanges.size() > 0) return true;
else return false;
if ( m_includeRanges.size() > 0 )
return true;
else
return false;
}
//==================================================================================================
///
/// \class cvf::StructGridGeometry
@ -173,15 +178,14 @@ bool CellRangeFilter::hasIncludeRanges() const
///
//--------------------------------------------------------------------------------------------------
StructGridGeometryGenerator::StructGridGeometryGenerator( const StructGridInterface* grid, bool useOpenMP )
: m_grid(grid),
m_useOpenMP(useOpenMP)
: m_grid( grid )
, m_useOpenMP( useOpenMP )
{
CVF_ASSERT( grid );
m_quadMapper = new StructGridQuadToCellFaceMapper;
m_triangleMapper = new StuctGridTriangleToCellFaceMapper( m_quadMapper.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -189,7 +193,6 @@ StructGridGeometryGenerator::~StructGridGeometryGenerator()
{
}
//--------------------------------------------------------------------------------------------------
/// Generate surface drawable geo from the specified region
///
@ -208,15 +211,12 @@ ref<DrawableGeo> StructGridGeometryGenerator::generateSurface()
return geo;
}
//--------------------------------------------------------------------------------------------------
/// Generates simplified mesh as line drawing
/// Must call generateSurface first
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawable()
{
if ( !( m_vertices.notNull() && m_vertices->size() != 0 ) ) return nullptr;
ref<DrawableGeo> geo = new DrawableGeo;
@ -230,8 +230,6 @@ ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawable()
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -266,9 +264,7 @@ ref<DrawableGeo> StructGridGeometryGenerator::createOutlineMeshDrawable(double c
ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell( const StructGridInterface* grid,
size_t cellIndex )
{
return createMeshDrawableFromSingleCell(grid,
cellIndex,
grid->displayModelOffset());
return createMeshDrawableFromSingleCell( grid, cellIndex, grid->displayModelOffset() );
}
//--------------------------------------------------------------------------------------------------
@ -355,8 +351,6 @@ void StructGridGeometryGenerator::addFaceVisibilityFilter(const CellFaceVisibili
m_cellVisibilityFilters.push_back( cellVisibilityFilter );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -404,12 +398,18 @@ void StructGridGeometryGenerator::computeArrays()
std::vector<StructGridInterface::FaceType> visibleFaces;
visibleFaces.reserve( 6 );
if (isCellFaceVisible(i, j, k, StructGridInterface::NEG_I)) visibleFaces.push_back(cvf::StructGridInterface::NEG_I);
if (isCellFaceVisible(i, j, k, StructGridInterface::POS_I)) visibleFaces.push_back(cvf::StructGridInterface::POS_I);
if (isCellFaceVisible(i, j, k, StructGridInterface::NEG_J)) visibleFaces.push_back(cvf::StructGridInterface::NEG_J);
if (isCellFaceVisible(i, j, k, StructGridInterface::POS_J)) visibleFaces.push_back(cvf::StructGridInterface::POS_J);
if (isCellFaceVisible(i, j, k, StructGridInterface::NEG_K)) visibleFaces.push_back(cvf::StructGridInterface::NEG_K);
if (isCellFaceVisible(i, j, k, StructGridInterface::POS_K)) visibleFaces.push_back(cvf::StructGridInterface::POS_K);
if ( isCellFaceVisible( i, j, k, StructGridInterface::NEG_I ) )
visibleFaces.push_back( cvf::StructGridInterface::NEG_I );
if ( isCellFaceVisible( i, j, k, StructGridInterface::POS_I ) )
visibleFaces.push_back( cvf::StructGridInterface::POS_I );
if ( isCellFaceVisible( i, j, k, StructGridInterface::NEG_J ) )
visibleFaces.push_back( cvf::StructGridInterface::NEG_J );
if ( isCellFaceVisible( i, j, k, StructGridInterface::POS_J ) )
visibleFaces.push_back( cvf::StructGridInterface::POS_J );
if ( isCellFaceVisible( i, j, k, StructGridInterface::NEG_K ) )
visibleFaces.push_back( cvf::StructGridInterface::NEG_K );
if ( isCellFaceVisible( i, j, k, StructGridInterface::POS_K ) )
visibleFaces.push_back( cvf::StructGridInterface::POS_K );
if ( visibleFaces.size() > 0 )
{
@ -447,13 +447,13 @@ void StructGridGeometryGenerator::computeArrays()
m_vertices->assign( vertices );
}
//--------------------------------------------------------------------------------------------------
/// Calculates the texture coordinates in a "nearly" one dimentional texture.
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
//--------------------------------------------------------------------------------------------------
void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* resultAccessor, const ScalarMapper* mapper) const
void StructGridGeometryGenerator::textureCoordinates( Vec2fArray* textureCoords,
const StructGridScalarDataAccess* resultAccessor,
const ScalarMapper* mapper ) const
{
if ( !resultAccessor ) return;
@ -530,4 +530,3 @@ void StructGridGeometryGenerator::setCellVisibility(const UByteArray* cellVisibi
}
} // namespace cvf

View File

@ -34,16 +34,15 @@
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfArray.h"
#include "cvfStructGrid.h"
#include "cvfCollection.h"
#include "cvfObject.h"
#include "cvfStructGrid.h"
namespace cvf {
namespace cvf
{
class DrawableGeo;
class ScalarMapper;
class StructGridScalarDataAccess;
@ -72,16 +71,16 @@ private:
{
public:
CellRange()
: m_min(cvf::Vec3st::ZERO),
m_max(UNDEFINED_SIZE_T, UNDEFINED_SIZE_T, UNDEFINED_SIZE_T),
m_applyToSubGridAreas(true)
: m_min( cvf::Vec3st::ZERO )
, m_max( UNDEFINED_SIZE_T, UNDEFINED_SIZE_T, UNDEFINED_SIZE_T )
, m_applyToSubGridAreas( true )
{
}
CellRange( size_t minI, size_t minJ, size_t minK, size_t maxI, size_t maxJ, size_t maxK, bool applyToSubGridAreas )
: m_min(minI, minJ, minK),
m_max(maxI, maxJ, maxK),
m_applyToSubGridAreas(applyToSubGridAreas)
: m_min( minI, minJ, minK )
, m_max( maxI, maxJ, maxK )
, m_applyToSubGridAreas( applyToSubGridAreas )
{
}
@ -113,17 +112,19 @@ private:
std::vector<CellRange> m_excludeRanges;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class CellFaceVisibilityFilter
{
public:
virtual bool isFaceVisible(size_t i, size_t j, size_t k, StructGridInterface::FaceType face, const UByteArray* cellVisibility) const = 0;
virtual bool isFaceVisible( size_t i,
size_t j,
size_t k,
StructGridInterface::FaceType face,
const UByteArray* cellVisibility ) const = 0;
};
class StructGridQuadToCellFaceMapper : public Object
{
public:
@ -141,21 +142,25 @@ private:
std::vector<StructGridInterface::FaceType> m_quadsToFace;
};
class StuctGridTriangleToCellFaceMapper : public Object
{
public:
explicit StuctGridTriangleToCellFaceMapper(const StructGridQuadToCellFaceMapper* quadMapper) { m_quadMapper = quadMapper; }
explicit StuctGridTriangleToCellFaceMapper( const StructGridQuadToCellFaceMapper* quadMapper )
{
m_quadMapper = quadMapper;
}
size_t triangleCount() const { return 2 * m_quadMapper->quadCount(); }
size_t cellIndex( size_t triangleIdx ) const { return m_quadMapper->cellIndex( triangleIdx / 2 ); }
StructGridInterface::FaceType cellFace(size_t triangleIdx) const {return m_quadMapper->cellFace(triangleIdx/2); }
StructGridInterface::FaceType cellFace( size_t triangleIdx ) const
{
return m_quadMapper->cellFace( triangleIdx / 2 );
}
private:
cref<StructGridQuadToCellFaceMapper> m_quadMapper;
};
//==================================================================================================
//
//
@ -176,7 +181,9 @@ public:
const StructGridInterface* activeGrid() { return m_grid.p(); }
void textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* resultAccessor, const ScalarMapper* mapper) const;
void textureCoordinates( Vec2fArray* textureCoords,
const StructGridScalarDataAccess* resultAccessor,
const ScalarMapper* mapper ) const;
// Mapping between cells and geometry
@ -188,16 +195,14 @@ public:
ref<DrawableGeo> createMeshDrawable();
ref<DrawableGeo> createOutlineMeshDrawable( double creaseAngle );
static ref<DrawableGeo> createMeshDrawableFromSingleCell(const StructGridInterface* grid,
size_t cellIndex);
static ref<DrawableGeo> createMeshDrawableFromSingleCell( const StructGridInterface* grid, size_t cellIndex );
static ref<DrawableGeo> createMeshDrawableFromSingleCell( const StructGridInterface* grid,
size_t cellIndex,
const cvf::Vec3d& displayModelOffset );
private:
static ref<UIntArray>
lineIndicesFromQuadVertexArray(const Vec3fArray* vertexArray);
static ref<UIntArray> lineIndicesFromQuadVertexArray( const Vec3fArray* vertexArray );
bool isCellFaceVisible( size_t i, size_t j, size_t k, StructGridInterface::FaceType face ) const;
void computeArrays();
@ -221,4 +226,4 @@ private:
bool m_useOpenMP;
};
}
} // namespace cvf

View File

@ -34,17 +34,14 @@
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf {
namespace cvf
{
class StructGridScalarDataAccess : public Object
{
public:
@ -52,5 +49,4 @@ public:
virtual void setCellScalar( size_t cellIndex, double value ) = 0;
};
} // namespace cvf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafAnimationToolBar.h"
#include "cafPopupMenuButton.h"
@ -47,7 +46,6 @@
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -90,7 +88,8 @@ void AnimationToolBar::init()
m_animStepForwardAction = new QAction( QIcon( ":/cafAnimControl/StepFwd.png" ), tr( "Step Forward" ), this );
m_animSkipToEndAction = new QAction( QIcon( ":/cafAnimControl/SkipToEnd.png" ), tr( "Skip to End" ), this );
m_animRepeatFromStartAction = new QAction(QIcon(":/cafAnimControl/RepeatFromStart.png"), tr("Repeat From start"), this);
m_animRepeatFromStartAction =
new QAction( QIcon( ":/cafAnimControl/RepeatFromStart.png" ), tr( "Repeat From start" ), this );
m_animRepeatFromStartAction->setCheckable( true );
m_animSpeedButton = new PopupMenuButton( this );
@ -172,8 +171,7 @@ void AnimationToolBar::updateAnimationButtons()
m_animSkipToStartAction->setEnabled( isPlaying || !isAtStart );
m_animStepBackwardAction->setEnabled( isPlaying || !isAtStart );
bool isRepeat = m_activeAnimationControl &&
m_activeAnimationControl->isRepeatingFromStart();
bool isRepeat = m_activeAnimationControl && m_activeAnimationControl->isRepeatingFromStart();
// Going forwards actions disabled when we're stopped at the end
m_animStepForwardAction->setEnabled( isPlaying || !isAtEnd );
@ -219,7 +217,10 @@ void AnimationToolBar::connectAnimationControl(caf::FrameAnimationControl* anima
m_animRepeatFromStartAction->setChecked( animationControl->isRepeatingFromStart() );
connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFromStart(bool)));
connect( m_animRepeatFromStartAction,
SIGNAL( triggered( bool ) ),
animationControl,
SLOT( slotRepeatFromStart( bool ) ) );
connect( m_timestepCombo, SIGNAL( currentIndexChanged( int ) ), animationControl, SLOT( setCurrentFrame( int ) ) );
connect( m_frameRateSlider, SIGNAL( valueChanged( int ) ), this, SLOT( slotFrameRateSliderChanged( int ) ) );
@ -234,7 +235,6 @@ void AnimationToolBar::connectAnimationControl(caf::FrameAnimationControl* anima
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -307,8 +307,8 @@ void AnimationToolBar::slotFrameRateSliderChanged(int sliderTickValue)
setFrameRate( newFrameRate );
if(!m_activeAnimationControl.isNull()) m_activeAnimationControl->setTimeout((int)(1.0/newFrameRate * 1000));
if ( !m_activeAnimationControl.isNull() )
m_activeAnimationControl->setTimeout( (int)( 1.0 / newFrameRate * 1000 ) );
}
//--------------------------------------------------------------------------------------------------
@ -327,7 +327,6 @@ void AnimationToolBar::setFastFrameRate(float frameRate)
m_fastFrameRate = frameRate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -371,7 +370,10 @@ void AnimationToolBar::slotUpdateAnimationGuiFromFrameIndex(int value)
// Update only the combo box index, but do not set current frame
// Disconnect the signal temporarily when updating UI
disconnect(m_timestepCombo, SIGNAL(currentIndexChanged(int)), m_activeAnimationControl, SLOT(setCurrentFrame(int)));
disconnect( m_timestepCombo,
SIGNAL( currentIndexChanged( int ) ),
m_activeAnimationControl,
SLOT( setCurrentFrame( int ) ) );
m_timestepCombo->setCurrentIndex( value );
updateAnimationButtons();
connect( m_timestepCombo, SIGNAL( currentIndexChanged( int ) ), m_activeAnimationControl, SLOT( setCurrentFrame( int ) ) );

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include <QPointer>
@ -84,6 +83,7 @@ private slots:
private:
void init();
void updateAnimationButtons();
private:
QAction* m_animSkipToStartAction;
QAction* m_animStepBackwardAction;
@ -109,5 +109,4 @@ private:
bool m_hasAutoTimeStepStrings;
};
} // End namespace caf

View File

@ -34,15 +34,12 @@
//
//##################################################################################################
#include "cafFrameAnimationControl.h"
#include <QTimer>
namespace caf
{
//==================================================================================================
///
/// \class RIAnimationControl
@ -180,7 +177,6 @@ void FrameAnimationControl::setNumFrames(int numFrames)
emit frameCountChanged( m_numFrames );
if ( m_currentFrame >= numFrames ) m_currentFrame = 0; // Should we emit frameChanged ?
}
//--------------------------------------------------------------------------------------------------
@ -415,6 +411,4 @@ void FrameAnimationControl::slotRepeatFwdBwd(bool turnRepeatOn)
setRepeatFwdBwd( turnRepeatOn );
}
} // End namespace caf

View File

@ -34,17 +34,14 @@
//
//##################################################################################################
#pragma once
#include <QObject>
class QTimer;
namespace caf
{
//==================================================================================================
///
//==================================================================================================
@ -119,5 +116,4 @@ private:
bool m_repeatFwdBwd;
};
} // End namespace caf

View File

@ -60,4 +60,4 @@ private:
QPointer<QBoxLayout> m_layout;
};
}
} // namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafCmdExecCommandManager.h"
#include "cafCmdExecuteCommand.h"
@ -57,36 +56,24 @@ public:
setText( m_executeCommand->name() );
}
~UndoRedoWrapper() override
{
delete m_executeCommand;
}
~UndoRedoWrapper() override { delete m_executeCommand; }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void undo() override
{
m_executeCommand->undo();
}
void undo() override { m_executeCommand->undo(); }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void redo() override
{
m_executeCommand->redo();
}
void redo() override { m_executeCommand->redo(); }
private:
caf::CmdExecuteCommand* m_executeCommand;
};
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -169,7 +156,8 @@ void CmdExecCommandManager::processExecuteCommand(CmdExecuteCommand* executeComm
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CmdExecCommandManager::processExecuteCommandsAsMacro(const QString& macroName, std::vector<CmdExecuteCommand*>& commands)
void CmdExecCommandManager::processExecuteCommandsAsMacro( const QString& macroName,
std::vector<CmdExecuteCommand*>& commands )
{
if ( commands.size() == 0 )
{
@ -219,5 +207,4 @@ bool CmdExecCommandManager::isUndoEnabledForCurrentCommand(CmdExecuteCommand* co
return useUndo;
}
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include <QPointer>
@ -46,7 +45,6 @@ class QString;
namespace caf
{
class CmdExecuteCommand;
class CmdUiCommandSystemImpl;
@ -75,10 +73,10 @@ public:
private:
CmdExecCommandManager();
// Creates the object (CmdUiCommandSystemImpl) used to communicate from UI editors to advanced parts of the command system
// This includes support for undo system and default command features for add/delete of items in PdmChildArrayFieldHandle
// and creation of field changed commands so a change in an editor can be put into undo/redo
// CmdUiCommandSystemImpl is a requirement for using the undo system
// Creates the object (CmdUiCommandSystemImpl) used to communicate from UI editors to advanced parts of the command
// system This includes support for undo system and default command features for add/delete of items in
// PdmChildArrayFieldHandle and creation of field changed commands so a change in an editor can be put into
// undo/redo CmdUiCommandSystemImpl is a requirement for using the undo system
void activateCommandSystem();
void deactivateCommandSystem();
@ -99,15 +97,9 @@ private:
class CmdExecCommandSystemDeactivator
{
public:
CmdExecCommandSystemDeactivator()
{
CmdExecCommandManager::instance()->deactivateCommandSystem();
}
CmdExecCommandSystemDeactivator() { CmdExecCommandManager::instance()->deactivateCommandSystem(); }
~CmdExecCommandSystemDeactivator()
{
CmdExecCommandManager::instance()->activateCommandSystem();
}
~CmdExecCommandSystemDeactivator() { CmdExecCommandManager::instance()->activateCommandSystem(); }
};
//==================================================================================================
@ -116,15 +108,9 @@ public:
class CmdExecCommandSystemActivator
{
public:
CmdExecCommandSystemActivator()
{
CmdExecCommandManager::instance()->activateCommandSystem();
}
CmdExecCommandSystemActivator() { CmdExecCommandManager::instance()->activateCommandSystem(); }
~CmdExecCommandSystemActivator()
{
CmdExecCommandManager::instance()->deactivateCommandSystem();
}
~CmdExecCommandSystemActivator() { CmdExecCommandManager::instance()->deactivateCommandSystem(); }
};
} // end namespace caf

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
#include <QString>
namespace caf
{
class NotificationCenter;
class PdmObjectHandle;
@ -51,10 +49,7 @@ class PdmObjectHandle;
class CmdExecuteCommand
{
public:
explicit CmdExecuteCommand(NotificationCenter* notificationCenter)
{
m_notificationCenter = notificationCenter;
}
explicit CmdExecuteCommand( NotificationCenter* notificationCenter ) { m_notificationCenter = notificationCenter; }
virtual ~CmdExecuteCommand(){};
@ -66,6 +61,4 @@ protected:
NotificationCenter* m_notificationCenter;
};
} // end namespace caf

View File

@ -46,7 +46,6 @@
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -60,7 +59,6 @@ CmdFeature::CmdFeature()
//--------------------------------------------------------------------------------------------------
CmdFeature::~CmdFeature()
{
}
//--------------------------------------------------------------------------------------------------

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include "cafFactory.h"
@ -54,13 +53,15 @@ class QString;
static const std::string& idNameStatic()
#define CAF_CMD_SOURCE_INIT( ClassName, CommandIdName ) \
const std::string& ClassName::idNameStatic() { static std::string id = CommandIdName; return id;} \
const std::string& ClassName::idNameStatic() \
{ \
static std::string id = CommandIdName; \
return id; \
} \
CAF_FACTORY_REGISTER( caf::CmdFeature, ClassName, std::string, ClassName::idNameStatic() )
namespace caf
{
class CmdExecuteCommand;
//==================================================================================================
@ -104,6 +105,4 @@ private:
bool m_triggerModelChange;
};
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafCmdFeatureManager.h"
#include "cafCmdFeature.h"
@ -46,7 +45,6 @@
namespace caf
{
typedef Factory<CmdFeature, std::string> CommandFeatureFactory;
//--------------------------------------------------------------------------------------------------
///
@ -69,7 +67,6 @@ CmdFeatureManager::CmdFeatureManager()
//--------------------------------------------------------------------------------------------------
CmdFeatureManager::~CmdFeatureManager()
{
}
//--------------------------------------------------------------------------------------------------
@ -113,7 +110,9 @@ QAction* CmdFeatureManager::action(const QString& commandId, const QString& cust
/// Get action for the specified command, with custom action text
/// The action is owned by the PdmCommandItemManager
//--------------------------------------------------------------------------------------------------
QAction* CmdFeatureManager::actionWithUserData(const QString& commandId, const QString& customActionText, const QVariant& userData)
QAction* CmdFeatureManager::actionWithUserData( const QString& commandId,
const QString& customActionText,
const QVariant& userData )
{
std::pair<CmdFeature*, size_t> featurePair = createFeature( commandId.toStdString() );
@ -282,7 +281,6 @@ CmdFeature* CmdFeatureManager::getCommandFeature(const std::string& commandId)
std::pair<CmdFeature*, size_t> featurePair = createFeature( commandId );
return featurePair.first;
}
//--------------------------------------------------------------------------------------------------

View File

@ -34,16 +34,15 @@
//
//##################################################################################################
#pragma once
#include <vector>
#include <map>
#include <set>
#include <vector>
#include <QObject>
#include <QStringList>
#include <QPointer>
#include <QStringList>
class QAction;
class QKeySequence;
@ -51,7 +50,6 @@ class QWidget;
namespace caf
{
class CmdFeature;
//==================================================================================================
@ -96,6 +94,4 @@ private:
QPointer<QWidget> m_currentContextMenuTargetWidget;
};
} // end namespace caf

View File

@ -49,12 +49,16 @@ namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdFeatureMenuBuilder::CmdFeatureMenuBuilder() {}
CmdFeatureMenuBuilder::CmdFeatureMenuBuilder()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdFeatureMenuBuilder::~CmdFeatureMenuBuilder() {}
CmdFeatureMenuBuilder::~CmdFeatureMenuBuilder()
{
}
//--------------------------------------------------------------------------------------------------
///
@ -90,7 +94,8 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeature(const QString comman
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeatureWithUserData(const QString commandId, const QString& uiText,
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeatureWithUserData( const QString commandId,
const QString& uiText,
const QVariant& userData )
{
MenuItem i;

View File

@ -59,8 +59,8 @@ public:
CmdFeatureMenuBuilder& operator<<( const QString& commandIdOrSeparator );
CmdFeatureMenuBuilder& addCmdFeature( const QString commandId, const QString& customUiText = "" );
CmdFeatureMenuBuilder& addCmdFeatureWithUserData(const QString commandId, const QString& customUiText,
const QVariant& userData);
CmdFeatureMenuBuilder&
addCmdFeatureWithUserData( const QString commandId, const QString& customUiText, const QVariant& userData );
CmdFeatureMenuBuilder& addSeparator();
@ -71,6 +71,7 @@ public:
bool isCmdFeatureAdded( const QString& commandId );
size_t itemCount() const;
private:
struct MenuItem
{

View File

@ -34,25 +34,22 @@
//
//##################################################################################################
#include "cafCmdFieldChangeExec.h"
#include "cafPdmReferenceHelper.h"
#include "cafNotificationCenter.h"
#include "cafPdmReferenceHelper.h"
namespace caf
{
CAF_PDM_SOURCE_INIT( CmdFieldChangeExecData, "CmdFieldChangeExecData" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString CmdFieldChangeExec::name()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
if ( field )
{
QString fieldText;
@ -84,7 +81,8 @@ QString CmdFieldChangeExec::name()
//--------------------------------------------------------------------------------------------------
void CmdFieldChangeExec::redo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
if ( !field )
{
CAF_ASSERT( false );
@ -137,7 +135,8 @@ void CmdFieldChangeExec::redo()
//--------------------------------------------------------------------------------------------------
void CmdFieldChangeExec::undo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
if ( !field )
{
CAF_ASSERT( false );
@ -171,13 +170,11 @@ CmdFieldChangeExec::CmdFieldChangeExec(NotificationCenter* notificationCenter)
m_commandData = new CmdFieldChangeExecData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdFieldChangeExec::~CmdFieldChangeExec()
{
}
//--------------------------------------------------------------------------------------------------

View File

@ -42,7 +42,6 @@
namespace caf
{
class PdmChildArrayFieldHandle;
//==================================================================================================
@ -55,7 +54,10 @@ class CmdFieldChangeExecData : public PdmObject
public:
CmdFieldChangeExecData()
{
CAF_PDM_InitObject("CmdFieldChangeExecData uiName", "", "CmdFieldChangeExecData tooltip", "CmdFieldChangeExecData whatsthis");
CAF_PDM_InitObject( "CmdFieldChangeExecData uiName",
"",
"CmdFieldChangeExecData tooltip",
"CmdFieldChangeExecData whatsthis" );
CAF_PDM_InitField( &m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis" );
}
@ -69,7 +71,6 @@ public:
QString m_redoFieldValueSerialized;
};
//==================================================================================================
///
//==================================================================================================
@ -79,7 +80,6 @@ public:
explicit CmdFieldChangeExec( NotificationCenter* notificationCenter );
~CmdFieldChangeExec() override;
CmdFieldChangeExecData* commandData();
QString name() override;
@ -94,6 +94,4 @@ private:
CmdFieldChangeExecData* m_commandData;
};
} // end namespace caf

View File

@ -34,15 +34,12 @@
//
//##################################################################################################
#include "cafCmdSelectionChangeExec.h"
#include "cafPdmReferenceHelper.h"
#include "cafSelectionManager.h"
namespace caf
{
CAF_PDM_SOURCE_INIT( CmdSelectionChangeExecData, "CmdSelectionChangeExecData" );
//--------------------------------------------------------------------------------------------------
@ -58,7 +55,8 @@ QString CmdSelectionChangeExec::name()
//--------------------------------------------------------------------------------------------------
void CmdSelectionChangeExec::redo()
{
SelectionManager::instance()->setSelectionAtLevelFromReferences(m_commandData->m_newSelection.v(), m_commandData->m_selectionLevel.v());
SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_newSelection.v(),
m_commandData->m_selectionLevel.v() );
}
//--------------------------------------------------------------------------------------------------
@ -66,7 +64,8 @@ void CmdSelectionChangeExec::redo()
//--------------------------------------------------------------------------------------------------
void CmdSelectionChangeExec::undo()
{
SelectionManager::instance()->setSelectionAtLevelFromReferences(m_commandData->m_previousSelection.v(), m_commandData->m_selectionLevel.v());
SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_previousSelection.v(),
m_commandData->m_selectionLevel.v() );
}
//--------------------------------------------------------------------------------------------------
@ -78,13 +77,11 @@ CmdSelectionChangeExec::CmdSelectionChangeExec(NotificationCenter* notificationC
m_commandData = new CmdSelectionChangeExecData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdSelectionChangeExec::~CmdSelectionChangeExec()
{
}
//--------------------------------------------------------------------------------------------------

View File

@ -38,16 +38,12 @@
#include "cafCmdExecuteCommand.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafAppEnum.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
@ -58,7 +54,10 @@ class CmdSelectionChangeExecData : public PdmObject
public:
CmdSelectionChangeExecData()
{
CAF_PDM_InitObject("CmdSelectionChangeExecData uiName", "", "CmdSelectionChangeExecData tooltip", "CmdSelectionChangeExecData whatsthis");
CAF_PDM_InitObject( "CmdSelectionChangeExecData uiName",
"",
"CmdSelectionChangeExecData tooltip",
"CmdSelectionChangeExecData whatsthis" );
CAF_PDM_InitFieldNoDefault( &m_selectionLevel, "selectionLevel", "selectionLevel", "", "", "" );
CAF_PDM_InitField( &m_previousSelection, "previousSelection", std::vector<QString>(), "previousSelection", "", "", "" );
@ -70,7 +69,6 @@ public:
PdmField<std::vector<QString>> m_newSelection;
};
//==================================================================================================
///
//==================================================================================================
@ -78,7 +76,8 @@ class CmdSelectionChangeExec : public CmdExecuteCommand
{
public:
explicit CmdSelectionChangeExec( NotificationCenter* notificationCenter );
~CmdSelectionChangeExec() override;;
~CmdSelectionChangeExec() override;
;
CmdSelectionChangeExecData* commandData();
@ -90,6 +89,4 @@ private:
CmdSelectionChangeExecData* m_commandData;
};
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafCmdSelectionHelper.h"
#include "cafCmdExecCommandManager.h"
@ -42,10 +41,8 @@
#include "cafSelectionManager.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -59,21 +56,24 @@ void CmdSelectionHelper::executeSelectionCommand(const std::vector<PdmObjectHand
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdSelectionChangeExec* CmdSelectionHelper::createSelectionCommand(const std::vector<PdmObjectHandle*>& selection, int selectionLevel)
CmdSelectionChangeExec* CmdSelectionHelper::createSelectionCommand( const std::vector<PdmObjectHandle*>& selection,
int selectionLevel )
{
CmdSelectionChangeExec* selectionChangeExec = new CmdSelectionChangeExec(SelectionManager::instance()->notificationCenter());
CmdSelectionChangeExec* selectionChangeExec =
new CmdSelectionChangeExec( SelectionManager::instance()->notificationCenter() );
selectionChangeExec->commandData()->m_selectionLevel.v() = selectionLevel;
SelectionManager::instance()->selectionAsReferences(selectionChangeExec->commandData()->m_previousSelection.v(), selectionLevel);
SelectionManager::instance()->selectionAsReferences( selectionChangeExec->commandData()->m_previousSelection.v(),
selectionLevel );
for ( size_t i = 0; i < selection.size(); i++ )
{
QString itemRef = PdmReferenceHelper::referenceFromRootToObject(PdmReferenceHelper::findRoot(selection[i]), selection[i]);
QString itemRef =
PdmReferenceHelper::referenceFromRootToObject( PdmReferenceHelper::findRoot( selection[i] ), selection[i] );
selectionChangeExec->commandData()->m_newSelection.v().push_back( itemRef );
}
return selectionChangeExec;
}
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include <vector>
@ -48,9 +47,8 @@ class CmdSelectionHelper
{
public:
static void executeSelectionCommand( const std::vector<PdmObjectHandle*>& selection, int selectionLevel );
static CmdSelectionChangeExec* createSelectionCommand(const std::vector<PdmObjectHandle*>& selection, int selectionLevel);
static CmdSelectionChangeExec* createSelectionCommand( const std::vector<PdmObjectHandle*>& selection,
int selectionLevel );
};
} // end namespace caf

View File

@ -34,13 +34,12 @@
//
//##################################################################################################
#include "cafCmdUiCommandSystemImpl.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdExecuteCommand.h"
#include "cafCmdFieldChangeExec.h"
#include "cafCmdFeatureManager.h"
#include "cafCmdFieldChangeExec.h"
#include "cafPdmFieldHandle.h"
#include "cafPdmUiObjectHandle.h"
@ -53,7 +52,6 @@
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -66,7 +64,8 @@ CmdUiCommandSystemImpl::CmdUiCommandSystemImpl()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHandle*>& fieldsToUpdate, const QVariant& newUiValue)
void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHandle*>& fieldsToUpdate,
const QVariant& newUiValue )
{
if ( fieldsToUpdate.empty() ) return;
@ -91,7 +90,8 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHand
return;
}
CmdFieldChangeExec* fieldChangeExec = new CmdFieldChangeExec(SelectionManager::instance()->notificationCenter());
CmdFieldChangeExec* fieldChangeExec =
new CmdFieldChangeExec( SelectionManager::instance()->notificationCenter() );
fieldChangeExec->commandData()->m_newUiValue = newUiValue;
fieldChangeExec->commandData()->m_pathToField = reference;
@ -130,8 +130,7 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHand
//--------------------------------------------------------------------------------------------------
void CmdUiCommandSystemImpl::populateMenuWithDefaultCommands( const QString& uiConfigName, QMenu* menu )
{
if (uiConfigName == "PdmUiTreeViewEditor" ||
uiConfigName == "PdmUiTableViewEditor")
if ( uiConfigName == "PdmUiTreeViewEditor" || uiConfigName == "PdmUiTableViewEditor" )
{
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
@ -139,7 +138,8 @@ void CmdUiCommandSystemImpl::populateMenuWithDefaultCommands(const QString& uiCo
menu->addAction( commandManager->action( "PdmListField_DeleteItem" ) );
QStringList commandIdList;
commandIdList << "PdmListField_AddItem" << "PdmListField_DeleteItem";
commandIdList << "PdmListField_AddItem"
<< "PdmListField_DeleteItem";
commandManager->refreshStates( commandIdList );
}
}

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include "cafInternalPdmUiCommandSystemInterface.h"
@ -42,7 +41,6 @@
namespace caf
{
class PdmFieldHandle;
class CmdUiCommandSystemImpl : public PdmUiCommandSystemInterface
@ -64,5 +62,4 @@ private:
bool m_disableUndoForFieldChange;
};
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafCmdAddItemExec.h"
#include "cafCmdAddItemExecData.h"
@ -45,17 +44,15 @@
#include "cafPdmChildArrayField.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString CmdAddItemExec::name()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
QString containedObjectType = "object";
@ -74,7 +71,8 @@ QString CmdAddItemExec::name()
//--------------------------------------------------------------------------------------------------
void CmdAddItemExec::redo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>( field );
if ( listField && field->xmlCapability() )
@ -118,7 +116,8 @@ void CmdAddItemExec::redo()
//--------------------------------------------------------------------------------------------------
void CmdAddItemExec::undo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>( field );
if ( listField && m_commandData->m_createdItemIndex >= 0 )
@ -157,13 +156,11 @@ CmdAddItemExec::CmdAddItemExec(NotificationCenter* notificationCenter)
m_commandData = new CmdAddItemExecData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CmdAddItemExec::~CmdAddItemExec()
{
}
//--------------------------------------------------------------------------------------------------

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
#include "cafCmdExecuteCommand.h"
namespace caf
{
class PdmChildArrayFieldHandle;
class CmdAddItemExecData;
@ -52,7 +50,8 @@ class CmdAddItemExec : public CmdExecuteCommand
{
public:
explicit CmdAddItemExec( NotificationCenter* notificationCenter );
~CmdAddItemExec() override;;
~CmdAddItemExec() override;
;
CmdAddItemExecData* commandData();
@ -64,6 +63,4 @@ private:
CmdAddItemExecData* m_commandData;
};
} // end namespace caf

View File

@ -34,13 +34,10 @@
//
//##################################################################################################
#include "cafCmdAddItemExecData.h"
namespace caf
{
CAF_PDM_SOURCE_INIT( CmdAddItemExecData, "CmdAddItemExecData" );
} // end namespace caf

View File

@ -34,16 +34,13 @@
//
//##################################################################################################
#pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
@ -58,7 +55,13 @@ public:
CAF_PDM_InitField( &m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis" );
CAF_PDM_InitField( &m_indexAfter, "indexAfter", -1, "indexAfter", "", "indexAfter tooltip", "indexAfter whatsthis" );
CAF_PDM_InitField(&m_createdItemIndex, "createdItemIndex", -1, "createdItemIndex", "", "createdItemIndex tooltip", "createdItemIndex whatsthis");
CAF_PDM_InitField( &m_createdItemIndex,
"createdItemIndex",
-1,
"createdItemIndex",
"",
"createdItemIndex tooltip",
"createdItemIndex whatsthis" );
}
caf::PdmPointer<PdmObjectHandle> m_rootObject;
@ -68,6 +71,4 @@ public:
caf::PdmField<int> m_createdItemIndex;
};
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafCmdAddItemFeature.h"
#include "cafCmdAddItemExec.h"
@ -52,11 +51,8 @@
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT( CmdAddItemFeature, "PdmListField_AddItem" );
//--------------------------------------------------------------------------------------------------

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
#include "cafCmdFeature.h"
namespace caf
{
class CmdExecuteCommand;
//==================================================================================================
@ -50,15 +48,13 @@ class CmdExecuteCommand;
class CmdAddItemFeature : public CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
CmdExecuteCommand* createExecuteCommand();
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#include "cafCmdDeleteItemExec.h"
#include "cafCmdDeleteItemExecData.h"
@ -45,10 +44,8 @@
#include "cafNotificationCenter.h"
#include "cafSelectionManager.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -62,7 +59,8 @@ QString CmdDeleteItemExec::name()
//--------------------------------------------------------------------------------------------------
void CmdDeleteItemExec::redo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>( field );
if ( listField )
@ -83,7 +81,6 @@ void CmdDeleteItemExec::redo()
listField->erase( m_commandData->m_indexToObject );
// TODO: The notification here could possibly be changed to
// PdmUiFieldHandle::notifyDataChange() similar to void CmdFieldChangeExec::redo()
@ -106,12 +103,15 @@ void CmdDeleteItemExec::redo()
//--------------------------------------------------------------------------------------------------
void CmdDeleteItemExec::undo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmFieldHandle* field =
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>( field );
if ( listField )
{
PdmObjectHandle* obj = PdmXmlObjectHandle::readUnknownObjectFromXmlString(m_commandData->m_deletedObjectAsXml(), PdmDefaultObjectFactory::instance(), false);
PdmObjectHandle* obj = PdmXmlObjectHandle::readUnknownObjectFromXmlString( m_commandData->m_deletedObjectAsXml(),
PdmDefaultObjectFactory::instance(),
false );
listField->insertAt( m_commandData->m_indexToObject, obj );

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
#include "cafCmdExecuteCommand.h"
namespace caf
{
class PdmChildArrayFieldHandle;
class CmdDeleteItemExecData;
@ -54,7 +52,6 @@ public:
explicit CmdDeleteItemExec( NotificationCenter* notificationCenter );
~CmdDeleteItemExec() override{};
CmdDeleteItemExecData* commandData();
QString name() override;
@ -65,6 +62,4 @@ private:
CmdDeleteItemExecData* m_commandData;
};
} // end namespace caf

View File

@ -34,13 +34,10 @@
//
//##################################################################################################
#include "cafCmdDeleteItemExecData.h"
namespace caf
{
CAF_PDM_SOURCE_INIT( CmdDeleteItemExecData, "CmdDeleteItemExecData" );
} // end namespace caf

View File

@ -34,16 +34,13 @@
//
//##################################################################################################
#pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
@ -54,11 +51,26 @@ class CmdDeleteItemExecData : public PdmObject
public:
CmdDeleteItemExecData()
{
CAF_PDM_InitObject("CmdDeleteItemExecData uiName", "", "CmdDeleteItemExecData tooltip", "CmdDeleteItemExecData whatsthis");
CAF_PDM_InitObject( "CmdDeleteItemExecData uiName",
"",
"CmdDeleteItemExecData tooltip",
"CmdDeleteItemExecData whatsthis" );
CAF_PDM_InitField( &m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis" );
CAF_PDM_InitField(&m_indexToObject, "indexToObject", -1, "indexToObject", "", "indexToObject tooltip", "indexToObject whatsthis");
CAF_PDM_InitField(&m_deletedObjectAsXml, "deletedObjectAsXml", QString(), "deletedObjectAsXml", "", "deletedObjectAsXml tooltip", "deletedObjectAsXml whatsthis");
CAF_PDM_InitField( &m_indexToObject,
"indexToObject",
-1,
"indexToObject",
"",
"indexToObject tooltip",
"indexToObject whatsthis" );
CAF_PDM_InitField( &m_deletedObjectAsXml,
"deletedObjectAsXml",
QString(),
"deletedObjectAsXml",
"",
"deletedObjectAsXml tooltip",
"deletedObjectAsXml whatsthis" );
}
caf::PdmPointer<PdmObjectHandle> m_rootObject;
@ -68,6 +80,4 @@ public:
caf::PdmField<QString> m_deletedObjectAsXml;
};
} // end namespace caf

View File

@ -36,9 +36,9 @@
#include "cafCmdDeleteItemFeature.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdDeleteItemExec.h"
#include "cafCmdDeleteItemExecData.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdSelectionHelper.h"
#include "cafPdmReferenceHelper.h"
#include "cafSelectionManager.h"
@ -60,7 +60,8 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand()
std::vector<PdmUiItem*> items;
SelectionManager::instance()->selectedItems( items, SelectionManager::FIRST_LEVEL );
caf::PdmChildArrayFieldHandle* childArrayFieldHandle = caf::SelectionManager::instance()->activeChildArrayFieldHandle();
caf::PdmChildArrayFieldHandle* childArrayFieldHandle =
caf::SelectionManager::instance()->activeChildArrayFieldHandle();
if ( !childArrayFieldHandle ) return nullptr;
caf::PdmObjectHandle* currentPdmObject = nullptr;
@ -106,10 +107,12 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand()
//--------------------------------------------------------------------------------------------------
bool CmdDeleteItemFeature::isCommandEnabled()
{
caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem(caf::SelectionManager::FIRST_LEVEL));
caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>(
caf::SelectionManager::instance()->selectedItem( caf::SelectionManager::FIRST_LEVEL ) );
if ( !currentPdmObject ) return false;
caf::PdmChildArrayFieldHandle* childArrayFieldHandle = caf::SelectionManager::instance()->activeChildArrayFieldHandle();
caf::PdmChildArrayFieldHandle* childArrayFieldHandle =
caf::SelectionManager::instance()->activeChildArrayFieldHandle();
if ( !childArrayFieldHandle ) return false;
return true;

View File

@ -34,20 +34,19 @@
//
//##################################################################################################
#pragma once
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class CmdDeleteItemFeature : public CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
CmdExecuteCommand* createExecuteCommand();
@ -57,6 +56,4 @@ protected:
void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -44,7 +44,6 @@
namespace caf
{
CAF_CMD_SOURCE_INIT( ToggleItemsFeature, "cafToggleItemsFeature" );
//--------------------------------------------------------------------------------------------------
@ -76,4 +75,4 @@ void ToggleItemsFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setIcon( QIcon( ":/cafCommandFeatures/ToggleOnOffL16x16.png" ) );
}
}
} // namespace caf

View File

@ -46,12 +46,12 @@ namespace caf
class ToggleItemsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
}
} // namespace caf

View File

@ -50,12 +50,11 @@
#include <QModelIndex>
#include <vector>
#include "cafCmdFeatureManager.h"
#include <vector>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -79,8 +78,7 @@ bool ToggleItemsFeatureImpl::isToggleCommandsAvailable()
caf::PdmObjectHandle* childObj = child->object();
caf::PdmUiObjectHandle* uiObjectHandleChild = uiObj( childObj );
if (uiObjectHandleChild &&
uiObjectHandleChild->objectToggleField() &&
if ( uiObjectHandleChild && uiObjectHandleChild->objectToggleField() &&
!uiObjectHandleChild->objectToggleField()->uiCapability()->isUiReadOnly() )
{
return true;
@ -180,7 +178,8 @@ void ToggleItemsFeatureImpl::setObjectToggleStateForSelection(SelectionToggleTyp
//--------------------------------------------------------------------------------------------------
caf::PdmUiTreeView* ToggleItemsFeatureImpl::findTreeView( const caf::PdmUiItem* uiItem )
{
caf::PdmUiTreeView* customActiveTreeView = dynamic_cast<caf::PdmUiTreeView*>(CmdFeatureManager::instance()->currentContextMenuTargetWidget());
caf::PdmUiTreeView* customActiveTreeView =
dynamic_cast<caf::PdmUiTreeView*>( CmdFeatureManager::instance()->currentContextMenuTargetWidget() );
return customActiveTreeView;
}
@ -201,4 +200,4 @@ caf::PdmUiTreeOrdering* ToggleItemsFeatureImpl::findTreeItemFromSelectedUiItem(c
return nullptr;
}
}
} // namespace caf

View File

@ -42,7 +42,6 @@ namespace caf
class PdmUiTreeOrdering;
class PdmUiTreeView;
//==================================================================================================
///
//==================================================================================================
@ -67,4 +66,4 @@ private:
static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem );
};
};
}; // namespace caf

View File

@ -44,7 +44,6 @@
namespace caf
{
CAF_CMD_SOURCE_INIT( ToggleItemsOffFeature, "cafToggleItemsOffFeature" );
//--------------------------------------------------------------------------------------------------
@ -74,7 +73,6 @@ void ToggleItemsOffFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText( "Off" );
actionToSetup->setIcon( QIcon( ":/cafCommandFeatures/ToggleOffL16x16.png" ) );
}
}
} // namespace caf

View File

@ -46,12 +46,12 @@ namespace caf
class ToggleItemsOffFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
}
} // namespace caf

View File

@ -44,7 +44,6 @@
namespace caf
{
CAF_CMD_SOURCE_INIT( ToggleItemsOnFeature, "cafToggleItemsOnFeature" );
//--------------------------------------------------------------------------------------------------
@ -74,7 +73,6 @@ void ToggleItemsOnFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText( "On" );
actionToSetup->setIcon( QIcon( ":/cafCommandFeatures/ToggleOnL16x16.png" ) );
}
}
} // namespace caf

View File

@ -40,19 +40,18 @@
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class ToggleItemsOnFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
}
} // namespace caf

View File

@ -40,14 +40,13 @@
#include "cafSelectionManager.h"
#include <QAction>
#include "cafPdmObjectHandle.h"
#include "cafPdmObject.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmUiItem.h"
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT( ToggleItemsOnOthersOffFeature, "cafToggleItemsOnOthersOffFeature" );
//--------------------------------------------------------------------------------------------------
@ -61,10 +60,8 @@ bool ToggleItemsOnOthersOffFeature::isCommandEnabled()
caf::PdmFieldHandle* commonParent = verifySameParentForSelection( selectedObjects );
std::vector<caf::PdmObjectHandle*> children = childObjects( commonParent );
return commonParent != nullptr
&& children.size() > 0
&& objectToggleField(children.front())
&& children.size() > selectedObjects.size();
return commonParent != nullptr && children.size() > 0 && objectToggleField( children.front() ) &&
children.size() > selectedObjects.size();
}
//--------------------------------------------------------------------------------------------------
@ -106,13 +103,13 @@ void ToggleItemsOnOthersOffFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText( "On - Others Off" );
actionToSetup->setIcon( QIcon( ":/cafCommandFeatures/ToggleOnOthersOffL16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* ToggleItemsOnOthersOffFeature::verifySameParentForSelection(const std::vector<caf::PdmObject*>& selection)
caf::PdmFieldHandle*
ToggleItemsOnOthersOffFeature::verifySameParentForSelection( const std::vector<caf::PdmObject*>& selection )
{
caf::PdmFieldHandle* sameParent = nullptr;
@ -162,4 +159,4 @@ caf::PdmField<bool>* ToggleItemsOnOthersOffFeature::objectToggleField(caf::PdmOb
return nullptr;
}
}
} // namespace caf

View File

@ -45,15 +45,14 @@ namespace caf
class PdmObject;
class PdmObjectHandle;
//==================================================================================================
///
//==================================================================================================
class ToggleItemsOnOthersOffFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
@ -65,4 +64,4 @@ private:
caf::PdmField<bool>* objectToggleField( caf::PdmObjectHandle* objectHandle );
};
}
} // namespace caf

View File

@ -1,3 +1,6 @@
// clang-format off
//##################################################################################################
//
// Custom Visualization Core library
@ -59,6 +62,10 @@ Normalized coordinates i, j, k
Normalized origo in center of element
Normalized cell corners NCn in :
[NC0] = {-1,-1,-1}
[NC1] = { 1,-1,-1}
[NC2] = { 1, 1,-1}
@ -84,7 +91,8 @@ we use i,j,k to calculate all Nn, and then :
R = sum_n(Nn * Vn)
A point [P] = {x,y,z} inside a general element can then be calculated by the {i,j,k} coordinates correponding to the point and the corner positions Cn = {Cx_n, Cy_n, Cz_n} (n = 0..7) of the general hex as:
A point [P] = {x,y,z} inside a general element can then be calculated by the {i,j,k} coordinates correponding to the
point and the corner positions Cn = {Cx_n, Cy_n, Cz_n} (n = 0..7) of the general hex as:
x = sum_n(Nn * Cn_x)
y = sum_n(Nn * Cn_y)
@ -107,8 +115,8 @@ it can be written
[P] = [Cn]*[Nn]
As seen, we need to know the { i, j, k} position of the point. This can only be calculated using some sort of iterative solution, eg. Newton-Rapson.
Using m as iteration number we can use { im, jm, km } to evaluate [Nn] and name it [Nnm].
As seen, we need to know the { i, j, k} position of the point. This can only be calculated using some sort of iterative
solution, eg. Newton-Rapson. Using m as iteration number we can use { im, jm, km } to evaluate [Nn] and name it [Nnm].
We use an initial guess of {im,jm,km} = { 0.5, 0.5, 0.5} // But why ? the element origo is at 0,0,0 !
[Pm] = {xm, ym, zm} = sum_n(Nnm * Cn_x), sum_n(Nnm * Cn_y), sum_n(Nnm * Cn_z) } When using im,jm,km to evaluate Nnm
@ -131,6 +139,10 @@ The Jacobian is the partially derived x, y, z with respect to i, j, k as follows
J = | dx/dj dy/dj dz/dj |
| dx/dk dy/dk dz/dk |
The partial derivatives are calculated by deriving the function [F(i,j,k)] = [Pm(i,j,k)] - [P]
Since [P] is constant, this is the same as deriving [Pm(i,j,k)] = [Cn]*[Nnm]
Explicitly:
@ -195,13 +207,13 @@ dN7/dk = 1/8 * ( + 1 - i + j - ij )
The inverse Jacobian can be calculated by inverting the resulting Jacobian matrix for a specifically chosen set of i,j,k
*/
#include "cvfVector3.h"
#include "cvfMatrix3.h"
#include "cvfVector3.h"
#include <array>
namespace caf {
namespace caf
{
class HexInterpolator
{
public:
@ -213,14 +225,12 @@ public:
return interpolateInNormElm( pointInNormElm, values );
}
static std::array<double, 8> vertexWeights(const std::array<cvf::Vec3d, 8>& hexCorners,
const cvf::Vec3d& point )
static std::array<double, 8> vertexWeights( const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& point )
{
cvf::Vec3d pointInNormElm = findNormalizedCoords( hexCorners, point );
return interpolationCoeffs( pointInNormElm );
}
static cvf::Mat3d jacobi( const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& pointInNormalizedElement )
{
const double k_1_8 = 0.125;
@ -233,14 +243,30 @@ public:
double ik = i * k;
double jk = j * k;
double C0_x = hexCorners[0][0]; double C0_y = hexCorners[0][1]; double C0_z = hexCorners[0][2];
double C1_x = hexCorners[1][0]; double C1_y = hexCorners[1][1]; double C1_z = hexCorners[1][2];
double C2_x = hexCorners[2][0]; double C2_y = hexCorners[2][1]; double C2_z = hexCorners[2][2];
double C3_x = hexCorners[3][0]; double C3_y = hexCorners[3][1]; double C3_z = hexCorners[3][2];
double C4_x = hexCorners[4][0]; double C4_y = hexCorners[4][1]; double C4_z = hexCorners[4][2];
double C5_x = hexCorners[5][0]; double C5_y = hexCorners[5][1]; double C5_z = hexCorners[5][2];
double C6_x = hexCorners[6][0]; double C6_y = hexCorners[6][1]; double C6_z = hexCorners[6][2];
double C7_x = hexCorners[7][0]; double C7_y = hexCorners[7][1]; double C7_z = hexCorners[7][2];
double C0_x = hexCorners[0][0];
double C0_y = hexCorners[0][1];
double C0_z = hexCorners[0][2];
double C1_x = hexCorners[1][0];
double C1_y = hexCorners[1][1];
double C1_z = hexCorners[1][2];
double C2_x = hexCorners[2][0];
double C2_y = hexCorners[2][1];
double C2_z = hexCorners[2][2];
double C3_x = hexCorners[3][0];
double C3_y = hexCorners[3][1];
double C3_z = hexCorners[3][2];
double C4_x = hexCorners[4][0];
double C4_y = hexCorners[4][1];
double C4_z = hexCorners[4][2];
double C5_x = hexCorners[5][0];
double C5_y = hexCorners[5][1];
double C5_z = hexCorners[5][2];
double C6_x = hexCorners[6][0];
double C6_y = hexCorners[6][1];
double C6_z = hexCorners[6][2];
double C7_x = hexCorners[7][0];
double C7_y = hexCorners[7][1];
double C7_z = hexCorners[7][2];
double dN0_di = ( -1 + j + k - jk );
double dN1_di = ( +1 - j - k + jk );
@ -269,6 +295,8 @@ public:
double dN6_dk = ( +1 + i + j + ij );
double dN7_dk = ( +1 - i + j - ij );
// clang-format off
double dx_di = k_1_8 * ( (dN0_di) * C0_x + (dN1_di) * C1_x + (dN2_di) * C2_x + (dN3_di) * C3_x + (dN4_di) * C4_x + (dN5_di) * C5_x + (dN6_di) * C6_x + (dN7_di) * C7_x );
double dx_dj = k_1_8 * ( (dN0_dj) * C0_x + (dN1_dj) * C1_x + (dN2_dj) * C2_x + (dN3_dj) * C3_x + (dN4_dj) * C4_x + (dN5_dj) * C5_x + (dN6_dj) * C6_x + (dN7_dj) * C7_x );
double dx_dk = k_1_8 * ( (dN0_dk) * C0_x + (dN1_dk) * C1_x + (dN2_dk) * C2_x + (dN3_dk) * C3_x + (dN4_dk) * C4_x + (dN5_dk) * C5_x + (dN6_dk) * C6_x + (dN7_dk) * C7_x );
@ -296,11 +324,11 @@ public:
dx_dk, dy_dk, dz_dk
);
#endif
// clang-format on
}
private:
static double interpolateInNormElm( const cvf::Vec3d& pointInNormElm, const std::array<double, 8>& values )
{
std::array<double, 8> Ni = interpolationCoeffs( pointInNormElm );
@ -344,16 +372,14 @@ private:
// could use as optimization ... >> double onk = 1 - k;
// could use as optimization ... >> double opk = 1 + k;
return {
k_1_8 *(1-i)*(1-j)*(1-k),
return {k_1_8 * ( 1 - i ) * ( 1 - j ) * ( 1 - k ),
k_1_8 * ( 1 + i ) * ( 1 - j ) * ( 1 - k ),
k_1_8 * ( 1 + i ) * ( 1 + j ) * ( 1 - k ),
k_1_8 * ( 1 - i ) * ( 1 + j ) * ( 1 - k ),
k_1_8 * ( 1 - i ) * ( 1 - j ) * ( 1 + k ),
k_1_8 * ( 1 + i ) * ( 1 - j ) * ( 1 + k ),
k_1_8 * ( 1 + i ) * ( 1 + j ) * ( 1 + k ),
k_1_8 *(1-i)*(1+j)*(1+k)
};
k_1_8 * ( 1 - i ) * ( 1 + j ) * ( 1 + k )};
}
static cvf::Vec3d findNormalizedCoords( const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& P )
@ -381,4 +407,6 @@ private:
}
};
}
} // namespace caf
// clang-format on

View File

@ -34,18 +34,18 @@
//
//##################################################################################################
#include <iostream>
#include "gtest/gtest.h"
#include <iostream>
#include "../cafHexInterpolator.h"
#include "cvfMatrix4.h"
namespace caf {
namespace caf
{
class HexInterpolatorTester
{
};
}
} // namespace caf
void testHex( const std::array<cvf::Vec3d, 8>& hexCorners, double tolerance = 1e-4 )
{
@ -68,26 +68,24 @@ void testHex(const std::array<cvf::Vec3d, 8>& hexCorners, double tolerance = 1e-
EXPECT_NEAR( result, 7.0, tolerance );
cvf::Vec3d avg = cvf::Vec3d::ZERO;
for ( const auto & v : hexCorners) avg += v;
for ( const auto& v : hexCorners )
avg += v;
avg *= 0.125;
result = caf::HexInterpolator::interpolateHex( hexCorners, {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}, avg );
EXPECT_NEAR( result, 3.5, tolerance );
}
TEST( InterpolationTest, UnitElement )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
testHex( hexCorners );
}
@ -95,18 +93,17 @@ TEST(InterpolationTest, UnitElement)
TEST( InterpolationTest, ScaledElement )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
for ( auto & v : hexCorners) v *= 2;
for ( auto& v : hexCorners )
v *= 2;
testHex( hexCorners );
}
@ -114,18 +111,17 @@ TEST(InterpolationTest, ScaledElement)
TEST( InterpolationTest, TranslatedElement )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
for ( auto & v : hexCorners) v += {2.2, 4.4, -7.6};
for ( auto& v : hexCorners )
v += {2.2, 4.4, -7.6};
testHex( hexCorners );
}
@ -133,20 +129,19 @@ TEST(InterpolationTest, TranslatedElement)
TEST( InterpolationTest, RotatedElement )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
cvf::Mat4d rot = cvf::Mat4d::fromRotation( {1, 1, 0}, 3.14159 );
for ( auto & v : hexCorners) v.transformPoint(rot);
for ( auto& v : hexCorners )
v.transformPoint( rot );
testHex( hexCorners );
}
@ -154,24 +149,25 @@ TEST(InterpolationTest, RotatedElement)
TEST( InterpolationTest, CombinedUndeformed )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
for ( auto & v : hexCorners) v *= 2;
for ( auto& v : hexCorners )
v *= 2;
for ( auto & v : hexCorners) v += {2.2, 4.4, -7.6};
for ( auto& v : hexCorners )
v += {2.2, 4.4, -7.6};
cvf::Mat4d rot = cvf::Mat4d::fromRotation( {1, 1, 0}, 3.14159 );
for ( auto & v : hexCorners) v.transformPoint(rot);
for ( auto& v : hexCorners )
v.transformPoint( rot );
testHex( hexCorners );
}
@ -179,28 +175,31 @@ TEST(InterpolationTest, CombinedUndeformed)
TEST( InterpolationTest, Compressed )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
for ( auto & v : hexCorners) v[0] *= 0.1;
for ( auto& v : hexCorners )
v[0] *= 0.1;
testHex( hexCorners );
for ( auto & v : hexCorners) v[0] *= 10.0;
for ( auto & v : hexCorners) v[1] *= 0.1;
for ( auto& v : hexCorners )
v[0] *= 10.0;
for ( auto& v : hexCorners )
v[1] *= 0.1;
testHex( hexCorners );
for ( auto & v : hexCorners) v[1] *= 10.0;
for ( auto & v : hexCorners) v[2] *= 0.1;
for ( auto& v : hexCorners )
v[1] *= 10.0;
for ( auto& v : hexCorners )
v[2] *= 0.1;
testHex( hexCorners );
}
@ -208,18 +207,17 @@ TEST(InterpolationTest, Compressed)
TEST( InterpolationTest, Scewed )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
for ( int i = 4 ; i< 8 ; ++i) hexCorners[i] += {1.0, 0.0, 0.0};
for ( int i = 4; i < 8; ++i )
hexCorners[i] += {1.0, 0.0, 0.0};
testHex( hexCorners );
}
@ -227,20 +225,19 @@ TEST(InterpolationTest, Scewed)
TEST( InterpolationTest, Screwed )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
cvf::Mat4d rot = cvf::Mat4d::fromRotation( {0, 0, 1}, 1.0 * 0.25 * 3.14159 );
for ( int i = 4 ; i< 8 ; ++i) hexCorners[i].transformPoint(rot);
for ( int i = 4; i < 8; ++i )
hexCorners[i].transformPoint( rot );
testHex( hexCorners );
}
@ -248,21 +245,20 @@ TEST(InterpolationTest, Screwed)
TEST( InterpolationTest, Warp )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
{
std::array<cvf::Vec3d, 8> cornerCopy = hexCorners;
// Compress x
for ( auto & v : cornerCopy ) v[0] *= 0.1;
for ( auto& v : cornerCopy )
v[0] *= 0.1;
cornerCopy[0][0] += 0.25;
cornerCopy[1][0] += 0.20;
@ -275,7 +271,8 @@ TEST(InterpolationTest, Warp)
{
std::array<cvf::Vec3d, 8> cornerCopy = hexCorners;
// Compress z
for ( auto & v : cornerCopy ) v[2] *= 0.1;
for ( auto& v : cornerCopy )
v[2] *= 0.1;
cornerCopy[0][2] += 0.25;
cornerCopy[2][2] += 0.25;
@ -289,28 +286,28 @@ TEST(InterpolationTest, Warp)
TEST( InterpolationTest, TotalCombined )
{
// Identity element
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(-1.0,-1.0,-1.0),
std::array<cvf::Vec3d, 8> hexCorners = {cvf::Vec3d( -1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, -1.0, -1.0 ),
cvf::Vec3d( 1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, 1.0, -1.0 ),
cvf::Vec3d( -1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, -1.0, 1.0 ),
cvf::Vec3d( 1.0, 1.0, 1.0 ),
cvf::Vec3d(-1.0, 1.0, 1.0)
};
cvf::Vec3d( -1.0, 1.0, 1.0 )};
cvf::Mat4d rot = cvf::Mat4d::fromRotation( {0, 0, 1}, 1.0 * 0.25 * 3.14159 );
for ( int i = 4 ; i< 8 ; ++i) hexCorners[i].transformPoint(rot);
for ( int i = 4 ; i< 8 ; ++i) hexCorners[i] += {0.2, 0.0, 0.0};
for ( int i = 4; i < 8; ++i )
hexCorners[i].transformPoint( rot );
for ( int i = 4; i < 8; ++i )
hexCorners[i] += {0.2, 0.0, 0.0};
{
std::array<cvf::Vec3d, 8> cornerCopy = hexCorners;
// Compress z
for ( auto & v : hexCorners ) v[2] *= 0.3;
for ( auto& v : hexCorners )
v[2] *= 0.3;
hexCorners[0][2] += 0.25;
hexCorners[2][2] += 0.25;
@ -318,14 +315,16 @@ TEST(InterpolationTest, TotalCombined)
hexCorners[6][2] += 0.4;
}
for ( auto & v : hexCorners) v *= 200;
for ( auto& v : hexCorners )
v *= 200;
for ( auto & v : hexCorners) v += {2.3e5, 4.7e6, -2000};
for ( auto& v : hexCorners )
v += {2.3e5, 4.7e6, -2000};
cvf::Mat4d rot2 = cvf::Mat4d::fromRotation( {1, 1, 0}, 3.14159 );
for ( auto & v : hexCorners) v.transformPoint(rot2);
for ( auto& v : hexCorners )
v.transformPoint( rot2 );
testHex( hexCorners );
}

View File

@ -34,10 +34,9 @@
//
//##################################################################################################
#include "gtest/gtest.h"
#include <stdio.h>
#include <iostream>
#include <stdio.h>
#include <string>
//--------------------------------------------------------------------------------------------------
@ -45,7 +44,6 @@
//--------------------------------------------------------------------------------------------------
int main( int argc, char** argv )
{
testing::InitGoogleTest( &argc, argv );
int result = RUN_ALL_TESTS();

View File

@ -1,9 +1,7 @@
namespace cvftest {
namespace cvftest
{
//==================================================================================================
//
//
@ -32,12 +30,11 @@ public:
std::string dir = std::string( testing::internal::FilePath::GetCurrentDir().ToString() );
std::string exe = dir + std::string( "/" ) + std::string( testing::internal::GetArgvs()[0] );
#endif
std::string glslPath = exe.substr(0, exe.find(unitTestFolder.toStdString())) + std::string("../LibRender/glsl/");
std::string glslPath = exe.substr( 0, exe.find( unitTestFolder.toStdString() ) ) +
std::string( "../LibRender/glsl/" );
return glslPath;
}
};
}
} // namespace cvftest

View File

@ -46,7 +46,6 @@
namespace caf
{
//==================================================================================================
/// Partial specialization for PdmValueFieldSpecialization< cvf::Color3f >
//==================================================================================================
@ -76,5 +75,4 @@ public:
}
};
} // end namespace caf

View File

@ -43,10 +43,8 @@
#include "cafPdmXmlMat4d.h"
namespace caf
{
template <>
class PdmValueFieldSpecialization<cvf::Mat4d>
{
@ -78,5 +76,4 @@ public:
}
};
} // end namespace caf

View File

@ -47,7 +47,6 @@ Q_DECLARE_METATYPE(cvf::Vec3d);
namespace caf
{
template <>
class PdmValueFieldSpecialization<cvf::Vec3d>
{
@ -77,8 +76,6 @@ public:
{
return variantValue == variantValue2;
}
};
} // end namespace caf

View File

@ -2,7 +2,6 @@
#include "gtest/gtest.h"
TEST( SerializeTest, PdmCoreColor3f )
{
float r = 0.4f;

View File

@ -34,10 +34,9 @@
//
//##################################################################################################
#include "gtest/gtest.h"
#include <stdio.h>
#include <iostream>
#include <stdio.h>
#include <string>
//--------------------------------------------------------------------------------------------------
@ -45,7 +44,6 @@
//--------------------------------------------------------------------------------------------------
int main( int argc, char** argv )
{
testing::InitGoogleTest( &argc, argv );
int result = RUN_ALL_TESTS();

View File

@ -34,10 +34,8 @@
//
//##################################################################################################
#pragma once
#include "cafPdmCoreColor3f.h"
#include "cafPdmXmlColor3f.h"
#include "cafPdmUiCoreColor3f.h"
#include "cafPdmXmlColor3f.h"

View File

@ -37,5 +37,5 @@
#pragma once
#include "cafPdmCoreMat4d.h"
#include "cafPdmXmlMat4d.h"
#include "cafPdmUiCoreMat4d.h"
#include "cafPdmXmlMat4d.h"

View File

@ -34,9 +34,8 @@
//
//##################################################################################################
#pragma once
#include "cafPdmCoreVec3d.h"
#include "cafPdmXmlVec3d.h"
#include "cafPdmUiCoreVec3d.h"
#include "cafPdmXmlVec3d.h"

View File

@ -72,6 +72,3 @@ void PdmFieldScriptabilityIOHandler<cvf::Color3f>::readFromField(const cvf::Colo
QString fieldStringValue = qColor.name();
PdmFieldScriptabilityIOHandler<QString>::readFromField( fieldStringValue, outputStream, quoteStrings );
}

View File

@ -37,7 +37,6 @@
#include "cvfColor3.h"
namespace caf
{
template <>
@ -52,4 +51,4 @@ struct PdmFieldScriptabilityIOHandler<cvf::Color3f>
bool quoteStrings = true,
bool quoteNonBuiltins = false );
};
}
} // namespace caf

View File

@ -43,10 +43,8 @@
#include "cafPdmXmlMat3d.h"
namespace caf
{
template <>
class PdmValueFieldSpecialization<cvf::Mat3d>
{
@ -78,5 +76,4 @@ public:
}
};
} // end namespace caf

View File

@ -37,5 +37,5 @@
#pragma once
#include "cafPdmCoreMat3d.h"
#include "cafPdmXmlMat3d.h"
#include "cafPdmUiCoreMat3d.h"
#include "cafPdmXmlMat3d.h"

View File

@ -47,7 +47,6 @@
namespace caf
{
template <>
class PdmUiFieldSpecialization<cvf::Mat3d>
{
@ -76,10 +75,7 @@ public:
}
/// Methods to retrieve the possible PdmObject pointed to by a field
static void childObjects(const PdmDataValueField< cvf::Mat3d >&, std::vector<PdmObjectHandle*>*)
{ }
static void childObjects( const PdmDataValueField<cvf::Mat3d>&, std::vector<PdmObjectHandle*>* ) {}
};
} // end namespace caf

View File

@ -40,7 +40,8 @@
#include "cafPdmProxyValueField.h"
#include "cafPdmUiColorEditor.h"
namespace caf {
namespace caf
{
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR( PdmUiColorEditor, cvf::Color3f );
}
@ -51,5 +52,4 @@ namespace caf {
//--------------------------------------------------------------------------------------------------
PdmColor3fInitializer::PdmColor3fInitializer()
{
}

View File

@ -45,10 +45,8 @@
#include "cafPdmCoreColor3f.h"
namespace caf
{
template <>
class PdmUiFieldSpecialization<cvf::Color3f>
{
@ -59,7 +57,6 @@ public:
return PdmValueFieldSpecialization<cvf::Color3f>::convert( value );
}
/// Set the field value from a QVariant
static void setFromVariant( const QVariant& variantValue, cvf::Color3f& value )
{
@ -78,14 +75,11 @@ public:
}
/// Methods to retrieve the possible PdmObject pointed to by a field
static void childObjects(const PdmDataValueField< cvf::Color3f >&, std::vector<PdmObjectHandle*>*)
{ }
static void childObjects( const PdmDataValueField<cvf::Color3f>&, std::vector<PdmObjectHandle*>* ) {}
};
} // end namespace caf
//--------------------------------------------------------------------------------------------------
// If the macro for registering the editor is put as the single statement
// in a cpp file, a dummy static class must be used to make sure the compile unit

View File

@ -47,7 +47,6 @@
namespace caf
{
template <>
class PdmUiFieldSpecialization<cvf::Mat4d>
{
@ -76,10 +75,7 @@ public:
}
/// Methods to retrieve the possible PdmObject pointed to by a field
static void childObjects(const PdmDataValueField< cvf::Mat4d >&, std::vector<PdmObjectHandle*>*)
{ }
static void childObjects( const PdmDataValueField<cvf::Mat4d>&, std::vector<PdmObjectHandle*>* ) {}
};
} // end namespace caf

View File

@ -41,10 +41,11 @@
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiListEditor.h"
namespace caf {
namespace caf
{
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR( PdmUiLineEditor, cvf::Vec3d );
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR( PdmUiListEditor, std::vector<cvf::Vec3d> );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
// If the macro for registering the editor is put as the single statement

View File

@ -45,10 +45,8 @@
#include "cvfBase.h"
#include "cvfVector3.h"
namespace caf
{
template <>
class PdmUiFieldSpecialization<cvf::Vec3d>
{
@ -77,14 +75,11 @@ public:
}
/// Methods to retrieve the possible PdmObject pointed to by a field
static void childObjects(const PdmDataValueField< cvf::Vec3d >&, std::vector<PdmObjectHandle*>*)
{ }
static void childObjects( const PdmDataValueField<cvf::Vec3d>&, std::vector<PdmObjectHandle*>* ) {}
};
} // end namespace caf
//--------------------------------------------------------------------------------------------------
// If the macro for registering the editor is put as the single statement
// in a cpp file, a dummy static class must be used to make sure the compile unit

View File

@ -57,4 +57,3 @@ QTextStream& operator << (QTextStream& str, const cvf::Vec3d& value)
return str;
}

View File

@ -44,12 +44,15 @@
static const std::string& fileExtension();
#define CAF_PDM_CODE_GENERATOR_SOURCE_INIT( ClassName, FileExtension ) \
const std::string& ClassName::fileExtension() { static std::string ext = FileExtension; return ext;} \
const std::string& ClassName::fileExtension() \
{ \
static std::string ext = FileExtension; \
return ext; \
} \
CAF_FACTORY_REGISTER( caf::PdmCodeGenerator, ClassName, std::string, ClassName::fileExtension() )
namespace caf {
namespace caf
{
class PdmObjectFactory;
//==================================================================================================
@ -61,7 +64,6 @@ public:
virtual QString generate( PdmObjectFactory* factory ) const = 0;
};
typedef Factory<PdmCodeGenerator, std::string> PdmCodeGeneratorFactory;
}
} // namespace caf

View File

@ -37,8 +37,8 @@
#include "cafPdmCodeGenerator.h"
namespace caf {
namespace caf
{
class PdmFieldHandle;
//==================================================================================================
@ -47,13 +47,13 @@ class PdmFieldHandle;
class PdmPythonGenerator : public PdmCodeGenerator
{
CAF_PDM_CODE_GENERATOR_HEADER_INIT;
public:
QString generate( PdmObjectFactory* factory ) const override;
static QString camelToSnakeCase( const QString& camelString );
static QString dataTypeString( const PdmFieldHandle* field, bool useStrForUnknownDataTypes );
static QString pythonifyDataValue( const QString& dataValue );
};
}
} // namespace caf

View File

@ -40,8 +40,8 @@
class QTextStream;
namespace caf {
namespace caf
{
class PdmScriptIOMessages
{
public:
@ -73,4 +73,4 @@ private:
int m_currentLineNumber;
};
}
} // namespace caf

View File

@ -34,14 +34,13 @@
//
//##################################################################################################
#pragma once
#include "cafAssert.h"
#include <cstddef>
#include <map>
#include <vector>
#include <cstddef>
// Taken from gtest.h
//
@ -62,13 +61,14 @@
/// There are two, to make it possible to use two registrations in one macro
#define CAF_FACTORY_REGISTER( BaseType, TypeToCreate, KeyType, key ) \
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(my##TypeToCreate) = caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>(key)
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME( my##TypeToCreate ) = \
caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>( key )
#define CAF_FACTORY_REGISTER2( BaseType, TypeToCreate, KeyType, key ) \
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(my2##TypeToCreate) = caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>(key)
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME( my2##TypeToCreate ) = \
caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>( key )
namespace caf
{
//==================================================================================================
/// A generic Factory class template
/// Usage:
@ -91,11 +91,11 @@ namespace caf
/// BaseType* newObject = caf::Factory<BaseType, KeyType>::instance()->create(key);
//==================================================================================================
template <typename BaseType, typename KeyType>
class Factory
{
class ObjectCreatorBase;
public:
typedef typename std::map<KeyType, ObjectCreatorBase*>::iterator iterator_type;
@ -185,5 +185,4 @@ namespace caf
std::map<KeyType, ObjectCreatorBase*> m_factoryMap;
};
} // End of namespace caf

View File

@ -34,14 +34,12 @@
//
//##################################################################################################
#pragma once
#include <omp.h>
namespace caf
{
//==================================================================================================
/// OpenMP mutex definition
/// Taken from http://bisqwit.iki.fi/story/howto/openmp/
@ -61,7 +59,6 @@ private:
omp_lock_t m_lock;
};
//==================================================================================================
/// OpenMP scoped lock on a mutex
/// Taken from http://bisqwit.iki.fi/story/howto/openmp/
@ -69,15 +66,14 @@ private:
class ScopedLock
{
public:
explicit ScopedLock(MutexType& m) : m_mutex(m), m_locked(true)
explicit ScopedLock( MutexType& m )
: m_mutex( m )
, m_locked( true )
{
m_mutex.lock();
}
~ScopedLock()
{
unlock();
}
~ScopedLock() { unlock(); }
void unlock()
{
@ -102,4 +98,4 @@ private: // prevent copying the scoped lock.
ScopedLock( const ScopedLock& );
};
}
} // namespace caf

Some files were not shown because too many files have changed in this diff Show More