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.

164 lines
4.7 KiB

++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@inpg.fr
  6. * Copyright (C) 2009-2020 KiCad Developers, see change_log.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. #include <netclass.h>
  26. #include <base_units.h>
  27. // This will get mapped to "kicad_default" in the specctra_export.
  28. const char NETCLASS::Default[] = "Default";
  29. // Initial values for netclass initialization
  30. const int DEFAULT_CLEARANCE = PcbMillimeter2iu( 0.2 ); // track to track and track to pads clearance
  31. const int DEFAULT_VIA_DIAMETER = PcbMillimeter2iu( 0.8 );
  32. const int DEFAULT_VIA_DRILL = PcbMillimeter2iu( 0.4 );
  33. const int DEFAULT_UVIA_DIAMETER = PcbMillimeter2iu( 0.3 );
  34. const int DEFAULT_UVIA_DRILL = PcbMillimeter2iu( 0.1 );
  35. const int DEFAULT_TRACK_WIDTH = PcbMillimeter2iu( 0.25 );
  36. const int DEFAULT_DIFF_PAIR_WIDTH = PcbMillimeter2iu( 0.2 );
  37. const int DEFAULT_DIFF_PAIR_GAP = PcbMillimeter2iu( 0.25 );
  38. const int DEFAULT_DIFF_PAIR_VIAGAP = PcbMillimeter2iu( 0.25 );
  39. const int DEFAULT_WIRE_WIDTH = SchMils2iu( 6 );
  40. const int DEFAULT_BUS_WIDTH = SchMils2iu( 12 );
  41. const int DEFAULT_LINE_STYLE = 0; // solid
  42. NETCLASS::NETCLASS( const wxString& aName ) :
  43. m_Name( aName ),
  44. m_PcbColor( KIGFX::COLOR4D::UNSPECIFIED )
  45. {
  46. // Default settings
  47. SetClearance( DEFAULT_CLEARANCE );
  48. SetViaDrill( DEFAULT_VIA_DRILL );
  49. SetuViaDrill( DEFAULT_UVIA_DRILL );
  50. // These defaults will be overwritten by SetParams,
  51. // from the board design parameters, later
  52. SetTrackWidth( DEFAULT_TRACK_WIDTH );
  53. SetViaDiameter( DEFAULT_VIA_DIAMETER );
  54. SetuViaDiameter( DEFAULT_UVIA_DIAMETER );
  55. SetDiffPairWidth( DEFAULT_DIFF_PAIR_WIDTH );
  56. SetDiffPairGap( DEFAULT_DIFF_PAIR_GAP );
  57. SetDiffPairViaGap( DEFAULT_DIFF_PAIR_VIAGAP );
  58. SetWireWidth( DEFAULT_WIRE_WIDTH );
  59. SetBusWidth( DEFAULT_BUS_WIDTH );
  60. SetSchematicColor( COLOR4D::UNSPECIFIED );
  61. SetLineStyle( DEFAULT_LINE_STYLE );
  62. }
  63. NETCLASS::~NETCLASS()
  64. {
  65. }
  66. NETCLASSES::NETCLASSES()
  67. {
  68. m_default = std::make_shared<NETCLASS>( NETCLASS::Default );
  69. }
  70. NETCLASSES::~NETCLASSES()
  71. {
  72. }
  73. bool NETCLASSES::Add( const NETCLASSPTR& aNetClass )
  74. {
  75. const wxString& name = aNetClass->GetName();
  76. if( name == NETCLASS::Default )
  77. {
  78. m_default = aNetClass;
  79. return true;
  80. }
  81. // Test for an existing netclass:
  82. if( !Find( name ) )
  83. {
  84. // name not found, take ownership
  85. m_NetClasses[name] = aNetClass;
  86. return true;
  87. }
  88. else
  89. {
  90. // name already exists
  91. // do not "take ownership" and return false telling caller such.
  92. return false;
  93. }
  94. }
  95. NETCLASSPTR NETCLASSES::Remove( const wxString& aNetName )
  96. {
  97. NETCLASS_MAP::iterator found = m_NetClasses.find( aNetName );
  98. if( found != m_NetClasses.end() )
  99. {
  100. std::shared_ptr<NETCLASS> netclass = found->second;
  101. m_NetClasses.erase( found );
  102. return netclass;
  103. }
  104. return NETCLASSPTR();
  105. }
  106. NETCLASSPTR NETCLASSES::Find( const wxString& aName ) const
  107. {
  108. if( aName == NETCLASS::Default )
  109. return GetDefault();
  110. NETCLASS_MAP::const_iterator found = m_NetClasses.find( aName );
  111. if( found == m_NetClasses.end() )
  112. return NETCLASSPTR();
  113. else
  114. return found->second;
  115. }
  116. #if defined(DEBUG)
  117. void NETCLASS::Show( int nestLevel, std::ostream& os ) const
  118. {
  119. // for now, make it look like XML:
  120. //NestedSpace( nestLevel, os )
  121. os << '<' << GetClass().Lower().mb_str() << ">\n";
  122. for( const_iterator i = begin(); i!=end(); ++i )
  123. {
  124. // NestedSpace( nestLevel+1, os ) << *i;
  125. os << TO_UTF8( *i );
  126. }
  127. // NestedSpace( nestLevel, os )
  128. os << "</" << GetClass().Lower().mb_str() << ">\n";
  129. }
  130. #endif