Add DMils2iu() for scaling deci-mils to internal units.
Instrument saveNETCLASS() with fmtBIU(). Can now round trip to mm board file using LEGACY_PLUGIN in DEBUG build.
This commit is contained in:
parent
149f6d807d
commit
9e980d916f
|
@ -124,6 +124,7 @@ inline int Mm2mils( double x ) { return wxRound( x * 1000./25.4 ); }
|
|||
/// Convert mils to mm.
|
||||
inline int Mils2mm( double x ) { return wxRound( x * 25.4 / 1000. ); }
|
||||
|
||||
|
||||
/// Return whether GOST is in play
|
||||
bool IsGOST();
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <class_track.h>
|
||||
|
||||
#define DEFAULT_BOARD_THICKNESS_DMILS 620
|
||||
|
||||
|
||||
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
|
||||
m_Pad_Master( 0 )
|
||||
|
@ -33,30 +35,34 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
|
|||
m_UseConnectedTrackWidth = false;
|
||||
|
||||
m_MicroViasAllowed = false; // true to allow micro vias
|
||||
m_DrawSegmentWidth = 100; // current graphic line width (not EDGE layer)
|
||||
m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only)
|
||||
m_PcbTextWidth = 100; // current Pcb (not module) Text width
|
||||
m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size
|
||||
m_TrackMinWidth = 100; // track min value for width ((min copper size value
|
||||
m_ViasMinSize = 350; // vias (not micro vias) min diameter
|
||||
m_ViasMinDrill = 200; // vias (not micro vias) min drill diameter
|
||||
m_MicroViasMinSize = 200; // micro vias (not vias) min diameter
|
||||
m_MicroViasMinDrill = 50; // micro vias (not vias) min drill diameter
|
||||
|
||||
m_DrawSegmentWidth = DMils2iu( 100 ); // current graphic line width (not EDGE layer)
|
||||
|
||||
m_EdgeSegmentWidth = DMils2iu( 100 ); // current graphic line width (EDGE layer only)
|
||||
m_PcbTextWidth = DMils2iu( 100 ); // current Pcb (not module) Text width
|
||||
|
||||
m_PcbTextSize = wxSize( DMils2iu( 500 ), DMils2iu( 500 ) );
|
||||
// current Pcb (not module) Text size
|
||||
|
||||
m_TrackMinWidth = DMils2iu( 100 ); // track min value for width ((min copper size value
|
||||
m_ViasMinSize = DMils2iu( 350 ); // vias (not micro vias) min diameter
|
||||
m_ViasMinDrill = DMils2iu( 200 ); // vias (not micro vias) min drill diameter
|
||||
m_MicroViasMinSize = DMils2iu( 200 ); // micro vias (not vias) min diameter
|
||||
m_MicroViasMinDrill = DMils2iu( 50 ); // micro vias (not vias) min drill diameter
|
||||
|
||||
// Global mask margins:
|
||||
m_SolderMaskMargin = 150; // Solder mask margin
|
||||
m_SolderMaskMargin = DMils2iu( 150 ); // Solder mask margin
|
||||
m_SolderPasteMargin = 0; // Solder paste margin absolute value
|
||||
m_SolderPasteMarginRatio = 0.0; // Solder pask margin ratio value of pad size
|
||||
// The final margin is the sum of these 2 values
|
||||
// Usually < 0 because the mask is smaller than pad
|
||||
|
||||
m_ModuleTextSize = wxSize( 500, 500 );
|
||||
m_ModuleTextWidth = 100;
|
||||
m_ModuleSegmentWidth = 100;
|
||||
|
||||
m_ModuleTextSize = wxSize( DMils2iu( 500 ), DMils2iu( 500 ) );
|
||||
m_ModuleTextWidth = DMils2iu( 100 );
|
||||
m_ModuleSegmentWidth = DMils2iu( 100 );
|
||||
|
||||
// Layer thickness for 3D viewer
|
||||
m_BoardThickness = (int)(1.6 * PCB_INTERNAL_UNIT / 25.4);
|
||||
m_BoardThickness = DMils2iu( DEFAULT_BOARD_THICKNESS_DMILS );
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,41 +70,38 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( PARAM_CFG_ARRAY* aResult )
|
|||
{
|
||||
m_Pad_Master.AppendConfigs( aResult );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ),
|
||||
&m_BoardThickness,
|
||||
630, 0, 0xFFFF ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ), &m_BoardThickness,
|
||||
DMils2iu( DEFAULT_BOARD_THICKNESS_DMILS ), 0, 0xFFFF ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtPcbV" ),
|
||||
&m_PcbTextSize.y,
|
||||
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtPcbV" ), &m_PcbTextSize.y,
|
||||
DMils2iu( 600 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ),
|
||||
&m_PcbTextSize.x,
|
||||
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ), &m_PcbTextSize.x,
|
||||
DMils2iu( 600 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &m_ModuleTextSize.y,
|
||||
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
DMils2iu( 500 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &m_ModuleTextSize.x,
|
||||
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
DMils2iu( 500 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &m_ModuleTextWidth,
|
||||
100, 1, TEXTS_MAX_WIDTH ) );
|
||||
DMils2iu( 100 ), 1, TEXTS_MAX_WIDTH ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "VEgarde" ),
|
||||
&m_SolderMaskMargin,
|
||||
100, 0, 10000 ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "VEgarde" ), &m_SolderMaskMargin,
|
||||
DMils2iu( 100 ), 0, DMils2iu( 10000 ) ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "DrawLar" ),
|
||||
&m_DrawSegmentWidth,
|
||||
120, 0, 0xFFFF ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "DrawLar" ), &m_DrawSegmentWidth,
|
||||
DMils2iu( 120 ), 0, 0xFFFF ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "EdgeLar" ), &m_EdgeSegmentWidth,
|
||||
DMils2iu( 120 ), 0, 0xFFFF ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtLar" ), &m_PcbTextWidth,
|
||||
DMils2iu( 120 ), 0, 0xFFFF ) );
|
||||
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "EdgeLar" ),
|
||||
&m_EdgeSegmentWidth,
|
||||
120, 0, 0xFFFF ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtLar" ),
|
||||
&m_PcbTextWidth,
|
||||
120, 0, 0xFFFF ) );
|
||||
aResult->push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &m_ModuleSegmentWidth,
|
||||
120, 0, 0xFFFF ) );
|
||||
DMils2iu( 120 ), 0, 0xFFFF ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
const wxString NETCLASS::Default = wxT("Default");
|
||||
|
||||
// Initial values for netclass initialization
|
||||
int NETCLASS::DEFAULT_CLEARANCE = 100; // track to track and track to pads clearance
|
||||
int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill
|
||||
int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill
|
||||
int NETCLASS::DEFAULT_CLEARANCE = DMils2iu( 100 ); // track to track and track to pads clearance
|
||||
int NETCLASS::DEFAULT_VIA_DRILL = DMils2iu( 250 ); // default via drill
|
||||
int NETCLASS::DEFAULT_UVIA_DRILL = DMils2iu( 50 ); // micro via drill
|
||||
|
||||
|
||||
NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters ) :
|
||||
|
@ -85,7 +85,7 @@ void NETCLASS::SetParams( const NETCLASS* defaults )
|
|||
|
||||
SetTrackWidth( g.m_TrackMinWidth );
|
||||
SetViaDiameter( g.m_ViasMinSize );
|
||||
SetuViaDiameter(g.m_MicroViasMinSize );
|
||||
SetuViaDiameter( g.m_MicroViasMinSize );
|
||||
|
||||
// Use default values for next parameters:
|
||||
SetClearance( DEFAULT_CLEARANCE );
|
||||
|
|
|
@ -1502,10 +1502,10 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
|
|||
if( thickn < 1 )
|
||||
thickn = 1;
|
||||
|
||||
/* this is better left to the save function, or to the accessor, since we will
|
||||
be supporting more than one board format.
|
||||
/* this is better left to the dialogs UIs
|
||||
aText->SetThickness( Clamp_Text_PenSize( thickn, aText->GetSize() ) );
|
||||
*/
|
||||
|
||||
aText->SetThickness( thickn );
|
||||
|
||||
aText->SetMirrored( mirror && *mirror == 'M' );
|
||||
|
@ -1514,8 +1514,6 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
|
|||
|
||||
aText->SetItalic( italic && *italic == 'I' );
|
||||
|
||||
// @todo put in accessor?
|
||||
// Test for a reasonable layer:
|
||||
if( layer < 0 )
|
||||
layer = 0;
|
||||
if( layer > LAST_NO_COPPER_LAYER )
|
||||
|
@ -1614,7 +1612,6 @@ void LEGACY_PLUGIN::loadPCB_LINE()
|
|||
BIU end_y = biuParse( data, &data );
|
||||
BIU width = biuParse( data );
|
||||
|
||||
// @todo put in accessor? why 0?
|
||||
if( width < 0 )
|
||||
width = 0;
|
||||
|
||||
|
@ -1638,7 +1635,6 @@ void LEGACY_PLUGIN::loadPCB_LINE()
|
|||
int layer;
|
||||
layer = intParse( data );
|
||||
|
||||
// @todo: put in accessor?
|
||||
if( layer < FIRST_NO_COPPER_LAYER )
|
||||
layer = FIRST_NO_COPPER_LAYER;
|
||||
|
||||
|
@ -3046,14 +3042,14 @@ void LEGACY_PLUGIN::saveNETCLASS( const NETCLASS* nc ) const
|
|||
fprintf( m_fp, "Name %s\n", EscapedUTF8( nc->GetName() ).c_str() );
|
||||
fprintf( m_fp, "Desc %s\n", EscapedUTF8( nc->GetDescription() ).c_str() );
|
||||
|
||||
fprintf( m_fp, "Clearance %d\n", nc->GetClearance() );
|
||||
fprintf( m_fp, "TrackWidth %d\n", nc->GetTrackWidth() );
|
||||
fprintf( m_fp, "Clearance %s\n", fmtBIU( nc->GetClearance() ).c_str() );
|
||||
fprintf( m_fp, "TrackWidth %s\n", fmtBIU( nc->GetTrackWidth() ).c_str() );
|
||||
|
||||
fprintf( m_fp, "ViaDia %d\n", nc->GetViaDiameter() );
|
||||
fprintf( m_fp, "ViaDrill %d\n", nc->GetViaDrill() );
|
||||
fprintf( m_fp, "ViaDia %s\n", fmtBIU( nc->GetViaDiameter() ).c_str() );
|
||||
fprintf( m_fp, "ViaDrill %s\n", fmtBIU( nc->GetViaDrill() ).c_str() );
|
||||
|
||||
fprintf( m_fp, "uViaDia %d\n", nc->GetuViaDiameter() );
|
||||
fprintf( m_fp, "uViaDrill %d\n", nc->GetuViaDrill() );
|
||||
fprintf( m_fp, "uViaDia %s\n", fmtBIU( nc->GetuViaDiameter() ).c_str() );
|
||||
fprintf( m_fp, "uViaDrill %s\n", fmtBIU( nc->GetuViaDrill() ).c_str() );
|
||||
|
||||
for( NETCLASS::const_iterator it = nc->begin(); it!=nc->end(); ++it )
|
||||
fprintf( m_fp, "AddNet %s\n", EscapedUTF8( *it ).c_str() );
|
||||
|
|
|
@ -33,9 +33,24 @@
|
|||
#define DIM_ANCRE_MODULE 3 /* Anchor size (footprint center) */
|
||||
#define DIM_ANCRE_TEXTE 2 /* Anchor size (Text center) */
|
||||
|
||||
#define TEXTS_MIN_SIZE 50 // Minimum text size in Pcbnew units value (50 * 0.0001 mils)
|
||||
#define TEXTS_MAX_SIZE 10000 // Maximum text size in Pcbnew units value (1 inch) )
|
||||
#define TEXTS_MAX_WIDTH 5000 // Maximum text width in Pcbnew units value (0.5 inches)
|
||||
|
||||
#if defined(PCBNEW)
|
||||
/// Convert deci-mils to PCBNEW internal units (iu).
|
||||
inline int DMils2iu( int dmils )
|
||||
{
|
||||
#if defined( USE_PCBNEW_NANOMETRES )
|
||||
return int( dmils * 25.4e2 + 0.5 );
|
||||
#else
|
||||
return dmils;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define TEXTS_MIN_SIZE DMils2iu( 50 ) ///< Minimum text size in Pcbnew units value (50 * 0.0001 mils)
|
||||
#define TEXTS_MAX_SIZE DMils2iu( 10000 ) ///< Maximum text size in Pcbnew units value (1 inch) )
|
||||
#define TEXTS_MAX_WIDTH DMils2iu( 5000 ) ///< Maximum text width in Pcbnew units value (0.5 inches)
|
||||
|
||||
|
||||
/* Flag to force the SKETCH mode to display items (.m_Flags member) */
|
||||
#define FORCE_SKETCH ( IS_DRAGGED | IN_EDIT )
|
||||
|
|
Loading…
Reference in New Issue