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.

200 lines
8.0 KiB

8 months ago
5 years ago
8 months ago
8 months ago
8 months ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. * @author Maciej Suminski <maciej.suminski@cern.ch>
  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 <dialogs/dialog_track_via_properties_base.h>
  26. #include <widgets/unit_binder.h>
  27. #include <optional>
  28. #include <layer_ids.h>
  29. class PCB_SELECTION;
  30. class PCB_BASE_EDIT_FRAME;
  31. class PAD;
  32. class PADSTACK;
  33. class DIALOG_TRACK_VIA_PROPERTIES : public DIALOG_TRACK_VIA_PROPERTIES_BASE
  34. {
  35. public:
  36. DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, const PCB_SELECTION& aItems );
  37. ~DIALOG_TRACK_VIA_PROPERTIES();
  38. bool TransferDataFromWindow() override;
  39. private:
  40. void onNetSelector( wxCommandEvent& aEvent );
  41. void onViaNotFreeClicked( wxCommandEvent& aEvent ) override;
  42. void onWidthSelect( wxCommandEvent& aEvent ) override;
  43. void onWidthEdit( wxCommandEvent& aEvent ) override;
  44. void onViaSelect( wxCommandEvent& aEvent ) override;
  45. void onViaEdit( wxCommandEvent& aEvent ) override;
  46. void onTrackEdit( wxCommandEvent& aEvent ) override;
  47. void onPadstackModeChanged( wxCommandEvent& aEvent ) override;
  48. void onEditLayerChanged( wxCommandEvent& aEvent ) override;
  49. void onUnitsChanged( wxCommandEvent& aEvent );
  50. void onTeardropsUpdateUi( wxUpdateUIEvent& event ) override;
  51. bool confirmShortingNets( int aNet, const std::set<int>& shortingNets );
  52. bool confirmPadChange( const std::set<PAD*>& connectedPads );
  53. int getLayerDepth();
  54. void afterPadstackModeChanged();
  55. private:
  56. PCB_BASE_EDIT_FRAME* m_frame;
  57. const PCB_SELECTION& m_items; // List of items to be modified.
  58. UNIT_BINDER m_trackStartX, m_trackStartY;
  59. UNIT_BINDER m_trackEndX, m_trackEndY;
  60. UNIT_BINDER m_trackWidth;
  61. UNIT_BINDER m_trackMaskMargin;
  62. UNIT_BINDER m_viaX, m_viaY;
  63. UNIT_BINDER m_viaDiameter, m_viaDrill;
  64. UNIT_BINDER m_teardropHDPercent;
  65. UNIT_BINDER m_teardropLenPercent;
  66. UNIT_BINDER m_teardropMaxLen;
  67. UNIT_BINDER m_teardropWidthPercent;
  68. UNIT_BINDER m_teardropMaxWidth;
  69. bool m_tracks; // True if dialog displays any track properties.
  70. bool m_vias; // True if dialog displays any via properties.
  71. /// Temporary padstack of the edited via(s)
  72. std::unique_ptr<PADSTACK> m_viaStack;
  73. /// The currently-shown copper layer of the edited via(s)
  74. PCB_LAYER_ID m_editLayer;
  75. std::map<int, PCB_LAYER_ID> m_editLayerCtrlMap;
  76. enum class IPC4761_SURFACE
  77. {
  78. FROM_RULES = 0,
  79. NONE = 1,
  80. FRONT = 2,
  81. BACK = 3,
  82. BOTH = 4,
  83. CUSTOM = 5
  84. };
  85. enum class IPC4761_DRILL
  86. {
  87. FROM_RULES = 0,
  88. NOT_SET = 1,
  89. SET = 2
  90. };
  91. enum class IPC4761_PRESET
  92. {
  93. FROM_RULES = 0,
  94. NONE = 1,
  95. IA = 2,
  96. IB = 3,
  97. IA_INVERTED = 4,
  98. IIA = 5,
  99. IIB = 6,
  100. IIA_INVERTED = 7,
  101. IIIA = 8,
  102. IIIB = 9,
  103. IIIA_INVERTED = 10,
  104. IVA = 11,
  105. IVB = 12,
  106. IVA_INVERTED = 13,
  107. V = 14,
  108. VIA = 15,
  109. VIB = 16,
  110. VIA_INVERTED = 17,
  111. VII = 18,
  112. CUSTOM = 19,
  113. END = 20
  114. };
  115. struct IPC4761_CONFIGURATION
  116. {
  117. IPC4761_SURFACE tent{ IPC4761_SURFACE::NONE };
  118. IPC4761_SURFACE cover{ IPC4761_SURFACE::NONE };
  119. IPC4761_SURFACE plug{ IPC4761_SURFACE::NONE };
  120. IPC4761_DRILL fill{ IPC4761_DRILL::NOT_SET };
  121. IPC4761_DRILL cap{ IPC4761_DRILL::NOT_SET };
  122. bool operator==( const IPC4761_CONFIGURATION& other ) const;
  123. };
  124. const std::map<IPC4761_PRESET, IPC4761_CONFIGURATION> m_IPC4761Presets{
  125. { IPC4761_PRESET::FROM_RULES,
  126. { IPC4761_SURFACE::FROM_RULES, IPC4761_SURFACE::FROM_RULES, IPC4761_SURFACE::FROM_RULES,
  127. IPC4761_DRILL::FROM_RULES, IPC4761_DRILL::FROM_RULES } },
  128. { IPC4761_PRESET::NONE, {} },
  129. { IPC4761_PRESET::IA, { .tent = IPC4761_SURFACE::FRONT } },
  130. { IPC4761_PRESET::IB, { .tent = IPC4761_SURFACE::BOTH } },
  131. { IPC4761_PRESET::IA_INVERTED, { .tent = IPC4761_SURFACE::BACK } },
  132. { IPC4761_PRESET::IIA,
  133. { .tent = IPC4761_SURFACE::FRONT, .cover = IPC4761_SURFACE::FRONT } },
  134. { IPC4761_PRESET::IIB, { .tent = IPC4761_SURFACE::BOTH, .cover = IPC4761_SURFACE::BOTH } },
  135. { IPC4761_PRESET::IIA_INVERTED,
  136. { .tent = IPC4761_SURFACE::BACK, .cover = IPC4761_SURFACE::BACK } },
  137. { IPC4761_PRESET::IIIA, { .plug = IPC4761_SURFACE::FRONT } },
  138. { IPC4761_PRESET::IIIB, { .plug = IPC4761_SURFACE::BOTH } },
  139. { IPC4761_PRESET::IIIA_INVERTED, { .plug = IPC4761_SURFACE::BACK } },
  140. { IPC4761_PRESET::IVA, { .tent = IPC4761_SURFACE::FRONT, .plug = IPC4761_SURFACE::FRONT } },
  141. { IPC4761_PRESET::IVB, { .tent = IPC4761_SURFACE::BOTH, .plug = IPC4761_SURFACE::BOTH } },
  142. { IPC4761_PRESET::IVA_INVERTED,
  143. { .tent = IPC4761_SURFACE::BACK, .plug = IPC4761_SURFACE::BACK } },
  144. { IPC4761_PRESET::V, { .fill = IPC4761_DRILL::SET } },
  145. { IPC4761_PRESET::VIA, { .tent = IPC4761_SURFACE::FRONT, .fill = IPC4761_DRILL::SET } },
  146. { IPC4761_PRESET::VIB, { .tent = IPC4761_SURFACE::BOTH, .fill = IPC4761_DRILL::SET } },
  147. { IPC4761_PRESET::VIA_INVERTED,
  148. { .tent = IPC4761_SURFACE::BACK, .fill = IPC4761_DRILL::SET } },
  149. { IPC4761_PRESET::VII, { .fill = IPC4761_DRILL::SET, .cap = IPC4761_DRILL::SET } },
  150. { IPC4761_PRESET::CUSTOM, {} },
  151. { IPC4761_PRESET::END, {} }
  152. };
  153. const std::map<IPC4761_PRESET, wxString> m_IPC4761Names{
  154. { IPC4761_PRESET::FROM_RULES, _( "From rules" ) },
  155. { IPC4761_PRESET::NONE, _( "None" ) },
  156. { IPC4761_PRESET::IA, _( "Type I a ( tented top )" ) },
  157. { IPC4761_PRESET::IB, _( "Type I b ( tented both sides )" ) },
  158. { IPC4761_PRESET::IA_INVERTED, _( "Type I a ( tented bottom )" ) },
  159. { IPC4761_PRESET::IIA, _( "Type II a ( covered and tented top )" ) },
  160. { IPC4761_PRESET::IIB, _( "Type II b ( covered and tented both sides )" ) },
  161. { IPC4761_PRESET::IIA_INVERTED, _( "Type II a ( covered and tented bottom )" ) },
  162. { IPC4761_PRESET::IIIA, _( "Type III a ( plugged top )" ) },
  163. { IPC4761_PRESET::IIIB, _( "Type III b ( plugged both sides )" ) },
  164. { IPC4761_PRESET::IIIA_INVERTED, _( "Type III a ( plugged bottom )" ) },
  165. { IPC4761_PRESET::IVA, _( "Type IV a ( plugged and tented top )" ) },
  166. { IPC4761_PRESET::IVB, _( "Type IV b ( plugged and tented both sides )" ) },
  167. { IPC4761_PRESET::IVA_INVERTED, _( "Type IV a ( plugged and tented bottom )" ) },
  168. { IPC4761_PRESET::V, _( "Type V ( filled )" ) },
  169. { IPC4761_PRESET::VIA, _( "Type VI a ( filled and tented top )" ) },
  170. { IPC4761_PRESET::VIB, _( "Type VI b ( filled and tented both sides )" ) },
  171. { IPC4761_PRESET::VIA_INVERTED, _( "Type VI a ( filled and tented bottom )" ) },
  172. { IPC4761_PRESET::VII, _( "Type VII ( filled and capped )" ) },
  173. { IPC4761_PRESET::CUSTOM, _( "Custom" ) },
  174. { IPC4761_PRESET::END, _( "End" ) }
  175. };
  176. };