37 #include <boost/property_tree/ptree.hpp> 40 #include <wx/choicdlg.h> 41 #include <wx/filedlg.h> 49 bool isChanged =
false;
60 CPTREE& back_anno = doc.get_child(
"cvpcb_netlist" );
63 for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
65 wxASSERT( ref->first ==
"ref" );
67 wxString reference = (
UTF8&) ref->second.front().first;
70 if( ref->second.get_child(
"fpid" ).size() )
72 wxString tmp = (
UTF8&) ref->second.get_child(
"fpid" ).front().first;
79 for(
unsigned ii = 0; ii < refs.
GetCount(); ++ii )
81 if( reference == refs[ii].GetRef() )
91 wxString oldfp = refs[ii].GetFootprint();
96 if( oldfp != footprint )
121 bool aForceVisibilityState,
122 bool aVisibilityState )
128 sheetList.
GetSymbols( referencesList,
false );
130 FILE* cmpFile = wxFopen( aFullFilename, wxT(
"rt" ) );
132 if( cmpFile ==
nullptr )
149 if( !buffer.StartsWith( wxT(
"BeginCmp" ) ) )
160 if( buffer.StartsWith( wxT(
"EndCmp" ) ) )
164 value = buffer.AfterFirst(
'=' );
165 value = value.BeforeLast(
';' );
169 if( buffer.StartsWith( wxT(
"Reference" ) ) )
171 else if( buffer.StartsWith( wxT(
"IdModule" ) ) )
177 if( reference.IsEmpty() )
181 for(
unsigned ii = 0; ii < referencesList.
GetCount(); ii++ )
183 if( reference == referencesList[ii].GetRef() )
188 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() );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
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.
This file is part of the common library.
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
virtual void SetVisible(bool aVisible)
boost::property_tree::ptree PTREE
A LINE_READER that reads from an open file.
void SyncView()
Mark all items for refresh.
virtual bool IsVisible() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString FootprintAssignmentFileWildcard()
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool processCmpToFootprintLinkFile(const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
Read the footprint info from each line in the stuff file by reference designator.
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
boost::property_tree::ptree_error PTREE_ERROR
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void AssignFootprints(const std::string &aChangedSetOfReferences)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
#define THROW_IO_ERROR(msg)
Implement a lexical analyzer for the SPECCTRA DSN file format.
Field Name Module PCB, i.e. "16DIP300".