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.

1234 lines
37 KiB

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
12 years ago
12 years ago
14 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
12 years ago
12 years ago
12 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
16 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. /**
  2. * @file dialog_pad_properties.cpp
  3. * @brief Pad editing functions and dialog pad editor.
  4. */
  5. /*
  6. * This program source code file is part of KiCad, a free EDA CAD application.
  7. *
  8. * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
  9. * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
  10. * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
  11. * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, you may find one here:
  25. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  26. * or you may search the http://www.gnu.org website for the version 2 license,
  27. * or you may write to the Free Software Foundation, Inc.,
  28. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  29. */
  30. #include <fctsys.h>
  31. #include <common.h>
  32. #include <gr_basic.h>
  33. #include <class_drawpanel.h>
  34. #include <confirm.h>
  35. #include <pcbnew.h>
  36. #include <trigo.h>
  37. #include <macros.h>
  38. #include <wxBasePcbFrame.h>
  39. #include <pcbcommon.h>
  40. #include <base_units.h>
  41. #include <wx/dcbuffer.h>
  42. #include <class_board.h>
  43. #include <class_module.h>
  44. #include <dialog_pad_properties_base.h>
  45. #include <html_messagebox.h>
  46. // list of pad shapes.
  47. static PAD_SHAPE_T code_shape[] = {
  48. PAD_CIRCLE,
  49. PAD_OVAL,
  50. PAD_RECT,
  51. PAD_TRAPEZOID
  52. };
  53. static PAD_ATTR_T code_type[] = {
  54. PAD_STANDARD,
  55. PAD_SMD,
  56. PAD_CONN,
  57. PAD_HOLE_NOT_PLATED
  58. };
  59. // Default mask layers setup for pads according to the pad type
  60. static const LSET std_pad_layers[] = {
  61. // PAD_STANDARD:
  62. D_PAD::StandardMask(),
  63. // PAD_SMD:
  64. D_PAD::SMDMask(),
  65. // PAD_CONN:
  66. D_PAD::ConnSMDMask(),
  67. // PAD_HOLE_NOT_PLATED:
  68. D_PAD::UnplatedHoleMask()
  69. };
  70. /**
  71. * class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
  72. * created by wxFormBuilder
  73. */
  74. class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
  75. {
  76. public:
  77. DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
  78. ~DIALOG_PAD_PROPERTIES()
  79. {
  80. delete m_dummyPad;
  81. }
  82. private:
  83. PCB_BASE_FRAME* m_parent;
  84. D_PAD* m_currentPad; // pad currently being edited
  85. D_PAD* m_dummyPad; // a working copy used to show changes
  86. D_PAD* m_padMaster; // The pad used to create new pads in board or
  87. // footprint editor
  88. BOARD* m_board; // the main board: this is the board handled by
  89. // the PCB editor, if running or the dummy
  90. // board used by the footprint editor
  91. // (could happen when the Footprint editor will be run
  92. // alone, outside the board editor
  93. bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
  94. // in this case, some Y coordinates values must be negated
  95. bool m_canUpdate;
  96. bool m_canEditNetName; // true only if the called is the board editor
  97. private:
  98. void initValues();
  99. bool padValuesOK(); ///< test if all values are acceptable for the pad
  100. void redraw();
  101. /**
  102. * Function setPadLayersList
  103. * updates the CheckBox states in pad layers list,
  104. * @param layer_mask = pad layer mask (ORed layers bit mask)
  105. */
  106. void setPadLayersList( LSET layer_mask );
  107. /// Copy values from dialog field to aPad's members
  108. bool transferDataToPad( D_PAD* aPad );
  109. // event handlers:
  110. void OnResize( wxSizeEvent& event );
  111. void OnPadShapeSelection( wxCommandEvent& event );
  112. void OnDrillShapeSelected( wxCommandEvent& event );
  113. void PadOrientEvent( wxCommandEvent& event );
  114. void PadTypeSelected( wxCommandEvent& event );
  115. void OnSetLayers( wxCommandEvent& event );
  116. void OnCancelButtonClick( wxCommandEvent& event );
  117. void OnPaintShowPanel( wxPaintEvent& event );
  118. /// Called when a dimension has changed.
  119. /// Update the graphical pad shown in the panel.
  120. void OnValuesChanged( wxCommandEvent& event );
  121. /// Updates the different parameters for the component being edited.
  122. /// Fired from the OK button click.
  123. void PadPropertiesAccept( wxCommandEvent& event );
  124. };
  125. void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
  126. {
  127. DIALOG_PAD_PROPERTIES dlg( this, aPad );
  128. dlg.ShowModal();
  129. }
  130. DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
  131. DIALOG_PAD_PROPERTIES_BASE( aParent )
  132. {
  133. m_canUpdate = false;
  134. m_parent = aParent;
  135. m_currentPad = aPad; // aPad can be NULL, if the dialog is called
  136. // from the module editor to set default pad characteristics
  137. m_board = m_parent->GetBoard();
  138. m_padMaster = &m_parent->GetDesignSettings().m_Pad_Master;
  139. m_dummyPad = new D_PAD( (MODULE*) NULL );
  140. if( aPad )
  141. m_dummyPad->Copy( aPad );
  142. else // We are editing a "master" pad, i.e. a pad used to create new pads
  143. m_dummyPad->Copy( m_padMaster );
  144. if( m_parent->IsGalCanvasActive() )
  145. {
  146. m_panelShowPadGal->UseColorScheme( m_board->GetColorsSettings() );
  147. m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
  148. #if !wxCHECK_VERSION( 3, 0, 0 )
  149. m_panelShowPadGal->SetSize( m_panelShowPad->GetSize() );
  150. #endif
  151. m_panelShowPadGal->Show();
  152. m_panelShowPad->Hide();
  153. m_panelShowPadGal->GetView()->Add( m_dummyPad );
  154. m_panelShowPadGal->StartDrawing();
  155. Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) );
  156. }
  157. else
  158. {
  159. m_panelShowPad->Show();
  160. m_panelShowPadGal->Hide();
  161. }
  162. initValues();
  163. m_sdbSizer1OK->SetDefault();
  164. GetSizer()->SetSizeHints( this );
  165. m_PadNumCtrl->SetFocus();
  166. m_canUpdate = true;
  167. }
  168. void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
  169. {
  170. wxPaintDC dc( m_panelShowPad );
  171. PAD_DRAWINFO drawInfo;
  172. EDA_COLOR_T color = BLACK;
  173. if( m_dummyPad->GetLayerSet()[F_Cu] )
  174. {
  175. color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
  176. }
  177. if( m_dummyPad->GetLayerSet()[B_Cu] )
  178. {
  179. color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
  180. }
  181. // What could happen: the pad color is *actually* black, or no
  182. // copper was selected
  183. if( color == BLACK )
  184. color = LIGHTGRAY;
  185. drawInfo.m_Color = color;
  186. drawInfo.m_HoleColor = DARKGRAY;
  187. drawInfo.m_Offset = m_dummyPad->GetPosition();
  188. drawInfo.m_Display_padnum = true;
  189. drawInfo.m_Display_netname = true;
  190. if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
  191. drawInfo.m_ShowNotPlatedHole = true;
  192. // Shows the local pad clearance
  193. drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();
  194. wxSize dc_size = dc.GetSize();
  195. dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
  196. // Calculate a suitable scale to fit the available draw area
  197. int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y );
  198. // Invalid x size. User could enter zero, or have deleted all text prior to
  199. // entering a new value; this is also treated as zero. If dim is left at
  200. // zero, the drawing scale is zero and we get a crash.
  201. if( dim == 0 )
  202. {
  203. // If drill size has been set, use that. Otherwise default to 1mm.
  204. dim = m_dummyPad->GetDrillSize().x;
  205. if( dim == 0 )
  206. dim = 1000000;
  207. }
  208. if( m_dummyPad->GetLocalClearance() > 0 )
  209. dim += m_dummyPad->GetLocalClearance() * 2;
  210. double scale = (double) dc_size.x / dim;
  211. // If the pad is a circle, use the x size here instead.
  212. int ysize;
  213. if( m_dummyPad->GetShape() == PAD_CIRCLE )
  214. ysize = m_dummyPad->GetSize().x;
  215. else
  216. ysize = m_dummyPad->GetSize().y;
  217. dim = ysize + std::abs( m_dummyPad->GetDelta().x );
  218. // Invalid y size. See note about x size above.
  219. if( dim == 0 )
  220. {
  221. dim = m_dummyPad->GetDrillSize().y;
  222. if( dim == 0 )
  223. dim = 1000000;
  224. }
  225. if( m_dummyPad->GetLocalClearance() > 0 )
  226. dim += m_dummyPad->GetLocalClearance() * 2;
  227. double altscale = (double) dc_size.y / dim;
  228. scale = std::min( scale, altscale );
  229. // Give a margin
  230. scale *= 0.7;
  231. dc.SetUserScale( scale, scale );
  232. GRResetPenAndBrush( &dc );
  233. m_dummyPad->DrawShape( NULL, &dc, drawInfo );
  234. // Draw X and Y axis.
  235. // this is particularly useful to show the reference position of pads
  236. // with offset and no hole
  237. GRLine( NULL, &dc, -dim, 0, dim, 0, 0, BLUE ); // X axis
  238. GRLine( NULL, &dc, 0, -dim, 0, dim, 0, BLUE ); // Y axis
  239. event.Skip();
  240. }
  241. void DIALOG_PAD_PROPERTIES::initValues()
  242. {
  243. wxString msg;
  244. double angle;
  245. // Disable pad net name wxTextCtrl if the caller is the footprint editor
  246. // because nets are living only in the board managed by the board editor
  247. m_canEditNetName = m_parent->IsType( FRAME_PCB );
  248. // Setup layers names from board
  249. // Should be made first, before calling m_rbCopperLayersSel->SetSelection()
  250. m_rbCopperLayersSel->SetString( 0, m_board->GetLayerName( F_Cu ) );
  251. m_rbCopperLayersSel->SetString( 1, m_board->GetLayerName( B_Cu ) );
  252. m_PadLayerAdhCmp->SetLabel( m_board->GetLayerName( F_Adhes ) );
  253. m_PadLayerAdhCu->SetLabel( m_board->GetLayerName( B_Adhes ) );
  254. m_PadLayerPateCmp->SetLabel( m_board->GetLayerName( F_Paste ) );
  255. m_PadLayerPateCu->SetLabel( m_board->GetLayerName( B_Paste ) );
  256. m_PadLayerSilkCmp->SetLabel( m_board->GetLayerName( F_SilkS ) );
  257. m_PadLayerSilkCu->SetLabel( m_board->GetLayerName( B_SilkS ) );
  258. m_PadLayerMaskCmp->SetLabel( m_board->GetLayerName( F_Mask ) );
  259. m_PadLayerMaskCu->SetLabel( m_board->GetLayerName( B_Mask ) );
  260. m_PadLayerECO1->SetLabel( m_board->GetLayerName( Eco1_User ) );
  261. m_PadLayerECO2->SetLabel( m_board->GetLayerName( Eco2_User ) );
  262. m_PadLayerDraft->SetLabel( m_board->GetLayerName( Dwgs_User ) );
  263. m_isFlipped = false;
  264. if( m_currentPad )
  265. {
  266. MODULE* module = m_currentPad->GetParent();
  267. if( module->GetLayer() == B_Cu )
  268. {
  269. m_isFlipped = true;
  270. m_staticModuleSideValue->SetLabel( _( "Back side (footprint is mirrored)" ) );
  271. }
  272. msg.Printf( wxT( "%.1f" ), module->GetOrientation() / 10.0 );
  273. m_staticModuleRotValue->SetLabel( msg );
  274. }
  275. if( m_isFlipped )
  276. {
  277. wxPoint pt = m_dummyPad->GetOffset();
  278. NEGATE( pt.y );
  279. m_dummyPad->SetOffset( pt );
  280. wxSize sz = m_dummyPad->GetDelta();
  281. NEGATE( sz.y );
  282. m_dummyPad->SetDelta( sz );
  283. // flip pad's layers
  284. m_dummyPad->SetLayerSet( FlipLayerMask( m_dummyPad->GetLayerSet() ) );
  285. }
  286. m_staticTextWarningPadFlipped->Show(m_isFlipped);
  287. m_PadNumCtrl->SetValue( m_dummyPad->GetPadName() );
  288. m_PadNetNameCtrl->SetValue( m_dummyPad->GetNetname() );
  289. // Display current unit name in dialog:
  290. m_PadPosX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  291. m_PadPosY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  292. m_PadDrill_X_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  293. m_PadDrill_Y_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  294. m_PadShapeSizeX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  295. m_PadShapeSizeY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  296. m_PadShapeOffsetX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  297. m_PadShapeOffsetY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  298. m_PadShapeDelta_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  299. m_PadLengthDie_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  300. // Display current pad masks clearances units
  301. m_NetClearanceUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  302. m_SolderMaskMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  303. m_SolderPasteMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  304. m_ThermalWidthUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  305. m_ThermalGapUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  306. // Display current pad parameters units:
  307. PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x );
  308. PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y );
  309. PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x );
  310. PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y );
  311. PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x );
  312. PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y );
  313. PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x );
  314. PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->GetOffset().y );
  315. if( m_dummyPad->GetDelta().x )
  316. {
  317. PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x );
  318. m_trapDeltaDirChoice->SetSelection( 0 );
  319. }
  320. else
  321. {
  322. PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().y );
  323. m_trapDeltaDirChoice->SetSelection( 1 );
  324. }
  325. PutValueInLocalUnits( *m_LengthPadToDieCtrl, m_dummyPad->GetPadToDieLength() );
  326. PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->GetLocalClearance() );
  327. PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_dummyPad->GetLocalSolderMaskMargin() );
  328. PutValueInLocalUnits( *m_ThermalWidthCtrl, m_dummyPad->GetThermalWidth() );
  329. PutValueInLocalUnits( *m_ThermalGapCtrl, m_dummyPad->GetThermalGap() );
  330. // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
  331. PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_dummyPad->GetLocalSolderPasteMargin() );
  332. if( m_dummyPad->GetLocalSolderPasteMargin() == 0 )
  333. m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
  334. msg.Printf( wxT( "%f" ), m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
  335. if( m_dummyPad->GetLocalSolderPasteMarginRatio() == 0.0 && msg[0] == '0' )
  336. // Sometimes Printf adds a sign if the value is small
  337. m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
  338. else
  339. m_SolderPasteMarginRatioCtrl->SetValue( msg );
  340. switch( m_dummyPad->GetZoneConnection() )
  341. {
  342. default:
  343. case UNDEFINED_CONNECTION:
  344. m_ZoneConnectionChoice->SetSelection( 0 );
  345. break;
  346. case PAD_IN_ZONE:
  347. m_ZoneConnectionChoice->SetSelection( 1 );
  348. break;
  349. case THERMAL_PAD:
  350. m_ZoneConnectionChoice->SetSelection( 2 );
  351. break;
  352. case PAD_NOT_IN_ZONE:
  353. m_ZoneConnectionChoice->SetSelection( 3 );
  354. break;
  355. }
  356. if( m_currentPad )
  357. {
  358. MODULE* module = m_currentPad->GetParent();
  359. angle = m_currentPad->GetOrientation() - module->GetOrientation();
  360. if( m_isFlipped )
  361. NEGATE( angle );
  362. m_dummyPad->SetOrientation( angle );
  363. }
  364. angle = m_dummyPad->GetOrientation();
  365. NORMALIZE_ANGLE_180( angle ); // ? normalizing is in D_PAD::SetOrientation()
  366. // Set layers used by this pad: :
  367. setPadLayersList( m_dummyPad->GetLayerSet() );
  368. // Pad Orient
  369. switch( int( angle ) )
  370. {
  371. case 0:
  372. m_PadOrient->SetSelection( 0 );
  373. break;
  374. case 900:
  375. m_PadOrient->SetSelection( 1 );
  376. break;
  377. case -900:
  378. m_PadOrient->SetSelection( 2 );
  379. break;
  380. case 1800:
  381. case -1800:
  382. m_PadOrient->SetSelection( 3 );
  383. break;
  384. default:
  385. m_PadOrient->SetSelection( 4 );
  386. break;
  387. }
  388. switch( m_dummyPad->GetShape() )
  389. {
  390. default:
  391. case PAD_CIRCLE:
  392. m_PadShape->SetSelection( 0 );
  393. break;
  394. case PAD_OVAL:
  395. m_PadShape->SetSelection( 1 );
  396. break;
  397. case PAD_RECT:
  398. m_PadShape->SetSelection( 2 );
  399. break;
  400. case PAD_TRAPEZOID:
  401. m_PadShape->SetSelection( 3 );
  402. break;
  403. }
  404. msg.Printf( wxT( "%g" ), angle );
  405. m_PadOrientCtrl->SetValue( msg );
  406. // Type of pad selection
  407. m_PadType->SetSelection( 0 );
  408. for( unsigned ii = 0; ii < DIM( code_type ); ii++ )
  409. {
  410. if( code_type[ii] == m_dummyPad->GetAttribute() )
  411. {
  412. m_PadType->SetSelection( ii );
  413. break;
  414. }
  415. }
  416. // Enable/disable Pad name,and pad length die
  417. // (disable for NPTH pads (mechanical pads)
  418. bool enable = m_dummyPad->GetAttribute() != PAD_HOLE_NOT_PLATED;
  419. m_PadNumCtrl->Enable( enable );
  420. m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
  421. m_LengthPadToDieCtrl->Enable( enable );
  422. if( m_dummyPad->GetDrillShape() != PAD_DRILL_OBLONG )
  423. m_DrillShapeCtrl->SetSelection( 0 );
  424. else
  425. m_DrillShapeCtrl->SetSelection( 1 );
  426. // Update some dialog widgets state (Enable/disable options):
  427. wxCommandEvent cmd_event;
  428. setPadLayersList( m_dummyPad->GetLayerSet() );
  429. OnDrillShapeSelected( cmd_event );
  430. OnPadShapeSelection( cmd_event );
  431. }
  432. void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event )
  433. {
  434. redraw();
  435. event.Skip();
  436. }
  437. void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
  438. {
  439. switch( m_PadShape->GetSelection() )
  440. {
  441. case 0: // CIRCLE:
  442. m_ShapeDelta_Ctrl->Enable( false );
  443. m_trapDeltaDirChoice->Enable( false );
  444. m_ShapeSize_Y_Ctrl->Enable( false );
  445. m_ShapeOffset_X_Ctrl->Enable( false );
  446. m_ShapeOffset_Y_Ctrl->Enable( false );
  447. break;
  448. case 1: // OVAL:
  449. m_ShapeDelta_Ctrl->Enable( false );
  450. m_trapDeltaDirChoice->Enable( false );
  451. m_ShapeSize_Y_Ctrl->Enable( true );
  452. m_ShapeOffset_X_Ctrl->Enable( true );
  453. m_ShapeOffset_Y_Ctrl->Enable( true );
  454. break;
  455. case 2: // PAD_RECT:
  456. m_ShapeDelta_Ctrl->Enable( false );
  457. m_trapDeltaDirChoice->Enable( false );
  458. m_ShapeSize_Y_Ctrl->Enable( true );
  459. m_ShapeOffset_X_Ctrl->Enable( true );
  460. m_ShapeOffset_Y_Ctrl->Enable( true );
  461. break;
  462. case 3: // TRAPEZOID:
  463. m_ShapeDelta_Ctrl->Enable( true );
  464. m_trapDeltaDirChoice->Enable( true );
  465. m_ShapeSize_Y_Ctrl->Enable( true );
  466. m_ShapeOffset_X_Ctrl->Enable( true );
  467. m_ShapeOffset_Y_Ctrl->Enable( true );
  468. break;
  469. }
  470. transferDataToPad( m_dummyPad );
  471. redraw();
  472. }
  473. void DIALOG_PAD_PROPERTIES::OnDrillShapeSelected( wxCommandEvent& event )
  474. {
  475. if( m_PadType->GetSelection() == 1 || m_PadType->GetSelection() == 2 )
  476. {
  477. // pad type = SMD or CONN: no hole allowed
  478. m_PadDrill_X_Ctrl->Enable( false );
  479. m_PadDrill_Y_Ctrl->Enable( false );
  480. }
  481. else
  482. {
  483. switch( m_DrillShapeCtrl->GetSelection() )
  484. {
  485. case 0: //CIRCLE:
  486. m_PadDrill_X_Ctrl->Enable( true );
  487. m_PadDrill_Y_Ctrl->Enable( false );
  488. break;
  489. case 1: //OVALE:
  490. m_PadDrill_X_Ctrl->Enable( true );
  491. m_PadDrill_Y_Ctrl->Enable( true );
  492. break;
  493. }
  494. }
  495. transferDataToPad( m_dummyPad );
  496. redraw();
  497. }
  498. void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
  499. {
  500. switch( m_PadOrient->GetSelection() )
  501. {
  502. case 0:
  503. m_dummyPad->SetOrientation( 0 );
  504. break;
  505. case 1:
  506. m_dummyPad->SetOrientation( 900 );
  507. break;
  508. case 2:
  509. m_dummyPad->SetOrientation( -900 );
  510. break;
  511. case 3:
  512. m_dummyPad->SetOrientation( 1800 );
  513. break;
  514. default:
  515. break;
  516. }
  517. wxString msg;
  518. msg.Printf( wxT( "%g" ), m_dummyPad->GetOrientation() );
  519. m_PadOrientCtrl->SetValue( msg );
  520. transferDataToPad( m_dummyPad );
  521. redraw();
  522. }
  523. void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
  524. {
  525. unsigned ii = m_PadType->GetSelection();
  526. if( ii >= DIM( code_type ) ) // catches < 0 also
  527. ii = 0;
  528. LSET layer_mask = std_pad_layers[ii];
  529. setPadLayersList( layer_mask );
  530. // Enable/disable drill dialog items:
  531. event.SetId( m_DrillShapeCtrl->GetSelection() );
  532. OnDrillShapeSelected( event );
  533. if( ii == 0 || ii == DIM( code_type )-1 )
  534. m_DrillShapeCtrl->Enable( true );
  535. else
  536. m_DrillShapeCtrl->Enable( false );
  537. // Enable/disable Pad name,and pad length die
  538. // (disable for NPTH pads (mechanical pads)
  539. bool enable = ii != 3;
  540. m_PadNumCtrl->Enable( enable );
  541. m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
  542. m_LengthPadToDieCtrl->Enable( enable );
  543. }
  544. void DIALOG_PAD_PROPERTIES::setPadLayersList( LSET layer_mask )
  545. {
  546. LSET cu_set = layer_mask & LSET::AllCuMask();
  547. if( cu_set == LSET( F_Cu ) )
  548. m_rbCopperLayersSel->SetSelection( 0 );
  549. else if( cu_set == LSET( B_Cu ) )
  550. m_rbCopperLayersSel->SetSelection( 1 );
  551. else if( cu_set.any() )
  552. m_rbCopperLayersSel->SetSelection( 2 );
  553. else
  554. m_rbCopperLayersSel->SetSelection( 3 );
  555. m_PadLayerAdhCmp->SetValue( layer_mask[F_Adhes] );
  556. m_PadLayerAdhCu->SetValue( layer_mask[B_Adhes] );
  557. m_PadLayerPateCmp->SetValue( layer_mask[F_Paste] );
  558. m_PadLayerPateCu->SetValue( layer_mask[B_Paste] );
  559. m_PadLayerSilkCmp->SetValue( layer_mask[F_SilkS] );
  560. m_PadLayerSilkCu->SetValue( layer_mask[B_SilkS] );
  561. m_PadLayerMaskCmp->SetValue( layer_mask[F_Mask] );
  562. m_PadLayerMaskCu->SetValue( layer_mask[B_Mask] );
  563. m_PadLayerECO1->SetValue( layer_mask[Eco1_User] );
  564. m_PadLayerECO2->SetValue( layer_mask[Eco2_User] );
  565. m_PadLayerDraft->SetValue( layer_mask[Dwgs_User] );
  566. }
  567. // Called when select/deselect a layer.
  568. void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
  569. {
  570. transferDataToPad( m_dummyPad );
  571. redraw();
  572. }
  573. // test if all values are acceptable for the pad
  574. bool DIALOG_PAD_PROPERTIES::padValuesOK()
  575. {
  576. bool error = transferDataToPad( m_dummyPad );
  577. wxArrayString error_msgs;
  578. wxString msg;
  579. // Test for incorrect values
  580. if( (m_dummyPad->GetSize().x <= 0) ||
  581. ((m_dummyPad->GetSize().y <= 0) && (m_dummyPad->GetShape() != PAD_CIRCLE)) )
  582. {
  583. error_msgs.Add( _( "Pad size must be greater than zero" ) );
  584. }
  585. if( (m_dummyPad->GetSize().x < m_dummyPad->GetDrillSize().x) ||
  586. (m_dummyPad->GetSize().y < m_dummyPad->GetDrillSize().y) )
  587. {
  588. error_msgs.Add( _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
  589. }
  590. LSET padlayers_mask = m_dummyPad->GetLayerSet();
  591. if( padlayers_mask == 0 )
  592. error_msgs.Add( _( "Error: pad has no layer" ) );
  593. if( !padlayers_mask[F_Cu] && !padlayers_mask[B_Cu] )
  594. {
  595. if( m_dummyPad->GetDrillSize().x || m_dummyPad->GetDrillSize().y )
  596. {
  597. // Note: he message is shown in an HTML window
  598. msg = _( "Error: the pad is not on a copper layer and has a hole" );
  599. if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
  600. {
  601. msg += wxT( "<br><br><i>" );
  602. msg += _( "For NPTH pad, set pad size value to pad drill value,"
  603. " if you do not want this pad plotted in gerber files"
  604. );
  605. }
  606. error_msgs.Add( msg );
  607. }
  608. }
  609. wxPoint max_size;
  610. max_size.x = std::abs( m_dummyPad->GetOffset().x );
  611. max_size.y = std::abs( m_dummyPad->GetOffset().y );
  612. max_size.x += m_dummyPad->GetDrillSize().x / 2;
  613. max_size.y += m_dummyPad->GetDrillSize().y / 2;
  614. if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||
  615. ( m_dummyPad->GetSize().y / 2 < max_size.y ) )
  616. {
  617. error_msgs.Add( _( "Incorrect value for pad offset" ) );
  618. }
  619. if( error )
  620. {
  621. error_msgs.Add( _( "Too large value for pad delta size" ) );
  622. }
  623. switch( m_dummyPad->GetAttribute() )
  624. {
  625. case PAD_HOLE_NOT_PLATED: // Not plated, but through hole, a hole is expected
  626. case PAD_STANDARD : // Pad through hole, a hole is also expected
  627. if( m_dummyPad->GetDrillSize().x <= 0 )
  628. error_msgs.Add( _( "Error: Through hole pad: drill diameter set to 0" ) );
  629. break;
  630. case PAD_CONN: // Connector pads are smd pads, just they do not have solder paste.
  631. if( padlayers_mask[B_Paste] || padlayers_mask[F_Paste] )
  632. error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n"
  633. "Use SMD pads instead" ) );
  634. // Fall trough
  635. case PAD_SMD: // SMD and Connector pads (One external copper layer only)
  636. /*
  637. if( padlayers_mask[B_Cu] && padlayers_mask[F_Cu] )
  638. error_msgs.Add( _( "Error: only one copper layer allowed for SMD or Connector pads" ) );
  639. */
  640. break;
  641. }
  642. if( error_msgs.GetCount() )
  643. {
  644. HTML_MESSAGE_BOX dlg( this, _("Pad setup errors list" ) );
  645. dlg.ListSet( error_msgs );
  646. dlg.ShowModal();
  647. }
  648. return error_msgs.GetCount() == 0;
  649. }
  650. void DIALOG_PAD_PROPERTIES::redraw()
  651. {
  652. if( m_parent->IsGalCanvasActive() )
  653. {
  654. m_dummyPad->ViewUpdate();
  655. BOX2I bbox = m_dummyPad->ViewBBox();
  656. if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
  657. {
  658. // Autozoom
  659. m_panelShowPadGal->GetView()->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
  660. // Add a margin
  661. m_panelShowPadGal->GetView()->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
  662. m_panelShowPadGal->Refresh();
  663. }
  664. }
  665. else
  666. {
  667. m_panelShowPad->Refresh();
  668. }
  669. }
  670. void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
  671. {
  672. if( !padValuesOK() )
  673. return;
  674. bool rastnestIsChanged = false;
  675. int isign = m_isFlipped ? -1 : 1;
  676. transferDataToPad( m_padMaster );
  677. // m_padMaster is a pattern: ensure there is no net for this pad:
  678. m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
  679. if( m_currentPad ) // Set current Pad parameters
  680. {
  681. wxSize size;
  682. MODULE* module = m_currentPad->GetParent();
  683. m_parent->SaveCopyInUndoList( module, UR_CHANGED );
  684. module->SetLastEditTime();
  685. // redraw the area where the pad was, without pad (delete pad on screen)
  686. m_currentPad->SetFlags( DO_NOT_DRAW );
  687. m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
  688. m_currentPad->ClearFlags( DO_NOT_DRAW );
  689. // Update values
  690. m_currentPad->SetShape( m_padMaster->GetShape() );
  691. m_currentPad->SetAttribute( m_padMaster->GetAttribute() );
  692. if( m_currentPad->GetPosition() != m_padMaster->GetPosition() )
  693. {
  694. m_currentPad->SetPosition( m_padMaster->GetPosition() );
  695. rastnestIsChanged = true;
  696. }
  697. // compute the pos 0 value, i.e. pad position for module with orientation = 0
  698. // i.e. relative to module origin (module position)
  699. wxPoint pt = m_currentPad->GetPosition() - module->GetPosition();
  700. RotatePoint( &pt, -module->GetOrientation() );
  701. m_currentPad->SetPos0( pt );
  702. m_currentPad->SetOrientation( m_padMaster->GetOrientation() * isign + module->GetOrientation() );
  703. m_currentPad->SetSize( m_padMaster->GetSize() );
  704. size = m_padMaster->GetDelta();
  705. size.y *= isign;
  706. m_currentPad->SetDelta( size );
  707. m_currentPad->SetDrillSize( m_padMaster->GetDrillSize() );
  708. m_currentPad->SetDrillShape( m_padMaster->GetDrillShape() );
  709. wxPoint offset = m_padMaster->GetOffset();
  710. offset.y *= isign;
  711. m_currentPad->SetOffset( offset );
  712. m_currentPad->SetPadToDieLength( m_padMaster->GetPadToDieLength() );
  713. if( m_currentPad->GetLayerSet() != m_padMaster->GetLayerSet() )
  714. {
  715. rastnestIsChanged = true;
  716. m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() );
  717. }
  718. if( m_isFlipped )
  719. m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
  720. m_currentPad->SetPadName( m_padMaster->GetPadName() );
  721. wxString padNetname;
  722. // For PAD_HOLE_NOT_PLATED, ensure there is no net name selected
  723. if( m_padMaster->GetAttribute() != PAD_HOLE_NOT_PLATED )
  724. padNetname = m_PadNetNameCtrl->GetValue();
  725. if( m_currentPad->GetNetname() != padNetname )
  726. {
  727. const NETINFO_ITEM* netinfo = m_board->FindNet( padNetname );
  728. if( !padNetname.IsEmpty() && netinfo == NULL )
  729. {
  730. DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
  731. }
  732. else
  733. {
  734. rastnestIsChanged = true;
  735. m_currentPad->SetNetCode( netinfo->GetNet() );
  736. }
  737. }
  738. m_currentPad->SetLocalClearance( m_padMaster->GetLocalClearance() );
  739. m_currentPad->SetLocalSolderMaskMargin( m_padMaster->GetLocalSolderMaskMargin() );
  740. m_currentPad->SetLocalSolderPasteMargin( m_padMaster->GetLocalSolderPasteMargin() );
  741. m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster->GetLocalSolderPasteMarginRatio() );
  742. m_currentPad->SetZoneConnection( m_padMaster->GetZoneConnection() );
  743. m_currentPad->SetThermalWidth( m_padMaster->GetThermalWidth() );
  744. m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
  745. module->CalculateBoundingBox();
  746. m_parent->SetMsgPanel( m_currentPad );
  747. // redraw the area where the pad was
  748. m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
  749. m_parent->OnModify();
  750. }
  751. EndModal( wxID_OK );
  752. if( rastnestIsChanged ) // The net ratsnest must be recalculated
  753. m_board->m_Status_Pcb = 0;
  754. }
  755. bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
  756. {
  757. wxString msg;
  758. int x, y;
  759. aPad->SetAttribute( code_type[m_PadType->GetSelection()] );
  760. aPad->SetShape( code_shape[m_PadShape->GetSelection()] );
  761. // Read pad clearances values:
  762. aPad->SetLocalClearance( ValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
  763. aPad->SetLocalSolderMaskMargin( ValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
  764. aPad->SetLocalSolderPasteMargin( ValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
  765. aPad->SetThermalWidth( ValueFromTextCtrl( *m_ThermalWidthCtrl ) );
  766. aPad->SetThermalGap( ValueFromTextCtrl( *m_ThermalGapCtrl ) );
  767. double dtmp = 0.0;
  768. msg = m_SolderPasteMarginRatioCtrl->GetValue();
  769. msg.ToDouble( &dtmp );
  770. // A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
  771. if( dtmp < -50.0 )
  772. dtmp = -50.0;
  773. // A margin ratio is always <= 0
  774. // 0 means use full pad copper area
  775. if( dtmp > 0.0 )
  776. dtmp = 0.0;
  777. aPad->SetLocalSolderPasteMarginRatio( dtmp / 100 );
  778. switch( m_ZoneConnectionChoice->GetSelection() )
  779. {
  780. default:
  781. case 0:
  782. aPad->SetZoneConnection( UNDEFINED_CONNECTION );
  783. break;
  784. case 1:
  785. aPad->SetZoneConnection( PAD_IN_ZONE );
  786. break;
  787. case 2:
  788. aPad->SetZoneConnection( THERMAL_PAD );
  789. break;
  790. case 3:
  791. aPad->SetZoneConnection( PAD_NOT_IN_ZONE );
  792. break;
  793. }
  794. // Read pad position:
  795. x = ValueFromTextCtrl( *m_PadPosition_X_Ctrl );
  796. y = ValueFromTextCtrl( *m_PadPosition_Y_Ctrl );
  797. aPad->SetPosition( wxPoint( x, y ) );
  798. aPad->SetPos0( wxPoint( x, y ) );
  799. // Read pad drill:
  800. x = ValueFromTextCtrl( *m_PadDrill_X_Ctrl );
  801. y = ValueFromTextCtrl( *m_PadDrill_Y_Ctrl );
  802. if( m_DrillShapeCtrl->GetSelection() == 0 )
  803. {
  804. aPad->SetDrillShape( PAD_DRILL_CIRCLE );
  805. y = x;
  806. }
  807. else
  808. aPad->SetDrillShape( PAD_DRILL_OBLONG );
  809. aPad->SetDrillSize( wxSize( x, y ) );
  810. // Read pad shape size:
  811. x = ValueFromTextCtrl( *m_ShapeSize_X_Ctrl );
  812. y = ValueFromTextCtrl( *m_ShapeSize_Y_Ctrl );
  813. if( aPad->GetShape() == PAD_CIRCLE )
  814. y = x;
  815. aPad->SetSize( wxSize( x, y ) );
  816. // Read pad length die
  817. aPad->SetPadToDieLength( ValueFromTextCtrl( *m_LengthPadToDieCtrl ) );
  818. // Read pad shape delta size:
  819. // m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid.
  820. wxSize delta;
  821. if( m_trapDeltaDirChoice->GetSelection() == 0 )
  822. delta.x = ValueFromTextCtrl( *m_ShapeDelta_Ctrl );
  823. else
  824. delta.y = ValueFromTextCtrl( *m_ShapeDelta_Ctrl );
  825. // Test bad values (be sure delta values are not too large)
  826. // remember DeltaSize.x is the Y size variation
  827. bool error = false;
  828. if( delta.x < 0 && delta.x <= -aPad->GetSize().y )
  829. {
  830. delta.x = -aPad->GetSize().y + 2;
  831. error = true;
  832. }
  833. if( delta.x > 0 && delta.x >= aPad->GetSize().y )
  834. {
  835. delta.x = aPad->GetSize().y - 2;
  836. error = true;
  837. }
  838. if( delta.y < 0 && delta.y <= -aPad->GetSize().x )
  839. {
  840. delta.y = -aPad->GetSize().x + 2;
  841. error = true;
  842. }
  843. if( delta.y > 0 && delta.y >= aPad->GetSize().x )
  844. {
  845. delta.y = aPad->GetSize().x - 2;
  846. error = true;
  847. }
  848. aPad->SetDelta( delta );
  849. // Read pad shape offset:
  850. x = ValueFromTextCtrl( *m_ShapeOffset_X_Ctrl );
  851. y = ValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl );
  852. aPad->SetOffset( wxPoint( x, y ) );
  853. double orient_value = 0;
  854. msg = m_PadOrientCtrl->GetValue();
  855. msg.ToDouble( &orient_value );
  856. aPad->SetOrientation( orient_value );
  857. msg = m_PadNumCtrl->GetValue().Left( 4 );
  858. aPad->SetPadName( msg );
  859. // Check if user has set an existing net name
  860. const NETINFO_ITEM* netinfo = m_board->FindNet( m_PadNetNameCtrl->GetValue() );
  861. if( netinfo != NULL )
  862. aPad->SetNetCode( netinfo->GetNet() );
  863. else
  864. aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
  865. // Clear some values, according to the pad type and shape
  866. switch( aPad->GetShape() )
  867. {
  868. case PAD_CIRCLE:
  869. aPad->SetOffset( wxPoint( 0, 0 ) );
  870. aPad->SetDelta( wxSize( 0, 0 ) );
  871. x = aPad->GetSize().x;
  872. aPad->SetSize( wxSize( x, x ) );
  873. break;
  874. case PAD_RECT:
  875. aPad->SetDelta( wxSize( 0, 0 ) );
  876. break;
  877. case PAD_OVAL:
  878. aPad->SetDelta( wxSize( 0, 0 ) );
  879. break;
  880. case PAD_TRAPEZOID:
  881. break;
  882. default:
  883. ;
  884. }
  885. switch( aPad->GetAttribute() )
  886. {
  887. case PAD_STANDARD:
  888. break;
  889. case PAD_CONN:
  890. case PAD_SMD:
  891. // SMD and PAD_CONN has no hole.
  892. // basically, SMD and PAD_CONN are same type of pads
  893. // PAD_CONN has just a default non technical layers that differs from SMD
  894. // and are intended to be used in virtual edge board connectors
  895. // However we can accept a non null offset,
  896. // mainly to allow complex pads build from a set of from basic pad shapes
  897. aPad->SetDrillSize( wxSize( 0, 0 ) );
  898. break;
  899. case PAD_HOLE_NOT_PLATED:
  900. // Mechanical purpose only:
  901. // no offset, no net name, no pad name allowed
  902. aPad->SetOffset( wxPoint( 0, 0 ) );
  903. aPad->SetPadName( wxEmptyString );
  904. aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
  905. break;
  906. default:
  907. DisplayError( NULL, wxT( "Error: unknown pad type" ) );
  908. break;
  909. }
  910. LSET padLayerMask;
  911. switch( m_rbCopperLayersSel->GetSelection() )
  912. {
  913. case 0:
  914. padLayerMask.set( F_Cu );
  915. break;
  916. case 1:
  917. padLayerMask.set( B_Cu );
  918. break;
  919. case 2:
  920. padLayerMask |= LSET::AllCuMask();
  921. break;
  922. case 3: // No copper layers
  923. break;
  924. }
  925. if( m_PadLayerAdhCmp->GetValue() )
  926. padLayerMask.set( F_Adhes );
  927. if( m_PadLayerAdhCu->GetValue() )
  928. padLayerMask.set( B_Adhes );
  929. if( m_PadLayerPateCmp->GetValue() )
  930. padLayerMask.set( F_Paste );
  931. if( m_PadLayerPateCu->GetValue() )
  932. padLayerMask.set( B_Paste );
  933. if( m_PadLayerSilkCmp->GetValue() )
  934. padLayerMask.set( F_SilkS );
  935. if( m_PadLayerSilkCu->GetValue() )
  936. padLayerMask.set( B_SilkS );
  937. if( m_PadLayerMaskCmp->GetValue() )
  938. padLayerMask.set( F_Mask );
  939. if( m_PadLayerMaskCu->GetValue() )
  940. padLayerMask.set( B_Mask );
  941. if( m_PadLayerECO1->GetValue() )
  942. padLayerMask.set( Eco1_User );
  943. if( m_PadLayerECO2->GetValue() )
  944. padLayerMask.set( Eco2_User );
  945. if( m_PadLayerDraft->GetValue() )
  946. padLayerMask.set( Dwgs_User );
  947. aPad->SetLayerSet( padLayerMask );
  948. return error;
  949. }
  950. void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
  951. {
  952. if( m_canUpdate )
  953. {
  954. transferDataToPad( m_dummyPad );
  955. redraw();
  956. }
  957. }
  958. void DIALOG_PAD_PROPERTIES::OnCancelButtonClick( wxCommandEvent& event )
  959. {
  960. EndModal( wxID_CANCEL );
  961. }