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 ); \
90 _(
"(unannotated; not updated)" ),
114 { wxID_CANCEL,
_(
"Close" ) } } );
116 wxArrayString gridslist;
121 int gridIndex =
m_frame->config()->m_Window.grid.last_size_idx;
123 if( gridIndex >= 0 && gridIndex < (
int)
m_GridChoice->GetCount() )
139 EndDialog( wxID_OK );
147 if( !selection.
Empty() )
163 if( aPrefix->GetValue().empty() )
166 char lastc = aPrefix->GetValue().Last();
168 if( isalnum( (
int) lastc ) )
171 if( tmps.find( lastc ) != std::string::npos )
174 tmps = aPrefix->GetValue();
177 aPrefix->AppendText( tmps );
219 ShowReport(
_(
"PCB annotation changes should be synchronized with schematic using "
225 m_frame->GetCanvas()->Refresh();
236 rounder = aCoord % aGrid;
239 if( abs( rounder ) > ( aGrid / 2 ) )
240 aCoord += ( aCoord < 0 ? -aGrid : aGrid );
286 return wxT(
"<i>" ) +
_(
"unannotated footprint" ) + wxT(
"</i>" );
292 return wxT(
"<i>" ) +
_(
"unknown" ) + wxT(
"</i>" );
298 return wxString::Format( wxT(
"%s, %s" ),
299 m_frame->MessageTextFromValue( aX ),
300 m_frame->MessageTextFromValue( aY ) );
306 wxStringTokenizer msgs( aMessage,
"\n" );
308 while( msgs.HasMoreTokens() )
317 message =
_(
"Reference Designator Prefixes in Use" );
318 message += wxT(
"<br/>-------------------------------------------------------------<br/>" );
323 message +=
info.RefDesPrefix + ( ( i++ % 16 ) == 0 ? wxT(
"<br/>" ) : wxS(
" " ) );
325 message += wxT(
"<br/>" );
332 excludes += exclude + wxS(
" " );
334 message += wxString::Format(
_(
"(Excluding %s from reannotation.)" ), excludes );
339 message =
_(
"Change Log" );
340 message += wxT(
"<br/>-------------------------------------------------------------<br/>" );
346 message += wxString::Format( wxT(
"%s <i>%s</i><br/>" ),
347 change.OldRefDesString.IsEmpty() ?
empty_str() : change.OldRefDesString,
352 message += wxString::Format( wxT(
"%s -> %s<br/>" ),
353 change.OldRefDesString.IsEmpty() ?
empty_str() : change.OldRefDesString,
354 change.NewRefDes.IsEmpty() ?
empty_str() : change.NewRefDes );
364 wxString message = aFootprints.front().Front ?
_(
"Front Footprints" ) :
_(
"Back Footprints" );
368 message +=
_(
"(sorted by footprint location)" );
370 message +=
_(
"(sorted by reference designator location)" );
372 message += wxT(
"<br/>-------------------------------------------------------------" );
378 message += wxString::Format(
_(
"<br/>%d %s at %s (rounded to %s)" ),
380 fp.RefDesString.IsEmpty() ?
empty_str() : fp.RefDesString,
391 std::vector<REFDES_INFO> BadRefDes;
392 wxString message1, message2, badrefdes;
403 if( !BadRefDes.empty() )
405 message1.Printf(
_(
"PCB has %d empty or invalid reference designations." ), (
int) BadRefDes.size() );
406 message2.Printf(
_(
"You may wish to run DRC with 'Test for parity between PCB and schematic' checked." ) );
410 badrefdes += wxString::Format(
_(
"<br/> RefDes: %s; footprint: %s at %s on PCB." ),
411 mod.RefDesString.IsEmpty() ?
empty_str() : mod.RefDesString,
412 mod.FPID.IsValid() ? wxString( mod.FPID.Format().c_str() ) :
unknown_str(),
418 if( !
IsOK(
m_frame, message1 +
"\n" + message2 +
"\n \n" +
_(
"Reannotate anyway?" ) ) )
428 if(
nullptr == newref )
431 commit.
Modify( footprint );
432 footprint->SetReference( newref->
NewRefDes );
433 m_frame->GetCanvas()->GetView()->Update( footprint );
436 commit.
Push(
_(
"Annotation" ) );
460 wxStringTokenizer tokenizer(
m_ExcludeList->GetValue(),
", \t\r\n", wxTOKEN_STRTOK );
462 while( tokenizer.HasMoreTokens() )
470 fpData.
Uuid = footprint->m_Uuid;
472 fpData.
FPID = footprint->GetFPID();
473 fpData.
x = useFPLocation ? footprint->GetPosition().x
474 : footprint->Reference().GetPosition().x;
475 fpData.
y = useFPLocation ? footprint->GetPosition().y
476 : footprint->Reference().GetPosition().y;
479 fpData.
Front = footprint->GetLayer() ==
F_Cu;
488 firstnum = fpData.
RefDesString.find_first_of( wxT(
"0123456789" ) );
490 if( std::string::npos == firstnum )
500 if( excluded.EndsWith(
'*' ) )
515 if( footprint->IsLocked() && skipLocked )
517 else if( annotateSelected )
519 else if( annotateFront )
521 else if( annotateBack )
534 if( sortbuttons->GetValue() )
579 for(
size_t i = 0; i < changearraysize; i++ )
583 for(
size_t j = i + 1; j < changearraysize; j++ )
603 return ( errorcount == 0 );
608 std::vector<REFDES_INFO> excludedFootprints;
613 excludedFootprints.push_back( fpData );
619 excludedFootprints.push_back( fpData );
622 for(
const REFDES_INFO& fpData : excludedFootprints )
634 unsigned int aStartRefDes,
const wxString& aPrefix,
635 bool aRemovePrefix, std::vector<REFDES_INFO>& aBadRefDes )
637 size_t prefixsize = aPrefix.size();
639 bool haveprefix = ( 0 != prefixsize );
640 bool addprefix = haveprefix & !aRemovePrefix;
641 aRemovePrefix &= haveprefix;
647 if( aStartRefDes != 0 )
650 prefixInfo.LastUsedRefDes = aStartRefDes - 1;
657 change.
Uuid = fpData.Uuid;
658 change.
Action = fpData.Action;
661 change.
Front = fpData.Front;
663 if( fpData.RefDesString.IsEmpty() )
669 aBadRefDes.push_back( fpData );
675 prefixpresent = ( fpData.RefDesPrefix.find( aPrefix ) == 0 );
677 if( addprefix && !prefixpresent )
678 fpData.RefDesPrefix.insert( 0, aPrefix );
680 if( aRemovePrefix && prefixpresent )
681 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.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
wxTextCtrl * m_FrontRefDesStart
wxStaticBitmap * reannotate_left_up_bitmap
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)
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
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.
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...
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.
The main frame for Pcbnew.
bool Empty() const
Checks if there is anything selected.
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.
Common grid settings, available to every frame.
unsigned int LastUsedRefDes
std::set< unsigned int > UnavailableRefs