A bit of "module" erradication, nameing conventions, and formatting.

This commit is contained in:
Jeff Young 2020-11-14 21:21:54 +00:00
parent d2a88234b6
commit 61bca4aaa4
47 changed files with 667 additions and 763 deletions

View File

@ -304,9 +304,9 @@ public:
// when importing values or creating a new pad // when importing values or creating a new pad
// Set to true if the board has a stackup management. // Set to true if the board has a stackup management.
// If not set a default basic stackup witll be used to generate the ;gbrjob file. // If not set a default basic stackup will be used to generate the gbrjob file.
// Could be removed later, or at least always set to true // Could be removed later, or at least always set to true
bool m_HasStackup; bool m_HasStackup;
private: private:
// Indicies into the trackWidth, viaSizes and diffPairDimensions lists. // Indicies into the trackWidth, viaSizes and diffPairDimensions lists.

View File

@ -313,7 +313,7 @@ void MICROWAVE_TOOL::createInductorBetween( const VECTOR2I& aStart, const VECTOR
} }
else else
{ {
// at this point, we can save the module // at this point, we can save the footprint
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, inductorFP.get() ); m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, inductorFP.get() );
BOARD_COMMIT commit( this ); BOARD_COMMIT commit( this );

View File

@ -54,7 +54,7 @@ class PCB_BASE_FRAME;
#define CH_UNROUTABLE 2 /* Don't use autorouter. */ #define CH_UNROUTABLE 2 /* Don't use autorouter. */
#define CH_ROUTE_REQ 4 /* Must be routed by the autorouter. */ #define CH_ROUTE_REQ 4 /* Must be routed by the autorouter. */
#define CH_ACTIF 8 /* Not routed. */ #define CH_ACTIF 8 /* Not routed. */
#define LOCAL_RATSNEST_ITEM 0x8000 /* Line between two pads of a single module. */ #define LOCAL_RATSNEST_ITEM 0x8000 /* Line between two pads of a single footprint. */
DECL_VEC_FOR_SWIG( PADS_VEC, PAD* ) DECL_VEC_FOR_SWIG( PADS_VEC, PAD* )

View File

@ -85,7 +85,7 @@ class FP_CACHE
PCB_IO* m_owner; // Plugin object that owns the cache. PCB_IO* m_owner; // Plugin object that owns the cache.
wxFileName m_lib_path; // The path of the library. wxFileName m_lib_path; // The path of the library.
wxString m_lib_raw_path; // For quick comparisons. wxString m_lib_raw_path; // For quick comparisons.
FOOTPRINT_MAP m_modules; // Map of footprint file name per FOOTPRINT*. FOOTPRINT_MAP m_footprints; // Map of footprint filename to FOOTPRINT*.
bool m_cache_dirty; // Stored separately because it's expensive to check bool m_cache_dirty; // Stored separately because it's expensive to check
// m_cache_timestamp against all the files. // m_cache_timestamp against all the files.
@ -101,16 +101,16 @@ public:
bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); } bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
FOOTPRINT_MAP& GetFootprints() { return m_modules; } FOOTPRINT_MAP& GetFootprints() { return m_footprints; }
// Most all functions in this class throw IO_ERROR exceptions. There are no // Most all functions in this class throw IO_ERROR exceptions. There are no
// error codes nor user interface calls from here, nor in any PLUGIN. // error codes nor user interface calls from here, nor in any PLUGIN.
// Catch these exceptions higher up please. // Catch these exceptions higher up please.
/** /**
* Save the footprint cache or a single module from it to disk * Save the footprint cache or a single footprint from it to disk
* *
* @param aFootprint if set, save only this module, otherwise, save the full library * @param aFootprint if set, save only this footprint, otherwise, save the full library
*/ */
void Save( FOOTPRINT* aFootprint = NULL ); void Save( FOOTPRINT* aFootprint = NULL );
@ -171,7 +171,7 @@ void FP_CACHE::Save( FOOTPRINT* aFootprint )
m_lib_raw_path ) ); m_lib_raw_path ) );
} }
for( FOOTPRINT_MAP::iterator it = m_modules.begin(); it != m_modules.end(); ++it ) for( FOOTPRINT_MAP::iterator it = m_footprints.begin(); it != m_footprints.end(); ++it )
{ {
if( aFootprint && aFootprint != it->second->GetModule() ) if( aFootprint && aFootprint != it->second->GetModule() )
continue; continue;
@ -263,7 +263,7 @@ void FP_CACHE::Load()
wxString fpName = fn.GetName(); wxString fpName = fn.GetName();
footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) ); footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) );
m_modules.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) ); m_footprints.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) );
m_cache_timestamp += fn.GetTimestamp(); m_cache_timestamp += fn.GetTimestamp();
} }
@ -284,9 +284,9 @@ void FP_CACHE::Load()
void FP_CACHE::Remove( const wxString& aFootprintName ) void FP_CACHE::Remove( const wxString& aFootprintName )
{ {
FOOTPRINT_MAP::const_iterator it = m_modules.find( aFootprintName ); FOOTPRINT_MAP::const_iterator it = m_footprints.find( aFootprintName );
if( it == m_modules.end() ) if( it == m_footprints.end() )
{ {
wxString msg = wxString::Format( _( "library \"%s\" has no footprint \"%s\" to delete" ), wxString msg = wxString::Format( _( "library \"%s\" has no footprint \"%s\" to delete" ),
m_lib_raw_path, m_lib_raw_path,
@ -296,7 +296,7 @@ void FP_CACHE::Remove( const wxString& aFootprintName )
// Remove the module from the cache and delete the module file from the library. // Remove the module from the cache and delete the module file from the library.
wxString fullPath = it->second->GetFileName().GetFullPath(); wxString fullPath = it->second->GetFileName().GetFullPath();
m_modules.erase( aFootprintName ); m_footprints.erase( aFootprintName );
wxRemoveFile( fullPath ); wxRemoveFile( fullPath );
} }
@ -640,7 +640,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );
} }
// Save the graphical items on the board (not owned by a module) // Save the graphical items on the board (not owned by a footprint)
for( BOARD_ITEM* item : sorted_drawings ) for( BOARD_ITEM* item : sorted_drawings )
Format( item, aNestLevel ); Format( item, aNestLevel );

View File

@ -73,7 +73,7 @@ class PCB_TEXT;
//#define SEXPR_BOARD_FILE_VERSION 20200614 // Add support for fp_rects and gr_rects //#define SEXPR_BOARD_FILE_VERSION 20200614 // Add support for fp_rects and gr_rects
//#define SEXPR_BOARD_FILE_VERSION 20200625 // Multilayer zones, zone names, island controls //#define SEXPR_BOARD_FILE_VERSION 20200625 // Multilayer zones, zone names, island controls
//#define SEXPR_BOARD_FILE_VERSION 20200628 // remove visibility settings //#define SEXPR_BOARD_FILE_VERSION 20200628 // remove visibility settings
//#define SEXPR_BOARD_FILE_VERSION 20200724 // Add KIID to module components //#define SEXPR_BOARD_FILE_VERSION 20200724 // Add KIID to footprints
//#define SEXPR_BOARD_FILE_VERSION 20200807 // Add zone hatch advanced settings //#define SEXPR_BOARD_FILE_VERSION 20200807 // Add zone hatch advanced settings
//#define SEXPR_BOARD_FILE_VERSION 20200808 // Add properties to footprints //#define SEXPR_BOARD_FILE_VERSION 20200808 // Add properties to footprints
//#define SEXPR_BOARD_FILE_VERSION 20200809 // Add REMOVE_UNUSED_LAYERS option to vias and THT pads //#define SEXPR_BOARD_FILE_VERSION 20200809 // Add REMOVE_UNUSED_LAYERS option to vias and THT pads

View File

@ -163,7 +163,7 @@ class PCB_PARSER : public PCB_LEXER
/** /**
* Function parseFOOTPRINT_unchecked * Function parseFOOTPRINT_unchecked
* Parse a module, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically. * Parse a footprint, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
*/ */
FOOTPRINT* parseFOOTPRINT_unchecked( wxArrayString* aInitialComments = 0 ); FOOTPRINT* parseFOOTPRINT_unchecked( wxArrayString* aInitialComments = 0 );
FP_TEXT* parseFP_TEXT(); FP_TEXT* parseFP_TEXT();
@ -182,7 +182,7 @@ class PCB_PARSER : public PCB_LEXER
/** /**
* Function parseBOARD_unchecked * Function parseBOARD_unchecked
* Parse a module, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically. * Parse a board, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
*/ */
BOARD* parseBOARD_unchecked(); BOARD* parseBOARD_unchecked();

View File

@ -1284,7 +1284,7 @@ void LEGACY_PLUGIN::loadFOOTPRINT( FOOTPRINT* aFootprint )
aFootprint->SetPlacementCost90((itmp1 << 4) | cntRot90 ); aFootprint->SetPlacementCost90((itmp1 << 4) | cntRot90 );
} }
else if( TESTLINE( "At" ) ) // (At)tributes of module else if( TESTLINE( "At" ) ) // (At)tributes of footprint
{ {
int attrs = 0; int attrs = 0;
@ -1607,8 +1607,8 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
else if( TESTLINE( "$EndPAD" ) ) else if( TESTLINE( "$EndPAD" ) )
{ {
// pad's "Position" is not relative to the module's, // pad's "Position" is not relative to the footprint's, whereas Pos0 is relative
// whereas Pos0 is relative to the module's but is the unrotated coordinate. // to the footprint's but is the unrotated coordinate.
wxPoint padpos = pad->GetPos0(); wxPoint padpos = pad->GetPos0();
@ -1754,7 +1754,7 @@ void LEGACY_PLUGIN::loadFP_SHAPE( FOOTPRINT* aFootprint )
aFootprint->Add( fpShape ); aFootprint->Add( fpShape );
// this had been done at the FOOTPRINT level before, presumably because the FP_SHAPE needs // this had been done at the FOOTPRINT level before, presumably because the FP_SHAPE needs
// to be already added to a module before this function will work. // to be already added to a footprint before this function will work.
fpShape->SetDrawCoord(); fpShape->SetDrawCoord();
} }

View File

@ -16,7 +16,7 @@ set( PCAD2PCBNEW_SRCS
pcb_cutout.cpp pcb_cutout.cpp
pcb_keepout.cpp pcb_keepout.cpp
pcb_line.cpp pcb_line.cpp
pcb_module.cpp pcb_footprint.cpp
pcb_net.cpp pcb_net.cpp
pcb_pad.cpp pcb_pad.cpp
pcb_pad_shape.cpp pcb_pad_shape.cpp

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -32,14 +32,8 @@
#include <common.h> #include <common.h>
#include <pcb.h> #include <pcb.h>
#include <pcb_arc.h>
#include <pcb_copper_pour.h>
#include <pcb_cutout.h>
#include <pcb_keepout.h> #include <pcb_keepout.h>
#include <pcb_line.h> #include <pcb_footprint.h>
#include <pcb_module.h>
#include <pcb_pad_shape.h>
#include <pcb_via_shape.h>
#include <pcb_pad.h> #include <pcb_pad.h>
#include <pcb_text.h> #include <pcb_text.h>
#include <pcb_via.h> #include <pcb_via.h>
@ -49,9 +43,9 @@ namespace PCAD2KICAD {
PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer )
{ {
auto it = m_layersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
if( it == m_layersMap.end() ) if( it == m_LayersMap.end() )
THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) ); THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
return it->second.KiCadLayer; return it->second.KiCadLayer;
@ -59,9 +53,9 @@ PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer )
LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer )
{ {
auto it = m_layersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
if( it == m_layersMap.end() ) if( it == m_LayersMap.end() )
THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) ); THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
return it->second.layerType; return it->second.layerType;
@ -69,17 +63,18 @@ LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer )
wxString PCB::GetLayerNetNameRef( int aPCadLayer ) wxString PCB::GetLayerNetNameRef( int aPCadLayer )
{ {
auto it = m_layersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
if( it == m_layersMap.end() ) if( it == m_LayersMap.end() )
THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) ); THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
return it->second.netNameRef; return it->second.netNameRef;
} }
PCB::PCB( BOARD* aBoard ) : PCB_MODULE( this, aBoard ) PCB::PCB( BOARD* aBoard ) :
PCB_FOOTPRINT( this, aBoard )
{ {
m_defaultMeasurementUnit = wxT( "mil" ); m_DefaultMeasurementUnit = wxT( "mil" );
for( size_t i = 0; i < 8; ++i ) for( size_t i = 0; i < 8; ++i )
{ {
@ -88,21 +83,21 @@ PCB::PCB( BOARD* aBoard ) : PCB_MODULE( this, aBoard )
layer.layerType = LAYER_TYPE_NONSIGNAL; // default layer.layerType = LAYER_TYPE_NONSIGNAL; // default
layer.netNameRef = wxT( "" ); // default layer.netNameRef = wxT( "" ); // default
m_layersMap.insert( std::make_pair( i, layer ) ); m_LayersMap.insert( std::make_pair( i, layer ) );
} }
m_sizeX = 0; m_SizeX = 0;
m_sizeY = 0; m_SizeY = 0;
m_layersMap[1].KiCadLayer = F_Cu; m_LayersMap[1].KiCadLayer = F_Cu;
m_layersMap[1].layerType = LAYER_TYPE_SIGNAL; m_LayersMap[1].layerType = LAYER_TYPE_SIGNAL;
m_layersMap[2].KiCadLayer = B_Cu; m_LayersMap[2].KiCadLayer = B_Cu;
m_layersMap[2].layerType = LAYER_TYPE_SIGNAL; m_LayersMap[2].layerType = LAYER_TYPE_SIGNAL;
m_layersMap[3].KiCadLayer = Eco2_User; m_LayersMap[3].KiCadLayer = Eco2_User;
m_layersMap[6].KiCadLayer = F_SilkS; m_LayersMap[6].KiCadLayer = F_SilkS;
m_layersMap[7].KiCadLayer = B_SilkS; m_LayersMap[7].KiCadLayer = B_SilkS;
} }
@ -110,14 +105,14 @@ PCB::~PCB()
{ {
int i; int i;
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
{ {
delete m_pcbComponents[i]; delete m_PcbComponents[i];
} }
for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ ) for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
{ {
delete m_pcbNetlist[i]; delete m_PcbNetlist[i];
} }
} }
@ -126,13 +121,13 @@ int PCB::GetNetCode( wxString aNetName )
{ {
PCB_NET* net; PCB_NET* net;
for( int i = 0; i < (int) m_pcbNetlist.GetCount(); i++ ) for( int i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
{ {
net = m_pcbNetlist[i]; net = m_PcbNetlist[i];
if( net->m_name == aNetName ) if( net->m_Name == aNetName )
{ {
return net->m_netCode; return net->m_NetCode;
} }
} }
@ -234,7 +229,7 @@ void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue,
} }
if( tNode ) if( tNode )
SetTextParameters( tNode, aTextValue, m_defaultMeasurementUnit, aActualConversion ); SetTextParameters( tNode, aTextValue, m_DefaultMeasurementUnit, aActualConversion );
} }
@ -243,18 +238,18 @@ void PCB::DoPCBComponents( XNODE* aNode,
const wxString& aActualConversion, const wxString& aActualConversion,
wxStatusBar* aStatusBar ) wxStatusBar* aStatusBar )
{ {
XNODE* lNode, * tNode, * mNode; XNODE* lNode, * tNode, * mNode;
PCB_MODULE* mc; PCB_FOOTPRINT* fp;
PCB_PAD* pad; PCB_PAD* pad;
PCB_VIA* via; PCB_VIA* via;
PCB_KEEPOUT* keepOut; PCB_KEEPOUT* keepOut;
wxString cn, str, propValue; wxString cn, str, propValue;
lNode = aNode->GetChildren(); lNode = aNode->GetChildren();
while( lNode ) while( lNode )
{ {
mc = NULL; fp = NULL;
if( lNode->GetName() == wxT( "pattern" ) ) if( lNode->GetName() == wxT( "pattern" ) )
{ {
@ -269,38 +264,37 @@ void PCB::DoPCBComponents( XNODE* aNode,
if( tNode ) if( tNode )
{ {
mc = new PCB_MODULE( this, m_board ); fp = new PCB_FOOTPRINT( this, m_board );
mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) ); mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) );
if( mNode ) if( mNode )
mNode->GetAttribute( wxT( "Name" ), &mc->m_patGraphRefName ); mNode->GetAttribute( wxT( "Name" ), &fp->m_patGraphRefName );
mc->Parse( tNode, aStatusBar, m_defaultMeasurementUnit, aActualConversion ); fp->Parse( tNode, aStatusBar, m_DefaultMeasurementUnit, aActualConversion );
} }
} }
if( mc ) if( fp )
{ {
mc->m_compRef = cn; // default - in new version of file it is updated later.... fp->m_compRef = cn; // default - in new version of file it is updated later....
tNode = FindNode( lNode, wxT( "refDesRef" ) ); tNode = FindNode( lNode, wxT( "refDesRef" ) );
if( tNode ) if( tNode )
{ {
tNode->GetAttribute( wxT( "Name" ), &mc->m_name.text ); tNode->GetAttribute( wxT( "Name" ), &fp->m_name.text );
SetTextProperty( lNode, &mc->m_name, mc->m_patGraphRefName, wxT( SetTextProperty( lNode, &fp->m_name, fp->m_patGraphRefName, wxT( "RefDes" ),
"RefDes" ), aActualConversion ); aActualConversion );
SetTextProperty( lNode, &mc->m_value, mc->m_patGraphRefName, wxT( SetTextProperty( lNode, &fp->m_Value, fp->m_patGraphRefName, wxT( "Value" ),
"Value" ), aActualConversion ); aActualConversion );
} }
tNode = FindNode( lNode, wxT( "pt" ) ); tNode = FindNode( lNode, wxT( "pt" ) );
if( tNode ) if( tNode )
SetPosition( tNode->GetNodeContent(), {
m_defaultMeasurementUnit, SetPosition( tNode->GetNodeContent(), m_DefaultMeasurementUnit,
&mc->m_positionX, &fp->m_positionX, &fp->m_positionY, aActualConversion );
&mc->m_positionY, }
aActualConversion );
tNode = FindNode( lNode, wxT( "rotation" ) ); tNode = FindNode( lNode, wxT( "rotation" ) );
@ -308,13 +302,13 @@ void PCB::DoPCBComponents( XNODE* aNode,
{ {
str = tNode->GetNodeContent(); str = tNode->GetNodeContent();
str.Trim( false ); str.Trim( false );
mc->m_rotation = StrToInt1Units( str ); fp->m_rotation = StrToInt1Units( str );
} }
str = FindNodeGetContent( lNode, wxT( "isFlipped" ) ); str = FindNodeGetContent( lNode, wxT( "isFlipped" ) );
if( str == wxT( "True" ) ) if( str == wxT( "True" ) )
mc->m_mirror = 1; fp->m_Mirror = 1;
tNode = aNode; tNode = aNode;
@ -331,24 +325,24 @@ void PCB::DoPCBComponents( XNODE* aNode,
{ {
tNode->GetAttribute( wxT( "Name" ), &propValue ); tNode->GetAttribute( wxT( "Name" ), &propValue );
if( propValue == mc->m_name.text ) if( propValue == fp->m_name.text )
{ {
if( FindNode( tNode, wxT( "compValue" ) ) ) if( FindNode( tNode, wxT( "compValue" ) ) )
{ {
FindNode( tNode, FindNode( tNode,
wxT( "compValue" ) )->GetAttribute( wxT( "Name" ), wxT( "compValue" ) )->GetAttribute( wxT( "Name" ),
&mc->m_value.text ); &fp->m_Value.text );
mc->m_value.text.Trim( false ); fp->m_Value.text.Trim( false );
mc->m_value.text.Trim( true ); fp->m_Value.text.Trim( true );
} }
if( FindNode( tNode, wxT( "compRef" ) ) ) if( FindNode( tNode, wxT( "compRef" ) ) )
{ {
FindNode( tNode, FindNode( tNode,
wxT( "compRef" ) )->GetAttribute( wxT( "Name" ), wxT( "compRef" ) )->GetAttribute( wxT( "Name" ),
&mc->m_compRef ); &fp->m_compRef );
mc->m_compRef.Trim( false ); fp->m_compRef.Trim( false );
mc->m_compRef.Trim( true ); fp->m_compRef.Trim( true );
} }
tNode = NULL; tNode = NULL;
@ -360,7 +354,7 @@ void PCB::DoPCBComponents( XNODE* aNode,
// map pins // map pins
tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) ); tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
tNode = FindCompDefName( tNode, mc->m_compRef ); tNode = FindCompDefName( tNode, fp->m_compRef );
if( tNode ) if( tNode )
{ {
@ -381,7 +375,7 @@ void PCB::DoPCBComponents( XNODE* aNode,
break; break;
mNode->GetAttribute( wxT( "Name" ), &propValue ); mNode->GetAttribute( wxT( "Name" ), &propValue );
mc->SetName( str, propValue ); fp->SetName( str, propValue );
mNode = mNode->GetNext(); mNode = mNode->GetNext();
} }
else else
@ -397,27 +391,27 @@ void PCB::DoPCBComponents( XNODE* aNode,
} }
} }
m_pcbComponents.Add( mc ); m_PcbComponents.Add( fp );
} }
} }
else if( lNode->GetName() == wxT( "pad" ) ) else if( lNode->GetName() == wxT( "pad" ) )
{ {
pad = new PCB_PAD( this, m_board ); pad = new PCB_PAD( this, m_board );
pad->Parse( lNode, m_defaultMeasurementUnit, aActualConversion ); pad->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion );
m_pcbComponents.Add( pad ); m_PcbComponents.Add( pad );
} }
else if( lNode->GetName() == wxT( "via" ) ) else if( lNode->GetName() == wxT( "via" ) )
{ {
via = new PCB_VIA( this, m_board ); via = new PCB_VIA( this, m_board );
via->Parse( lNode, m_defaultMeasurementUnit, aActualConversion ); via->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion );
m_pcbComponents.Add( via ); m_PcbComponents.Add( via );
} }
else if( lNode->GetName() == wxT( "polyKeepOut" ) ) else if( lNode->GetName() == wxT( "polyKeepOut" ) )
{ {
keepOut = new PCB_KEEPOUT( m_callbacks, m_board, 0 ); keepOut = new PCB_KEEPOUT( m_callbacks, m_board, 0 );
if( keepOut->Parse( lNode, m_defaultMeasurementUnit, aActualConversion ) ) if( keepOut->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion ) )
m_pcbComponents.Add( keepOut ); m_PcbComponents.Add( keepOut );
else else
delete keepOut; delete keepOut;
} }
@ -427,25 +421,24 @@ void PCB::DoPCBComponents( XNODE* aNode,
} }
void PCB::ConnectPinToNet( const wxString& aCompRef, void PCB::ConnectPinToNet( const wxString& aCompRef, const wxString& aPinRef,
const wxString& aPinRef,
const wxString& aNetName ) const wxString& aNetName )
{ {
PCB_MODULE* module; PCB_FOOTPRINT* footprint;
PCB_PAD* cp; PCB_PAD* cp;
int i, j; int i, j;
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
{ {
module = (PCB_MODULE*) m_pcbComponents[i]; footprint = (PCB_FOOTPRINT*) m_PcbComponents[i];
if( module->m_objType == wxT( 'M' ) && module->m_name.text == aCompRef ) if( footprint->m_objType == wxT( 'M' ) && footprint->m_name.text == aCompRef )
{ {
for( j = 0; j < (int) module->m_moduleObjects.GetCount(); j++ ) for( j = 0; j < (int) footprint->m_FootprintItems.GetCount(); j++ )
{ {
if( module->m_moduleObjects[j]->m_objType == wxT( 'P' ) ) if( footprint->m_FootprintItems[j]->m_objType == wxT( 'P' ) )
{ {
cp = (PCB_PAD*) module->m_moduleObjects[j]; cp = (PCB_PAD*) footprint->m_FootprintItems[j];
if( cp->m_name.text == aPinRef ) if( cp->m_name.text == aPinRef )
cp->m_net = aNetName; cp->m_net = aNetName;
@ -552,12 +545,12 @@ void PCB::MapLayer( XNODE* aNode )
newlayer.layerType = LAYER_TYPE_PLANE; newlayer.layerType = LAYER_TYPE_PLANE;
} }
m_layersMap.insert( std::make_pair( num, newlayer ) ); m_LayersMap.insert( std::make_pair( num, newlayer ) );
if( FindNode( aNode, wxT( "netNameRef" ) ) ) if( FindNode( aNode, wxT( "netNameRef" ) ) )
{ {
FindNode( aNode, wxT( "netNameRef" ) )->GetAttribute( wxT( "Name" ), FindNode( aNode, wxT( "netNameRef" ) )->GetAttribute( wxT( "Name" ),
&m_layersMap[(int) num].netNameRef ); &m_LayersMap[(int) num].netNameRef );
} }
} }
@ -621,11 +614,11 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
if( pNode ) if( pNode )
{ {
SetPosition( pNode->GetNodeContent(), m_defaultMeasurementUnit, SetPosition( pNode->GetNodeContent(), m_DefaultMeasurementUnit,
&x, &y, aActualConversion ); &x, &y, aActualConversion );
if( FindOutlinePoint( &m_boardOutline, wxRealPoint( x, y) ) == -1 ) if( FindOutlinePoint( &m_BoardOutline, wxRealPoint( x, y) ) == -1 )
m_boardOutline.Add( new wxRealPoint( x, y ) ); m_BoardOutline.Add( new wxRealPoint( x, y ) );
} }
if( pNode ) if( pNode )
@ -633,11 +626,11 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
if( pNode ) if( pNode )
{ {
SetPosition( pNode->GetNodeContent(), m_defaultMeasurementUnit, SetPosition( pNode->GetNodeContent(), m_DefaultMeasurementUnit,
&x, &y, aActualConversion ); &x, &y, aActualConversion );
if( FindOutlinePoint( &m_boardOutline, wxRealPoint( x, y) ) == -1 ) if( FindOutlinePoint( &m_BoardOutline, wxRealPoint( x, y) ) == -1 )
m_boardOutline.Add( new wxRealPoint( x, y ) ); m_BoardOutline.Add( new wxRealPoint( x, y ) );
} }
} }
@ -646,16 +639,16 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
//m_boardOutline.Sort( cmpFunc ); //m_boardOutline.Sort( cmpFunc );
// sort vertices according to the distances between them // sort vertices according to the distances between them
if( m_boardOutline.GetCount() > 3 ) if( m_BoardOutline.GetCount() > 3 )
{ {
for( i = 0; i < (int) m_boardOutline.GetCount() - 1; i++ ) for( i = 0; i < (int) m_BoardOutline.GetCount() - 1; i++ )
{ {
minDistance = GetDistance( m_boardOutline[i], m_boardOutline[i + 1] ); minDistance = GetDistance( m_BoardOutline[i], m_BoardOutline[ i + 1] );
targetInd = i + 1; targetInd = i + 1;
for( j = i + 2; j < (int) m_boardOutline.GetCount(); j++ ) for( j = i + 2; j < (int) m_BoardOutline.GetCount(); j++ )
{ {
distance = GetDistance( m_boardOutline[i], m_boardOutline[j] ); distance = GetDistance( m_BoardOutline[i], m_BoardOutline[j] );
if( distance < minDistance ) if( distance < minDistance )
{ {
minDistance = distance; minDistance = distance;
@ -663,9 +656,9 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
} }
} }
xchgPoint = m_boardOutline[i + 1]; xchgPoint = m_BoardOutline[ i + 1];
m_boardOutline[i + 1] = m_boardOutline[targetInd]; m_BoardOutline[ i + 1] = m_BoardOutline[targetInd];
m_boardOutline[targetInd] = xchgPoint; m_BoardOutline[targetInd] = xchgPoint;
} }
} }
@ -683,7 +676,7 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
XNODE* aNode;//, *aaNode; XNODE* aNode;//, *aaNode;
PCB_NET* net; PCB_NET* net;
PCB_COMPONENT* comp; PCB_COMPONENT* comp;
PCB_MODULE* module; PCB_FOOTPRINT* footprint;
wxString compRef, pinRef, layerName, layerType; wxString compRef, pinRef, layerName, layerType;
int i, j, netCode; int i, j, netCode;
@ -696,9 +689,9 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
if( aNode ) if( aNode )
{ {
m_defaultMeasurementUnit = aNode->GetNodeContent().Lower(); m_DefaultMeasurementUnit = aNode->GetNodeContent().Lower();
m_defaultMeasurementUnit.Trim( true ); m_DefaultMeasurementUnit.Trim( true );
m_defaultMeasurementUnit.Trim( false ); m_DefaultMeasurementUnit.Trim( false );
} }
} }
@ -793,7 +786,7 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
{ {
net = new PCB_NET( netCode++ ); net = new PCB_NET( netCode++ );
net->Parse( aNode ); net->Parse( aNode );
m_pcbNetlist.Add( net ); m_PcbNetlist.Add( net );
aNode = aNode->GetNext(); aNode = aNode->GetNext();
} }
@ -817,8 +810,8 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
// objects // objects
if( aNode->GetName() == wxT( "layerContents" ) ) if( aNode->GetName() == wxT( "layerContents" ) )
DoLayerContentsObjects( aNode, NULL, &m_pcbComponents, aStatusBar, DoLayerContentsObjects( aNode, NULL, &m_PcbComponents, aStatusBar,
m_defaultMeasurementUnit, aActualConversion ); m_DefaultMeasurementUnit, aActualConversion );
aNode = aNode->GetNext(); aNode = aNode->GetNext();
} }
@ -826,78 +819,78 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
// POSTPROCESS -- SET NETLIST REFERENCES // POSTPROCESS -- SET NETLIST REFERENCES
// aStatusBar->SetStatusText( wxT( "Processing NETLIST " ) ); // aStatusBar->SetStatusText( wxT( "Processing NETLIST " ) );
for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ ) for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
{ {
net = m_pcbNetlist[i]; net = m_PcbNetlist[i];
for( j = 0; j < (int) net->m_netNodes.GetCount(); j++ ) for( j = 0; j < (int) net->m_NetNodes.GetCount(); j++ )
{ {
compRef = net->m_netNodes[j]->m_compRef; compRef = net->m_NetNodes[j]->m_CompRef;
compRef.Trim( false ); compRef.Trim( false );
compRef.Trim( true ); compRef.Trim( true );
pinRef = net->m_netNodes[j]->m_pinRef; pinRef = net->m_NetNodes[j]->m_PinRef;
pinRef.Trim( false ); pinRef.Trim( false );
pinRef.Trim( true ); pinRef.Trim( true );
ConnectPinToNet( compRef, pinRef, net->m_name ); ConnectPinToNet( compRef, pinRef, net->m_Name );
} }
} }
// POSTPROCESS -- FLIP COMPONENTS // POSTPROCESS -- FLIP COMPONENTS
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
{ {
if( m_pcbComponents[i]->m_objType == wxT( 'M' ) ) if( m_PcbComponents[i]->m_objType == wxT( 'M' ) )
( (PCB_MODULE*) m_pcbComponents[i] )->Flip(); ( (PCB_FOOTPRINT*) m_PcbComponents[i] )->Flip();
} }
// POSTPROCESS -- SET/OPTIMIZE NEW PCB POSITION // POSTPROCESS -- SET/OPTIMIZE NEW PCB POSITION
// aStatusBar->SetStatusText( wxT( "Optimizing BOARD POSITION " ) ); // aStatusBar->SetStatusText( wxT( "Optimizing BOARD POSITION " ) );
m_sizeX = 10000000; m_SizeX = 10000000;
m_sizeY = 0; m_SizeY = 0;
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
{ {
comp = m_pcbComponents[i]; comp = m_PcbComponents[i];
if( comp->m_positionY < m_sizeY ) if( comp->m_positionY < m_SizeY )
m_sizeY = comp->m_positionY; // max Y m_SizeY = comp->m_positionY; // max Y
if( comp->m_positionX < m_sizeX && comp->m_positionX > 0 ) if( comp->m_positionX < m_SizeX && comp->m_positionX > 0 )
m_sizeX = comp->m_positionX; // Min X m_SizeX = comp->m_positionX; // Min X
} }
m_sizeY -= 10000; m_SizeY -= 10000;
m_sizeX -= 10000; m_SizeX -= 10000;
// aStatusBar->SetStatusText( wxT( " POSITIONING POSTPROCESS " ) ); // aStatusBar->SetStatusText( wxT( " POSITIONING POSTPROCESS " ) );
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
m_pcbComponents[i]->SetPosOffset( -m_sizeX, -m_sizeY ); m_PcbComponents[i]->SetPosOffset( -m_SizeX, -m_SizeY );
m_sizeX = 0; m_SizeX = 0;
m_sizeY = 0; m_SizeY = 0;
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
{ {
comp = m_pcbComponents[i]; comp = m_PcbComponents[i];
if( comp->m_positionY < m_sizeY ) if( comp->m_positionY < m_SizeY )
m_sizeY = comp->m_positionY; // max Y m_SizeY = comp->m_positionY; // max Y
if( comp->m_positionX > m_sizeX ) if( comp->m_positionX > m_SizeX )
m_sizeX = comp->m_positionX; // Min X m_SizeX = comp->m_positionX; // Min X
} }
// SHEET SIZE CALCULATION // SHEET SIZE CALCULATION
m_sizeY = -m_sizeY; // it is in absolute units m_SizeY = -m_SizeY; // it is in absolute units
m_sizeX += 10000; m_SizeX += 10000;
m_sizeY += 10000; m_SizeY += 10000;
// A4 is minimum $Descr A4 11700 8267 // A4 is minimum $Descr A4 11700 8267
if( m_sizeX < 11700 ) if( m_SizeX < 11700 )
m_sizeX = 11700; m_SizeX = 11700;
if( m_sizeY < 8267 ) if( m_SizeY < 8267 )
m_sizeY = 8267; m_SizeY = 8267;
} }
else else
{ {
@ -916,10 +909,10 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
if( aNode->GetName() == wxT( "compDef" ) ) if( aNode->GetName() == wxT( "compDef" ) )
{ {
module = new PCB_MODULE( this, m_board ); footprint = new PCB_FOOTPRINT( this, m_board );
module->Parse( aNode, aStatusBar, m_defaultMeasurementUnit, footprint->Parse( aNode, aStatusBar, m_DefaultMeasurementUnit,
aActualConversion ); aActualConversion );
m_pcbComponents.Add( module ); m_PcbComponents.Add( footprint );
} }
aNode = aNode->GetNext(); aNode = aNode->GetNext();
@ -936,16 +929,16 @@ void PCB::AddToBoard()
m_board->SetCopperLayerCount( m_layersStackup.GetCount() ); m_board->SetCopperLayerCount( m_layersStackup.GetCount() );
for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ ) for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
{ {
net = m_pcbNetlist[i]; net = m_PcbNetlist[i];
m_board->Add( new NETINFO_ITEM( m_board, net->m_name, net->m_netCode ) ); m_board->Add( new NETINFO_ITEM( m_board, net->m_Name, net->m_NetCode ) );
} }
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ ) for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
{ {
m_pcbComponents[i]->AddToBoard(); m_PcbComponents[i]->AddToBoard();
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -34,57 +34,52 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <xnode.h> #include <xnode.h>
#include <pcb_module.h> #include <pcb_footprint.h>
#include <pcb_net.h> #include <pcb_net.h>
namespace PCAD2KICAD { namespace PCAD2KICAD {
class PCB : public PCB_MODULE, public PCB_CALLBACKS class PCB : public PCB_FOOTPRINT, public PCB_CALLBACKS
{ {
public: public:
PCB_COMPONENTS_ARRAY m_pcbComponents; // PCB footprints,Lines,Routes,Texts, .... and so on PCB_COMPONENTS_ARRAY m_PcbComponents; // PCB footprints,Lines,Routes,Texts, .... and so on
PCB_NETS_ARRAY m_pcbNetlist; // net objects collection PCB_NETS_ARRAY m_PcbNetlist; // net objects collection
wxString m_defaultMeasurementUnit; wxString m_DefaultMeasurementUnit;
std::map<int, TLAYER> m_layersMap; // flexible layers mapping std::map<int, TLAYER> m_LayersMap; // flexible layers mapping
int m_sizeX; int m_SizeX;
int m_sizeY; int m_SizeY;
PCB( BOARD* aBoard ); PCB( BOARD* aBoard );
~PCB(); ~PCB();
PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) override; PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) override;
LAYER_TYPE_T GetLayerType( int aPCadLayer ) override; LAYER_TYPE_T GetLayerType( int aPCadLayer ) override;
wxString GetLayerNetNameRef( int aPCadLayer ) override; wxString GetLayerNetNameRef( int aPCadLayer ) override;
int GetNetCode( wxString aNetName ) override; int GetNetCode( wxString aNetName ) override;
void ParseBoard( wxStatusBar* aStatusBar, void ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
wxXmlDocument* aXmlDoc, const wxString& aActualConversion );
const wxString& aActualConversion );
void AddToBoard() override; void AddToBoard() override;
private: private:
wxArrayString m_layersStackup; wxArrayString m_layersStackup;
XNODE* FindCompDefName( XNODE* aNode, const wxString& aName ); XNODE* FindCompDefName( XNODE* aNode, const wxString& aName );
void SetTextProperty( XNODE* aNode,
TTEXTVALUE* aTextValue, void SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aPatGraphRefName,
const wxString& aPatGraphRefName, const wxString& aXmlName, const wxString& aActualConversion );
const wxString& aXmlName,
const wxString& aActualConversion ); void DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString& aActualConversion,
void DoPCBComponents( XNODE* aNode, wxStatusBar* aStatusBar );
wxXmlDocument* aXmlDoc,
const wxString& aActualConversion, void ConnectPinToNet( const wxString& aCr, const wxString& aPr, const wxString& aNetName );
wxStatusBar* aStatusBar );
void ConnectPinToNet( const wxString& aCr, int FindLayer( const wxString& aLayerName );
const wxString& aPr, void MapLayer( XNODE* aNode );
const wxString& aNetName ); int FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint );
int FindLayer( const wxString& aLayerName ); double GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 );
void MapLayer( XNODE* aNode ); void GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion );
int FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint );
double GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 );
void GetBoardOutline( wxXmlDocument* aXmlDoc,
const wxString& aActualConversion );
}; };
} // namespace PCAD2KICAD } // namespace PCAD2KICAD

View File

@ -30,7 +30,7 @@
#include <pcb_cutout.h> #include <pcb_cutout.h>
#include <pcb_plane.h> #include <pcb_plane.h>
#include <pcb_line.h> #include <pcb_line.h>
#include <pcb_module.h> #include <pcb_footprint.h>
#include <pcb_pad.h> #include <pcb_pad.h>
#include <pcb_polygon.h> #include <pcb_polygon.h>
#include <plugins/pcad/pcb_text.h> #include <plugins/pcad/pcb_text.h>
@ -40,28 +40,28 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
PCB_MODULE::PCB_MODULE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_FOOTPRINT::PCB_FOOTPRINT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard ) PCB_COMPONENT( aCallbacks, aBoard )
{ {
InitTTextValue( &m_value ); InitTTextValue( &m_Value );
m_mirror = 0; m_Mirror = 0;
m_objType = wxT( 'M' ); // FOOTPRINT m_objType = wxT( 'M' ); // FOOTPRINT
m_KiCadLayer = F_SilkS; // default m_KiCadLayer = F_SilkS; // default
} }
PCB_MODULE::~PCB_MODULE() PCB_FOOTPRINT::~PCB_FOOTPRINT()
{ {
int i; int i;
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
delete m_moduleObjects[i]; delete m_FootprintItems[i];
} }
} }
XNODE* PCB_MODULE::FindModulePatternDefName( XNODE* aNode, const wxString& aName ) XNODE* PCB_FOOTPRINT::FindModulePatternDefName( XNODE* aNode, const wxString& aName )
{ {
XNODE* result, * lNode; XNODE* result, * lNode;
wxString propValue1, propValue2; wxString propValue1, propValue2;
@ -115,7 +115,7 @@ XNODE* PCB_MODULE::FindModulePatternDefName( XNODE* aNode, const wxString& aName
} }
XNODE* PCB_MODULE::FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName ) XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName )
{ {
XNODE* result, * pNode, * lNode; XNODE* result, * pNode, * lNode;
wxString propValue, patName; wxString propValue, patName;
@ -207,12 +207,12 @@ XNODE* PCB_MODULE::FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGra
} }
void PCB_MODULE::DoLayerContentsObjects( XNODE* aNode, void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode,
PCB_MODULE* aPCBModule, PCB_FOOTPRINT* aFootprint,
PCB_COMPONENTS_ARRAY* aList, PCB_COMPONENTS_ARRAY* aList,
wxStatusBar* aStatusBar, wxStatusBar* aStatusBar,
const wxString& aDefaultMeasurementUnit, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
PCB_ARC* arc; PCB_ARC* arc;
PCB_POLYGON* polygon; PCB_POLYGON* polygon;
@ -240,7 +240,7 @@ void PCB_MODULE::DoLayerContentsObjects( XNODE* aNode,
{ {
plane_layer = new PCB_POLYGON( m_callbacks, m_board, PCadLayer ); plane_layer = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
plane_layer->AssignNet( m_callbacks->GetLayerNetNameRef( PCadLayer ) ); plane_layer->AssignNet( m_callbacks->GetLayerNetNameRef( PCadLayer ) );
plane_layer->SetOutline( &m_boardOutline ); plane_layer->SetOutline( &m_BoardOutline );
aList->Add( plane_layer ); aList->Add( plane_layer );
// fill the polygon with the same contour as its outline is // fill the polygon with the same contour as its outline is
@ -281,7 +281,7 @@ void PCB_MODULE::DoLayerContentsObjects( XNODE* aNode,
{ {
tNode = FindNode( lNode, wxT( "textStyleRef" ) ); tNode = FindNode( lNode, wxT( "textStyleRef" ) );
if( tNode && aPCBModule ) if( tNode && aFootprint )
{ {
// TODO: to understand and may be repair // TODO: to understand and may be repair
// Alexander Lunev: originally in Delphi version of the project there was // Alexander Lunev: originally in Delphi version of the project there was
@ -291,7 +291,7 @@ void PCB_MODULE::DoLayerContentsObjects( XNODE* aNode,
// required when the function DoLayerContentsObjects() is called from // required when the function DoLayerContentsObjects() is called from
// function ProcessXMLtoPCBLib(). // function ProcessXMLtoPCBLib().
SetFontProperty( tNode, SetFontProperty( tNode,
&aPCBModule->m_name, &aFootprint->m_name,
aDefaultMeasurementUnit, aDefaultMeasurementUnit,
aActualConversion ); aActualConversion );
} }
@ -362,27 +362,27 @@ void PCB_MODULE::DoLayerContentsObjects( XNODE* aNode,
} }
void PCB_MODULE::SetName( const wxString& aPin, const wxString& aName ) void PCB_FOOTPRINT::SetName( const wxString& aPin, const wxString& aName )
{ {
int i; int i;
long num; long num;
aPin.ToLong( &num ); aPin.ToLong( &num );
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
if( ( (PCB_PAD*) m_moduleObjects[i] )->m_number == num ) if(( (PCB_PAD*) m_FootprintItems[i] )->m_Number == num )
( (PCB_PAD*) m_moduleObjects[i] )->m_name.text = aName; ( (PCB_PAD*) m_FootprintItems[i] )->m_name.text = aName;
} }
} }
void PCB_MODULE::Parse( XNODE* aNode, wxStatusBar* aStatusBar, void PCB_FOOTPRINT::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
const wxString& aDefaultMeasurementUnit, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
XNODE* lNode, * tNode, * mNode; XNODE* lNode, * tNode, * mNode;
PCB_PAD* pad; PCB_PAD* pad;
@ -409,14 +409,14 @@ void PCB_MODULE::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
{ {
pad = new PCB_PAD( m_callbacks, m_board ); pad = new PCB_PAD( m_callbacks, m_board );
pad->Parse( tNode, aDefaultMeasurementUnit, aActualConversion ); pad->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
m_moduleObjects.Add( pad ); m_FootprintItems.Add( pad );
} }
if( tNode->GetName() == wxT( "via" ) ) if( tNode->GetName() == wxT( "via" ) )
{ {
via = new PCB_VIA( m_callbacks, m_board ); via = new PCB_VIA( m_callbacks, m_board );
via->Parse( tNode, aDefaultMeasurementUnit, aActualConversion ); via->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
m_moduleObjects.Add( via ); m_FootprintItems.Add( via );
} }
tNode = tNode->GetNext(); tNode = tNode->GetNext();
@ -432,7 +432,7 @@ void PCB_MODULE::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
while( lNode ) while( lNode )
{ {
if( lNode->GetName() == wxT( "layerContents" ) ) if( lNode->GetName() == wxT( "layerContents" ) )
DoLayerContentsObjects( lNode, this, &m_moduleObjects, aStatusBar, DoLayerContentsObjects( lNode, this, &m_FootprintItems, aStatusBar,
aDefaultMeasurementUnit, aActualConversion ); aDefaultMeasurementUnit, aActualConversion );
lNode = lNode->GetNext(); lNode = lNode->GetNext();
@ -473,7 +473,7 @@ void PCB_MODULE::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
} }
wxString PCB_MODULE::ModuleLayer( int aMirror ) wxString PCB_FOOTPRINT::ModuleLayer( int aMirror )
{ {
wxString result; wxString result;
@ -490,7 +490,7 @@ wxString PCB_MODULE::ModuleLayer( int aMirror )
} }
void PCB_MODULE::AddToBoard() void PCB_FOOTPRINT::AddToBoard()
{ {
int i; int i;
int r; int r;
@ -499,23 +499,23 @@ void PCB_MODULE::AddToBoard()
CorrectTextPosition( &m_name ); CorrectTextPosition( &m_name );
RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, (double) -m_rotation ); RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, (double) -m_rotation );
CorrectTextPosition( &m_value ); CorrectTextPosition( &m_Value );
RotatePoint( &m_value.correctedPositionX, &m_value.correctedPositionY, (double) -m_rotation ); RotatePoint( &m_Value.correctedPositionX, &m_Value.correctedPositionY, (double) -m_rotation );
FOOTPRINT* module = new FOOTPRINT( m_board ); FOOTPRINT* footprint = new FOOTPRINT( m_board );
m_board->Add( module, ADD_MODE::APPEND ); m_board->Add( footprint, ADD_MODE::APPEND );
module->SetPosition( wxPoint( m_positionX, m_positionY ) ); footprint->SetPosition( wxPoint( m_positionX, m_positionY ) );
module->SetLayer( m_mirror ? B_Cu : F_Cu ); footprint->SetLayer( m_Mirror ? B_Cu : F_Cu );
module->SetOrientation( m_rotation ); footprint->SetOrientation( m_rotation );
module->SetLastEditTime( 0 ); footprint->SetLastEditTime( 0 );
LIB_ID fpID; LIB_ID fpID;
fpID.Parse( m_compRef, LIB_ID::ID_PCB, true ); fpID.Parse( m_compRef, LIB_ID::ID_PCB, true );
module->SetFPID( fpID ); footprint->SetFPID( fpID );
// reference text // reference text
FP_TEXT* ref_text = &module->Reference(); FP_TEXT* ref_text = &footprint->Reference();
ref_text->SetText( ValidateReference( m_name.text ) ); ref_text->SetText( ValidateReference( m_name.text ) );
ref_text->SetType( FP_TEXT::TEXT_is_REFERENCE ); ref_text->SetType( FP_TEXT::TEXT_is_REFERENCE );
@ -542,98 +542,98 @@ void PCB_MODULE::AddToBoard()
ref_text->SetDrawCoord(); ref_text->SetDrawCoord();
// value text // value text
FP_TEXT* val_text = &module->Value(); FP_TEXT* val_text = &footprint->Value();
val_text->SetText( m_value.text ); val_text->SetText( m_Value.text );
val_text->SetType( FP_TEXT::TEXT_is_VALUE ); val_text->SetType( FP_TEXT::TEXT_is_VALUE );
val_text->SetPos0( wxPoint( m_value.correctedPositionX, m_value.correctedPositionY ) ); val_text->SetPos0( wxPoint( m_Value.correctedPositionX, m_Value.correctedPositionY ) );
if( m_value.isTrueType ) if( m_Value.isTrueType )
SetTextSizeFromTrueTypeFontHeight( val_text, m_value.textHeight ); SetTextSizeFromTrueTypeFontHeight( val_text, m_Value.textHeight );
else else
SetTextSizeFromStrokeFontHeight( val_text, m_value.textHeight ); SetTextSizeFromStrokeFontHeight( val_text, m_Value.textHeight );
r = m_value.textRotation - m_rotation; r = m_Value.textRotation - m_rotation;
val_text->SetTextAngle( r ); val_text->SetTextAngle( r );
val_text->SetKeepUpright( false ); val_text->SetKeepUpright( false );
val_text->SetItalic( m_value.isItalic ); val_text->SetItalic( m_Value.isItalic );
val_text->SetTextThickness( m_value.textstrokeWidth ); val_text->SetTextThickness( m_Value.textstrokeWidth );
val_text->SetMirrored( m_value.mirror ); val_text->SetMirrored( m_Value.mirror );
val_text->SetVisible( m_value.textIsVisible ); val_text->SetVisible( m_Value.textIsVisible );
val_text->SetLayer( m_value.mirror ? FlipLayer( m_KiCadLayer ) : m_KiCadLayer ); val_text->SetLayer( m_Value.mirror ? FlipLayer( m_KiCadLayer ) : m_KiCadLayer );
// Calculate the actual position. // Calculate the actual position.
val_text->SetDrawCoord(); val_text->SetDrawCoord();
// TEXTS // TEXTS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'T' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'T' ) )
{ {
( (PCB_TEXT*) m_moduleObjects[i] )->m_tag = i + 2; ( (PCB_TEXT*) m_FootprintItems[i] )->m_tag = i + 2;
m_moduleObjects[ i ]->AddToFootprint( module ); m_FootprintItems[ i ]->AddToFootprint( footprint );
} }
} }
// FOOTPRINT LINES // FOOTPRINT LINES
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'L' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'L' ) )
m_moduleObjects[ i ]->AddToFootprint( module ); m_FootprintItems[ i ]->AddToFootprint( footprint );
} }
// FOOTPRINT ARCS // FOOTPRINT ARCS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'A' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'A' ) )
m_moduleObjects[ i ]->AddToFootprint( module ); m_FootprintItems[ i ]->AddToFootprint( footprint );
} }
// FOOTPRINT POLYGONS // FOOTPRINT POLYGONS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'Z' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'Z' ) )
m_moduleObjects[ i ]->AddToFootprint( module ); m_FootprintItems[ i ]->AddToFootprint( footprint );
} }
// PADS // PADS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
((PCB_PAD*) m_moduleObjects[ i ] )->AddToFootprint( module, m_rotation, false ); ((PCB_PAD*) m_FootprintItems[ i ] )->AddToFootprint( footprint, m_rotation, false );
} }
// VIAS // VIAS
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'V' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'V' ) )
((PCB_VIA*) m_moduleObjects[ i ] )->AddToFootprint( module, m_rotation, false ); ((PCB_VIA*) m_FootprintItems[ i ] )->AddToFootprint( footprint, m_rotation, false );
} }
module->CalculateBoundingBox(); footprint->CalculateBoundingBox();
} }
void PCB_MODULE::Flip() void PCB_FOOTPRINT::Flip()
{ {
int i; int i;
if( m_mirror == 1 ) if( m_Mirror == 1 )
{ {
m_rotation = -m_rotation; m_rotation = -m_rotation;
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_moduleObjects[i]->m_objType == wxT( 'L' ) || // lines if( m_FootprintItems[i]->m_objType == wxT( 'L' ) || // lines
m_moduleObjects[i]->m_objType == wxT( 'A' ) || // arcs m_FootprintItems[i]->m_objType == wxT( 'A' ) || // arcs
m_moduleObjects[i]->m_objType == wxT( 'Z' ) || // polygons m_FootprintItems[i]->m_objType == wxT( 'Z' ) || // polygons
m_moduleObjects[i]->m_objType == wxT( 'P' ) || // pads m_FootprintItems[i]->m_objType == wxT( 'P' ) || // pads
m_moduleObjects[i]->m_objType == wxT( 'V' ) ) // vias m_FootprintItems[i]->m_objType == wxT( 'V' ) ) // vias
{ {
m_moduleObjects[i]->Flip(); m_FootprintItems[i]->Flip();
} }
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -37,34 +37,32 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
class PCB_MODULE : public PCB_COMPONENT class PCB_FOOTPRINT : public PCB_COMPONENT
{ {
public: public:
TTEXTVALUE m_value; // has reference (Name from parent) and value TTEXTVALUE m_Value; // has reference (Name from parent) and value
PCB_COMPONENTS_ARRAY m_moduleObjects; // set of objects like PCB_LINE, PCB_PAD, PCB_VIA,.... PCB_COMPONENTS_ARRAY m_FootprintItems; // set of objects like PCB_LINE, PCB_PAD, PCB_VIA....
int m_mirror; int m_Mirror;
VERTICES_ARRAY m_boardOutline; VERTICES_ARRAY m_BoardOutline;
PCB_MODULE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ); PCB_FOOTPRINT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_MODULE(); ~PCB_FOOTPRINT();
XNODE* FindModulePatternDefName( XNODE* aNode, const wxString& aName ); XNODE* FindModulePatternDefName( XNODE* aNode, const wxString& aName );
void DoLayerContentsObjects( XNODE* aNode, void DoLayerContentsObjects( XNODE* aNode, PCB_FOOTPRINT* aFootprint,
PCB_MODULE* aPCBModule, PCB_COMPONENTS_ARRAY* aList, wxStatusBar* aStatusBar,
PCB_COMPONENTS_ARRAY* aList, const wxString& aDefaultMeasurementUnit,
wxStatusBar* aStatusBar, const wxString& aActualConversion );
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion );
void SetName( const wxString& aPin, const wxString& aName ); void SetName( const wxString& aPin, const wxString& aName );
virtual void Parse( XNODE* aNode, wxStatusBar* aStatusBar, virtual void Parse( XNODE* aNode, wxStatusBar* aStatusBar,
const wxString& aDefaultMeasurementUnit, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ); const wxString& aActualConversion );
virtual void Flip() override; virtual void Flip() override;
void AddToBoard() override; void AddToBoard() override;
private: private:
XNODE* FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName ); XNODE* FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -39,9 +39,9 @@ namespace PCAD2KICAD {
PCB_LINE::PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, PCB_LINE::PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks,
aBoard ) aBoard )
{ {
m_width = 0; m_Width = 0;
m_toX = 0; m_ToX = 0;
m_toY = 0; m_ToY = 0;
m_objType = wxT( 'L' ); m_objType = wxT( 'L' );
} }
@ -63,9 +63,9 @@ void PCB_LINE::Parse( XNODE* aNode,
m_KiCadLayer = GetKiCadLayer(); m_KiCadLayer = GetKiCadLayer();
m_positionX = 0; m_positionX = 0;
m_positionY = 0; m_positionY = 0;
m_toX = 0; m_ToX = 0;
m_toY = 0; m_ToY = 0;
m_width = 0; m_Width = 0;
lNode = FindNode( aNode, wxT( "pt" ) ); lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode ) if( lNode )
@ -77,12 +77,12 @@ void PCB_LINE::Parse( XNODE* aNode,
if( lNode ) if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_toX, &m_toY, aActualConversion ); &m_ToX, &m_ToY, aActualConversion );
lNode = FindNode( aNode, wxT( "width" ) ); lNode = FindNode( aNode, wxT( "width" ) );
if( lNode ) if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion ); SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Width, aActualConversion );
lNode = FindNode( aNode, wxT( "netNameRef" ) ); lNode = FindNode( aNode, wxT( "netNameRef" ) );
@ -101,8 +101,8 @@ void PCB_LINE::SetPosOffset( int aX_offs, int aY_offs )
{ {
PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs ); PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
m_toX += aX_offs; m_ToX += aX_offs;
m_toY += aY_offs; m_ToY += aY_offs;
} }
@ -110,7 +110,7 @@ void PCB_LINE::Flip()
{ {
PCB_COMPONENT::Flip(); PCB_COMPONENT::Flip();
m_toX = -m_toX; m_ToX = -m_ToX;
m_KiCadLayer = FlipLayer( m_KiCadLayer ); m_KiCadLayer = FlipLayer( m_KiCadLayer );
} }
@ -123,9 +123,9 @@ void PCB_LINE::AddToFootprint( FOOTPRINT* aFootprint )
aFootprint->Add( segment ); aFootprint->Add( segment );
segment->m_Start0 = wxPoint( m_positionX, m_positionY ); segment->m_Start0 = wxPoint( m_positionX, m_positionY );
segment->m_End0 = wxPoint( m_toX, m_toY ); segment->m_End0 = wxPoint( m_ToX, m_ToY );
segment->SetWidth( m_width ); segment->SetWidth( m_Width );
segment->SetLayer( m_KiCadLayer ); segment->SetLayer( m_KiCadLayer );
segment->SetDrawCoord(); segment->SetDrawCoord();
@ -141,9 +141,9 @@ void PCB_LINE::AddToBoard()
m_board->Add( track ); m_board->Add( track );
track->SetPosition( wxPoint( m_positionX, m_positionY ) ); track->SetPosition( wxPoint( m_positionX, m_positionY ) );
track->SetEnd( wxPoint( m_toX, m_toY ) ); track->SetEnd( wxPoint( m_ToX, m_ToY ) );
track->SetWidth( m_width ); track->SetWidth( m_Width );
track->SetLayer( m_KiCadLayer ); track->SetLayer( m_KiCadLayer );
track->SetNetCode( m_netCode ); track->SetNetCode( m_netCode );
@ -155,8 +155,8 @@ void PCB_LINE::AddToBoard()
segment->SetLayer( m_KiCadLayer ); segment->SetLayer( m_KiCadLayer );
segment->SetStart( wxPoint( m_positionX, m_positionY ) ); segment->SetStart( wxPoint( m_positionX, m_positionY ) );
segment->SetEnd( wxPoint( m_toX, m_toY ) ); segment->SetEnd( wxPoint( m_ToX, m_ToY ) );
segment->SetWidth( m_width ); segment->SetWidth( m_Width );
} }
} }

View File

@ -40,9 +40,9 @@ namespace PCAD2KICAD {
class PCB_LINE : public PCB_COMPONENT class PCB_LINE : public PCB_COMPONENT
{ {
public: public:
int m_width; int m_Width;
int m_toX; int m_ToX;
int m_toY; int m_ToY;
PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ); PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_LINE(); ~PCB_LINE();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -35,8 +35,8 @@ namespace PCAD2KICAD {
PCB_NET_NODE::PCB_NET_NODE() PCB_NET_NODE::PCB_NET_NODE()
{ {
m_compRef = wxEmptyString; m_CompRef = wxEmptyString;
m_pinRef = wxEmptyString; m_PinRef = wxEmptyString;
} }
@ -45,9 +45,9 @@ PCB_NET_NODE::~PCB_NET_NODE()
} }
PCB_NET::PCB_NET( int aNetCode ) : m_netCode( aNetCode ) PCB_NET::PCB_NET( int aNetCode ) : m_NetCode( aNetCode )
{ {
m_name = wxEmptyString; m_Name = wxEmptyString;
} }
@ -55,9 +55,9 @@ PCB_NET::~PCB_NET()
{ {
int i; int i;
for( i = 0; i < (int) m_netNodes.GetCount(); i++ ) for( i = 0; i < (int) m_NetNodes.GetCount(); i++ )
{ {
delete m_netNodes[i]; delete m_NetNodes[i];
} }
} }
@ -71,7 +71,7 @@ void PCB_NET::Parse( XNODE* aNode )
aNode->GetAttribute( wxT( "Name" ), &propValue ); aNode->GetAttribute( wxT( "Name" ), &propValue );
propValue.Trim( false ); propValue.Trim( false );
propValue.Trim( true ); propValue.Trim( true );
m_name = propValue; m_Name = propValue;
lNode = FindNode( aNode, wxT( "node" ) ); lNode = FindNode( aNode, wxT( "node" ) );
@ -90,12 +90,12 @@ void PCB_NET::Parse( XNODE* aNode )
netNode = new PCB_NET_NODE; netNode = new PCB_NET_NODE;
s1.Trim( false ); s1.Trim( false );
s1.Trim( true ); s1.Trim( true );
netNode->m_compRef = s1; netNode->m_CompRef = s1;
s2.Trim( false ); s2.Trim( false );
s2.Trim( true ); s2.Trim( true );
netNode->m_pinRef = s2; netNode->m_PinRef = s2;
m_netNodes.Add( netNode ); m_NetNodes.Add( netNode );
lNode = lNode->GetNext(); lNode = lNode->GetNext();
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -39,8 +39,8 @@ namespace PCAD2KICAD {
class PCB_NET_NODE : public wxObject class PCB_NET_NODE : public wxObject
{ {
public: public:
wxString m_compRef; wxString m_CompRef;
wxString m_pinRef; wxString m_PinRef;
PCB_NET_NODE(); PCB_NET_NODE();
~PCB_NET_NODE(); ~PCB_NET_NODE();
@ -51,9 +51,9 @@ WX_DEFINE_ARRAY( PCB_NET_NODE*, PCB_NET_NODES_ARRAY );
class PCB_NET : public wxObject class PCB_NET : public wxObject
{ {
public: public:
wxString m_name; wxString m_Name;
int m_netCode; int m_NetCode;
PCB_NET_NODES_ARRAY m_netNodes; PCB_NET_NODES_ARRAY m_NetNodes;
PCB_NET( int aNetCode ); PCB_NET( int aNetCode );
~PCB_NET(); ~PCB_NET();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -38,9 +38,9 @@ PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard ) PCB_COMPONENT( aCallbacks, aBoard )
{ {
m_objType = wxT( 'P' ); m_objType = wxT( 'P' );
m_number = 0; m_Number = 0;
m_hole = 0; m_Hole = 0;
m_isHolePlated = true; m_IsHolePlated = true;
m_defaultPinDes = wxEmptyString; m_defaultPinDes = wxEmptyString;
} }
@ -49,8 +49,8 @@ PCB_PAD::~PCB_PAD()
{ {
int i; int i;
for( i = 0; i < (int) m_shapes.GetCount(); i++ ) for( i = 0; i < (int) m_Shapes.GetCount(); i++ )
delete m_shapes[i]; delete m_Shapes[i];
} }
@ -69,7 +69,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
if( lNode ) if( lNode )
{ {
lNode->GetNodeContent().ToLong( &num ); lNode->GetNodeContent().ToLong( &num );
m_number = (int) num; m_Number = (int) num;
} }
lNode = FindNode( aNode, wxT( "padStyleRef" ) ); lNode = FindNode( aNode, wxT( "padStyleRef" ) );
@ -146,10 +146,10 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
cNode = FindNode( lNode, wxT( "holeDiam" ) ); cNode = FindNode( lNode, wxT( "holeDiam" ) );
if( cNode ) if( cNode )
SetWidth( cNode->GetNodeContent(), aDefaultMeasurementUnit, &m_hole, aActualConversion ); SetWidth( cNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Hole, aActualConversion );
if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ) == wxT( "False" ) ) if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ) == wxT( "False" ) )
m_isHolePlated = false; m_IsHolePlated = false;
cNode = FindNode( lNode, wxT( "padShape" ) ); cNode = FindNode( lNode, wxT( "padShape" ) );
@ -163,7 +163,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
{ {
padShape = new PCB_PAD_SHAPE( m_callbacks, m_board ); padShape = new PCB_PAD_SHAPE( m_callbacks, m_board );
padShape->Parse( cNode, aDefaultMeasurementUnit, aActualConversion ); padShape->Parse( cNode, aDefaultMeasurementUnit, aActualConversion );
m_shapes.Add( padShape ); m_Shapes.Add( padShape );
} }
} }
@ -181,8 +181,8 @@ void PCB_PAD::Flip()
if( m_objType == wxT( 'P' ) ) if( m_objType == wxT( 'P' ) )
m_rotation = -m_rotation; m_rotation = -m_rotation;
for( i = 0; i < (int)m_shapes.GetCount(); i++ ) for( i = 0; i < (int)m_Shapes.GetCount(); i++ )
m_shapes[i]->m_KiCadLayer = FlipLayer( m_shapes[i]->m_KiCadLayer ); m_Shapes[i]->m_KiCadLayer = FlipLayer( m_Shapes[i]->m_KiCadLayer );
} }
@ -197,21 +197,21 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
PAD* pad = new PAD( aFootprint ); PAD* pad = new PAD( aFootprint );
if( !m_isHolePlated && m_hole ) if( !m_IsHolePlated && m_Hole )
{ {
// mechanical hole // mechanical hole
pad->SetShape( PAD_SHAPE_CIRCLE ); pad->SetShape( PAD_SHAPE_CIRCLE );
pad->SetAttribute( PAD_ATTRIB_NPTH ); pad->SetAttribute( PAD_ATTRIB_NPTH );
pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
pad->SetDrillSize( wxSize( m_hole, m_hole ) ); pad->SetDrillSize( wxSize( m_Hole, m_Hole ) );
pad->SetSize( wxSize( m_hole, m_hole ) ); pad->SetSize( wxSize( m_Hole, m_Hole ) );
// Mounting Hole: Solder Mask Margin from Top Layer Width size. // Mounting Hole: Solder Mask Margin from Top Layer Width size.
// Used the default zone clearance (simplify) // Used the default zone clearance (simplify)
if( m_shapes.GetCount() && m_shapes[0]->m_shape == wxT( "MtHole" ) ) if( m_Shapes.GetCount() && m_Shapes[0]->m_Shape == wxT( "MtHole" ) )
{ {
int sm_margin = ( m_shapes[0]->m_width - m_hole ) / 2; int sm_margin = ( m_Shapes[0]->m_Width - m_Hole ) / 2;
pad->SetLocalSolderMaskMargin( sm_margin ); pad->SetLocalSolderMaskMargin( sm_margin );
pad->SetLocalClearance( sm_margin + Millimeter2iu( 0.254 ) ); pad->SetLocalClearance( sm_margin + Millimeter2iu( 0.254 ) );
} }
@ -220,21 +220,21 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
} }
else else
{ {
( m_hole ) ? padType = PAD_ATTRIB_PTH : padType = PAD_ATTRIB_SMD; ( m_Hole ) ? padType = PAD_ATTRIB_PTH : padType = PAD_ATTRIB_SMD;
// form layer mask // form layer mask
for( i = 0; i < (int) m_shapes.GetCount(); i++ ) for( i = 0; i < (int) m_Shapes.GetCount(); i++ )
{ {
padShape = m_shapes[i]; padShape = m_Shapes[i];
if( padShape->m_width > 0 && padShape->m_height > 0 ) if( padShape->m_Width > 0 && padShape->m_Height > 0 )
{ {
if( padShape->m_KiCadLayer == F_Cu || if( padShape->m_KiCadLayer == F_Cu ||
padShape->m_KiCadLayer == B_Cu ) padShape->m_KiCadLayer == B_Cu )
{ {
padShapeName = padShape->m_shape; padShapeName = padShape->m_Shape;
width = padShape->m_width; width = padShape->m_Width;
height = padShape->m_height; height = padShape->m_Height;
// assume this is SMD pad // assume this is SMD pad
if( padShape->m_KiCadLayer == F_Cu ) if( padShape->m_KiCadLayer == F_Cu )
@ -280,7 +280,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
pad->SetOffset( wxPoint( 0, 0 ) ); pad->SetOffset( wxPoint( 0, 0 ) );
pad->SetDrillSize( wxSize( m_hole, m_hole ) ); pad->SetDrillSize( wxSize( m_Hole, m_Hole ) );
pad->SetAttribute( padType ); pad->SetAttribute( padType );
@ -298,8 +298,8 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
if( !aEncapsulatedPad ) if( !aEncapsulatedPad )
{ {
// pad's "Position" is not relative to the module's, // pad's "Position" is not relative to the footprint's, whereas Pos0 is relative to
// whereas Pos0 is relative to the module's but is the unrotated coordinate. // the footprint's but is the unrotated coordinate.
wxPoint padpos( m_positionX, m_positionY ); wxPoint padpos( m_positionX, m_positionY );
pad->SetPos0( padpos ); pad->SetPos0( padpos );
RotatePoint( &padpos, aFootprint->GetOrientation() ); RotatePoint( &padpos, aFootprint->GetOrientation() );
@ -320,17 +320,17 @@ void PCB_PAD::AddToBoard()
if( m_objType == wxT( 'V' ) ) // via if( m_objType == wxT( 'V' ) ) // via
{ {
// choose one of the shapes // choose one of the shapes
for( i = 0; i < (int) m_shapes.GetCount(); i++ ) for( i = 0; i < (int) m_Shapes.GetCount(); i++ )
{ {
padShape = m_shapes[i]; padShape = m_Shapes[i];
if( padShape->m_width > 0 && padShape->m_height > 0 ) if( padShape->m_Width > 0 && padShape->m_Height > 0 )
{ {
if( padShape->m_KiCadLayer == F_Cu if( padShape->m_KiCadLayer == F_Cu
|| padShape->m_KiCadLayer == B_Cu ) || padShape->m_KiCadLayer == B_Cu )
{ {
width = padShape->m_width; width = padShape->m_Width;
height = padShape->m_height; height = padShape->m_Height;
break; break;
} }
@ -351,7 +351,7 @@ void PCB_PAD::AddToBoard()
via->SetWidth( height ); via->SetWidth( height );
via->SetViaType( VIATYPE::THROUGH ); via->SetViaType( VIATYPE::THROUGH );
via->SetLayerPair( F_Cu, B_Cu ); via->SetLayerPair( F_Cu, B_Cu );
via->SetDrill( m_hole ); via->SetDrill( m_Hole );
via->SetLayer( m_KiCadLayer ); via->SetLayer( m_KiCadLayer );
via->SetNetCode( m_netCode ); via->SetNetCode( m_netCode );
@ -359,14 +359,13 @@ void PCB_PAD::AddToBoard()
} }
else // pad else // pad
{ {
FOOTPRINT* module = new FOOTPRINT( m_board ); FOOTPRINT* footprint = new FOOTPRINT( m_board );
m_board->Add( module, ADD_MODE::APPEND ); m_board->Add( footprint, ADD_MODE::APPEND );
m_name.text = m_defaultPinDes; m_name.text = m_defaultPinDes;
module->SetPosition( wxPoint( m_positionX, m_positionY ) ); footprint->SetPosition( wxPoint( m_positionX, m_positionY ) );
AddToFootprint( module, 0, true ); AddToFootprint( footprint, 0, true );
} }
} }

View File

@ -36,10 +36,10 @@ namespace PCAD2KICAD {
class PCB_PAD : public PCB_COMPONENT class PCB_PAD : public PCB_COMPONENT
{ {
public: public:
int m_number; int m_Number;
int m_hole; int m_Hole;
bool m_isHolePlated; bool m_IsHolePlated;
PCB_PAD_SHAPES_ARRAY m_shapes; PCB_PAD_SHAPES_ARRAY m_Shapes;
PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ); PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_PAD(); ~PCB_PAD();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -38,9 +38,9 @@ namespace PCAD2KICAD {
PCB_PAD_SHAPE::PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, PCB_PAD_SHAPE::PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks,
BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard ) BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
{ {
m_shape = wxEmptyString; m_Shape = wxEmptyString;
m_width = 0; m_Width = 0;
m_height = 0; m_Height = 0;
} }
@ -64,7 +64,7 @@ void PCB_PAD_SHAPE::Parse( XNODE* aNode,
{ {
str = lNode->GetNodeContent(); str = lNode->GetNodeContent();
str.Trim( false ); str.Trim( false );
m_shape = str; m_Shape = str;
} }
lNode = FindNode( aNode, wxT( "layerNumRef" ) ); lNode = FindNode( aNode, wxT( "layerNumRef" ) );
@ -77,25 +77,25 @@ void PCB_PAD_SHAPE::Parse( XNODE* aNode,
m_KiCadLayer = GetKiCadLayer(); m_KiCadLayer = GetKiCadLayer();
if( m_shape == wxT( "Oval" ) if( m_Shape == wxT( "Oval" )
|| m_shape == wxT( "Rect" ) || m_Shape == wxT( "Rect" )
|| m_shape == wxT( "Ellipse" ) || m_Shape == wxT( "Ellipse" )
|| m_shape == wxT( "MtHole" ) || m_Shape == wxT( "MtHole" )
|| m_shape == wxT( "RndRect" ) ) || m_Shape == wxT( "RndRect" ) )
{ {
lNode = FindNode( aNode, wxT( "shapeWidth" ) ); lNode = FindNode( aNode, wxT( "shapeWidth" ) );
if( lNode ) if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width, SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Width,
aActualConversion ); aActualConversion );
lNode = FindNode( aNode, wxT( "shapeHeight" ) ); lNode = FindNode( aNode, wxT( "shapeHeight" ) );
if( lNode ) if( lNode )
SetWidth( SetWidth(
lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_height, aActualConversion ); lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Height, aActualConversion );
} }
else if( m_shape == wxT( "Polygon" ) ) else if( m_Shape == wxT( "Polygon" ) )
{ {
// aproximation to simplier pad shape ..... // aproximation to simplier pad shape .....
lNode = FindNode( aNode, wxT( "shapeOutline" ) ); lNode = FindNode( aNode, wxT( "shapeOutline" ) );
@ -128,8 +128,8 @@ void PCB_PAD_SHAPE::Parse( XNODE* aNode,
lNode = lNode->GetNext(); lNode = lNode->GetNext();
} }
m_width = maxX - minX; m_Width = maxX - minX;
m_height = maxY - minY; m_Height = maxY - minY;
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -40,18 +40,17 @@ namespace PCAD2KICAD {
class PCB_PAD_SHAPE : public PCB_COMPONENT class PCB_PAD_SHAPE : public PCB_COMPONENT
{ {
public: public:
wxString m_shape; wxString m_Shape;
int m_width; int m_Width;
int m_height; int m_Height;
PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ); PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_PAD_SHAPE(); ~PCB_PAD_SHAPE();
virtual void Parse( XNODE* aNode, virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aDefaultMeasurementUnit, const wxString& aActualConversion );
const wxString& aActualConversion );
void AddToBoard() override; void AddToBoard() override;
}; };
WX_DEFINE_ARRAY( PCB_PAD_SHAPE*, PCB_PAD_SHAPES_ARRAY ); WX_DEFINE_ARRAY( PCB_PAD_SHAPE*, PCB_PAD_SHAPES_ARRAY );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -112,7 +112,7 @@ void PCB_VIA::Parse( XNODE* aNode,
lNode = FindNode( tNode, wxT( "holeDiam" ) ); lNode = FindNode( tNode, wxT( "holeDiam" ) );
if( lNode ) if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_hole, SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Hole,
aActualConversion ); aActualConversion );
lNode = FindNode( tNode, wxT( "viaShape" ) ); lNode = FindNode( tNode, wxT( "viaShape" ) );
@ -127,7 +127,7 @@ void PCB_VIA::Parse( XNODE* aNode,
{ {
viaShape = new PCB_VIA_SHAPE( m_callbacks, m_board ); viaShape = new PCB_VIA_SHAPE( m_callbacks, m_board );
viaShape->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ); viaShape->Parse( lNode, aDefaultMeasurementUnit, aActualConversion );
m_shapes.Add( viaShape ); m_Shapes.Add( viaShape );
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -40,12 +40,10 @@ namespace PCAD2KICAD {
class PCB_VIA : public PCB_PAD class PCB_VIA : public PCB_PAD
{ {
public: public:
PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ); PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_VIA(); ~PCB_VIA();
virtual void Parse( XNODE* aNode, virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) override; const wxString& aActualConversion ) override;
}; };

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -59,7 +59,7 @@ void PCB_VIA_SHAPE::Parse( XNODE* aNode,
{ {
str = lNode->GetNodeContent(); str = lNode->GetNodeContent();
str.Trim( false ); str.Trim( false );
m_shape = str; m_Shape = str;
} }
lNode = FindNode( aNode, wxT( "layerNumRef" ) ); lNode = FindNode( aNode, wxT( "layerNumRef" ) );
@ -74,12 +74,12 @@ void PCB_VIA_SHAPE::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "shapeWidth" ) ); lNode = FindNode( aNode, wxT( "shapeWidth" ) );
if( lNode ) if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion ); SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Width, aActualConversion );
lNode = FindNode( aNode, wxT( "shapeHeight" ) ); lNode = FindNode( aNode, wxT( "shapeHeight" ) );
if( lNode ) if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_height, aActualConversion ); SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Height, aActualConversion );
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -42,8 +42,7 @@ public:
PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ); PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_VIA_SHAPE(); ~PCB_VIA_SHAPE();
virtual void Parse( XNODE* aNode, virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) override; const wxString& aActualConversion ) override;
}; };

View File

@ -78,9 +78,9 @@ void SPECCTRA_DB::buildLayerMaps( BOARD* aBoard )
// Same as KiCad now except for B_Cu // Same as KiCad now except for B_Cu
unsigned layerCount = aBoard->GetCopperLayerCount(); unsigned layerCount = aBoard->GetCopperLayerCount();
layerIds.clear(); m_layerIds.clear();
pcbLayer2kicad.resize( layerCount ); m_pcbLayer2kicad.resize( layerCount );
kicadLayer2pcb.resize( B_Cu + 1 ); m_kicadLayer2pcb.resize( B_Cu + 1 );
#if 0 // was: #if 0 // was:
for( LAYER_NUM kiNdx = layerCount - 1, pcbNdx=FIRST_LAYER; for( LAYER_NUM kiNdx = layerCount - 1, pcbNdx=FIRST_LAYER;
@ -99,22 +99,22 @@ void SPECCTRA_DB::buildLayerMaps( BOARD* aBoard )
// establish bi-directional mapping between KiCad's BOARD layer and PCB layer // establish bi-directional mapping between KiCad's BOARD layer and PCB layer
for( unsigned i = 0; i < kicadLayer2pcb.size(); ++i ) for( unsigned i = 0; i < m_kicadLayer2pcb.size(); ++i )
{ {
if( i < layerCount-1 ) if( i < layerCount-1 )
kicadLayer2pcb[i] = i; m_kicadLayer2pcb[i] = i;
else else
kicadLayer2pcb[i] = layerCount - 1; m_kicadLayer2pcb[i] = layerCount - 1;
} }
for( unsigned i = 0; i < pcbLayer2kicad.size(); ++i ) for( unsigned i = 0; i < m_pcbLayer2kicad.size(); ++i )
{ {
PCB_LAYER_ID id = ( i < layerCount-1 ) ? ToLAYER_ID( i ) : B_Cu; PCB_LAYER_ID id = ( i < layerCount-1 ) ? ToLAYER_ID( i ) : B_Cu;
pcbLayer2kicad[i] = id; m_pcbLayer2kicad[i] = id;
// save the specctra layer name in SPECCTRA_DB::layerIds for later. // save the specctra layer name in SPECCTRA_DB::layerIds for later.
layerIds.push_back( TO_UTF8( aBoard->GetLayerName( id ) ) ); m_layerIds.push_back(TO_UTF8( aBoard->GetLayerName( id ) ) );
} }
#endif #endif
@ -123,9 +123,9 @@ void SPECCTRA_DB::buildLayerMaps( BOARD* aBoard )
int SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const int SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const
{ {
for( int i=0; i < int(layerIds.size()); ++i ) for( int i=0; i < int( m_layerIds.size()); ++i )
{ {
if( 0 == aLayerName.compare( layerIds[i] ) ) if( 0 == aLayerName.compare( m_layerIds[i] ) )
return i; return i;
} }
return -1; return -1;
@ -254,7 +254,7 @@ void SPECCTRA_DB::LoadPCB( const wxString& aFilename )
SetPCB( new PCB() ); SetPCB( new PCB() );
doPCB( pcb ); doPCB( m_pcb );
PopReader(); PopReader();
} }
@ -273,7 +273,7 @@ void SPECCTRA_DB::LoadSESSION( const wxString& aFilename )
SetSESSION( new SESSION() ); SetSESSION( new SESSION() );
doSESSION( session ); doSESSION( m_session );
PopReader(); PopReader();
} }
@ -420,7 +420,7 @@ void SPECCTRA_DB::doPARSER( PARSER* growth )
Expecting( T_QUOTE_DEF ); Expecting( T_QUOTE_DEF );
SetStringDelimiter( (unsigned char) *CurText() ); SetStringDelimiter( (unsigned char) *CurText() );
growth->string_quote = *CurText(); growth->string_quote = *CurText();
quote_char = CurText(); m_quote_char = CurText();
NeedRIGHT(); NeedRIGHT();
break; break;
@ -1400,12 +1400,12 @@ void SPECCTRA_DB::doRULE( RULE* growth )
builder += ' '; builder += ' ';
if( tok==T_STRING ) if( tok==T_STRING )
builder += quote_char; builder += m_quote_char;
builder += CurText(); builder += CurText();
if( tok==T_STRING ) if( tok==T_STRING )
builder += quote_char; builder += m_quote_char;
} }
// When the nested rule is closed with a T_RIGHT and we are back down // When the nested rule is closed with a T_RIGHT and we are back down
@ -2576,12 +2576,12 @@ void SPECCTRA_DB::doCLASS( CLASS* growth )
builder += ' '; builder += ' ';
if( tok==T_STRING ) if( tok==T_STRING )
builder += quote_char; builder += m_quote_char;
builder += CurText(); builder += CurText();
if( tok==T_STRING ) if( tok==T_STRING )
builder += quote_char; builder += m_quote_char;
} }
// When the nested rule is closed with a T_RIGHT and we are back down // When the nested rule is closed with a T_RIGHT and we are back down
@ -3441,25 +3441,25 @@ void SPECCTRA_DB::doSUPPLY_PIN( SUPPLY_PIN* growth )
void SPECCTRA_DB::ExportPCB( const wxString& aFilename, bool aNameChange ) void SPECCTRA_DB::ExportPCB( const wxString& aFilename, bool aNameChange )
{ {
if( pcb ) if( m_pcb )
{ {
FILE_OUTPUTFORMATTER formatter( aFilename, wxT( "wt" ), quote_char[0] ); FILE_OUTPUTFORMATTER formatter( aFilename, wxT( "wt" ), m_quote_char[0] );
if( aNameChange ) if( aNameChange )
pcb->pcbname = TO_UTF8( aFilename ); m_pcb->pcbname = TO_UTF8( aFilename );
pcb->Format( &formatter, 0 ); m_pcb->Format( &formatter, 0 );
} }
} }
void SPECCTRA_DB::ExportSESSION( const wxString& aFilename ) void SPECCTRA_DB::ExportSESSION( const wxString& aFilename )
{ {
if( session ) if( m_session )
{ {
FILE_OUTPUTFORMATTER formatter( aFilename, wxT( "wt" ), quote_char[0] ); FILE_OUTPUTFORMATTER formatter( aFilename, wxT( "wt" ), m_quote_char[0] );
session->Format( &formatter, 0 ); m_session->Format( &formatter, 0 );
} }
} }

View File

@ -3600,49 +3600,43 @@ typedef boost::ptr_set<PADSTACK> PADSTACKSET;
/** /**
* SPECCTRA_DB * SPECCTRA_DB
* holds a DSN data tree, usually coming from a DSN file. Is essentially a * holds a DSN data tree, usually coming from a DSN file. Is essentially a SPECCTRA_PARSER class.
* SPECCTRA_PARSER class.
*/ */
class SPECCTRA_DB : public SPECCTRA_LEXER class SPECCTRA_DB : public SPECCTRA_LEXER
{ {
/// specctra DSN keywords /// specctra DSN keywords
static const KEYWORD keywords[]; static const KEYWORD keywords[];
static const unsigned keywordCount;
PCB* pcb; PCB* m_pcb;
SESSION* session; SESSION* m_session;
wxString filename; wxString m_filename;
std::string quote_char; std::string m_quote_char;
bool modulesAreFlipped; bool m_footprintsAreFlipped;
STRING_FORMATTER sf; STRING_FORMATTER m_sf;
STRINGS layerIds; ///< indexed by PCB layer number STRINGS m_layerIds; ///< indexed by PCB layer number
/// maps BOARD layer number to PCB layer numbers std::vector<int> m_kicadLayer2pcb; ///< maps BOARD layer number to PCB layer numbers
std::vector<int> kicadLayer2pcb; std::vector<PCB_LAYER_ID> m_pcbLayer2kicad; ///< maps PCB layer number to BOARD layer numbers
/// maps PCB layer number to BOARD layer numbers
std::vector<PCB_LAYER_ID> pcbLayer2kicad;
/// used during FromSESSION() only, memory for it is not owned here. /// used during FromSESSION() only, memory for it is not owned here.
UNIT_RES* routeResolution; UNIT_RES* m_routeResolution;
/// a copy to avoid passing as an argument, memory for it is not owned here. /// a copy to avoid passing as an argument, memory for it is not owned here.
BOARD* sessionBoard; BOARD* m_sessionBoard;
static const KICAD_T scanPADs[]; static const KICAD_T scanPADs[];
PADSTACKSET padstackset; PADSTACKSET m_padstackset;
/// we don't want ownership here permanently, so we don't use boost::ptr_vector /// we don't want ownership here permanently, so we don't use boost::ptr_vector
std::vector<NET*> nets; std::vector<NET*> m_nets;
/// specctra cu layers, 0 based index: /// specctra cu layers, 0 based index:
int m_top_via_layer; int m_top_via_layer;
int m_bot_via_layer; int m_bot_via_layer;
/** /**
* Function buildLayerMaps * Function buildLayerMaps
@ -3808,10 +3802,10 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
*/ */
void deleteNETs() void deleteNETs()
{ {
for( unsigned n=0; n<nets.size(); ++n ) for( unsigned n=0; n < m_nets.size(); ++n )
delete nets[n]; delete m_nets[n];
nets.clear(); m_nets.clear();
} }
/** /**
@ -3848,24 +3842,24 @@ public:
// we don't own it: // we don't own it:
wxASSERT( !iOwnReaders ); wxASSERT( !iOwnReaders );
pcb = 0; m_pcb = 0;
session = 0; m_session = 0;
quote_char += '"'; m_quote_char += '"';
modulesAreFlipped = false; m_footprintsAreFlipped = false;
SetSpecctraMode( true ); SetSpecctraMode( true );
// Avoid not initialized members: // Avoid not initialized members:
routeResolution = NULL; m_routeResolution = NULL;
sessionBoard = NULL; m_sessionBoard = NULL;
m_top_via_layer = 0; m_top_via_layer = 0;
m_bot_via_layer = 0; m_bot_via_layer = 0;
} }
virtual ~SPECCTRA_DB() virtual ~SPECCTRA_DB()
{ {
delete pcb; delete m_pcb;
delete session; delete m_session;
deleteNETs(); deleteNETs();
} }
@ -3882,10 +3876,10 @@ public:
*/ */
void SetPCB( PCB* aPcb ) void SetPCB( PCB* aPcb )
{ {
delete pcb; delete m_pcb;
pcb = aPcb; m_pcb = aPcb;
} }
PCB* GetPCB() { return pcb; } PCB* GetPCB() { return m_pcb; }
/** /**
* Function SetSESSION * Function SetSESSION
@ -3893,10 +3887,10 @@ public:
*/ */
void SetSESSION( SESSION* aSession ) void SetSESSION( SESSION* aSession )
{ {
delete session; delete m_session;
session = aSession; m_session = aSession;
} }
SESSION* GetSESSION() { return session; } SESSION* GetSESSION() { return m_session; }
/** /**
* Function LoadPCB * Function LoadPCB
@ -3935,7 +3929,7 @@ public:
/** /**
* Function FromBOARD * Function FromBOARD
* adds the entire BOARD to the PCB but does not write it out. Note that the BOARD given * adds the entire BOARD to the PCB but does not write it out. Note that the BOARD given
* to this function must have all the MODULEs on the component side of the BOARD. * to this function must have all the FOOTPRINTs on the component side of the BOARD.
* *
* See PCB_EDIT_FRAME::ExportToSpecctra() for an example before calling this function. * See PCB_EDIT_FRAME::ExportToSpecctra() for an example before calling this function.
* *
@ -3962,16 +3956,16 @@ public:
void ExportSESSION( const wxString& aFilename ); void ExportSESSION( const wxString& aFilename );
/** /**
* Function FlipMODULEs * Function FlipFOOTPRINTs
* flips the footprints which are on the back side of the board to the front. * flips the footprints which are on the back side of the board to the front.
*/ */
void FlipMODULEs( BOARD* aBoard ); void FlipFOOTPRINTs( BOARD* aBoard );
/** /**
* Function RevertMODULEs * Function RevertFOOTPRINTs
* flips the footprints which were on the back side of the board back to the back. * flips the footprints which were on the back side of the board back to the back.
*/ */
void RevertMODULEs( BOARD* aBoard ); void RevertFOOTPRINTs( BOARD* aBoard );
}; };

View File

@ -95,7 +95,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
// DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the top view. So we // DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the top view. So we
// temporarily flip any footprints which are on the back side of the board to the front, // temporarily flip any footprints which are on the back side of the board to the front,
// and record this in the FOOTPRINT's flag field. // and record this in the FOOTPRINT's flag field.
db.FlipMODULEs( GetBoard() ); db.FlipFOOTPRINTs( GetBoard());
try try
{ {
@ -115,7 +115,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
} }
// done assuredly, even if an exception was thrown and caught. // done assuredly, even if an exception was thrown and caught.
db.RevertMODULEs( GetBoard() ); db.RevertFOOTPRINTs( GetBoard());
// The two calls below to FOOTPRINT::Flip(), both set the // The two calls below to FOOTPRINT::Flip(), both set the
// modified flag, yet their actions cancel each other out, so it should // modified flag, yet their actions cancel each other out, so it should
@ -255,11 +255,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
for( int layer=0; layer<copperCount; ++layer ) for( int layer=0; layer<copperCount; ++layer )
{ {
PCB_LAYER_ID kilayer = pcbLayer2kicad[layer]; PCB_LAYER_ID kilayer = m_pcbLayer2kicad[layer];
if( onAllCopperLayers || aPad->IsOnLayer( kilayer ) ) if( onAllCopperLayers || aPad->IsOnLayer( kilayer ) )
{ {
layerName[reportedLayers++] = layerIds[layer].c_str(); layerName[reportedLayers++] = m_layerIds[layer].c_str();
if( !onAllCopperLayers ) if( !onAllCopperLayers )
{ {
@ -632,7 +632,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
circle->SetDiameter( diameter ); circle->SetDiameter( diameter );
circle->SetVertex( vertex ); circle->SetVertex( vertex );
circle->SetLayerId( layerIds[layer].c_str() ); circle->SetLayerId( m_layerIds[layer].c_str() );
} }
} }
// else if() could there be a square keepout here? // else if() could there be a square keepout here?
@ -647,9 +647,9 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
continue; continue;
PADSTACK* padstack = makePADSTACK( aBoard, pad ); PADSTACK* padstack = makePADSTACK( aBoard, pad );
PADSTACKSET::iterator iter = padstackset.find( *padstack ); PADSTACKSET::iterator iter = m_padstackset.find( *padstack );
if( iter != padstackset.end() ) if( iter != m_padstackset.end() )
{ {
// padstack is a duplicate, delete it and use the original // padstack is a duplicate, delete it and use the original
delete padstack; delete padstack;
@ -657,7 +657,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
} }
else else
{ {
padstackset.insert( padstack ); m_padstackset.insert( padstack );
} }
PIN* pin = new PIN( image ); PIN* pin = new PIN( image );
@ -796,7 +796,7 @@ PADSTACK* SPECCTRA_DB::makeVia( int aCopperDiameter, int aDrillDiameter,
shape->SetShape( circle ); shape->SetShape( circle );
circle->SetDiameter( dsnDiameter ); circle->SetDiameter( dsnDiameter );
circle->SetLayerId( layerIds[layer].c_str() ); circle->SetLayerId( m_layerIds[layer].c_str() );
} }
snprintf( name, sizeof(name), "Via[%d-%d]_%.6g:%.6g_um", snprintf( name, sizeof(name), "Via[%d-%d]_%.6g:%.6g_um",
@ -819,8 +819,8 @@ PADSTACK* SPECCTRA_DB::makeVia( const ::VIA* aVia )
aVia->LayerPair( &topLayerNum, &botLayerNum ); aVia->LayerPair( &topLayerNum, &botLayerNum );
int topLayer = kicadLayer2pcb[topLayerNum]; int topLayer = m_kicadLayer2pcb[topLayerNum];
int botLayer = kicadLayer2pcb[botLayerNum]; int botLayer = m_kicadLayer2pcb[botLayerNum];
if( topLayer > botLayer ) if( topLayer > botLayer )
std::swap( topLayer, botLayer ); std::swap( topLayer, botLayer );
@ -863,7 +863,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
keepout->SetShape( poly_ko ); keepout->SetShape( poly_ko );
poly_ko->SetLayerId( "signal" ); poly_ko->SetLayerId( "signal" );
pcb->structure->keepouts.push_back( keepout ); m_pcb->structure->keepouts.push_back( keepout );
SHAPE_LINE_CHAIN& hole = outlines.Hole( cnt, ii ); SHAPE_LINE_CHAIN& hole = outlines.Hole( cnt, ii );
@ -925,8 +925,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
} }
} }
if( !pcb ) if( !m_pcb )
pcb = SPECCTRA_DB::MakePCB(); m_pcb = SPECCTRA_DB::MakePCB();
//-----<layer_descriptor>----------------------------------------------- //-----<layer_descriptor>-----------------------------------------------
{ {
@ -940,15 +940,15 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
for( int pcbNdx=0; pcbNdx<layerCount; ++pcbNdx ) for( int pcbNdx=0; pcbNdx<layerCount; ++pcbNdx )
{ {
LAYER* layer = new LAYER( pcb->structure ); LAYER* layer = new LAYER( m_pcb->structure );
pcb->structure->layers.push_back( layer ); m_pcb->structure->layers.push_back( layer );
layer->name = layerIds[pcbNdx]; layer->name = m_layerIds[pcbNdx];
DSN_T layerType; DSN_T layerType;
switch( aBoard->GetLayerType( pcbLayer2kicad[pcbNdx] ) ) switch( aBoard->GetLayerType( m_pcbLayer2kicad[pcbNdx] ) )
{ {
default: default:
case LT_SIGNAL: layerType = T_signal; break; case LT_SIGNAL: layerType = T_signal; break;
@ -975,7 +975,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
} }
// a space in a quoted token is NOT a terminator, true establishes this. // a space in a quoted token is NOT a terminator, true establishes this.
pcb->parser->space_in_quoted_tokens = true; m_pcb->parser->space_in_quoted_tokens = true;
//-----<unit_descriptor> & <resolution_descriptor>-------------------- //-----<unit_descriptor> & <resolution_descriptor>--------------------
{ {
@ -983,9 +983,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// which is 100 nm resolution. Possibly more resolution is possible // which is 100 nm resolution. Possibly more resolution is possible
// in freerouter, but it would need testing. // in freerouter, but it would need testing.
pcb->unit->units = T_um; m_pcb->unit->units = T_um;
pcb->resolution->units = T_um; m_pcb->resolution->units = T_um;
pcb->resolution->value = 10; // tenths of a um m_pcb->resolution->value = 10; // tenths of a um
// pcb->resolution->value = 1000; // "thousandths of a um" (i.e. "nm") // pcb->resolution->value = 1000; // "thousandths of a um" (i.e. "nm")
} }
@ -996,7 +996,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// of an exception. // of an exception.
BOUNDARY* boundary = new BOUNDARY( 0 ); BOUNDARY* boundary = new BOUNDARY( 0 );
pcb->structure->SetBOUNDARY( boundary ); m_pcb->structure->SetBOUNDARY( boundary );
fillBOUNDARY( aBoard, boundary ); fillBOUNDARY( aBoard, boundary );
} }
@ -1011,7 +1011,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
double clearance = scale( defaultClearance ); double clearance = scale( defaultClearance );
STRINGS& rules = pcb->structure->rules->rules; STRINGS& rules = m_pcb->structure->rules->rules;
sprintf( rule, "(width %.6g)", scale( defaultTrackWidth ) ); sprintf( rule, "(width %.6g)", scale( defaultTrackWidth ) );
rules.push_back( rule ); rules.push_back( rule );
@ -1088,9 +1088,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
if( ! IsCopperLayer( item->GetLayer() ) ) if( ! IsCopperLayer( item->GetLayer() ) )
continue; continue;
COPPER_PLANE* plane = new COPPER_PLANE( pcb->structure ); COPPER_PLANE* plane = new COPPER_PLANE( m_pcb->structure );
pcb->structure->planes.push_back( plane ); m_pcb->structure->planes.push_back( plane );
PATH* mainPolygon = new PATH( plane, T_polygon ); PATH* mainPolygon = new PATH( plane, T_polygon );
@ -1104,19 +1104,19 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// This is one of those no connection zones, netcode=0, and it has no name. // This is one of those no connection zones, netcode=0, and it has no name.
// Create a unique, bogus netname. // Create a unique, bogus netname.
NET* no_net = new NET( pcb->network ); NET* no_net = new NET( m_pcb->network );
sprintf( name, "@:no_net_%d", netlessZones++ ); sprintf( name, "@:no_net_%d", netlessZones++ );
no_net->net_id = name; no_net->net_id = name;
// add the bogus net name to network->nets. // add the bogus net name to network->nets.
pcb->network->nets.push_back( no_net ); m_pcb->network->nets.push_back( no_net );
// use the bogus net name in the netless zone. // use the bogus net name in the netless zone.
plane->name = no_net->net_id; plane->name = no_net->net_id;
} }
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ]; mainPolygon->layer_id = m_layerIds[ m_kicadLayer2pcb[ item->GetLayer() ] ];
// Handle the main outlines // Handle the main outlines
SHAPE_POLY_SET::ITERATOR iterator; SHAPE_POLY_SET::ITERATOR iterator;
@ -1163,7 +1163,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
window->SetShape( cutout ); window->SetShape( cutout );
cutout->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ]; cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ item->GetLayer() ] ];
} }
// If the point in this iteration is the last of the contour, the next iteration // If the point in this iteration is the last of the contour, the next iteration
@ -1229,13 +1229,13 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
if( !item->IsOnLayer( PCB_LAYER_ID( layer ) ) ) if( !item->IsOnLayer( PCB_LAYER_ID( layer ) ) )
continue; continue;
KEEPOUT* keepout = new KEEPOUT( pcb->structure, keepout_type ); KEEPOUT* keepout = new KEEPOUT( m_pcb->structure, keepout_type );
pcb->structure->keepouts.push_back( keepout ); m_pcb->structure->keepouts.push_back( keepout );
PATH* mainPolygon = new PATH( keepout, T_polygon ); PATH* mainPolygon = new PATH( keepout, T_polygon );
keepout->SetShape( mainPolygon ); keepout->SetShape( mainPolygon );
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ layer ] ]; mainPolygon->layer_id = m_layerIds[ m_kicadLayer2pcb[ layer ] ];
// Handle the main outlines // Handle the main outlines
SHAPE_POLY_SET::ITERATOR iterator; SHAPE_POLY_SET::ITERATOR iterator;
@ -1280,7 +1280,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
window->SetShape( cutout ); window->SetShape( cutout );
cutout->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ]; cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ item->GetLayer() ] ];
} }
isStartContour = iterator.IsEndContour(); isStartContour = iterator.IsEndContour();
@ -1308,7 +1308,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
//-----<build the images, components, and netlist>----------------------- //-----<build the images, components, and netlist>-----------------------
{ {
PIN_REF empty( pcb->network ); PIN_REF empty( m_pcb->network );
std::string componentId; std::string componentId;
@ -1318,10 +1318,10 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
deleteNETs(); deleteNETs();
// expand the net vector to highestNetCode+1, setting empty to NULL // expand the net vector to highestNetCode+1, setting empty to NULL
nets.resize( highestNetCode + 1, NULL ); m_nets.resize( highestNetCode + 1, NULL );
for( unsigned i = 1 /* skip "No Net" at [0] */; i < nets.size(); ++i ) for( unsigned i = 1 /* skip "No Net" at [0] */; i < m_nets.size(); ++i )
nets[i] = new NET( pcb->network ); m_nets[i] = new NET( m_pcb->network );
for( unsigned ii = 0; ii < aBoard->GetNetCount(); ii++ ) for( unsigned ii = 0; ii < aBoard->GetNetCount(); ii++ )
{ {
@ -1329,12 +1329,12 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
int netcode = net->GetNet(); int netcode = net->GetNet();
if( netcode > 0 ) if( netcode > 0 )
nets[ netcode ]->net_id = TO_UTF8( net->GetNetname() ); m_nets[ netcode ]->net_id = TO_UTF8( net->GetNetname() );
} }
items.Collect( aBoard, scanMODULEs ); items.Collect( aBoard, scanMODULEs );
padstackset.clear(); m_padstackset.clear();
for( int m = 0; m<items.GetCount(); ++m ) for( int m = 0; m<items.GetCount(); ++m )
{ {
@ -1360,7 +1360,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
if( netcode > 0 ) if( netcode > 0 )
{ {
NET* net = nets[netcode]; NET* net = m_nets[netcode];
net->pins.push_back( empty ); net->pins.push_back( empty );
@ -1372,7 +1372,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
} }
IMAGE* registered = pcb->library->LookupIMAGE( image ); IMAGE* registered = m_pcb->library->LookupIMAGE( image );
if( registered != image ) if( registered != image )
{ {
@ -1382,7 +1382,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
image = registered; image = registered;
} }
COMPONENT* comp = pcb->placement->LookupCOMPONENT( image->GetImageId() ); COMPONENT* comp = m_pcb->placement->LookupCOMPONENT( image->GetImageId() );
PLACE* place = new PLACE( comp ); PLACE* place = new PLACE( comp );
@ -1406,25 +1406,25 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// copy the SPECCTRA_DB::padstackset to the LIBRARY. Since we are // copy the SPECCTRA_DB::padstackset to the LIBRARY. Since we are
// removing, do not increment the iterator // removing, do not increment the iterator
for( PADSTACKSET::iterator i = padstackset.begin(); i!=padstackset.end(); for( PADSTACKSET::iterator i = m_padstackset.begin(); i != m_padstackset.end();
i = padstackset.begin() ) i = m_padstackset.begin() )
{ {
PADSTACKSET::auto_type ps = padstackset.release( i ); PADSTACKSET::auto_type ps = m_padstackset.release( i );
PADSTACK* padstack = ps.release(); PADSTACK* padstack = ps.release();
pcb->library->AddPadstack( padstack ); m_pcb->library->AddPadstack( padstack );
} }
// copy our SPECCTRA_DB::nets to the pcb->network // copy our SPECCTRA_DB::nets to the pcb->network
for( unsigned n = 1; n<nets.size(); ++n ) for( unsigned n = 1; n < m_nets.size(); ++n )
{ {
NET* net = nets[n]; NET* net = m_nets[n];
if( net->pins.size() ) if( net->pins.size() )
{ {
// give ownership to pcb->network // give ownership to pcb->network
pcb->network->nets.push_back( net ); m_pcb->network->nets.push_back( net );
nets[n] = 0; m_nets[n] = 0;
} }
} }
} }
@ -1464,8 +1464,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// we AppendVia() this first one, there is no way it can be a duplicate, // we AppendVia() this first one, there is no way it can be a duplicate,
// the pcb->library via container is empty at this point. After this, // the pcb->library via container is empty at this point. After this,
// we'll have to use LookupVia(). // we'll have to use LookupVia().
wxASSERT( pcb->library->vias.size() == 0 ); wxASSERT( m_pcb->library->vias.size() == 0 );
pcb->library->AppendVia( via ); m_pcb->library->AppendVia( via );
#if 0 #if 0
// I've seen no way to make stock vias useable by freerouter. Also the // I've seen no way to make stock vias useable by freerouter. Also the
@ -1502,7 +1502,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
m_top_via_layer, m_bot_via_layer ); m_top_via_layer, m_bot_via_layer );
// maybe add 'via' to the library, but only if unique. // maybe add 'via' to the library, but only if unique.
PADSTACK* registered = pcb->library->LookupVia( via ); PADSTACK* registered = m_pcb->library->LookupVia( via );
if( registered != via ) if( registered != via )
delete via; delete via;
@ -1521,7 +1521,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
items.Collect( aBoard, scanTRACKs ); items.Collect( aBoard, scanTRACKs );
std::string netname; std::string netname;
WIRING* wiring = pcb->wiring; WIRING* wiring = m_pcb->wiring;
PATH* path = 0; PATH* path = 0;
int old_netcode = -1; int old_netcode = -1;
@ -1562,13 +1562,13 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
wire->wire_type = T_protect; // @todo, this should be configurable wire->wire_type = T_protect; // @todo, this should be configurable
LAYER_NUM kiLayer = track->GetLayer(); LAYER_NUM kiLayer = track->GetLayer();
int pcbLayer = kicadLayer2pcb[kiLayer]; int pcbLayer = m_kicadLayer2pcb[kiLayer];
path = new PATH( wire ); path = new PATH( wire );
wire->SetShape( path ); wire->SetShape( path );
path->layer_id = layerIds[pcbLayer]; path->layer_id = m_layerIds[pcbLayer];
path->aperture_width = scale( old_width ); path->aperture_width = scale( old_width );
path->AppendPoint( mapPt( track->GetStart() ) ); path->AppendPoint( mapPt( track->GetStart() ) );
@ -1598,7 +1598,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
continue; continue;
PADSTACK* padstack = makeVia( via ); PADSTACK* padstack = makeVia( via );
PADSTACK* registered = pcb->library->LookupVia( padstack ); PADSTACK* registered = m_pcb->library->LookupVia( padstack );
// if the one looked up is not our padstack, then delete our padstack // if the one looked up is not our padstack, then delete our padstack
// since it was a duplicate of one already registered. // since it was a duplicate of one already registered.
@ -1607,9 +1607,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
delete padstack; delete padstack;
} }
WIRE_VIA* dsnVia = new WIRE_VIA( pcb->wiring ); WIRE_VIA* dsnVia = new WIRE_VIA( m_pcb->wiring );
pcb->wiring->wire_vias.push_back( dsnVia ); m_pcb->wiring->wire_vias.push_back( dsnVia );
dsnVia->padstack_id = registered->padstack_id; dsnVia->padstack_id = registered->padstack_id;
dsnVia->vertexes.push_back( mapPt( via->GetPosition() ) ); dsnVia->vertexes.push_back( mapPt( via->GetPosition() ) );
@ -1633,11 +1633,11 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// Output the vias in the padstack list here, by name only. This must // Output the vias in the padstack list here, by name only. This must
// be done after exporting existing vias as WIRE_VIAs. // be done after exporting existing vias as WIRE_VIAs.
VIA* vias = pcb->structure->via; VIA* vias = m_pcb->structure->via;
for( unsigned viaNdx = 0; viaNdx < pcb->library->vias.size(); ++viaNdx ) for( unsigned viaNdx = 0; viaNdx < m_pcb->library->vias.size(); ++viaNdx )
{ {
vias->AppendVia( pcb->library->vias[viaNdx].padstack_id.c_str() ); vias->AppendVia( m_pcb->library->vias[viaNdx].padstack_id.c_str() );
} }
} }
@ -1687,9 +1687,9 @@ void SPECCTRA_DB::exportNETCLASS( const NETCLASSPTR& aNetClass, BOARD* aBoard )
char text[256]; char text[256];
CLASS* clazz = new CLASS( pcb->network ); CLASS* clazz = new CLASS( m_pcb->network );
pcb->network->classes.push_back( clazz ); m_pcb->network->classes.push_back( clazz );
// freerouter creates a class named 'default' anyway, and if we // freerouter creates a class named 'default' anyway, and if we
// try and use that, we end up with two 'default' via rules so use // try and use that, we end up with two 'default' via rules so use
@ -1731,7 +1731,7 @@ void SPECCTRA_DB::exportNETCLASS( const NETCLASSPTR& aNetClass, BOARD* aBoard )
} }
void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard ) void SPECCTRA_DB::FlipFOOTPRINTs( BOARD* aBoard )
{ {
// DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the // DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the
// top view. // top view.
@ -1747,28 +1747,28 @@ void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard )
} }
} }
modulesAreFlipped = true; m_footprintsAreFlipped = true;
} }
void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard ) void SPECCTRA_DB::RevertFOOTPRINTs( BOARD* aBoard )
{ {
if( !modulesAreFlipped ) if( !m_footprintsAreFlipped )
return; return;
// DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the // DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the
// top view. Restore those that were flipped. // top view. Restore those that were flipped.
// Note: to export footprints, the footprints were flipped around the X axis, // Note: to export footprints, the footprints were flipped around the X axis,
for( auto module : aBoard->Footprints() ) for( FOOTPRINT* footprint : aBoard->Footprints() )
{ {
if( module->GetFlag() ) if( footprint->GetFlag() )
{ {
module->Flip( module->GetPosition(), false ); footprint->Flip( footprint->GetPosition(), false );
module->SetFlag( 0 ); footprint->SetFlag( 0 );
} }
} }
modulesAreFlipped = false; m_footprintsAreFlipped = false;
} }
} // namespace DSN } // namespace DSN

View File

@ -167,12 +167,12 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
wxString::Format( _( "Session file uses invalid layer id \"%s\"" ), layerName ) ); wxString::Format( _( "Session file uses invalid layer id \"%s\"" ), layerName ) );
} }
TRACK* track = new TRACK( sessionBoard ); TRACK* track = new TRACK( m_sessionBoard );
track->SetStart( mapPt( aPath->points[aPointIndex+0], routeResolution ) ); track->SetStart( mapPt( aPath->points[aPointIndex+0], m_routeResolution ) );
track->SetEnd( mapPt( aPath->points[aPointIndex+1], routeResolution ) ); track->SetEnd( mapPt( aPath->points[aPointIndex+1], m_routeResolution ) );
track->SetLayer( pcbLayer2kicad[layerNdx] ); track->SetLayer( m_pcbLayer2kicad[layerNdx] );
track->SetWidth( scale( aPath->aperture_width, routeResolution ) ); track->SetWidth( scale( aPath->aperture_width, m_routeResolution ) );
track->SetNetCode( aNetcode ); track->SetNetCode( aNetcode );
return track; return track;
@ -187,7 +187,7 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
int shapeCount = aPadstack->Length(); int shapeCount = aPadstack->Length();
int drill_diam_iu = -1; int drill_diam_iu = -1;
int copperLayerCount = sessionBoard->GetCopperLayerCount(); int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
// The drill diameter is encoded in the padstack name if Pcbnew did the DSN export. // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
@ -226,10 +226,10 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) ); wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
CIRCLE* circle = (CIRCLE*) shape->shape; CIRCLE* circle = (CIRCLE*) shape->shape;
int viaDiam = scale( circle->diameter, routeResolution ); int viaDiam = scale( circle->diameter, m_routeResolution );
via = new ::VIA( sessionBoard ); via = new ::VIA( m_sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) ); via->SetPosition( mapPt( aPoint, m_routeResolution ) );
via->SetDrill( drill_diam_iu ); via->SetDrill( drill_diam_iu );
via->SetViaType( VIATYPE::THROUGH ); via->SetViaType( VIATYPE::THROUGH );
via->SetWidth( viaDiam ); via->SetWidth( viaDiam );
@ -244,10 +244,10 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) ); wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
CIRCLE* circle = (CIRCLE*) shape->shape; CIRCLE* circle = (CIRCLE*) shape->shape;
int viaDiam = scale( circle->diameter, routeResolution ); int viaDiam = scale( circle->diameter, m_routeResolution );
via = new ::VIA( sessionBoard ); via = new ::VIA( m_sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) ); via->SetPosition( mapPt( aPoint, m_routeResolution ) );
via->SetDrill( drill_diam_iu ); via->SetDrill( drill_diam_iu );
via->SetViaType( VIATYPE::THROUGH ); via->SetViaType( VIATYPE::THROUGH );
via->SetWidth( viaDiam ); via->SetWidth( viaDiam );
@ -285,11 +285,11 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
botLayerNdx = layerNdx; botLayerNdx = layerNdx;
if( viaDiam == -1 ) if( viaDiam == -1 )
viaDiam = scale( circle->diameter, routeResolution ); viaDiam = scale( circle->diameter, m_routeResolution );
} }
via = new ::VIA( sessionBoard ); via = new ::VIA( m_sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) ); via->SetPosition( mapPt( aPoint, m_routeResolution ) );
via->SetDrill( drill_diam_iu ); via->SetDrill( drill_diam_iu );
if( (topLayerNdx==0 && botLayerNdx==1) if( (topLayerNdx==0 && botLayerNdx==1)
@ -300,8 +300,8 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
via->SetWidth( viaDiam ); via->SetWidth( viaDiam );
PCB_LAYER_ID topLayer = pcbLayer2kicad[topLayerNdx]; PCB_LAYER_ID topLayer = m_pcbLayer2kicad[topLayerNdx];
PCB_LAYER_ID botLayer = pcbLayer2kicad[botLayerNdx]; PCB_LAYER_ID botLayer = m_pcbLayer2kicad[botLayerNdx];
via->SetLayerPair( topLayer, botLayer ); via->SetLayerPair( topLayer, botLayer );
} }
@ -318,15 +318,15 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode )
void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
{ {
sessionBoard = aBoard; // not owned here m_sessionBoard = aBoard; // not owned here
if( !session ) if( !m_session )
THROW_IO_ERROR( _("Session file is missing the \"session\" section") ); THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
if( !session->route ) if( !m_session->route )
THROW_IO_ERROR( _("Session file is missing the \"routes\" section") ); THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
if( !session->route->library ) if( !m_session->route->library )
THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") ); THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
// delete all the old tracks and vias // delete all the old tracks and vias
@ -336,12 +336,12 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
buildLayerMaps( aBoard ); buildLayerMaps( aBoard );
if( session->placement ) if( m_session->placement )
{ {
// Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
// each COMPONENT, reposition and re-orient each component and put on // each COMPONENT, reposition and re-orient each component and put on
// correct side of the board. // correct side of the board.
COMPONENTS& components = session->placement->components; COMPONENTS& components = m_session->placement->components;
for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp ) for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
{ {
PLACES& places = comp->places; PLACES& places = comp->places;
@ -401,10 +401,10 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
} }
} }
routeResolution = session->route->GetUnits(); m_routeResolution = m_session->route->GetUnits();
// Walk the NET_OUTs and create tracks and vias anew. // Walk the NET_OUTs and create tracks and vias anew.
NET_OUTS& net_outs = session->route->net_outs; NET_OUTS& net_outs = m_session->route->net_outs;
for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net ) for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
{ {
int netoutCode = 0; int netoutCode = 0;
@ -456,7 +456,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
} }
WIRE_VIAS& wire_vias = net->wire_vias; WIRE_VIAS& wire_vias = net->wire_vias;
LIBRARY& library = *session->route->library; LIBRARY& library = *m_session->route->library;
for( unsigned i=0; i<wire_vias.size(); ++i ) for( unsigned i=0; i<wire_vias.size(); ++i )
{ {
int netCode = 0; int netCode = 0;

View File

@ -150,13 +150,13 @@ public:
/** /**
* Function PlaceImportedGraphics() * Function PlaceImportedGraphics()
* Places a drawing imported from a DXF or SVG file in module editor. * Places a drawing imported from a DXF or SVG file in footprint editor.
*/ */
int PlaceImportedGraphics( const TOOL_EVENT& aEvent ); int PlaceImportedGraphics( const TOOL_EVENT& aEvent );
/** /**
* Function SetAnchor() * Function SetAnchor()
* Places the footprint anchor (only in module editor). * Places the footprint anchor (only in footprint editor).
*/ */
int SetAnchor( const TOOL_EVENT& aEvent ); int SetAnchor( const TOOL_EVENT& aEvent );

View File

@ -85,7 +85,7 @@ void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags,
aCollector.Remove( item ); aCollector.Remove( item );
} }
// case 2: selection contains both the module and its pads - remove the pads // case 2: selection contains both the footprint and its pads - remove the pads
if( !( aFlags & INCLUDE_PADS_AND_FOOTPRINTS ) && fp && aCollector.HasItem( fp ) ) if( !( aFlags & INCLUDE_PADS_AND_FOOTPRINTS ) && fp && aCollector.HasItem( fp ) )
aCollector.Remove( item ); aCollector.Remove( item );
} }
@ -107,7 +107,7 @@ void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags,
aCollector.Append( fp ); aCollector.Append( fp );
} }
// case 2: selection contains both the module and its pads - remove the pads // case 2: selection contains both the footprint and its pads - remove the pads
if( !( aFlags & INCLUDE_PADS_AND_FOOTPRINTS ) && fp && aCollector.HasItem( fp ) ) if( !( aFlags & INCLUDE_PADS_AND_FOOTPRINTS ) && fp && aCollector.HasItem( fp ) )
aCollector.Remove( item ); aCollector.Remove( item );
} }

View File

@ -138,9 +138,8 @@ int FOOTPRINT_EDITOR_TOOLS::NewFootprint( const TOOL_EVENT& aEvent )
canvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); canvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
m_frame->AddFootprintToBoard( newFootprint ); m_frame->AddFootprintToBoard( newFootprint );
// Initialize data relative to nets and netclasses (for a new // Initialize data relative to nets and netclasses (for a new footprint the defaults are
// module the defaults are used) // used). This is mandatory to handle and draw pads.
// This is mandatory to handle and draw pads
board()->BuildListOfNets(); board()->BuildListOfNets();
newFootprint->SetPosition( wxPoint( 0, 0 ) ); newFootprint->SetPosition( wxPoint( 0, 0 ) );
newFootprint->ClearFlags(); newFootprint->ClearFlags();
@ -191,7 +190,7 @@ int FOOTPRINT_EDITOR_TOOLS::CreateFootprint( const TOOL_EVENT& aEvent )
// Creates the new footprint from python script wizard // Creates the new footprint from python script wizard
FOOTPRINT* newFootprint = wizard->GetBuiltFootprint(); FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
if( newFootprint ) // i.e. if create module command is OK if( newFootprint ) // i.e. if create footprint command is OK
{ {
m_frame->Clear_Pcb( false ); m_frame->Clear_Pcb( false );
@ -199,9 +198,8 @@ int FOOTPRINT_EDITOR_TOOLS::CreateFootprint( const TOOL_EVENT& aEvent )
// Add the new object to board // Add the new object to board
m_frame->AddFootprintToBoard( newFootprint ); m_frame->AddFootprintToBoard( newFootprint );
// Initialize data relative to nets and netclasses (for a new // Initialize data relative to nets and netclasses (for a new footprint the defaults
// module the defaults are used) // are used). This is mandatory to handle and draw pads.
// This is mandatory to handle and draw pads
board()->BuildListOfNets(); board()->BuildListOfNets();
newFootprint->SetPosition( wxPoint( 0, 0 ) ); newFootprint->SetPosition( wxPoint( 0, 0 ) );
newFootprint->ClearFlags(); newFootprint->ClearFlags();

View File

@ -49,8 +49,8 @@ public:
/** /**
* Function ExchangeFootprints() * Function ExchangeFootprints()
* *
* Invoke the dialog used to update or exchange the footprints used for * Invoke the dialog used to update or exchange the footprint definitions used for
* modules. The mode depends on the PCB_ACTIONS held by the TOOL_EVENT. * footprints. The mode depends on the PCB_ACTIONS held by the TOOL_EVENT.
*/ */
int ExchangeFootprints( const TOOL_EVENT& aEvent ); int ExchangeFootprints( const TOOL_EVENT& aEvent );

View File

@ -54,7 +54,7 @@ public:
/** /**
* Function PlacePad() * Function PlacePad()
* Places a pad in module editor. * Places a pad in footprint editor.
*/ */
int PlacePad( const TOOL_EVENT& aEvent ); int PlacePad( const TOOL_EVENT& aEvent );
@ -76,7 +76,7 @@ private:
///> Copy pad settings from a pad to the board design settings ///> Copy pad settings from a pad to the board design settings
int copyPadSettings( const TOOL_EVENT& aEvent ); int copyPadSettings( const TOOL_EVENT& aEvent );
///> Push pad settings from a pad to other pads on board or module ///> Push pad settings from a pad to other pads on board or footprint
int pushPadSettings( const TOOL_EVENT& aEvent ); int pushPadSettings( const TOOL_EVENT& aEvent );
PCB_LAYER_ID explodePad( PAD* aPad ); PCB_LAYER_ID explodePad( PAD* aPad );

View File

@ -380,7 +380,7 @@ public:
/// Tool for creating an array of objects /// Tool for creating an array of objects
static TOOL_ACTION createArray; static TOOL_ACTION createArray;
/// Display module edges as outlines /// Display footprint graphics as outlines
static TOOL_ACTION graphicsOutlines; static TOOL_ACTION graphicsOutlines;
/// Display texts as lines /// Display texts as lines
@ -394,7 +394,7 @@ public:
/// Copy the default pad settings to the selected pad /// Copy the default pad settings to the selected pad
static TOOL_ACTION applyPadSettings; static TOOL_ACTION applyPadSettings;
/// Copy the current pad's settings to other pads in the module or on the board /// Copy the current pad's settings to other pads in the footprint or on the board
static TOOL_ACTION pushPadSettings; static TOOL_ACTION pushPadSettings;
// Microwave tools // Microwave tools

View File

@ -96,7 +96,7 @@ public:
/** /**
* Function PlaceModule() * Function PlaceModule()
* Displays a dialog to select a module to be added and allows the user to set its position. * Displays a dialog to select a footprint to be added and allows the user to set its position.
*/ */
int PlaceModule( const TOOL_EVENT& aEvent ); int PlaceModule( const TOOL_EVENT& aEvent );

View File

@ -97,7 +97,7 @@ public:
/** /**
* Function SetIsFootprintEditor() * Function SetIsFootprintEditor()
* *
* Toggles edit module mode. When enabled, one may select parts of footprints individually * Toggles edit footprint mode. When enabled, one may select parts of footprints individually
* (graphics, pads, etc.), so they can be modified. * (graphics, pads, etc.), so they can be modified.
* @param aEnabled decides if the mode should be enabled. * @param aEnabled decides if the mode should be enabled.
*/ */

View File

@ -68,7 +68,7 @@ public:
void setTransitions() override; void setTransitions() override;
/** /**
* Toggles edit module mode. When enabled, one may select parts of footprints individually * Toggles edit footprint mode. When enabled, one may select parts of footprints individually
* (graphics, pads, etc.), so they can be modified. * (graphics, pads, etc.), so they can be modified.
* @param aEnabled decides if the mode should be enabled. * @param aEnabled decides if the mode should be enabled.
*/ */

View File

@ -952,19 +952,19 @@ int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
// Mark existing items, in order to know what are the new items so we can select only // Mark existing items, in order to know what are the new items so we can select only
// the new items after loading // the new items after loading
for( auto track : brd->Tracks() ) for( TRACK* track : brd->Tracks() )
track->SetFlags( SKIP_STRUCT ); track->SetFlags( SKIP_STRUCT );
for( auto module : brd->Footprints() ) for( FOOTPRINT* footprint : brd->Footprints() )
module->SetFlags( SKIP_STRUCT ); footprint->SetFlags( SKIP_STRUCT );
for( auto group : brd->Groups() ) for( PCB_GROUP* group : brd->Groups() )
group->SetFlags( SKIP_STRUCT ); group->SetFlags( SKIP_STRUCT );
for( auto drawing : brd->Drawings() ) for( BOARD_ITEM* drawing : brd->Drawings() )
drawing->SetFlags( SKIP_STRUCT ); drawing->SetFlags( SKIP_STRUCT );
for( auto zone : brd->Zones() ) for( ZONE* zone : brd->Zones() )
zone->SetFlags( SKIP_STRUCT ); zone->SetFlags( SKIP_STRUCT );
std::map<wxString, wxString> oldProperties = brd->GetProperties(); std::map<wxString, wxString> oldProperties = brd->GetProperties();

View File

@ -1212,9 +1212,8 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetPath )
for( PAD* pad : padList ) for( PAD* pad : padList )
selectConnectedTracks( *pad, STOP_NEVER ); selectConnectedTracks( *pad, STOP_NEVER );
// now we need to find all footprints that are connected to each of these nets // now we need to find all footprints that are connected to each of these nets then we need
// then we need to determine if these modules are in the list of footprints // to determine if these footprints are in the list of footprints belonging to this sheet
// belonging to this sheet ( modList )
std::list<int> removeCodeList; std::list<int> removeCodeList;
constexpr KICAD_T padType[] = { PCB_PAD_T, EOT }; constexpr KICAD_T padType[] = { PCB_PAD_T, EOT };
@ -1224,9 +1223,9 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetPath )
{ {
if( mitem->Type() == PCB_PAD_T && !alg::contains( footprintList, mitem->GetParent() ) ) if( mitem->Type() == PCB_PAD_T && !alg::contains( footprintList, mitem->GetParent() ) )
{ {
// if we cannot find the module of the pad in the modList // if we cannot find the footprint of the pad in the footprintList then we can
// then we can assume that that module is not located in the same // assume that that footprint is not located in the same schematic, therefore
// schematic, therefore invalidate this netcode. // invalidate this netcode.
removeCodeList.push_back( netCode ); removeCodeList.push_back( netCode );
break; break;
} }
@ -1612,7 +1611,7 @@ void SELECTION_TOOL::RebuildSelection()
{ {
EDA_ITEM* parent = item->GetParent(); EDA_ITEM* parent = item->GetParent();
// Flags on module children might be set only because the parent is selected. // Flags on footprint children might be set only because the parent is selected.
if( parent && parent->Type() == PCB_FOOTPRINT_T && parent->IsSelected() ) if( parent && parent->Type() == PCB_FOOTPRINT_T && parent->IsSelected() )
return SEARCH_RESULT::CONTINUE; return SEARCH_RESULT::CONTINUE;
@ -1877,7 +1876,7 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn
case PCB_FOOTPRINT_T: case PCB_FOOTPRINT_T:
{ {
// In modedit, we do not want to select the module itself. // In footprint editor, we do not want to select the footprint itself.
if( m_isFootprintEditor ) if( m_isFootprintEditor )
return false; return false;
@ -1908,8 +1907,9 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn
case PCB_FP_TEXT_T: case PCB_FP_TEXT_T:
// Multiple selection is only allowed in modedit mode. In pcbnew, you have to select // Multiple selection is only allowed in modedit mode. In pcbnew, you have to select
// module subparts one by one, rather than with a drag selection. This is so you can // footprint subparts one by one, rather than with a drag selection. This is so you can
// pick up items under an (unlocked) module without also moving the module's sub-parts. // pick up items under an (unlocked) footprint without also moving the footprint's
// sub-parts.
if( !m_isFootprintEditor && !checkVisibilityOnly ) if( !m_isFootprintEditor && !checkVisibilityOnly )
{ {
if( m_multiple && !settings->GetHighContrast() ) if( m_multiple && !settings->GetHighContrast() )
@ -1931,8 +1931,9 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn
case PCB_PAD_T: case PCB_PAD_T:
{ {
// Multiple selection is only allowed in modedit mode. In pcbnew, you have to select // Multiple selection is only allowed in modedit mode. In pcbnew, you have to select
// module subparts one by one, rather than with a drag selection. This is so you can // footprint subparts one by one, rather than with a drag selection. This is so you can
// pick up items under an (unlocked) module without also moving the module's sub-parts. // pick up items under an (unlocked) footprint without also moving the footprint's
// sub-parts.
if( !m_isFootprintEditor && !checkVisibilityOnly ) if( !m_isFootprintEditor && !checkVisibilityOnly )
{ {
if( m_multiple ) if( m_multiple )
@ -1972,8 +1973,8 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn
{ {
PCB_GROUP* group = const_cast<PCB_GROUP*>( static_cast<const PCB_GROUP*>( aItem ) ); PCB_GROUP* group = const_cast<PCB_GROUP*>( static_cast<const PCB_GROUP*>( aItem ) );
// Similar to logic for module, a group is selectable if any of its // Similar to logic for footprint, a group is selectable if any of its members are.
// members are. (This recurses.) // (This recurses.)
for( BOARD_ITEM* item : group->GetItems() ) for( BOARD_ITEM* item : group->GetItems() )
{ {
if( Selectable( item, true ) ) if( Selectable( item, true ) )
@ -2122,7 +2123,7 @@ void SELECTION_TOOL::unhighlightInternal( BOARD_ITEM* aItem, int aMode,
} }
// footprints are treated in a special way - when they are highlighted, we have to // footprints are treated in a special way - when they are highlighted, we have to
// highlight all the parts that make the module, not the module itself // highlight all the parts that make the footprint, not the footprint itself
if( aItem->Type() == PCB_FOOTPRINT_T ) if( aItem->Type() == PCB_FOOTPRINT_T )
{ {
static_cast<FOOTPRINT*>( aItem )->RunOnChildren( static_cast<FOOTPRINT*>( aItem )->RunOnChildren(

View File

@ -39,7 +39,7 @@ set( QA_EESCHEMA_SRCS
uuid_test_utils.cpp uuid_test_utils.cpp
# The main test entry points # The main test entry points
test_module.cpp test_footprint.cpp
# Base internal units (1=100nm) testing. # Base internal units (1=100nm) testing.
test_sch_biu.cpp test_sch_biu.cpp

View File

@ -1,68 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 CERN
* @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* Main file for the Eeschema tests to be compiled
*/
#include <boost/test/unit_test.hpp>
#include <wx/init.h>
#include <unit_test_utils/wx_assert.h>
/*
* Simple function to handle a WX assertion and throw a real exception.
*
* This is useful when you want to check assertions fire in unit tests.
*/
void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
const wxString& aCond, const wxString& aMsg )
{
throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
}
bool init_unit_test()
{
boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";
bool ok = wxInitialize();
wxSetAssertHandler( &wxAssertThrower );
return ok;
}
int main( int argc, char* argv[] )
{
int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
// This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
// but without it, Valgrind notices a lot of leaks from WX
wxUninitialize();
return ret;
}

View File

@ -36,9 +36,9 @@
#include <pad.h> #include <pad.h>
/** /**
* Make a module with a given list of named pads * Make a footprint with a given list of named pads
*/ */
static std::unique_ptr<FOOTPRINT> ModuleWithPads( const std::vector<wxString> aNames ) static std::unique_ptr<FOOTPRINT> FootprintWithPads( const std::vector<wxString> aNames )
{ {
std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( nullptr ); std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( nullptr );
@ -63,7 +63,7 @@ BOOST_AUTO_TEST_SUITE( ArrayPadNameProv )
struct APNP_CASE struct APNP_CASE
{ {
std::string m_case_name; std::string m_case_name;
bool m_using_module; bool m_using_footprint;
std::vector<wxString> m_existing_pads; std::vector<wxString> m_existing_pads;
std::unique_ptr<ARRAY_OPTIONS> m_arr_opts; std::unique_ptr<ARRAY_OPTIONS> m_arr_opts;
std::vector<wxString> m_exp_arr_names; std::vector<wxString> m_exp_arr_names;
@ -71,10 +71,10 @@ struct APNP_CASE
/** /**
* Get Array Pad Name Provider cases when a module is looked * Get Array Pad Name Provider cases when a footprint is looked at to determine what names
* at to determine what names are available. * are available.
*/ */
std::vector<APNP_CASE> GetModuleAPNPCases() std::vector<APNP_CASE> GetFootprintAPNPCases()
{ {
std::vector<APNP_CASE> cases; std::vector<APNP_CASE> cases;
@ -93,7 +93,7 @@ std::vector<APNP_CASE> GetModuleAPNPCases()
{ "2", "4", "5", "6", "7" }, { "2", "4", "5", "6", "7" },
} ); } );
// one without a module // one without a footprint
opts = std::make_unique<ARRAY_GRID_OPTIONS>(); opts = std::make_unique<ARRAY_GRID_OPTIONS>();
// simple linear numbering (again) // simple linear numbering (again)
@ -102,7 +102,7 @@ std::vector<APNP_CASE> GetModuleAPNPCases()
opts->m_pri_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC ); opts->m_pri_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC );
cases.push_back( { cases.push_back( {
"Simple linear, no module", "Simple linear, no footprint",
false, false,
{}, // not used {}, // not used
std::move( opts ), std::move( opts ),
@ -135,20 +135,18 @@ void CheckPadNameProvider( ARRAY_PAD_NAME_PROVIDER& aProvider, std::vector<wxStr
} }
BOOST_AUTO_TEST_CASE( ModuleCases ) BOOST_AUTO_TEST_CASE( FootprintCases )
{ {
for( const auto& c : GetModuleAPNPCases() ) for( const auto& c : GetFootprintAPNPCases() )
{ {
BOOST_TEST_CONTEXT( c.m_case_name ) BOOST_TEST_CONTEXT( c.m_case_name )
{ {
std::unique_ptr<FOOTPRINT> module; std::unique_ptr<FOOTPRINT> footprint;
if( c.m_using_module ) if( c.m_using_footprint )
{ footprint = FootprintWithPads( c.m_existing_pads );
module = ModuleWithPads( c.m_existing_pads );
}
ARRAY_PAD_NAME_PROVIDER apnp( module.get(), *c.m_arr_opts ); ARRAY_PAD_NAME_PROVIDER apnp( footprint.get(), *c.m_arr_opts );
CheckPadNameProvider( apnp, c.m_exp_arr_names ); CheckPadNameProvider( apnp, c.m_exp_arr_names );
} }

View File

@ -42,8 +42,8 @@ namespace KI_TEST
{ {
/** /**
* Draw a segment in the given module. * Draw a segment in the given footprint.
* @param aMod The module to add the segment to * @param aMod The footprint to add the segment to
* @param aSeg The segment geometry * @param aSeg The segment geometry
* @param aWidth The width of the segment * @param aWidth The width of the segment
* @param aLayer The layer to draw on * @param aLayer The layer to draw on
@ -52,7 +52,7 @@ void DrawSegment( FOOTPRINT& aFootprint, const SEG& aSeg, int aWidth, PCB_LAYER_
/** /**
* Draw a polyline - a set of linked segments * Draw a polyline - a set of linked segments
* @param aMod The module to add the segment to * @param aMod The footprint to add the segment to
* @param aPts The polyline points * @param aPts The polyline points
* @param aWidth The width of the segments * @param aWidth The width of the segments
* @param aLayer The layer to draw on * @param aLayer The layer to draw on
@ -61,8 +61,8 @@ void DrawPolyline( FOOTPRINT& aFootprint, const std::vector<VECTOR2I>& aPts, int
PCB_LAYER_ID aLayer ); PCB_LAYER_ID aLayer );
/** /**
* Draw an arc on a module * Draw an arc on a footprint
* @param aMod The module to add the segment to * @param aMod The footprint to add the segment to
* @param aCentre The arc centre * @param aCentre The arc centre
* @param aStart The arc start point * @param aStart The arc start point
* @param aAngle The arc angle (degrees, NOT deci-degrees) * @param aAngle The arc angle (degrees, NOT deci-degrees)
@ -73,8 +73,8 @@ void DrawArc( FOOTPRINT& aFootprint, const VECTOR2I& aCentre, const VECTOR2I& aS
double aAngle, int aWidth, PCB_LAYER_ID aLayer ); double aAngle, int aWidth, PCB_LAYER_ID aLayer );
/** /**
* Draw a rectangle on a module * Draw a rectangle on a footprint
* @param aMod The module to add the rectangle to * @param aMod The footprint to add the rectangle to
* @param aPos Rectangle centre point * @param aPos Rectangle centre point
* @param aSize Rectangle size (x, y) * @param aSize Rectangle size (x, y)
* @param aRadius Corner radius (0 for a normal rect) * @param aRadius Corner radius (0 for a normal rect)

View File

@ -31,7 +31,7 @@
bool init_unit_test() bool init_unit_test()
{ {
boost::unit_test::framework::master_test_suite().p_name.value = "S-expression module tests"; boost::unit_test::framework::master_test_suite().p_name.value = "S-expression footprint tests";
return wxInitialize(); return wxInitialize();
} }

View File

@ -53,8 +53,8 @@ enum CURVE_TYPE
/* /*
* Layers of importance to MCAD export: * Layers of importance to MCAD export:
* LAYER_TOP: specifies that a module is on the top of the PCB * LAYER_TOP: specifies that a footprint is on the top of the PCB
* LAYER_BOTTOM: specifies that a module is on the bottom of the PCB * LAYER_BOTTOM: specifies that a footprint is on the bottom of the PCB
* LAYER_EDGE: specifies that a Curve is associated with the PCB edge * LAYER_EDGE: specifies that a Curve is associated with the PCB edge
*/ */
enum LAYERS enum LAYERS

View File

@ -103,7 +103,7 @@ KICADPCB::KICADPCB()
KICADPCB::~KICADPCB() KICADPCB::~KICADPCB()
{ {
for( auto i : m_modules ) for( auto i : m_footprints )
delete i; delete i;
for( auto i : m_curves ) for( auto i : m_curves )
@ -368,41 +368,41 @@ bool KICADPCB::parseSetup( SEXPR::SEXPR* data )
bool KICADPCB::parseModule( SEXPR::SEXPR* data ) bool KICADPCB::parseModule( SEXPR::SEXPR* data )
{ {
KICADFOOTPRINT* mp = new KICADFOOTPRINT( this ); KICADFOOTPRINT* footprint = new KICADFOOTPRINT( this );
if( !mp->Read( data ) ) if( !footprint->Read( data ) )
{ {
delete mp; delete footprint;
return false; return false;
} }
m_modules.push_back( mp ); m_footprints.push_back( footprint );
return true; return true;
} }
bool KICADPCB::parseRect( SEXPR::SEXPR* data ) bool KICADPCB::parseRect( SEXPR::SEXPR* data )
{ {
KICADCURVE* mp = new KICADCURVE(); KICADCURVE* rect = new KICADCURVE();
if( !mp->Read( data, CURVE_LINE ) ) if( !rect->Read( data, CURVE_LINE ) )
{ {
delete mp; delete rect;
return false; return false;
} }
// reject any curves not on the Edge.Cuts layer // reject any curves not on the Edge.Cuts layer
if( mp->GetLayer() != LAYER_EDGE ) if( rect->GetLayer() != LAYER_EDGE )
{ {
delete mp; delete rect;
return true; return true;
} }
KICADCURVE* top = new KICADCURVE( *mp ); KICADCURVE* top = new KICADCURVE( *rect );
KICADCURVE* right = new KICADCURVE( *mp ); KICADCURVE* right = new KICADCURVE( *rect );
KICADCURVE* bottom = new KICADCURVE( *mp ); KICADCURVE* bottom = new KICADCURVE( *rect );
KICADCURVE* left = new KICADCURVE( *mp ); KICADCURVE* left = new KICADCURVE( *rect );
delete mp; delete rect;
top->m_end.y = right->m_start.y; top->m_end.y = right->m_start.y;
m_curves.push_back( top ); m_curves.push_back( top );
@ -422,22 +422,22 @@ bool KICADPCB::parseRect( SEXPR::SEXPR* data )
bool KICADPCB::parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType ) bool KICADPCB::parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType )
{ {
KICADCURVE* mp = new KICADCURVE(); KICADCURVE* curve = new KICADCURVE();
if( !mp->Read( data, aCurveType ) ) if( !curve->Read( data, aCurveType ) )
{ {
delete mp; delete curve;
return false; return false;
} }
// reject any curves not on the Edge.Cuts layer // reject any curves not on the Edge.Cuts layer
if( mp->GetLayer() != LAYER_EDGE ) if( curve->GetLayer() != LAYER_EDGE )
{ {
delete mp; delete curve;
return true; return true;
} }
m_curves.push_back( mp ); m_curves.push_back( curve );
return true; return true;
} }
@ -447,7 +447,7 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual )
if( m_pcb_model ) if( m_pcb_model )
return true; return true;
if( m_modules.empty() && m_curves.empty() ) if( m_footprints.empty() && m_curves.empty() )
{ {
ReportMessage( "Error: no PCB data (no footprint, no outline) to render\n" ); ReportMessage( "Error: no PCB data (no footprint, no outline) to render\n" );
return false; return false;
@ -499,7 +499,7 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual )
m_pcb_model->AddOutlineSegment( &lcurve ); m_pcb_model->AddOutlineSegment( &lcurve );
} }
for( auto i : m_modules ) for( auto i : m_footprints )
i->ComposePCB( m_pcb_model, &m_resolver, origin, aComposeVirtual ); i->ComposePCB( m_pcb_model, &m_resolver, origin, aComposeVirtual );
ReportMessage( "Create PCB solid model\n" ); ReportMessage( "Create PCB solid model\n" );

View File

@ -70,9 +70,9 @@ private:
std::map<std::string, int> m_layersNames; std::map<std::string, int> m_layersNames;
// PCB parameters/entities // PCB parameters/entities
double m_thickness; double m_thickness;
std::vector< KICADFOOTPRINT* > m_modules; std::vector<KICADFOOTPRINT*> m_footprints;
std::vector< KICADCURVE* > m_curves; std::vector<KICADCURVE*> m_curves;
bool parsePCB( SEXPR::SEXPR* data ); bool parsePCB( SEXPR::SEXPR* data );
bool parseGeneral( SEXPR::SEXPR* data ); bool parseGeneral( SEXPR::SEXPR* data );