Commit 63d3c835 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: refinement to Bug #1422093 fix.

parent 6312f838
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.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
...@@ -68,8 +68,8 @@ MODULE::MODULE( BOARD* parent ) : ...@@ -68,8 +68,8 @@ MODULE::MODULE( BOARD* parent ) :
m_LocalSolderPasteMargin = 0; m_LocalSolderPasteMargin = 0;
m_LocalSolderPasteMarginRatio = 0.0; m_LocalSolderPasteMarginRatio = 0.0;
m_ZoneConnection = UNDEFINED_CONNECTION; // Use zone setting by default m_ZoneConnection = UNDEFINED_CONNECTION; // Use zone setting by default
m_ThermalWidth = 0; // Use zone setting by default m_ThermalWidth = 0; // Use zone setting by default
m_ThermalGap = 0; // Use zone setting by default m_ThermalGap = 0; // Use zone setting by default
// These are special and mandatory text fields // These are special and mandatory text fields
m_Reference = new TEXTE_MODULE( this, TEXTE_MODULE::TEXT_is_REFERENCE ); m_Reference = new TEXTE_MODULE( this, TEXTE_MODULE::TEXT_is_REFERENCE );
...@@ -174,6 +174,21 @@ MODULE::~MODULE() ...@@ -174,6 +174,21 @@ MODULE::~MODULE()
delete m_initial_comments; 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) /* Draw the anchor cross (vertical)
* Must be done after the pads, because drawing the hole will erase overwrite * Must be done after the pads, because drawing the hole will erase overwrite
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.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
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
void Copy( MODULE* Module ); // Copy structure void Copy( MODULE* Module ); // Copy structure
/* /**
* Function Add * Function Add
* adds the given item to this MODULE and takes ownership of its memory. * adds the given item to this MODULE and takes ownership of its memory.
* @param aBoardItem The item to add to this board. * @param aBoardItem The item to add to this board.
...@@ -123,6 +123,15 @@ public: ...@@ -123,6 +123,15 @@ public:
*/ */
BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem ); 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 * Function CalculateBoundingBox
* calculates the bounding box in board coordinates. * calculates the bounding box in board coordinates.
......
...@@ -101,8 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) ...@@ -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 // Morever we do not want to save any reference to an unknown net when
// saving the footprint in lib cache // saving the footprint in lib cache
// so we force the ORPHANED dummy net info for all pads // so we force the ORPHANED dummy net info for all pads
for( D_PAD* pad = newModule->Pads(); pad; pad = pad->Next() ) newModule->ClearAllNets();
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
SetCrossHairPosition( wxPoint( 0, 0 ) ); SetCrossHairPosition( wxPoint( 0, 0 ) );
PlaceModule( newModule, NULL ); PlaceModule( newModule, NULL );
...@@ -332,12 +331,12 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId ) ...@@ -332,12 +331,12 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
MODULE* module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId ); MODULE* module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
// Clear all references to any net info, to be sure there is no broken links // If the module is found, clear all net info,
// to any netinfo list (should be not needed, but...) // to be sure there is no broken links
#if 0 // FIXME : currently crashes Pcbnew. should not. // to any netinfo list (should be not needed, but it can be edited from
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) // the footprint editor )
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED ); if( module )
#endif module->ClearAllNets();
return module; return module;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment