KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <map>
25#include <set>
26
28#include <layer_ids.h>
30#include <pcb_base_frame.h>
31#include <pcb_edit_frame.h>
32#include <project.h>
33#include <frame_type.h>
34#include <tool/actions.h>
35#include <tool/tool_manager.h>
37
38#define SORTXFIRST 0b000 // Sort on X
39#define SORTYFIRST 0b100 // Sort on Y
40#define ASCENDINGFIRST 0b000 // Sort low to high
41#define DESCENDINGFIRST 0b010 // Sort high to low
42#define ASCENDINGSECOND 0b000 // Sort low to high
43#define DESCENDINGSECOND 0b001 // Sort high to low
44
45#define MINGRID 1000
46#define MAXERROR 10
47#define VALIDPREFIX "_-+=/\\" // Prefixs can be alpha or these symbols
48
57
59{
61 wxString NewRefDes; // The new reference designation (F_U21)
62 wxString OldRefDesString; // What the old refdes preamble + number was
63 bool Front; // True if on the front of the board
64 ACTION_CODE Action; // Used to skip (if #, etc)
65 wxString Suffix; // Sheet suffix kept after the new number
66 KIID Representative; // Footprint whose new base this one takes
67};
68
70{
72 bool Front; // True if on the front of the board
73 wxString RefDesString; // What its refdes is R1, C2
74 wxString RefDesPrefix; // ie R, C, etc
75 int x, y; // The coordinates
76 int roundedx, roundedy; // The coordinates after rounding.
77 ACTION_CODE Action; // Used to skip (if #, etc)
79 wxString Suffix; // Sheet suffix of a copy on a reused sheet
80 KIID Representative; // Copy whose placement numbers the base this one shares
81 bool Shared; // One of the copies on reused sheets that share a base
82 bool Held; // Locked or explicitly excluded, so copies sharing its base keep theirs too
83};
84
86{
87 wxString RefDesPrefix;
88 unsigned int LastUsedRefDes;
89 std::set<unsigned int> UnavailableRefs;
90};
91
92
94{
95public:
98
99private:
100 std::vector<wxRadioButton*> m_sortButtons = {
107 m_Up_Left,
109 };
110
111 std::vector<wxRadioButton*> m_scopeRadioButtons = {
116 };
117
128
129 bool TransferDataToWindow() override;
130
131 void OnApplyClick( wxCommandEvent& event ) override;
132 void OnCloseClick( wxCommandEvent& event ) override;
133 void FilterFrontPrefix( wxCommandEvent& event ) override;
134 void FilterBackPrefix( wxCommandEvent& event ) override;
135
137 void ShowReport( const wxString& aMessage, SEVERITY aSeverity );
138
140 void LogFootprints( const std::vector<REFDES_INFO>& aFootprints );
141
143 void LogChangePlan( void );
144
147 bool ReannotateBoard( void );
148
151 bool BuildFootprintList( std::vector<REFDES_INFO>& aBadRefDes );
152
155
157 void BuildChangeArray( std::vector<REFDES_INFO>& aFootprints, unsigned int aStartRefDes,
158 const wxString& aPrefix, bool aRemovePrefix,
159 std::vector<REFDES_INFO>& aBadRefDes );
160
162 REFDES_CHANGE* GetNewRefDes( FOOTPRINT* aFootprint );
163
165 int RoundToGrid( int aCoord, int aGrid );
166
169 wxString CoordTowxString( int aX, int aY );
170
172 void FilterPrefix( wxTextCtrl* aPrefix );
173
176 REFDES_PREFIX_INFO* GetOrBuildRefDesInfo( const wxString& aRefDesPrefix, int aStartRefDes = 1 );
177
178private:
181
182 std::vector<REFDES_CHANGE> m_changeArray;
183 std::vector<REFDES_INFO> m_frontFootprints;
184 std::vector<REFDES_INFO> m_backFootprints;
185 std::vector<REFDES_PREFIX_INFO> m_refDesPrefixInfos;
186 std::vector<wxString> m_excludeArray;
187
188 std::map<KIID, std::vector<wxString>> m_groupSuffixes; // Suffixes of the copies each representative numbers
189 std::map<KIID, wxString> m_newBases;
190 std::set<wxString> m_takenRefs; // Kept and assigned references
191 std::set<wxString> m_suffixedRefs; // The taken references that end in a sheet suffix
192};
DIALOG_BOARD_REANNOTATE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Geographical Reannotation"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
std::vector< REFDES_CHANGE > m_changeArray
std::vector< wxString > m_excludeArray
bool BuildFootprintList(std::vector< REFDES_INFO > &aBadRefDes)
Build the footprint lists, sort it, filter for excludes, then build the change list.
std::map< KIID, std::vector< wxString > > m_groupSuffixes
std::vector< wxRadioButton * > m_scopeRadioButtons
void FilterBackPrefix(wxCommandEvent &event) override
std::map< KIID, wxString > m_newBases
std::vector< wxStaticBitmap * > Bitmaps
std::vector< REFDES_INFO > m_frontFootprints
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.
void BuildChangeArray(std::vector< REFDES_INFO > &aFootprints, unsigned int aStartRefDes, const wxString &aPrefix, bool aRemovePrefix, std::vector< REFDES_INFO > &aBadRefDes)
Scan through the footprint arrays and create the from -> to array.
void LogFootprints(const std::vector< REFDES_INFO > &aFootprints)
Create a list of the footprints and their coordinates.
int RoundToGrid(int aCoord, int aGrid)
Round an int coordinate to a suitable grid.
REFDES_PREFIX_INFO * GetOrBuildRefDesInfo(const wxString &aRefDesPrefix, int aStartRefDes=1)
Get the structure representing the information currently held for aRefDesPrefix or create one if it d...
void BuildUnavailableRefsList()
Build list of unavailable references. E.g. unselected footprints or locked footprints.
~DIALOG_BOARD_REANNOTATE()=default
void LogChangePlan(void)
Create an audit trail of the changes.
std::set< wxString > m_suffixedRefs
void OnCloseClick(wxCommandEvent &event) override
REFDES_CHANGE * GetNewRefDes(FOOTPRINT *aFootprint)
bool ReannotateBoard(void)
Actually reannotate the board.
void ShowReport(const wxString &aMessage, SEVERITY aSeverity)
Break report into strings separated by and sent to the reporter.
std::vector< REFDES_INFO > m_backFootprints
std::vector< REFDES_PREFIX_INFO > m_refDesPrefixInfos
DIALOG_BOARD_REANNOTATE(PCB_EDIT_FRAME *aParentFrame)
void OnApplyClick(wxCommandEvent &event) override
std::vector< wxRadioButton * > m_sortButtons
void FilterFrontPrefix(wxCommandEvent &event) override
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
The main frame for Pcbnew.
@ UNKNOWN_SUFFIX_REFDES
std::deque< FOOTPRINT * > FOOTPRINTS
SEVERITY
std::set< unsigned int > UnavailableRefs