From 3f8343b3416596e6ff1c737cafe3e042d0b225aa Mon Sep 17 00:00:00 2001 From: Carl Poirier Date: Tue, 6 Aug 2013 18:21:40 -0500 Subject: [PATCH] REMOVE: USE_PCBNEW_NANOMETERS by making it the only way to go in pcbnew, effectively removing the deci-mils build. --- CMakeLists.txt | 3 --- CMakeModules/config.h.cmake | 9 +------ Documentation/compiling/build-config.txt | 4 --- HOW_TO_CONTRIBUTE.txt | 4 +-- common/basicframe.cpp | 7 ------ common/drawframe.cpp | 4 --- include/convert_from_iu.h | 16 +----------- include/convert_to_biu.h | 29 ++++++--------------- pcbnew/CMakeLists.txt | 4 --- pcbnew/basepcbframe.cpp | 22 ---------------- pcbnew/class_board_item.cpp | 2 +- pcbnew/classpcb.cpp | 10 -------- pcbnew/legacy_plugin.cpp | 23 +---------------- pcbnew/specctra_export.cpp | 20 +-------------- pcbnew/specctra_import.cpp | 32 ------------------------ 15 files changed, 14 insertions(+), 175 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21b2f16411..fe85f4c05a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) # reports. # -option(USE_PCBNEW_NANOMETRES - "Use nanometers for Pcbnew internal units instead of deci-mils (default ON)." ON) - # Russian GOST patch option(wxUSE_UNICODE "enable/disable building unicode (default OFF)") option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)") diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake index 4914b6c417..eec9fc8547 100644 --- a/CMakeModules/config.h.cmake +++ b/CMakeModules/config.h.cmake @@ -75,15 +75,8 @@ #cmakedefine USE_IMAGES_IN_MENUS 1 -/// Definitions to enable the s-expression file formats and nanometer units. -#cmakedefine USE_PCBNEW_NANOMETRES - /// The legacy file format revision of the *.brd file created by this build -#if defined(USE_PCBNEW_NANOMETRES) -#define LEGACY_BOARD_FILE_VERSION 2 -#else -#define LEGACY_BOARD_FILE_VERSION 1 -#endif +#define LEGACY_BOARD_FILE_VERSION 2 /// Definition to compile with Pcbnew footprint library table implementation. #cmakedefine USE_FP_LIB_TABLE diff --git a/Documentation/compiling/build-config.txt b/Documentation/compiling/build-config.txt index 058106fcb6..6daa3618e7 100644 --- a/Documentation/compiling/build-config.txt +++ b/Documentation/compiling/build-config.txt @@ -111,10 +111,6 @@ This option is used to enable or disable building KiCad with images in menu items. If this is not defined when CMake is used to create the build files, images will be included in menu items on all platforms except OSX. -USE_PCBNEW_NANOMETRES (ON/OFF) -This option is used to enable or disable the nano-meter internal units for -Pcbnew. The default is ON. - KICAD_GOST (ON/OFF) ------------------- This option is used to enable or disable the GOST notation for multiple gates diff --git a/HOW_TO_CONTRIBUTE.txt b/HOW_TO_CONTRIBUTE.txt index 746d3e3698..510c49e6c1 100644 --- a/HOW_TO_CONTRIBUTE.txt +++ b/HOW_TO_CONTRIBUTE.txt @@ -25,10 +25,10 @@ Contribute to KiCad (under Linux) 6) Compile: cd kicad_john mkdir build; cd build - cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug + cmake ../ -DCMAKE_BUILD_TYPE=Debug to build a debug version or - cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release + cmake ../ -DCMAKE_BUILD_TYPE=Release to build a release version make diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 0c06bde3b2..b5434b01b5 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -502,13 +502,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) tmp << wxT( "Boost version: " ) << ( BOOST_VERSION / 100000 ) << wxT( "." ) << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." ) << ( BOOST_VERSION % 100 ) << wxT( "\n" ); - tmp << wxT( "Options: USE_PCBNEW_NANOMETRES=" ); -#ifdef USE_PCBNEW_NANOMETRES - tmp << wxT( "ON\n" ); -#else - tmp << wxT( "OFF\n" ); -#endif - tmp << wxT( " USE_WX_GRAPHICS_CONTEXT=" ); #ifdef USE_WX_GRAPHICS_CONTEXT tmp << wxT( "ON\n" ); diff --git a/common/drawframe.cpp b/common/drawframe.cpp index ac0669ef7d..06e8e018e5 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -755,7 +755,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) DBOX clientRectIU( xIU, yIU, clientSizeIU.x, clientSizeIU.y ); wxPoint centerPositionIU; -#if 1 || defined( USE_PCBNEW_NANOMETRES ) // put "int" limits on the clientRect if( clientRectIU.GetLeft() < VIRT_MIN ) clientRectIU.MoveLeftTo( VIRT_MIN ); @@ -765,7 +764,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) clientRectIU.MoveRightTo( VIRT_MAX ); if( clientRectIU.GetBottom() > VIRT_MAX ) clientRectIU.MoveBottomTo( VIRT_MAX ); -#endif centerPositionIU.x = KiROUND( clientRectIU.x + clientRectIU.width/2 ); centerPositionIU.y = KiROUND( clientRectIU.y + clientRectIU.height/2 ); @@ -838,11 +836,9 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) } } -#if 1 || defined( USE_PCBNEW_NANOMETRES ) // put "int" limits on the virtualSizeIU virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS ); virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS ); -#endif if( screen->m_Center ) { diff --git a/include/convert_from_iu.h b/include/convert_from_iu.h index 05f5e5a6bf..842777dc27 100644 --- a/include/convert_from_iu.h +++ b/include/convert_from_iu.h @@ -31,11 +31,10 @@ #ifndef _CONVERT_FROM_IU_ #define _CONVERT_FROM_IU_ -#include // USE_PCBNEW_NANOMETRES is defined here +#include /// Convert from internal units to user units. #if defined(PCBNEW) || defined(CVPCB) || defined(GERBVIEW) - #if defined( USE_PCBNEW_NANOMETRES ) #if defined(GERBVIEW) #define MM_PER_IU 1.0 / 1e5 // Gerbview uses 10 micrometer. #else @@ -43,32 +42,19 @@ #endif #define MILS_PER_IU ( MM_PER_IU * 0.0254 ) #define DECIMILS_PER_IU (MM_PER_IU * 0.00254 ) - #else // Pcbnew in deci-mils. - #define DECIMILS_PER_IU 1 - #define MILS_PER_IU 0.1 - #define MM_PER_IU (25.4 / 1e4) - #endif /// Convert PCBNEW internal units (iu) to mils. inline int Iu2Mils( int iu ) { -#if defined( USE_PCBNEW_NANOMETRES ) double x = iu * MILS_PER_IU; return int( x < 0 ? x - 0.5 : x + 0.5 ); -#else - return iu * MILS_PER_IU; -#endif } /// Convert PCBNEW internal units (iu) to deci-mils. inline int Iu2DMils( int iu ) { -#if defined( USE_PCBNEW_NANOMETRES ) double x = iu * DECIMILS_PER_IU; return int( x < 0 ? x - 0.5 : x + 0.5 ); -#else - return iu; -#endif } #else // Eeschema and anything else. diff --git a/include/convert_to_biu.h b/include/convert_to_biu.h index 5401930078..7df4af7516 100644 --- a/include/convert_to_biu.h +++ b/include/convert_to_biu.h @@ -1,7 +1,7 @@ #ifndef CONVERT_TO_BIU_H_ #define CONVERT_TO_BIU_H_ -#include // USE_PCBNEW_NANOMETRES is defined here +#include /** * @file convert_to_biu.h @@ -18,41 +18,26 @@ /// Scaling factor to convert mils to internal units. #if defined(PCBNEW) || defined(CVPCB) || defined(GERBVIEW) - #if defined( USE_PCBNEW_NANOMETRES ) - #if defined(GERBVIEW) - #define IU_PER_MM 1e5 // Gerbview IU is 10 nanometers. - #else - #define IU_PER_MM 1e6 // Pcbnew IU is 1 nanometer. - #endif - #define IU_PER_MILS (IU_PER_MM * 0.0254) - #define IU_PER_DECIMILS (IU_PER_MM * 0.00254) - - #else // Pcbnew compiled for deci-mils. - #define IU_PER_DECIMILS 1 - #define IU_PER_MILS 10.0 - #define IU_PER_MM (1e4 / 25.4) + #if defined(GERBVIEW) + #define IU_PER_MM 1e5 // Gerbview IU is 10 nanometers. + #else + #define IU_PER_MM 1e6 // Pcbnew IU is 1 nanometer. #endif + #define IU_PER_MILS (IU_PER_MM * 0.0254) + #define IU_PER_DECIMILS (IU_PER_MM * 0.00254) /// Convert mils to PCBNEW internal units (iu). inline int Mils2iu( int mils ) { -#if defined( USE_PCBNEW_NANOMETRES ) double x = mils * IU_PER_MILS; return int( x < 0 ? x - 0.5 : x + 0.5 ); -#else - return mils * IU_PER_MILS; -#endif } /// Convert deci-mils to PCBNEW internal units (iu). inline int DMils2iu( int dmils ) { -#if defined( USE_PCBNEW_NANOMETRES ) double x = dmils * IU_PER_DECIMILS; return int( x < 0 ? x - 0.5 : x + 0.5 ); -#else - return dmils; -#endif } #elif defined (PL_EDITOR) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 4b4c47f824..be4a999279 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -270,10 +270,6 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) set( SWIG_FLAGS ${SWIG_FLAGS} -D${d} ) endforeach() - if( USE_PCBNEW_NANOMETRES ) - set( SWIG_FLAGS ${SWIG_FLAGS} -DUSE_PCBNEW_NANOMETRES ) - endif( USE_PCBNEW_NANOMETRES ) - endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 1cd6d4663d..2e379e42ca 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -618,7 +618,6 @@ void PCB_BASE_FRAME::UpdateStatusBar() switch( g_UserUnit ) { -#if defined( USE_PCBNEW_NANOMETRES ) case INCHES: absformatter = wxT( "X %.6f Y %.6f" ); locformatter = wxT( "dx %.6f dy %.6f d %.6f" ); @@ -628,19 +627,6 @@ void PCB_BASE_FRAME::UpdateStatusBar() absformatter = wxT( "X %.6f Y %.6f" ); locformatter = wxT( "dx %.6f dy %.6f d %.6f" ); break; -#else - case INCHES: - absformatter = wxT( "X %.4f Y %.4f" ); - locformatter = wxT( "dx %.4f dy %.4f d %.4f" ); - break; - - case MILLIMETRES: - dXpos = RoundTo0( dXpos, 1000.0 ); - dYpos = RoundTo0( dYpos, 1000.0 ); - absformatter = wxT( "X %.3f Y %.3f" ); - locformatter = wxT( "dx %.3f dy %.3f d %.3f" ); - break; -#endif case UNSCALED_UNITS: absformatter = wxT( "X %f Y %f" ); @@ -659,14 +645,6 @@ void PCB_BASE_FRAME::UpdateStatusBar() dXpos = To_User_Unit( g_UserUnit, dx ); dYpos = To_User_Unit( g_UserUnit, dy ); -#ifndef USE_PCBNEW_NANOMETRES - if ( g_UserUnit == MILLIMETRES ) - { - dXpos = RoundTo0( dXpos, 1000.0 ); - dYpos = RoundTo0( dYpos, 1000.0 ); - } -#endif - // We already decided the formatter above line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) ); SetStatusText( line, 3 ); diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index dec5ab8afa..6c309c11c7 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -88,7 +88,7 @@ wxString BOARD_ITEM::GetLayerName() const std::string BOARD_ITEM::FormatInternalUnits( int aValue ) { -#if 1 // !defined( USE_PCBNEW_NANOMETRES ) +#if 1 char buf[50]; int len; diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index b9e205e203..1bba2e67dd 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -64,12 +64,9 @@ */ static const double pcbZoomList[] = { -#if defined( USE_PCBNEW_NANOMETRES ) ZOOM_FACTOR( 0.1 ), ZOOM_FACTOR( 0.2 ), ZOOM_FACTOR( 0.3 ), -#endif - ZOOM_FACTOR( 0.5 ), ZOOM_FACTOR( 1.0 ), ZOOM_FACTOR( 1.5 ), @@ -129,13 +126,6 @@ static const double pcbZoomList[] = The largest ZOOM_FACTOR in above table is ZOOM_FACTOR( 300 ), which computes out to 762000 just below 790885. */ - - -#if !defined( USE_PCBNEW_NANOMETRES ) - ZOOM_FACTOR( 500.0 ), - ZOOM_FACTOR( 1000.0 ), - ZOOM_FACTOR( 2000.0 ) -#endif }; diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 03a1fd8313..abe600d41b 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -411,11 +411,7 @@ void LEGACY_PLUGIN::loadGENERAL() if( !strcmp( data, "mm" ) ) { -#if defined( USE_PCBNEW_NANOMETRES ) diskToBiu = IU_PER_MM; -#else - THROW_IO_ERROR( _( "May not load millimeter *.brd file into 'Pcbnew compiled for deci-mils'" ) ); -#endif } } @@ -2822,11 +2818,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties ) m_props = aProperties; // conversion factor for saving RAM BIUs to KICAD legacy file format. -#if defined( USE_PCBNEW_NANOMETRES ) biuToDisk = 1.0/IU_PER_MM; // BIUs are nanometers & file is mm -#else - biuToDisk = 1.0; // BIUs are deci-mils -#endif // Conversion factor for loading KICAD legacy file format into BIUs in RAM // Start by assuming the *.brd file is in deci-mils. @@ -2835,8 +2827,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties ) // mm to nanometers. The deci-mil legacy files have no such "Units" marker // so we must assume the file is in deci-mils until told otherwise. - diskToBiu = IU_PER_DECIMILS; // BIUs are nanometers if defined(USE_PCBNEW_NANOMETRES) - // else are deci-mils + diskToBiu = IU_PER_DECIMILS; // BIUs are nanometers } @@ -2918,11 +2909,7 @@ void LEGACY_PLUGIN::saveGENERAL( const BOARD* aBoard ) const fprintf( m_fp, "encoding utf-8\n" ); // tell folks the units used within the file, as early as possible here. -#if defined( USE_PCBNEW_NANOMETRES ) fprintf( m_fp, "Units mm\n" ); -#else - fprintf( m_fp, "Units deci-mils\n" ); -#endif // Write copper layer count fprintf( m_fp, "LayerCount %d\n", aBoard->GetCopperLayerCount() ); @@ -3991,11 +3978,7 @@ void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader ) if( !strcmp( units, "mm" ) ) { -#if defined( USE_PCBNEW_NANOMETRES ) m_owner->diskToBiu = IU_PER_MM; -#else - THROW_IO_ERROR( _( "May not load millimeter legacy library file into 'Pcbnew compiled for deci-mils'" ) ); -#endif } } @@ -4191,11 +4174,7 @@ void FPL_CACHE::SaveHeader( FILE* aFile ) { fprintf( aFile, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) ); fprintf( aFile, "# encoding utf-8\n" ); -#if defined( USE_PCBNEW_NANOMETRES ) fprintf( aFile, "Units mm\n" ); -#else - fprintf( aFile, "Units deci-mils\n" ); -#endif } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 96b027c217..f974af99f0 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -201,18 +201,12 @@ const KICAD_T SPECCTRA_DB::scanPADs[] = { PCB_PAD_T, EOT }; */ static inline double scale( int kicadDist ) { -#if defined(USE_PCBNEW_NANOMETRES) // nanometers to um return kicadDist / ( IU_PER_MM / 1000.0 ); // nanometers to mils // return kicadDist/IU_PER_MILS; - -#else - // deci-mils to mils. - return kicadDist / 10.0; -#endif } @@ -1356,7 +1350,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR ) //----- & -------------------- { -#if defined(USE_PCBNEW_NANOMETRES) + // tell freerouter to use "tenths of micrometers", // which is 100 nm resolution. Possibly more resolution is possible // in freerouter, but it would need testing. @@ -1365,18 +1359,6 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR ) pcb->resolution->units = T_um; pcb->resolution->value = 10; // tenths of a um // pcb->resolution->value = 1000; // "thousandths of a um" (i.e. "nm") - -#else - pcb->unit->units = T_mil; - pcb->resolution->units = T_mil; - - // Kicad only supports 1/10th of mil internal coordinates. So to avoid - // having the router give us back 1/100th of mil coordinates which we - // will have to round and thereby cause error, we declare our maximum - // resolution precisely at 1/10th for now. For more on this, see: - // http://www.freerouting.net/usren/viewtopic.php?f=3&t=354 - pcb->resolution->value = 10; -#endif } //----------------------------------------------- diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 78ad143edd..da0310e811 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -147,8 +147,6 @@ static int scale( double distance, UNIT_RES* aResolution ) double resValue = aResolution->GetValue(); double factor; -#if defined(USE_PCBNEW_NANOMETRES) - switch( aResolution->GetEngUnits() ) { default: @@ -171,36 +169,6 @@ static int scale( double distance, UNIT_RES* aResolution ) int ret = KiROUND( factor * distance / resValue ); -#else - - switch( aResolution->GetEngUnits() ) - { - default: - case T_inch: - factor = 1000.0; - break; - case T_mil: - factor = 1.0; - break; - case T_cm: - factor = 1000.0/2.54; - break; - case T_mm: - factor = 1000.0/25.4; - break; - case T_um: - factor = 1.0/25.4; - break; - } - - // the factor of 10.0 is used to convert mils to deci-mils, the units - // used within KiCad. - factor *= 10.0; - - int ret = KiROUND( factor * distance / resValue ); - -#endif - return ret; }