Commit 3341669f authored by Dick Hollenbeck's avatar Dick Hollenbeck

more footprint support for LEGACY_PLUGIN

parent a42490e0
...@@ -23,8 +23,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) ...@@ -23,8 +23,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option(USE_PCBNEW_SEXPR_FILE_FORMAT option(USE_PCBNEW_SEXPR_FILE_FORMAT
"Use s-expression Pcbnew file format support (default OFF)." ) "Use s-expression Pcbnew file format support (default OFF)." )
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" ON)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" ON)
option(USE_PCBNEW_NANOMETRES option(USE_PCBNEW_NANOMETRES
"Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).") "Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).")
......
...@@ -55,8 +55,6 @@ ...@@ -55,8 +55,6 @@
#cmakedefine USE_IMAGES_IN_MENUS 1 #cmakedefine USE_IMAGES_IN_MENUS 1
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANOMETRES #cmakedefine USE_PCBNEW_NANOMETRES
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT #cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT
......
...@@ -116,21 +116,13 @@ set(PCB_COMMON_SRCS ...@@ -116,21 +116,13 @@ set(PCB_COMMON_SRCS
../pcbnew/collectors.cpp ../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp ../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp ../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.cpp pcb_plot_params_keywords.cpp
dialogs/dialog_page_settings.cpp dialogs/dialog_page_settings.cpp
) )
if( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
set( PCB_COMMON_SRCS
${PCB_COMMON_SRCS}
../pcbnew/item_io.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
)
else()
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp )
endif()
# add -DPCBNEW to compilation of these PCBNEW sources # add -DPCBNEW to compilation of these PCBNEW sources
set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
......
...@@ -98,26 +98,6 @@ public: ...@@ -98,26 +98,6 @@ public:
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; } BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; } BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
#if 0
// DICK: there is no value in having a polymorphic {Get,Set}Position(). We never
// call GetPosition() using a generic pointer, and the virtual is slower and
// can never be inlined.
/**
* Function GetPosition
* returns the position of this object.
* @return const wxPoint - The position of this object
*/
virtual const wxPoint GetPosition() const = 0;
/**
* Function SetPosition
* sets the position of this object.
* @param aPos is the new position of this object
*/
virtual void SetPosition( const wxPoint& aPos ) = 0;
#endif
/** /**
* Function GetLayer * Function GetLayer
* returns the layer this item is on. * returns the layer this item is on.
...@@ -173,7 +153,6 @@ public: ...@@ -173,7 +153,6 @@ public:
return false; // only MODULEs can be locked at this time. return false; // only MODULEs can be locked at this time.
} }
/** /**
* Function UnLink * Function UnLink
* detaches this object from its owner. This base class implementation * detaches this object from its owner. This base class implementation
...@@ -191,21 +170,12 @@ public: ...@@ -191,21 +170,12 @@ public:
delete this; delete this;
} }
/** /**
* Function ShowShape * Function ShowShape
* converts the enum STROKE_T integer value to a wxString. * converts the enum STROKE_T integer value to a wxString.
*/ */
static wxString ShowShape( STROKE_T aShape ); static wxString ShowShape( STROKE_T aShape );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
virtual bool Save( FILE* aFile ) const = 0;
// Some geometric transforms, that must be rewritten for derived classes // Some geometric transforms, that must be rewritten for derived classes
/** /**
* Function Move * Function Move
......
...@@ -373,20 +373,45 @@ public: ...@@ -373,20 +373,45 @@ public:
// loading footprints // loading footprints
/** /**
* Function GetModuleLibrary * Function loadFootprintFromLibrary
* loads @a aFootprintName from @a aLibraryPath.
* If found add the module is also added to the BOARD, just for good measure.
* *
* Read active libraries or one library to find and load a given module
* If found the module is linked to the tail of linked list of modules
* @param aLibraryFullFilename - the full filename of the library to read. If empty, * @param aLibraryFullFilename - the full filename of the library to read. If empty,
* all active libraries are read * all active libraries are read
* @param aModuleName = module name to load *
* @param aDisplayMessageError = true to display an error message if any. * @param aFootprintName is the footprint to load
*
* @param aDisplayError = true to display an error message if any.
*
* @return MODULE* - new module, or NULL
*/
MODULE* loadFootprintFromLibrary( const wxString& aLibraryPath,
const wxString& aFootprintName, bool aDisplayError );
MODULE* loadFootprintFromLibraries( const wxString& aFootprintName,
bool aDisplayError );
/**
* Function GetModuleLibrary
* scans active libraries to find and load @a aFootprintName.
* If found add the module is also added to the BOARD, just for good measure.
*
* @param aFootprintName is the footprint to load
*
* @param aDisplayError = true to display an error message if any.
*
* @return a pointer to the new module, or NULL * @return a pointer to the new module, or NULL
* *
*/ */
MODULE* GetModuleLibrary( const wxString& aLibraryFullFilename, MODULE* GetModuleLibrary( const wxString& aLibraryPath, const wxString& aFootprintName,
const wxString& aModuleName, bool aDisplayError )
bool aDisplayMessageError ); {
if( !aLibraryPath )
return loadFootprintFromLibraries( aFootprintName, aDisplayError );
else
return loadFootprintFromLibrary( aLibraryPath, aFootprintName, aDisplayError );
}
/** /**
* Function Select_1_Module_From_List * Function Select_1_Module_From_List
...@@ -409,7 +434,8 @@ public: ...@@ -409,7 +434,8 @@ public:
/** /**
* Function Load_Module_From_Library * Function Load_Module_From_Library
* Open a dialog to select a footprint, and load in in current board * opens a dialog to select a footprint, and loads it into current board.
*
* @param aLibrary = the library name to use, or empty string to search * @param aLibrary = the library name to use, or empty string to search
* in all loaded libraries * in all loaded libraries
* @param aUseFootprintViewer = true to show the option * @param aUseFootprintViewer = true to show the option
......
...@@ -136,7 +136,6 @@ set(PCBNEW_SRCS ...@@ -136,7 +136,6 @@ set(PCBNEW_SRCS
hotkeys_board_editor.cpp hotkeys_board_editor.cpp
hotkeys_module_editor.cpp hotkeys_module_editor.cpp
initpcb.cpp initpcb.cpp
ioascii.cpp
layer_widget.cpp layer_widget.cpp
librairi.cpp librairi.cpp
loadcmp.cpp loadcmp.cpp
......
...@@ -892,8 +892,6 @@ public: ...@@ -892,8 +892,6 @@ public:
/***************************************************************************/ /***************************************************************************/
bool Save( FILE* aFile ) const;
wxString GetClass() const wxString GetClass() const
{ {
return wxT( "BOARD" ); return wxT( "BOARD" );
......
...@@ -135,14 +135,8 @@ public: ...@@ -135,14 +135,8 @@ public:
*/ */
} }
bool Save( FILE* aFile ) const
{
return true;
}
//-----</ satisfy some virtual functions >----------------------------- //-----</ satisfy some virtual functions >-----------------------------
/** /**
* Function GetCount * Function GetCount
* returns the number of BOARD_ITEMs. * returns the number of BOARD_ITEMs.
......
...@@ -88,10 +88,6 @@ public: ...@@ -88,10 +88,6 @@ public:
*/ */
void AdjustDimensionDetails( bool aDoNotChangeText = false ); void AdjustDimensionDetails( bool aDoNotChangeText = false );
bool ReadDimensionDescr( LINE_READER* aReader );
bool Save( FILE* aFile ) const;
void SetText( const wxString& NewText ); void SetText( const wxString& NewText );
const wxString GetText() const; const wxString GetText() const;
......
...@@ -152,10 +152,6 @@ public: ...@@ -152,10 +152,6 @@ public:
m_PolyPoints = aPoints; m_PolyPoints = aPoints;
} }
bool Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( LINE_READER* aReader );
void Copy( DRAWSEGMENT* source ); void Copy( DRAWSEGMENT* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
......
...@@ -64,10 +64,6 @@ public: ...@@ -64,10 +64,6 @@ public:
void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; } void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
const wxPoint& GetEnd0() const { return m_End0; } const wxPoint& GetEnd0() const { return m_End0; }
bool Save( FILE* aFile ) const;
int ReadDescr( LINE_READER* aReader );
void SetDrawCoord(); void SetDrawCoord();
/* drawing functions */ /* drawing functions */
......
...@@ -70,13 +70,6 @@ public: ...@@ -70,13 +70,6 @@ public:
void DisplayInfo( EDA_DRAW_FRAME* frame ); void DisplayInfo( EDA_DRAW_FRAME* frame );
bool Save( FILE* aFile ) const
{
// not implemented, this is here to satisfy BOARD_ITEM::Save()
// "pure" virtual-ness
return true;
}
wxString GetSelectMenuText() const; wxString GetSelectMenuText() const;
BITMAP_DEF GetMenuImage() const { return drc_xpm; } BITMAP_DEF GetMenuImage() const { return drc_xpm; }
......
...@@ -86,10 +86,6 @@ public: ...@@ -86,10 +86,6 @@ public:
void Flip( const wxPoint& aCentre ); void Flip( const wxPoint& aCentre );
bool Save( FILE* aFile ) const;
bool ReadMirePcbDescr( LINE_READER* aReader );
void Copy( PCB_TARGET* source ); void Copy( PCB_TARGET* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
......
...@@ -111,6 +111,7 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -111,6 +111,7 @@ MODULE::MODULE( const MODULE& aModule ) :
// Copy reference and value. // Copy reference and value.
m_Reference = new TEXTE_MODULE( *aModule.m_Reference ); m_Reference = new TEXTE_MODULE( *aModule.m_Reference );
m_Reference->SetParent( this ); m_Reference->SetParent( this );
m_Value = new TEXTE_MODULE( *aModule.m_Value ); m_Value = new TEXTE_MODULE( *aModule.m_Value );
m_Value->SetParent( this ); m_Value->SetParent( this );
......
...@@ -108,16 +108,6 @@ public: ...@@ -108,16 +108,6 @@ public:
wxString m_Doc; // Module Description (info for users) wxString m_Doc; // Module Description (info for users)
wxString m_KeyWord; // Keywords to select the module in lib wxString m_KeyWord; // Keywords to select the module in lib
// Local tolerances. When zero, this means the corresponding netclass value
// is used. Usually theses local tolerances zero, in deference to the
// corresponding netclass values.
int m_LocalClearance;
int m_LocalSolderMaskMargin; ///< Solder mask margin
int m_LocalSolderPasteMargin; ///< Solder paste margin
///< absolute value
double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
///< value of pad size
// The final margin is the sum of these 2 values // The final margin is the sum of these 2 values
ZoneConnection m_ZoneConnection; ZoneConnection m_ZoneConnection;
...@@ -236,14 +226,6 @@ public: ...@@ -236,14 +226,6 @@ public:
void SetLastEditTime( long aTime ) { m_LastEdit_Time = aTime; } void SetLastEditTime( long aTime ) { m_LastEdit_Time = aTime; }
long GetLastEditTime() const { return m_LastEdit_Time; } long GetLastEditTime() const { return m_LastEdit_Time; }
/* Reading and writing data on files */
bool Save( FILE* aFile ) const;
int Write_3D_Descr( FILE* File ) const;
int ReadDescr( LINE_READER* aReader );
/** /**
* Function Read_GPCB_Descr * Function Read_GPCB_Descr
* reads a footprint description in GPCB format (newlib version) * reads a footprint description in GPCB format (newlib version)
...@@ -358,7 +340,18 @@ public: ...@@ -358,7 +340,18 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
};
private:
// Local tolerances. When zero, this means the corresponding netclass value
// is used. Usually theses local tolerances zero, in deference to the
// corresponding netclass values.
int m_LocalClearance;
int m_LocalSolderMaskMargin; ///< Solder mask margin
int m_LocalSolderPasteMargin; ///< Solder paste margin
///< absolute value
double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
///< value of pad size
};
#endif // MODULE_H_ #endif // MODULE_H_
...@@ -198,22 +198,6 @@ public: ...@@ -198,22 +198,6 @@ public:
*/ */
void SetParams( const NETCLASS* defaults = NULL ); void SetParams( const NETCLASS* defaults = NULL );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Function ReadDescr
* reads the data structures for this object from a LINE_READER in "*.brd" format.
* @param aReader is a pointer to a LINE_READER to read from.
* @return bool - true if success reading else false.
*/
bool ReadDescr( LINE_READER* aReader );
/** /**
* Function Format * Function Format
* outputs the net class to \a aFormatter in s-expression form. * outputs the net class to \a aFormatter in s-expression form.
......
...@@ -342,18 +342,6 @@ public: ...@@ -342,18 +342,6 @@ public:
#endif #endif
/* Reading and writing data on files */
int ReadDescr( LINE_READER* aReader );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/** /**
* Function Draw * Function Draw
* @todo we actually could show a NET, simply show all the tracks and * @todo we actually could show a NET, simply show all the tracks and
......
...@@ -332,9 +332,10 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const ...@@ -332,9 +332,10 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int clearance = m_LocalClearance; int clearance = m_LocalClearance;
if( clearance == 0 ) if( clearance == 0 )
{ // If local clearance is 0, use the parent footprint clearance value {
if( GetParent() && ( (MODULE*) GetParent() )->m_LocalClearance ) // If local clearance is 0, use the parent footprint clearance value
clearance = ( (MODULE*) GetParent() )->m_LocalClearance; if( GetParent() && GetParent()->GetLocalClearance() )
clearance = GetParent()->GetLocalClearance();
} }
if( clearance == 0 ) // If the parent footprint clearance value = 0, use NETCLASS value if( clearance == 0 ) // If the parent footprint clearance value = 0, use NETCLASS value
...@@ -367,14 +368,14 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const ...@@ -367,14 +368,14 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int D_PAD::GetSolderMaskMargin() int D_PAD::GetSolderMaskMargin()
{ {
int margin = m_LocalSolderMaskMargin; int margin = m_LocalSolderMaskMargin;
MODULE* module = (MODULE*) GetParent(); MODULE* module = GetParent();
if( module ) if( module )
{ {
if( margin == 0 ) if( margin == 0 )
{ {
if( module->m_LocalSolderMaskMargin ) if( module->GetLocalSolderMaskMargin() )
margin = module->m_LocalSolderMaskMargin; margin = module->GetLocalSolderMaskMargin();
} }
if( margin == 0 ) if( margin == 0 )
...@@ -410,12 +411,12 @@ wxSize D_PAD::GetSolderPasteMargin() ...@@ -410,12 +411,12 @@ wxSize D_PAD::GetSolderPasteMargin()
{ {
int margin = m_LocalSolderPasteMargin; int margin = m_LocalSolderPasteMargin;
double mratio = m_LocalSolderPasteMarginRatio; double mratio = m_LocalSolderPasteMarginRatio;
MODULE * module = (MODULE*) GetParent(); MODULE* module = GetParent();
if( module ) if( module )
{ {
if( margin == 0 ) if( margin == 0 )
margin = module->m_LocalSolderPasteMargin; margin = module->GetLocalSolderPasteMargin();
BOARD * brd = GetBoard(); BOARD * brd = GetBoard();
...@@ -423,7 +424,7 @@ wxSize D_PAD::GetSolderPasteMargin() ...@@ -423,7 +424,7 @@ wxSize D_PAD::GetSolderPasteMargin()
margin = brd->GetDesignSettings().m_SolderPasteMargin; margin = brd->GetDesignSettings().m_SolderPasteMargin;
if( mratio == 0.0 ) if( mratio == 0.0 )
mratio = module->m_LocalSolderPasteMarginRatio; mratio = module->GetLocalSolderPasteMarginRatio();
if( mratio == 0.0 ) if( mratio == 0.0 )
{ {
......
...@@ -267,12 +267,6 @@ public: ...@@ -267,12 +267,6 @@ public:
void SetThermalGap( int aGap ) { m_ThermalGap = aGap; } void SetThermalGap( int aGap ) { m_ThermalGap = aGap; }
int GetThermalGap() const; int GetThermalGap() const;
/* Reading and writing data on files */
int ReadDescr( LINE_READER* aReader );
bool Save( FILE* aFile ) const;
/* drawing functions */ /* drawing functions */
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int aDrawMode, const wxPoint& aOffset = ZeroOffset ); int aDrawMode, const wxPoint& aOffset = ZeroOffset );
......
...@@ -73,11 +73,6 @@ public: ...@@ -73,11 +73,6 @@ public:
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& offset = ZeroOffset ); const wxPoint& offset = ZeroOffset );
// File Operations:
int ReadTextePcbDescr( LINE_READER* aReader );
bool Save( FILE* aFile ) const;
void DisplayInfo( EDA_DRAW_FRAME* frame ); void DisplayInfo( EDA_DRAW_FRAME* frame );
bool HitTest( const wxPoint& aPosition ) bool HitTest( const wxPoint& aPosition )
......
...@@ -116,16 +116,6 @@ public: ...@@ -116,16 +116,6 @@ public:
void SetLocalCoord(); // Set relative coordinates. void SetLocalCoord(); // Set relative coordinates.
bool Save( FILE* aFile ) const;
/**
* Function ReadDescr
* Read description from a given line in "*.brd" format.
* @param aReader is a pointer to a LINE_READER to read from.
* @return int - > 0 if success reading else 0.
*/
int ReadDescr( LINE_READER* aReader );
/* drawing functions */ /* drawing functions */
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel,
wxDC* DC, wxDC* DC,
......
...@@ -125,8 +125,6 @@ public: ...@@ -125,8 +125,6 @@ public:
EDA_RECT GetBoundingBox() const; EDA_RECT GetBoundingBox() const;
bool Save( FILE* aFile ) const;
/** /**
* Function GetBestInsertPoint * Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list. * searches the "best" insertion point within the track linked list.
......
...@@ -135,16 +135,6 @@ public: ...@@ -135,16 +135,6 @@ public:
~ZONE_CONTAINER(); ~ZONE_CONTAINER();
bool Save( FILE* aFile ) const;
/**
* Function ReadDescr
* reads the data structures for this object from a LINE_READER in "*.brd" format.
* @param aReader is a pointer to a LINE_READER to read from.
* @return int - 1 if success, 0 if not.
*/
int ReadDescr( LINE_READER* aReader );
/** /**
* Function GetPosition * Function GetPosition
* @return a wxPoint, position of the first point of the outline * @return a wxPoint, position of the first point of the outline
......
...@@ -110,8 +110,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() ...@@ -110,8 +110,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance ); PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin ); PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() );
// These 2 parameters are usually < 0, so prepare entering a negative // These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0 // value, if current is 0
......
...@@ -149,8 +149,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() ...@@ -149,8 +149,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
wxString msg; wxString msg;
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance ); PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin ); PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() );
// These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0 // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() ); PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() );
......
...@@ -202,70 +202,6 @@ the changes?" ) ) ) ...@@ -202,70 +202,6 @@ the changes?" ) ) )
GetScreen()->SetFileName( fileName.GetFullPath() ); GetScreen()->SetFileName( fileName.GetFullPath() );
#if !defined(USE_NEW_PCBNEW_LOAD)
// Start read PCB file
FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL )
{
msg.Printf( _( "File <%s> not found" ), GetChars( GetScreen()->GetFileName() ) );
DisplayError( this, msg );
return false;
}
FILE_LINE_READER fileReader( source, GetScreen()->GetFileName() );
FILTER_READER reader( fileReader );
// Read header and TEST if it is a PCB file format
reader.ReadLine();
if( strncmp( reader.Line(), "PCBNEW-BOARD", 12 ) != 0 )
{
DisplayError( this, wxT( "Unknown file type" ) );
return false;
}
int ver;
sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver );
if ( ver > LEGACY_BOARD_FILE_VERSION )
{
DisplayInfoMessage( this, _( "This file was created by a more recent \
version of Pcbnew and may not load correctly. Please consider updating!" ) );
}
else if ( ver < LEGACY_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." ) );
}
// Reload the corresponding configuration file:
wxSetWorkingDirectory( wxPathOnly( GetScreen()->GetFileName() ) );
if( aAppend )
{
ReadPcbFile( &reader, true );
}
else
{
// Update the option toolbar
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayModText = DisplayOpt.DisplayModText;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
// load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() );
ReadPcbFile( &reader, false );
}
#else
if( !aAppend ) if( !aAppend )
{ {
// Update the option toolbar // Update the option toolbar
...@@ -321,8 +257,6 @@ this file again." ) ); ...@@ -321,8 +257,6 @@ this file again." ) );
BestZoom(); BestZoom();
} }
#endif
GetScreen()->ClrModify(); GetScreen()->ClrModify();
// If append option: change the initial board name to <oldname>-append.brd // If append option: change the initial board name to <oldname>-append.brd
...@@ -456,10 +390,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -456,10 +390,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
pcbFileName = GetScreen()->GetFileName(); pcbFileName = GetScreen()->GetFileName();
#if defined( USE_NEW_PCBNEW_LOAD ) || defined( USE_NEW_PCBNEW_SAVE )
if( pcbFileName.GetExt().IsEmpty() ) if( pcbFileName.GetExt().IsEmpty() )
pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) ); pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) );
#endif
if( !IsWritable( pcbFileName ) ) if( !IsWritable( pcbFileName ) )
return false; return false;
...@@ -493,8 +425,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -493,8 +425,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
} }
} }
#if defined(USE_NEW_PCBNEW_SAVE)
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK; GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
GetBoard()->SynchronizeNetsAndNetClasses(); GetBoard()->SynchronizeNetsAndNetClasses();
...@@ -535,29 +465,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -535,29 +465,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
UpdateTitle(); UpdateTitle();
} }
#else
// Create the file
FILE* dest;
dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) );
if( dest == 0 )
{
msg = _( "Unable to create " ) + pcbFileName.GetFullPath();
DisplayError( this, msg );
saveok = false;
}
if( dest )
{
GetScreen()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle();
SavePcbFormatAscii( dest );
fclose( dest );
}
#endif
// Display the file names: // Display the file names:
m_messagePanel->EraseMsgBox(); m_messagePanel->EraseMsgBox();
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <legacy_plugin.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <pcb_plot_params.h> #include <pcb_plot_params.h>
...@@ -532,7 +533,6 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) ...@@ -532,7 +533,6 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
*/ */
bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM ) bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM )
{ {
MODULE* Module;
D_PAD* pad; D_PAD* pad;
char line[1024]; char line[1024];
wxString fnFront, msg; wxString fnFront, msg;
...@@ -550,9 +550,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool ...@@ -550,9 +550,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
double conv_unit = aUnitsMM ? conv_unit_mm : conv_unit_inch; double conv_unit = aUnitsMM ? conv_unit_mm : conv_unit_inch;
const char *unit_text = aUnitsMM ? unit_text_mm : unit_text_inch; const char *unit_text = aUnitsMM ? unit_text_mm : unit_text_inch;
// Switch the locale to standard C (needed to print floating point LOCALE_IO toggle;
// numbers like 1.3)
SetLocaleTo_C_standard();
// Generate header file comments.) // Generate header file comments.)
sprintf( line, "## Module report - date %s\n", TO_UTF8( DateAndTime() ) ); sprintf( line, "## Module report - date %s\n", TO_UTF8( DateAndTime() ) );
...@@ -584,9 +582,15 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool ...@@ -584,9 +582,15 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fputs( "$EndBOARD\n\n", rptfile ); fputs( "$EndBOARD\n\n", rptfile );
Module = (MODULE*) GetBoard()->m_Modules; try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
LEGACY_PLUGIN* legacy = (LEGACY_PLUGIN*) (PLUGIN*) pi;
legacy->SetFilePtr( rptfile );
for( ; Module != NULL; Module = Module->Next() ) for( MODULE* Module = GetBoard()->m_Modules; Module; Module = Module->Next() )
{ {
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() ); sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile ); fputs( line, rptfile );
...@@ -632,7 +636,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool ...@@ -632,7 +636,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fputs( line, rptfile ); fputs( line, rptfile );
Module->Write_3D_Descr( rptfile ); legacy->SaveModule3D( Module );
for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
...@@ -682,6 +686,11 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool ...@@ -682,6 +686,11 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fprintf( rptfile, "$EndMODULE %s\n\n", fprintf( rptfile, "$EndMODULE %s\n\n",
TO_UTF8(Module->m_Reference->m_Text ) ); TO_UTF8(Module->m_Reference->m_Text ) );
} }
}
catch( IO_ERROR ioe )
{
DisplayError( NULL, ioe.errorText );
}
// Write board Edges // Write board Edges
EDA_ITEM* PtStruct; EDA_ITEM* PtStruct;
...@@ -700,7 +709,6 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool ...@@ -700,7 +709,6 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
// Generate EOF. // Generate EOF.
fputs( "$EndDESCRIPTION\n", rptfile ); fputs( "$EndDESCRIPTION\n", rptfile );
fclose( rptfile ); fclose( rptfile );
SetLocaleTo_Default( ); // revert to the current locale
return true; return true;
} }
......
...@@ -170,7 +170,7 @@ MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFo ...@@ -170,7 +170,7 @@ MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFo
} }
void PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties ) void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
...@@ -184,7 +184,21 @@ void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo ...@@ -184,7 +184,21 @@ void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo
} }
bool PLUGIN::IsLibraryWritable( const wxString& aLibraryPath ) void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
......
...@@ -153,7 +153,9 @@ public: ...@@ -153,7 +153,9 @@ public:
* is a base class that BOARD loading and saving plugins should derive from. * is a base class that BOARD loading and saving plugins should derive from.
* Implementations can provide either Load() or Save() functions, or both. * Implementations can provide either Load() or Save() functions, or both.
* PLUGINs throw exceptions, so it is best that you wrap your calls to these * PLUGINs throw exceptions, so it is best that you wrap your calls to these
* functions in a try catch block. * functions in a try catch block. Plugins throw exceptions because it is illegal
* for them to have any user interface calls in them whatsoever, i.e. no windowing
* or screen printing at all.
* *
* <pre> * <pre>
* try * try
...@@ -188,9 +190,9 @@ public: ...@@ -188,9 +190,9 @@ public:
/** /**
* Function Load * Function Load
* loads a board file, or a portion of one, from some input file format * loads information from some input file format that this PLUGIN implementation
* that this PLUGIN implementation knows about. This may be used to load an * knows about, into either a new BOARD or an existing one. This may be used to load an
* entire new BOARD, or to augment an existing one if \a aAppendToMe is not NULL. * entire new BOARD, or to augment an existing one if @a aAppendToMe is not NULL.
* *
* @param aFileName is the name of the file to use as input and may be foreign in * @param aFileName is the name of the file to use as input and may be foreign in
* nature or native in nature. * nature or native in nature.
...@@ -217,7 +219,7 @@ public: ...@@ -217,7 +219,7 @@ public:
/** /**
* Function Save * Function Save
* will write a full aBoard to a storage file in a format that this * will write @a aBoard to a storage file in a format that this
* PLUGIN implementation knows about, or it can be used to write a portion of * PLUGIN implementation knows about, or it can be used to write a portion of
* aBoard to a special kind of export file. * aBoard to a special kind of export file.
* *
...@@ -242,7 +244,7 @@ public: ...@@ -242,7 +244,7 @@ public:
* Function FootprintEnumerate * Function FootprintEnumerate
* returns a list of footprint names contained within the library at @a aLibraryPath. * returns a list of footprint names contained within the library at @a aLibraryPath.
* *
* @param aLibraryPath is locator for the "library", usually a directory * @param aLibraryPath is a locator for the "library", usually a directory
* or file containing several footprints. * or file containing several footprints.
* *
* @param aProperties is an associative array that can be used to tell the * @param aProperties is an associative array that can be used to tell the
...@@ -262,7 +264,7 @@ public: ...@@ -262,7 +264,7 @@ public:
* loads a MODULE having @a aFootprintName from the @a aLibraryPath containing * loads a MODULE having @a aFootprintName from the @a aLibraryPath containing
* a library format that this PLUGIN knows about. * a library format that this PLUGIN knows about.
* *
* @param aLibraryPath is locator for the "library", usually a directory * @param aLibraryPath is a locator for the "library", usually a directory
* or file containing several footprints. * or file containing several footprints.
* *
* @param aFootprintName is the name of the footprint to load. * @param aFootprintName is the name of the footprint to load.
...@@ -273,21 +275,20 @@ public: ...@@ -273,21 +275,20 @@ public:
* The caller continues to own this object (plugin may not delete it), and * The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL. * plugins should expect it to be optionally NULL.
* *
* @return MODULE* - caller owns it. Never NULL because exception thrown if error. * @return MODULE* - if found caller owns it, else NULL if not found.
* *
* @throw IO_ERROR if the PLUGIN cannot be found, library cannot be found, * @throw IO_ERROR if the library cannot be found or read. No exception
* or footprint cannot be loaded. * is thrown in the case where aFootprintName cannot be found.
*/ */
virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
/** /**
* Function FootprintSave * Function FootprintSave
* will write @a aModule to an existing library located at @a aLibraryPath, * will write @a aModule to an existing library located at @a aLibraryPath.
* and create the library if it doesn't exist then perform the write. If a * If a footprint by the same name already exists, it is replaced.
* footprint by the same name already exists, it is replaced.
* *
* @param aLibraryPath is locator for the "library", usually a directory * @param aLibraryPath is a locator for the "library", usually a directory
* or file containing several footprints. This is where the footprint is * or file containing several footprints. This is where the footprint is
* to be stored. * to be stored.
* *
...@@ -302,14 +303,14 @@ public: ...@@ -302,14 +303,14 @@ public:
* *
* @throw IO_ERROR if there is a problem saving. * @throw IO_ERROR if there is a problem saving.
*/ */
virtual void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, virtual void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
/** /**
* Function FootprintDelete * Function FootprintDelete
* deletes the @a aFootprintName from the library at @a aLibraryPath. * deletes the @a aFootprintName from the library at @a aLibraryPath.
* *
* @param aLibraryPath is locator for the "library", usually a directory * @param aLibraryPath is a locator for the "library", usually a directory
* or file containing several footprints. * or file containing several footprints.
* *
* @param aFootprintName is the name of a footprint to delete from the specificed library. * @param aFootprintName is the name of a footprint to delete from the specificed library.
...@@ -319,11 +320,48 @@ public: ...@@ -319,11 +320,48 @@ public:
virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName ); virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
/** /**
* Function IsLibraryWritable * Function FootprintLibCreate
* creates a new empty footprint library at @a aLibraryPath empty. It is an
* error to attempt to create an existing library or to attempt to create
* on a "read only" location.
*
* @param aLibraryPath is a locator for the "library", usually a directory
* or file which will contain footprints.
*
* @param aProperties is an associative array that can be used to tell the
* library create function anything special, because it can take any number of
* additional named tuning arguments that the plugin is known to support.
* The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL.
*
* @throw IO_ERROR if there is a problem finding the library, or creating it.
*/
virtual void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
/**
* Function FootprintLibDelete
* deletes an existing footprint library, or complains if it cannot delete it or if it
* does not exist.
*
* @param aLibraryPath is a locator for the "library", usually a directory
* or file which will contain footprints.
*
* @param aProperties is an associative array that can be used to tell the
* library create function anything special, because it can take any number of
* additional named tuning arguments that the plugin is known to support.
* The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL.
*
* @throw IO_ERROR if there is a problem finding the library, or deleting it.
*/
virtual void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
/**
* Function IsFootprintLibWritable
* returns true iff the library at @a aLibraryPath is writable. (Often * returns true iff the library at @a aLibraryPath is writable. (Often
* system libraries are read only because of where they are installed.) * system libraries are read only because of where they are installed.)
*/ */
virtual bool IsLibraryWritable( const wxString& aLibraryPath ); virtual bool IsFootprintLibWritable( const wxString& aLibraryPath );
//-----</PUBLIC PLUGIN API>------------------------------------------------ //-----</PUBLIC PLUGIN API>------------------------------------------------
......
This diff is collapsed.
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include <io_mgr.h> #include <io_mgr.h>
#include <string> #include <string>
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
#define FOOTPRINT_LIBRARY_HEADER_CNT 18
typedef int BIU; typedef int BIU;
class PCB_TARGET; class PCB_TARGET;
...@@ -44,7 +48,7 @@ class EDGE_MODULE; ...@@ -44,7 +48,7 @@ class EDGE_MODULE;
class TRACK; class TRACK;
class SEGZONE; class SEGZONE;
class D_PAD; class D_PAD;
class FPL_CACHE; struct FPL_CACHE;
/** /**
...@@ -54,6 +58,7 @@ class FPL_CACHE; ...@@ -54,6 +58,7 @@ class FPL_CACHE;
*/ */
class LEGACY_PLUGIN : public PLUGIN class LEGACY_PLUGIN : public PLUGIN
{ {
friend struct FPL_CACHE;
public: public:
...@@ -80,12 +85,16 @@ public: ...@@ -80,12 +85,16 @@ public:
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName ); void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
bool IsLibraryWritable( const wxString& aLibraryPath ); void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( const wxString& aLibraryPath );
//-----</PLUGIN IMPLEMENTATION>--------------------------------------------- //-----</PLUGIN IMPLEMENTATION>---------------------------------------------
...@@ -103,7 +112,8 @@ public: ...@@ -103,7 +112,8 @@ public:
void SetFilePtr( FILE* aFile ) { m_fp = aFile; } void SetFilePtr( FILE* aFile ) { m_fp = aFile; }
MODULE* LoadMODULE(); MODULE* LoadMODULE();
void SaveMODULE( const MODULE* aModule ) const;
void SaveModule3D( const MODULE* aModule ) const;
protected: protected:
...@@ -243,11 +253,9 @@ protected: ...@@ -243,11 +253,9 @@ protected:
void saveSETUP() const; void saveSETUP() const;
void saveBOARD() const; void saveBOARD() const;
void saveMODULE( const MODULE* aModule ) const;
void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const; void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const; void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
void savePAD( const D_PAD* aPad ) const; void savePAD( const D_PAD* aPad ) const;
void save3D( const MODULE* aModule ) const;
void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const; void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
void saveNETCLASSES() const; void saveNETCLASSES() const;
......
This diff is collapsed.
...@@ -42,11 +42,11 @@ ...@@ -42,11 +42,11 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <io_mgr.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <module_editor_frame.h> #include <module_editor_frame.h>
#include <footprint_info.h> #include <footprint_info.h>
#include <class_footprint_library.h>
#include <dialog_get_component.h> #include <dialog_get_component.h>
#include <modview_frame.h> #include <modview_frame.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
...@@ -141,6 +141,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void ) ...@@ -141,6 +141,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
return fpname; return fpname;
} }
MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
bool aUseFootprintViewer, bool aUseFootprintViewer,
wxDC* aDC ) wxDC* aDC )
...@@ -148,7 +149,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -148,7 +149,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
MODULE* module; MODULE* module;
wxPoint curspos = GetScreen()->GetCrossHairPosition(); wxPoint curspos = GetScreen()->GetCrossHairPosition();
wxString moduleName, keys; wxString moduleName, keys;
bool AllowWildSeach = true; bool allowWildSeach = true;
static wxArrayString HistoryList; static wxArrayString HistoryList;
static wxString lastComponentName; static wxString lastComponentName;
...@@ -181,7 +182,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -181,7 +182,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
if( dlg.IsKeyword() ) // Selection by keywords if( dlg.IsKeyword() ) // Selection by keywords
{ {
AllowWildSeach = false; allowWildSeach = false;
keys = moduleName; keys = moduleName;
moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys ); moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys );
...@@ -194,7 +195,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -194,7 +195,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
else if( ( moduleName.Contains( wxT( "?" ) ) ) else if( ( moduleName.Contains( wxT( "?" ) ) )
|| ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card || ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{ {
AllowWildSeach = false; allowWildSeach = false;
moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString );
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
...@@ -206,11 +207,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -206,11 +207,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
module = GetModuleLibrary( aLibrary, moduleName, false ); module = GetModuleLibrary( aLibrary, moduleName, false );
if( ( module == NULL ) && AllowWildSeach ) // Search with wild card if( !module && allowWildSeach ) // Search with wild card
{ {
AllowWildSeach = false; allowWildSeach = false;
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
moduleName = wildname; moduleName = wildname;
moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString );
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
...@@ -234,13 +237,17 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -234,13 +237,17 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
module->SetFlags( IS_NEW ); module->SetFlags( IS_NEW );
module->m_Link = 0; module->m_Link = 0;
module->SetTimeStamp( GetNewTimeStamp() ); module->SetTimeStamp( GetNewTimeStamp() );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
module->SetPosition( curspos ); module->SetPosition( curspos );
// Put it on FRONT layer, // Put it on FRONT layer,
// (Can be stored on BACK layer if the lib is an archive built from a board) // (Can be stored on BACK layer if the lib is an archive built from a board)
if( module->GetLayer() != LAYER_N_FRONT ) if( module->GetLayer() != LAYER_N_FRONT )
module->Flip( module->m_Pos ); module->Flip( module->m_Pos );
// Put in in orientation 0, // Put in in orientation 0,
// even if it is not saved with with orientation 0 in lib // even if it is not saved with with orientation 0 in lib
// (Can happen if the lib is an archive built from a board) // (Can happen if the lib is an archive built from a board)
...@@ -256,117 +263,102 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -256,117 +263,102 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
} }
MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename, MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
const wxString& aModuleName, const wxString& aFootprintName, bool aDisplayError )
bool aDisplayMessageError )
{ {
wxFileName fn; try
wxString msg, tmp;
MODULE* newModule;
FILE* file = NULL;
bool error_set = false;
bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{ {
if( one_lib ) PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
fn = aLibraryFullFilename;
else
fn = wxFileName( wxEmptyString, g_LibraryNames[ii], FootprintLibFileExtension );
tmp = wxGetApp().FindLibraryPath( fn ); wxString libPath = wxGetApp().FindLibraryPath( aLibraryPath );
if( !tmp ) MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
if( !footprint )
{ {
if( aDisplayMessageError && !error_set ) if( aDisplayError )
{ {
msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ), wxString msg = wxString::Format(
GetChars( fn.GetFullName() ) ); _( "Footprint '%s' not found in library '%s'" ),
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this ); aFootprintName.GetData(),
error_set = true; libPath.GetData() );
}
continue; DisplayError( NULL, msg );
} }
file = wxFopen( tmp, wxT( "rt" ) ); return NULL;
}
if( file == NULL ) GetBoard()->Add( footprint, ADD_APPEND );
SetStatusText( wxEmptyString );
return footprint;
}
catch( IO_ERROR ioe )
{ {
msg.Printf( _( "Could not open PCB footprint library file <%s>." ), DisplayError( this, ioe.errorText );
GetChars( tmp ) ); return NULL;
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
continue;
} }
}
FILE_LINE_READER fileReader( file, tmp );
FILTER_READER reader( fileReader );
msg.Printf( _( "Scan Lib: %s" ), GetChars( tmp ) );
SetStatusText( msg );
FOOTPRINT_LIBRARY curr_lib( file, &reader ); MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
const wxString& aFootprintName, bool aDisplayError )
{
bool showed_error = false;
MODULE* footprint = NULL;
if( !curr_lib.IsLibrary() ) try
{ {
msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library file." ), PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
GetChars( tmp ) );
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
return NULL;
}
// Reading the list of modules in the library.
curr_lib.ReadSectionIndex();
bool found = curr_lib.FindInList( aModuleName );
// Read library. for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
if( found )
{ {
wxString name; wxFileName fn = wxFileName( wxEmptyString, g_LibraryNames[ii], FootprintLibFileExtension );
fileReader.Rewind(); wxString libPath = wxGetApp().FindLibraryPath( fn );
while( reader.ReadLine() ) if( !libPath )
{ {
char* line = reader.Line(); if( aDisplayError && !showed_error )
{
StrPurge( line + 8 ); wxString msg = wxString::Format(
_( "PCB footprint library file <%s> not found in search paths." ),
fn.GetFullName().GetData() );
if( strnicmp( line, "$MODULE", 7 ) != 0 ) DisplayError( this, msg );
showed_error = true;
}
continue; continue;
}
// Read module name. footprint = pi->FootprintLoad( libPath, aFootprintName );
name = FROM_UTF8( line + 8 );
if( name.CmpNoCase( aModuleName ) == 0 ) if( footprint )
{ {
newModule = new MODULE( GetBoard() ); GetBoard()->Add( footprint, ADD_APPEND );
// Temporarily switch the locale to standard C (needed to print
// floating point numbers like 1.3)
LOCALE_IO toggle;
newModule->ReadDescr( &reader );
GetBoard()->Add( newModule, ADD_APPEND );
SetStatusText( wxEmptyString ); SetStatusText( wxEmptyString );
return newModule; return footprint;
}
}
} }
if( one_lib )
break;
} }
if( aDisplayMessageError ) if( !footprint )
{
if( aDisplayError )
{ {
msg.Printf( _( "Module <%s> not found" ), GetChars( aModuleName ) ); wxString msg = wxString::Format(
_( "Footprint '%s' not found in any library" ),
aFootprintName.GetData() );
DisplayError( NULL, msg ); DisplayError( NULL, msg );
} }
return NULL;
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
}
return NULL; return NULL;
} }
......
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