38#include <boost/property_tree/ptree.hpp>
41#include <wx/choicdlg.h>
42#include <wx/filedlg.h>
50 bool isChanged =
false;
61 CPTREE& back_anno = doc.get_child(
"cvpcb_netlist" );
64 for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
66 wxASSERT( ref->first ==
"ref" );
68 wxString reference = (
UTF8&) ref->second.front().first;
71 if( ref->second.get_child(
"fpid" ).size() )
73 wxString tmp = (
UTF8&) ref->second.get_child(
"fpid" ).front().first;
80 for(
unsigned ii = 0; ii < refs.
GetCount(); ++ii )
82 if( reference == refs[ii].GetRef() )
91 wxString oldfp = refs[ii].GetFootprint();
96 if( oldfp != footprint )
99 SCH_SCREEN* screen = refs[ii].GetSheetPath().LastScreen();
101 commit.
Modify( symbol, screen );
118 commit.
Push( wxS(
"Assign Footprints" ) );
124 bool aForceVisibilityState,
125 bool aVisibilityState )
131 FILE* cmpFile = wxFopen( aFullFilename, wxT(
"rt" ) );
133 if( cmpFile ==
nullptr )
150 if( !buffer.StartsWith( wxT(
"BeginCmp" ) ) )
161 if( buffer.StartsWith( wxT(
"EndCmp" ) ) )
165 value = buffer.AfterFirst(
'=' );
166 value = value.BeforeLast(
';' );
170 if( buffer.StartsWith( wxT(
"Reference" ) ) )
172 else if( buffer.StartsWith( wxT(
"IdModule" ) ) )
178 if( reference.IsEmpty() )
182 for(
unsigned ii = 0; ii < referencesList.
GetCount(); ii++ )
184 if( reference == referencesList[ii].GetRef() )
189 SCH_SYMBOL* symbol = referencesList[ ii ].GetSymbol();
193 if( aForceVisibilityState )
207 wxFileDialog dlg(
m_frame,
_(
"Load Symbol Footprint Link File" ),
210 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
212 if( dlg.ShowModal() == wxID_CANCEL )
215 wxString filename = dlg.GetPath();
217 wxArrayString choices;
218 choices.Add(
_(
"Keep existing footprint field visibility" ) );
219 choices.Add(
_(
"Show all footprint fields" ) );
220 choices.Add(
_(
"Hide all footprint fields" ) );
222 wxSingleChoiceDialog choiceDlg(
m_frame,
_(
"Select the footprint field visibility setting." ),
223 _(
"Change Visibility" ), choices );
225 if( choiceDlg.ShowModal() == wxID_CANCEL )
228 bool forceVisibility = (choiceDlg.GetSelection() != 0 );
229 bool visibilityState = (choiceDlg.GetSelection() == 1 );
233 wxString msg = wxString::Format(
_(
"Failed to open symbol-footprint link file '%s'." ),
234 filename.GetData() );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Implement a lexical analyzer for the SPECCTRA DSN file format.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
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.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
char * Line() const
Return a pointer to the last line that was read in.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncView()
Mark all items for refresh.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
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 OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCHEMATIC & Schematic() const
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
void SetFootprintFieldText(const wxString &aFootprint)
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, int aDisplayTime)
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)
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
Field Name Module PCB, i.e. "16DIP300".
Definition of file extensions used in Kicad.