Пример #1
0
bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
{
    wxString path = wxGetCwd();

    wxFileDialog dlg( this, _( "Load Component-Footprint Link File" ),
                      path, wxEmptyString,
                      ComponentFileExtensionWildcard,
                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );

    if( dlg.ShowModal() == wxID_CANCEL )
        return false;

    wxString filename = dlg.GetPath();
    wxString title  = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
    title += wxT( " " ) + filename;
    SetTitle( title );

    int response = wxMessageBox( _( "Do you want to force all the footprint fields visibility?" ),
                                 _( "Field Visibility Change" ),
                                 wxYES_NO | wxICON_QUESTION | wxCANCEL, this );

    if( response == wxCANCEL )
        return false;

    bool changevisibility = response == wxYES;
    bool visible = false;

    if( changevisibility )
    {
        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;
    }

    if( ! ProcessCmpToFootprintLinkFile( filename, changevisibility, visible ) )
    {
        wxString msg;
        msg.Printf( _( "Failed to open component-footprint link file <%s>" ), filename.GetData() );
        DisplayError( this, msg );
        return false;
    }

    OnModify();
    return true;
}
Пример #2
0
bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
{
    wxString path = wxPathOnly( Prj().GetProjectFullName() );

    wxFileDialog dlg( this, _( "Load Component Footprint Link File" ),
                      path, wxEmptyString,
                      ComponentFileExtensionWildcard,
                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );

    if( dlg.ShowModal() == wxID_CANCEL )
        return false;

    wxString filename = dlg.GetPath();
    wxString title    = wxT( "Eeschema " ) + GetBuildVersion() + wxT( ' ' ) + filename;

    SetTitle( title );

    wxArrayString choices;
    choices.Add( _( "Keep existing footprint field visibility" ) );
    choices.Add( _( "Show all footprint fields" ) );
    choices.Add( _( "Hide all footprint fields" ) );

    wxSingleChoiceDialog choiceDlg( this, _( "Select the footprint field visibility setting." ),
                                    _( "Change Visibility" ), choices );


    if( choiceDlg.ShowModal() == wxID_CANCEL )
        return false;

    bool forceVisibility = (choiceDlg.GetSelection() != 0 );
    bool visibilityState = (choiceDlg.GetSelection() == 1 );

    if( !ProcessCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) )
    {
        wxString msg = wxString::Format( _( "Failed to open component-footprint link file '%s'" ),
                                         filename.GetData() );

        DisplayError( this, msg );
        return false;
    }

    OnModify();
    return true;
}