コード例 #1
0
void AutoSaveManager::timerTimedOut()
{
    timedOut = true;
    timer.stop();

    if(saveOnTimeOut){
        doAutoSave(); // trigger the save() and restart the timer
    }
}
コード例 #2
0
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
{
    if( !doAutoSave() )
        m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
}
コード例 #3
0
void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
{

    wxFileName brdFile = GetBoard()->GetFileName();
    wxString brdName;

    if( GetScreen()->IsModify() || brdFile.GetFullPath().empty() )
    {
        if( !doAutoSave() )
        {
            wxMessageBox( _( "STEP export failed; please save the PCB and try again" ),
                          _( "STEP Export" ) );
            return;
        }

        brdFile = GetBoard()->GetFileName();
        brdName = GetAutoSaveFilePrefix();
        brdName.append( brdFile.GetName() );
        brdFile.SetName( brdName );
    }

    brdName = "\"";
    brdName.Append( brdFile.GetFullPath() );
    brdName.Append( "\"" );

    // Build default output file name
    brdFile = GetBoard()->GetFileName();
    wxString brdExt = brdFile.GetExt();
    brdFile.SetExt( "stp" );

    DIALOG_EXPORT_STEP dlg( this );
    dlg.FilePicker()->SetPath( brdFile.GetFullPath() );
    bool fileOverwrite = false;
    wxString outputFile;

    while( !fileOverwrite )
    {
        if ( dlg.ShowModal() != wxID_OK )
            return;

        brdFile = dlg.FilePicker()->GetPath();
        brdFile.SetExt( "stp" );
        outputFile = brdFile.GetFullPath();

        if( wxFile::Exists( outputFile ) )
        {
            wxString msg( _( "File: " ) );
            msg.append( outputFile );
            msg.append( "\n" );
            msg.append( _( "File exists, overwrite?" ) );
            int resp = wxMessageBox( msg, _( "STEP Export" ), wxYES_NO | wxCANCEL, this );

            switch( resp )
            {
                case wxCANCEL:
                    return;

                case wxYES:
                    fileOverwrite = true;
                    break;

                default:
                    break;
            }
        }
        else
        {
            fileOverwrite = true;
        }
    }

    outputFile.Prepend( "\"" );
    outputFile.Append( "\"" );
    bool   aUseDrillOrg = dlg.GetDrillOrgOption();
    bool   aUseAuxOrg   = dlg.GetAuxOrgOption();
    bool   aUseUserOrg  = dlg.GetUserOrgOption();
    bool   aNoVirtual = dlg.GetNoVirtOption();
    double aXOrg = 0.0;
    double aYOrg = 0.0;

    if( aUseUserOrg )
    {
        aXOrg = dlg.GetXOrg();
        aYOrg = dlg.GetYOrg();

        if( dlg.GetOrgUnitsChoice() == 1 )
        {
            // selected reference unit is in inches
            aXOrg *= 25.4;
            aYOrg *= 25.4;
        }
    }

    wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
    appK2S.SetName( "kicad2step" );

    wxString cmdK2S = "\"";
    cmdK2S.Append( appK2S.GetFullPath() );
    cmdK2S.Append( "\"" );

    if( aNoVirtual )
        cmdK2S.Append( " --no-virtual" );

    if( aUseDrillOrg )
        cmdK2S.Append( " --drill-origin" );

    if( aUseAuxOrg )
        cmdK2S.Append( " --grid-origin" );

    if( aUseUserOrg )
        cmdK2S.Append( wxString::Format( " --user-origin %.6fx%.6f", aXOrg, aYOrg ) );

    cmdK2S.Append( " -f -o " );
    cmdK2S.Append( outputFile );

    cmdK2S.Append( " " );
    cmdK2S.Append( brdName );

    int result = 0;

    do
    {
        wxBusyCursor dummy;
        result = wxExecute( cmdK2S, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE );
    } while( 0 );

    if( result )
    {
        wxMessageBox(
            _( "Unable to create STEP file; check that the board has a valid outline and models." ),
            _( "STEP Export" ), wxOK );
    }

    return;
}