KiCad PCB EDA Suite
dialog_pad_properties.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
6  * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef _DIALOG_PAD_PROPERTIES_H_
28 #define _DIALOG_PAD_PROPERTIES_H_
29 
30 #include <pcbnew.h>
31 #include <pcb_base_frame.h>
32 #include <base_units.h>
33 #include <wx/valnum.h>
34 #include <board.h>
35 #include <footprint.h>
36 #include <pcb_shape.h>
37 #include <origin_viewitem.h>
39 #include <widgets/text_ctrl_eval.h>
40 #include <pcb_draw_panel_gal.h>
41 #include <widgets/unit_binder.h>
42 
47 // The wxWidgets window name. Used to retrieve the dialog by window name
48 #define PAD_PROPERTIES_DLG_NAME "pad_properties_dlg_name"
49 
51 {
52 public:
53  DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad );
55 
56 private:
58  PAD* m_currentPad; // pad currently being edited
59  PAD* m_dummyPad; // a working copy used to show changes
60  PAD* m_padMaster; // pad used to create new pads in board or footprint editor
61  BOARD* m_board; // the main board: this is the board handled by the PCB
62  // editor or the dummy board used by the footprint editor
63  bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in
64  // which case some Y coordinates values must be negated
66  bool m_canEditNetName; // true only if the caller is the board editor
67  bool m_isFpEditor; // true if the caller is the footprint editor
68 
69  std::vector<std::shared_ptr<PCB_SHAPE>> m_primitives; // the custom shape primitives in
70  // local coords, orient 0
71  // must define a single copper area
72  COLOR4D m_selectedColor; // color used to draw selected primitives when
73  // editing a custom pad shape
74 
75  std::vector<PCB_SHAPE*> m_highlight; // shapes highlighted in GAL mode
77  KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
78  static bool m_sketchPreview; // session storage
79 
87  wxFloatingPointValidator<double> m_OrientValidator;
88  double m_OrientValue;
92 
93 private:
94  void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
95  void initValues();
96  void displayPrimitivesList();
97  bool padValuesOK();
98  void redraw();
99  void editPrimitive();
101  void enablePrimitivePage( bool aEnable );
102 
108  void updatePadLayersList( LSET layer_mask, bool remove_unconnected, bool keep_top_bottom );
109 
111  bool transferDataToPad( PAD* aPad );
112 
113  bool Show( bool aShow ) override;
114 
115  // event handlers:
116  void OnInitDialog( wxInitDialogEvent& event ) override;
117  void OnResize( wxSizeEvent& event );
118  void OnCancel( wxCommandEvent& event ) override;
119  void OnUpdateUI( wxUpdateUIEvent& event ) override;
120 
121  void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override
122  {
123  bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
124  m_nonCopperWarningBook->SetSelection( isOnCopperLayer ? 0 : 1 );
125  }
126 
127  void OnPadShapeSelection( wxCommandEvent& event ) override;
128  void OnDrillShapeSelected( wxCommandEvent& event ) override;
129  void onChangePadMode( wxCommandEvent& event ) override;
130  void OnOffsetCheckbox( wxCommandEvent& event ) override;
131  void OnPadToDieCheckbox( wxCommandEvent& event ) override;
132 
133  void PadOrientEvent( wxCommandEvent& event ) override;
134  void PadTypeSelected( wxCommandEvent& event ) override;
135 
136  void UpdateLayersDropdown();
137  void OnSetCopperLayers( wxCommandEvent& event ) override;
138  void OnSetLayers( wxCommandEvent& event ) override;
139 
140  // Called when corner setup value is changed for rounded rect pads
141  void onCornerSizePercentChange( wxCommandEvent& event ) override;
142  void onCornerRadiusChange( wxCommandEvent& event ) override;
143 
146  void OnValuesChanged( wxCommandEvent& event ) override;
147 
150 
151  bool TransferDataFromWindow() override;
152  bool TransferDataToWindow() override;
153 
155  void onDeletePrimitive( wxCommandEvent& event ) override;
156  void onEditPrimitive( wxCommandEvent& event ) override;
157  void onAddPrimitive( wxCommandEvent& event ) override;
158  void onGeometryTransform( wxCommandEvent& event ) override;
159  void onDuplicatePrimitive( wxCommandEvent& event ) override;
160 
162  void onPrimitiveDClick( wxMouseEvent& event ) override;
164  void OnPrimitiveSelection( wxListEvent& event ) override;
165 
168 };
169 
175 {
176 public:
177  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
178  PCB_SHAPE* aShape );
179 
184  bool TransferDataFromWindow() override;
185 
186 private:
191  bool TransferDataToWindow() override;
192 
193  // The basic shape currently edited
195 
206 };
207 
208 
213 {
214  // The basic shape currently edited
216 
217  // The working copy of the basic shape currently edited
218  std::vector<wxPoint> m_currPoints;
219 
221 
222 public:
223  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
224  PCB_SHAPE* aShape );
226 
231  bool TransferDataFromWindow() override;
232 
233 private:
238  bool TransferDataToWindow() override;
239 
243  bool Validate() override;
244 
245  // Events handlers:
246  void OnButtonAdd( wxCommandEvent& event ) override;
247  void OnButtonDelete( wxCommandEvent& event ) override;
248  void onPaintPolyPanel( wxPaintEvent& event ) override;
249  void onPolyPanelResize( wxSizeEvent& event ) override;
250  void onGridSelect( wxGridRangeSelectEvent& event ) override;
251  void onCellChanging( wxGridEvent& event );
252  void onCellSelect( wxGridEvent& event ) override
253  {
254  event.Skip();
255  }
256 
257  bool doValidate( bool aRemoveRedundantCorners );
258 
259 };
260 
261 
270 {
271 public:
272  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
273  std::vector<std::shared_ptr<PCB_SHAPE>>& aList,
274  bool aShowDuplicate );
275 
283  void Transform( std::vector<std::shared_ptr<PCB_SHAPE>>* aList = nullptr,
284  int aDuplicateCount = 0 );
285 
289  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
290 
291 private:
292  std::vector<std::shared_ptr<PCB_SHAPE>>& m_list;
293 
297 };
298 
299 #endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
void OnInitDialog(wxInitDialogEvent &event) override
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
void OnValuesChanged(wxCommandEvent &event) override
Called when a dimension has changed.
void enablePrimitivePage(bool aEnable)
enable (or disable) the primitive page editor
PAD_PROP_T getSelectedProperty()
Return the pad property currently selected.
Implementation of conversion functions that require both schematic and board internal units.
Class DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE.
void onCellSelect(wxGridEvent &event) override
std::vector< std::shared_ptr< PCB_SHAPE > > m_primitives
DIALOG_PAD_PROPERTIES(PCB_BASE_FRAME *aParent, PAD *aPad)
void OnPadToDieCheckbox(wxCommandEvent &event) override
wxFloatingPointValidator< double > m_OrientValidator
DIALOG_PAD_PRIMITIVE_POLY_PROPS(wxWindow *aParent, PCB_BASE_FRAME *aFrame, PCB_SHAPE *aShape)
void onChangePadMode(wxCommandEvent &event) override
void OnButtonDelete(wxCommandEvent &event) override
void onCornerSizePercentChange(wxCommandEvent &event) override
bool TransferDataFromWindow() override
Function TransferDataFromWindow Transfer data out of the GUI.
Classes used in Pcbnew, CvPcb and GerbView.
Class DIALOG_PAD_PRIMITIVES_TRANSFORM_BASE.
DIALOG_PAD_PRIMITIVES_TRANSFORM(wxWindow *aParent, PCB_BASE_FRAME *aFrame, std::vector< std::shared_ptr< PCB_SHAPE >> &aList, bool aShowDuplicate)
KIGFX::ORIGIN_VIEWITEM * m_axisOrigin
void Transform(std::vector< std::shared_ptr< PCB_SHAPE >> *aList=nullptr, int aDuplicateCount=0)
Apply geometric transform (rotation, move, scale) defined in dialog aDuplicate = 1 .
void onAddPrimitive(wxCommandEvent &event) override
void OnCancel(wxCommandEvent &event) override
bool TransferDataToWindow() override
Function TransferDataToWindow Transfer data into the GUI.
bool TransferDataToWindow() override
Function TransferDataToWindow Transfer data into the GUI.
LSET is a set of PCB_LAYER_IDs.
void updatePadLayersList(LSET layer_mask, bool remove_unconnected, bool keep_top_bottom)
Function updatePadLayersList updates the CheckBox states in pad layers list, based on the layer_mask ...
void onGridSelect(wxGridRangeSelectEvent &event) override
void OnSetLayers(wxCommandEvent &event) override
void OnSetCopperLayers(wxCommandEvent &event) override
bool transferDataToPad(PAD *aPad)
Copy values from dialog field to aPad's members.
void onCornerRadiusChange(wxCommandEvent &event) override
Class DIALOG_PAD_PROPERTIES_BASE.
void OnUpdateUINonCopperWarning(wxUpdateUIEvent &event) override
void OnResize(wxSizeEvent &event)
void OnPadShapeSelection(wxCommandEvent &event) override
void PadTypeSelected(wxCommandEvent &event) override
void onPrimitiveDClick(wxMouseEvent &event) override
Called on a double click on the basic shapes list.
void onPolyPanelResize(wxSizeEvent &event) override
DIALOG_PAD_PRIMITIVES_PROPERTIES(wxWindow *aParent, PCB_BASE_FRAME *aFrame, PCB_SHAPE *aShape)
void OnDrillShapeSelected(wxCommandEvent &event) override
PAD_PROP_T
Ghe set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: pad_shapes.h:94
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:360
void onGeometryTransform(wxCommandEvent &event) override
void onPaintPolyPanel(wxPaintEvent &event) override
a dialog to edit basic polygonal shape parameters
void OnButtonAdd(wxCommandEvent &event) override
bool Show(bool aShow) override
void OnPrimitiveSelection(wxListEvent &event) override
Called on selection/deselection of a basic shape.
void onEditPrimitive(wxCommandEvent &event) override
bool TransferDataFromWindow() override
Updates the different parameters for the component being edited.
void PadOrientEvent(wxCommandEvent &event) override
void onDeletePrimitive(wxCommandEvent &event) override
Event handlers of basic shapes list panel.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void onDuplicatePrimitive(wxCommandEvent &event) override
PCB_DRAW_PANEL_GAL * m_padPreviewGAL
void OnOffsetCheckbox(wxCommandEvent &event) override
bool padValuesOK()
test if all values are acceptable for the pad
bool doValidate(bool aRemoveRedundantCorners)
Definition: pad.h:60
std::vector< PCB_SHAPE * > m_highlight
A dialog to apply geometry transforms to a shape or set of shapes (move, rotate around origin,...
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
std::vector< std::shared_ptr< PCB_SHAPE > > & m_list
a dialog to edit basics shapes parameters.
bool TransferDataFromWindow() override
Function TransferDataFromWindow Transfer data out of the GUI.
void OnUpdateUI(wxUpdateUIEvent &event) override
bool Validate() override
test for a valid polygon (a not self intersectiong polygon)
Class DIALOG_PAD_PRIMITIVES_PROPERTIES_BASE.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98