Esempio n. 1
0
int main( int argc, char** argv )
{
//    wxString    filename( wxT("/tmp/fpcroute/Sample_1sided/demo_1sided.dsn") );
//    wxString    filename( wxT("/tmp/testdesigns/test.dsn") );
//    wxString    filename( wxT("/tmp/testdesigns/test.ses") );
    wxString    filename( wxT("/tmp/specctra_big.dsn") );

    SPECCTRA_DB     db;
    bool            failed = false;

    LOCALE_IO toggle;   // Temporary switch the locale to standard C to r/w floats

    if( argc == 2 )
    {
        filename = FROM_UTF8( argv[1] );
    }

    try
    {
//        db.LoadPCB( filename );
        db.LoadSESSION( filename );
    }
    catch( const IO_ERROR& ioe )
    {
        fprintf( stderr, "%s\n", TO_UTF8(ioe.errorText) );
        failed = true;
    }

    if( !failed )
        fprintf( stderr, "loaded OK\n" );

    // export what we read in, making this test program basically a beautifier
    // hose the beautified DSN file to stdout.  If an exception occurred,
    // we will be outputting only a portion of what we wanted to read in.
    db.SetFILE( stdout );

#if 0
    // export a PCB
    DSN::PCB* pcb = db.GetPCB();
    pcb->Format( &db, 0 );

#else
    // export a SESSION file.
    DSN::SESSION* ses = db.GetSESSION();
    ses->Format( &db, 0 );
#endif
}
void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
{
/*
    if( GetScreen()->IsModify() )
    {
        if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
            return;
    }
*/

    wxString fullFileName = GetBoard()->GetFileName();
    wxString path;
    wxString name;
    wxString ext;

    wxString sessionExt( wxT( ".ses" ) );
    wxString mask = wxT( "*" ) + sessionExt;

    wxFileName::SplitPath( fullFileName, &path, &name, &ext );
    name += sessionExt;

    fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ),
                                      path,
                                      name,
                                      sessionExt,
                                      mask,
                                      this,
                                      wxFD_OPEN,
                                      false );

    if( fullFileName == wxEmptyString )
        return;

    SPECCTRA_DB     db;
    LOCALE_IO       toggle;

    try
    {
        db.LoadSESSION( fullFileName );
        db.FromSESSION( GetBoard() );
    }
    catch( const IO_ERROR& ioe )
    {
        wxString msg = ioe.errorText;
        msg += '\n';
        msg += _("BOARD may be corrupted, do not save it.");
        msg += '\n';
        msg += _("Fix problem and try again.");

        DisplayError( this, msg );
        return;
    }

    OnModify();
    GetBoard()->m_Status_Pcb = 0;

    /* At this point we should call Compile_Ratsnest()
     * but this could be time consumming.
     * So if incorrect number of Connected and No connected pads is accepted
     * until Compile_Ratsnest() is called (when track tool selected for instance)
     * leave the next line commented
     * Otherwise uncomment this line
    */
    //Compile_Ratsnest( NULL, true );

    SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );

    m_canvas->Refresh( true );
}
Esempio n. 3
0
void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
{
    wxString fullFileName = GetBoard()->GetFileName();
    wxString path;
    wxString name;
    wxString ext;

    wxString sessionExt( wxT( ".ses" ) );
    wxString mask = wxT( "*" ) + sessionExt;

    wxFileName::SplitPath( fullFileName, &path, &name, &ext );
    name += sessionExt;

    fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ),
                                      path,
                                      name,
                                      sessionExt,
                                      mask,
                                      this,
                                      wxFD_OPEN,
                                      false );

    if( fullFileName == wxEmptyString )
    {
        return;
    }

    SetCurItem( NULL );

    // To avoid issues with undo/redo lists (dangling pointers)
    // clear the lists
    // todo: use undo/redo feature
    GetScreen()->ClearUndoRedoList();

    SPECCTRA_DB     db;
    LOCALE_IO       toggle;

    try
    {
        db.LoadSESSION( fullFileName );
        db.FromSESSION( GetBoard() );
    }
    catch( const IO_ERROR& ioe )
    {
        wxString msg = _(
                "Board may be corrupted, do not save it.\n"
                "Fix problem and try again"
                );

        wxString extra = ioe.What();

        DisplayErrorMessage( this, msg, extra);
        return;
    }

    OnModify();
    GetBoard()->m_Status_Pcb = 0;

    GetBoard()->GetConnectivity()->Clear();
    GetBoard()->GetConnectivity()->Build( GetBoard() );

    if( GetGalCanvas() )    // Update view:
    {
        auto view = GetGalCanvas()->GetView();

        // Update footprint positions
        view->RecacheAllItems();

        // add imported tracks (previous tracks are removed, therfore all are new)
        for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
        {
            view->Add( track );
        }
   }

    SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );

    Refresh();
}