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.

139 lines
4.8 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 AUTHORS.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 3
  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 along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <wx/app.h>
  21. #include <wx/msgdlg.h>
  22. #include <pcb_calculator_frame_base.h>
  23. #include <pcb_calculator.h>
  24. #include <UnitSelector.h>
  25. #include <units_scales.h>
  26. // A helper class to handle min values
  27. // Values are in meters.
  28. // Note : use -1.0 when a value is irrelevant in a class
  29. class BOARD_MIN_SIZE_VALUES
  30. {
  31. public:
  32. int m_Class; // Class Id
  33. double m_Lines; // min copper lines width
  34. double m_Clearance; // min dist between copper lines
  35. double m_ViaDiamDiff; // Min value for diff between Via diameter
  36. // and its hole diameter
  37. double m_PadDiamDiffPlated; // Min value for diff between Pad diameter
  38. // and its hole diameter (plated)
  39. double m_PadDiamDiffNotPlated; // Min value for diff between Pad diameter
  40. // and its hole diameter (not plated)
  41. public:
  42. BOARD_MIN_SIZE_VALUES( int aClass, double aLines,
  43. double aClearance, double aViaDiffPlated,
  44. double aPadDiffPlated , double aPadDiffNotPlated )
  45. {
  46. m_Class = aClass;
  47. m_Lines = aLines;
  48. m_Clearance = aClearance;
  49. m_ViaDiamDiff = aViaDiffPlated;
  50. m_PadDiamDiffPlated = aPadDiffPlated;
  51. m_PadDiamDiffNotPlated = aPadDiffNotPlated;
  52. }
  53. };
  54. #define BRDCLASS_COUNT 6
  55. static BOARD_MIN_SIZE_VALUES clist[BRDCLASS_COUNT] =
  56. {
  57. // class 1
  58. BOARD_MIN_SIZE_VALUES(1, 0.80*UNIT_MM, 0.68*UNIT_MM,
  59. -1.0,
  60. 1.19*UNIT_MM, 1.57*UNIT_MM ),
  61. // class 2
  62. BOARD_MIN_SIZE_VALUES(1, 0.50*UNIT_MM, 0.50*UNIT_MM,
  63. -1.0,
  64. 0.78*UNIT_MM, 1.13*UNIT_MM ),
  65. // class 3
  66. BOARD_MIN_SIZE_VALUES(1, 0.31*UNIT_MM, 0.31*UNIT_MM,
  67. 0.45*UNIT_MM,
  68. 0.6*UNIT_MM, 0.90*UNIT_MM ),
  69. // class 4
  70. BOARD_MIN_SIZE_VALUES(1, 0.21*UNIT_MM, 0.21*UNIT_MM,
  71. 0.34*UNIT_MM,
  72. 0.49*UNIT_MM, -1.0 ),
  73. // class 5
  74. BOARD_MIN_SIZE_VALUES(1, 0.15*UNIT_MM, 0.15*UNIT_MM,
  75. 0.24*UNIT_MM,
  76. 0.39*UNIT_MM, -1.0 ),
  77. // class 6
  78. BOARD_MIN_SIZE_VALUES(1, 0.12*UNIT_MM, 0.12*UNIT_MM,
  79. 0.20*UNIT_MM,
  80. 0.35*UNIT_MM, -1.0 )
  81. };
  82. void PCB_CALCULATOR_FRAME::OnBoardClassesUnitsSelection( wxCommandEvent& event )
  83. {
  84. BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() );
  85. }
  86. void PCB_CALCULATOR_FRAME::BoardClassesUpdateData( double aUnitScale )
  87. {
  88. wxString txt;
  89. #define FMT wxT("%g")
  90. #define NOVAL wxT("--")
  91. for( int ii = 0; ii < BRDCLASS_COUNT; ii ++ )
  92. {
  93. // Display min tracks width
  94. if( clist[ii].m_Lines > -1.0 )
  95. txt.Printf( FMT, clist[ii].m_Lines / aUnitScale);
  96. else
  97. txt = NOVAL;
  98. m_gridClassesValuesDisplay->SetCellValue(0, ii, txt );
  99. // Display min clearance
  100. if( clist[ii].m_Clearance > -1.0 )
  101. txt.Printf( FMT, clist[ii].m_Clearance / aUnitScale);
  102. else
  103. txt = NOVAL;
  104. m_gridClassesValuesDisplay->SetCellValue(1, ii, txt );
  105. // Display min Via diam diff
  106. if( clist[ii].m_ViaDiamDiff > -1.0 )
  107. txt.Printf( FMT, clist[ii].m_ViaDiamDiff / aUnitScale);
  108. else
  109. txt = NOVAL;
  110. m_gridClassesValuesDisplay->SetCellValue(2, ii, txt );
  111. // Display min Pad diam diff (plated)
  112. if( clist[ii].m_PadDiamDiffPlated > -1.0 )
  113. txt.Printf( FMT, clist[ii].m_PadDiamDiffPlated / aUnitScale);
  114. else
  115. txt = NOVAL;
  116. m_gridClassesValuesDisplay->SetCellValue(3, ii, txt );
  117. // Display min Pad diam diff (non plated)
  118. if( clist[ii].m_PadDiamDiffNotPlated > -1.0 )
  119. txt.Printf( FMT, clist[ii].m_PadDiamDiffNotPlated / aUnitScale);
  120. else
  121. txt = NOVAL;
  122. m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
  123. }
  124. m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE );
  125. m_gridClassesValuesDisplay->AutoSize();
  126. }