Commit Graph

123 Commits

Author SHA1 Message Date
Lorenzo Marcantonio 082d901d60 Encapsulated drawmode as an enum for type checking 2012-09-01 15:38:27 +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
Wayne Stambaugh 45445dd88f Minor code improvements and coding policy fixes.
* BLOCK_SELECTOR class is not longer derived from EDA_ITEM.
* Encapsulate BLOCK_SELECTOR class member variables and add access methods.
* Move HandleBlockBegin() function from block_commande.cpp to drawframe.cpp.
* Remove virtual methods from top level derived objects per future
  coding policy change.
* Remove Doxygen copydoc statement from objects derived from EDA_ITEM
  since the comments are automatically copied to the derived object.
* Removed copy and pasted Doxygen comments from objects derived from
  EDA_ITEM.
2012-03-26 19:47:08 -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
marco. 54c20b57f2 MacOSX: Main issue catch! wxPen with size 0 draws NOTHING (8 months to spot it) 2012-01-10 20:52:48 +01: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 560abfa30a gr_basic.cpp: fix a bug I created in my last commit. Pcbnew: fix a very minor bug in hight light behavior 2011-04-15 16:10:20 +02:00
jean-pierre charras 14e3507e16 gr_basic: fix incorrect clipping of thick lines (due to changes in code, the thickness was not taken in account to calculate the clip box size)
Pcbnew: fix a very minor bug.
2011-04-14 20:44:46 +02:00
jean-pierre charras e9c618b65a gr_basic: fix incorrect clipping of thick lines (due to changes in code, the thickness was not taken in account to calculate the clip box size) 2011-04-13 12:22:58 +02:00
Vladimir Ur bf44999a6c Recangle program rewritten so it became more accurate on a screen 2011-04-12 21:21:22 +04:00
Wayne Stambaugh 67f70fe079 Coding style and Doxygen comment fixes.
* Rename EDA_Rect class to EDA_RECT.
* Rename EDA_TextStruct class to EDA_TEXT.
* Remove duplicate Doxygen comments from sch_sheet_path.cpp.
2011-03-29 15:33:07 -04:00
Wayne Stambaugh 85ae0373e3 Global variable removal and coordinate fixes.
* ActiveScreen global variable is gone, yeah!
* Use drawing coordinates instead of screen coordinates when calling
  GeneralControle().
2011-02-01 10:46:25 -05:00
Wayne Stambaugh 44e474c25c Drawing, pcbnew, and other minor fixes.
* Use wxDC to calculate screen center position.
* Minor grid drawing optimization.
* Remove an unnecessary use of global variable ActiveScreen.
* Doxygen warning fixes.
2011-01-31 13:26:12 -05:00
Wayne Stambaugh d657b43052 Use wxDC for all coordinate manipulations.
* Remove all occurrences if #ifdef USE_WX_ZOOM and all associated code within
  the #else/#endif block ( old zoom code ).
* Removed the build option for USE_WX_ZOOM from CMakeList.txt and config.h.in.
* Removed all scaling code in base screen object.
* Fixed buffered paint and buffered client DC on Windows.  Buffering works
  properly on Linux and Windows.
* Modified kicad_device_context.h to automatically uses buffering on platforms
  where double buffering is supported natively.
* Remove all of the scaled versions of the drawing functions in gr_basic.cpp
  and any support code.
* Removed all traces of ActiveScreen global variable from eeschema and
  gerbview.
* Renamed Recadre_Trace to RedrawScreen in draw frame object.
* Renamed PostDirtyRect to RefreshDrawingRect in draw panel object.
* Lots of code cleaning an Doxygen comment improvements.
2011-01-30 17:22:38 -05:00
jean-pierre charras 5bab73d638 Eeschema: fix issues in drag command (mainly hotkey command and forgotten wire ends connected to components to drag).
Rename EDA_Rect::Inside to EDA_Rect::Contains ( EDA_Rect::Inside( const EDA_Rect& aRect ) was very ambiguous )
 Fix some Doxygen warnings and erroneous comments; Add comments.
2010-12-20 18:44:25 +01:00
Marco Serantoni 81b3fdf157 Mac: OVERLAY FIXES for WX2.8 and Enhancements 2010-12-17 23:57:09 +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 387bbe2b22 Pcbnew: fixed bug 666210 2010-10-25 18:48:05 +02:00
jean-pierre charras 1206177ce0 Gerbview: minor enhancement. Boost::Polygon: commit forgotten file 2010-10-23 20:12:11 +02:00
jean-pierre charras 6b05cf315f Fixed bug in GRLineArray(). Cleanup Gerbview code 2010-10-13 21:50:23 +02:00
jean-pierre charras cc6cae9b12 Gerbview: added support of mirroring, scaling an offseting RS274X commands 2010-10-09 22:05:03 +02:00
Marco Serantoni ea812ef5c9 Zones drawing optimization with WXGrapchisContext + Fix bug #612132 2010-10-09 10:08:29 +02:00
jean-pierre charras 69b3bfd471 added forgotten lines from patch "EEschema selection.patch" 2010-10-06 22:16:31 +02:00
jean-pierre charras f431869300 added forgotten lines from patch "EEschema selection.patch" 2010-10-06 21:35:20 +02:00
jean-pierre charras 3c6c7134af added forgotten lines from patch "EEschema selection.patch" 2010-10-06 20:43:51 +02:00
jean-pierre charras 0687921fa9 Gerbview: display now an error report after loading a gerber file. 2010-10-05 21:54:27 +02:00
Wayne Stambaugh 40c7d81bbd Fix build errors when compiling against wxWidgets 2.8.x.
* Changed wxPenStyle which is not define in wxWidgets 2.8 to int and
  renamed GRRect to prevent duplicate function definition in gr_basic.
* Add missing wxT() macros to strings in rs274x.cpp.
2010-10-05 09:46:53 -04:00
jean-pierre charras 9f4e57d428 Some cleanup and fixes in gerbview. Cleanup gr_basic.* and added in gr_basic.* a minor modification coming from "EEschema selection.patch". 2010-10-05 13:44:34 +02:00
jean-pierre charras 659299ee8f Gerbview: more about apertures macros and draw funtions. 2010-10-01 21:11:30 +02:00
jean-pierre charras b992af3eb3 Gerbview code redesign 2010-09-28 16:42:05 +02:00
Marco Serantoni 27e9eedd9d speedup enhancement and little cleanup 2010-09-21 21:21:46 +02:00
jean-pierre charras bcd4d4ecde fixed a minor artefact when 45 deg segments are drawn in sketch mode 2010-09-21 08:35:11 +02:00
jean-pierre charras 658ca2a21e Fixed some issues about trapezoidal pads. Better pad editor dialog. fixed other (very) minor bugs. Code cleaning 2010-09-11 18:33:43 +02:00
jean-pierre charras 642d1f2ea6 fixed very minor compil warnings. (no bugs) 2010-07-12 21:28:38 +02:00
charras 1aaabf2c0f Removing min size pen, now useless. Replaced when needed in some print dialogs by Default pen size. 2010-02-22 19:56:32 +00:00
stambaughw aab2f8a775 USE_WX_ZOOM clean up and other minor improvements.
* Make USE_WX_ZOOM clipping routine actually clip rather than just test
  if line needs drawn.
* Clean up as many USE_WX_ZOOM #ifdefs as possible.
* Minor coordinate rounding improvements.
* Minor scrolling and panning improvements.
* Remove unused KicadGraphicContext object code.
2010-02-22 16:45:35 +00:00
stambaughw ac82654563 More USE_WX_ZOOM bug fixes.
* Changed line clipping function in gr_basic.cpp when USE_WX_ZOOM is
  enabled.
* Set wxDC clipping region to client size when drawing outside of paint
  event handler.
* Updated kicad and eeschema CMake files as the common library now
  requires linking to the polygon library.
2010-02-11 19:57:47 +00:00
stambaughw 5591ccd443 USE_WX_ZOOM fixes.
* Corrected over zealous clipping fix in last commit.
* Tweaked clip box rectangle size.
* Fixed cross hair cursor drawing bug.
2010-02-10 21:39:32 +00:00
stambaughw f69a4914fe Minor drawing and build bug fixes.
* Fixed clipping bug when USE_WX_ZOOM is enabled that causes rats nest
  to be drawn incorrectly.
* Fix ambiguous function error in trigo.cpp when building with MSVS.
* Add instructions for building wxWidgets with graphics context
  enabled (GDI+) using MinGW/MSYS to COMPILING.txt.
* Initial EESchema find dialog work.
* Set modified flag when using PCBNew global deletion dialog to prevent
  closing without warning user of changes.
2010-02-10 16:25:13 +00:00
stambaughw 3066c70559 Implement wxDC coordinate handling and wxGCDC.
* Implement code to allow wxDC to handle coordinate conversions between
  device and drawing units.
* Add build settings to enable wxGCDC for wxGraphicsContext testing.
* Remove wxAUI conditional build cruft as it is now required to build
  Kicad.
* Fix scroll increment size regression to prevent jumping around the
  zoom center position.
* Add find GDI+ cmake module for building on WXMSW when wxGraphicsContext
  is enabled.
2010-02-08 18:15:42 +00:00
charras 1b6ad8c7f7 code cleaning and a minor problem fixed in Gerbview printing option 2010-01-04 19:09:33 +00:00
charras a1998410fc Some enhancements and fixes. (see changelog) 2009-12-30 18:06:12 +00:00
stambaughw bc5d9a75f5 Complete comment translation of common source. 2009-11-23 15:16:50 +00:00
charras cffe0cfcaa support for bezier curves 2009-06-25 20:45:27 +00:00
charras 23dace1dc8 macOSX compatibility change 2009-05-30 19:34:13 +00:00
charras ce9db78c95 Cleaned and optimized code about new hershey fonts and bold texts handling (see changelog) 2009-05-30 16:06:01 +00:00
charras 497cb9f7d0 code cleanup 2009-05-25 16:07:33 +00:00
stambaughw 8bf7911125 Build improvements, compiler warning fixes and build fixes, and lots of clean up.
* Created separate SVN version header.
* Add true config.h for platform dependency checks.
* Add dependency check cmake module.
* Remove some leftover hand crafted make files.
* Remove non-cmake build instructions from COMPILING.txt.
* Fix split _() strings causing Visual C++ compiler error.
* Fix lots of compiler warnings.
* Change project file parameter container from wxArray to boost::vector_ptr.
* Removed lots of redundant header definitions.
* Fixed green_xpm redefinition in ercgreen.xpm.
* Remove some dead code and unnecessary class methods.
2009-05-21 17:42:42 +00:00
charras bb5832c863 Fixed: incorrect refresh of screen area after closing a popup menu (texts and polygons sometimes not redrawn) 2009-04-17 12:45:22 +00:00
charras 7ab924c3e1 minor bugs fixed, and remove warnings when using wxWidgets 3 in specctra.cpp 2009-04-16 08:48:54 +00:00
charras 20cb87a8b7 better handling of libraries paths (removed g_RealLibraryBuffer that had no sense with the new code), mainly in Eeschema
TODO: better handling of user lib paths (more than one path)
2009-04-14 16:45:22 +00:00
charras 89e7f96574 made kicad compilable with wxWidgets 2.9 (wxWidgets 3) 2009-04-13 05:58:11 +00:00
stambaughw dfb88c6495 Library search path fixes, library configuration dialog fixes, and code cleaning.
Added application method to fix searching for user libraries.
Fixed documentation search path bug.
Moved auto pan setting from draw frame to draw panel were it is defined.
Some minor device context drawing changes.
2009-04-08 18:06:22 +00:00
stambaughw 689579bde1 Global variable unobfuscation, new library path search, and lots of other changes. See CHANGELOG.txt. 2009-04-05 20:49:15 +00:00
charras 2eaa28f0cb Pcbnew: some enhancements 2009-03-26 19:27:50 +00:00
charras f2c03f2b97 gr_basic.cpp now clips filled polygons,using the Sutherland and Hodgman algo to clip the poly against a rectangle
Filled polygons are now correctly displayed under Linux(i hope)
2009-02-20 14:31:16 +00:00
charras 69756df3f6 Some update for Kicad Release Candidate 1 2009-02-16 10:28:46 +00:00
stambaughw b833a46bad More header file realignments to reduce recompiling and general code cleaning. 2009-02-04 15:25:03 +00:00
stambaughw 2e5a57e100 New zoom implementation and some build optimizations. 2009-01-29 14:26:20 +00:00
stambaughw 21faf9d370 Integrate wxFileHistory, add missing header files to fix Linux build, initial search path work, and general housekeeping. 2009-01-17 20:31:19 +00:00
dickelbeck 0d790e57a2 polygon work, EDGE_MODULE::m_PolyPoints is now std::vector 2008-12-29 18:02:54 +00:00
charras 75b3c3bf37 Switch to polygons in zones (old way no more supported)
areas can be now filled using solid polygons, or using segments to fill areas inside polygons.
2008-12-03 10:32:53 +00:00
charras 365dbe15b8 Enhancement in zones filling by polygon, and better display for small texts
(more noticeable in eeschema)
2008-10-31 17:02:24 +00:00
charras 5f777f8c60 pcbnew: bug solved: pad holes not printed 2008-08-09 08:05:42 +00:00
charras 1f34ed0583 minor bug 1974672 solved 2008-07-20 12:59:52 +00:00
dickelbeck 9d395aa0c5 MAC alpha support 2008-04-02 14:16:14 +00:00
lifekidyeaa c7ec524fc7 eeschema: fixed:
* crash when creating a sheet that does not yet have a sch file
* when loading schematic file v 1 annotations are applied to all sheets independent of path in hierarchy
* component reference is drawn by default upon placing a new libary comp.
2008-02-15 23:21:33 +00:00
dickelbeck e35e2eac8d fixed compiler warning 2007-12-22 07:16:45 +00:00
dickelbeck 9fe9fc7c00 fix macro to inline conversion 2007-10-31 17:44:51 +00:00
dickelbeck f353c77cdc more zone preps 2007-10-31 06:40:15 +00:00
raburton dedb0228dc add files not currently available in source (e.g. docs, modules, etc.)
set svn:eol-style property to native for all ascii files to support cross platform development
2007-06-05 12:10:51 +00:00
dickelbeck ae74527bc2 Jean-Pierre's changes for kicad-2007-05-25 release 2007-05-28 18:09:49 +00:00
plyatov 23c40f7e86 Initial import of KiCad. 2007-05-06 16:03:28 +00:00