42#include <wx/valtext.h>
79#define SetSortCodes( DirArray, Code ) \
81 g_SortYFirst = ( ( DirArray[Code] & SORTYFIRST ) != 0 ); \
82 g_DescendingFirst = ( ( DirArray[Code] & DESCENDINGFIRST ) != 0 ); \
83 g_DescendingSecond = ( ( DirArray[Code] & DESCENDINGSECOND ) != 0 ); \
97 m_frame( aParentFrame ),
98 m_footprints( aParentFrame->
GetBoard()->Footprints() )
114 { wxID_CANCEL,
_(
"Close" ) } } );
116 wxArrayString gridslist;
132 EndDialog( wxID_OK );
140 if( !selection.
Empty() )
151 if( aPrefix->GetValue().empty() )
154 char lastc = aPrefix->GetValue().Last();
156 if( isalnum( (
int) lastc ) )
159 if( tmps.find( lastc ) != std::string::npos )
162 tmps = aPrefix->GetValue();
165 aPrefix->AppendText( tmps );
207 ShowReport(
_(
"PCB annotation changes should be synchronized with schematic using "
224 rounder = aCoord % aGrid;
227 if( abs( rounder ) > ( aGrid / 2 ) )
228 aCoord += ( aCoord < 0 ? -aGrid : aGrid );
274 return wxString::Format( wxT(
"%s, %s" ),
282 wxStringTokenizer msgs( aMessage, wxT(
"\n" ) );
284 while( msgs.HasMoreTokens() )
294 message.Printf(
_(
"<br/>There are %i reference designator prefixes in use<br/>"
295 "**********************************************************<br/>" ),
299 message +=
info.RefDesPrefix + ( ( i++ % 16 ) == 0 ? wxT(
"<br/>" ) : wxS(
" " ) );
301 message += wxT(
"<br/>" );
308 excludes += exclude + wxS(
" " );
310 message += wxString::Format(
_(
"Excluding: %s from reannotation<br/>" ), excludes );
313 message +=
_(
"<br/>Change Array\n***********************<br/>" );
317 message += wxString::Format( wxT(
"%s -> %s %s %s\n" ),
318 change.OldRefDesString,
321 change.Action !=
UPDATE_REFDES ?
_(
"(will be ignored)" ) : wxString(
"" ) );
329 const std::vector<REFDES_INFO>& aFootprints )
331 wxString message = aMessage;
333 if( aFootprints.empty() )
334 message +=
_(
"<br/>No footprints" );
340 message +=
_(
"<br/>*********** Sort on Footprint Coordinates ***********" );
342 message +=
_(
"<br/>*********** Sort on Reference Coordinates ***********" );
346 message += wxString::Format(
_(
"<br/>%d %s X, Y: %s; rounded X, Y: %s" ),
360 std::vector<REFDES_INFO> BadRefDes;
361 wxString message, badrefdes;
372 if( !BadRefDes.empty() )
374 message.Printf(
_(
"<br/>PCB has %d empty or invalid reference designations."
375 "<br/>Recommend running DRC with 'Test for parity between PCB and schematic' checked.\n" ),
376 (
int) BadRefDes.size() );
380 badrefdes += wxString::Format(
_(
"<br/>RefDes: %s Footprint: %s:%s at %s on PCB." ),
382 mod.FPID.GetLibNickname().wx_str(),
383 mod.FPID.GetLibItemName().wx_str(),
388 message +=
_(
"Reannotate anyway?" );
400 if(
nullptr == newref )
403 commit.
Modify( footprint );
404 footprint->SetReference( newref->
NewRefDes );
408 commit.
Push(
_(
"Annotation" ) );
432 wxStringTokenizer tokenizer(
m_ExcludeList->GetValue(), wxS(
" ," ), wxTOKEN_STRTOK );
434 while( tokenizer.HasMoreTokens() )
442 fpData.
Uuid = footprint->m_Uuid;
444 fpData.
FPID = footprint->GetFPID();
445 fpData.
x = useFPLocation ? footprint->GetPosition().x
446 : footprint->Reference().GetPosition().x;
447 fpData.
y = useFPLocation ? footprint->GetPosition().y
448 : footprint->Reference().GetPosition().y;
451 fpData.
Front = footprint->GetLayer() ==
F_Cu;
460 firstnum = fpData.
RefDesString.find_first_of( wxT(
"0123456789" ) );
462 if( std::string::npos == firstnum )
478 if( footprint->IsLocked() && skipLocked )
480 else if( annotateSelected )
482 else if( annotateFront )
484 else if( annotateBack )
497 if( sortbuttons->GetValue() )
542 for(
size_t i = 0; i < changearraysize; i++ )
546 for(
size_t j = i + 1; j < changearraysize; j++ )
566 return ( errorcount == 0 );
571 std::vector<REFDES_INFO> excludedFootprints;
576 excludedFootprints.push_back( fpData );
582 excludedFootprints.push_back( fpData );
585 for(
const REFDES_INFO& fpData : excludedFootprints )
597 unsigned int aStartRefDes,
const wxString& aPrefix,
599 std::vector<REFDES_INFO>& aBadRefDes )
601 size_t prefixsize = aPrefix.size();
603 bool haveprefix = ( 0 != prefixsize );
604 bool addprefix = haveprefix & !aRemovePrefix;
605 aRemovePrefix &= haveprefix;
609 wxString logstring = ( aFootprints.front().Front ) ?
_(
"<br/><br/>Front Footprints" )
610 :
_(
"<br/><br/>Back Footprints" );
613 if( aStartRefDes != 0 )
623 change.
Uuid = fpData.Uuid;
624 change.
Action = fpData.Action;
627 change.
Front = fpData.Front;
629 if( fpData.RefDesString.IsEmpty() )
635 aBadRefDes.push_back( fpData );
641 prefixpresent = ( fpData.RefDesPrefix.find( aPrefix ) == 0 );
643 if( addprefix && !prefixpresent )
644 fpData.RefDesPrefix.insert( 0, aPrefix );
646 if( aRemovePrefix && prefixpresent )
647 fpData.RefDesPrefix.erase( 0, prefixsize );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
const FOOTPRINTS & Footprints() const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Class DIALOG_BOARD_REANNOTATE_BASE.
wxTextCtrl * m_FrontRefDesStart
wxStaticBitmap * reannotate_left_up_bitmap
wxStaticBitmap * reannotate_down_right_bitmap
wxTextCtrl * m_ExcludeList
wxTextCtrl * m_FrontPrefix
WX_HTML_REPORT_PANEL * m_MessageWindow
wxTextCtrl * m_BackRefDesStart
wxStaticText * m_SortGridText
wxStaticBitmap * reannotate_right_up_bitmap
wxCheckBox * m_ExcludeLocked
wxRadioButton * m_AnnotateBack
wxStaticBitmap * reannotate_up_right_bitmap
wxRadioButton * m_AnnotateFront
wxRadioButton * m_AnnotateSelection
wxCheckBox * m_RemoveFrontPrefix
wxStaticBitmap * reannotate_right_down_bitmap
wxTextCtrl * m_BackPrefix
wxCheckBox * m_RemoveBackPrefix
wxChoice * m_locationChoice
wxStaticText * m_ExcludeListText
wxStaticBitmap * reannotate_up_left_bitmap
wxStaticBitmap * reannotate_down_left_bitmap
wxStaticBitmap * reannotate_left_down_bitmap
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.
void FilterBackPrefix(wxCommandEvent &event) override
void LogFootprints(const wxString &aMessage, const std::vector< REFDES_INFO > &aFootprints)
Create a list of the footprints and their coordinates.
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.
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.
bool TransferDataToWindow() override
void LogChangePlan(void)
Create an audit trail of the changes.
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
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
The main frame for Pcbnew.
void OnModify() override
Must be called after a board change to set the modified flag.
bool Empty() const
Checks if there is anything selected.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
void SetLazyUpdate(bool aLazyUpdate)
Set the lazy update.
void SetFileName(const wxString &aReportFileName)
Set the report full file name to the string.
void Report(const wxString &aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation=REPORTER::LOC_BODY)
Report the string.
void Flush(bool aSort=false)
Force updating the HTML page, after the report is built in lazy mode If aSort = true,...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
This file is part of the common library.
int BackDirectionsArray[]
int FrontDirectionsArray[]
#define SetSortCodes(DirArray, Code)
static bool ChangeArrayCompare(const REFDES_CHANGE &aA, const REFDES_CHANGE &aB)
Compare function used to compare ChangeArray element for sort.
static bool FootprintCompare(const REFDES_INFO &aA, const REFDES_INFO &aB)
Compare function to sort footprints.
KICOMMON_API long long int ValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue in aUnits to internal units used by the application.
int GetRefDesNumber(const wxString &aRefDes)
Get the numeric suffix from a refdes - e.g.
Collection of utility functions for component reference designators (refdes)
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
std::vector< GRID > grids
Common grid settings, available to every frame.
unsigned int LastUsedRefDes
std::set< unsigned int > UnavailableRefs