Give up on enforcing non-defined-internal-units.

It results in trade-offs in packaging and/or conidtional compilation
which are worse than the disease.
This commit is contained in:
Jeff Young 2020-06-13 19:58:19 +01:00
parent 47ab7c78a6
commit fc44506fe1
6 changed files with 9 additions and 13 deletions

View File

@ -10,8 +10,8 @@ include_directories( BEFORE ${INC_BEFORE} )
include_directories( ${INC_AFTER} )
set( BITMAP2COMPONENT_SRCS
${CMAKE_SOURCE_DIR}/common/base_units.cpp
${CMAKE_SOURCE_DIR}/common/single_top.cpp
bitmap2cmp_main.cpp
bitmap2cmp_settings.cpp
bitmap2component.cpp

View File

@ -41,16 +41,12 @@
#include <title_block.h>
#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA ) || defined( GERBVIEW ) || defined( PL_EDITOR )
#define IU_TO_MM( x ) ( x / IU_PER_MM )
#define IU_TO_IN( x ) ( x / IU_PER_MILS / 1000 )
#define IU_TO_MILS( x ) ( x / IU_PER_MILS )
#define MM_TO_IU( x ) ( x * IU_PER_MM )
#define IN_TO_IU( x ) ( x * IU_PER_MILS * 1000 )
#define MILS_TO_IU( x ) ( x * IU_PER_MILS )
#else
#error "Cannot resolve internal units due to no definition of EESCHEMA, CVPCB or PCBNEW."
#endif
// Helper function to print a float number without using scientific notation

View File

@ -25,6 +25,7 @@
#include <settings/app_settings.h>
#include <settings/common_settings.h>
#include <settings/parameters.h>
#include <base_units.h>
///! Update the schema version whenever a migration is required
const int appSettingsSchemaVersion = 0;
@ -211,7 +212,6 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri
ret &= fromLegacy<int>( aCfg,
aFrame + "_LastGridSize", aJsonPath + ".grid.last_size" );
#if defined( PCBNEW )
double x, y;
if( aCfg->Read( aFrame + "PcbUserGrid_X", &x ) && aCfg->Read( aFrame + "PcbUserGrid_Y", &y ) )
@ -221,7 +221,6 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri
( *this )[PointerFromString( ".grid.user_grid_x" )] = StringFromValue( u, x, true, true );
( *this )[PointerFromString( ".grid.user_grid_y" )] = StringFromValue( u, y, true, true );
}
#endif
ret &= fromLegacy<bool>( aCfg,
aFrame + gd + "GridAxesEnabled", aJsonPath + ".grid.axes_enabled" );

View File

@ -86,12 +86,13 @@ constexpr inline int Iu2Mils( int iu )
return static_cast< int >( mils < 0 ? mils - 0.5 : mils + 0.5 );
}
#else
// Here, we do not know the value of internal units: do not define
// conversion functions (They do not have meaning)
#define UNKNOWN_IU
// Here, we do not know the value of internal units: just use something safe to allow
// easier packaging of compilation units
constexpr double IU_PER_MM = 1;
constexpr double IU_PER_MILS = IU_PER_MM * 0.0254;
#endif
#ifndef UNKNOWN_IU
// Other definitions used in a few files
constexpr double MM_PER_IU = ( 1 / IU_PER_MM );
@ -121,6 +122,4 @@ constexpr inline double Iu2Millimeter( int iu )
constexpr int ARC_LOW_DEF = Millimeter2iu( 0.02 );
constexpr int ARC_HIGH_DEF = Millimeter2iu( 0.005 );
#endif
#endif // CONVERT_TO_BIU_H_

View File

@ -15,6 +15,7 @@ include_directories(
set( KICAD_SRCS
${CMAKE_SOURCE_DIR}/common/base_units.cpp
dialogs/dialog_template_selector_base.cpp
dialogs/dialog_template_selector.cpp
files-io.cpp

View File

@ -10,6 +10,7 @@ include_directories(
)
set( PCB_CALCULATOR_SRCS
${CMAKE_SOURCE_DIR}/common/base_units.cpp
attenuators.cpp
board_classes_values.cpp
colorcode.cpp