Commit a9e23996 authored by Dick Hollenbeck's avatar Dick Hollenbeck

legacy pcbnew plugin touch ups

parent cc70c1a4
/* Do not modify this file, it was automatically generated by CMake. */ /* Do not modify this file, it was automatically generated by CMake. */
#ifndef __CONFIG_H__ #ifndef CONFIG_H_
#define __CONFIG_H__ #define CONFIG_H_
#cmakedefine HAVE_STRCASECMP #cmakedefine HAVE_STRCASECMP
...@@ -57,4 +57,12 @@ ...@@ -57,4 +57,12 @@
#cmakedefine USE_NEW_PCBNEW_LOAD #cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE #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_
...@@ -12,8 +12,4 @@ class wxString; ...@@ -12,8 +12,4 @@ class wxString;
*/ */
wxString GetBuildVersion(); wxString GetBuildVersion();
/// The file format revision of the *.brd file created by this build
#define BOARD_FILE_VERSION 1
#endif // KICAD_BUILD_VERSION_H #endif // KICAD_BUILD_VERSION_H
...@@ -845,7 +845,6 @@ public: ...@@ -845,7 +845,6 @@ public:
m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1; m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1;
} }
/** /**
* Function GetCurrentMicroViaSize * Function GetCurrentMicroViaSize
* @return the current micro via size, * @return the current micro via size,
......
...@@ -272,31 +272,36 @@ this file again." ) ); ...@@ -272,31 +272,36 @@ this file again." ) );
m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
} }
else
{
GetBoard()->m_NetClasses.Clear();
}
BOARD* loadedBoard = 0; // it will be set to non-NULL if loadedOK
try try
{ {
// load or append either: // 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, aAppend ? GetBoard() : NULL,
NULL ); NULL );
if( !aAppend ) if( !aAppend )
{ {
if( board->GetFileFormatVersionAtLoad() < BOARD_FILE_VERSION ) if( loadedBoard->GetFileFormatVersionAtLoad() < BOARD_FILE_VERSION )
{ {
DisplayInfoMessage( this, _( "This file was created by an older \ DisplayInfoMessage( this, _( "This file was created by an older \
version of Pcbnew. It will be stored in the new file format when you save \ version of Pcbnew. It will be stored in the new file format when you save \
this file again." ) ); this file again." ) );
} }
SetBoard( board ); SetBoard( loadedBoard );
} }
} }
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
wxString msg = wxString::Format( _( "Error loading board.\n%s" ), wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
ioe.errorText.GetData() ); ioe.errorText.GetData() );
wxMessageBox( msg, _( "Open Board File" ), wxICON_ERROR ); wxMessageBox( msg, _( "Open Board File" ), wxICON_ERROR );
} }
...@@ -305,6 +310,16 @@ this file again." ) ); ...@@ -305,6 +310,16 @@ this file again." ) );
LoadProjectSettings( GetScreen()->GetFileName() ); LoadProjectSettings( GetScreen()->GetFileName() );
} }
if( loadedBoard )
{
// we should not ask PLUGINs to do these items:
loadedBoard->BuildListOfNets();
loadedBoard->SynchronizeNetsAndNetClasses();
SetStatusText( wxEmptyString );
BestZoom();
}
#endif #endif
GetScreen()->ClrModify(); GetScreen()->ClrModify();
...@@ -448,18 +463,43 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -448,18 +463,43 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
#if defined(USE_NEW_PCBNEW_SAVE) #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 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 ) 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() ); ioe.errorText.GetData() );
wxMessageBox( msg, _( "Save Board File" ), wxICON_ERROR ); wxMessageBox( msg, _( "Save Board File" ), wxICON_ERROR );
saveok = false; saveok = false;
} }
if( saveok )
{
GetScreen()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle();
}
#else #else
// Create the file // Create the file
FILE* dest; FILE* dest;
......
...@@ -227,10 +227,9 @@ public: ...@@ -227,10 +227,9 @@ public:
/* The compiler writes the "zero argument" constructor for a PLUGIN /* The compiler writes the "zero argument" constructor for a PLUGIN
automatically if you do not provide one. If you decide you need to 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, 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" It must be public, and it is what the IO_MGR uses. Parameters may be
version. Normally you can do your initialization in a function like passed into a PLUGIN via the PROPERTIES variable for either Save() and Load().
KICAD_PLUGIN::init( PROPERTIES* aProperties ) instead.
*/ */
virtual ~PLUGIN() {} virtual ~PLUGIN() {}
......
This diff is collapsed.
...@@ -73,6 +73,7 @@ protected: ...@@ -73,6 +73,7 @@ protected:
wxString m_error; ///< for throwing exceptions wxString m_error; ///< for throwing exceptions
BOARD* m_board; ///< which BOARD, no ownership here BOARD* m_board; ///< which BOARD, no ownership here
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
LINE_READER* m_reader; ///< no ownership here. LINE_READER* m_reader; ///< no ownership here.
FILE* m_fp; ///< no ownership here. FILE* m_fp; ///< no ownership here.
...@@ -89,7 +90,8 @@ protected: ...@@ -89,7 +90,8 @@ protected:
/** /**
* Function biuParse * Function biuParse
* parses an ASCII decimal floating point value and scales it into a BIU * parses an ASCII decimal floating point value and scales it into a BIU
* according to the current value of diskToBui. * according to the current value of diskToBui. This fuction is the complement of
* fmtBIU(). One has to know what the other is doing.
* *
* @param aValue is the ASCII value in C locale form with possible leading whitespace * @param aValue is the ASCII value in C locale form with possible leading whitespace
* *
...@@ -104,7 +106,8 @@ protected: ...@@ -104,7 +106,8 @@ protected:
* Function degParse * Function degParse
* parses an ASCII decimal floating point value which is certainy an angle. This * parses an ASCII decimal floating point value which is certainy an angle. This
* is a dedicated function for encapsulating support for the migration from * is a dedicated function for encapsulating support for the migration from
* tenths of degrees to degrees in floating point. * tenths of degrees to degrees in floating point. This function is the complement of
* fmtDEG(). One has to know what the other is doing.
* *
* @param aValue is the ASCII value in C locale form with possible leading whitespace * @param aValue is the ASCII value in C locale form with possible leading whitespace
* *
...@@ -164,9 +167,15 @@ protected: ...@@ -164,9 +167,15 @@ protected:
*/ */
wxString writeError() const; wxString writeError() const;
/// encapsulate the BIU formatting tricks in one place.
int biuSprintf( char* buf, BIU aValue ) const; int biuSprintf( char* buf, BIU aValue ) const;
/// convert a BIU to engineering units by scaling and formatting to ASCII. /**
* Function fmtBIU
* converts a BIU to engineering units by scaling and formatting to ASCII.
* This function is the complement of biuParse(). One has to know what the
* other is doing.
*/
std::string fmtBIU( BIU aValue ) const; std::string fmtBIU( BIU aValue ) const;
std::string fmtBIUPair( BIU first, BIU second ) const; std::string fmtBIUPair( BIU first, BIU second ) const;
...@@ -178,11 +187,17 @@ protected: ...@@ -178,11 +187,17 @@ protected:
std::string fmtBIUSize( const wxSize& aSize ) const std::string fmtBIUSize( const wxSize& aSize ) const
{ {
// unfortunately there is inconsistency in the order of saving wxSize,
// so sometimes we use fmtBIUPair() directly in the saveXXX() functions.
return fmtBIUPair( aSize.x, aSize.y ); return fmtBIUPair( aSize.x, aSize.y );
} }
/**
* Function fmtDEG
* formats an angle in a way particular to a board file format. This function
* is the opposite or complement of degParse(). One has to know what the
* other is doing.
*/
std::string fmtDEG( double aAngle ) const;
void saveAllSections() const; void saveAllSections() const;
void saveGENERAL() const; void saveGENERAL() const;
void saveSHEET() const; void saveSHEET() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment