Commit Graph

21 Commits

Author SHA1 Message Date
jean-pierre charras 61acac28e1 Add patch from Lorenzo Marcantonio. Fix some warning issues, and zlib issue under Windows (zlib sources added) 2012-05-03 20:37:56 +02:00
Dick Hollenbeck c24863c078 // Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did.  This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.


#include <stdio.h>
#include <assert.h>
#include <limits.h>

//-----<KiROUND KIT>------------------------------------------------------------

/**
 * KiROUND
 * rounds a floating point number to an int using
 * "round halfway cases away from zero".
 * In Debug build an assert fires if will not fit into an int.
 */

#if defined( DEBUG )

// DEBUG: a macro to capture line and file, then calls this inline

static inline int KiRound( double v, int line, const char* filename )
{
    v = v < 0 ? v - 0.5 : v + 0.5;
    if( v > INT_MAX + 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    else if( v < INT_MIN - 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    return int( v );
}

#define KiROUND( v )    KiRound( v, __LINE__, __FILE__ )

#else

// RELEASE: a macro so compile can pre-compute constants.

#define KiROUND( v )  int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )

#endif


//-----</KiROUND KIT>-----------------------------------------------------------

// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );


int main( int argc, char** argv )
{
    for( double d = double(INT_MAX)-1;  d < double(INT_MAX)+8;  d += 2.0 )
    {
        int i = KiROUND( d );

        printf( "t: %d  %.16g\n", i, d );
    }

    return 0;
}
2012-04-19 01:55:45 -05:00
Andrey Fedorushkov 9eb7cba156 revert my bug commit 3389 2012-02-01 15:53:32 +04:00
Andrey Fedorushkov 0c00c88f11 fix DXF plot arc 2012-02-01 13:36:43 +04:00
Dick Hollenbeck b8a0ab4c52 switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
Wayne Stambaugh b774d96fb0 Minor coding policy and code readability improvements. 2012-01-03 12:14:17 -05:00
Wayne Stambaugh 4b853dedb4 Application name capitalization fixes.
* Correct all user strings and comments for the correct capitalization of
  application names according to JP.  They are KiCad, Pcbnew, CvPcb,
  Eeschema, and GerbView.
* Add a note the the user interface policy about the correct capitalization.
2011-09-30 14:15:37 -04:00
jean-pierre charras 4402c97c7a Eeschema: Fix a subtle bug in undo command when editing texts and labels.
Add a new schematic item: SCH_BITMAP. One can insert now images in a schematic.
Add Fabrizio Tappero as contributor  in Kicad About dialog
2011-08-31 16:59:20 +02:00
jean-pierre charras c89070da83 Plot poly code cleaning. Suppress erreurs for malformed polygons (< 2 corners) 2011-04-20 10:13:21 +02:00
jean-pierre charras 92952b70aa Use UTF-8 encoding only in kicad files. Under Linux, this was already the case. Under Windows, texts with non ascii characters must be corrected.
This ensure compatibility between platforms.
2011-02-28 19:36:19 +01:00
jean-pierre charras 258cebf1a8 Fix some Doxygen warnings. No new code. 2010-12-28 12:24:42 +01:00
jean-pierre charras e9f557e65a Pcbnew plot functions: code cleanup, coding policy fixes and minor enhancements 2010-12-11 19:40:39 +01:00
Dick Hollenbeck 636b2d301e function comments, fix ones in *.cpp files until they can be deleted if they exist in the headers 2010-11-12 10:36:43 -06:00
jean-pierre charras e162ffee3c Use D_PAD::BuildPadPolygon() in plot functions 2010-09-13 13:51:09 +02:00
charras 5f5620a1b9 ++Pcbnew
Pcbnew: Fixed an issue in GERBER file creation, under Vista and W7 only for non administrator users
Plot files were 0 byte length.
This was due to use of function tmpfile() in a GERBER function to create a temporary file that seems not working using mingw.
Replaced by more usual files functions.
2010-03-31 16:59:32 +00:00
viknn 8be7f467e8 Added filling of junctions circles to EEschema DXF export 2010-02-10 17:27:45 +00:00
stambaughw 1aaa7a9bf2 Compiler warning, object name, bug, and string fixes.
* Fixed EESchema options dialog focus bug so escape key now works in GTK.
* Rename schematic objects for improved readability.
* Fixed GCC compiler warnings in plot code.
* Added paragraph in UIpolicies.txt about setting dialog box sizes.
* Lots of message box string clean up.
2009-12-02 21:44:03 +00:00
stambaughw bc5d9a75f5 Complete comment translation of common source. 2009-11-23 15:16:50 +00:00
charras c3fde30419 code cleaning. Pcbnew: Minor enhancements in Plot dialog 2009-08-29 10:20:48 +00:00
charras aa509dda2d changes in common_plotDFX.cpp to avoid compil warnings 2009-07-01 05:20:11 +00:00
charras f7a804e23d Bugfix for plotting 2009-06-30 10:43:20 +00:00