Hotglue wxLogDebug into math/util.h without the global include

This commit is contained in:
Marek Roszko 2021-06-01 23:14:14 -04:00
parent 5f581aa6ad
commit 0b4a680dbb
2 changed files with 22 additions and 0 deletions

View File

@ -31,6 +31,11 @@
#include <limits>
#include <typeinfo>
/**
* Helper to avoid directly including wx/log.h for the templated functions in kimath
*/
void kimathLogDebug( const char* aFormatString, ... );
/**
* Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
@ -70,6 +75,8 @@ constexpr ret_type KiROUND( fp_type v )
if( std::numeric_limits<ret_type>::max() < ret ||
std::numeric_limits<ret_type>::lowest() > ret )
{
kimathLogDebug( "Overflow KiROUND converting value %f to %s", double( v ),
typeid( ret_type ).name() );
return 0;
}

View File

@ -27,6 +27,21 @@
#include <cstdlib>
#include <climits>
#include <math/util.h>
#include <wx/log.h>
void kimathLogDebug( const char* aFormatString, ... )
{
if( wxLog::IsLevelEnabled( wxLOG_Debug, wxASCII_STR( wxLOG_COMPONENT ) ) )
{
va_list argList;
va_start( argList, aFormatString );
wxVLogWarning( aFormatString, argList );
va_end( argList );
}
}
template<>
int rescale( int aNumerator, int aValue, int aDenominator )