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, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
23#include "string_utils.h"
24
25#include <memory>
26#include <vector>
27#include <pad.h>
28
29class PCB_BASE_FRAME;
30class FOOTPRINT;
31class UNITS_PROVIDER;
32
34{
35public:
36 // Column indices (after adding Type column)
50
51 DIALOG_FP_EDIT_PAD_TABLE( PCB_BASE_FRAME* aParent, FOOTPRINT* aFootprint );
53
54 bool TransferDataToWindow() override;
55 bool TransferDataFromWindow() override;
58
59private:
60 void OnSize( wxSizeEvent& aEvent ) override;
61 void OnCharHook( wxKeyEvent& aEvent ) override;
62 void OnCellChanged( wxGridEvent& aEvent ) override;
63 void OnSelectCell( wxGridEvent& aEvent ) override;
64 void OnUpdateUI( wxUpdateUIEvent& aEvent ) override;
65 void OnCancel( wxCommandEvent& aEvent ) override;
66
68
69 void updateSummary();
70 void setRowNullableEditors( int aRowId ) const;
71
72 PAD* getPadForRow( int aRowId ) const;
73
74private:
76
77 // Proportional resize support
78 std::vector<double> m_colProportions; // relative widths captured after init
79 std::vector<int> m_minColWidths; // initial (minimum) widths
80
97
98 // Comparison function to order the pads in the map
100 {
101 bool operator()( const PAD* a, const PAD* b ) const
102 {
103 const int cmpVal = StrNumCmp( a->GetNumber(), b->GetNumber() );
104
105 // First sort by alphanumeric ordering
106 if( cmpVal < 0 )
107 return true;
108
109 if( cmpVal > 0 )
110 return false;
111
112 // Sort by x and then y
113 if( a->GetCenter().x < b->GetCenter().x )
114 return true;
115
116 if( a->GetCenter().x > b->GetCenter().x )
117 return false;
118
119 if( a->GetCenter().y < b->GetCenter().y )
120 return true;
121
122 if( a->GetCenter().y > b->GetCenter().y )
123 return false;
124
125 // For degenerate pads, sort by raw pointer value
126 return a < b;
127 }
128 };
129
130 std::map<PAD*, PAD_SNAPSHOT, PAD_SNAPSHOT_COMPARE> m_originalPads; // original pad data for cancel rollback
131 bool m_cancelled = false; // set if user hit cancel
132
134 std::unique_ptr<UNITS_PROVIDER> m_unitsProvider;
136};
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:61
const wxString & GetNumber() const
Definition pad.h:143
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pad.h:324
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:683