Commit 3cbf8a72 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix back annotate field visibility bug in Eeschema. (fixes lp:1304835)

*  Fix Eeschema back annotation bug where footprint field visibility setting was ignored.
*  Replace two confusing and ambiguous dialogs with a simple single choice dialog.
parent 8d23b26f
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <dsnlexer.h> #include <dsnlexer.h>
#include <ptree.h> #include <ptree.h>
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree.hpp>
#include <wx/choicdlg.h>
void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences ) throw( IO_ERROR ) void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences ) throw( IO_ERROR )
...@@ -88,7 +89,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef ...@@ -88,7 +89,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
else else
footprint.Empty(); footprint.Empty();
DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); ) // DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); )
// Search the component in the flat list // Search the component in the flat list
for( unsigned ii = 0; ii < refs.GetCount(); ++ii ) for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
...@@ -128,8 +129,8 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef ...@@ -128,8 +129,8 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilename, bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilename,
bool aForceFieldsVisibleAttribute, bool aForceVisibilityState,
bool aFieldsVisibleAttributeState ) bool aVisibilityState )
{ {
// Build a flat list of components in schematic: // Build a flat list of components in schematic:
SCH_REFERENCE_LIST referencesList; SCH_REFERENCE_LIST referencesList;
...@@ -138,6 +139,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -138,6 +139,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
sheetList.GetComponents( Prj().SchLibs(), referencesList, false ); sheetList.GetComponents( Prj().SchLibs(), referencesList, false );
FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) ); FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );
if( cmpFile == NULL ) if( cmpFile == NULL )
return false; return false;
...@@ -155,7 +157,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -155,7 +157,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
{ {
buffer = FROM_UTF8( cmpFileReader.Line() ); buffer = FROM_UTF8( cmpFileReader.Line() );
if( !buffer.StartsWith( wxT("BeginCmp") ) ) if( !buffer.StartsWith( wxT( "BeginCmp" ) ) )
continue; continue;
// Begin component description. // Begin component description.
...@@ -166,7 +168,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -166,7 +168,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
{ {
buffer = FROM_UTF8( cmpFileReader.Line() ); buffer = FROM_UTF8( cmpFileReader.Line() );
if( buffer.StartsWith( wxT("EndCmp") ) ) if( buffer.StartsWith( wxT( "EndCmp" ) ) )
break; break;
// store string value, stored between '=' and ';' delimiters. // store string value, stored between '=' and ';' delimiters.
...@@ -175,17 +177,17 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -175,17 +177,17 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
value.Trim(true); value.Trim(true);
value.Trim(false); value.Trim(false);
if( buffer.StartsWith( wxT("Reference") ) ) if( buffer.StartsWith( wxT( "Reference" ) ) )
{ {
reference = value; reference = value;
} }
else if( buffer.StartsWith( wxT("IdModule =" ) ) ) else if( buffer.StartsWith( wxT( "IdModule =" ) ) )
{ {
footprint = value; footprint = value;
} }
} }
// A block is read: initialize the footprint field of the correponding component // A block is read: initialize the footprint field of the corresponding component
// if the footprint name is not empty // if the footprint name is not empty
if( reference.IsEmpty() ) if( reference.IsEmpty() )
continue; continue;
...@@ -203,10 +205,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -203,10 +205,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
fpfield->SetText( footprint ); fpfield->SetText( footprint );
if( aForceFieldsVisibleAttribute ) if( aForceVisibilityState )
{ {
component->GetField( FOOTPRINT ) component->GetField( FOOTPRINT )->SetVisible( aVisibilityState );
->SetVisible( aFieldsVisibleAttributeState );
} }
} }
} }
...@@ -220,7 +221,7 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() ...@@ -220,7 +221,7 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
{ {
wxString path = wxPathOnly( Prj().GetProjectFullName() ); wxString path = wxPathOnly( Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Load Component-Footprint Link File" ), wxFileDialog dlg( this, _( "Load Component Footprint Link File" ),
path, wxEmptyString, path, wxEmptyString,
ComponentFileExtensionWildcard, ComponentFileExtensionWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST ); wxFD_OPEN | wxFD_FILE_MUST_EXIST );
...@@ -233,33 +234,26 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() ...@@ -233,33 +234,26 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
SetTitle( title ); SetTitle( title );
int response = wxMessageBox( _( "Do you want to force all the footprint fields visibility?" ), wxArrayString choices;
_( "Field Visibility Change" ), choices.Add( _( "Keep existing footprint field visibility" ) );
wxYES_NO | wxICON_QUESTION | wxCANCEL, this ); choices.Add( _( "Show all footprint fields" ) );
choices.Add( _( "Hide all footprint fields" ) );
if( response == wxCANCEL ) wxSingleChoiceDialog choiceDlg( this, _( "Select the footprint field visibility setting." ),
return false; _( "Change Visibility" ), choices );
bool changevisibility = response == wxYES;
bool visible = false;
if( changevisibility ) if( choiceDlg.ShowModal() == wxID_CANCEL )
{ return false;
response = wxMessageBox( _( "Do you want to make all the footprint fields visible?" ),
_( "Field Visibility Option" ),
wxYES_NO | wxICON_QUESTION | wxCANCEL, this );
if( response == wxCANCEL )
return false;
visible = response == wxYES; bool forceVisibility = (choiceDlg.GetSelection() != 0 );
} bool visibilityState = (choiceDlg.GetSelection() == 1 );
if( !ProcessCmpToFootprintLinkFile( filename, changevisibility, visible ) ) if( !ProcessCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) )
{ {
wxString msg = wxString::Format( _( wxString msg = wxString::Format( _( "Failed to open component-footprint link file '%s'" ),
"Failed to open component-footprint link file '%s'" ), filename.GetData() );
filename.GetData()
);
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
} }
......
...@@ -701,15 +701,16 @@ public: ...@@ -701,15 +701,16 @@ public:
* EndCmp * EndCmp
* *
* @param aFullFilename = the full filename to read * @param aFullFilename = the full filename to read
* @param aForceFieldsVisibleAttribute = true to change the footprint field flag * @param aForceVisibilityState = Set to true to change the footprint field visibility
* visible or invisible * state to \a aVisibilityState. False retains the
* false = keep old state. * current footprint field visibility state.
* @param aFieldsVisibleAttributeState = footprint field flag visible new state * @param aVisiblityState True to show the footprint field or false to hide the footprint
* field if \a aForceVisibilityState is true.
* @return bool = true if success. * @return bool = true if success.
*/ */
bool ProcessCmpToFootprintLinkFile( const wxString& aFullFilename, bool ProcessCmpToFootprintLinkFile( const wxString& aFullFilename,
bool aForceFieldsVisibleAttribute, bool aForceVisibilityState,
bool aFieldsVisibleAttributeState ); bool aVisibilityState );
/** /**
* Function SaveEEFile * Function SaveEEFile
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment