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, dick@softplc.com
6  * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2019 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 <pcbnew.h>
31 #include <pcb_base_frame.h>
32 #include <base_units.h>
33 #include <wx/valnum.h>
34 #include <class_board.h>
35 #include <class_module.h>
36 #include <class_drawsegment.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 
48 {
49 public:
50  DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
52 
53 private:
55  D_PAD* m_currentPad; // pad currently being edited
56  D_PAD* m_dummyPad; // a working copy used to show changes
57  D_PAD* m_padMaster; // pad used to create new pads in board or footprint editor
58  BOARD* m_board; // the main board: this is the board handled by the PCB
59  // editor or the dummy board used by the footprint editor
60  bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in
61  // which case some Y coordinates values must be negated
63  bool m_canEditNetName; // true only if the caller is the board editor
64 
65  std::vector<PAD_CS_PRIMITIVE> m_primitives; // the list of custom shape primitives (basic
66  // shapes), in local coords, orient 0
67  // must define a single copper area
68  COLOR4D m_selectedColor; // color used to draw selected primitives when
69  // editing a custom pad shape
70 
71  std::vector<DRAWSEGMENT*> m_highlight; // shapes highlighted in GAL mode
72  KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
73  static bool m_sketchPreview; // session storage
74 
82  wxFloatingPointValidator<double> m_OrientValidator;
83  double m_OrientValue;
87 
88 private:
89  void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
90  void initValues();
91  void displayPrimitivesList();
92  bool padValuesOK();
93  void redraw();
94  void editPrimitive();
96  void enablePrimitivePage( bool aEnable );
97 
103  void setPadLayersList( LSET layer_mask );
104 
106  bool transferDataToPad( D_PAD* aPad );
107 
108  // event handlers:
109  void OnInitDialog( wxInitDialogEvent& event ) override;
110  void OnResize( wxSizeEvent& event );
111  void OnCancel( wxCommandEvent& event ) override;
112  void OnUpdateUI( wxUpdateUIEvent& event ) override;
113 
114  void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override
115  {
116  bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
117  m_nonCopperWarningBook->SetSelection( isOnCopperLayer ? 0 : 1 );
118  }
119 
120  void OnPadShapeSelection( wxCommandEvent& event ) override;
121  void OnDrillShapeSelected( wxCommandEvent& event ) override;
122  void onChangePadMode( wxCommandEvent& event ) override;
123 
124  void PadOrientEvent( wxCommandEvent& event ) override;
125  void PadTypeSelected( wxCommandEvent& event ) override;
126 
127  void OnSetLayers( wxCommandEvent& event ) override;
128  void OnPaintShowPanel( wxPaintEvent& event ) override;
129 
130  // Called when corner setup value is changed for rounded rect pads
131  void onCornerSizePercentChange( wxCommandEvent& event ) override;
132  void onCornerRadiusChange( wxCommandEvent& event ) override;
133 
136  void OnValuesChanged( wxCommandEvent& event ) override;
137 
140 
141  bool TransferDataFromWindow() override;
142  bool TransferDataToWindow() override;
143 
145  void onDeletePrimitive( wxCommandEvent& event ) override;
146  void onEditPrimitive( wxCommandEvent& event ) override;
147  void onAddPrimitive( wxCommandEvent& event ) override;
148  void onGeometryTransform( wxCommandEvent& event ) override;
149  void onDuplicatePrimitive( wxCommandEvent& event ) override;
150 
152  void onPrimitiveDClick( wxMouseEvent& event ) override;
154  void OnPrimitiveSelection( wxListEvent& event ) override;
155 };
156 
162 {
163 public:
164  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
165  PAD_CS_PRIMITIVE * aShape );
166 
171  bool TransferDataFromWindow() override;
172 
173 private:
178  bool TransferDataToWindow() override;
179 
180  // The basic shape currently edited
182 
193 };
194 
195 
200 {
201  // The basic shape currently edited
203 
204  // The working copy of the basic shape currently edited
206 
208 
209 public:
210  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
211  PAD_CS_PRIMITIVE * aShape );
213 
218  bool TransferDataFromWindow() override;
219 
220 private:
225  bool TransferDataToWindow() override;
226 
230  bool Validate() override;
231 
232  // Events handlers:
233  void OnValidateButton( wxCommandEvent& event );
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 };
248 
249 
258 {
259 public:
260  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
261  std::vector<PAD_CS_PRIMITIVE*>& aList, bool aShowDuplicate );
262 
270  void Transform( std::vector<PAD_CS_PRIMITIVE>* aList = NULL, int aDuplicateCount = 0 );
271 
275  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
276 
277 private:
278  std::vector<PAD_CS_PRIMITIVE*>& m_list;
279 
283 };
284 
285 #endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
void OnInitDialog(wxInitDialogEvent &event) override
DIALOG_PAD_PRIMITIVES_PROPERTIES(wxWindow *aParent, PCB_BASE_FRAME *aFrame, PAD_CS_PRIMITIVE *aShape)
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:676
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's members.
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 OnButtonDelete(wxCommandEvent &event) override
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
DIALOG_PAD_PRIMITIVES_TRANSFORM(wxWindow *aParent, PCB_BASE_FRAME *aFrame, std::vector< PAD_CS_PRIMITIVE * > &aList, bool aShowDuplicate)
bool TransferDataFromWindow() override
Function TransferDataFromWindow Transfer data out of the GUI.
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
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.
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:89
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:442
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.
DIALOG_PAD_PRIMITIVE_POLY_PROPS(wxWindow *aParent, PCB_BASE_FRAME *aFrame, PAD_CS_PRIMITIVE *aShape)
void onPolyPanelResize(wxSizeEvent &event) override
void OnDrillShapeSelected(wxCommandEvent &event) override
void onGeometryTransform(wxCommandEvent &event) override
void onPaintPolyPanel(wxPaintEvent &event) override
a dialog to edit basic polygonal shape parameters
void OnButtonAdd(wxCommandEvent &event) 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
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:161
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)
bool doValidate(bool aRemoveRedundantCorners)
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.
bool TransferDataFromWindow() override
Function TransferDataFromWindow 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.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39