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
51a83a7a
Commit
51a83a7a
authored
Apr 17, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cvpcb LEGACY_PLUGIN usage factoring
parent
3341669f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
246 deletions
+119
-246
loadcmp.cpp
cvpcb/loadcmp.cpp
+26
-99
export_to_pcbnew.cpp
gerbview/export_to_pcbnew.cpp
+29
-83
class_board.h
pcbnew/class_board.h
+1
-1
legacy_plugin.cpp
pcbnew/legacy_plugin.cpp
+55
-57
legacy_plugin.h
pcbnew/legacy_plugin.h
+8
-6
No files found.
cvpcb/loadcmp.cpp
View file @
51a83a7a
...
@@ -17,8 +17,7 @@
...
@@ -17,8 +17,7 @@
#include <cvpcb.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
#include <class_DisplayFootprintsFrame.h>
#include <richio.h>
#include <io_mgr.h>
#include <filter_reader.h>
#include <wildcards_and_files_ext.h>
#include <wildcards_and_files_ext.h>
...
@@ -29,122 +28,50 @@
...
@@ -29,122 +28,50 @@
* @param CmpName - Module name
* @param CmpName - Module name
* @return - a pointer to the loaded module or NULL.
* @return - a pointer to the loaded module or NULL.
*/
*/
MODULE
*
DISPLAY_FOOTPRINTS_FRAME
::
Get_Module
(
const
wxString
&
Cmp
Name
)
MODULE
*
DISPLAY_FOOTPRINTS_FRAME
::
Get_Module
(
const
wxString
&
aFootprint
Name
)
{
{
int
Found
=
0
;
unsigned
ii
;
char
*
Line
;
char
Name
[
255
];
wxString
tmp
,
msg
;
wxFileName
fn
;
MODULE
*
Module
=
NULL
;
CVPCB_MAINFRAME
*
parent
=
(
CVPCB_MAINFRAME
*
)
GetParent
();
CVPCB_MAINFRAME
*
parent
=
(
CVPCB_MAINFRAME
*
)
GetParent
();
for
(
ii
=
0
;
ii
<
parent
->
m_ModuleLibNames
.
GetCount
();
ii
++
)
try
{
{
fn
=
parent
->
m_ModuleLibNames
[
ii
];
PLUGIN
::
RELEASER
pi
(
IO_MGR
::
PluginFind
(
IO_MGR
::
LEGACY
)
);
fn
.
SetExt
(
FootprintLibFileExtension
);
tmp
=
wxGetApp
().
FindLibraryPath
(
fn
);
if
(
!
tmp
)
for
(
unsigned
i
=
0
;
i
<
parent
->
m_ModuleLibNames
.
GetCount
();
++
i
)
{
{
msg
.
Printf
(
_
(
"PCB foot print library file <%s> could not be \
wxFileName
fn
=
parent
->
m_ModuleLibNames
[
i
];
found in the default search paths."
),
GetChars
(
fn
.
GetFullName
()
)
);
wxMessageBox
(
msg
,
titleLibLoadError
,
wxOK
|
wxICON_ERROR
,
this
);
continue
;
}
FILE
*
file
=
wxFopen
(
tmp
,
wxT
(
"rt"
)
);
fn
.
SetExt
(
FootprintLibFileExtension
);
wxString
libPath
=
wxGetApp
().
FindLibraryPath
(
fn
);
if
(
file
==
NULL
)
if
(
!
libPath
)
{
{
msg
.
Printf
(
_
(
"Could not open PCB foot print library file <%s>."
),
wxString
msg
=
wxString
::
Format
(
GetChars
(
tmp
)
);
_
(
"PCB foot print library file <%s> could not be found in the default search paths."
),
fn
.
GetFullName
().
GetData
()
);
// @todo we should not be using wxMessageBox directly.
wxMessageBox
(
msg
,
titleLibLoadError
,
wxOK
|
wxICON_ERROR
,
this
);
wxMessageBox
(
msg
,
titleLibLoadError
,
wxOK
|
wxICON_ERROR
,
this
);
continue
;
continue
;
}
}
FILE_LINE_READER
fileReader
(
file
,
tmp
);
MODULE
*
footprint
=
pi
->
FootprintLoad
(
libPath
,
aFootprintName
);
FILTER_READER
reader
(
fileReader
);
/* Read header. */
reader
.
ReadLine
();
Line
=
reader
.
Line
();
StrPurge
(
Line
);
if
(
strnicmp
(
Line
,
FOOTPRINT_LIBRARY_HEADER
,
FOOTPRINT_LIBRARY_HEADER_CNT
)
!=
0
)
if
(
footprint
)
{
{
msg
.
Printf
(
_
(
"<%s> is not a valid KiCad PCB foot print library."
),
footprint
->
SetPosition
(
wxPoint
(
0
,
0
)
);
GetChars
(
tmp
)
);
return
footprint
;
wxMessageBox
(
msg
,
titleLibLoadError
,
wxOK
|
wxICON_ERROR
,
this
);
fclose
(
file
);
return
NULL
;
}
Found
=
0
;
while
(
!
Found
&&
reader
.
ReadLine
()
)
{
Line
=
reader
.
Line
();
if
(
strncmp
(
Line
,
"$MODULE"
,
6
)
==
0
)
break
;
if
(
strnicmp
(
Line
,
"$INDEX"
,
6
)
==
0
)
{
while
(
reader
.
ReadLine
()
)
{
Line
=
reader
.
Line
();
if
(
strnicmp
(
Line
,
"$EndINDEX"
,
9
)
==
0
)
break
;
StrPurge
(
Line
);
if
(
stricmp
(
Line
,
TO_UTF8
(
CmpName
)
)
==
0
)
{
Found
=
1
;
break
;
}
}
}
}
}
}
}
catch
(
IO_ERROR
ioe
)
while
(
Found
&&
reader
.
ReadLine
()
)
{
{
Line
=
reader
.
Line
();
DisplayError
(
this
,
ioe
.
errorText
);
if
(
Line
[
0
]
!=
'$'
)
return
NULL
;
continue
;
if
(
Line
[
1
]
!=
'M'
)
continue
;
if
(
strnicmp
(
Line
,
"$MODULE"
,
7
)
!=
0
)
continue
;
/* Read component name. */
sscanf
(
Line
+
7
,
" %s"
,
Name
);
if
(
stricmp
(
Name
,
TO_UTF8
(
CmpName
)
)
==
0
)
{
Module
=
new
MODULE
(
GetBoard
()
);
// Switch the locale to standard C (needed to print floating
// point numbers like 1.3)
SetLocaleTo_C_standard
();
Module
->
ReadDescr
(
&
reader
);
SetLocaleTo_Default
();
// revert to the current locale
Module
->
SetPosition
(
wxPoint
(
0
,
0
)
);
return
Module
;
}
}
file
=
NULL
;
}
}
msg
.
Printf
(
_
(
"Module %s not found"
),
Cmp
Name
.
GetData
()
);
wxString
msg
=
wxString
::
Format
(
_
(
"Footprint '%s' not found"
),
aFootprint
Name
.
GetData
()
);
DisplayError
(
this
,
msg
);
DisplayError
(
this
,
msg
);
return
NULL
;
return
NULL
;
}
}
gerbview/export_to_pcbnew.cpp
View file @
51a83a7a
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include <../pcbnew/class_track.h>
#include <../pcbnew/class_track.h>
#include <../pcbnew/class_drawsegment.h>
#include <../pcbnew/class_drawsegment.h>
#include <io_mgr.h>
#include <gerbview.h>
#include <gerbview.h>
#include <class_board_design_settings.h>
#include <class_board_design_settings.h>
#include <class_gerber_draw_item.h>
#include <class_gerber_draw_item.h>
...
@@ -26,32 +27,35 @@
...
@@ -26,32 +27,35 @@
*/
*/
class
GBR_TO_PCB_EXPORTER
class
GBR_TO_PCB_EXPORTER
{
{
GERBVIEW_FRAME
*
m_gerbview_frame
;
// the maint gerber frame
FILE
*
m_file
;
// .brd file to write to
BOARD
*
m_pcb
;
// the board to populate and export
public
:
public
:
GBR_TO_PCB_EXPORTER
(
GERBVIEW_FRAME
*
aFrame
,
FILE
*
aFil
e
);
GBR_TO_PCB_EXPORTER
(
GERBVIEW_FRAME
*
aFrame
,
const
wxString
&
aFileNam
e
);
~
GBR_TO_PCB_EXPORTER
();
~
GBR_TO_PCB_EXPORTER
();
/**
* Function ExportPcb
* saves a board from a gerber load.
*/
bool
ExportPcb
(
int
*
LayerLookUpTable
);
bool
ExportPcb
(
int
*
LayerLookUpTable
);
BOARD
*
GetBoard
()
{
return
m_pcb
;
}
BOARD
*
GetBoard
()
{
return
m_pcb
;
}
private
:
private
:
bool
WriteSetup
(
);
// Write the SETUP section data file
bool
WriteGeneralDescrPcb
(
);
void
export_non_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_non_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_flashed_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_flashed_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_segline_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_segline_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_segarc_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
export_segarc_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
);
void
cleanBoard
();
void
cleanBoard
();
GERBVIEW_FRAME
*
m_gerbview_frame
;
// the maint gerber frame
wxString
m_file_name
;
// BOARD file to write to
BOARD
*
m_pcb
;
// the board to populate and export
};
};
GBR_TO_PCB_EXPORTER
::
GBR_TO_PCB_EXPORTER
(
GERBVIEW_FRAME
*
aFrame
,
FILE
*
aFil
e
)
GBR_TO_PCB_EXPORTER
::
GBR_TO_PCB_EXPORTER
(
GERBVIEW_FRAME
*
aFrame
,
const
wxString
&
aFileNam
e
)
{
{
m_gerbview_frame
=
aFrame
;
m_gerbview_frame
=
aFrame
;
m_file
=
aFil
e
;
m_file
_name
=
aFileNam
e
;
m_pcb
=
new
BOARD
();
m_pcb
=
new
BOARD
();
}
}
...
@@ -84,12 +88,12 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
...
@@ -84,12 +88,12 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
return
;
return
;
}
}
wxString
FullF
ileName
,
msg
;
wxString
f
ileName
,
msg
;
wxString
PcbExt
(
wxT
(
".brd"
)
);
wxString
PcbExt
(
wxT
(
".brd"
)
);
msg
=
wxT
(
"*"
)
+
PcbExt
;
msg
=
wxT
(
"*"
)
+
PcbExt
;
FullF
ileName
=
EDA_FileSelector
(
_
(
"Board file name:"
),
f
ileName
=
EDA_FileSelector
(
_
(
"Board file name:"
),
wxEmptyString
,
wxEmptyString
,
wxEmptyString
,
wxEmptyString
,
PcbExt
,
PcbExt
,
...
@@ -98,7 +102,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
...
@@ -98,7 +102,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
wxFD_SAVE
,
wxFD_SAVE
,
false
false
);
);
if
(
FullF
ileName
==
wxEmptyString
)
if
(
f
ileName
==
wxEmptyString
)
return
;
return
;
/* Install a dialog frame to choose the mapping
/* Install a dialog frame to choose the mapping
...
@@ -111,24 +115,15 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
...
@@ -111,24 +115,15 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
if
(
ok
!=
wxID_OK
)
if
(
ok
!=
wxID_OK
)
return
;
return
;
if
(
wxFileExists
(
FullF
ileName
)
)
if
(
wxFileExists
(
f
ileName
)
)
{
{
if
(
!
IsOK
(
this
,
_
(
"Ok to change the existing file ?"
)
)
)
if
(
!
IsOK
(
this
,
_
(
"Ok to change the existing file ?"
)
)
)
return
;
return
;
}
}
FILE
*
file
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
);
GBR_TO_PCB_EXPORTER
gbr_exporter
(
this
,
fileName
);
if
(
file
==
NULL
)
{
msg
=
_
(
"Unable to create "
)
+
FullFileName
;
DisplayError
(
this
,
msg
);
return
;
}
GBR_TO_PCB_EXPORTER
gbr_exporter
(
this
,
file
);
gbr_exporter
.
ExportPcb
(
dlg
->
GetLayersLookUpTable
()
);
gbr_exporter
.
ExportPcb
(
dlg
->
GetLayersLookUpTable
()
);
fclose
(
file
);
}
}
...
@@ -162,54 +157,6 @@ void GBR_TO_PCB_EXPORTER::cleanBoard()
...
@@ -162,54 +157,6 @@ void GBR_TO_PCB_EXPORTER::cleanBoard()
}
}
bool
GBR_TO_PCB_EXPORTER
::
WriteSetup
(
)
{
fprintf
(
m_file
,
"$SETUP
\n
"
);
fprintf
(
m_file
,
"InternalUnit %f INCH
\n
"
,
1.0
/
PCB_INTERNAL_UNIT
);
fprintf
(
m_file
,
"Layers %d
\n
"
,
m_pcb
->
GetCopperLayerCount
()
);
fprintf
(
m_file
,
"$EndSETUP
\n\n
"
);
return
true
;
}
bool
GBR_TO_PCB_EXPORTER
::
WriteGeneralDescrPcb
(
)
{
int
nbLayers
;
// Print the copper layer count
nbLayers
=
m_pcb
->
GetCopperLayerCount
();
if
(
nbLayers
<=
1
)
// Minimal layers count in Pcbnew is 2
{
nbLayers
=
2
;
m_pcb
->
SetCopperLayerCount
(
2
);
}
fprintf
(
m_file
,
"$GENERAL
\n
"
);
fprintf
(
m_file
,
"encoding utf-8
\n
"
);
fprintf
(
m_file
,
"LayerCount %d
\n
"
,
nbLayers
);
// Compute and print the board bounding box
EDA_RECT
bbbox
=
m_pcb
->
ComputeBoundingBox
();
fprintf
(
m_file
,
"Di %d %d %d %d
\n
"
,
bbbox
.
GetX
(),
bbbox
.
GetY
(),
bbbox
.
GetRight
(),
bbbox
.
GetBottom
()
);
fprintf
(
m_file
,
"$EndGENERAL
\n\n
"
);
return
true
;
}
/* Routine to save the board
* @param frame = pointer to the main frame
* @param File = FILE * pointer to an already opened file
* @param LayerLookUpTable = look up table: Pcbnew layer for each gerber layer
* @return 1 if OK, 0 if fail
*/
bool
GBR_TO_PCB_EXPORTER
::
ExportPcb
(
int
*
LayerLookUpTable
)
bool
GBR_TO_PCB_EXPORTER
::
ExportPcb
(
int
*
LayerLookUpTable
)
{
{
BOARD
*
gerberPcb
=
m_gerbview_frame
->
GetBoard
();
BOARD
*
gerberPcb
=
m_gerbview_frame
->
GetBoard
();
...
@@ -235,22 +182,21 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
...
@@ -235,22 +182,21 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
cleanBoard
();
cleanBoard
();
m_pcb
->
SetCopperLayerCount
(
LayerLookUpTable
[
32
]
);
m_pcb
->
SetCopperLayerCount
(
LayerLookUpTable
[
32
]
);
// Switch the locale to standard C (needed to print floating point numbers)
try
SetLocaleTo_C_standard
();
{
PLUGIN
::
RELEASER
pi
(
IO_MGR
::
PluginFind
(
IO_MGR
::
LEGACY
)
);
// write PCB header
pi
->
Save
(
m_file_name
,
m_pcb
);
fprintf
(
m_file
,
"PCBNEW-BOARD Version %d date %s
\n\n
"
,
LEGACY_BOARD_FILE_VERSION
,
}
TO_UTF8
(
DateAndTime
()
)
);
catch
(
IO_ERROR
ioe
)
WriteGeneralDescrPcb
(
);
{
WriteSetup
(
);
DisplayError
(
m_gerbview_frame
,
ioe
.
errorText
);
return
false
;
// write items on file
}
m_pcb
->
Save
(
m_file
);
SetLocaleTo_Default
();
// revert to the current locale
return
true
;
return
true
;
}
}
void
GBR_TO_PCB_EXPORTER
::
export_non_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
)
void
GBR_TO_PCB_EXPORTER
::
export_non_copper_item
(
GERBER_DRAW_ITEM
*
aGbrItem
,
int
aLayer
)
{
{
DRAWSEGMENT
*
drawitem
=
new
DRAWSEGMENT
(
m_pcb
,
PCB_LINE_T
);
DRAWSEGMENT
*
drawitem
=
new
DRAWSEGMENT
(
m_pcb
,
PCB_LINE_T
);
...
...
pcbnew/class_board.h
View file @
51a83a7a
...
@@ -848,7 +848,7 @@ public:
...
@@ -848,7 +848,7 @@ public:
* ( using the default netclass value or a preset value )
* ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0]
* the default netclass is always in m_TrackWidthList[0]
*/
*/
int
GetCurrentTrackWidth
()
int
GetCurrentTrackWidth
()
const
{
{
return
m_TrackWidthList
[
m_TrackWidthSelector
];
return
m_TrackWidthList
[
m_TrackWidthSelector
];
}
}
...
...
pcbnew/legacy_plugin.cpp
View file @
51a83a7a
...
@@ -2710,8 +2710,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
...
@@ -2710,8 +2710,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
init
(
aProperties
);
init
(
aProperties
);
m_board
=
aBoard
;
FILE
*
fp
=
wxFopen
(
aFileName
,
wxT
(
"w"
)
);
FILE
*
fp
=
wxFopen
(
aFileName
,
wxT
(
"w"
)
);
if
(
!
fp
)
if
(
!
fp
)
{
{
...
@@ -2728,12 +2726,13 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
...
@@ -2728,12 +2726,13 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
if
(
m_props
)
if
(
m_props
)
{
{
// @todo move the header production into this source file.
wxString
header
=
(
*
m_props
)[
"header"
];
wxString
header
=
(
*
m_props
)[
"header"
];
// save a file header, if caller provided one (with trailing \n hopefully).
// save a file header, if caller provided one (with trailing \n hopefully).
fprintf
(
m_fp
,
"%s"
,
TO_UTF8
(
header
)
);
fprintf
(
m_fp
,
"%s"
,
TO_UTF8
(
header
)
);
}
}
saveAllSections
(
);
SaveBOARD
(
aBoard
);
}
}
...
@@ -2751,19 +2750,19 @@ do { \
...
@@ -2751,19 +2750,19 @@ do { \
} while(0)
} while(0)
void
LEGACY_PLUGIN
::
saveAllSections
(
)
const
void
LEGACY_PLUGIN
::
SaveBOARD
(
const
BOARD
*
aBoard
)
const
{
{
saveGENERAL
();
saveGENERAL
(
aBoard
);
saveSHEET
();
saveSHEET
(
aBoard
);
saveSETUP
();
saveSETUP
(
aBoard
);
saveBOARD
(
);
saveBOARD
_ITEMS
(
aBoard
);
}
}
void
LEGACY_PLUGIN
::
saveGENERAL
()
const
void
LEGACY_PLUGIN
::
saveGENERAL
(
const
BOARD
*
aBoard
)
const
{
{
fprintf
(
m_fp
,
"$GENERAL
\n
"
);
fprintf
(
m_fp
,
"$GENERAL
\n
"
);
fprintf
(
m_fp
,
"encoding utf-8
\n
"
);
fprintf
(
m_fp
,
"encoding utf-8
\n
"
);
...
@@ -2776,7 +2775,7 @@ void LEGACY_PLUGIN::saveGENERAL() const
...
@@ -2776,7 +2775,7 @@ void LEGACY_PLUGIN::saveGENERAL() const
#endif
#endif
// Write copper layer count
// Write copper layer count
fprintf
(
m_fp
,
"LayerCount %d
\n
"
,
m_b
oard
->
GetCopperLayerCount
()
);
fprintf
(
m_fp
,
"LayerCount %d
\n
"
,
aB
oard
->
GetCopperLayerCount
()
);
/* No, EnabledLayers has this information, plus g_TabAllCopperLayerMask is
/* No, EnabledLayers has this information, plus g_TabAllCopperLayerMask is
global and globals are not allowed in a plugin.
global and globals are not allowed in a plugin.
...
@@ -2785,34 +2784,35 @@ void LEGACY_PLUGIN::saveGENERAL() const
...
@@ -2785,34 +2784,35 @@ void LEGACY_PLUGIN::saveGENERAL() const
g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
*/
*/
fprintf
(
m_fp
,
"EnabledLayers %08X
\n
"
,
m_b
oard
->
GetEnabledLayers
()
);
fprintf
(
m_fp
,
"EnabledLayers %08X
\n
"
,
aB
oard
->
GetEnabledLayers
()
);
if
(
m_board
->
GetEnabledLayers
()
!=
m_b
oard
->
GetVisibleLayers
()
)
if
(
aBoard
->
GetEnabledLayers
()
!=
aB
oard
->
GetVisibleLayers
()
)
fprintf
(
m_fp
,
"VisibleLayers %08X
\n
"
,
m_b
oard
->
GetVisibleLayers
()
);
fprintf
(
m_fp
,
"VisibleLayers %08X
\n
"
,
aB
oard
->
GetVisibleLayers
()
);
fprintf
(
m_fp
,
"Links %d
\n
"
,
m_b
oard
->
GetRatsnestsCount
()
);
fprintf
(
m_fp
,
"Links %d
\n
"
,
aB
oard
->
GetRatsnestsCount
()
);
fprintf
(
m_fp
,
"NoConn %d
\n
"
,
m_b
oard
->
m_NbNoconnect
);
fprintf
(
m_fp
,
"NoConn %d
\n
"
,
aB
oard
->
m_NbNoconnect
);
// Write Bounding box info
// Write Bounding box info
EDA_RECT
bbbox
=
m_board
->
ComputeBoundingBox
();
EDA_RECT
bbbox
=
((
BOARD
*
)
aBoard
)
->
ComputeBoundingBox
();
fprintf
(
m_fp
,
"Di %s %s
\n
"
,
fprintf
(
m_fp
,
"Di %s %s
\n
"
,
fmtBIUPair
(
bbbox
.
GetX
(),
bbbox
.
GetY
()
).
c_str
(),
fmtBIUPair
(
bbbox
.
GetX
(),
bbbox
.
GetY
()
).
c_str
(),
fmtBIUPair
(
bbbox
.
GetRight
(),
bbbox
.
GetBottom
()
).
c_str
()
);
fmtBIUPair
(
bbbox
.
GetRight
(),
bbbox
.
GetBottom
()
).
c_str
()
);
fprintf
(
m_fp
,
"Ndraw %d
\n
"
,
m_b
oard
->
m_Drawings
.
GetCount
()
);
fprintf
(
m_fp
,
"Ndraw %d
\n
"
,
aB
oard
->
m_Drawings
.
GetCount
()
);
fprintf
(
m_fp
,
"Ntrack %d
\n
"
,
m_b
oard
->
GetNumSegmTrack
()
);
fprintf
(
m_fp
,
"Ntrack %d
\n
"
,
aB
oard
->
GetNumSegmTrack
()
);
fprintf
(
m_fp
,
"Nzone %d
\n
"
,
m_b
oard
->
GetNumSegmZone
()
);
fprintf
(
m_fp
,
"Nzone %d
\n
"
,
aB
oard
->
GetNumSegmZone
()
);
fprintf
(
m_fp
,
"BoardThickness %s
\n
"
,
fmtBIU
(
m_b
oard
->
GetDesignSettings
().
m_BoardThickness
).
c_str
()
);
fprintf
(
m_fp
,
"BoardThickness %s
\n
"
,
fmtBIU
(
aB
oard
->
GetDesignSettings
().
m_BoardThickness
).
c_str
()
);
fprintf
(
m_fp
,
"Nmodule %d
\n
"
,
m_b
oard
->
m_Modules
.
GetCount
()
);
fprintf
(
m_fp
,
"Nmodule %d
\n
"
,
aB
oard
->
m_Modules
.
GetCount
()
);
fprintf
(
m_fp
,
"Nnets %d
\n
"
,
m_b
oard
->
GetNetCount
()
);
fprintf
(
m_fp
,
"Nnets %d
\n
"
,
aB
oard
->
GetNetCount
()
);
fprintf
(
m_fp
,
"$EndGENERAL
\n\n
"
);
fprintf
(
m_fp
,
"$EndGENERAL
\n\n
"
);
}
}
void
LEGACY_PLUGIN
::
saveSHEET
()
const
void
LEGACY_PLUGIN
::
saveSHEET
(
const
BOARD
*
aBoard
)
const
{
{
const
PAGE_INFO
&
pageInfo
=
m_b
oard
->
GetPageSettings
();
const
PAGE_INFO
&
pageInfo
=
aB
oard
->
GetPageSettings
();
const
TITLE_BLOCK
&
tb
=
m_board
->
GetTitleBlock
();
const
TITLE_BLOCK
&
tb
=
((
BOARD
*
)
aBoard
)
->
GetTitleBlock
();
fprintf
(
m_fp
,
"$SHEETDESCR
\n
"
);
fprintf
(
m_fp
,
"$SHEETDESCR
\n
"
);
...
@@ -2837,10 +2837,10 @@ void LEGACY_PLUGIN::saveSHEET() const
...
@@ -2837,10 +2837,10 @@ void LEGACY_PLUGIN::saveSHEET() const
}
}
void
LEGACY_PLUGIN
::
saveSETUP
()
const
void
LEGACY_PLUGIN
::
saveSETUP
(
const
BOARD
*
aBoard
)
const
{
{
NETCLASS
*
netclass_default
=
m_b
oard
->
m_NetClasses
.
GetDefault
();
NETCLASS
*
netclass_default
=
aB
oard
->
m_NetClasses
.
GetDefault
();
const
BOARD_DESIGN_SETTINGS
&
bds
=
m_b
oard
->
GetDesignSettings
();
const
BOARD_DESIGN_SETTINGS
&
bds
=
aB
oard
->
GetDesignSettings
();
fprintf
(
m_fp
,
"$SETUP
\n
"
);
fprintf
(
m_fp
,
"$SETUP
\n
"
);
...
@@ -2849,32 +2849,32 @@ void LEGACY_PLUGIN::saveSETUP() const
...
@@ -2849,32 +2849,32 @@ void LEGACY_PLUGIN::saveSETUP() const
fprintf( m_fp,, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( m_fp,, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
*/
*/
fprintf
(
m_fp
,
"Layers %d
\n
"
,
m_b
oard
->
GetCopperLayerCount
()
);
fprintf
(
m_fp
,
"Layers %d
\n
"
,
aB
oard
->
GetCopperLayerCount
()
);
unsigned
layerMask
=
ALL_CU_LAYERS
&
m_b
oard
->
GetEnabledLayers
();
unsigned
layerMask
=
ALL_CU_LAYERS
&
aB
oard
->
GetEnabledLayers
();
for
(
int
layer
=
0
;
layerMask
;
++
layer
,
layerMask
>>=
1
)
for
(
int
layer
=
0
;
layerMask
;
++
layer
,
layerMask
>>=
1
)
{
{
if
(
layerMask
&
1
)
if
(
layerMask
&
1
)
{
{
fprintf
(
m_fp
,
"Layer[%d] %s %s
\n
"
,
layer
,
fprintf
(
m_fp
,
"Layer[%d] %s %s
\n
"
,
layer
,
TO_UTF8
(
m_b
oard
->
GetLayerName
(
layer
)
),
TO_UTF8
(
aB
oard
->
GetLayerName
(
layer
)
),
LAYER
::
ShowType
(
m_b
oard
->
GetLayerType
(
layer
)
)
);
LAYER
::
ShowType
(
aB
oard
->
GetLayerType
(
layer
)
)
);
}
}
}
}
// Save current default track width, for compatibility with older Pcbnew version;
// Save current default track width, for compatibility with older Pcbnew version;
fprintf
(
m_fp
,
"TrackWidth %s
\n
"
,
fmtBIU
(
m_b
oard
->
GetCurrentTrackWidth
()
).
c_str
()
);
fprintf
(
m_fp
,
"TrackWidth %s
\n
"
,
fmtBIU
(
aB
oard
->
GetCurrentTrackWidth
()
).
c_str
()
);
// Save custom tracks width list (the first is not saved here: this is the netclass value
// Save custom tracks width list (the first is not saved here: this is the netclass value
for
(
unsigned
ii
=
1
;
ii
<
m_b
oard
->
m_TrackWidthList
.
size
();
ii
++
)
for
(
unsigned
ii
=
1
;
ii
<
aB
oard
->
m_TrackWidthList
.
size
();
ii
++
)
fprintf
(
m_fp
,
"TrackWidthList %s
\n
"
,
fmtBIU
(
m_b
oard
->
m_TrackWidthList
[
ii
]
).
c_str
()
);
fprintf
(
m_fp
,
"TrackWidthList %s
\n
"
,
fmtBIU
(
aB
oard
->
m_TrackWidthList
[
ii
]
).
c_str
()
);
fprintf
(
m_fp
,
"TrackClearence %s
\n
"
,
fmtBIU
(
netclass_default
->
GetClearance
()
).
c_str
()
);
fprintf
(
m_fp
,
"TrackClearence %s
\n
"
,
fmtBIU
(
netclass_default
->
GetClearance
()
).
c_str
()
);
// ZONE_SETTINGS
// ZONE_SETTINGS
fprintf
(
m_fp
,
"ZoneClearence %s
\n
"
,
fmtBIU
(
m_b
oard
->
GetZoneSettings
().
m_ZoneClearance
).
c_str
()
);
fprintf
(
m_fp
,
"ZoneClearence %s
\n
"
,
fmtBIU
(
aB
oard
->
GetZoneSettings
().
m_ZoneClearance
).
c_str
()
);
fprintf
(
m_fp
,
"Zone_45_Only %d
\n
"
,
m_b
oard
->
GetZoneSettings
().
m_Zone_45_Only
);
fprintf
(
m_fp
,
"Zone_45_Only %d
\n
"
,
aB
oard
->
GetZoneSettings
().
m_Zone_45_Only
);
fprintf
(
m_fp
,
"TrackMinWidth %s
\n
"
,
fmtBIU
(
bds
.
m_TrackMinWidth
).
c_str
()
);
fprintf
(
m_fp
,
"TrackMinWidth %s
\n
"
,
fmtBIU
(
bds
.
m_TrackMinWidth
).
c_str
()
);
...
@@ -2889,10 +2889,10 @@ void LEGACY_PLUGIN::saveSETUP() const
...
@@ -2889,10 +2889,10 @@ void LEGACY_PLUGIN::saveSETUP() const
// Save custom vias diameters list (the first is not saved here: this is
// Save custom vias diameters list (the first is not saved here: this is
// the netclass value
// the netclass value
for
(
unsigned
ii
=
1
;
ii
<
m_b
oard
->
m_ViasDimensionsList
.
size
();
ii
++
)
for
(
unsigned
ii
=
1
;
ii
<
aB
oard
->
m_ViasDimensionsList
.
size
();
ii
++
)
fprintf
(
m_fp
,
"ViaSizeList %s %s
\n
"
,
fprintf
(
m_fp
,
"ViaSizeList %s %s
\n
"
,
fmtBIU
(
m_b
oard
->
m_ViasDimensionsList
[
ii
].
m_Diameter
).
c_str
(),
fmtBIU
(
aB
oard
->
m_ViasDimensionsList
[
ii
].
m_Diameter
).
c_str
(),
fmtBIU
(
m_b
oard
->
m_ViasDimensionsList
[
ii
].
m_Drill
).
c_str
()
);
fmtBIU
(
aB
oard
->
m_ViasDimensionsList
[
ii
].
m_Drill
).
c_str
()
);
// for old versions compatibility:
// for old versions compatibility:
fprintf
(
m_fp
,
"MicroViaSize %s
\n
"
,
fmtBIU
(
netclass_default
->
GetuViaDiameter
()
).
c_str
()
);
fprintf
(
m_fp
,
"MicroViaSize %s
\n
"
,
fmtBIU
(
netclass_default
->
GetuViaDiameter
()
).
c_str
()
);
...
@@ -2926,14 +2926,14 @@ void LEGACY_PLUGIN::saveSETUP() const
...
@@ -2926,14 +2926,14 @@ void LEGACY_PLUGIN::saveSETUP() const
}
}
*/
*/
fprintf
(
m_fp
,
"AuxiliaryAxisOrg %s
\n
"
,
fmtBIUPoint
(
m_b
oard
->
GetOriginAxisPosition
()
).
c_str
()
);
fprintf
(
m_fp
,
"AuxiliaryAxisOrg %s
\n
"
,
fmtBIUPoint
(
aB
oard
->
GetOriginAxisPosition
()
).
c_str
()
);
fprintf
(
m_fp
,
"VisibleElements %X
\n
"
,
bds
.
GetVisibleElements
()
);
fprintf
(
m_fp
,
"VisibleElements %X
\n
"
,
bds
.
GetVisibleElements
()
);
{
{
STRING_FORMATTER
sf
;
STRING_FORMATTER
sf
;
m_b
oard
->
GetPlotOptions
().
Format
(
&
sf
,
0
);
aB
oard
->
GetPlotOptions
().
Format
(
&
sf
,
0
);
wxString
record
=
FROM_UTF8
(
sf
.
GetString
().
c_str
()
);
wxString
record
=
FROM_UTF8
(
sf
.
GetString
().
c_str
()
);
...
@@ -2947,22 +2947,22 @@ void LEGACY_PLUGIN::saveSETUP() const
...
@@ -2947,22 +2947,22 @@ void LEGACY_PLUGIN::saveSETUP() const
}
}
void
LEGACY_PLUGIN
::
saveBOARD
(
)
const
void
LEGACY_PLUGIN
::
saveBOARD
_ITEMS
(
const
BOARD
*
aBoard
)
const
{
{
// save the nets
// save the nets
int
netcount
=
m_b
oard
->
GetNetCount
();
int
netcount
=
aB
oard
->
GetNetCount
();
for
(
int
i
=
0
;
i
<
netcount
;
++
i
)
for
(
int
i
=
0
;
i
<
netcount
;
++
i
)
saveNETINFO_ITEM
(
m_b
oard
->
FindNet
(
i
)
);
saveNETINFO_ITEM
(
aB
oard
->
FindNet
(
i
)
);
// Saved nets do not include netclass names, so save netclasses after nets.
// Saved nets do not include netclass names, so save netclasses after nets.
saveNETCLASSES
();
saveNETCLASSES
(
&
aBoard
->
m_NetClasses
);
// save the modules
// save the modules
for
(
MODULE
*
m
=
m_b
oard
->
m_Modules
;
m
;
m
=
(
MODULE
*
)
m
->
Next
()
)
for
(
MODULE
*
m
=
aB
oard
->
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_b
oard
->
m_Drawings
;
gr
;
gr
=
gr
->
Next
()
)
for
(
BOARD_ITEM
*
gr
=
aB
oard
->
m_Drawings
;
gr
;
gr
=
gr
->
Next
()
)
{
{
switch
(
gr
->
Type
()
)
switch
(
gr
->
Type
()
)
{
{
...
@@ -2987,19 +2987,19 @@ void LEGACY_PLUGIN::saveBOARD() const
...
@@ -2987,19 +2987,19 @@ void LEGACY_PLUGIN::saveBOARD() const
// save the tracks & vias
// save the tracks & vias
fprintf
(
m_fp
,
"$TRACK
\n
"
);
fprintf
(
m_fp
,
"$TRACK
\n
"
);
for
(
TRACK
*
track
=
m_b
oard
->
m_Track
;
track
;
track
=
track
->
Next
()
)
for
(
TRACK
*
track
=
aB
oard
->
m_Track
;
track
;
track
=
track
->
Next
()
)
saveTRACK
(
track
);
saveTRACK
(
track
);
fprintf
(
m_fp
,
"$EndTRACK
\n
"
);
fprintf
(
m_fp
,
"$EndTRACK
\n
"
);
// save the old obsolete zones which were done by segments (tracks)
// save the old obsolete zones which were done by segments (tracks)
fprintf
(
m_fp
,
"$ZONE
\n
"
);
fprintf
(
m_fp
,
"$ZONE
\n
"
);
for
(
SEGZONE
*
zone
=
m_b
oard
->
m_Zone
;
zone
;
zone
=
zone
->
Next
()
)
for
(
SEGZONE
*
zone
=
aB
oard
->
m_Zone
;
zone
;
zone
=
zone
->
Next
()
)
saveTRACK
(
zone
);
saveTRACK
(
zone
);
fprintf
(
m_fp
,
"$EndZONE
\n
"
);
fprintf
(
m_fp
,
"$EndZONE
\n
"
);
// save the polygon (which are the newer technology) zones
// save the polygon (which are the newer technology) zones
for
(
int
i
=
0
;
i
<
m_b
oard
->
GetAreaCount
();
++
i
)
for
(
int
i
=
0
;
i
<
aB
oard
->
GetAreaCount
();
++
i
)
saveZONE_CONTAINER
(
m_b
oard
->
GetArea
(
i
)
);
saveZONE_CONTAINER
(
aB
oard
->
GetArea
(
i
)
);
fprintf
(
m_fp
,
"$EndBOARD
\n
"
);
fprintf
(
m_fp
,
"$EndBOARD
\n
"
);
...
@@ -3018,15 +3018,13 @@ void LEGACY_PLUGIN::saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const
...
@@ -3018,15 +3018,13 @@ void LEGACY_PLUGIN::saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const
}
}
void
LEGACY_PLUGIN
::
saveNETCLASSES
()
const
void
LEGACY_PLUGIN
::
saveNETCLASSES
(
const
NETCLASSES
*
aNetClasses
)
const
{
{
const
NETCLASSES
&
nc
=
m_board
->
m_NetClasses
;
// save the default first.
// save the default first.
saveNETCLASS
(
nc
.
GetDefault
()
);
saveNETCLASS
(
aNetClasses
->
GetDefault
()
);
// the rest will be alphabetical in the *.brd file.
// the rest will be alphabetical in the *.brd file.
for
(
NETCLASSES
::
const_iterator
it
=
nc
.
begin
();
it
!=
nc
.
end
();
++
it
)
for
(
NETCLASSES
::
const_iterator
it
=
aNetClasses
->
begin
();
it
!=
aNetClasses
->
end
();
++
it
)
{
{
NETCLASS
*
netclass
=
it
->
second
;
NETCLASS
*
netclass
=
it
->
second
;
saveNETCLASS
(
netclass
);
saveNETCLASS
(
netclass
);
...
...
pcbnew/legacy_plugin.h
View file @
51a83a7a
...
@@ -40,6 +40,7 @@ class NETINFO;
...
@@ -40,6 +40,7 @@ class NETINFO;
class
TEXTE_PCB
;
class
TEXTE_PCB
;
class
TRACK
;
class
TRACK
;
class
NETCLASS
;
class
NETCLASS
;
class
NETCLASSES
;
class
ZONE_CONTAINER
;
class
ZONE_CONTAINER
;
class
DIMENSION
;
class
DIMENSION
;
class
NETINFO_ITEM
;
class
NETINFO_ITEM
;
...
@@ -114,6 +115,8 @@ public:
...
@@ -114,6 +115,8 @@ public:
MODULE
*
LoadMODULE
();
MODULE
*
LoadMODULE
();
void
SaveMODULE
(
const
MODULE
*
aModule
)
const
;
void
SaveMODULE
(
const
MODULE
*
aModule
)
const
;
void
SaveModule3D
(
const
MODULE
*
aModule
)
const
;
void
SaveModule3D
(
const
MODULE
*
aModule
)
const
;
void
SaveBOARD
(
const
BOARD
*
aBoard
)
const
;
protected
:
protected
:
...
@@ -247,18 +250,17 @@ protected:
...
@@ -247,18 +250,17 @@ protected:
*/
*/
std
::
string
fmtDEG
(
double
aAngle
)
const
;
std
::
string
fmtDEG
(
double
aAngle
)
const
;
void
saveAllSections
()
const
;
void
saveGENERAL
(
const
BOARD
*
aBoard
)
const
;
void
saveGENERAL
()
const
;
void
saveSHEET
(
const
BOARD
*
aBoard
)
const
;
void
saveSHEET
()
const
;
void
saveSETUP
(
const
BOARD
*
aBoard
)
const
;
void
saveSETUP
()
const
;
void
saveBOARD_ITEMS
(
const
BOARD
*
aBoard
)
const
;
void
saveBOARD
()
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
saveNETINFO_ITEM
(
const
NETINFO_ITEM
*
aNet
)
const
;
void
saveNETINFO_ITEM
(
const
NETINFO_ITEM
*
aNet
)
const
;
void
saveNETCLASSES
()
const
;
void
saveNETCLASSES
(
const
NETCLASSES
*
aNetClasses
)
const
;
void
saveNETCLASS
(
const
NETCLASS
*
aNetclass
)
const
;
void
saveNETCLASS
(
const
NETCLASS
*
aNetclass
)
const
;
void
savePCB_TEXT
(
const
TEXTE_PCB
*
aText
)
const
;
void
savePCB_TEXT
(
const
TEXTE_PCB
*
aText
)
const
;
...
...
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