C++ (Qt)#ifndef MESHPROGRESS_H#define MESHPROGRESS_H struct CMeshProgress { CMeshProgress ( void ); virtual ~CMeshProgress ( void ); virtual bool _Update ( long cur ); virtual void _SetIndicator ( const char * text, long maxNum ); static bool Update ( long cur, long step ); static void SetIndicator ( const char * text, long maxNum ); // data members static CMeshProgress * mInstance;}; inline CMeshProgress::CMeshProgress( void ){ mInstance = this;} inline CMeshProgress::~CMeshProgress( void ) { mInstance = 0; } inline bool CMeshProgress::_Update( long cur ) { return true; } inline void CMeshProgress::_SetIndicator( const char *, long ) {} inline bool CMeshProgress::Update( long cur, long step ){ if (((cur + 1) % step) != 0) return true; return mInstance ? mInstance->_Update(cur) : true;} inline void CMeshProgress::SetIndicator( const char * text, long maxNum ){ if (mInstance) mInstance->_SetIndicator(text, maxNum);}#endif // MESHPROGRESS_H
C++ (Qt)int CMeshCalculator::CalcNormals( void ){ CMeshProgress::SetIndicator("Calculating Normals", mNormals.size()); ... for (size_t i = 0; i < count; ++i) { .. if (!CMeshProgress::Update(i, 100)) return ERR_USER_CANCEL; .. Calc1Normal(..); }}