Commit cdf248b2 authored by charras's avatar charras
Browse files

minor bugs fix.

parent 34d5dff9
Loading
Loading
Loading
Loading
+12 −27
Original line number Diff line number Diff line
@@ -14,8 +14,7 @@


static void LoadDCodeFile( WinEDA_GerberFrame* frame,
                           const wxString&     FullFileName,
                           wxDC*               DC );
                           const wxString&     FullFileName );


void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )
@@ -26,11 +25,7 @@ void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )

    if( fn != wxEmptyString && Clear_Pcb( true ) )
    {
        wxClientDC dc( DrawPanel );
        DrawPanel->CursorOff( &dc );
        LoadOneGerberFile( fn, &dc, false );
        DrawPanel->MouseToCursorSchema();
        DrawPanel->CursorOn( &dc );
        LoadOneGerberFile( fn, false );
    }
}

@@ -40,16 +35,12 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
{
    int        id = event.GetId();

    wxClientDC dc( DrawPanel );

    DrawPanel->CursorOff( &dc );

    switch( id )
    {
    case ID_LOAD_FILE:
        if( Clear_Pcb( TRUE ) )
        {
            LoadOneGerberFile( wxEmptyString, &dc, 0 );
            LoadOneGerberFile( wxEmptyString, 0 );
        }
        break;

@@ -60,7 +51,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )

        GetScreen()->m_Active_Layer++;

        if( !LoadOneGerberFile( wxEmptyString, &dc, 0 ) )
        if( !LoadOneGerberFile( wxEmptyString, 0 ) )
            GetScreen()->m_Active_Layer = origLayer;

        SetToolbars();
@@ -68,7 +59,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
    break;

    case ID_APPEND_FILE:
        LoadOneGerberFile( wxEmptyString, &dc, 0 );
        LoadOneGerberFile( wxEmptyString, 0 );
        break;

    case ID_NEW_BOARD:
@@ -82,24 +73,21 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
        break;

    case ID_GERBVIEW_LOAD_DCODE_FILE:
        LoadDCodeFile( this, wxEmptyString, &dc );
        LoadDCodeFile( this, wxEmptyString );
        break;

    case ID_SAVE_BOARD:
        SaveGerberFile( GetScreen()->m_FileName, &dc );
        SaveGerberFile( GetScreen()->m_FileName );
        break;

    case ID_SAVE_BOARD_AS:
        SaveGerberFile( wxEmptyString, &dc );
        SaveGerberFile( wxEmptyString );
        break;

    default:
        DisplayError( this, wxT( "File_io Internal Error" ) );
        break;
    }

    DrawPanel->MouseToCursorSchema();
    DrawPanel->CursorOn( &dc );
}


@@ -111,7 +99,6 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
 *   1 if OK
 */
bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
                                            wxDC*           DC,
                                           int             mode )
{
    wxString   filetypes;
@@ -165,7 +152,7 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
    wxSetWorkingDirectory( filename.GetPath() );
    filename.SetExt( g_PenFilenameExt );

    if( Read_GERBER_File( DC, GetScreen()->m_FileName, filename.GetFullPath() ) )
    if( Read_GERBER_File( GetScreen()->m_FileName, filename.GetFullPath() ) )
        SetLastProject( GetScreen()->m_FileName );

    Zoom_Automatique( FALSE );
@@ -184,8 +171,7 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
 *   1 if OK
 */
static void LoadDCodeFile( WinEDA_GerberFrame* frame,
                           const wxString&     FullFileName,
                           wxDC*               DC )
                           const wxString&     FullFileName )
{
    wxString   wildcard;
    wxFileName fn = FullFileName;
@@ -218,8 +204,7 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame,

/* Save the file in ASCII PCB.
 */
bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName,
                                         wxDC*           DC )
bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName )
{
    wxString   wildcard;
    wxFileName fn = FullFileName;
+4 −9
Original line number Diff line number Diff line
@@ -95,26 +95,21 @@ bool WinEDA_App::OnInit()
        return true;

    fn = argv[1];
    fn.SetExt( g_PhotoFilenameExt );

    if( fn.IsOk() )
    {
        wxClientDC dc( frame->DrawPanel );
        frame->DrawPanel->PrepareGraphicContext( &dc );

        if( fn.DirExists() )
            wxSetWorkingDirectory( fn.GetPath() );

        // Load all files specified on the command line.
        for( int i = 1; i < argc; ++i )
        for( int ii = 1; ii < argc && ii <= LAYER_COUNT; ++ii )
        {
            fn = wxFileName( argv[i] );
            fn.SetExt( g_PhotoFilenameExt );
            fn = wxFileName( argv[ii] );

            if( fn.FileExists() )
            {
                ( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = i - 1;
                frame->LoadOneGerberFile( fn.GetFullPath(), &dc, FALSE );
                ( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = ii - 1;
                frame->LoadOneGerberFile( fn.GetFullPath(), FALSE );
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ public:
    int     ReturnGCodeNumber( char*& Text );
    int     ReturnDCodeNumber( char*& Text );
    bool    Execute_G_Command( char*& text, int G_commande );
    bool    Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
    bool    Execute_DCODE_Command( WinEDA_GerberFrame* frame,
                                   char*& text, int D_commande );

   /**
@@ -393,7 +393,7 @@ public:
     * Function ReadRS274XCommand
     * reads a single RS274X command terminated with a %
     */
    bool    ReadRS274XCommand( WinEDA_GerberFrame* frame, wxDC* DC,
    bool    ReadRS274XCommand( WinEDA_GerberFrame* frame,
                               char aBuff[GERBER_BUFZ], char*& text );

    /**
+5 −6
Original line number Diff line number Diff line
@@ -102,8 +102,7 @@
 * CrLf after each command
 * G codes BROKE
 */
bool WinEDA_GerberFrame::Read_GERBER_File( wxDC*           DC,
                                           const wxString& GERBER_FullFileName,
bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
                                           const wxString& D_Code_FullFileName )
{
    int      G_commande = 0,
@@ -197,7 +196,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
            case 'D':       /* Line type Dxx : Tool selection (xx > 0) or
                             * command if xx = 0..9 */
                D_commande = gerber->ReturnDCodeNumber( text );
                gerber->Execute_DCODE_Command( this, DC, text, D_commande );
                gerber->Execute_DCODE_Command( this, text, D_commande );
                break;

            case 'X':
@@ -205,7 +204,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
                pos = gerber->ReadXYCoord( text );
                if( *text == '*' )      // command like X12550Y19250*
                {
                    gerber->Execute_DCODE_Command( this, DC, text,
                    gerber->Execute_DCODE_Command( this, text,
                                                   gerber->m_Last_Pen_Command );
                }
                break;
@@ -220,7 +219,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
                {
                    gerber->m_CommandState = ENTER_RS274X_CMD;

                    if( !gerber->ReadRS274XCommand( this, DC, line, text ) )
                    if( !gerber->ReadRS274XCommand( this, line, text ) )
                    {
                        error++;
                    }
@@ -244,7 +243,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
    if( error )
    {
        msg.Printf( _( "%d errors while reading Gerber file [%s]" ),
                   error, GERBER_FullFileName.GetData() );
                   error, GetChars(GERBER_FullFileName) );
        DisplayError( this, msg );
    }
    fclose( gerber->m_Current_File );
+1 −1
Original line number Diff line number Diff line
@@ -849,7 +849,7 @@ static bool mapExposure( int param1, bool curExposure, bool isNegative )
}


bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
                                    char*& text, int D_commande )
{
    wxSize     size( 15, 15 );
Loading