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, [email protected]
6 * Copyright (C) 2008-2013 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2022 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 <pcb_base_frame.h>
31#include <wx/valnum.h>
32#include <board.h>
33#include <footprint.h>
34#include <pad_shapes.h>
35#include <pcb_shape.h>
36#include <origin_viewitem.h>
39#include <pcb_draw_panel_gal.h>
40#include <widgets/unit_binder.h>
41
46// The wxWidgets window name. Used to retrieve the dialog by window name
47#define PAD_PROPERTIES_DLG_NAME wxT( "pad_properties_dlg_name" )
48
50{
51public:
52 DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad );
54
55private:
56 void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
57 void initValues();
59 bool padValuesOK();
60 void redraw();
61 void editPrimitive();
63 void enablePrimitivePage( bool aEnable );
64
69 void updatePadLayersList( LSET layer_mask, bool remove_unconnected, bool keep_top_bottom );
70
72 bool transferDataToPad( PAD* aPad );
73
74 bool Show( bool aShow ) override;
75
76 // event handlers:
77 void OnInitDialog( wxInitDialogEvent& event ) override;
78 void OnResize( wxSizeEvent& event );
79 void OnCancel( wxCommandEvent& event ) override;
80 void OnUpdateUI( wxUpdateUIEvent& event ) override;
81
82 void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override;
83
84 void OnPadShapeSelection( wxCommandEvent& event ) override;
85 void OnDrillShapeSelected( wxCommandEvent& event ) override;
86 void onChangePadMode( wxCommandEvent& event ) override;
87 void OnOffsetCheckbox( wxCommandEvent& event ) override;
88 void OnPadToDieCheckbox( wxCommandEvent& event ) override;
89
90 void PadOrientEvent( wxCommandEvent& event ) override;
91 void PadTypeSelected( wxCommandEvent& event ) override;
92
94 void OnSetCopperLayers( wxCommandEvent& event ) override;
95 void OnSetLayers( wxCommandEvent& event ) override;
96
97 // Called when corner setup value is changed for rounded rect pads
98 void onCornerSizePercentChange( wxCommandEvent& event ) override;
99 void onCornerRadiusChange( wxCommandEvent& event ) override;
100
103 void OnValuesChanged( wxCommandEvent& event ) override;
104
107
108 bool TransferDataFromWindow() override;
109 bool TransferDataToWindow() override;
110
112 void onDeletePrimitive( wxCommandEvent& event ) override;
113 void onEditPrimitive( wxCommandEvent& event ) override;
114 void onAddPrimitive( wxCommandEvent& event ) override;
115 void onGeometryTransform( wxCommandEvent& event ) override;
116 void onDuplicatePrimitive( wxCommandEvent& event ) override;
117
119 void onPrimitiveDClick( wxMouseEvent& event ) override;
121 void OnPrimitiveSelection( wxListEvent& event ) override;
122
125
126private:
128 PAD* m_currentPad; // pad currently being edited
129 PAD* m_dummyPad; // a working copy used to show changes
130 PAD* m_padMaster; // pad used to create new pads in board or footprint editor
131 BOARD* m_board; // the main board: this is the board handled by the PCB
132 // editor or the dummy board used by the footprint editor
133 bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in
134 // which case some Y coordinates values must be negated
136 bool m_canEditNetName; // true only if the caller is the board editor
137 bool m_isFpEditor; // true if the caller is the footprint editor
138
139 std::vector<std::shared_ptr<PCB_SHAPE>> m_primitives; // the custom shape primitives in
140 // local coords, orient 0
141 // must define a single copper area
142 COLOR4D m_selectedColor; // color used to draw selected primitives when
143 // editing a custom pad shape
144
145 std::vector<PCB_SHAPE*> m_highlight; // shapes highlighted in GAL mode
147 KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
148 static bool m_sketchPreview; // session storage
149
169
170 // Show/hide the hole size Y widgets
171 // Setting the X/Diameter label according to the selected hole type
172 void updateHoleControls();
173
174 // Show/hide the pad size Y widgets
175 // Setting the X/Diameter label according to the selected hole type
177};
178
185{
186public:
187 DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
188 PCB_SHAPE* aShape );
189
193 bool TransferDataFromWindow() override;
194
195private:
200 bool TransferDataToWindow() override;
201
202 // The basic shape currently edited
204
215};
216
217
222{
223public:
224 DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
225 PCB_SHAPE* aShape );
227
231 bool TransferDataFromWindow() override;
232
233private:
237 bool TransferDataToWindow() override;
238
242 bool Validate() override;
243
244 // Events handlers:
245 void OnButtonAdd( wxCommandEvent& event ) override;
246 void OnButtonDelete( wxCommandEvent& event ) override;
247 void onPaintPolyPanel( wxPaintEvent& event ) override;
248 void onPolyPanelResize( wxSizeEvent& event ) override;
249 void onGridSelect( wxGridRangeSelectEvent& event ) override;
250 void onCellChanging( wxGridEvent& event );
251 void onCellSelect( wxGridEvent& event ) override
252 {
253 event.Skip();
254 }
255
256 bool doValidate( bool aRemoveRedundantCorners );
257
258private:
261
262 std::vector<VECTOR2I> m_currPoints; // The working copy of the data being edited
264};
265
266
275{
276public:
277 DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
278 std::vector<std::shared_ptr<PCB_SHAPE>>& aList,
279 bool aShowDuplicate );
280
288 void Transform( std::vector<std::shared_ptr<PCB_SHAPE>>* aList = nullptr,
289 int aDuplicateCount = 0 );
290
294 int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
295
296private:
297 std::vector<std::shared_ptr<PCB_SHAPE>>& m_list;
298
302};
303
304#endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
Class DIALOG_PAD_PRIMITIVES_PROPERTIES_BASE.
A dialog to edit basic shape parameters.
DIALOG_PAD_PRIMITIVES_PROPERTIES(wxWindow *aParent, PCB_BASE_FRAME *aFrame, PCB_SHAPE *aShape)
bool TransferDataToWindow() override
Function TransferDataToWindow Transfer data into the GUI.
bool TransferDataFromWindow() override
Transfer data out of the GUI.
Class DIALOG_PAD_PRIMITIVES_TRANSFORM_BASE.
A dialog to apply geometry transforms to a shape or set of shapes (move, rotate around origin,...
DIALOG_PAD_PRIMITIVES_TRANSFORM(wxWindow *aParent, PCB_BASE_FRAME *aFrame, std::vector< std::shared_ptr< PCB_SHAPE > > &aList, bool aShowDuplicate)
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 .
std::vector< std::shared_ptr< PCB_SHAPE > > & m_list
Class DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE.
A dialog to edit basic polygonal shape parameters.
void onPolyPanelResize(wxSizeEvent &event) override
bool TransferDataFromWindow() override
Transfer data out of the GUI.
bool Validate() override
Test for a valid polygon (a not self intersectiong polygon).
void onCellSelect(wxGridEvent &event) override
std::vector< VECTOR2I > m_currPoints
void onGridSelect(wxGridRangeSelectEvent &event) override
void OnButtonAdd(wxCommandEvent &event) override
void onPaintPolyPanel(wxPaintEvent &event) override
void OnButtonDelete(wxCommandEvent &event) override
bool TransferDataToWindow() override
Transfer data into the GUI.
DIALOG_PAD_PRIMITIVE_POLY_PROPS(wxWindow *aParent, PCB_BASE_FRAME *aFrame, PCB_SHAPE *aShape)
bool doValidate(bool aRemoveRedundantCorners)
Class DIALOG_PAD_PROPERTIES_BASE.
void OnUpdateUINonCopperWarning(wxUpdateUIEvent &event) override
void OnInitDialog(wxInitDialogEvent &event) override
void PadTypeSelected(wxCommandEvent &event) override
void OnPadShapeSelection(wxCommandEvent &event) override
bool transferDataToPad(PAD *aPad)
Copy values from dialog field to aPad's members.
void onAddPrimitive(wxCommandEvent &event) override
bool TransferDataFromWindow() override
Updates the different parameters for the component being edited.
bool Show(bool aShow) override
std::vector< std::shared_ptr< PCB_SHAPE > > m_primitives
bool padValuesOK()
test if all values are acceptable for the pad
void onPrimitiveDClick(wxMouseEvent &event) override
Called on a double click on the basic shapes list.
void PadOrientEvent(wxCommandEvent &event) override
void OnResize(wxSizeEvent &event)
void OnOffsetCheckbox(wxCommandEvent &event) override
PCB_DRAW_PANEL_GAL * m_padPreviewGAL
void OnValuesChanged(wxCommandEvent &event) override
Called when a dimension has changed.
DIALOG_PAD_PROPERTIES(PCB_BASE_FRAME *aParent, PAD *aPad)
void onEditPrimitive(wxCommandEvent &event) override
void onChangePadMode(wxCommandEvent &event) override
void OnPrimitiveSelection(wxListEvent &event) override
Called on selection/deselection of a basic shape.
std::vector< PCB_SHAPE * > m_highlight
KIGFX::ORIGIN_VIEWITEM * m_axisOrigin
void OnSetCopperLayers(wxCommandEvent &event) override
void OnCancel(wxCommandEvent &event) override
void onCornerRadiusChange(wxCommandEvent &event) override
void updatePadLayersList(LSET layer_mask, bool remove_unconnected, bool keep_top_bottom)
Updates the CheckBox states in pad layers list, based on the layer_mask (if non-empty) or the default...
PAD_PROP getSelectedProperty()
Return the pad property currently selected.
void OnSetLayers(wxCommandEvent &event) override
void onCornerSizePercentChange(wxCommandEvent &event) override
void enablePrimitivePage(bool aEnable)
enable (or disable) the primitive page editor
void OnPadToDieCheckbox(wxCommandEvent &event) override
void onGeometryTransform(wxCommandEvent &event) override
void onDuplicatePrimitive(wxCommandEvent &event) override
void OnDrillShapeSelected(wxCommandEvent &event) override
void onDeletePrimitive(wxCommandEvent &event) override
Event handlers of basic shapes list panel.
void OnUpdateUI(wxUpdateUIEvent &event) override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
Definition: pad.h:59
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: pad_shapes.h:97