From 5fc382df8500322e2448b1f93a5a2af71bef6ff3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 9 Mar 2013 20:36:31 +0100 Subject: [PATCH] Pcbnew: Partial merge from pcad2kicad (from Alexander Lunev). Fix an old bug related to pads with offset: sometimes the connection to a zone was not detected. --- common/build_version.cpp | 4 +- packaging/windows/nsis/install.nsi | 4 +- pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp | 2 +- pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h | 2 +- pcbnew/pcad2kicadpcb_plugin/pcb.cpp | 21 ++- pcbnew/pcad2kicadpcb_plugin/pcb.h | 6 +- pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp | 47 +++--- pcbnew/pcad2kicadpcb_plugin/pcb_arc.h | 3 +- pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp | 43 +++++- pcbnew/pcad2kicadpcb_plugin/pcb_component.h | 5 +- .../pcad2kicadpcb_plugin/pcb_copper_pour.cpp | 6 +- pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp | 11 +- pcbnew/pcad2kicadpcb_plugin/pcb_line.h | 3 +- pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp | 110 +++----------- pcbnew/pcad2kicadpcb_plugin/pcb_module.h | 3 +- pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp | 136 ++++++++++++------ pcbnew/pcad2kicadpcb_plugin/pcb_pad.h | 8 +- pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp | 17 ++- pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h | 4 +- pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp | 3 +- pcbnew/zones_polygons_test_connections.cpp | 6 +- 21 files changed, 254 insertions(+), 190 deletions(-) diff --git a/common/build_version.cpp b/common/build_version.cpp index 464e4f87d1..0ea25a3f78 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -7,9 +7,9 @@ #ifndef KICAD_BUILD_VERSION #if defined KICAD_GOST -# define KICAD_BUILD_VERSION "(2013-mar-08 GOST)" +# define KICAD_BUILD_VERSION "(2013-mar-09 GOST)" #else -# define KICAD_BUILD_VERSION "(2013-mar-08)" +# define KICAD_BUILD_VERSION "(2013-mar-09)" #endif #endif diff --git a/packaging/windows/nsis/install.nsi b/packaging/windows/nsis/install.nsi index 1bd81d14c6..e37ae0a11e 100644 --- a/packaging/windows/nsis/install.nsi +++ b/packaging/windows/nsis/install.nsi @@ -17,7 +17,7 @@ ; General Product Description Definitions !define PRODUCT_NAME "KiCad" -!define PRODUCT_VERSION "2013.03.08" +!define PRODUCT_VERSION "2013.03.09" !define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/" !define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/" !define COMPANY_NAME "" @@ -36,7 +36,7 @@ SetCompressor /final /solid lzma CRCCheck force XPStyle on Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" -OutFile "${PRODUCT_NAME}_stable-${PRODUCT_VERSION}-BZR3989_Win_full_version.exe" +OutFile "${PRODUCT_NAME}_stable-${PRODUCT_VERSION}-BZR3990_Win_full_version.exe" InstallDir "$PROGRAMFILES\KiCad" ShowInstDetails hide ShowUnInstDetails hide diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp index 5bf58d7950..86cfcb3a06 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp @@ -24,7 +24,7 @@ /** * @file pcad_plugin.cpp - * @brief Pcbnew PLUGIN for P-Cad 2002/2004 ASCII *.pcb format. + * @brief Pcbnew PLUGIN for P-Cad 200x ASCII *.pcb format. */ #include diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h index ae68ce62ac..aaefce22e0 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h @@ -24,7 +24,7 @@ /** * @file pcad_plugin.h - * @brief Pcbnew PLUGIN for P-Cad 2002/2004 ASCII *.pcb format. + * @brief Pcbnew PLUGIN for P-Cad 200x ASCII *.pcb format. */ #ifndef PCAD_PLUGIN_H_ diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb.cpp index 07cd18d739..393ab9da63 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -50,19 +50,19 @@ namespace PCAD2KICAD { int PCB::GetKiCadLayer( int aPCadLayer ) { - assert( aPCadLayer >= FIRST_COPPER_LAYER && aPCadLayer <= LAST_NO_COPPER_LAYER ); + wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY ); return m_layersMap[aPCadLayer].KiCadLayer; } LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) { - assert( aPCadLayer >= FIRST_COPPER_LAYER && aPCadLayer <= LAST_NO_COPPER_LAYER ); + wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY ); return m_layersMap[aPCadLayer].layerType; } wxString PCB::GetLayerNetNameRef( int aPCadLayer ) { - assert( aPCadLayer >= FIRST_COPPER_LAYER && aPCadLayer <= LAST_NO_COPPER_LAYER ); + wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY ); return m_layersMap[aPCadLayer].netNameRef; } @@ -72,7 +72,7 @@ PCB::PCB( BOARD* aBoard ) : PCB_MODULE( this, aBoard ) m_defaultMeasurementUnit = wxT( "mil" ); - for( i = 0; i < NB_LAYERS; i++ ) + for( i = 0; i < MAX_PCAD_LAYER_QTY; i++ ) { m_layersMap[i].KiCadLayer = SOLDERMASK_N_FRONT; // default m_layersMap[i].layerType = LAYER_TYPE_NONSIGNAL; // default @@ -173,7 +173,7 @@ void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, t1Node = aNode; n = aXmlName; - // new file foramat version + // new file format version if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) ) { FindNode( tNode, @@ -262,6 +262,11 @@ void PCB::DoPCBComponents( XNODE* aNode, if( tNode ) { mc = new PCB_MODULE( this, m_board ); + + mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) ); + if( mNode ) + mNode->GetAttribute( wxT( "Name" ), &mc->m_patGraphRefName ); + mc->Parse( tNode, aStatusBar, m_defaultMeasurementUnit, aActualConversion ); } } @@ -515,7 +520,9 @@ void PCB::MapLayer( XNODE* aNode ) if( FindNode( aNode, wxT( "layerNum" ) ) ) FindNode( aNode, wxT( "layerNum" ) )->GetNodeContent().ToLong( &num ); - assert( num >= FIRST_COPPER_LAYER && num <= LAST_NO_COPPER_LAYER ); + if( num < 0 || num >= MAX_PCAD_LAYER_QTY ) + THROW_IO_ERROR( wxString::Format( wxT( "layerNum = %ld is out of range" ), num ) ); + m_layersMap[(int) num].KiCadLayer = KiCadLayer; if( FindNode( aNode, wxT( "layerType" ) ) ) diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb.h b/pcbnew/pcad2kicadpcb_plugin/pcb.h index 0f5b3f6713..91b76cd6c4 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -38,13 +38,15 @@ namespace PCAD2KICAD { +#define MAX_PCAD_LAYER_QTY 32 + class PCB : public PCB_MODULE, public PCB_CALLBACKS { public: PCB_COMPONENTS_ARRAY m_pcbComponents; // PCB Modules,Lines,Routes,Texts, .... and so on PCB_NETS_ARRAY m_pcbNetlist; // net objects collection wxString m_defaultMeasurementUnit; - TLAYER m_layersMap[NB_LAYERS]; // flexible layers mapping + TLAYER m_layersMap[MAX_PCAD_LAYER_QTY]; // flexible layers mapping int m_sizeX; int m_sizeY; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp index 10247b8ab5..ac31c82177 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -39,11 +39,11 @@ namespace PCAD2KICAD { PCB_ARC::PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard ) { - m_objType = wxT( 'A' ); - m_startX = 0; - m_startY = 0; - m_angle = 0; - m_width = 0; + m_objType = wxT( 'A' ); + m_startX = 0; + m_startY = 0; + m_angle = 0; + m_width = 0; } @@ -58,11 +58,14 @@ void PCB_ARC::Parse( XNODE* aNode, wxString aActualConversion ) { XNODE* lNode; - double r = 0.0, a = 0.0; - int endPointX, endPointY; + double a = 0.0; + int r = 0; + int endX; + int endY; m_PCadLayer = aLayer; m_KiCadLayer = GetKiCadLayer(); + if( FindNode( aNode, wxT( "width" ) ) ) SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion ); @@ -88,17 +91,16 @@ void PCB_ARC::Parse( XNODE* aNode, if( lNode ) SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, - &endPointX, &endPointY, aActualConversion ); + &endX, &endY, aActualConversion ); int alpha1 = ArcTangente( m_startY - m_positionY, m_startX - m_positionX ); - int alpha2 = ArcTangente( endPointY - m_positionY, endPointX - m_positionX ); + int alpha2 = ArcTangente( endY - m_positionY, endX - m_positionX ); m_angle = alpha1 - alpha2; if( m_angle < 0 ) m_angle = 3600 + m_angle; } - - if( aNode->GetName() == wxT( "arc" ) ) + else if( aNode->GetName() == wxT( "arc" ) ) { lNode = FindNode( aNode, wxT( "pt" ) ); @@ -108,18 +110,20 @@ void PCB_ARC::Parse( XNODE* aNode, lNode = FindNode( aNode, wxT( "radius" ) ); if( lNode) - r = StrToIntUnits( lNode->GetNodeContent(), wxT( ' ' ), aActualConversion ); + SetWidth( FindNode( aNode, wxT( "radius" ) )->GetNodeContent(), + aDefaultMeasurementUnit, &r, aActualConversion ); + lNode = FindNode( aNode, wxT( "startAngle" ) ); if( lNode ) a = StrToInt1Units( lNode->GetNodeContent() ); - m_startX = KiROUND( m_positionX + r * sin( (a - 900.0) * M_PI / 1800.0 ) ); - m_startY = KiROUND( m_positionY - r * cos( (a - 900.0) * M_PI / 1800.0 ) ); - lNode = FindNode( aNode, wxT( "sweepAngle" ) ); if( lNode ) m_angle = StrToInt1Units( lNode->GetNodeContent() ); + + m_startX = KiROUND( m_positionX + (double)r * cos( a * M_PI / 1800.0 ) ); + m_startY = KiROUND( m_positionY - (double)r * sin( a * M_PI / 1800.0 ) ); } } @@ -133,6 +137,17 @@ void PCB_ARC::SetPosOffset( int aX_offs, int aY_offs ) } +void PCB_ARC::Flip() +{ + PCB_COMPONENT::Flip(); + + m_startX = -m_startX; + m_angle = -m_angle; + + m_KiCadLayer = FlipLayers( m_KiCadLayer ); +} + + void PCB_ARC::AddToModule( MODULE* aModule ) { if( IsValidNonCopperLayerIndex( m_KiCadLayer ) ) diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h index f0d82622f7..fc6282b099 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -51,6 +51,7 @@ public: wxString aDefaultMeasurementUnit, wxString aActualConversion ); virtual void SetPosOffset( int aX_offs, int aY_offs ); + virtual void Flip(); void AddToModule( MODULE* aModule ); void AddToBoard(); }; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp index 500a41da0d..2e59042f43 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -61,7 +61,6 @@ PCB_COMPONENT::~PCB_COMPONENT() } - void PCB_COMPONENT::AddToModule( MODULE* aModule ) { } @@ -73,4 +72,44 @@ void PCB_COMPONENT::SetPosOffset( int aX_offs, int aY_offs ) m_positionY += aY_offs; } +void PCB_COMPONENT::Flip() +{ + m_positionX = -m_positionX; +} + +int PCB_COMPONENT::FlipLayers( int aLayer ) +{ + int result = aLayer; // dafault is no swap + + // routed layers + if( aLayer == LAYER_N_BACK ) + result = LAYER_N_FRONT; + + if( aLayer == LAYER_N_FRONT ) + result = LAYER_N_BACK; + + // Silk + if( aLayer == SILKSCREEN_N_FRONT ) + result = SILKSCREEN_N_BACK; + + if( aLayer == SILKSCREEN_N_BACK ) + result = SILKSCREEN_N_FRONT; + + // Paste + if( aLayer == SOLDERPASTE_N_FRONT ) + result = SOLDERPASTE_N_BACK; + + if( aLayer == SOLDERPASTE_N_BACK ) + result = SOLDERPASTE_N_FRONT; + + // Mask + if( aLayer == SOLDERMASK_N_FRONT ) + result = SOLDERMASK_N_BACK; + + if( aLayer == SOLDERMASK_N_BACK ) + result = SOLDERMASK_N_FRONT; + + return result; +} + } // namespace PCAD2KICAD diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_component.h b/pcbnew/pcad2kicadpcb_plugin/pcb_component.h index 0d01b2a156..a89deb9062 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_component.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_component.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -66,6 +66,7 @@ public: ~PCB_COMPONENT(); virtual void SetPosOffset( int aX_offs, int aY_offs ); + virtual void Flip(); virtual void AddToModule( MODULE* aModule ); virtual void AddToBoard() = 0; @@ -76,6 +77,8 @@ public: protected: PCB_CALLBACKS* m_callbacks; BOARD* m_board; + + int FlipLayers( int aLayer ); }; WX_DEFINE_ARRAY( PCB_COMPONENT*, PCB_COMPONENTS_ARRAY ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp index 9aafe80588..16c7c220fa 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -41,6 +41,7 @@ PCB_COPPER_POUR::PCB_COPPER_POUR( PCB_CALLBACKS* aCallbacks, int aPCadLayer ) : PCB_POLYGON( aCallbacks, aBoard, aPCadLayer ) { + m_filled = false; } @@ -87,6 +88,9 @@ bool PCB_COPPER_POUR::Parse( XNODE* aNode, SetWidth( FindNode( aNode, wxT( "thermalWidth" ) )->GetNodeContent(), aDefaultMeasurementUnit, &thermalWidth, aActualConversion ); + if( FindNode( aNode, wxT( "island" ) ) ) + m_filled = true; + lNode = FindNode( aNode, wxT( "pcbPoly" ) ); if( lNode ) diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp index 7d7a0ed70f..9934f53bbe 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -105,6 +105,15 @@ void PCB_LINE::SetPosOffset( int aX_offs, int aY_offs ) } +void PCB_LINE::Flip() +{ + PCB_COMPONENT::Flip(); + + m_toX = -m_toX; + m_KiCadLayer = FlipLayers( m_KiCadLayer ); +} + + void PCB_LINE::AddToModule( MODULE* aModule ) { if( IsValidNonCopperLayerIndex( m_KiCadLayer ) ) diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_line.h b/pcbnew/pcad2kicadpcb_plugin/pcb_line.h index 37de6a7d9c..e24aa38f2b 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_line.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_line.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -52,6 +52,7 @@ public: wxString aDefaultMeasurementUnit, wxString aActualConversion ); virtual void SetPosOffset( int aX_offs, int aY_offs ); + virtual void Flip(); void AddToModule( MODULE* aModule ); void AddToBoard(); }; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp index 9625d4e81a..ec350268a3 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -154,26 +154,25 @@ XNODE* PCB_MODULE::FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGra if( pNode ) lNode = FindNode( pNode, wxT( "multiLayer" ) ); // Old file format - *aPatGraphRefName = wxEmptyString; // default - if( lNode ) + { + *aPatGraphRefName = wxEmptyString; // default result = lNode; + } else { // New file format - if( FindNode( aNode, wxT( "patternGraphicsNameRef" ) ) ) + + if( *aPatGraphRefName == wxEmptyString ) // default { - FindNode( aNode, - wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ), - aPatGraphRefName ); + if( FindNode( aNode, wxT( "patternGraphicsNameRef" ) ) ) + { + FindNode( aNode, + wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ), + aPatGraphRefName ); + } } -// ///////////////////////////////////////////////////////////////////// -// lNode:=iNode.ChildNodes.FindNode('patternGraphicsDef'); before -// Fixed 02/08, Sergeys input file format -// Did it work before ???? -// lNode:=pNode.ChildNodes.FindNode('patternGraphicsDef'); Nw for some files -// //////////////////////////////////////////////////////////////////// if( FindNode( aNode, wxT( "patternGraphicsDef" ) ) ) lNode = FindNode( aNode, wxT( "patternGraphicsDef" ) ); else @@ -586,59 +585,23 @@ void PCB_MODULE::AddToBoard() for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) { if( m_moduleObjects[i]->m_objType == wxT( 'P' ) ) - ( (PCB_PAD*) m_moduleObjects[i] )->AddToModule( module, m_rotation ); + ( (PCB_PAD*) m_moduleObjects[i] )->AddToModule( module, m_rotation, false ); } // VIAS for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) { if( m_moduleObjects[i]->m_objType == wxT( 'V' ) ) - ( (PCB_VIA*) m_moduleObjects[i] )->AddToModule( module, m_rotation ); + ( (PCB_VIA*) m_moduleObjects[i] )->AddToModule( module, m_rotation, false ); } module->CalculateBoundingBox(); } -int PCB_MODULE::FlipLayers( int aLayer ) -{ - int result = aLayer; // no swap default.... - - // routed layers - if( aLayer == 0 ) - result = 15; - - if( aLayer == 15 ) - result = 0; - - // Silk - if( aLayer == 21 ) - result = 20; - - if( aLayer == 20 ) - result = 21; - - // Paste - if( aLayer == 19 ) - result = 18; - - if( aLayer == 18 ) - result = 19; - - // Mask - if( aLayer == 23 ) - result = 22; - - if( aLayer == 22 ) - result = 23; - - return result; -} - - void PCB_MODULE::Flip() { - int i, j; + int i; if( m_mirror == 1 ) { @@ -652,45 +615,12 @@ void PCB_MODULE::Flip() for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ ) { - // MODULE LINES - if( m_moduleObjects[i]->m_objType == wxT( 'L' ) ) + if( m_moduleObjects[i]->m_objType == wxT( 'L' ) || // lines + m_moduleObjects[i]->m_objType == wxT( 'A' ) || // arcs + m_moduleObjects[i]->m_objType == wxT( 'P' ) || // pads + m_moduleObjects[i]->m_objType == wxT( 'V' ) ) // vias { - m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX; - ( (PCB_LINE*) m_moduleObjects[i] )->m_toX = - -( (PCB_LINE*) m_moduleObjects[i] )->m_toX; - m_moduleObjects[i]->m_KiCadLayer = FlipLayers( m_moduleObjects[i]->m_KiCadLayer ); - } - - // MODULE Arcs - if( m_moduleObjects[i]->m_objType == wxT( 'A' ) ) - { - m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX; - ( (PCB_ARC*) m_moduleObjects[i] )->m_startX = - -( (PCB_ARC*) m_moduleObjects[i] )->m_startX; - m_moduleObjects[i]->m_KiCadLayer = FlipLayers( m_moduleObjects[i]->m_KiCadLayer ); - } - - // PADS - if( m_moduleObjects[i]->m_objType == wxT( 'P' ) ) - { - m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX; - m_moduleObjects[i]->m_rotation = -m_moduleObjects[i]->m_rotation; - - for( j = 0; j < (int) ( (PCB_PAD*) m_moduleObjects[i] )->m_shapes.GetCount(); j++ ) - ( (PCB_PAD*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer = - FlipLayers( ( (PCB_PAD*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer ); - - } - - // VIAS - if( m_moduleObjects[i]->m_objType == wxT( 'V' ) ) - { - m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX; - - for( j = 0; j < (int) ( (PCB_VIA*) m_moduleObjects[i] )->m_shapes.GetCount(); j++ ) - ( (PCB_VIA*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer = - FlipLayers( ( (PCB_VIA*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer ); - + m_moduleObjects[i]->Flip(); } } } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.h b/pcbnew/pcad2kicadpcb_plugin/pcb_module.h index 6719d62387..27d8d3d891 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -68,7 +68,6 @@ public: private: XNODE* FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName ); wxString ModuleLayer( int aMirror ); - int FlipLayers( int aLayer ); }; } // namespace PCAD2KICAD diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp index 8ec8a59b9a..3b91f5beba 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -37,10 +37,11 @@ namespace PCAD2KICAD { PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard ) { - m_objType = wxT( 'P' ); - m_number = 0; - m_hole = 0; - m_isHolePlated = true; + m_objType = wxT( 'P' ); + m_number = 0; + m_hole = 0; + m_isHolePlated = true; + m_defaultPinDes = wxEmptyString; } @@ -96,6 +97,26 @@ void PCB_PAD::Parse( XNODE* aNode, wxString aDefaultMeasurementUnit, m_rotation = StrToInt1Units( str ); } + lNode = FindNode( aNode, wxT( "netNameRef" ) ); + + if( lNode ) + { + lNode->GetAttribute( wxT( "Name" ), &propValue ); + propValue.Trim( false ); + propValue.Trim( true ); + m_net = propValue; + m_netCode = GetNetCode( m_net ); + } + + lNode = FindNode( aNode, wxT( "defaultPinDes" ) ); + + if( lNode ) + { + lNode->GetAttribute( wxT( "Name" ), &propValue ); + //propValue.Trim( false ); + m_defaultPinDes = propValue; + } + lNode = aNode; while( lNode && lNode->GetName() != wxT( "www.lura.sk" ) ) @@ -149,7 +170,21 @@ void PCB_PAD::Parse( XNODE* aNode, wxString aDefaultMeasurementUnit, } -void PCB_PAD::AddToModule( MODULE* aModule, int aRotation ) +void PCB_PAD::Flip() +{ + int i; + + PCB_COMPONENT::Flip(); + + if( m_objType == wxT( 'P' ) ) + m_rotation = -m_rotation; + + for( i = 0; i < (int)m_shapes.GetCount(); i++ ) + m_shapes[i]->m_KiCadLayer = FlipLayers( m_shapes[i]->m_KiCadLayer ); +} + + +void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad ) { PCB_PAD_SHAPE* padShape; wxString padShapeName = wxT( "Ellipse" ); @@ -158,12 +193,12 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation ) int width = 0; int height = 0; + D_PAD* pad = new D_PAD( aModule ); + aModule->m_Pads.PushBack( pad ); + if( !m_isHolePlated && m_hole ) { // mechanical hole - D_PAD* pad = new D_PAD( aModule ); - aModule->m_Pads.PushBack( pad ); - pad->SetShape( PAD_CIRCLE ); pad->SetAttribute( PAD_HOLE_NOT_PLATED ); @@ -171,20 +206,10 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation ) pad->SetDrillSize( wxSize( m_hole, m_hole ) ); pad->SetSize( wxSize( m_hole, m_hole ) ); - // pad's "Position" is not relative to the module's, - // whereas Pos0 is relative to the module's but is the unrotated coordinate. - wxPoint padpos( m_positionX, m_positionY ); - pad->SetPos0( padpos ); - RotatePoint( &padpos, aModule->GetOrientation() ); - pad->SetPosition( padpos + aModule->GetPosition() ); - pad->SetLayerMask( ALL_CU_LAYERS | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ); } else { - D_PAD* pad = new D_PAD( aModule ); - aModule->m_Pads.PushBack( pad ); - ( m_hole ) ? padType = PAD_STANDARD : padType = PAD_SMD; // form layer mask @@ -250,7 +275,10 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation ) pad->SetNet( 0 ); pad->SetNetname( m_net ); + } + if( !aEncapsulatedPad ) + { // pad's "Position" is not relative to the module's, // whereas Pos0 is relative to the module's but is the unrotated coordinate. wxPoint padpos( m_positionX, m_positionY ); @@ -268,44 +296,58 @@ void PCB_PAD::AddToBoard() int width = 0; int height = 0; - // choose one of the shapes - for( i = 0; i < (int) m_shapes.GetCount(); i++ ) + if( m_objType == wxT( 'V' ) ) // via { - padShape = m_shapes[i]; - - if( padShape->m_width > 0 && padShape->m_height > 0 ) + // choose one of the shapes + for( i = 0; i < (int) m_shapes.GetCount(); i++ ) { - if( padShape->m_KiCadLayer == LAYER_N_FRONT - || padShape->m_KiCadLayer == LAYER_N_BACK ) - { - width = padShape->m_width; - height = padShape->m_height; + padShape = m_shapes[i]; - break; + if( padShape->m_width > 0 && padShape->m_height > 0 ) + { + if( padShape->m_KiCadLayer == LAYER_N_FRONT + || padShape->m_KiCadLayer == LAYER_N_BACK ) + { + width = padShape->m_width; + height = padShape->m_height; + + break; + } } } + + if( width == 0 || height == 0 ) + THROW_IO_ERROR( wxT( "pad or via with zero size" ) ); + + if( IsValidCopperLayerIndex( m_KiCadLayer ) ) + { + SEGVIA* via = new SEGVIA( m_board ); + m_board->m_Track.Append( via ); + + via->SetTimeStamp( 0 ); + + via->SetPosition( wxPoint( m_positionX, m_positionY ) ); + via->SetEnd( wxPoint( m_positionX, m_positionY ) ); + + via->SetWidth( height ); + via->SetShape( VIA_THROUGH ); + ( (SEGVIA*) via )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK ); + via->SetDrill( m_hole ); + + via->SetLayer( m_KiCadLayer ); + via->SetNet( m_netCode ); + } } - - if( width == 0 || height == 0 ) - THROW_IO_ERROR( wxT( "pad or via with zero size" ) ); - - if( IsValidCopperLayerIndex( m_KiCadLayer ) ) + else // pad { - SEGVIA* via = new SEGVIA( m_board ); - m_board->m_Track.Append( via ); + MODULE* module = new MODULE( m_board ); + m_board->Add( module, ADD_APPEND ); - via->SetTimeStamp( 0 ); + m_name.text = m_defaultPinDes; - via->SetPosition( wxPoint( m_positionX, m_positionY ) ); - via->SetEnd( wxPoint( m_positionX, m_positionY ) ); + module->SetPosition( wxPoint( m_positionX, m_positionY ) ); + AddToModule( module, 0, true ); - via->SetWidth( height ); - via->SetShape( VIA_THROUGH ); - ( (SEGVIA*) via )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK ); - via->SetDrill( m_hole ); - - via->SetLayer( m_KiCadLayer ); - via->SetNet( m_netCode ); } } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h index 14fc7f4848..fa18bd52b9 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -51,8 +51,12 @@ public: virtual void Parse( XNODE* aNode, wxString aDefaultMeasurementUnit, wxString aActualConversion ); - void AddToModule( MODULE* aModule, int aRotation ); + virtual void Flip(); + void AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad ); void AddToBoard(); + +private: + wxString m_defaultPinDes; }; } // namespace PCAD2KICAD diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp index 3438b4d026..064e1eabec 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -39,12 +39,13 @@ namespace PCAD2KICAD { PCB_POLYGON::PCB_POLYGON( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer ) : PCB_COMPONENT( aCallbacks, aBoard ) { - m_width = 0; - m_priority = 0; - m_objType = wxT( 'Z' ); - m_PCadLayer = aPCadLayer; + m_width = 0; + m_priority = 0; + m_objType = wxT( 'Z' ); + m_PCadLayer = aPCadLayer; m_KiCadLayer = GetKiCadLayer(); - m_timestamp = GetNewTimestamp(); + m_timestamp = GetNewTimestamp(); + m_filled = true; } @@ -209,7 +210,9 @@ void PCB_POLYGON::AddToBoard() zone->SetDoNotAllowCopperPour( true ); } - //zone->BuildFilledPolysListData( m_board ); + //if( m_filled ) + // cvpcb is not linked + // zone->BuildFilledPolysListData( m_board ); } } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h index 49ab0a93d5..822822760b 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007, 2008 Lubo Racko - * Copyright (C) 2007, 2008, 2012 Alexander Lunev + * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -66,6 +66,8 @@ public: void FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon, wxString aDefaultMeasurementUnit, wxString actualConversion ); +protected: + bool m_filled; }; } // namespace PCAD2KICAD diff --git a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp index badcbd2770..6bd2392968 100644 --- a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Alexander Lunev + * Copyright (C) 2012-2013 Alexander Lunev * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -26,7 +26,6 @@ * @file s_expr_loader.cpp */ -#include #include #include #include diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 354de8fed5..4c083eae4e 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -166,7 +166,11 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) if( item->Type() == PCB_PAD_T ) { - pos1 = pos2 = ( (D_PAD*) item )->GetPosition(); + // For pads we use the shape position instead of + // the pad position, because the zones are connected + // to the center of the shape, not the pad position + // (this is important for pads with thermal relief) + pos1 = pos2 = ( (D_PAD*) item )->ReturnShapePos(); } else if( item->Type() == PCB_VIA_T ) {