KiCad PCB EDA Suite
dialog_pad_properties.h
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
10  * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
11  * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
12  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, you may find one here:
26  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
27  * or you may search the http://www.gnu.org website for the version 2 license,
28  * or you may write to the Free Software Foundation, Inc.,
29  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30  */
31 
32 #ifndef _DIALOG_PAD_PROPERTIES_H_
33 #define _DIALOG_PAD_PROPERTIES_H_
34 
35 #include <class_drawpanel.h>
36 #include <pcbnew.h>
37 #include <wxBasePcbFrame.h>
38 #include <base_units.h>
39 #include <wx/valnum.h>
40 
41 #include <class_board.h>
42 #include <class_module.h>
43 #include <class_drawsegment.h>
44 
45 #include <origin_viewitem.h>
46 
48 #include <widgets/text_ctrl_eval.h>
49 #include <pcb_draw_panel_gal.h>
50 
51 
52 
58 {
59 public:
60  DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
62  {
63  delete m_dummyPad;
64  delete m_axisOrigin;
65  }
66 
67 private:
70  D_PAD* m_currentPad; // pad currently being edited
71  D_PAD* m_dummyPad; // a working copy used to show changes
72  D_PAD* m_padMaster; // The pad used to create new pads in board or
73  // footprint editor
74  BOARD* m_board; // the main board: this is the board handled by
75  // the PCB editor, if running or the dummy
76  // board used by the footprint editor
77  // (could happen when the Footprint editor will be run
78  // alone, outside the board editor
79  bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
80  // in this case, some Y coordinates values must be negated
82  bool m_canEditNetName; // true only if the caller is the board editor
83 
84  // for free shape pads: the list of primitives (basic shapes),
85  // in local coordinates, orient 0, coordinates relative to m_Pos
86  // They are expected to define only one copper area.
87  std::vector<PAD_CS_PRIMITIVE> m_primitives;
88 
89  std::vector<DRAWSEGMENT*> m_highligth; // shapes highlighted in GAL mode
90 
91  wxFloatingPointValidator<double> m_OrientValidator;
92  double m_OrientValue;
93 
94 private:
95  void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
96  void initValues();
97  void displayPrimitivesList();
98  bool padValuesOK();
99  void redraw();
100  void editPrimitive();
102  void enablePrimitivePage( bool aEnable );
103 
109  void setPadLayersList( LSET layer_mask );
110 
112  bool transferDataToPad( D_PAD* aPad );
113 
114  // event handlers:
115  void OnInitDialog( wxInitDialogEvent& event ) override;
116  void OnResize( wxSizeEvent& event );
117  void OnCancel( wxCommandEvent& event ) override;
118 
119  void OnPadShapeSelection( wxCommandEvent& event ) override;
120  void OnDrillShapeSelected( wxCommandEvent& event ) override;
121 
122  void PadOrientEvent( wxCommandEvent& event ) override;
123  void PadTypeSelected( wxCommandEvent& event ) override;
124 
125  void OnSetLayers( wxCommandEvent& event ) override;
126  void OnPaintShowPanel( wxPaintEvent& event ) override;
127 
128  // Called when corner setup value is changed for rounded rect pads
129  void onCornerSizePercentChange( wxCommandEvent& event ) override;
130 
133  void OnValuesChanged( wxCommandEvent& event ) override;
134 
137 
138  bool TransferDataFromWindow() override;
139  bool TransferDataToWindow() override;
140 
142  void onDeletePrimitive( wxCommandEvent& event ) override;
143  void onEditPrimitive( wxCommandEvent& event ) override;
144  void onAddPrimitive( wxCommandEvent& event ) override;
145  void onImportPrimitives( wxCommandEvent& event ) override;
146  void onGeometryTransform( wxCommandEvent& event ) override;
147  void onDuplicatePrimitive( wxCommandEvent& event ) override;
148 
150  void onPrimitiveDClick( wxMouseEvent& event ) override;
152  void OnPrimitiveSelection( wxListEvent& event ) override;
153 };
154 
160 {
161 public:
162  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PAD_CS_PRIMITIVE * aShape );
163 
168  bool TransferDataFromWindow() override;
169 
170 private:
175  bool TransferDataToWindow() override;
176 
177  // The basic shape currently edited
179 };
180 
181 
186 {
187  // The basic shape currently edited
189 
190  // The working copy of the basic shape currently edited
192 
193 public:
194  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PAD_CS_PRIMITIVE * aShape );
196 
201  bool TransferDataFromWindow() override;
202 
203 private:
208  bool TransferDataToWindow() override;
209 
213  bool Validate() override;
214 
215  // Events handlers:
216  void OnValidateButton( wxCommandEvent& event );
217  void onButtonAdd( wxCommandEvent& event ) override;
218  void OnButtonDelete( wxCommandEvent& event ) override;
219  void onPaintPolyPanel( wxPaintEvent& event ) override;
220  void onPolyPanelResize( wxSizeEvent& event ) override;
221  void onGridSelect( wxGridRangeSelectEvent& event ) override;
222  void onCellChanging( wxGridEvent& event );
223  void onCellSelect( wxGridEvent& event ) override
224  {
225  event.Skip();
226  }
227 };
228 
229 
238 {
239 public:
240  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent,
241  std::vector<PAD_CS_PRIMITIVE*>& aList, bool aShowDuplicate );
242 
250  void Transform( std::vector<PAD_CS_PRIMITIVE>* aList = NULL, int aDuplicateCount = 0 );
251 
255  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
256 
257 private:
258  std::vector<PAD_CS_PRIMITIVE*>& m_list;
259 };
260 
261 #endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
void OnInitDialog(wxInitDialogEvent &event) override
void OnValuesChanged(wxCommandEvent &event) override
Called when a dimension has changed.
DIALOG_PAD_PROPERTIES(PCB_BASE_FRAME *aParent, D_PAD *aPad)
void enablePrimitivePage(bool aEnable)
enable (or disable) the primitive page editor
DIALOG_PAD_PRIMITIVES_PROPERTIES(wxWindow *aParent, PAD_CS_PRIMITIVE *aShape)
Implementation of conversion functions that require both schematic and board internal units...
Class DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE.
void onCellSelect(wxGridEvent &event) override
bool transferDataToPad(D_PAD *aPad)
Copy values from dialog field to aPad's members.
Class BOARD to handle a board.
void setPadLayersList(LSET layer_mask)
Function setPadLayersList updates the CheckBox states in pad layers list,.
wxFloatingPointValidator< double > m_OrientValidator
void onButtonAdd(wxCommandEvent &event) override
void OnButtonDelete(wxCommandEvent &event) override
DIALOG_PAD_PRIMITIVE_POLY_PROPS(wxWindow *aParent, PAD_CS_PRIMITIVE *aShape)
void Transform(std::vector< PAD_CS_PRIMITIVE > *aList=NULL, int aDuplicateCount=0)
Apply geometric transform (rotation, move, scale) defined in dialog aDuplicate = 1 ...
void onCornerSizePercentChange(wxCommandEvent &event) override
bool TransferDataFromWindow() override
Function TransferDataFromWindow Transfer data out of the GUI.
class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE, created by wxFormBuilder ...
Class DIALOG_PAD_PRIMITIVES_TRANSFORM_BASE.
KIGFX::ORIGIN_VIEWITEM * m_axisOrigin
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.
Class LSET is a set of PCB_LAYER_IDs.
Classes used in Pcbnew, CvPcb and GerbView.
void onGridSelect(wxGridRangeSelectEvent &event) override
void OnSetLayers(wxCommandEvent &event) override
void OnValidateButton(wxCommandEvent &event)
void OnPaintShowPanel(wxPaintEvent &event) override
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
Class DIALOG_PAD_PROPERTIES_BASE.
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
void OnDrillShapeSelected(wxCommandEvent &event) override
void onGeometryTransform(wxCommandEvent &event) override
void onImportPrimitives(wxCommandEvent &event) override
void onPaintPolyPanel(wxPaintEvent &event) override
a dialog to edit basic polygonal shape parameters
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
std::vector< PAD_CS_PRIMITIVE > m_primitives
Class to handle a graphic segment.
void onDeletePrimitive(wxCommandEvent &event) override
Event handlers of basic shapes list panel.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void onDuplicatePrimitive(wxCommandEvent &event) override
DIALOG_PAD_PRIMITIVES_TRANSFORM(wxWindow *aParent, std::vector< PAD_CS_PRIMITIVE * > &aList, bool aShowDuplicate)
std::vector< PAD_CS_PRIMITIVE * > & m_list
std::vector< DRAWSEGMENT * > m_highligth
bool padValuesOK()
test if all values are acceptable for the pad
Module description (excepted pads)
A dialog to apply geometry transforms to a shape or set of shapes (move, rotate around origin...
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
a dialog to edit basics shapes parameters.
bool TransferDataFromWindow() override
Function TransferDataFromWindow Transfer data out of the GUI.
bool Validate() override
test for a valid polygon (a not self intersectiong polygon)
Class DIALOG_PAD_PRIMITIVES_PROPERTIES_BASE.