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-2021 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 <base_units.h>
32 #include <wx/valnum.h>
33 #include <board.h>
34 #include <footprint.h>
35 #include <pad_shapes.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:
57  void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
58  void initValues();
59  void displayPrimitivesList();
60  bool padValuesOK();
61  void redraw();
62  void editPrimitive();
64  void enablePrimitivePage( bool aEnable );
65 
70  void updatePadLayersList( LSET layer_mask, bool remove_unconnected, bool keep_top_bottom );
71 
73  bool transferDataToPad( PAD* aPad );
74 
75  bool Show( bool aShow ) override;
76 
77  // event handlers:
78  void OnInitDialog( wxInitDialogEvent& event ) override;
79  void OnResize( wxSizeEvent& event );
80  void OnCancel( wxCommandEvent& event ) override;
81  void OnUpdateUI( wxUpdateUIEvent& event ) override;
82 
83  void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override;
84 
85  void OnPadShapeSelection( wxCommandEvent& event ) override;
86  void OnDrillShapeSelected( wxCommandEvent& event ) override;
87  void onChangePadMode( wxCommandEvent& event ) override;
88  void OnOffsetCheckbox( wxCommandEvent& event ) override;
89  void OnPadToDieCheckbox( wxCommandEvent& event ) override;
90 
91  void PadOrientEvent( wxCommandEvent& event ) override;
92  void PadTypeSelected( wxCommandEvent& event ) override;
93 
94  void UpdateLayersDropdown();
95  void OnSetCopperLayers( wxCommandEvent& event ) override;
96  void OnSetLayers( wxCommandEvent& event ) override;
97 
98  // Called when corner setup value is changed for rounded rect pads
99  void onCornerSizePercentChange( wxCommandEvent& event ) override;
100  void onCornerRadiusChange( wxCommandEvent& event ) override;
101 
104  void OnValuesChanged( wxCommandEvent& event ) override;
105 
108 
109  bool TransferDataFromWindow() override;
110  bool TransferDataToWindow() override;
111 
113  void onDeletePrimitive( wxCommandEvent& event ) override;
114  void onEditPrimitive( wxCommandEvent& event ) override;
115  void onAddPrimitive( wxCommandEvent& event ) override;
116  void onGeometryTransform( wxCommandEvent& event ) override;
117  void onDuplicatePrimitive( wxCommandEvent& event ) override;
118 
120  void onPrimitiveDClick( wxMouseEvent& event ) override;
122  void OnPrimitiveSelection( wxListEvent& event ) override;
123 
126 
127 private:
129  PAD* m_currentPad; // pad currently being edited
130  PAD* m_dummyPad; // a working copy used to show changes
131  PAD* m_padMaster; // pad used to create new pads in board or footprint editor
132  BOARD* m_board; // the main board: this is the board handled by the PCB
133  // editor or the dummy board used by the footprint editor
134  bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in
135  // which case some Y coordinates values must be negated
137  bool m_canEditNetName; // true only if the caller is the board editor
138  bool m_isFpEditor; // true if the caller is the footprint editor
139 
140  std::vector<std::shared_ptr<PCB_SHAPE>> m_primitives; // the custom shape primitives in
141  // local coords, orient 0
142  // must define a single copper area
143  COLOR4D m_selectedColor; // color used to draw selected primitives when
144  // editing a custom pad shape
145 
146  std::vector<PCB_SHAPE*> m_highlight; // shapes highlighted in GAL mode
148  KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
149  static bool m_sketchPreview; // session storage
150 
166 };
167 
174 {
175 public:
176  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
177  PCB_SHAPE* aShape );
178 
182  bool TransferDataFromWindow() override;
183 
184 private:
189  bool TransferDataToWindow() override;
190 
191  // The basic shape currently edited
193 
204 };
205 
206 
211 {
212 public:
213  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
214  PCB_SHAPE* aShape );
216 
220  bool TransferDataFromWindow() override;
221 
222 private:
226  bool TransferDataToWindow() override;
227 
231  bool Validate() override;
232 
233  // Events handlers:
234  void OnButtonAdd( wxCommandEvent& event ) override;
235  void OnButtonDelete( wxCommandEvent& event ) override;
236  void onPaintPolyPanel( wxPaintEvent& event ) override;
237  void onPolyPanelResize( wxSizeEvent& event ) override;
238  void onGridSelect( wxGridRangeSelectEvent& event ) override;
239  void onCellChanging( wxGridEvent& event );
240  void onCellSelect( wxGridEvent& event ) override
241  {
242  event.Skip();
243  }
244 
245  bool doValidate( bool aRemoveRedundantCorners );
246 
247  // The basic shape currently edited
249 
250  // The working copy of the basic shape currently edited
251  std::vector<wxPoint> m_currPoints;
252 
254 };
255 
256 
265 {
266 public:
267  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
268  std::vector<std::shared_ptr<PCB_SHAPE>>& aList,
269  bool aShowDuplicate );
270 
278  void Transform( std::vector<std::shared_ptr<PCB_SHAPE>>* aList = nullptr,
279  int aDuplicateCount = 0 );
280 
284  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
285 
286 private:
287  std::vector<std::shared_ptr<PCB_SHAPE>>& m_list;
288 
292 };
293 
294 #endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
void OnInitDialog(wxInitDialogEvent &event) override
void OnValuesChanged(wxCommandEvent &event) override
Called when a dimension has changed.
void enablePrimitivePage(bool aEnable)
enable (or disable) the primitive page editor
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
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
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
Transfer data into the GUI.
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
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...
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
void onGeometryTransform(wxCommandEvent &event) override
void onPaintPolyPanel(wxPaintEvent &event) override
A dialog to edit basic polygonal shape parameters.
PAD_PROP getSelectedProperty()
Return the pad property currently selected.
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
PAD_PROP
Ghe set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: pad_shapes.h:95
void onDeletePrimitive(wxCommandEvent &event) override
Event handlers of basic shapes list panel.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
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:57
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 basic shape parameters.
bool TransferDataFromWindow() override
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:103