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 #include <widgets/unit_binder.h>
51 
57 {
58 public:
59  DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
61 
62 private:
64  D_PAD* m_currentPad; // pad currently being edited
65  D_PAD* m_dummyPad; // a working copy used to show changes
66  D_PAD* m_padMaster; // pad used to create new pads in board or footprint editor
67  BOARD* m_board; // the main board: this is the board handled by the PCB
68  // editor or the dummy board used by the footprint editor
69  bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in
70  // which case some Y coordinates values must be negated
72  bool m_canEditNetName; // true only if the caller is the board editor
73 
74  std::vector<PAD_CS_PRIMITIVE> m_primitives; // the list of custom shape primitives (basic
75  // shapes), in local coords, orient 0
76  // must define a single copper area
77  COLOR4D m_selectedColor; // color used to draw selected primitives when
78  // editing a custom pad shape
79 
80  std::vector<DRAWSEGMENT*> m_highlight; // shapes highlighted in GAL mode
81  KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
82  static bool m_sketchPreview; // session storage
83 
91  wxFloatingPointValidator<double> m_OrientValidator;
92  double m_OrientValue;
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  virtual void OnUpdateUI( wxUpdateUIEvent& event ) override;
122 
123  void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override
124  {
125  bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
126  m_nonCopperWarningBook->SetSelection( isOnCopperLayer ? 0 : 1 );
127  }
128 
129  void OnPadShapeSelection( wxCommandEvent& event ) override;
130  void OnDrillShapeSelected( wxCommandEvent& event ) override;
131  void onChangePadMode( wxCommandEvent& event ) override;
132 
133  void PadOrientEvent( wxCommandEvent& event ) override;
134  void PadTypeSelected( wxCommandEvent& event ) override;
135 
136  void OnSetLayers( wxCommandEvent& event ) override;
137  void OnPaintShowPanel( wxPaintEvent& event ) override;
138 
139  // Called when corner setup value is changed for rounded rect pads
140  void onCornerSizePercentChange( wxCommandEvent& event ) override;
141  void onCornerRadiusChange( wxCommandEvent& event ) override;
142 
145  void OnValuesChanged( wxCommandEvent& event ) override;
146 
149 
150  bool TransferDataFromWindow() override;
151  bool TransferDataToWindow() override;
152 
154  void onDeletePrimitive( wxCommandEvent& event ) override;
155  void onEditPrimitive( wxCommandEvent& event ) override;
156  void onAddPrimitive( wxCommandEvent& event ) override;
157  void onGeometryTransform( wxCommandEvent& event ) override;
158  void onDuplicatePrimitive( wxCommandEvent& event ) override;
159 
161  void onPrimitiveDClick( wxMouseEvent& event ) override;
163  void OnPrimitiveSelection( wxListEvent& event ) override;
164 };
165 
171 {
172 public:
173  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
174  PAD_CS_PRIMITIVE * aShape );
175 
180  bool TransferDataFromWindow() override;
181 
182 private:
187  bool TransferDataToWindow() override;
188 
189  // The basic shape currently edited
191 
198 };
199 
200 
205 {
206  // The basic shape currently edited
208 
209  // The working copy of the basic shape currently edited
211 
213 
214 public:
215  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
216  PAD_CS_PRIMITIVE * aShape );
218 
223  bool TransferDataFromWindow() override;
224 
225 private:
230  bool TransferDataToWindow() override;
231 
235  bool Validate() override;
236 
237  // Events handlers:
238  void OnValidateButton( wxCommandEvent& event );
239  void OnButtonAdd( wxCommandEvent& event ) override;
240  void OnButtonDelete( wxCommandEvent& event ) override;
241  void onPaintPolyPanel( wxPaintEvent& event ) override;
242  void onPolyPanelResize( wxSizeEvent& event ) override;
243  void onGridSelect( wxGridRangeSelectEvent& event ) override;
244  void onCellChanging( wxGridEvent& event );
245  void onCellSelect( wxGridEvent& event ) override
246  {
247  event.Skip();
248  }
249 
250  bool doValidate( bool aRemoveRedundantCorners );
251 
252 };
253 
254 
263 {
264 public:
265  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
266  std::vector<PAD_CS_PRIMITIVE*>& aList, bool aShowDuplicate );
267 
275  void Transform( std::vector<PAD_CS_PRIMITIVE>* aList = NULL, int aDuplicateCount = 0 );
276 
280  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
281 
282 private:
283  std::vector<PAD_CS_PRIMITIVE*>& m_list;
284 
288 };
289 
290 #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
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 OnDrillShapeSelected(wxCommandEvent &event) override
void onGeometryTransform(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:170
void onDuplicatePrimitive(wxCommandEvent &event) override
std::vector< PAD_CS_PRIMITIVE * > & m_list
bool padValuesOK()
test if all values are acceptable for the pad
Module description (excepted pads)
std::vector< DRAWSEGMENT * > m_highlight
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.
virtual void OnUpdateUI(wxUpdateUIEvent &event) override
Class DIALOG_PAD_PRIMITIVES_PROPERTIES_BASE.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39