more footprint support for LEGACY_PLUGIN
This commit is contained in:
parent
a42490e0f3
commit
3341669fc6
|
@ -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 @@
|
||||||
|
|
||||||
#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
|
||||||
../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:
|
||||||
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:
|
||||||
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:
|
||||||
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:
|
||||||
// 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:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
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:
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
bool Save( FILE* aFile ) const;
|
|
||||||
|
|
||||||
wxString GetClass() const
|
wxString GetClass() const
|
||||||
{
|
{
|
||||||
return wxT( "BOARD" );
|
return wxT( "BOARD" );
|
||||||
|
|
|
@ -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:
|
||||||
*/
|
*/
|
||||||
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:
|
||||||
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:
|
||||||
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:
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
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 ) :
|
||||||
// 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:
|
||||||
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:
|
||||||
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:
|
||||||
#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:
|
||||||
*/
|
*/
|
||||||
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:
|
||||||
|
|
||||||
#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
|
||||||
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
|
||||||
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()
|
||||||
{
|
{
|
||||||
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()
|
||||||
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:
|
||||||
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:
|
||||||
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:
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
~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()
|
||||||
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()
|
||||||
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?" ) ) )
|
||||||
|
|
||||||
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." ) );
|
||||||
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
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#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
|
||||||
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 @@
|
||||||
#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 )
|
||||||
*/
|
*/
|
||||||
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
|
||||||
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
|
||||||
|
|
||||||
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 ) );
|
||||||
|
|
||||||
for( ; Module != NULL; Module = Module->Next() )
|
LEGACY_PLUGIN* legacy = (LEGACY_PLUGIN*) (PLUGIN*) pi;
|
||||||
|
|
||||||
|
legacy->SetFilePtr( rptfile );
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
* 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:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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:
|
||||||
* 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:
|
||||||
* 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:
|
||||||
* 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:
|
||||||
*
|
*
|
||||||
* @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:
|
||||||
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>------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2007-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
* Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
||||||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
||||||
|
|
||||||
|
@ -98,6 +98,8 @@
|
||||||
#define SZ( x ) (sizeof(x)-1)
|
#define SZ( x ) (sizeof(x)-1)
|
||||||
|
|
||||||
|
|
||||||
|
//-----<BOARD Load Functions>---------------------------------------------------
|
||||||
|
|
||||||
/// C string compare test for a specific length of characters.
|
/// C string compare test for a specific length of characters.
|
||||||
#define TESTLINE( x ) ( !strnicmp( line, x, SZ( x ) ) && isspace( line[SZ( x )] ) )
|
#define TESTLINE( x ) ( !strnicmp( line, x, SZ( x ) ) && isspace( line[SZ( x )] ) )
|
||||||
|
|
||||||
|
@ -940,7 +942,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
|
||||||
|
|
||||||
else if( TESTLINE( "Li" ) ) // Library name of footprint
|
else if( TESTLINE( "Li" ) ) // Library name of footprint
|
||||||
{
|
{
|
||||||
module->m_LibRef = FROM_UTF8( StrPurge( line + SZ( "Li" ) ) );
|
module->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TESTLINE( "Sc" ) ) // timestamp
|
else if( TESTLINE( "Sc" ) ) // timestamp
|
||||||
|
@ -2685,7 +2687,6 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
|
||||||
biuToDisk = 1.0; // BIUs are deci-mils
|
biuToDisk = 1.0; // BIUs are deci-mils
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// conversion factor for loading KICAD legacy file format into BIUs in RAM
|
// conversion factor for loading KICAD legacy file format into BIUs in RAM
|
||||||
|
|
||||||
// Start by assuming the *.brd file is in deci-mils.
|
// Start by assuming the *.brd file is in deci-mils.
|
||||||
|
@ -2701,7 +2702,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----<Save() Functions>-------------------------------------------------------
|
//-----<BOARD Save Functions>---------------------------------------------------
|
||||||
|
|
||||||
void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
|
void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
|
@ -2958,7 +2959,7 @@ void LEGACY_PLUGIN::saveBOARD() const
|
||||||
|
|
||||||
// save the modules
|
// save the modules
|
||||||
for( MODULE* m = m_board->m_Modules; m; m = (MODULE*) m->Next() )
|
for( MODULE* m = m_board->m_Modules; m; m = (MODULE*) m->Next() )
|
||||||
saveMODULE( m );
|
SaveMODULE( m );
|
||||||
|
|
||||||
// save the graphics owned by the board (not owned by a module)
|
// save the graphics owned by the board (not owned by a module)
|
||||||
for( BOARD_ITEM* gr = m_board->m_Drawings; gr; gr = gr->Next() )
|
for( BOARD_ITEM* gr = m_board->m_Drawings; gr; gr = gr->Next() )
|
||||||
|
@ -3231,8 +3232,9 @@ void LEGACY_PLUGIN::savePAD( const D_PAD* me ) const
|
||||||
if( me->GetLocalSolderPasteMargin() != 0 )
|
if( me->GetLocalSolderPasteMargin() != 0 )
|
||||||
fprintf( m_fp, ".SolderPaste %s\n", fmtBIU( me->GetLocalSolderPasteMargin() ).c_str() );
|
fprintf( m_fp, ".SolderPaste %s\n", fmtBIU( me->GetLocalSolderPasteMargin() ).c_str() );
|
||||||
|
|
||||||
if( me->GetLocalSolderPasteMarginRatio() != 0 )
|
double ratio = me->GetLocalSolderPasteMarginRatio();
|
||||||
fprintf( m_fp, ".SolderPasteRatio %g\n", me->GetLocalSolderPasteMarginRatio() );
|
if( ratio != 0.0 )
|
||||||
|
fprintf( m_fp, ".SolderPasteRatio %g\n", ratio );
|
||||||
|
|
||||||
if( me->GetLocalClearance() != 0 )
|
if( me->GetLocalClearance() != 0 )
|
||||||
fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
|
fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
|
||||||
|
@ -3252,7 +3254,7 @@ void LEGACY_PLUGIN::savePAD( const D_PAD* me ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
|
void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
|
||||||
{
|
{
|
||||||
char statusTxt[3];
|
char statusTxt[3];
|
||||||
double orient = me->GetOrientation();
|
double orient = me->GetOrientation();
|
||||||
|
@ -3293,8 +3295,9 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
|
||||||
if( me->GetLocalSolderPasteMargin() != 0 )
|
if( me->GetLocalSolderPasteMargin() != 0 )
|
||||||
fprintf( m_fp, ".SolderPaste %s\n", fmtBIU( me->GetLocalSolderPasteMargin() ).c_str() );
|
fprintf( m_fp, ".SolderPaste %s\n", fmtBIU( me->GetLocalSolderPasteMargin() ).c_str() );
|
||||||
|
|
||||||
if( me->GetLocalSolderPasteMarginRatio() != 0 )
|
double ratio = me->GetLocalSolderPasteMarginRatio();
|
||||||
fprintf( m_fp, ".SolderPasteRatio %g\n", me->GetLocalSolderPasteMarginRatio() );
|
if( ratio != 0.0 )
|
||||||
|
fprintf( m_fp, ".SolderPasteRatio %g\n", ratio );
|
||||||
|
|
||||||
if( me->GetLocalClearance() != 0 )
|
if( me->GetLocalClearance() != 0 )
|
||||||
fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
|
fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
|
||||||
|
@ -3345,7 +3348,7 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
|
||||||
for( D_PAD* pad = me->m_Pads; pad; pad = pad->Next() )
|
for( D_PAD* pad = me->m_Pads; pad; pad = pad->Next() )
|
||||||
savePAD( pad );
|
savePAD( pad );
|
||||||
|
|
||||||
save3D( me );
|
SaveModule3D( me );
|
||||||
|
|
||||||
fprintf( m_fp, "$EndMODULE %s\n", TO_UTF8( me->GetLibRef() ) );
|
fprintf( m_fp, "$EndMODULE %s\n", TO_UTF8( me->GetLibRef() ) );
|
||||||
|
|
||||||
|
@ -3353,7 +3356,7 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LEGACY_PLUGIN::save3D( const MODULE* me ) const
|
void LEGACY_PLUGIN::SaveModule3D( const MODULE* me ) const
|
||||||
{
|
{
|
||||||
for( S3D_MASTER* t3D = me->m_3D_Drawings; t3D; t3D = t3D->Next() )
|
for( S3D_MASTER* t3D = me->m_3D_Drawings; t3D; t3D = t3D->Next() )
|
||||||
{
|
{
|
||||||
|
@ -3722,8 +3725,6 @@ typedef boost::ptr_map< wxString, MODULE > MODULE_MAP;
|
||||||
typedef MODULE_MAP::iterator MODULE_ITER;
|
typedef MODULE_MAP::iterator MODULE_ITER;
|
||||||
typedef MODULE_MAP::const_iterator MODULE_CITER;
|
typedef MODULE_MAP::const_iterator MODULE_CITER;
|
||||||
|
|
||||||
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FPL_CACHE
|
* Class FPL_CACHE
|
||||||
|
@ -3736,13 +3737,13 @@ struct FPL_CACHE
|
||||||
LEGACY_PLUGIN* m_owner; // my owner, I need its LEGACY_PLUGIN::LoadMODULE()
|
LEGACY_PLUGIN* m_owner; // my owner, I need its LEGACY_PLUGIN::LoadMODULE()
|
||||||
wxString m_lib_name;
|
wxString m_lib_name;
|
||||||
wxDateTime m_mod_time;
|
wxDateTime m_mod_time;
|
||||||
MODULE_MAP m_modules; // tuple of footprint name vs. MODULE*
|
MODULE_MAP m_modules; // map or tuple of footprint_name vs. MODULE*
|
||||||
bool m_writable;
|
bool m_writable;
|
||||||
|
|
||||||
FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath );
|
FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath );
|
||||||
|
|
||||||
// Most all functions in this class throw IO_ERROR exceptions. There is no
|
// Most all functions in this class throw IO_ERROR exceptions. There are no
|
||||||
// error codes nor user interface calls from here.
|
// error codes nor user interface calls from here, nor in any PLUGIN.
|
||||||
// Catch these exceptions higher up please.
|
// Catch these exceptions higher up please.
|
||||||
|
|
||||||
/// save the entire legacy library to m_lib_name;
|
/// save the entire legacy library to m_lib_name;
|
||||||
|
@ -3754,9 +3755,12 @@ struct FPL_CACHE
|
||||||
|
|
||||||
void SaveModules( FILE* aFile );
|
void SaveModules( FILE* aFile );
|
||||||
|
|
||||||
void SaveEndOfFile( FILE* aFile );
|
void SaveEndOfFile( FILE* aFile )
|
||||||
|
{
|
||||||
|
fprintf( aFile, "$EndLIBRARY\n" );
|
||||||
|
}
|
||||||
|
|
||||||
void Load( LINE_READER* aReader );
|
void Load();
|
||||||
|
|
||||||
void ReadAndVerifyHeader( LINE_READER* aReader );
|
void ReadAndVerifyHeader( LINE_READER* aReader );
|
||||||
|
|
||||||
|
@ -3771,19 +3775,8 @@ struct FPL_CACHE
|
||||||
FPL_CACHE::FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath ) :
|
FPL_CACHE::FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath ) :
|
||||||
m_owner( aOwner ),
|
m_owner( aOwner ),
|
||||||
m_lib_name( aLibraryPath ),
|
m_lib_name( aLibraryPath ),
|
||||||
m_writable( false )
|
m_writable( true )
|
||||||
{
|
{
|
||||||
FILE* fp = wxFopen( aLibraryPath, wxT( "r" ) );
|
|
||||||
if( !fp )
|
|
||||||
{
|
|
||||||
THROW_IO_ERROR( wxString::Format(
|
|
||||||
_( "Unable to open legacy library file '%s'" ), aLibraryPath.GetData() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// reader now owns fp, will close on exception or return
|
|
||||||
FILE_LINE_READER reader( fp, aLibraryPath );
|
|
||||||
|
|
||||||
Load( &reader );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3791,17 +3784,29 @@ wxDateTime FPL_CACHE::GetLibModificationTime()
|
||||||
{
|
{
|
||||||
wxFileName fn( m_lib_name );
|
wxFileName fn( m_lib_name );
|
||||||
|
|
||||||
|
// update the writable flag while we have a wxFileName, in a network this
|
||||||
|
// is possibly quite dynamic anyway.
|
||||||
m_writable = fn.IsFileWritable();
|
m_writable = fn.IsFileWritable();
|
||||||
|
|
||||||
return fn.GetModificationTime();
|
return fn.GetModificationTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FPL_CACHE::Load( LINE_READER* aReader )
|
void FPL_CACHE::Load()
|
||||||
{
|
{
|
||||||
ReadAndVerifyHeader( aReader );
|
FILE* fp = wxFopen( m_lib_name, wxT( "r" ) );
|
||||||
SkipIndex( aReader );
|
if( !fp )
|
||||||
LoadModules( aReader );
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format(
|
||||||
|
_( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// reader now owns fp, will close on exception or return
|
||||||
|
FILE_LINE_READER reader( fp, m_lib_name );
|
||||||
|
|
||||||
|
ReadAndVerifyHeader( &reader );
|
||||||
|
SkipIndex( &reader );
|
||||||
|
LoadModules( &reader );
|
||||||
|
|
||||||
// Remember the file modification time of library file when the
|
// Remember the file modification time of library file when the
|
||||||
// cache snapshot was made, so that in a networked environment we will
|
// cache snapshot was made, so that in a networked environment we will
|
||||||
|
@ -3812,17 +3817,45 @@ void FPL_CACHE::Load( LINE_READER* aReader )
|
||||||
|
|
||||||
void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
|
void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
|
||||||
{
|
{
|
||||||
|
char* line;
|
||||||
|
|
||||||
if( !aReader->ReadLine() )
|
if( !aReader->ReadLine() )
|
||||||
|
goto L_bad_library;
|
||||||
|
|
||||||
|
line = aReader->Line();
|
||||||
|
if( !TESTLINE( "PCBNEW-LibModule-V1" ) )
|
||||||
|
goto L_bad_library;
|
||||||
|
|
||||||
|
while( aReader->ReadLine() )
|
||||||
{
|
{
|
||||||
L_not_library:
|
line = aReader->Line();
|
||||||
THROW_IO_ERROR( wxString::Format( _( "File %s is empty or is not a legacy library" ),
|
if( TESTLINE( "Units" ) )
|
||||||
m_lib_name.GetData() ) );
|
{
|
||||||
|
const char* units = strtok( line + SZ( "Units" ), delims );
|
||||||
|
|
||||||
|
if( !strcmp( units, "mm" ) )
|
||||||
|
{
|
||||||
|
#if defined( USE_PCBNEW_NANOMETRES )
|
||||||
|
m_owner->diskToBiu = 1000000.0;
|
||||||
|
|
||||||
|
#elif defined(DEBUG)
|
||||||
|
// mm to deci-mils:
|
||||||
|
// advanced testing of round tripping only, not supported in non DEBUG build
|
||||||
|
m_owner->diskToBiu = 10000/25.4;
|
||||||
|
|
||||||
|
#else
|
||||||
|
THROW_IO_ERROR( _( "May not load millimeter legacy library file into 'PCBNew compiled for deci-mils'" ) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char* line = aReader->Line();
|
}
|
||||||
|
else if( TESTLINE( "$INDEX" ) )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( !TESTLINE( "PCBNEW-LibModule-V1" ) )
|
L_bad_library:
|
||||||
goto L_not_library;
|
THROW_IO_ERROR( wxString::Format( _( "File '%s' is empty or is not a legacy library" ),
|
||||||
|
m_lib_name.GetData() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3833,7 +3866,7 @@ void FPL_CACHE::SkipIndex( LINE_READER* aReader )
|
||||||
// to see if this is not a new $INDEX tag.
|
// to see if this is not a new $INDEX tag.
|
||||||
bool exit = false;
|
bool exit = false;
|
||||||
|
|
||||||
while( aReader->ReadLine() )
|
do
|
||||||
{
|
{
|
||||||
char* line = aReader->Line();
|
char* line = aReader->Line();
|
||||||
|
|
||||||
|
@ -3854,7 +3887,7 @@ void FPL_CACHE::SkipIndex( LINE_READER* aReader )
|
||||||
}
|
}
|
||||||
else if( exit )
|
else if( exit )
|
||||||
break;
|
break;
|
||||||
}
|
} while( aReader->ReadLine() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3871,17 +3904,20 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader )
|
||||||
{
|
{
|
||||||
MODULE* m = m_owner->LoadMODULE();
|
MODULE* m = m_owner->LoadMODULE();
|
||||||
|
|
||||||
wxString reference = m->GetReference();
|
// wxString footprintName = m->GetReference();
|
||||||
|
wxString footprintName = m->GetLibRef();
|
||||||
|
|
||||||
MODULE_CITER it = m_modules.find( reference );
|
std::pair<MODULE_ITER, bool> r = m_modules.insert( footprintName, m );
|
||||||
|
|
||||||
if( it != m_modules.end() )
|
// m's module is gone here, both on success or failure of insertion.
|
||||||
|
// no memory leak, container deleted m on failure.
|
||||||
|
|
||||||
|
if( !r.second )
|
||||||
{
|
{
|
||||||
THROW_IO_ERROR( wxString::Format(
|
THROW_IO_ERROR( wxString::Format(
|
||||||
_( "library %s has a duplicate footprint named %s" ),
|
_( "library '%s' has a duplicate footprint named '%s'" ),
|
||||||
m_lib_name.GetData(), reference.GetData() ) );
|
m_lib_name.GetData(), footprintName.GetData() ) );
|
||||||
}
|
}
|
||||||
m_modules.insert( reference, m );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( aReader->ReadLine() );
|
} while( aReader->ReadLine() );
|
||||||
|
@ -3904,7 +3940,8 @@ void FPL_CACHE::Save()
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
THROW_IO_ERROR( wxString::Format(
|
THROW_IO_ERROR( wxString::Format(
|
||||||
_( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) );
|
_( "Unable to open or create legacy library file '%s'" ),
|
||||||
|
m_lib_name.GetData() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// wxf now owns fp, will close on exception or return
|
// wxf now owns fp, will close on exception or return
|
||||||
|
@ -3915,8 +3952,15 @@ void FPL_CACHE::Save()
|
||||||
SaveModules( fp );
|
SaveModules( fp );
|
||||||
SaveEndOfFile( fp );
|
SaveEndOfFile( fp );
|
||||||
|
|
||||||
wxRemoveFile( m_lib_name );
|
wxRemove( m_lib_name ); // it is not an error if this does not exist
|
||||||
wxRenameFile( tempFileName, m_lib_name );
|
|
||||||
|
if( wxRename( tempFileName, m_lib_name ) )
|
||||||
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format(
|
||||||
|
_( "Unable to rename tempfile '%s' to to library file '%s'" ),
|
||||||
|
tempFileName.GetData(),
|
||||||
|
m_lib_name.GetData() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3924,6 +3968,11 @@ void FPL_CACHE::SaveHeader( FILE* aFile )
|
||||||
{
|
{
|
||||||
fprintf( aFile, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) );
|
fprintf( aFile, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) );
|
||||||
fprintf( aFile, "# encoding utf-8\n" );
|
fprintf( aFile, "# encoding utf-8\n" );
|
||||||
|
#if defined( USE_PCBNEW_NANOMETRES )
|
||||||
|
fprintf( aFile, "Units mm\n" );
|
||||||
|
#else
|
||||||
|
fprintf( aFile, "Units deci-mils\n" );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3942,24 +3991,32 @@ void FPL_CACHE::SaveIndex( FILE* aFile )
|
||||||
|
|
||||||
void FPL_CACHE::SaveModules( FILE* aFile )
|
void FPL_CACHE::SaveModules( FILE* aFile )
|
||||||
{
|
{
|
||||||
|
m_owner->SetFilePtr( aFile );
|
||||||
|
|
||||||
|
for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it )
|
||||||
|
{
|
||||||
|
m_owner->SaveMODULE( it->second );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
|
void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
|
||||||
{
|
{
|
||||||
if( !m_cache || m_cache->m_lib_name != aLibraryPath ||
|
if( !m_cache || m_cache->m_lib_name != aLibraryPath ||
|
||||||
|
// somebody else on a network touched the library:
|
||||||
m_cache->m_mod_time != m_cache->GetLibModificationTime() )
|
m_cache->m_mod_time != m_cache->GetLibModificationTime() )
|
||||||
{
|
{
|
||||||
// a spectacular episode in memory management.
|
// a spectacular episode in memory management:
|
||||||
delete m_cache;
|
delete m_cache;
|
||||||
m_cache = new FPL_CACHE( this, aLibraryPath );
|
m_cache = new FPL_CACHE( this, aLibraryPath );
|
||||||
|
m_cache->Load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
|
wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
wxArrayString ret;
|
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||||
|
|
||||||
init( aProperties );
|
init( aProperties );
|
||||||
|
|
||||||
|
@ -3967,6 +4024,8 @@ wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, P
|
||||||
|
|
||||||
const MODULE_MAP& mods = m_cache->m_modules;
|
const MODULE_MAP& mods = m_cache->m_modules;
|
||||||
|
|
||||||
|
wxArrayString ret;
|
||||||
|
|
||||||
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
|
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
|
||||||
{
|
{
|
||||||
ret.Add( it->first );
|
ret.Add( it->first );
|
||||||
|
@ -3979,6 +4038,8 @@ wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, P
|
||||||
MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||||
PROPERTIES* aProperties )
|
PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
|
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||||
|
|
||||||
init( aProperties );
|
init( aProperties );
|
||||||
|
|
||||||
cacheLib( aLibraryPath );
|
cacheLib( aLibraryPath );
|
||||||
|
@ -3989,8 +4050,12 @@ MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStri
|
||||||
|
|
||||||
if( it == mods.end() )
|
if( it == mods.end() )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
THROW_IO_ERROR( wxString::Format( _( "No '%s' footprint in library '%s'" ),
|
THROW_IO_ERROR( wxString::Format( _( "No '%s' footprint in library '%s'" ),
|
||||||
aFootprintName.GetData(), aLibraryPath.GetData() ) );
|
aFootprintName.GetData(), aLibraryPath.GetData() ) );
|
||||||
|
*/
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy constructor to clone the already loaded MODULE
|
// copy constructor to clone the already loaded MODULE
|
||||||
|
@ -3998,30 +4063,45 @@ MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStri
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties )
|
void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
|
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||||
|
|
||||||
init( aProperties );
|
init( aProperties );
|
||||||
|
|
||||||
cacheLib( aLibraryPath );
|
cacheLib( aLibraryPath );
|
||||||
|
|
||||||
if( !m_cache->m_writable )
|
if( !m_cache->m_writable )
|
||||||
{
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ), aLibraryPath.GetData() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString reference = aFootprint->GetReference();
|
wxString footprintName = aFootprint->GetLibRef();
|
||||||
|
|
||||||
MODULE_MAP& mods = m_cache->m_modules;
|
MODULE_MAP& mods = m_cache->m_modules;
|
||||||
|
|
||||||
// quietly overwrite any by same name.
|
// quietly overwrite any by same name.
|
||||||
MODULE_CITER it = mods.find( reference );
|
MODULE_CITER it = mods.find( footprintName );
|
||||||
if( it != mods.end() )
|
if( it != mods.end() )
|
||||||
{
|
{
|
||||||
mods.erase( reference );
|
mods.erase( footprintName );
|
||||||
}
|
}
|
||||||
|
|
||||||
aFootprint->SetParent( 0 );
|
// I need my own copy for the cache
|
||||||
|
MODULE* my_module = new MODULE( *aFootprint );
|
||||||
|
|
||||||
mods.insert( reference, aFootprint );
|
// and it's time stamp must be 0, it should have no parent, orientation should
|
||||||
|
// be zero, and it should be on the front layer.
|
||||||
|
|
||||||
|
my_module->SetTimeStamp( 0 );
|
||||||
|
my_module->SetParent( 0 );
|
||||||
|
|
||||||
|
my_module->SetOrientation( 0 );
|
||||||
|
|
||||||
|
if( my_module->GetLayer() != LAYER_N_FRONT )
|
||||||
|
my_module->Flip( my_module->GetPosition() );
|
||||||
|
|
||||||
|
mods.insert( footprintName, my_module );
|
||||||
|
|
||||||
m_cache->Save();
|
m_cache->Save();
|
||||||
}
|
}
|
||||||
|
@ -4029,12 +4109,15 @@ void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootpr
|
||||||
|
|
||||||
void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
|
void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
|
||||||
{
|
{
|
||||||
|
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||||
|
|
||||||
init( NULL );
|
init( NULL );
|
||||||
|
|
||||||
cacheLib( aLibraryPath );
|
cacheLib( aLibraryPath );
|
||||||
|
|
||||||
if( !m_cache->m_writable )
|
if( !m_cache->m_writable )
|
||||||
{
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ), aLibraryPath.GetData() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t erasedCount = m_cache->m_modules.erase( aFootprintName );
|
size_t erasedCount = m_cache->m_modules.erase( aFootprintName );
|
||||||
|
@ -4050,8 +4133,52 @@ void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LEGACY_PLUGIN::IsLibraryWritable( const wxString& aLibraryPath )
|
void LEGACY_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
|
if( wxFileExists( aLibraryPath ) )
|
||||||
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format(
|
||||||
|
_( "library '%s' already exists, will not create anew" ),
|
||||||
|
aLibraryPath.GetData() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
init( NULL );
|
||||||
|
|
||||||
|
delete m_cache;
|
||||||
|
m_cache = new FPL_CACHE( this, aLibraryPath );
|
||||||
|
m_cache->Save();
|
||||||
|
m_cache->Load(); // update m_writable and m_mod_time
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LEGACY_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
|
||||||
|
{
|
||||||
|
wxFileName fn = aLibraryPath;
|
||||||
|
|
||||||
|
if( !fn.FileExists() )
|
||||||
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format(
|
||||||
|
_( "library '%s' does not exist, cannot be deleted" ),
|
||||||
|
aLibraryPath.GetData() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
|
||||||
|
// we don't want that. we want bare metal portability with no UI here.
|
||||||
|
if( wxRemove( aLibraryPath ) )
|
||||||
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format(
|
||||||
|
_( "library '%s' cannot be deleted" ),
|
||||||
|
aLibraryPath.GetData() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEGACY_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
|
||||||
|
{
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
init( NULL );
|
init( NULL );
|
||||||
|
|
||||||
cacheLib( aLibraryPath );
|
cacheLib( aLibraryPath );
|
||||||
|
|
|
@ -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;
|
||||||
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;
|
||||||
*/
|
*/
|
||||||
class LEGACY_PLUGIN : public PLUGIN
|
class LEGACY_PLUGIN : public PLUGIN
|
||||||
{
|
{
|
||||||
|
friend struct FPL_CACHE;
|
||||||
|
|
||||||
public:
|
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:
|
||||||
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:
|
||||||
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;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <module_editor_frame.h>
|
#include <module_editor_frame.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
|
#include <legacy_plugin.h> // temporarily, for LoadMODULE()
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -45,26 +46,24 @@ static const wxString ModImportFileWildcard( _( "GPcb foot print files (*)|*" )
|
||||||
|
|
||||||
MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
{
|
{
|
||||||
char* Line;
|
// use the clipboard for this in the future?
|
||||||
FILE* file;
|
|
||||||
MODULE* module = NULL;
|
|
||||||
bool Footprint_Is_GPCB_Format = false;
|
|
||||||
|
|
||||||
wxString LastOpenedPathForLoading;
|
wxString lastOpenedPathForLoading;
|
||||||
wxConfig* Config = wxGetApp().GetSettings();
|
wxConfig* config = wxGetApp().GetSettings();
|
||||||
|
|
||||||
if( Config )
|
if( config )
|
||||||
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
|
config->Read( EXPORT_IMPORT_LASTPATH_KEY, &lastOpenedPathForLoading );
|
||||||
|
|
||||||
wxString importWildCard = ModExportFileWildcard + wxT("|") + ModImportFileWildcard;
|
wxString importWildCard = ModExportFileWildcard + wxT("|") + ModImportFileWildcard;
|
||||||
|
|
||||||
wxFileDialog dlg( this, _( "Import Footprint Module" ),
|
wxFileDialog dlg( this, _( "Import Footprint Module" ),
|
||||||
LastOpenedPathForLoading, wxEmptyString,
|
lastOpenedPathForLoading, wxEmptyString,
|
||||||
importWildCard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
importWildCard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
file = wxFopen( dlg.GetPath(), wxT( "rt" ) );
|
FILE* file = wxFopen( dlg.GetPath(), wxT( "rt" ) );
|
||||||
|
|
||||||
if( file == NULL )
|
if( file == NULL )
|
||||||
{
|
{
|
||||||
|
@ -74,28 +73,29 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( config ) // Save file path
|
||||||
|
{
|
||||||
|
lastOpenedPathForLoading = wxPathOnly( dlg.GetPath() );
|
||||||
|
config->Write( EXPORT_IMPORT_LASTPATH_KEY, lastOpenedPathForLoading );
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
FILE_LINE_READER fileReader( file, dlg.GetPath() );
|
FILE_LINE_READER fileReader( file, dlg.GetPath() );
|
||||||
|
|
||||||
FILTER_READER reader( fileReader );
|
FILTER_READER reader( fileReader );
|
||||||
|
|
||||||
if( Config ) // Save file path
|
|
||||||
{
|
|
||||||
LastOpenedPathForLoading = wxPathOnly( dlg.GetPath() );
|
|
||||||
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
|
||||||
SetLocaleTo_C_standard();
|
|
||||||
|
|
||||||
// Read header and test file type
|
// Read header and test file type
|
||||||
reader.ReadLine();
|
reader.ReadLine();
|
||||||
Line = reader.Line();
|
char* line = reader.Line();
|
||||||
|
|
||||||
if( strnicmp( Line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
|
bool footprint_Is_GPCB_Format = false;
|
||||||
|
|
||||||
|
if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
|
||||||
{
|
{
|
||||||
if( strnicmp( Line, "Element", 7 ) == 0 )
|
if( strnicmp( line, "Element", 7 ) == 0 )
|
||||||
{
|
{
|
||||||
Footprint_Is_GPCB_Format = true;
|
footprint_Is_GPCB_Format = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -105,27 +105,41 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read file: Search the description starting line (skip lib header)
|
// Read file: Search the description starting line (skip lib header)
|
||||||
if( !Footprint_Is_GPCB_Format )
|
if( !footprint_Is_GPCB_Format )
|
||||||
{
|
{
|
||||||
while( reader.ReadLine() )
|
while( reader.ReadLine() )
|
||||||
{
|
{
|
||||||
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
|
if( strnicmp( line, "$MODULE", 7 ) == 0 )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module = new MODULE( GetBoard() );
|
MODULE* module;
|
||||||
|
|
||||||
if( Footprint_Is_GPCB_Format )
|
if( footprint_Is_GPCB_Format )
|
||||||
{
|
{
|
||||||
|
// @todo GEDA plugin
|
||||||
|
module = new MODULE( GetBoard() );
|
||||||
module->Read_GPCB_Descr( dlg.GetPath() );
|
module->Read_GPCB_Descr( dlg.GetPath() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
module->ReadDescr( &reader );
|
try
|
||||||
}
|
{
|
||||||
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
|
|
||||||
SetLocaleTo_Default(); // revert to the current locale
|
LEGACY_PLUGIN* lp = (LEGACY_PLUGIN*)(PLUGIN*)pi;
|
||||||
|
|
||||||
|
lp->SetReader( &reader );
|
||||||
|
|
||||||
|
module = lp->LoadMODULE();
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Insert footprint in list
|
// Insert footprint in list
|
||||||
GetBoard()->Add( module );
|
GetBoard()->Add( module );
|
||||||
|
@ -143,9 +157,8 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
|
void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
|
||||||
{
|
{
|
||||||
wxFileName fn;
|
wxFileName fn;
|
||||||
FILE* file;
|
|
||||||
wxString msg, path, title, wildcard;
|
wxString msg, path, title, wildcard;
|
||||||
wxConfig* Config = wxGetApp().GetSettings();
|
wxConfig* config = wxGetApp().GetSettings();
|
||||||
|
|
||||||
if( aModule == NULL )
|
if( aModule == NULL )
|
||||||
return;
|
return;
|
||||||
|
@ -155,12 +168,14 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
|
||||||
|
|
||||||
if( aCreateSysLib )
|
if( aCreateSysLib )
|
||||||
path = wxGetApp().ReturnLastVisitedLibraryPath();
|
path = wxGetApp().ReturnLastVisitedLibraryPath();
|
||||||
else if( Config )
|
else if( config )
|
||||||
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path );
|
config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path );
|
||||||
|
|
||||||
fn.SetPath( path );
|
|
||||||
title = aCreateSysLib ? _( "Create New Library" ) : _( "Export Module" );
|
title = aCreateSysLib ? _( "Create New Library" ) : _( "Export Module" );
|
||||||
wildcard = aCreateSysLib ? FootprintLibFileWildcard : ModExportFileWildcard;
|
wildcard = aCreateSysLib ? FootprintLibFileWildcard : ModExportFileWildcard;
|
||||||
|
|
||||||
|
fn.SetPath( path );
|
||||||
|
|
||||||
wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(),
|
wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(),
|
||||||
wxGetTranslation( wildcard ),
|
wxGetTranslation( wildcard ),
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||||
|
@ -171,64 +186,53 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
|
||||||
fn = dlg.GetPath();
|
fn = dlg.GetPath();
|
||||||
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
|
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
|
||||||
|
|
||||||
if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL )
|
if( !aCreateSysLib && config ) // Save file path
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
|
config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
|
||||||
DisplayError( this, msg );
|
}
|
||||||
|
|
||||||
|
wxString libName = fn.GetFullPath();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// @todo : hard code this as IO_MGR::KICAD plugin, what would be the reason to "export"
|
||||||
|
// any other single footprint type, with clipboard support coming?
|
||||||
|
// Use IO_MGR::LEGACY for now, until the IO_MGR::KICAD plugin is ready.
|
||||||
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
|
|
||||||
|
pi->FootprintLibCreate( libName );
|
||||||
|
pi->FootprintSave( libName, aModule );
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !aCreateSysLib && Config ) // Save file path
|
msg.Printf( _( "Module exported in file <%s>" ), libName.GetData() );
|
||||||
{
|
|
||||||
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch the locale to standard C (needed to read/write floating point numbers like 1.3)
|
|
||||||
SetLocaleTo_C_standard();
|
|
||||||
|
|
||||||
FOOTPRINT_LIBRARY libexport( file );
|
|
||||||
libexport.WriteHeader();
|
|
||||||
libexport.m_List.Add(aModule->m_LibRef);
|
|
||||||
libexport.WriteSectionIndex();
|
|
||||||
|
|
||||||
GetBoard()->m_Modules->Save( file );
|
|
||||||
|
|
||||||
libexport.WriteEndOfFile();
|
|
||||||
fclose( file );
|
|
||||||
|
|
||||||
SetLocaleTo_Default(); // revert to the current locale
|
|
||||||
|
|
||||||
msg.Printf( _( "Module exported in file <%s>" ), GetChars( fn.GetFullPath() ) );
|
|
||||||
DisplayInfoMessage( this, msg );
|
DisplayInfoMessage( this, msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
|
void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibName )
|
||||||
{
|
{
|
||||||
wxFileName newFileName;
|
wxString footprintName = Select_1_Module_From_List( this, aLibName, wxEmptyString, wxEmptyString );
|
||||||
wxFileName oldFileName;
|
|
||||||
int LineNum = 0;
|
|
||||||
char Line[1024], Name[256];
|
|
||||||
FILE* out_file, * lib_module;
|
|
||||||
wxString CmpName, msg;
|
|
||||||
|
|
||||||
CmpName = Select_1_Module_From_List( this, aLibname, wxEmptyString, wxEmptyString );
|
if( footprintName == wxEmptyString )
|
||||||
|
|
||||||
if( CmpName == wxEmptyString )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Confirmation
|
// Confirmation
|
||||||
msg.Printf( _( "Ok to delete module %s in library %s" ),
|
wxString msg = wxString::Format( _( "Ok to delete module '%s' in library '%s'" ),
|
||||||
GetChars( CmpName ), GetChars( aLibname ) );
|
footprintName.GetData(), aLibName.GetData() );
|
||||||
|
|
||||||
if( !IsOK( this, msg ) )
|
if( !IsOK( this, msg ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PLUGIN::HOLDER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
|
|
||||||
pi->FootprintDelete( aLibname, CmpName );
|
pi->FootprintDelete( aLibName, footprintName );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( IO_ERROR ioe )
|
||||||
{
|
{
|
||||||
|
@ -236,8 +240,9 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ),
|
msg.Printf( _( "Component '%s' deleted from library '%s'" ),
|
||||||
GetChars( oldFileName.GetFullPath() ) );
|
footprintName.GetData(), aLibName.GetData() );
|
||||||
|
|
||||||
SetStatusText( msg );
|
SetStatusText( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +265,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
|
||||||
|
|
||||||
path = wxGetApp().ReturnLastVisitedLibraryPath();
|
path = wxGetApp().ReturnLastVisitedLibraryPath();
|
||||||
|
|
||||||
if( aLibName.IsEmpty() )
|
if( !aLibName )
|
||||||
{
|
{
|
||||||
wxFileDialog dlg( this, _( "Library" ), path,
|
wxFileDialog dlg( this, _( "Library" ), path,
|
||||||
wxEmptyString,
|
wxEmptyString,
|
||||||
|
@ -275,12 +280,12 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
|
||||||
|
|
||||||
wxFileName fn( fileName );
|
wxFileName fn( fileName );
|
||||||
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
|
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
|
||||||
bool file_exists = wxFileExists( fileName );
|
bool lib_exists = wxFileExists( fileName );
|
||||||
|
|
||||||
if( !aNewModulesOnly && file_exists )
|
if( !aNewModulesOnly && lib_exists )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
msg.Printf( _( "File %s exists, OK to replace ?" ), GetChars( fileName ) );
|
msg.Printf( _( "Library %s exists, OK to replace ?" ), GetChars( fileName ) );
|
||||||
|
|
||||||
if( !IsOK( this, msg ) )
|
if( !IsOK( this, msg ) )
|
||||||
return;
|
return;
|
||||||
|
@ -288,46 +293,34 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
|
||||||
|
|
||||||
m_canvas->SetAbortRequest( false );
|
m_canvas->SetAbortRequest( false );
|
||||||
|
|
||||||
// Create a new, empty library if no old lib, or if archive all modules
|
try
|
||||||
if( !aNewModulesOnly || !file_exists )
|
|
||||||
{
|
{
|
||||||
FILE* lib_module;
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
|
|
||||||
if( ( lib_module = wxFopen( fileName, wxT( "w+t" ) ) ) == NULL )
|
// Delete old library if we're replacing it entirely.
|
||||||
|
if( lib_exists && !aNewModulesOnly )
|
||||||
{
|
{
|
||||||
wxString msg;
|
pi->FootprintLibDelete( fileName );
|
||||||
msg.Printf( _( "Unable to create <%s>" ), GetChars(fileName) );
|
lib_exists = false;
|
||||||
DisplayError( this, msg );
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FOOTPRINT_LIBRARY new_lib( lib_module );
|
if( !lib_exists )
|
||||||
new_lib.WriteHeader();
|
{
|
||||||
new_lib.WriteSectionIndex();
|
pi->FootprintLibCreate( fileName );
|
||||||
new_lib.WriteEndOfFile();
|
|
||||||
fclose( lib_module );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE* module = (MODULE*) GetBoard()->m_Modules;
|
if( !aNewModulesOnly )
|
||||||
for( int ii = 1; module != NULL; ii++, module = module->Next() )
|
|
||||||
{
|
{
|
||||||
// Save footprints in default orientation (0.0) and default layer (FRONT layer)
|
for( MODULE* m = GetBoard()->m_Modules; m; m = m->Next() )
|
||||||
int orient = module->GetOrientation();
|
{
|
||||||
if ( orient != 0 )
|
pi->FootprintSave( fileName, m );
|
||||||
module->SetOrientation( 0 );
|
}
|
||||||
int layer = module->GetLayer();
|
}
|
||||||
if(layer != LAYER_N_FRONT )
|
else
|
||||||
module->Flip( module->m_Pos );
|
{
|
||||||
|
for( MODULE* m = GetBoard()->m_Modules; m; m = m->Next() )
|
||||||
bool success = Save_Module_In_Library( fileName, module,
|
{
|
||||||
aNewModulesOnly ? false : true, false );
|
if( !Save_Module_In_Library( fileName, m, false, false ) )
|
||||||
// Restore previous orientation and/or side
|
|
||||||
if(layer != module->GetLayer() )
|
|
||||||
module->Flip( module->m_Pos );
|
|
||||||
if ( orient != 0 )
|
|
||||||
module->SetOrientation( orient );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Check for request to stop backup (ESCAPE key actuated)
|
// Check for request to stop backup (ESCAPE key actuated)
|
||||||
|
@ -335,6 +328,13 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
|
bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
|
||||||
|
@ -342,202 +342,84 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
|
||||||
bool aOverwrite,
|
bool aOverwrite,
|
||||||
bool aDisplayDialog )
|
bool aDisplayDialog )
|
||||||
{
|
{
|
||||||
wxFileName oldFileName;
|
|
||||||
wxFileName newFileName;
|
|
||||||
int LineNum = 0, tmp;
|
|
||||||
char Name[256], Line[1024];
|
|
||||||
wxString Name_Cmp;
|
|
||||||
wxString msg;
|
|
||||||
FILE* lib_module, * dest;
|
|
||||||
|
|
||||||
if( aModule == NULL )
|
if( aModule == NULL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
aModule->DisplayInfo( this );
|
aModule->DisplayInfo( this );
|
||||||
|
|
||||||
newFileName = aLibName;
|
if( !wxFileExists( aLibName ) )
|
||||||
|
|
||||||
if( !newFileName.FileExists( aLibName ) )
|
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Library <%s> not found." ), GetChars( aLibName ) );
|
wxString msg = wxString::Format( _( "Library <%s> not found." ),
|
||||||
|
aLibName.GetData() );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !IsWritable( newFileName ) )
|
if( !IsWritable( aLibName ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ask for the footprint name in lib
|
// Ask what to use as the footprint name in the library
|
||||||
Name_Cmp = aModule->m_LibRef;
|
wxString footprintName = aModule->GetLibRef();
|
||||||
|
|
||||||
if( aDisplayDialog )
|
if( aDisplayDialog )
|
||||||
{
|
{
|
||||||
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
|
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save Module" ), footprintName );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return false; // canceled by user
|
return false; // canceled by user
|
||||||
|
|
||||||
Name_Cmp = dlg.GetValue();
|
footprintName = dlg.GetValue();
|
||||||
Name_Cmp.Trim( true );
|
footprintName.Trim( true );
|
||||||
Name_Cmp.Trim( false );
|
footprintName.Trim( false );
|
||||||
|
|
||||||
if( Name_Cmp.IsEmpty() )
|
if( footprintName.IsEmpty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
aModule->m_LibRef = Name_Cmp;
|
aModule->SetLibRef( footprintName );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure this footprint has a libname
|
// Ensure this footprint has a libname
|
||||||
if( Name_Cmp.IsEmpty() )
|
if( footprintName.IsEmpty() )
|
||||||
{
|
{
|
||||||
Name_Cmp = wxT("noname");
|
footprintName = wxT("noname");
|
||||||
aModule->m_LibRef = Name_Cmp;
|
aModule->SetLibRef( footprintName );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( lib_module = wxFopen( aLibName, wxT( "rt" ) ) ) == NULL )
|
MODULE* module_exists = NULL;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Unable to open <%s>" ), GetChars( aLibName ) );
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
DisplayError( this, msg );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read library file
|
module_exists = pi->FootprintLoad( aLibName, footprintName );
|
||||||
FOOTPRINT_LIBRARY input_lib( lib_module );
|
|
||||||
|
|
||||||
if( ! input_lib.IsLibrary() )
|
|
||||||
{
|
|
||||||
fclose( lib_module );
|
|
||||||
msg.Printf( _( "File <%s> is not an Eeschema library" ), GetChars( aLibName ) );
|
|
||||||
DisplayError( this, msg );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read footprints in lib: - search for an existing footprint
|
|
||||||
input_lib.RebuildIndex();
|
|
||||||
bool module_exists = input_lib.FindInList( Name_Cmp );
|
|
||||||
|
|
||||||
if( module_exists )
|
if( module_exists )
|
||||||
{
|
{
|
||||||
|
delete module_exists;
|
||||||
|
|
||||||
// an existing footprint is found in current lib
|
// an existing footprint is found in current lib
|
||||||
if( aDisplayDialog )
|
if( aDisplayDialog )
|
||||||
{
|
{
|
||||||
msg = _( "Module exists\n Line: " );
|
wxString msg = wxString::Format(
|
||||||
msg << LineNum;
|
_( "Footprint '%s' already exists in library '%s'" ),
|
||||||
|
footprintName.GetData(), aLibName.GetData() );
|
||||||
|
|
||||||
SetStatusText( msg );
|
SetStatusText( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !aOverwrite ) // Do not save the given footprint: an old one exists
|
if( !aOverwrite )
|
||||||
{
|
{
|
||||||
fclose( lib_module );
|
// Do not save the given footprint: an old one exists
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the new library
|
// this always overwrites any existing footprint
|
||||||
|
pi->FootprintSave( aLibName, aModule );
|
||||||
newFileName.SetExt( FILETMP_EXT );
|
|
||||||
|
|
||||||
if( ( dest = wxFopen( newFileName.GetFullPath(), wxT( "w+t" ) ) ) == NULL )
|
|
||||||
{
|
|
||||||
fclose( lib_module );
|
|
||||||
msg.Printf( _( "Unable to create <%s>" ), GetChars( newFileName.GetFullPath() ) );
|
|
||||||
DisplayError( this, msg );
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
wxBeginBusyCursor();
|
|
||||||
|
|
||||||
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
|
||||||
SetLocaleTo_C_standard();
|
|
||||||
|
|
||||||
FOOTPRINT_LIBRARY output_lib( dest );
|
|
||||||
output_lib.m_List = input_lib.m_List;
|
|
||||||
|
|
||||||
if( ! module_exists )
|
|
||||||
output_lib.m_List.Add( Name_Cmp );
|
|
||||||
|
|
||||||
output_lib.SortList();
|
|
||||||
|
|
||||||
// Create the library header with a new date
|
|
||||||
output_lib.WriteHeader();
|
|
||||||
output_lib.WriteSectionIndex();
|
|
||||||
|
|
||||||
LineNum = 0;
|
|
||||||
rewind( lib_module);
|
|
||||||
|
|
||||||
// Copy footprints, until the old footprint to delete
|
|
||||||
bool skip_header = true;
|
|
||||||
|
|
||||||
while( GetLine( lib_module, Line, &LineNum ) )
|
|
||||||
{
|
{
|
||||||
StrPurge( Line );
|
DisplayError( this, ioe.errorText );
|
||||||
if( strnicmp( Line, "$EndLIBRARY", 8 ) == 0 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Search for the beginning of module section:
|
|
||||||
if( skip_header )
|
|
||||||
{
|
|
||||||
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
|
|
||||||
skip_header = false;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
|
|
||||||
{
|
|
||||||
sscanf( Line + 7, " %s", Name );
|
|
||||||
msg = FROM_UTF8( Name );
|
|
||||||
|
|
||||||
if( msg.CmpNoCase( Name_Cmp ) == 0 )
|
|
||||||
{
|
|
||||||
// skip old footprint descr (delete from the lib)
|
|
||||||
while( GetLine( lib_module, Line, &LineNum ) )
|
|
||||||
{
|
|
||||||
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf( dest, "%s\n", Line );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the new footprint ( append it to the list of footprint )
|
|
||||||
tmp = aModule->GetTimeStamp();
|
|
||||||
aModule->SetTimeStamp( 0 );
|
|
||||||
aModule->Save( dest );
|
|
||||||
aModule->SetTimeStamp( tmp );
|
|
||||||
|
|
||||||
output_lib.WriteEndOfFile();
|
|
||||||
|
|
||||||
fclose( dest );
|
|
||||||
fclose( lib_module );
|
|
||||||
SetLocaleTo_Default(); // revert to the current locale
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
|
|
||||||
// The old library file is renamed .bak
|
|
||||||
oldFileName = aLibName;
|
|
||||||
oldFileName.SetExt( BACKUP_EXT );
|
|
||||||
|
|
||||||
if( oldFileName.FileExists() )
|
|
||||||
wxRemoveFile( oldFileName.GetFullPath() );
|
|
||||||
|
|
||||||
if( !wxRenameFile( aLibName, oldFileName.GetFullPath() ) )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Could not create library back up file <%s>." ),
|
|
||||||
GetChars( oldFileName.GetFullName() ) );
|
|
||||||
DisplayError( this, msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
// The new library file is renamed
|
|
||||||
if( !wxRenameFile( newFileName.GetFullPath(), aLibName ) )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Could not create temporary library file <%s>." ),
|
|
||||||
GetChars( aLibName ) );
|
|
||||||
DisplayError( this, msg );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +428,8 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
|
||||||
wxString fmt = module_exists ?
|
wxString fmt = module_exists ?
|
||||||
_( "Component [%s] replaced in <%s>" ) :
|
_( "Component [%s] replaced in <%s>" ) :
|
||||||
_( "Component [%s] added in <%s>" );
|
_( "Component [%s] added in <%s>" );
|
||||||
msg.Printf( fmt, GetChars( Name_Cmp ), GetChars( aLibName ) );
|
|
||||||
|
wxString msg = wxString::Format( fmt, footprintName.GetData(), aLibName.GetData() );
|
||||||
SetStatusText( msg );
|
SetStatusText( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,13 +530,14 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library()
|
||||||
|
|
||||||
int FOOTPRINT_EDIT_FRAME::CreateLibrary( const wxString& aLibName )
|
int FOOTPRINT_EDIT_FRAME::CreateLibrary( const wxString& aLibName )
|
||||||
{
|
{
|
||||||
FILE* lib_module;
|
|
||||||
wxString msg;
|
|
||||||
wxFileName fileName = aLibName;
|
wxFileName fileName = aLibName;
|
||||||
|
|
||||||
if( fileName.FileExists() )
|
if( fileName.FileExists() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Library <%s> already exists." ), GetChars( fileName.GetFullPath() ) );
|
wxString msg = wxString::Format(
|
||||||
|
_( "Library <%s> already exists." ),
|
||||||
|
aLibName.GetData() );
|
||||||
|
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -661,18 +545,18 @@ int FOOTPRINT_EDIT_FRAME::CreateLibrary( const wxString& aLibName )
|
||||||
if( !IsWritable( fileName ) )
|
if( !IsWritable( fileName ) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if( ( lib_module = wxFopen( fileName.GetFullPath(), wxT( "wt" ) ) ) == NULL )
|
try
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Unable to create library <%s>" ), GetChars( fileName.GetFullPath() ) );
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
DisplayError( this, msg );
|
|
||||||
return -1;
|
pi->FootprintLibCreate( aLibName );
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOOTPRINT_LIBRARY new_lib( lib_module );
|
return 1; // remember how many times we succeeded
|
||||||
new_lib.WriteHeader();
|
|
||||||
new_lib.WriteSectionIndex();
|
|
||||||
new_lib.WriteEndOfFile();
|
|
||||||
fclose( lib_module );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
||||||
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,
|
||||||
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,
|
||||||
|
|
||||||
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,
|
||||||
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,
|
||||||
|
|
||||||
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,
|
||||||
|
|
||||||
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,120 +263,105 @@ 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
file = wxFopen( tmp, wxT( "rt" ) );
|
|
||||||
|
|
||||||
if( file == NULL )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Could not open PCB footprint library file <%s>." ),
|
|
||||||
GetChars( tmp ) );
|
|
||||||
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 );
|
|
||||||
|
|
||||||
if( !curr_lib.IsLibrary() )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library file." ),
|
|
||||||
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.
|
|
||||||
if( found )
|
|
||||||
{
|
|
||||||
wxString name;
|
|
||||||
|
|
||||||
fileReader.Rewind();
|
|
||||||
|
|
||||||
while( reader.ReadLine() )
|
|
||||||
{
|
|
||||||
char* line = reader.Line();
|
|
||||||
|
|
||||||
StrPurge( line + 8 );
|
|
||||||
|
|
||||||
if( strnicmp( line, "$MODULE", 7 ) != 0 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Read module name.
|
|
||||||
name = FROM_UTF8( line + 8 );
|
|
||||||
|
|
||||||
if( name.CmpNoCase( aModuleName ) == 0 )
|
|
||||||
{
|
|
||||||
newModule = new MODULE( GetBoard() );
|
|
||||||
|
|
||||||
// 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 );
|
|
||||||
return newModule;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( one_lib )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aDisplayMessageError )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Module <%s> not found" ), GetChars( aModuleName ) );
|
|
||||||
DisplayError( NULL, msg );
|
DisplayError( NULL, msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetBoard()->Add( footprint, ADD_APPEND );
|
||||||
|
SetStatusText( wxEmptyString );
|
||||||
|
return footprint;
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
|
||||||
|
const wxString& aFootprintName, bool aDisplayError )
|
||||||
|
{
|
||||||
|
bool showed_error = false;
|
||||||
|
MODULE* footprint = NULL;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
||||||
|
{
|
||||||
|
wxFileName fn = wxFileName( wxEmptyString, g_LibraryNames[ii], FootprintLibFileExtension );
|
||||||
|
|
||||||
|
wxString libPath = wxGetApp().FindLibraryPath( fn );
|
||||||
|
|
||||||
|
if( !libPath )
|
||||||
|
{
|
||||||
|
if( aDisplayError && !showed_error )
|
||||||
|
{
|
||||||
|
wxString msg = wxString::Format(
|
||||||
|
_( "PCB footprint library file <%s> not found in search paths." ),
|
||||||
|
fn.GetFullName().GetData() );
|
||||||
|
|
||||||
|
DisplayError( this, msg );
|
||||||
|
showed_error = true;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
footprint = pi->FootprintLoad( libPath, aFootprintName );
|
||||||
|
|
||||||
|
if( footprint )
|
||||||
|
{
|
||||||
|
GetBoard()->Add( footprint, ADD_APPEND );
|
||||||
|
SetStatusText( wxEmptyString );
|
||||||
|
return footprint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !footprint )
|
||||||
|
{
|
||||||
|
if( aDisplayError )
|
||||||
|
{
|
||||||
|
wxString msg = wxString::Format(
|
||||||
|
_( "Footprint '%s' not found in any library" ),
|
||||||
|
aFootprintName.GetData() );
|
||||||
|
|
||||||
|
DisplayError( NULL, msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
|
wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
|
||||||
const wxString& aLibraryFullFilename,
|
const wxString& aLibraryFullFilename,
|
||||||
|
|
Loading…
Reference in New Issue