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<std::shared_ptr<DRAWSEGMENT>> m_primitives; // the custom shape primitives in
66  // 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
73  KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
74  static bool m_sketchPreview; // session storage
75 
83  wxFloatingPointValidator<double> m_OrientValidator;
84  double m_OrientValue;
88 
89 private:
90  void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
91  void initValues();
92  void displayPrimitivesList();
93  bool padValuesOK();
94  void redraw();
95  void editPrimitive();
97  void enablePrimitivePage( bool aEnable );
98 
104  void setPadLayersList( LSET layer_mask );
105 
107  bool transferDataToPad( D_PAD* aPad );
108 
109  // event handlers:
110  void OnInitDialog( wxInitDialogEvent& event ) override;
111  void OnResize( wxSizeEvent& event );
112  void OnCancel( wxCommandEvent& event ) override;
113  void OnUpdateUI( wxUpdateUIEvent& event ) override;
114 
115  void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override
116  {
117  bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
118  m_nonCopperWarningBook->SetSelection( isOnCopperLayer ? 0 : 1 );
119  }
120 
121  void OnPadShapeSelection( wxCommandEvent& event ) override;
122  void OnDrillShapeSelected( wxCommandEvent& event ) override;
123  void onChangePadMode( wxCommandEvent& event ) override;
124  void OnOffsetCheckbox( wxCommandEvent& event ) override;
125  void OnPadToDieCheckbox( wxCommandEvent& event ) override;
126 
127  void PadOrientEvent( wxCommandEvent& event ) override;
128  void PadTypeSelected( wxCommandEvent& event ) override;
129 
130  void OnSetLayers( wxCommandEvent& event ) override;
131 
132  // Called when corner setup value is changed for rounded rect pads
133  void onCornerSizePercentChange( wxCommandEvent& event ) override;
134  void onCornerRadiusChange( wxCommandEvent& event ) override;
135 
138  void OnValuesChanged( wxCommandEvent& event ) override;
139 
142 
143  bool TransferDataFromWindow() override;
144  bool TransferDataToWindow() override;
145 
147  void onDeletePrimitive( wxCommandEvent& event ) override;
148  void onEditPrimitive( wxCommandEvent& event ) override;
149  void onAddPrimitive( wxCommandEvent& event ) override;
150  void onGeometryTransform( wxCommandEvent& event ) override;
151  void onDuplicatePrimitive( wxCommandEvent& event ) override;
152 
154  void onPrimitiveDClick( wxMouseEvent& event ) override;
156  void OnPrimitiveSelection( wxListEvent& event ) override;
157 
160 };
161 
167 {
168 public:
169  DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
170  DRAWSEGMENT* aShape );
171 
176  bool TransferDataFromWindow() override;
177 
178 private:
183  bool TransferDataToWindow() override;
184 
185  // The basic shape currently edited
187 
198 };
199 
200 
205 {
206  // The basic shape currently edited
208 
209  // The working copy of the basic shape currently edited
210  std::vector<wxPoint> m_currPoints;
211 
213 
214 public:
215  DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
216  DRAWSEGMENT* aShape );
218 
223  bool TransferDataFromWindow() override;
224 
225 private:
230  bool TransferDataToWindow() override;
231 
235  bool Validate() override;
236 
237  // Events handlers:
238  void OnButtonAdd( wxCommandEvent& event ) override;
239  void OnButtonDelete( wxCommandEvent& event ) override;
240  void onPaintPolyPanel( wxPaintEvent& event ) override;
241  void onPolyPanelResize( wxSizeEvent& event ) override;
242  void onGridSelect( wxGridRangeSelectEvent& event ) override;
243  void onCellChanging( wxGridEvent& event );
244  void onCellSelect( wxGridEvent& event ) override
245  {
246  event.Skip();
247  }
248 
249  bool doValidate( bool aRemoveRedundantCorners );
250 
251 };
252 
253 
262 {
263 public:
264  DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
265  std::vector<std::shared_ptr<DRAWSEGMENT>>& aList,
266  bool aShowDuplicate );
267 
275  void Transform( std::vector<std::shared_ptr<DRAWSEGMENT>>* aList = NULL,
276  int aDuplicateCount = 0 );
277 
281  int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
282 
283 private:
284  std::vector<std::shared_ptr<DRAWSEGMENT>>& m_list;
285 
289 };
290 
291 #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:712
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
PAD_PROP_T getSelectedProperty()
Return the pad property currently selected.
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 OnPadToDieCheckbox(wxCommandEvent &event) override
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 onCornerSizePercentChange(wxCommandEvent &event) override
bool TransferDataFromWindow() override
Function TransferDataFromWindow Transfer data out of the GUI.
Classes used in Pcbnew, CvPcb and GerbView.
DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE, created by wxFormBuilder.
Class DIALOG_PAD_PRIMITIVES_TRANSFORM_BASE.
KIGFX::ORIGIN_VIEWITEM * m_axisOrigin
DIALOG_PAD_PRIMITIVES_TRANSFORM(wxWindow *aParent, PCB_BASE_FRAME *aFrame, std::vector< std::shared_ptr< DRAWSEGMENT >> &aList, bool aShowDuplicate)
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.
LSET is a set of PCB_LAYER_IDs.
#define NULL
void onGridSelect(wxGridRangeSelectEvent &event) override
void OnSetLayers(wxCommandEvent &event) override
void Transform(std::vector< std::shared_ptr< DRAWSEGMENT >> *aList=NULL, int aDuplicateCount=0)
Apply geometric transform (rotation, move, scale) defined in dialog aDuplicate = 1 .
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:325
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, DRAWSEGMENT *aShape)
void OnDrillShapeSelected(wxCommandEvent &event) override
PAD_PROP_T
Enum PAD_PROP_T is the set of pad properties used in Gerber files (Draw files, and P&P files) to defi...
Definition: pad_shapes.h:95
DIALOG_PAD_PRIMITIVE_POLY_PROPS(wxWindow *aParent, PCB_BASE_FRAME *aFrame, DRAWSEGMENT *aShape)
void onGeometryTransform(wxCommandEvent &event) override
std::vector< std::shared_ptr< DRAWSEGMENT > > m_primitives
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
Class to handle a graphic segment.
void onDeletePrimitive(wxCommandEvent &event) override
Event handlers of basic shapes list panel.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
void onDuplicatePrimitive(wxCommandEvent &event) override
std::vector< std::shared_ptr< DRAWSEGMENT > > & m_list
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)
std::vector< DRAWSEGMENT * > m_highlight
A dialog to apply geometry transforms to a shape or set of shapes (move, rotate around origin,...
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.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99