38#include <boost/property_tree/ptree.hpp>
41#include <wx/choicdlg.h>
42#include <wx/filedlg.h>
51 bool isChanged =
false;
53 m_frame->Schematic().Hierarchy().GetSymbols( refs,
false );
62 CPTREE& back_anno = doc.get_child(
"cvpcb_netlist" );
65 for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
67 wxASSERT( ref->first ==
"ref" );
69 wxString reference =
UTF8( ref->second.front().first );
72 if( ref->second.get_child(
"fpid" ).size() )
74 wxString tmp =
UTF8( ref->second.get_child(
"fpid" ).front().first );
81 for(
unsigned ii = 0; ii < refs.
GetCount(); ++ii )
83 if( reference == refs[ii].GetRef() )
92 wxString oldfp = refs[ii].GetFootprint();
95 if( oldfp.IsEmpty() && footprintField->
IsVisible() )
98 if( oldfp != footprint )
101 SCH_SCREEN* screen = refs[ii].GetSheetPath().LastScreen();
104 footprintField->
SetText( footprint );
119 commit.
Push( wxS(
"Assign Footprints" ) );
125 bool aForceVisibilityState,
126 bool aVisibilityState )
130 m_frame->Schematic().Hierarchy().GetSymbols( referencesList,
false );
132 FILE* cmpFile = wxFopen( aFullFilename, wxT(
"rt" ) );
134 if( cmpFile ==
nullptr )
151 if( !buffer.StartsWith( wxT(
"BeginCmp" ) ) )
162 if( buffer.StartsWith( wxT(
"EndCmp" ) ) )
166 value = buffer.AfterFirst(
'=' );
167 value = value.BeforeLast(
';' );
171 if( buffer.StartsWith( wxT(
"Reference" ) ) )
173 else if( buffer.StartsWith( wxT(
"IdModule" ) ) )
179 if( reference.IsEmpty() )
183 for(
unsigned ii = 0; ii < referencesList.
GetCount(); ii++ )
185 if( reference == referencesList[ii].GetRef() )
190 SCH_SYMBOL* symbol = referencesList[ ii ].GetSymbol();
194 if( aForceVisibilityState )
206 wxString
path = wxPathOnly(
m_frame->Prj().GetProjectFullName() );
208 wxFileDialog dlg(
m_frame,
_(
"Load Symbol Footprint Link File" ),
211 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
215 if( dlg.ShowModal() == wxID_CANCEL )
218 wxString filename = dlg.GetPath();
220 wxArrayString choices;
221 choices.Add(
_(
"Keep existing footprint field visibility" ) );
222 choices.Add(
_(
"Show all footprint fields" ) );
223 choices.Add(
_(
"Hide all footprint fields" ) );
225 wxSingleChoiceDialog choiceDlg(
m_frame,
_(
"Select the footprint field visibility setting." ),
226 _(
"Change Visibility" ), choices );
228 if( choiceDlg.ShowModal() == wxID_CANCEL )
231 bool forceVisibility = (choiceDlg.GetSelection() != 0 );
232 bool visibilityState = (choiceDlg.GetSelection() == 1 );
236 wxString msg = wxString::Format(
_(
"Failed to open symbol-footprint link file '%s'." ),
237 filename.GetData() );
244 m_frame->GetCanvas()->Refresh();
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Implement a lexical analyzer for the SPECCTRA DSN file format.
virtual bool IsVisible() const
virtual void SetVisible(bool aVisible)
A LINE_READER that reads from an open file.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
char * Line() const
Return a pointer to the last line that was read in.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
void AssignFootprints(const std::string &aChangedSetOfReferences)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
bool processCmpToFootprintLinkFile(const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
Read the footprint info from each line in the stuff file by reference designator.
void SetText(const wxString &aText) override
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SetFootprintFieldText(const wxString &aFootprint)
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
static wxString FootprintAssignmentFileWildcard()
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
boost::property_tree::ptree_error PTREE_ERROR
boost::property_tree::ptree PTREE
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
wxString From_UTF8(const char *cstring)
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
Definition of file extensions used in Kicad.