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 ); \
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 wxString::Format( wxT(
"%s, %s" ),
287 m_frame->MessageTextFromValue( aX ),
288 m_frame->MessageTextFromValue( aY ) );
294 wxStringTokenizer msgs( aMessage,
"\n" );
296 while( msgs.HasMoreTokens() )
306 message.Printf(
_(
"<br/>There are %i reference designator prefixes in use<br/>"
307 "**********************************************************<br/>" ),
311 message +=
info.RefDesPrefix + ( ( i++ % 16 ) == 0 ? wxT(
"<br/>" ) : wxS(
" " ) );
313 message += wxT(
"<br/>" );
320 excludes += exclude + wxS(
" " );
322 message += wxString::Format(
_(
"Excluding: %s from reannotation<br/>" ), excludes );
325 message +=
_(
"<br/>Change Array\n***********************<br/>" );
329 message += wxString::Format( wxT(
"%s -> %s %s %s\n" ),
330 change.OldRefDesString,
333 change.Action !=
UPDATE_REFDES ?
_(
"(will be ignored)" ) : wxString(
"" ) );
341 const std::vector<REFDES_INFO>& aFootprints )
343 wxString message = aMessage;
345 if( aFootprints.empty() )
346 message +=
_(
"<br/>No footprints" );
352 message +=
_(
"<br/>*********** Sort on Footprint Coordinates ***********" );
354 message +=
_(
"<br/>*********** Sort on Reference Coordinates ***********" );
358 message += wxString::Format(
_(
"<br/>%d %s X, Y: %s; rounded X, Y: %s" ),
372 std::vector<REFDES_INFO> BadRefDes;
373 wxString message, badrefdes;
384 if( !BadRefDes.empty() )
386 message.Printf(
_(
"<br/>PCB has %d empty or invalid reference designations."
387 "<br/>Recommend running DRC with 'Test for parity between PCB and schematic' checked.\n" ),
388 (
int) BadRefDes.size() );
392 badrefdes += wxString::Format(
_(
"<br/>RefDes: %s Footprint: %s:%s at %s on PCB." ),
394 mod.FPID.GetLibNickname().wx_str(),
395 mod.FPID.GetLibItemName().wx_str(),
400 message +=
_(
"Reannotate anyway?" );
412 if(
nullptr == newref )
415 commit.
Modify( footprint );
416 footprint->SetReference( newref->
NewRefDes );
417 m_frame->GetCanvas()->GetView()->Update( footprint );
420 commit.
Push(
_(
"Annotation" ) );
444 wxStringTokenizer tokenizer(
m_ExcludeList->GetValue(),
" ,", wxTOKEN_STRTOK );
446 while( tokenizer.HasMoreTokens() )
454 fpData.
Uuid = footprint->m_Uuid;
456 fpData.
FPID = footprint->GetFPID();
457 fpData.
x = useFPLocation ? footprint->GetPosition().x
458 : footprint->Reference().GetPosition().x;
459 fpData.
y = useFPLocation ? footprint->GetPosition().y
460 : footprint->Reference().GetPosition().y;
463 fpData.
Front = footprint->GetLayer() ==
F_Cu;
472 firstnum = fpData.
RefDesString.find_first_of( wxT(
"0123456789" ) );
474 if( std::string::npos == firstnum )
490 if( footprint->IsLocked() && skipLocked )
492 else if( annotateSelected )
494 else if( annotateFront )
496 else if( annotateBack )
509 if( sortbuttons->GetValue() )
554 for(
size_t i = 0; i < changearraysize; i++ )
558 for(
size_t j = i + 1; j < changearraysize; j++ )
578 return ( errorcount == 0 );
583 std::vector<REFDES_INFO> excludedFootprints;
588 excludedFootprints.push_back( fpData );
594 excludedFootprints.push_back( fpData );
597 for(
const REFDES_INFO& fpData : excludedFootprints )
609 unsigned int aStartRefDes,
const wxString& aPrefix,
611 std::vector<REFDES_INFO>& aBadRefDes )
613 size_t prefixsize = aPrefix.size();
615 bool haveprefix = ( 0 != prefixsize );
616 bool addprefix = haveprefix & !aRemovePrefix;
617 aRemovePrefix &= haveprefix;
621 wxString logstring = ( aFootprints.front().Front ) ?
_(
"<br/><br/>Front Footprints" )
622 :
_(
"<br/><br/>Back Footprints" );
625 if( aStartRefDes != 0 )
635 change.
Uuid = fpData.Uuid;
636 change.
Action = fpData.Action;
639 change.
Front = fpData.Front;
641 if( fpData.RefDesString.IsEmpty() )
647 aBadRefDes.push_back( fpData );
653 prefixpresent = ( fpData.RefDesPrefix.find( aPrefix ) == 0 );
655 if( addprefix && !prefixpresent )
656 fpData.RefDesPrefix.insert( 0, aPrefix );
658 if( aRemovePrefix && prefixpresent )
659 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
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...
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