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) 2018 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-2018 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 <pcb_base_frame.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  static bool m_drawPadOutlineMode; // Stores the pad draw option during a session
94  COLOR4D m_selectedColor; // Color used to draw selected primitives when
95  // editing a custom pad shape
96 
97 private:
98  void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
99  void initValues();
100  void displayPrimitivesList();
101  bool padValuesOK();
102  void redraw();
103  void editPrimitive();
105  void enablePrimitivePage( bool aEnable );
106 
112  void setPadLayersList( LSET layer_mask );
113 
115  bool transferDataToPad( D_PAD* aPad );
116 
117  // event handlers:
118  void OnInitDialog( wxInitDialogEvent& event ) override;
119  void OnResize( wxSizeEvent& event );
120  void OnCancel( wxCommandEvent& event ) override;
121 
122  void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override
123  {
124  bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
125  m_nonCopperWarningBook->SetSelection( isOnCopperLayer ? 0 : 1 );
126  }
127 
128  void OnPadShapeSelection( wxCommandEvent& event ) override;
129  void OnDrillShapeSelected( wxCommandEvent& event ) override;
130  void onChangePadMode( wxCommandEvent& event ) override;
131 
132  void PadOrientEvent( wxCommandEvent& event ) override;
133  void PadTypeSelected( wxCommandEvent& event ) override;
134 
135  void OnSetLayers( wxCommandEvent& event ) override;
136  void OnPaintShowPanel( wxPaintEvent& event ) override;
137 
138  // Called when corner setup value is changed for rounded rect pads
139  void onCornerSizePercentChange( wxCommandEvent& event ) override;
140 
143  void OnValuesChanged( wxCommandEvent& event ) override;
144 
147 
148  bool TransferDataFromWindow() override;
149  bool TransferDataToWindow() override;
150 
152  void onDeletePrimitive( wxCommandEvent& event ) override;
153  void onEditPrimitive( wxCommandEvent& event ) override;
154  void onAddPrimitive( wxCommandEvent& event ) override;
155  void onImportPrimitives( wxCommandEvent& event ) override;
156  void onGeometryTransform( wxCommandEvent& event ) override;
157  void onDuplicatePrimitive( wxCommandEvent& event ) override;
158 
160  void onPrimitiveDClick( wxMouseEvent& event ) override;
162  void OnPrimitiveSelection( wxListEvent& event ) override;
163 };
164 
170 {
171 public:
172  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PAD_CS_PRIMITIVE * aShape );
173 
178  bool TransferDataFromWindow() override;
179 
180 private:
185  bool TransferDataToWindow() override;
186 
187  // The basic shape currently edited
189 };
190 
191 
196 {
197  // The basic shape currently edited
199 
200  // The working copy of the basic shape currently edited
202 
203 public:
204  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PAD_CS_PRIMITIVE * aShape );
206 
211  bool TransferDataFromWindow() override;
212 
213 private:
218  bool TransferDataToWindow() override;
219 
223  bool Validate() override;
224 
225  // Events handlers:
226  void OnValidateButton( wxCommandEvent& event );
227  void onButtonAdd( wxCommandEvent& event ) override;
228  void OnButtonDelete( wxCommandEvent& event ) override;
229  void onPaintPolyPanel( wxPaintEvent& event ) override;
230  void onPolyPanelResize( wxSizeEvent& event ) override;
231  void onGridSelect( wxGridRangeSelectEvent& event ) override;
232  void onCellChanging( wxGridEvent& event );
233  void onCellSelect( wxGridEvent& event ) override
234  {
235  event.Skip();
236  }
237 };
238 
239 
248 {
249 public:
250  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent,
251  std::vector<PAD_CS_PRIMITIVE*>& aList, bool aShowDuplicate );
252 
260  void Transform( std::vector<PAD_CS_PRIMITIVE>* aList = NULL, int aDuplicateCount = 0 );
261 
265  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
266 
267 private:
268  std::vector<PAD_CS_PRIMITIVE*>& m_list;
269 };
270 
271 #endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
void OnInitDialog(wxInitDialogEvent &event) override
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
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
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&#39;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 onChangePadMode(wxCommandEvent &event) override
void onCornerSizePercentChange(wxCommandEvent &event) override
Classes used in Pcbnew, CvPcb and GerbView.
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
Class LSET is a set of PCB_LAYER_IDs.
void OnSetLayers(wxCommandEvent &event) override
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
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:402
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 OnDrillShapeSelected(wxCommandEvent &event) override
void onGeometryTransform(wxCommandEvent &event) override
void onImportPrimitives(wxCommandEvent &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
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.
Class DIALOG_PAD_PRIMITIVES_PROPERTIES_BASE.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39