Pcbnew: refinement to Bug #1422093 fix.

This commit is contained in:
jean-pierre charras 2015-02-18 10:13:17 +01:00
parent 6312f8386a
commit 63d3c835cb
3 changed files with 40 additions and 17 deletions

View File

@ -1,10 +1,10 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 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
@ -68,8 +68,8 @@ MODULE::MODULE( BOARD* parent ) :
m_LocalSolderPasteMargin = 0;
m_LocalSolderPasteMarginRatio = 0.0;
m_ZoneConnection = UNDEFINED_CONNECTION; // Use zone setting by default
m_ThermalWidth = 0; // Use zone setting by default
m_ThermalGap = 0; // Use zone setting by default
m_ThermalWidth = 0; // Use zone setting by default
m_ThermalGap = 0; // Use zone setting by default
// These are special and mandatory text fields
m_Reference = new TEXTE_MODULE( this, TEXTE_MODULE::TEXT_is_REFERENCE );
@ -174,6 +174,21 @@ MODULE::~MODULE()
delete m_initial_comments;
}
/**
* Function ClearAllNets
* Clear (i.e. force the ORPHANED dummy net info) the net info which
* depends on a given board for all pads of the footprint.
* This is needed when a footprint is copied between the fp editor and
* the board editor for instance, because net info become fully broken
*/
void MODULE::ClearAllNets()
{
// Force the ORPHANED dummy net info for all pads.
// ORPHANED dummy net does not depend on a board
for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
}
/* Draw the anchor cross (vertical)
* Must be done after the pads, because drawing the hole will erase overwrite

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 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
@ -93,7 +93,7 @@ public:
void Copy( MODULE* Module ); // Copy structure
/*
/**
* Function Add
* adds the given item to this MODULE and takes ownership of its memory.
* @param aBoardItem The item to add to this board.
@ -123,6 +123,15 @@ public:
*/
BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem );
/**
* Function ClearAllNets
* Clear (i.e. force the ORPHANED dummy net info) the net info which
* depends on a given board for all pads of the footprint.
* This is needed when a footprint is copied between the fp editor and
* the board editor for instance, because net info become fully broken
*/
void ClearAllNets();
/**
* Function CalculateBoundingBox
* calculates the bounding box in board coordinates.

View File

@ -101,8 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
// Morever we do not want to save any reference to an unknown net when
// saving the footprint in lib cache
// so we force the ORPHANED dummy net info for all pads
for( D_PAD* pad = newModule->Pads(); pad; pad = pad->Next() )
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
newModule->ClearAllNets();
SetCrossHairPosition( wxPoint( 0, 0 ) );
PlaceModule( newModule, NULL );
@ -332,12 +331,12 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
MODULE* module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
// Clear all references to any net info, to be sure there is no broken links
// to any netinfo list (should be not needed, but...)
#if 0 // FIXME : currently crashes Pcbnew. should not.
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
#endif
// If the module is found, clear all net info,
// to be sure there is no broken links
// to any netinfo list (should be not needed, but it can be edited from
// the footprint editor )
if( module )
module->ClearAllNets();
return module;
}