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.

137 lines
4.8 KiB

  1. /**
  2. * @file dialog_pad_properties.cpp
  3. * @brief dialog pad properties editor.
  4. */
  5. /*
  6. * This program source code file is part of KiCad, a free EDA CAD application.
  7. *
  8. * Copyright (C) 2016 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-2016 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. #ifndef _DIALOG_PAD_PROPERTIES_H_
  31. #define _DIALOG_PAD_PROPERTIES_H_
  32. #include <fctsys.h>
  33. #include <common.h>
  34. #include <class_drawpanel.h>
  35. #include <pcbnew.h>
  36. #include <wxBasePcbFrame.h>
  37. #include <pcbcommon.h>
  38. #include <base_units.h>
  39. #include <wx/valnum.h>
  40. #include <class_board.h>
  41. #include <class_module.h>
  42. #include <origin_viewitem.h>
  43. #include <dialog_pad_properties_base.h>
  44. /**
  45. * class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
  46. * created by wxFormBuilder
  47. */
  48. class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
  49. {
  50. public:
  51. DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
  52. ~DIALOG_PAD_PROPERTIES()
  53. {
  54. delete m_dummyPad;
  55. delete m_axisOrigin;
  56. }
  57. private:
  58. PCB_BASE_FRAME* m_parent;
  59. KIGFX::ORIGIN_VIEWITEM* m_axisOrigin;
  60. D_PAD* m_currentPad; // pad currently being edited
  61. D_PAD* m_dummyPad; // a working copy used to show changes
  62. D_PAD* m_padMaster; // The pad used to create new pads in board or
  63. // footprint editor
  64. BOARD* m_board; // the main board: this is the board handled by
  65. // the PCB editor, if running or the dummy
  66. // board used by the footprint editor
  67. // (could happen when the Footprint editor will be run
  68. // alone, outside the board editor
  69. bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
  70. // in this case, some Y coordinates values must be negated
  71. bool m_canUpdate;
  72. bool m_canEditNetName; // true only if the caller is the board editor
  73. wxFloatingPointValidator<double> m_OrientValidator;
  74. double m_OrientValue;
  75. private:
  76. void initValues();
  77. bool padValuesOK(); ///< test if all values are acceptable for the pad
  78. void redraw();
  79. void updateRoundRectCornerValues();
  80. /**
  81. * Function setPadLayersList
  82. * updates the CheckBox states in pad layers list,
  83. * @param layer_mask = pad layer mask (ORed layers bit mask)
  84. */
  85. void setPadLayersList( LSET layer_mask );
  86. /// Copy values from dialog field to aPad's members
  87. bool transferDataToPad( D_PAD* aPad );
  88. // event handlers:
  89. void OnResize( wxSizeEvent& event );
  90. void OnPadShapeSelection( wxCommandEvent& event );
  91. void OnDrillShapeSelected( wxCommandEvent& event );
  92. void PadOrientEvent( wxCommandEvent& event );
  93. void PadTypeSelected( wxCommandEvent& event );
  94. void OnSetLayers( wxCommandEvent& event );
  95. void OnPaintShowPanel( wxPaintEvent& event );
  96. // Called when corner setup value is changed for rounded rect pads
  97. void onCornerSizePercentChange( wxCommandEvent& event );
  98. /// Called when a dimension has changed.
  99. /// Update the graphical pad shown in the panel.
  100. void OnValuesChanged( wxCommandEvent& event );
  101. void OnInitDlg( wxInitDialogEvent& event )
  102. {
  103. // Call the default wxDialog handler of a wxInitDialogEvent
  104. TransferDataToWindow();
  105. // Now all widgets have the size fixed, call FinishDialogSettings
  106. FinishDialogSettings();
  107. }
  108. /// Updates the different parameters for the component being edited.
  109. /// Automatically fired from the OK button click.
  110. bool TransferDataFromWindow();
  111. bool TransferDataToWindow();
  112. };
  113. #endif // #ifndef _DIALOG_PAD_PROPERTIES_H_