Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
3341669f
Commit
3341669f
authored
Apr 17, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more footprint support for LEGACY_PLUGIN
parent
a42490e0
Changes
35
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
684 additions
and
819 deletions
+684
-819
CMakeLists.txt
CMakeLists.txt
+0
-2
config.h.cmake
CMakeModules/config.h.cmake
+0
-2
CMakeLists.txt
common/CMakeLists.txt
+3
-11
class_board_item.h
include/class_board_item.h
+0
-30
wxBasePcbFrame.h
include/wxBasePcbFrame.h
+35
-9
CMakeLists.txt
pcbnew/CMakeLists.txt
+0
-1
class_board.h
pcbnew/class_board.h
+0
-2
class_board_connected_item.h
pcbnew/class_board_connected_item.h
+0
-6
class_dimension.h
pcbnew/class_dimension.h
+0
-4
class_drawsegment.h
pcbnew/class_drawsegment.h
+0
-4
class_edge_mod.h
pcbnew/class_edge_mod.h
+0
-4
class_marker_pcb.h
pcbnew/class_marker_pcb.h
+0
-7
class_mire.h
pcbnew/class_mire.h
+0
-4
class_module.cpp
pcbnew/class_module.cpp
+1
-0
class_module.h
pcbnew/class_module.h
+12
-19
class_netclass.h
pcbnew/class_netclass.h
+0
-16
class_netinfo.h
pcbnew/class_netinfo.h
+0
-12
class_pad.cpp
pcbnew/class_pad.cpp
+15
-14
class_pad.h
pcbnew/class_pad.h
+0
-6
class_pcb_text.h
pcbnew/class_pcb_text.h
+0
-5
class_text_mod.h
pcbnew/class_text_mod.h
+0
-10
class_track.h
pcbnew/class_track.h
+0
-2
class_zone.h
pcbnew/class_zone.h
+0
-10
dialog_edit_module_for_BoardEditor.cpp
pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
+2
-2
dialog_edit_module_for_Modedit.cpp
pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
+3
-2
files.cpp
pcbnew/files.cpp
+0
-93
gen_modules_placefile.cpp
pcbnew/gen_modules_placefile.cpp
+83
-75
io_mgr.cpp
pcbnew/io_mgr.cpp
+16
-2
io_mgr.h
pcbnew/io_mgr.h
+56
-18
ioascii.cpp.notused
pcbnew/ioascii.cpp.notused
+0
-0
item_io.cpp.notused
pcbnew/item_io.cpp.notused
+0
-0
legacy_plugin.cpp
pcbnew/legacy_plugin.cpp
+193
-66
legacy_plugin.h
pcbnew/legacy_plugin.h
+14
-6
librairi.cpp
pcbnew/librairi.cpp
+169
-285
loadcmp.cpp
pcbnew/loadcmp.cpp
+82
-90
No files found.
CMakeLists.txt
View file @
3341669f
...
...
@@ -23,8 +23,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option
(
USE_PCBNEW_SEXPR_FILE_FORMAT
"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
"Use nanometers for Pcbnew internal units instead of deci-mils (default OFF)."
)
...
...
CMakeModules/config.h.cmake
View file @
3341669f
...
...
@@ -55,8 +55,6 @@
#cmakedefine USE_IMAGES_IN_MENUS 1
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANOMETRES
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT
...
...
common/CMakeLists.txt
View file @
3341669f
...
...
@@ -116,21 +116,13 @@ set(PCB_COMMON_SRCS
../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.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
set_source_files_properties
(
${
PCB_COMMON_SRCS
}
PROPERTIES
...
...
include/class_board_item.h
View file @
3341669f
...
...
@@ -98,26 +98,6 @@ public:
BOARD_ITEM
*
Back
()
const
{
return
(
BOARD_ITEM
*
)
Pback
;
}
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
* returns the layer this item is on.
...
...
@@ -173,7 +153,6 @@ public:
return
false
;
// only MODULEs can be locked at this time.
}
/**
* Function UnLink
* detaches this object from its owner. This base class implementation
...
...
@@ -191,21 +170,12 @@ public:
delete
this
;
}
/**
* Function ShowShape
* converts the enum STROKE_T integer value to a wxString.
*/
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
/**
* Function Move
...
...
include/wxBasePcbFrame.h
View file @
3341669f
...
...
@@ -373,20 +373,45 @@ public:
// 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,
* 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
*
*/
MODULE
*
GetModuleLibrary
(
const
wxString
&
aLibraryFullFilename
,
const
wxString
&
aModuleName
,
bool
aDisplayMessageError
);
MODULE
*
GetModuleLibrary
(
const
wxString
&
aLibraryPath
,
const
wxString
&
aFootprintName
,
bool
aDisplayError
)
{
if
(
!
aLibraryPath
)
return
loadFootprintFromLibraries
(
aFootprintName
,
aDisplayError
);
else
return
loadFootprintFromLibrary
(
aLibraryPath
,
aFootprintName
,
aDisplayError
);
}
/**
* Function Select_1_Module_From_List
...
...
@@ -409,7 +434,8 @@ public:
/**
* 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
* in all loaded libraries
* @param aUseFootprintViewer = true to show the option
...
...
pcbnew/CMakeLists.txt
View file @
3341669f
...
...
@@ -136,7 +136,6 @@ set(PCBNEW_SRCS
hotkeys_board_editor.cpp
hotkeys_module_editor.cpp
initpcb.cpp
ioascii.cpp
layer_widget.cpp
librairi.cpp
loadcmp.cpp
...
...
pcbnew/class_board.h
View file @
3341669f
...
...
@@ -892,8 +892,6 @@ public:
/***************************************************************************/
bool
Save
(
FILE
*
aFile
)
const
;
wxString
GetClass
()
const
{
return
wxT
(
"BOARD"
);
...
...
pcbnew/class_board_connected_item.h
View file @
3341669f
...
...
@@ -135,14 +135,8 @@ public:
*/
}
bool Save( FILE* aFile ) const
{
return true;
}
//-----</ satisfy some virtual functions >-----------------------------
/**
* Function GetCount
* returns the number of BOARD_ITEMs.
...
...
pcbnew/class_dimension.h
View file @
3341669f
...
...
@@ -88,10 +88,6 @@ public:
*/
void
AdjustDimensionDetails
(
bool
aDoNotChangeText
=
false
);
bool
ReadDimensionDescr
(
LINE_READER
*
aReader
);
bool
Save
(
FILE
*
aFile
)
const
;
void
SetText
(
const
wxString
&
NewText
);
const
wxString
GetText
()
const
;
...
...
pcbnew/class_drawsegment.h
View file @
3341669f
...
...
@@ -152,10 +152,6 @@ public:
m_PolyPoints
=
aPoints
;
}
bool
Save
(
FILE
*
aFile
)
const
;
bool
ReadDrawSegmentDescr
(
LINE_READER
*
aReader
);
void
Copy
(
DRAWSEGMENT
*
source
);
void
Draw
(
EDA_DRAW_PANEL
*
panel
,
wxDC
*
DC
,
...
...
pcbnew/class_edge_mod.h
View file @
3341669f
...
...
@@ -64,10 +64,6 @@ public:
void
SetEnd0
(
const
wxPoint
&
aPoint
)
{
m_End0
=
aPoint
;
}
const
wxPoint
&
GetEnd0
()
const
{
return
m_End0
;
}
bool
Save
(
FILE
*
aFile
)
const
;
int
ReadDescr
(
LINE_READER
*
aReader
);
void
SetDrawCoord
();
/* drawing functions */
...
...
pcbnew/class_marker_pcb.h
View file @
3341669f
...
...
@@ -70,13 +70,6 @@ public:
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
;
BITMAP_DEF
GetMenuImage
()
const
{
return
drc_xpm
;
}
...
...
pcbnew/class_mire.h
View file @
3341669f
...
...
@@ -86,10 +86,6 @@ public:
void
Flip
(
const
wxPoint
&
aCentre
);
bool
Save
(
FILE
*
aFile
)
const
;
bool
ReadMirePcbDescr
(
LINE_READER
*
aReader
);
void
Copy
(
PCB_TARGET
*
source
);
void
Draw
(
EDA_DRAW_PANEL
*
panel
,
wxDC
*
DC
,
int
aDrawMode
,
...
...
pcbnew/class_module.cpp
View file @
3341669f
...
...
@@ -111,6 +111,7 @@ MODULE::MODULE( const MODULE& aModule ) :
// Copy reference and value.
m_Reference
=
new
TEXTE_MODULE
(
*
aModule
.
m_Reference
);
m_Reference
->
SetParent
(
this
);
m_Value
=
new
TEXTE_MODULE
(
*
aModule
.
m_Value
);
m_Value
->
SetParent
(
this
);
...
...
pcbnew/class_module.h
View file @
3341669f
...
...
@@ -108,16 +108,6 @@ public:
wxString
m_Doc
;
// Module Description (info for users)
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
ZoneConnection
m_ZoneConnection
;
...
...
@@ -236,14 +226,6 @@ public:
void
SetLastEditTime
(
long
aTime
)
{
m_LastEdit_Time
=
aTime
;
}
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
* reads a footprint description in GPCB format (newlib version)
...
...
@@ -358,7 +340,18 @@ public:
#if defined(DEBUG)
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
const
;
// overload
#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_
pcbnew/class_netclass.h
View file @
3341669f
...
...
@@ -198,22 +198,6 @@ public:
*/
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
* outputs the net class to \a aFormatter in s-expression form.
...
...
pcbnew/class_netinfo.h
View file @
3341669f
...
...
@@ -342,18 +342,6 @@ public:
#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
* @todo we actually could show a NET, simply show all the tracks and
...
...
pcbnew/class_pad.cpp
View file @
3341669f
...
...
@@ -332,9 +332,10 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int
clearance
=
m_LocalClearance
;
if
(
clearance
==
0
)
{
// If local clearance is 0, use the parent footprint clearance value
if
(
GetParent
()
&&
(
(
MODULE
*
)
GetParent
()
)
->
m_LocalClearance
)
clearance
=
(
(
MODULE
*
)
GetParent
()
)
->
m_LocalClearance
;
{
// If local clearance is 0, use the parent footprint clearance value
if
(
GetParent
()
&&
GetParent
()
->
GetLocalClearance
()
)
clearance
=
GetParent
()
->
GetLocalClearance
();
}
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
margin
=
m_LocalSolderMaskMargin
;
MODULE
*
module
=
(
MODULE
*
)
GetParent
();
MODULE
*
module
=
GetParent
();
if
(
module
)
{
if
(
margin
==
0
)
{
if
(
module
->
m_LocalSolderMaskMargin
)
margin
=
module
->
m_LocalSolderMaskMargin
;
if
(
module
->
GetLocalSolderMaskMargin
()
)
margin
=
module
->
GetLocalSolderMaskMargin
()
;
}
if
(
margin
==
0
)
...
...
@@ -408,26 +409,26 @@ int D_PAD::GetSolderMaskMargin()
*/
wxSize
D_PAD
::
GetSolderPasteMargin
()
{
int
margin
=
m_LocalSolderPasteMargin
;
double
mratio
=
m_LocalSolderPasteMarginRatio
;
MODULE
*
module
=
(
MODULE
*
)
GetParent
();
int
margin
=
m_LocalSolderPasteMargin
;
double
mratio
=
m_LocalSolderPasteMarginRatio
;
MODULE
*
module
=
GetParent
();
if
(
module
)
{
if
(
margin
==
0
)
margin
=
module
->
m_LocalSolderPasteMargin
;
if
(
margin
==
0
)
margin
=
module
->
GetLocalSolderPasteMargin
()
;
BOARD
*
brd
=
GetBoard
();
if
(
margin
==
0
)
if
(
margin
==
0
)
margin
=
brd
->
GetDesignSettings
().
m_SolderPasteMargin
;
if
(
mratio
==
0.0
)
mratio
=
module
->
m_LocalSolderPasteMarginRatio
;
mratio
=
module
->
GetLocalSolderPasteMarginRatio
()
;
if
(
mratio
==
0.0
)
{
mratio
=
brd
->
GetDesignSettings
().
m_SolderPasteMarginRatio
;
mratio
=
brd
->
GetDesignSettings
().
m_SolderPasteMarginRatio
;
}
}
...
...
pcbnew/class_pad.h
View file @
3341669f
...
...
@@ -267,12 +267,6 @@ public:
void
SetThermalGap
(
int
aGap
)
{
m_ThermalGap
=
aGap
;
}
int
GetThermalGap
()
const
;
/* Reading and writing data on files */
int
ReadDescr
(
LINE_READER
*
aReader
);
bool
Save
(
FILE
*
aFile
)
const
;
/* drawing functions */
void
Draw
(
EDA_DRAW_PANEL
*
aPanel
,
wxDC
*
aDC
,
int
aDrawMode
,
const
wxPoint
&
aOffset
=
ZeroOffset
);
...
...
pcbnew/class_pcb_text.h
View file @
3341669f
...
...
@@ -73,11 +73,6 @@ public:
void
Draw
(
EDA_DRAW_PANEL
*
panel
,
wxDC
*
DC
,
int
aDrawMode
,
const
wxPoint
&
offset
=
ZeroOffset
);
// File Operations:
int
ReadTextePcbDescr
(
LINE_READER
*
aReader
);
bool
Save
(
FILE
*
aFile
)
const
;
void
DisplayInfo
(
EDA_DRAW_FRAME
*
frame
);
bool
HitTest
(
const
wxPoint
&
aPosition
)
...
...
pcbnew/class_text_mod.h
View file @
3341669f
...
...
@@ -116,16 +116,6 @@ public:
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 */
void
Draw
(
EDA_DRAW_PANEL
*
panel
,
wxDC
*
DC
,
...
...
pcbnew/class_track.h
View file @
3341669f
...
...
@@ -125,8 +125,6 @@ public:
EDA_RECT
GetBoundingBox
()
const
;
bool
Save
(
FILE
*
aFile
)
const
;
/**
* Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list.
...
...
pcbnew/class_zone.h
View file @
3341669f
...
...
@@ -135,16 +135,6 @@ public:
~
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
* @return a wxPoint, position of the first point of the outline
...
...
pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
View file @
3341669f
...
...
@@ -110,8 +110,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
m_SolderMaskMarginUnits
->
SetLabel
(
GetUnitsLabel
(
g_UserUnit
)
);
m_SolderPasteMarginUnits
->
SetLabel
(
GetUnitsLabel
(
g_UserUnit
)
);
PutValueInLocalUnits
(
*
m_NetClearanceValueCtrl
,
m_CurrentModule
->
m_LocalClearance
);
PutValueInLocalUnits
(
*
m_SolderMaskMarginCtrl
,
m_CurrentModule
->
m_LocalSolderMaskMargin
);
PutValueInLocalUnits
(
*
m_NetClearanceValueCtrl
,
m_CurrentModule
->
GetLocalClearance
()
);
PutValueInLocalUnits
(
*
m_SolderMaskMarginCtrl
,
m_CurrentModule
->
GetLocalSolderMaskMargin
()
);
// These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0
...
...
pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
View file @
3341669f
...
...
@@ -149,8 +149,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
m_SolderPasteMarginUnits
->
SetLabel
(
GetUnitsLabel
(
g_UserUnit
)
);
wxString
msg
;
PutValueInLocalUnits
(
*
m_NetClearanceValueCtrl
,
m_CurrentModule
->
m_LocalClearance
);
PutValueInLocalUnits
(
*
m_SolderMaskMarginCtrl
,
m_CurrentModule
->
m_LocalSolderMaskMargin
);
PutValueInLocalUnits
(
*
m_NetClearanceValueCtrl
,
m_CurrentModule
->
GetLocalClearance
()
);
PutValueInLocalUnits
(
*
m_SolderMaskMarginCtrl
,
m_CurrentModule
->
GetLocalSolderMaskMargin
()
);
// These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
PutValueInLocalUnits
(
*
m_SolderPasteMarginCtrl
,
m_CurrentModule
->
GetLocalSolderPasteMargin
()
);
...
...
pcbnew/files.cpp
View file @
3341669f
...
...
@@ -202,70 +202,6 @@ the changes?" ) ) )
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
)
{
// Update the option toolbar
...
...
@@ -321,8 +257,6 @@ this file again." ) );
BestZoom
();
}
#endif
GetScreen
()
->
ClrModify
();
// 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
();
#if defined( USE_NEW_PCBNEW_LOAD ) || defined( USE_NEW_PCBNEW_SAVE )
if
(
pcbFileName
.
GetExt
().
IsEmpty
()
)
pcbFileName
.
SetExt
(
IO_MGR
::
GetFileExtension
(
(
IO_MGR
::
PCB_FILE_T
)
wildcardIndex
)
);
#endif
if
(
!
IsWritable
(
pcbFileName
)
)
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
()
->
SynchronizeNetsAndNetClasses
();
...
...
@@ -535,29 +465,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
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:
m_messagePanel
->
EraseMsgBox
();
...
...
pcbnew/gen_modules_placefile.cpp
View file @
3341669f
...
...
@@ -42,6 +42,7 @@
#include <class_board.h>
#include <class_module.h>
#include <class_drawsegment.h>
#include <legacy_plugin.h>
#include <pcbnew.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
)
{
MODULE
*
Module
;
D_PAD
*
pad
;
char
line
[
1024
];
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
;
const
char
*
unit_text
=
aUnitsMM
?
unit_text_mm
:
unit_text_inch
;
// Switch the locale to standard C (needed to print floating point
// numbers like 1.3)
SetLocaleTo_C_standard
();
LOCALE_IO
toggle
;
// Generate header file comments.)
sprintf
(
line
,
"## Module report - date %s
\n
"
,
TO_UTF8
(
DateAndTime
()
)
);
...
...
@@ -584,103 +582,114 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fputs
(
"$EndBOARD
\n\n
"
,
rptfile
);
Module
=
(
MODULE
*
)
GetBoard
()
->
m_Modules
;
for
(
;
Module
!=
NULL
;
Module
=
Module
->
Next
()
)
try
{
sprintf
(
line
,
"$MODULE %s
\n
"
,
EscapedUTF8
(
Module
->
m_Reference
->
m_Text
).
c_str
()
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"reference %s
\n
"
,
EscapedUTF8
(
Module
->
m_Reference
->
m_Text
).
c_str
()
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"value %s
\n
"
,
EscapedUTF8
(
Module
->
m_Value
->
m_Text
).
c_str
()
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"footprint %s
\n
"
,
EscapedUTF8
(
Module
->
m_LibRef
).
c_str
()
);
fputs
(
line
,
rptfile
);
msg
=
wxT
(
"attribut"
);
PLUGIN
::
RELEASER
pi
(
IO_MGR
::
PluginFind
(
IO_MGR
::
LEGACY
)
);
if
(
Module
->
m_Attributs
&
MOD_VIRTUAL
)
msg
+=
wxT
(
" virtual"
);
LEGACY_PLUGIN
*
legacy
=
(
LEGACY_PLUGIN
*
)
(
PLUGIN
*
)
pi
;
if
(
Module
->
m_Attributs
&
MOD_CMS
)
msg
+=
wxT
(
" smd"
);
legacy
->
SetFilePtr
(
rptfile
);
if
(
(
Module
->
m_Attributs
&
(
MOD_VIRTUAL
|
MOD_CMS
)
)
==
0
)
msg
+=
wxT
(
" none"
);
for
(
MODULE
*
Module
=
GetBoard
()
->
m_Modules
;
Module
;
Module
=
Module
->
Next
()
)
{
sprintf
(
line
,
"$MODULE %s
\n
"
,
EscapedUTF8
(
Module
->
m_Reference
->
m_Text
).
c_str
()
);
fputs
(
line
,
rptfile
);
msg
+=
wxT
(
"
\n
"
);
fputs
(
TO_UTF8
(
msg
),
rptfile
);
sprintf
(
line
,
"reference %s
\n
"
,
EscapedUTF8
(
Module
->
m_Reference
->
m_Text
).
c_str
()
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"value %s
\n
"
,
EscapedUTF8
(
Module
->
m_Value
->
m_Text
).
c_str
()
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"footprint %s
\n
"
,
EscapedUTF8
(
Module
->
m_LibRef
).
c_str
()
);
fputs
(
line
,
rptfile
);
module_pos
=
Module
->
m_Pos
;
module_pos
.
x
-=
File_Place_Offset
.
x
;
module_pos
.
y
-=
File_Place_Offset
.
y
;
msg
=
wxT
(
"attribut"
);
sprintf
(
line
,
"position %9.6f %9.6f
\n
"
,
module_pos
.
x
*
conv_unit
,
module_pos
.
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
if
(
Module
->
m_Attributs
&
MOD_VIRTUAL
)
msg
+=
wxT
(
" virtual"
);
sprintf
(
line
,
"orientation %.2f
\n
"
,
(
double
)
Module
->
m_Orient
/
10
);
if
(
Module
->
m_Attributs
&
MOD_CMS
)
msg
+=
wxT
(
" smd"
);
if
(
Module
->
GetLayer
()
==
LAYER_N_FRONT
)
strcat
(
line
,
"layer component
\n
"
);
else
if
(
Module
->
GetLayer
()
==
LAYER_N_BACK
)
strcat
(
line
,
"layer copper
\n
"
);
else
strcat
(
line
,
"layer other
\n
"
);
if
(
(
Module
->
m_Attributs
&
(
MOD_VIRTUAL
|
MOD_CMS
)
)
==
0
)
msg
+=
wxT
(
" none"
);
fputs
(
line
,
rptfile
);
msg
+=
wxT
(
"
\n
"
);
fputs
(
TO_UTF8
(
msg
),
rptfile
);
Module
->
Write_3D_Descr
(
rptfile
);
module_pos
=
Module
->
m_Pos
;
module_pos
.
x
-=
File_Place_Offset
.
x
;
module_pos
.
y
-=
File_Place_Offset
.
y
;
for
(
pad
=
Module
->
m_Pads
;
pad
!=
NULL
;
pad
=
pad
->
Next
()
)
{
fprintf
(
rptfile
,
"$PAD
\"
%s
\"\n
"
,
TO_UTF8
(
pad
->
GetPadName
()
)
);
sprintf
(
line
,
"position %9.6f %9.6f
\n
"
,
pad
->
GetPos0
()
.
x
*
conv_unit
,
pad
->
GetPos0
()
.
y
*
conv_unit
);
module_pos
.
x
*
conv_unit
,
module_pos
.
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"size %9.6f %9.6f
\n
"
,
pad
->
GetSize
().
x
*
conv_unit
,
pad
->
GetSize
().
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"orientation %.2f
\n
"
,
(
double
)
Module
->
m_Orient
/
10
);
sprintf
(
line
,
"drill %9.6f
\n
"
,
pad
->
GetDrillSize
().
x
*
conv_unit
);
fputs
(
line
,
rptfile
);
if
(
Module
->
GetLayer
()
==
LAYER_N_FRONT
)
strcat
(
line
,
"layer component
\n
"
);
else
if
(
Module
->
GetLayer
()
==
LAYER_N_BACK
)
strcat
(
line
,
"layer copper
\n
"
);
else
strcat
(
line
,
"layer other
\n
"
);
sprintf
(
line
,
"shape_offset %9.6f %9.6f
\n
"
,
pad
->
GetOffset
().
x
*
conv_unit
,
pad
->
GetOffset
().
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"orientation %.2f
\n
"
,
double
(
pad
->
GetOrientation
()
-
Module
->
GetOrientation
())
/
10
);
fputs
(
line
,
rptfile
);
legacy
->
SaveModule3D
(
Module
);
static
const
char
*
shape_name
[
6
]
=
{
"??? "
,
"Circ"
,
"Rect"
,
"Oval"
,
"trap"
,
"spec"
};
for
(
pad
=
Module
->
m_Pads
;
pad
!=
NULL
;
pad
=
pad
->
Next
()
)
{
fprintf
(
rptfile
,
"$PAD
\"
%s
\"\n
"
,
TO_UTF8
(
pad
->
GetPadName
()
)
);
sprintf
(
line
,
"position %9.6f %9.6f
\n
"
,
pad
->
GetPos0
().
x
*
conv_unit
,
pad
->
GetPos0
().
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"Shape %s
\n
"
,
shape_name
[
pad
->
GetShape
()]
);
fputs
(
line
,
rptfile
);
sprintf
(
line
,
"size %9.6f %9.6f
\n
"
,
pad
->
GetSize
().
x
*
conv_unit
,
pad
->
GetSize
().
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
int
layer
=
0
;
sprintf
(
line
,
"drill %9.6f
\n
"
,
pad
->
GetDrillSize
().
x
*
conv_unit
);
fputs
(
line
,
rptfile
);
if
(
pad
->
GetLayerMask
()
&
LAYER_BACK
)
layer
=
1
;
sprintf
(
line
,
"shape_offset %9.6f %9.6f
\n
"
,
pad
->
GetOffset
().
x
*
conv_unit
,
pad
->
GetOffset
().
y
*
conv_unit
);
fputs
(
line
,
rptfile
);
if
(
pad
->
GetLayerMask
()
&
LAYER_FRONT
)
layer
|=
2
;
sprintf
(
line
,
"orientation %.2f
\n
"
,
double
(
pad
->
GetOrientation
()
-
Module
->
GetOrientation
())
/
10
);
fputs
(
line
,
rptfile
);
static
const
char
*
layer_name
[
4
]
=
{
"??? "
,
"copper"
,
"component"
,
"all
"
};
static
const
char
*
shape_name
[
6
]
=
{
"??? "
,
"Circ"
,
"Rect"
,
"Oval"
,
"trap"
,
"spec
"
};
sprintf
(
line
,
"Layer %s
\n
"
,
layer_name
[
layer
]
);
fputs
(
line
,
rptfile
);
fprintf
(
rptfile
,
"$EndPAD
\n
"
);
}
sprintf
(
line
,
"Shape %s
\n
"
,
shape_name
[
pad
->
GetShape
()]
);
fputs
(
line
,
rptfile
);
int
layer
=
0
;
if
(
pad
->
GetLayerMask
()
&
LAYER_BACK
)
layer
=
1
;
fprintf
(
rptfile
,
"$EndMODULE %s
\n\n
"
,
TO_UTF8
(
Module
->
m_Reference
->
m_Text
)
);
if
(
pad
->
GetLayerMask
()
&
LAYER_FRONT
)
layer
|=
2
;
static
const
char
*
layer_name
[
4
]
=
{
"??? "
,
"copper"
,
"component"
,
"all"
};
sprintf
(
line
,
"Layer %s
\n
"
,
layer_name
[
layer
]
);
fputs
(
line
,
rptfile
);
fprintf
(
rptfile
,
"$EndPAD
\n
"
);
}
fprintf
(
rptfile
,
"$EndMODULE %s
\n\n
"
,
TO_UTF8
(
Module
->
m_Reference
->
m_Text
)
);
}
}
catch
(
IO_ERROR
ioe
)
{
DisplayError
(
NULL
,
ioe
.
errorText
);
}
// Write board Edges
...
...
@@ -700,7 +709,6 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
// Generate EOF.
fputs
(
"$EndDESCRIPTION
\n
"
,
rptfile
);
fclose
(
rptfile
);
SetLocaleTo_Default
(
);
// revert to the current locale
return
true
;
}
...
...
pcbnew/io_mgr.cpp
View file @
3341669f
...
...
@@ -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.
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.
THROW_IO_ERROR
(
wxString
::
Format
(
FMT_UNIMPLEMENTED
,
PluginName
().
GetData
()
,
__FUNCTION__
)
);
...
...
pcbnew/io_mgr.h
View file @
3341669f
...
...
@@ -153,7 +153,9 @@ public:
* is a base class that BOARD loading and saving plugins should derive from.
* Implementations can provide either Load() or Save() functions, or both.
* 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>
* try
...
...
@@ -188,9 +190,9 @@ public:
/**
* Function Load
* loads
a board file, or a portion of one, from some input file format
*
that this PLUGIN implementation knows about
. This may be used to load an
* entire new BOARD, or to augment an existing one if
\
a aAppendToMe is not NULL.
* loads
information from some input file format that this PLUGIN implementation
*
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.
*
* @param aFileName is the name of the file to use as input and may be foreign in
* nature or native in nature.
...
...
@@ -217,7 +219,7 @@ public:
/**
* 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
* aBoard to a special kind of export file.
*
...
...
@@ -242,7 +244,7 @@ public:
* Function FootprintEnumerate
* 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.
*
* @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
* 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.
*
* @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
* 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,
*
or footprint cannot be loade
d.
* @throw IO_ERROR if the
library cannot be found or read. No exception
*
is thrown in the case where aFootprintName cannot be foun
d.
*/
virtual
MODULE
*
FootprintLoad
(
const
wxString
&
aLibraryPath
,
const
wxString
&
aFootprintName
,
PROPERTIES
*
aProperties
=
NULL
);
/**
* Function FootprintSave
* 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
* footprint by the same name already exists, it is replaced.
* will write @a aModule to an existing library located at @a aLibraryPath.
* If a 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
* to be stored.
*
...
...
@@ -302,14 +303,14 @@ public:
*
* @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
);
/**
* Function FootprintDelete
* 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.
*
* @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
);
/**
* 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
* system libraries are read only because of where they are installed.)
*/
virtual
bool
Is
Library
Writable
(
const
wxString
&
aLibraryPath
);
virtual
bool
Is
FootprintLib
Writable
(
const
wxString
&
aLibraryPath
);
//-----</PUBLIC PLUGIN API>------------------------------------------------
...
...
pcbnew/ioascii.cpp
→
pcbnew/ioascii.cpp
.notused
View file @
3341669f
File moved
pcbnew/item_io.cpp
→
pcbnew/item_io.cpp
.notused
View file @
3341669f
File moved
pcbnew/legacy_plugin.cpp
View file @
3341669f
This diff is collapsed.
Click to expand it.
pcbnew/legacy_plugin.h
View file @
3341669f
...
...
@@ -27,6 +27,10 @@
#include <io_mgr.h>
#include <string>
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
#define FOOTPRINT_LIBRARY_HEADER_CNT 18
typedef
int
BIU
;
class
PCB_TARGET
;
...
...
@@ -44,7 +48,7 @@ class EDGE_MODULE;
class
TRACK
;
class
SEGZONE
;
class
D_PAD
;
class
FPL_CACHE
;
struct
FPL_CACHE
;
/**
...
...
@@ -54,6 +58,7 @@ class FPL_CACHE;
*/
class
LEGACY_PLUGIN
:
public
PLUGIN
{
friend
struct
FPL_CACHE
;
public
:
...
...
@@ -80,12 +85,16 @@ public:
MODULE
*
FootprintLoad
(
const
wxString
&
aLibraryPath
,
const
wxString
&
aFootprintName
,
PROPERTIES
*
aProperties
=
NULL
);
void
FootprintSave
(
const
wxString
&
aLibraryPath
,
MODULE
*
aFootprint
,
void
FootprintSave
(
const
wxString
&
aLibraryPath
,
const
MODULE
*
aFootprint
,
PROPERTIES
*
aProperties
=
NULL
);
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>---------------------------------------------
...
...
@@ -103,7 +112,8 @@ public:
void
SetFilePtr
(
FILE
*
aFile
)
{
m_fp
=
aFile
;
}
MODULE
*
LoadMODULE
();
void
SaveMODULE
(
const
MODULE
*
aModule
)
const
;
void
SaveModule3D
(
const
MODULE
*
aModule
)
const
;
protected
:
...
...
@@ -243,11 +253,9 @@ protected:
void
saveSETUP
()
const
;
void
saveBOARD
()
const
;
void
saveMODULE
(
const
MODULE
*
aModule
)
const
;
void
saveMODULE_TEXT
(
const
TEXTE_MODULE
*
aText
)
const
;
void
saveMODULE_EDGE
(
const
EDGE_MODULE
*
aGraphic
)
const
;
void
savePAD
(
const
D_PAD
*
aPad
)
const
;
void
save3D
(
const
MODULE
*
aModule
)
const
;
void
saveNETINFO_ITEM
(
const
NETINFO_ITEM
*
aNet
)
const
;
void
saveNETCLASSES
()
const
;
...
...
pcbnew/librairi.cpp
View file @
3341669f
This diff is collapsed.
Click to expand it.
pcbnew/loadcmp.cpp
View file @
3341669f
...
...
@@ -42,11 +42,11 @@
#include <class_board.h>
#include <class_module.h>
#include <io_mgr.h>
#include <pcbnew.h>
#include <module_editor_frame.h>
#include <footprint_info.h>
#include <class_footprint_library.h>
#include <dialog_get_component.h>
#include <modview_frame.h>
#include <wildcards_and_files_ext.h>
...
...
@@ -141,6 +141,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
return
fpname
;
}
MODULE
*
PCB_BASE_FRAME
::
Load_Module_From_Library
(
const
wxString
&
aLibrary
,
bool
aUseFootprintViewer
,
wxDC
*
aDC
)
...
...
@@ -148,7 +149,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
MODULE
*
module
;
wxPoint
curspos
=
GetScreen
()
->
GetCrossHairPosition
();
wxString
moduleName
,
keys
;
bool
A
llowWildSeach
=
true
;
bool
a
llowWildSeach
=
true
;
static
wxArrayString
HistoryList
;
static
wxString
lastComponentName
;
...
...
@@ -181,7 +182,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
if
(
dlg
.
IsKeyword
()
)
// Selection by keywords
{
A
llowWildSeach
=
false
;
a
llowWildSeach
=
false
;
keys
=
moduleName
;
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
(
"?"
)
)
)
||
(
moduleName
.
Contains
(
wxT
(
"*"
)
)
)
)
// Selection wild card
{
A
llowWildSeach
=
false
;
a
llowWildSeach
=
false
;
moduleName
=
Select_1_Module_From_List
(
this
,
aLibrary
,
moduleName
,
wxEmptyString
);
if
(
moduleName
.
IsEmpty
()
)
...
...
@@ -206,11 +207,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
module
=
GetModuleLibrary
(
aLibrary
,
moduleName
,
false
);
if
(
(
module
==
NULL
)
&&
A
llowWildSeach
)
// Search with wild card
if
(
!
module
&&
a
llowWildSeach
)
// Search with wild card
{
AllowWildSeach
=
false
;
allowWildSeach
=
false
;
wxString
wildname
=
wxChar
(
'*'
)
+
moduleName
+
wxChar
(
'*'
);
moduleName
=
wildname
;
moduleName
=
Select_1_Module_From_List
(
this
,
aLibrary
,
moduleName
,
wxEmptyString
);
if
(
moduleName
.
IsEmpty
()
)
...
...
@@ -233,14 +236,18 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
AddHistoryComponentName
(
HistoryList
,
moduleName
);
module
->
SetFlags
(
IS_NEW
);
module
->
m_Link
=
0
;
module
->
m_Link
=
0
;
module
->
SetTimeStamp
(
GetNewTimeStamp
()
);
GetBoard
()
->
m_Status_Pcb
=
0
;
module
->
SetPosition
(
curspos
);
// Put it on FRONT layer,
// (Can be stored on BACK layer if the lib is an archive built from a board)
if
(
module
->
GetLayer
()
!=
LAYER_N_FRONT
)
module
->
Flip
(
module
->
m_Pos
);
// Put in in orientation 0,
// even if it is not saved with with orientation 0 in lib
// (Can happen if the lib is an archive built from a board)
...
...
@@ -256,117 +263,102 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
}
MODULE
*
PCB_BASE_FRAME
::
GetModuleLibrary
(
const
wxString
&
aLibraryFullFilename
,
const
wxString
&
aModuleName
,
bool
aDisplayMessageError
)
MODULE
*
PCB_BASE_FRAME
::
loadFootprintFromLibrary
(
const
wxString
&
aLibraryPath
,
const
wxString
&
aFootprintName
,
bool
aDisplayError
)
{
wxFileName
fn
;
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
++
)
try
{
if
(
one_lib
)
fn
=
aLibraryFullFilename
;
else
fn
=
wxFileName
(
wxEmptyString
,
g_LibraryNames
[
ii
],
FootprintLibFileExtension
);
PLUGIN
::
RELEASER
pi
(
IO_MGR
::
PluginFind
(
IO_MGR
::
LEGACY
)
);
wxString
libPath
=
wxGetApp
().
FindLibraryPath
(
aLibraryPath
);
tmp
=
wxGetApp
().
FindLibraryPath
(
fn
);
MODULE
*
footprint
=
pi
->
FootprintLoad
(
libPath
,
aFootprintName
);
if
(
!
tmp
)
if
(
!
footprint
)
{
if
(
aDisplay
MessageError
&&
!
error_set
)
if
(
aDisplay
Error
)
{
msg
.
Printf
(
_
(
"PCB footprint library file <%s> not found in search paths."
),
GetChars
(
fn
.
GetFullName
()
)
);
wxMessageBox
(
msg
,
_
(
"Library Load Error"
),
wxOK
|
wxICON_ERROR
,
this
);
error_set
=
true
;
}
wxString
msg
=
wxString
::
Format
(
_
(
"Footprint '%s' not found in library '%s'"
),
aFootprintName
.
GetData
(),
libPath
.
GetData
()
);
continue
;
}
file
=
wxFopen
(
tmp
,
wxT
(
"rt"
)
);
DisplayError
(
NULL
,
msg
);
}
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
;
return
NULL
;
}
FILE_LINE_READER
fileReader
(
file
,
tmp
);
FILTER_READER
reader
(
fileReader
);
msg
.
Printf
(
_
(
"Scan Lib: %s"
),
GetChars
(
tmp
)
);
SetStatusText
(
msg
);
GetBoard
()
->
Add
(
footprint
,
ADD_APPEND
);
SetStatusText
(
wxEmptyString
);
return
footprint
;
}
catch
(
IO_ERROR
ioe
)
{
DisplayError
(
this
,
ioe
.
errorText
);
return
NULL
;
}
}
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
;
}
MODULE
*
PCB_BASE_FRAME
::
loadFootprintFromLibraries
(
const
wxString
&
aFootprintName
,
bool
aDisplayError
)
{
bool
showed_error
=
false
;
MODULE
*
footprint
=
NULL
;
// Reading the list of modules in the library.
curr_lib
.
ReadSectionIndex
();
bool
found
=
curr_lib
.
FindInList
(
aModuleName
);
try
{
PLUGIN
::
RELEASER
pi
(
IO_MGR
::
PluginFind
(
IO_MGR
::
LEGACY
)
);
// Read library.
if
(
found
)
for
(
unsigned
ii
=
0
;
ii
<
g_LibraryNames
.
GetCount
();
ii
++
)
{
wx
String
name
;
wx
FileName
fn
=
wxFileName
(
wxEmptyString
,
g_LibraryNames
[
ii
],
FootprintLibFileExtension
)
;
fileReader
.
Rewind
(
);
wxString
libPath
=
wxGetApp
().
FindLibraryPath
(
fn
);
while
(
reader
.
ReadLine
()
)
if
(
!
libPath
)
{
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
)
if
(
aDisplayError
&&
!
showed_error
)
{
newModule
=
new
MODULE
(
GetBoard
()
);
wxString
msg
=
wxString
::
Format
(
_
(
"PCB footprint library file <%s> not found in search paths."
),
fn
.
GetFullName
().
GetData
()
);
// Temporarily switch the locale to standard C (needed to print
// floating point numbers like 1.3)
LOCALE_IO
toggle
;
DisplayError
(
this
,
msg
);
showed_error
=
true
;
}
continue
;
}
newModule
->
ReadDescr
(
&
reader
);
footprint
=
pi
->
FootprintLoad
(
libPath
,
aFootprintName
);
GetBoard
()
->
Add
(
newModule
,
ADD_APPEND
);
SetStatusText
(
wxEmptyString
);
return
newModule
;
}
if
(
footprint
)
{
GetBoard
()
->
Add
(
footprint
,
ADD_APPEND
);
SetStatusText
(
wxEmptyString
);
return
footprint
;
}
}
if
(
one_lib
)
break
;
}
if
(
!
footprint
)
{
if
(
aDisplayError
)
{
wxString
msg
=
wxString
::
Format
(
_
(
"Footprint '%s' not found in any library"
),
aFootprintName
.
GetData
()
);
if
(
aDisplayMessageError
)
DisplayError
(
NULL
,
msg
);
}
return
NULL
;
}
}
catch
(
IO_ERROR
ioe
)
{
msg
.
Printf
(
_
(
"Module <%s> not found"
),
GetChars
(
aModuleName
)
);
DisplayError
(
NULL
,
msg
);
DisplayError
(
this
,
ioe
.
errorText
);
}
return
NULL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment