KiCad PCB EDA Suite
dialog_board_reannotate.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) 2020 Brian Piccioni [email protected]
5 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Brian Piccioni <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef DIALOG_BOARD_REANNOTATE_H
27#define DIALOG_BOARD_REANNOTATE_H
28
29#include <board.h>
30#include <footprint.h>
32#include <layer_ids.h>
34#include <pcb_base_frame.h>
35#include <pcb_edit_frame.h>
36#include <project.h>
37#include <frame_type.h>
38#include <tool/actions.h>
39#include <tool/tool_manager.h>
41
42#define SORTXFIRST 0b000 // Sort on X
43#define SORTYFIRST 0b100 // Sort on Y
44#define ASCENDINGFIRST 0b000 // Sort low to high
45#define DESCENDINGFIRST 0b010 // Sort high to low
46#define ASCENDINGSECOND 0b000 // Sort low to high
47#define DESCENDINGSECOND 0b001 // Sort high to low
48
49#define MINGRID 1000
50#define MAXERROR 10
51#define VALIDPREFIX "_-+=/\\" // Prefixs can be alpha or these symbols
52
54{
59};
60
62{
67};
68
70{
72 wxString NewRefDes; // The new reference designation (F_U21)
73 wxString OldRefDesString; // What the old refdes preamble + number was
74 bool Front; // True if on the front of the board
75 ActionCode Action; // Used to skip (if #, etc)
76};
77
79{
81 bool Front; // True if on the front of the board
82 wxString RefDesString; // What its refdes is R1, C2
83 wxString RefDesType; // ie R, C, etc
84 int x, y; // The coordinates
85 int roundedx, roundedy; // The coordinates after rounding.
86 ActionCode Action; // Used to skip (if #, etc)
88};
89
91{
92 wxString RefDesType;
93 unsigned int LastUsedRefDes;
94 std::set<unsigned int> UnavailableRefs;
95};
96
97
99{
100public:
103
104private:
105 std::vector<wxRadioButton*> m_sortButtons = {
112 m_Up_Left,
114 };
115
116 std::vector<wxRadioButton*> m_scopeRadioButtons = {
121 };
122
123 std::vector<wxStaticBitmap*> Bitmaps = {
132 };
133
134 void GetParameters( void );
135
137 void InitValues( void );
138
139 void OnApplyClick( wxCommandEvent& event ) override;
140 void OnCloseClick( wxCommandEvent& event ) override;
141 void FilterFrontPrefix( wxCommandEvent& event ) override;
142 void FilterBackPrefix( wxCommandEvent& event ) override;
143
145 void ShowReport( const wxString& aMessage, SEVERITY aSeverity );
146
148 void LogFootprints( const wxString& aMessage, const std::vector<RefDesInfo>& aFootprints );
149
151 void LogChangePlan( void );
152
155 bool ReannotateBoard( void );
156
159 bool BuildFootprintList( std::vector<RefDesInfo>& aBadRefDes );
160
163
165 void BuildChangeArray( std::vector<RefDesInfo>& aFootprints, unsigned int aStartRefDes,
166 const wxString& aPrefix, bool aRemovePrefix,
167 std::vector<RefDesInfo>& aBadRefDes );
168
170 RefDesChange* GetNewRefDes( FOOTPRINT* aFootprint );
171
173 int RoundToGrid( int aCoord, int aGrid );
174
177 wxString CoordTowxString( int aX, int aY );
178
180 void MakeSampleText( wxString& aMessage );
181
183 void FilterPrefix( wxTextCtrl* aPrefix );
184
187 RefDesTypeStr* GetOrBuildRefDesInfo( const wxString& aRefDesPrefix, unsigned int aStartRefDes = 0 );
188
190 FOOTPRINTS m_footprints;
192
193 std::vector<RefDesChange> m_changeArray;
194 std::vector<RefDesInfo> m_frontFootprints;
195 std::vector<RefDesInfo> m_backFootprints;
196 std::vector<RefDesTypeStr> m_refDesTypes;
197 std::vector<wxString> m_excludeArray;
198
203
206
210
212
214};
215
216#endif /* DIALOG_BOARD_REANNOTATE_H */
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
Class DIALOG_BOARD_REANNOTATE_BASE.
void BuildChangeArray(std::vector< RefDesInfo > &aFootprints, unsigned int aStartRefDes, const wxString &aPrefix, bool aRemovePrefix, std::vector< RefDesInfo > &aBadRefDes)
Scan through the footprint arrays and create the from -> to array.
std::vector< wxString > m_excludeArray
std::vector< wxRadioButton * > m_scopeRadioButtons
void FilterBackPrefix(wxCommandEvent &event) override
std::vector< RefDesChange > m_changeArray
std::vector< RefDesInfo > m_frontFootprints
std::vector< wxStaticBitmap * > Bitmaps
wxString CoordTowxString(int aX, int aY)
Convert coordinates to wxString.
void FilterPrefix(wxTextCtrl *aPrefix)
Check to make sure the prefix (if there is one) is properly constructed.
int RoundToGrid(int aCoord, int aGrid)
Round an int coordinate to a suitable grid.
void MakeSampleText(wxString &aMessage)
Make the text to summarize what is about to happen.
void BuildUnavailableRefsList()
Build list of unavailable references. E.g. unselected footprints or locked footprints.
RefDesTypeStr * GetOrBuildRefDesInfo(const wxString &aRefDesPrefix, unsigned int aStartRefDes=0)
Get the structure representing the information currently held for aRefDesPrefix or create one if it d...
void LogChangePlan(void)
Create an audit trail of the changes.
bool BuildFootprintList(std::vector< RefDesInfo > &aBadRefDes)
Build the footprint lists, sort it, filter for excludes, then build the change list.
RefDesChange * GetNewRefDes(FOOTPRINT *aFootprint)
void OnCloseClick(wxCommandEvent &event) override
bool ReannotateBoard(void)
Actually reannotate the board.
void InitValues(void)
Copy saved app settings to the dialog.
void ShowReport(const wxString &aMessage, SEVERITY aSeverity)
Break report into strings separated by and sent to the reporter.
std::vector< RefDesInfo > m_backFootprints
DIALOG_BOARD_REANNOTATE(PCB_EDIT_FRAME *aParentFrame)
void OnApplyClick(wxCommandEvent &event) override
std::vector< wxRadioButton * > m_sortButtons
void LogFootprints(const wxString &aMessage, const std::vector< RefDesInfo > &aFootprints)
Create a list of the footprints and their coordinates.
std::vector< RefDesTypeStr > m_refDesTypes
void FilterFrontPrefix(wxCommandEvent &event) override
Definition: kiid.h:48
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
The main frame for Pcbnew.
@ AnnotateSelected
SEVERITY
unsigned int LastUsedRefDes
std::set< unsigned int > UnavailableRefs