You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.2 KiB

12 years ago
8 years ago
12 years ago
12 years ago
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time). Now, nets are saved with consecutive net codes (both modern & legacy plugins). Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp). Performed tests: - Changed a pad's net name from empty to existent - ok, name was changed. - Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty. - Changed a pad's net name from existent to empty - ok, net name became empty - Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed. - Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled. - Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes). - KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications). - A few boards were also saved using the legacy format and were opened with the master KiCad without any issues. - Change a net name for a pad, restore with undo/redo - ok - Remove everything, restore with undo - ok - Remove everything, reload netlist - ok Differences observed between files saved by the master branch KiCad and this one: - list of nets are not saved in any particular order, so net codes may differ - the default net class does not contain the unconnected net
12 years ago
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file board_connected_item.cpp
  27. * @brief BOARD_CONNECTED_ITEM class functions.
  28. */
  29. #include <fctsys.h>
  30. #include <pcbnew.h>
  31. #include <class_board.h>
  32. #include <class_board_item.h>
  33. #include <connectivity/connectivity_data.h>
  34. const wxChar* const traceMask = wxT( "BOARD_CONNECTED_ITEM" );
  35. BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
  36. BOARD_ITEM( aParent, idtype ), m_netinfo( NETINFO_LIST::OrphanedItem() )
  37. {
  38. m_localRatsnestVisible = true;
  39. }
  40. bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert )
  41. {
  42. if( !IsOnCopperLayer() )
  43. aNetCode = 0;
  44. // if aNetCode < 0 ( typically NETINFO_LIST::FORCE_ORPHANED )
  45. // or no parent board,
  46. // set the m_netinfo to the dummy NETINFO_LIST::ORPHANED
  47. BOARD* board = GetBoard();
  48. //auto connectivity = board ? board->GetConnectivity() : nullptr;
  49. //bool addRatsnest = false;
  50. //if( connectivity )
  51. //addRatsnest = connectivity->Remove( this );
  52. if( ( aNetCode >= 0 ) && board )
  53. m_netinfo = board->FindNet( aNetCode );
  54. else
  55. m_netinfo = NETINFO_LIST::OrphanedItem();
  56. if( !aNoAssert )
  57. wxASSERT( m_netinfo );
  58. // Add only if it was previously added to the ratsnest
  59. //if( addRatsnest )
  60. // connectivity->Add( this );
  61. return ( m_netinfo != NULL );
  62. }
  63. int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
  64. {
  65. int myClearance = m_netinfo->GetClearance();
  66. if( m_netinfo->GetNet() == 0 )
  67. myClearance = GetBoard()->GetDesignSettings().GetDefault()->GetClearance();
  68. if( aItem )
  69. return std::max( myClearance, aItem->GetClearance() );
  70. return myClearance;
  71. }
  72. NETCLASSPTR BOARD_CONNECTED_ITEM::GetNetClass() const
  73. {
  74. NETCLASSPTR netclass = m_netinfo->GetNetClass();
  75. if( netclass )
  76. return netclass;
  77. else
  78. return GetBoard()->GetDesignSettings().GetDefault();
  79. }
  80. wxString BOARD_CONNECTED_ITEM::GetNetClassName() const
  81. {
  82. return m_netinfo->GetClassName();
  83. }