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.

144 lines
5.0 KiB

  1. /*
  2. * This program source code file is part of KICAD, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 jean-pierre.charras
  5. * Copyright (C) 2015 Kicad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <wx/app.h>
  25. #include <wx/config.h>
  26. #include <wx/msgdlg.h>
  27. #include <pcb_calculator_frame_base.h>
  28. #include <pcb_calculator.h>
  29. #include <UnitSelector.h>
  30. #include <units_scales.h>
  31. // A helper class to handle min values
  32. // Values are in meters.
  33. // Note : use -1.0 when a vaule is irrelevant in a class
  34. class BOARD_MIN_SIZE_VALUES
  35. {
  36. public:
  37. int m_Class; // Class Id
  38. double m_Lines; // min copper lines width
  39. double m_Clearance; // min dist between copper lines
  40. double m_ViaDiamDiff; // Min value for diff between Via diameter
  41. // and its hole diameter
  42. double m_PadDiamDiffPlated; // Min value for diff between Pad diameter
  43. // and its hole diameter (plated)
  44. double m_PadDiamDiffNotPlated; // Min value for diff between Pad diameter
  45. // and its hole diameter (not plated)
  46. public:
  47. BOARD_MIN_SIZE_VALUES( int aClass, double aLines,
  48. double aClearance, double aViaDiffPlated,
  49. double aPadDiffPlated , double aPadDiffNotPlated )
  50. {
  51. m_Class = aClass;
  52. m_Lines = aLines;
  53. m_Clearance = aClearance;
  54. m_ViaDiamDiff = aViaDiffPlated;
  55. m_PadDiamDiffPlated = aPadDiffPlated;
  56. m_PadDiamDiffNotPlated = aPadDiffNotPlated;
  57. }
  58. };
  59. #define BRDCLASS_COUNT 6
  60. static BOARD_MIN_SIZE_VALUES clist[BRDCLASS_COUNT] =
  61. {
  62. // class 1
  63. BOARD_MIN_SIZE_VALUES(1, 0.80*UNIT_MM, 0.68*UNIT_MM,
  64. -1.0,
  65. 1.19*UNIT_MM, 1.57*UNIT_MM ),
  66. // class 2
  67. BOARD_MIN_SIZE_VALUES(1, 0.50*UNIT_MM, 0.50*UNIT_MM,
  68. -1.0,
  69. 0.78*UNIT_MM, 1.13*UNIT_MM ),
  70. // class 3
  71. BOARD_MIN_SIZE_VALUES(1, 0.31*UNIT_MM, 0.31*UNIT_MM,
  72. 0.45*UNIT_MM,
  73. 0.6*UNIT_MM, 0.90*UNIT_MM ),
  74. // class 4
  75. BOARD_MIN_SIZE_VALUES(1, 0.21*UNIT_MM, 0.21*UNIT_MM,
  76. 0.34*UNIT_MM,
  77. 0.49*UNIT_MM, -1.0 ),
  78. // class 5
  79. BOARD_MIN_SIZE_VALUES(1, 0.15*UNIT_MM, 0.15*UNIT_MM,
  80. 0.24*UNIT_MM,
  81. 0.39*UNIT_MM, -1.0 ),
  82. // class 6
  83. BOARD_MIN_SIZE_VALUES(1, 0.12*UNIT_MM, 0.12*UNIT_MM,
  84. 0.20*UNIT_MM,
  85. 0.35*UNIT_MM, -1.0 )
  86. };
  87. void PCB_CALCULATOR_FRAME::OnBoardClassesUnitsSelection( wxCommandEvent& event )
  88. {
  89. BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() );
  90. }
  91. void PCB_CALCULATOR_FRAME::BoardClassesUpdateData( double aUnitScale )
  92. {
  93. wxString txt;
  94. #define FMT wxT("%g")
  95. #define NOVAL wxT("--")
  96. for( int ii = 0; ii < BRDCLASS_COUNT; ii ++ )
  97. {
  98. // Display min tracks width
  99. if( clist[ii].m_Lines > -1.0 )
  100. txt.Printf( FMT, clist[ii].m_Lines / aUnitScale);
  101. else
  102. txt = NOVAL;
  103. m_gridClassesValuesDisplay->SetCellValue(0, ii, txt );
  104. // Display min clearance
  105. if( clist[ii].m_Clearance > -1.0 )
  106. txt.Printf( FMT, clist[ii].m_Clearance / aUnitScale);
  107. else
  108. txt = NOVAL;
  109. m_gridClassesValuesDisplay->SetCellValue(1, ii, txt );
  110. // Display min Via diam diff
  111. if( clist[ii].m_ViaDiamDiff > -1.0 )
  112. txt.Printf( FMT, clist[ii].m_ViaDiamDiff / aUnitScale);
  113. else
  114. txt = NOVAL;
  115. m_gridClassesValuesDisplay->SetCellValue(2, ii, txt );
  116. // Display min Pad diam diff (plated)
  117. if( clist[ii].m_PadDiamDiffPlated > -1.0 )
  118. txt.Printf( FMT, clist[ii].m_PadDiamDiffPlated / aUnitScale);
  119. else
  120. txt = NOVAL;
  121. m_gridClassesValuesDisplay->SetCellValue(3, ii, txt );
  122. // Display min Pad diam diff (non plated)
  123. if( clist[ii].m_PadDiamDiffNotPlated > -1.0 )
  124. txt.Printf( FMT, clist[ii].m_PadDiamDiffNotPlated / aUnitScale);
  125. else
  126. txt = NOVAL;
  127. m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
  128. }
  129. m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE );
  130. m_gridClassesValuesDisplay->AutoSize();
  131. }