KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_fp_edit_pad_table.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
27#include "string_utils.h"
28
29#include <memory>
30#include <vector>
31#include <pad.h>
32
33class PCB_BASE_FRAME;
34class FOOTPRINT;
35class UNITS_PROVIDER;
36
38{
39public:
40 // Column indices (after adding Type column)
54
55 DIALOG_FP_EDIT_PAD_TABLE( PCB_BASE_FRAME* aParent, FOOTPRINT* aFootprint );
57
58 bool TransferDataToWindow() override;
59 bool TransferDataFromWindow() override;
62
63private:
64 void OnSize( wxSizeEvent& aEvent ) override;
65 void OnCharHook( wxKeyEvent& aEvent ) override;
66 void OnCellChanged( wxGridEvent& aEvent ) override;
67 void OnSelectCell( wxGridEvent& aEvent ) override;
68 void OnUpdateUI( wxUpdateUIEvent& aEvent ) override;
69 void OnCancel( wxCommandEvent& aEvent ) override;
70
72
73 void updateSummary();
74 void setRowNullableEditors( int aRowId ) const;
75
76 PAD* getPadForRow( int aRowId ) const;
77
78private:
80
81 // Proportional resize support
82 std::vector<double> m_colProportions; // relative widths captured after init
83 std::vector<int> m_minColWidths; // initial (minimum) widths
84
101
102 // Comparison function to order the pads in the map
104 {
105 bool operator()( const PAD* a, const PAD* b ) const
106 {
107 const int cmpVal = StrNumCmp( a->GetNumber(), b->GetNumber() );
108
109 // First sort by alphanumeric ordering
110 if( cmpVal < 0 )
111 return true;
112
113 if( cmpVal > 0 )
114 return false;
115
116 // Sort by x and then y
117 if( a->GetCenter().x < b->GetCenter().x )
118 return true;
119
120 if( a->GetCenter().x > b->GetCenter().x )
121 return false;
122
123 if( a->GetCenter().y < b->GetCenter().y )
124 return true;
125
126 if( a->GetCenter().y > b->GetCenter().y )
127 return false;
128
129 // For degenerate pads, sort by raw pointer value
130 return a < b;
131 }
132 };
133
134 std::map<PAD*, PAD_SNAPSHOT, PAD_SNAPSHOT_COMPARE> m_originalPads; // original pad data for cancel rollback
135 bool m_cancelled = false; // set if user hit cancel
136
138 std::unique_ptr<UNITS_PROVIDER> m_unitsProvider;
140};
DIALOG_FP_EDIT_PAD_TABLE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Pad Table"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
PAD * getPadForRow(int aRowId) const
void OnCellChanged(wxGridEvent &aEvent) override
DIALOG_FP_EDIT_PAD_TABLE(PCB_BASE_FRAME *aParent, FOOTPRINT *aFootprint)
void OnCharHook(wxKeyEvent &aEvent) override
void OnSelectCell(wxGridEvent &aEvent) override
std::map< PAD *, PAD_SNAPSHOT, PAD_SNAPSHOT_COMPARE > m_originalPads
void setRowNullableEditors(int aRowId) const
void OnSize(wxSizeEvent &aEvent) override
void OnCancel(wxCommandEvent &aEvent) override
std::vector< double > m_colProportions
std::unique_ptr< UNITS_PROVIDER > m_unitsProvider
void OnUpdateUI(wxUpdateUIEvent &aEvent) override
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition padstack.h:157
Definition pad.h:55
const wxString & GetNumber() const
Definition pad.h:137
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pad.h:331
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition padstack.h:97
@ PTH
Plated through hole pad.
Definition padstack.h:98
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:52
@ CHAMFERED_RECT
Definition padstack.h:60
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
bool operator()(const PAD *a, const PAD *b) const
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687