Commit a9e23996 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

legacy pcbnew plugin touch ups

parent cc70c1a4
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
/* Do not modify this file, it was automatically generated by CMake. */

#ifndef __CONFIG_H__
#define __CONFIG_H__
#ifndef CONFIG_H_
#define CONFIG_H_

#cmakedefine HAVE_STRCASECMP

@@ -57,4 +57,12 @@
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE

#endif  /* __CONFIG_H__ */

/// The file format revision of the *.brd file created by this build
#if defined(KICAD_NANOMETRE)
#define BOARD_FILE_VERSION          2
#else
#define BOARD_FILE_VERSION          1
#endif

#endif  // CONFIG_H_
+0 −4
Original line number Diff line number Diff line
@@ -12,8 +12,4 @@ class wxString;
 */
wxString GetBuildVersion();

/// The file format revision of the *.brd file created by this build
#define BOARD_FILE_VERSION          1


#endif	// KICAD_BUILD_VERSION_H
+0 −1
Original line number Diff line number Diff line
@@ -845,7 +845,6 @@ public:
               m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1;
    }


    /**
     * Function GetCurrentMicroViaSize
     * @return the current micro via size,
+46 −6
Original line number Diff line number Diff line
@@ -272,31 +272,36 @@ this file again." ) );
        m_DisplayPadFill = DisplayOpt.DisplayPadFill;
        m_DisplayViaFill = DisplayOpt.DisplayViaFill;
    }
    else
    {
        GetBoard()->m_NetClasses.Clear();
    }

    BOARD* loadedBoard = 0;   // it will be set to non-NULL if loadedOK

    try
    {
        // load or append either:
        BOARD* board = IO_MGR::Load( IO_MGR::KICAD, GetScreen()->GetFileName(),
        loadedBoard = IO_MGR::Load( IO_MGR::KICAD, GetScreen()->GetFileName(),
                            aAppend ? GetBoard() : NULL,
                            NULL );

        if( !aAppend )
        {
            if( board->GetFileFormatVersionAtLoad() < BOARD_FILE_VERSION )
            if( loadedBoard->GetFileFormatVersionAtLoad() < BOARD_FILE_VERSION )
            {
                DisplayInfoMessage( this, _( "This file was created by an older \
version of Pcbnew. It will be stored in the new file format when you save \
this file again." ) );
            }

            SetBoard( board );
            SetBoard( loadedBoard );
        }
    }
    catch( IO_ERROR ioe )
    {
        wxString msg = wxString::Format(  _( "Error loading board.\n%s" ),
                            ioe.errorText.GetData() );

        wxMessageBox( msg, _( "Open Board File" ), wxICON_ERROR );
    }

@@ -305,6 +310,16 @@ this file again." ) );
        LoadProjectSettings( GetScreen()->GetFileName() );
    }

    if( loadedBoard )
    {
        // we should not ask PLUGINs to do these items:
        loadedBoard->BuildListOfNets();
        loadedBoard->SynchronizeNetsAndNetClasses();

        SetStatusText( wxEmptyString );
        BestZoom();
    }

#endif

    GetScreen()->ClrModify();
@@ -448,18 +463,43 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF

#if defined(USE_NEW_PCBNEW_SAVE)

    GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;

    GetBoard()->SynchronizeNetsAndNetClasses();

    // Select default Netclass before writing file.
    // Useful to save default values in headers
    GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName() );

    try
    {
        IO_MGR::Save( IO_MGR::KICAD, pcbFileName.GetFullPath(), GetBoard(), NULL );
        wxString header = wxString::Format(
                            wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ),
                            BOARD_FILE_VERSION, TO_UTF8( DateAndTime() ),
                            TO_UTF8( GetBuildVersion() ) );

        PROPERTIES   props;

        // wanting wxWidgets 2.9.x which can actually create a wxString() from
        // a const char*, so don't have to use wxT()
        props[ wxT("header") ] = header;

        IO_MGR::Save( IO_MGR::KICAD, pcbFileName.GetFullPath(), GetBoard(), &props );
    }
    catch( IO_ERROR ioe )
    {
        wxString msg = wxString::Format(  _( "Error loading board.\n%s" ),
        wxString msg = wxString::Format(  _( "Error saving board.\n%s" ),
                            ioe.errorText.GetData() );
        wxMessageBox( msg, _( "Save Board File" ), wxICON_ERROR );
        saveok = false;
    }

    if( saveok )
    {
        GetScreen()->SetFileName( pcbFileName.GetFullPath() );
        UpdateTitle();
    }

#else
    // Create the file
    FILE* dest;
+3 −4
Original line number Diff line number Diff line
@@ -227,10 +227,9 @@ public:

    /*  The compiler writes the "zero argument" constructor for a PLUGIN
        automatically if you do not provide one. If you decide you need to
        provide a zero argument constructor of your own design, that is allowed,
        but there can only be one constructor and it must be a "zero argument"
        version. Normally you can do your initialization in a function like
        KICAD_PLUGIN::init( PROPERTIES* aProperties ) instead.
        provide a zero argument constructor of your own design, that is allowed.
        It must be public, and it is what the IO_MGR uses.  Parameters may be
        passed into a PLUGIN via the PROPERTIES variable for either Save() and Load().
    */

    virtual ~PLUGIN() {}
Loading