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
e733864d
Commit
e733864d
authored
May 15, 2008
by
raburton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set eol-style native on new file
parent
142565c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
865 additions
and
865 deletions
+865
-865
build_BOM.cpp
eeschema/build_BOM.cpp
+865
-865
No files found.
eeschema/build_BOM.cpp
View file @
e733864d
// Name: build_BOM.cpp
// Name: build_BOM.cpp
// Purpose:
// Purpose:
// Author: jean-pierre Charras
// Author: jean-pierre Charras
// Licence: GPL license
// Licence: GPL license
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
#include "fctsys.h"
#include "common.h"
#include "common.h"
#include "program.h"
#include "program.h"
#include "libcmp.h"
#include "libcmp.h"
#include "general.h"
#include "general.h"
#include "netlist.h"
#include "netlist.h"
#include "dialog_build_BOM.h"
#include "dialog_build_BOM.h"
#include "protos.h"
#include "protos.h"
// Filename extension for BOM list
// Filename extension for BOM list
#define EXT_LIST wxT( ".lst" )
#define EXT_LIST wxT( ".lst" )
// Exported functions
// Exported functions
int
BuildComponentsListFromSchematic
(
ListComponent
*
List
);
int
BuildComponentsListFromSchematic
(
ListComponent
*
List
);
/* fonctions locales */
/* fonctions locales */
static
int
GenListeGLabels
(
ListLabel
*
List
);
static
int
GenListeGLabels
(
ListLabel
*
List
);
static
int
ListTriComposantByRef
(
ListComponent
*
Objet1
,
static
int
ListTriComposantByRef
(
ListComponent
*
Objet1
,
ListComponent
*
Objet2
);
ListComponent
*
Objet2
);
static
int
ListTriComposantByVal
(
ListComponent
*
Objet1
,
static
int
ListTriComposantByVal
(
ListComponent
*
Objet1
,
ListComponent
*
Objet2
);
ListComponent
*
Objet2
);
static
int
ListTriGLabelBySheet
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
);
static
int
ListTriGLabelBySheet
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
);
static
int
ListTriGLabelByVal
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
);
static
int
ListTriGLabelByVal
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
);
static
void
DeleteSubCmp
(
ListComponent
*
List
,
int
NbItems
);
static
void
DeleteSubCmp
(
ListComponent
*
List
,
int
NbItems
);
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
List
,
int
NbItems
);
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
List
,
int
NbItems
);
/* Local variables */
/* Local variables */
/* separator used in bom export to spreadsheet */
/* separator used in bom export to spreadsheet */
static
char
s_ExportSeparatorSymbol
;
static
char
s_ExportSeparatorSymbol
;
/**************************************************************************/
/**************************************************************************/
void
WinEDA_Build_BOM_Frame
::
Create_BOM_Lists
(
bool
aTypeFileIsExport
,
void
WinEDA_Build_BOM_Frame
::
Create_BOM_Lists
(
bool
aTypeFileIsExport
,
bool
aIncludeSubComponents
,
bool
aIncludeSubComponents
,
char
aExportSeparatorSymbol
,
char
aExportSeparatorSymbol
,
bool
aRunBrowser
)
bool
aRunBrowser
)
/**************************************************************************/
/**************************************************************************/
{
{
wxString
mask
,
filename
;
wxString
mask
,
filename
;
s_ExportSeparatorSymbol
=
aExportSeparatorSymbol
;
s_ExportSeparatorSymbol
=
aExportSeparatorSymbol
;
m_ListFileName
=
g_RootSheet
->
m_AssociatedScreen
->
m_FileName
;
m_ListFileName
=
g_RootSheet
->
m_AssociatedScreen
->
m_FileName
;
ChangeFileNameExt
(
m_ListFileName
,
EXT_LIST
);
ChangeFileNameExt
(
m_ListFileName
,
EXT_LIST
);
//need to get rid of the path.
//need to get rid of the path.
m_ListFileName
=
m_ListFileName
.
AfterLast
(
'/'
);
m_ListFileName
=
m_ListFileName
.
AfterLast
(
'/'
);
mask
=
wxT
(
"*"
);
mask
=
wxT
(
"*"
);
mask
+=
EXT_LIST
;
mask
+=
EXT_LIST
;
filename
=
EDA_FileSelector
(
_
(
"Bill of materials:"
),
filename
=
EDA_FileSelector
(
_
(
"Bill of materials:"
),
wxEmptyString
,
/* Chemin par defaut (ici dir courante) */
wxEmptyString
,
/* Chemin par defaut (ici dir courante) */
m_ListFileName
,
/* nom fichier par defaut, et resultat */
m_ListFileName
,
/* nom fichier par defaut, et resultat */
EXT_LIST
,
/* extension par defaut */
EXT_LIST
,
/* extension par defaut */
mask
,
/* Masque d'affichage */
mask
,
/* Masque d'affichage */
this
,
this
,
wxFD_SAVE
,
wxFD_SAVE
,
TRUE
TRUE
);
);
if
(
filename
.
IsEmpty
()
)
if
(
filename
.
IsEmpty
()
)
return
;
return
;
else
else
m_ListFileName
=
filename
;
m_ListFileName
=
filename
;
/* Close dialog, then show the list (if so requested) */
/* Close dialog, then show the list (if so requested) */
if
(
aTypeFileIsExport
)
if
(
aTypeFileIsExport
)
CreateExportList
(
m_ListFileName
,
aIncludeSubComponents
);
CreateExportList
(
m_ListFileName
,
aIncludeSubComponents
);
else
else
GenereListeOfItems
(
m_ListFileName
,
aIncludeSubComponents
);
GenereListeOfItems
(
m_ListFileName
,
aIncludeSubComponents
);
EndModal
(
1
);
EndModal
(
1
);
if
(
aRunBrowser
)
if
(
aRunBrowser
)
{
{
wxString
editorname
=
GetEditorName
();
wxString
editorname
=
GetEditorName
();
AddDelimiterString
(
filename
);
AddDelimiterString
(
filename
);
ExecuteFile
(
this
,
editorname
,
filename
);
ExecuteFile
(
this
,
editorname
,
filename
);
}
}
}
}
/****************************************************************************/
/****************************************************************************/
void
WinEDA_Build_BOM_Frame
::
CreateExportList
(
const
wxString
&
FullFileName
,
void
WinEDA_Build_BOM_Frame
::
CreateExportList
(
const
wxString
&
FullFileName
,
bool
aIncludeSubComponents
)
bool
aIncludeSubComponents
)
/****************************************************************************/
/****************************************************************************/
/*
/*
* Print a list of components, in a form which can be imported by a spreadsheet
* Print a list of components, in a form which can be imported by a spreadsheet
* form is:
* form is:
* cmp name; cmp val; fields;
* cmp name; cmp val; fields;
*/
*/
{
{
FILE
*
f
;
FILE
*
f
;
ListComponent
*
List
;
ListComponent
*
List
;
int
NbItems
;
int
NbItems
;
wxString
msg
;
wxString
msg
;
/* Creation de la liste des elements */
/* Creation de la liste des elements */
if
(
(
f
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
if
(
(
f
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
{
{
msg
=
_
(
"Failed to open file "
);
msg
=
_
(
"Failed to open file "
);
msg
<<
FullFileName
;
msg
<<
FullFileName
;
DisplayError
(
this
,
msg
);
DisplayError
(
this
,
msg
);
return
;
return
;
}
}
NbItems
=
BuildComponentsListFromSchematic
(
NULL
);
NbItems
=
BuildComponentsListFromSchematic
(
NULL
);
if
(
NbItems
)
if
(
NbItems
)
{
{
List
=
(
ListComponent
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListComponent
)
);
List
=
(
ListComponent
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListComponent
)
);
if
(
List
==
NULL
)
if
(
List
==
NULL
)
{
{
fclose
(
f
);
fclose
(
f
);
return
;
return
;
}
}
BuildComponentsListFromSchematic
(
List
);
BuildComponentsListFromSchematic
(
List
);
/* sort component list */
/* sort component list */
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByRef
);
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByRef
);
if
(
!
aIncludeSubComponents
)
if
(
!
aIncludeSubComponents
)
DeleteSubCmp
(
List
,
NbItems
);
DeleteSubCmp
(
List
,
NbItems
);
/* create the file */
/* create the file */
PrintComponentsListByRef
(
f
,
List
,
NbItems
,
TRUE
,
aIncludeSubComponents
);
PrintComponentsListByRef
(
f
,
List
,
NbItems
,
TRUE
,
aIncludeSubComponents
);
MyFree
(
List
);
MyFree
(
List
);
}
}
fclose
(
f
);
fclose
(
f
);
}
}
/****************************************************************************/
/****************************************************************************/
void
WinEDA_Build_BOM_Frame
::
GenereListeOfItems
(
const
wxString
&
FullFileName
,
void
WinEDA_Build_BOM_Frame
::
GenereListeOfItems
(
const
wxString
&
FullFileName
,
bool
aIncludeSubComponents
)
bool
aIncludeSubComponents
)
/****************************************************************************/
/****************************************************************************/
/*
/*
* Routine principale pour la creation des listings ( composants et/ou labels
* Routine principale pour la creation des listings ( composants et/ou labels
* globaux et "sheet labels" )
* globaux et "sheet labels" )
*/
*/
{
{
FILE
*
f
;
FILE
*
f
;
ListComponent
*
List
;
ListComponent
*
List
;
ListLabel
*
ListOfLabels
;
ListLabel
*
ListOfLabels
;
int
NbItems
;
int
NbItems
;
char
Line
[
1024
];
char
Line
[
1024
];
wxString
msg
;
wxString
msg
;
/* Creation de la liste des elements */
/* Creation de la liste des elements */
if
(
(
f
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
if
(
(
f
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
{
{
msg
=
_
(
"Failed to open file "
);
msg
=
_
(
"Failed to open file "
);
msg
<<
FullFileName
;
msg
<<
FullFileName
;
DisplayError
(
this
,
msg
);
DisplayError
(
this
,
msg
);
return
;
return
;
}
}
NbItems
=
BuildComponentsListFromSchematic
(
NULL
);
NbItems
=
BuildComponentsListFromSchematic
(
NULL
);
if
(
NbItems
)
if
(
NbItems
)
{
{
List
=
(
ListComponent
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListComponent
)
);
List
=
(
ListComponent
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListComponent
)
);
if
(
List
==
NULL
)
// Error memory alloc
if
(
List
==
NULL
)
// Error memory alloc
{
{
fclose
(
f
);
fclose
(
f
);
return
;
return
;
}
}
BuildComponentsListFromSchematic
(
List
);
BuildComponentsListFromSchematic
(
List
);
/* generation du fichier listing */
/* generation du fichier listing */
DateAndTime
(
Line
);
DateAndTime
(
Line
);
wxString
Title
=
g_Main_Title
+
wxT
(
" "
)
+
GetBuildVersion
();
wxString
Title
=
g_Main_Title
+
wxT
(
" "
)
+
GetBuildVersion
();
fprintf
(
f
,
"%s >> Creation date: %s
\n
"
,
CONV_TO_UTF8
(
Title
),
Line
);
fprintf
(
f
,
"%s >> Creation date: %s
\n
"
,
CONV_TO_UTF8
(
Title
),
Line
);
/* Tri et impression de la liste des composants */
/* Tri et impression de la liste des composants */
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByRef
);
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByRef
);
if
(
!
aIncludeSubComponents
)
if
(
!
aIncludeSubComponents
)
DeleteSubCmp
(
List
,
NbItems
);
DeleteSubCmp
(
List
,
NbItems
);
// if( s_ListByRef )
// if( s_ListByRef )
if
(
m_ListCmpbyRefItems
->
GetValue
()
)
if
(
m_ListCmpbyRefItems
->
GetValue
()
)
{
{
PrintComponentsListByRef
(
f
,
List
,
NbItems
,
false
,
aIncludeSubComponents
);
PrintComponentsListByRef
(
f
,
List
,
NbItems
,
false
,
aIncludeSubComponents
);
}
}
// if( s_ListByValue )
// if( s_ListByValue )
if
(
m_ListCmpbyValItems
->
GetValue
()
)
if
(
m_ListCmpbyValItems
->
GetValue
()
)
{
{
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByVal
);
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByVal
);
PrintComponentsListByVal
(
f
,
List
,
NbItems
,
aIncludeSubComponents
);
PrintComponentsListByVal
(
f
,
List
,
NbItems
,
aIncludeSubComponents
);
}
}
MyFree
(
List
);
MyFree
(
List
);
}
}
/***************************************/
/***************************************/
/* Generation liste des Labels globaux */
/* Generation liste des Labels globaux */
/***************************************/
/***************************************/
NbItems
=
GenListeGLabels
(
NULL
);
NbItems
=
GenListeGLabels
(
NULL
);
if
(
NbItems
)
if
(
NbItems
)
{
{
ListOfLabels
=
(
ListLabel
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListLabel
)
);
ListOfLabels
=
(
ListLabel
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListLabel
)
);
if
(
ListOfLabels
==
NULL
)
if
(
ListOfLabels
==
NULL
)
{
{
fclose
(
f
);
fclose
(
f
);
return
;
return
;
}
}
GenListeGLabels
(
ListOfLabels
);
GenListeGLabels
(
ListOfLabels
);
/* Tri de la liste */
/* Tri de la liste */
// if( s_ListBySheet )
// if( s_ListBySheet )
if
(
m_GenListLabelsbySheet
->
GetValue
()
)
if
(
m_GenListLabelsbySheet
->
GetValue
()
)
{
{
qsort
(
ListOfLabels
,
NbItems
,
sizeof
(
ListLabel
),
qsort
(
ListOfLabels
,
NbItems
,
sizeof
(
ListLabel
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriGLabelBySheet
);
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriGLabelBySheet
);
msg
.
Printf
(
_
(
msg
.
Printf
(
_
(
"
\n
#Global, Hierarchical Labels and PinSheets ( order = Sheet Number ) count = %d
\n
"
),
"
\n
#Global, Hierarchical Labels and PinSheets ( order = Sheet Number ) count = %d
\n
"
),
NbItems
);
NbItems
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
PrintListeGLabel
(
f
,
ListOfLabels
,
NbItems
);
PrintListeGLabel
(
f
,
ListOfLabels
,
NbItems
);
}
}
// if( s_ListHierarchicalPinByName )
// if( s_ListHierarchicalPinByName )
if
(
m_GenListLabelsbyVal
->
GetValue
()
)
if
(
m_GenListLabelsbyVal
->
GetValue
()
)
{
{
qsort
(
ListOfLabels
,
NbItems
,
sizeof
(
ListLabel
),
qsort
(
ListOfLabels
,
NbItems
,
sizeof
(
ListLabel
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriGLabelByVal
);
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriGLabelByVal
);
msg
.
Printf
(
_
(
msg
.
Printf
(
_
(
"
\n
#Global, Hierarchical Labels and PinSheets ( order = Alphab. ) count = %d
\n\n
"
),
"
\n
#Global, Hierarchical Labels and PinSheets ( order = Alphab. ) count = %d
\n\n
"
),
NbItems
);
NbItems
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
PrintListeGLabel
(
f
,
ListOfLabels
,
NbItems
);
PrintListeGLabel
(
f
,
ListOfLabels
,
NbItems
);
}
}
MyFree
(
ListOfLabels
);
MyFree
(
ListOfLabels
);
}
}
msg
=
_
(
"
\n
#End List
\n
"
);
msg
=
_
(
"
\n
#End List
\n
"
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
fclose
(
f
);
fclose
(
f
);
}
}
/*********************************************************/
/*********************************************************/
int
BuildComponentsListFromSchematic
(
ListComponent
*
List
)
int
BuildComponentsListFromSchematic
(
ListComponent
*
List
)
/*********************************************************/
/*********************************************************/
/* Creates the list of components found in the whole schematic
/* Creates the list of components found in the whole schematic
*
*
* if List == null, just returns the count. if not, fills the list.
* if List == null, just returns the count. if not, fills the list.
* goes through the sheets, not the screens, so that we account for
* goes through the sheets, not the screens, so that we account for
* multiple instances of a given screen.
* multiple instances of a given screen.
* Also Initialise m_Father as pointer pointeur of the SCH_SCREN parent
* Also Initialise m_Father as pointer pointeur of the SCH_SCREN parent
*/
*/
{
{
int
ItemCount
=
0
;
int
ItemCount
=
0
;
EDA_BaseStruct
*
SchItem
;
EDA_BaseStruct
*
SchItem
;
SCH_COMPONENT
*
DrawLibItem
;
SCH_COMPONENT
*
DrawLibItem
;
DrawSheetPath
*
sheet
;
DrawSheetPath
*
sheet
;
/* Build the sheet (not screen) list */
/* Build the sheet (not screen) list */
EDA_SheetList
SheetList
(
NULL
);
EDA_SheetList
SheetList
(
NULL
);
for
(
sheet
=
SheetList
.
GetFirst
();
sheet
!=
NULL
;
sheet
=
SheetList
.
GetNext
()
)
for
(
sheet
=
SheetList
.
GetFirst
();
sheet
!=
NULL
;
sheet
=
SheetList
.
GetNext
()
)
{
{
for
(
SchItem
=
sheet
->
LastDrawList
();
SchItem
;
SchItem
=
SchItem
->
Next
()
)
for
(
SchItem
=
sheet
->
LastDrawList
();
SchItem
;
SchItem
=
SchItem
->
Next
()
)
{
{
if
(
SchItem
->
Type
()
!=
TYPE_SCH_COMPONENT
)
if
(
SchItem
->
Type
()
!=
TYPE_SCH_COMPONENT
)
continue
;
continue
;
ItemCount
++
;
ItemCount
++
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
SchItem
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
SchItem
;
DrawLibItem
->
m_Parent
=
sheet
->
LastScreen
();
DrawLibItem
->
m_Parent
=
sheet
->
LastScreen
();
if
(
List
)
if
(
List
)
{
{
List
->
m_Comp
=
DrawLibItem
;
List
->
m_Comp
=
DrawLibItem
;
List
->
m_SheetList
=
*
sheet
;
List
->
m_SheetList
=
*
sheet
;
List
->
m_Unit
=
DrawLibItem
->
GetUnitSelection
(
sheet
);
List
->
m_Unit
=
DrawLibItem
->
GetUnitSelection
(
sheet
);
strncpy
(
List
->
m_Ref
,
strncpy
(
List
->
m_Ref
,
CONV_TO_UTF8
(
DrawLibItem
->
GetRef
(
sheet
)
),
CONV_TO_UTF8
(
DrawLibItem
->
GetRef
(
sheet
)
),
sizeof
(
List
->
m_Ref
)
);
sizeof
(
List
->
m_Ref
)
);
List
++
;
List
++
;
}
}
}
}
}
}
return
ItemCount
;
return
ItemCount
;
}
}
/*********************************************/
/*********************************************/
static
int
GenListeGLabels
(
ListLabel
*
List
)
static
int
GenListeGLabels
(
ListLabel
*
List
)
/*********************************************/
/*********************************************/
/* Count the Glabels, or fill the list Listwith Glabel pointers
/* Count the Glabels, or fill the list Listwith Glabel pointers
* If List == NULL: Item count only
* If List == NULL: Item count only
* Else fill list of Glabels
* Else fill list of Glabels
*/
*/
{
{
int
ItemCount
=
0
;
int
ItemCount
=
0
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
Hierarchical_PIN_Sheet_Struct
*
SheetLabel
;
Hierarchical_PIN_Sheet_Struct
*
SheetLabel
;
DrawSheetPath
*
sheet
;
DrawSheetPath
*
sheet
;
/* Build the screen list */
/* Build the screen list */
EDA_SheetList
SheetList
(
NULL
);
EDA_SheetList
SheetList
(
NULL
);
for
(
sheet
=
SheetList
.
GetFirst
();
sheet
!=
NULL
;
sheet
=
SheetList
.
GetNext
()
)
for
(
sheet
=
SheetList
.
GetFirst
();
sheet
!=
NULL
;
sheet
=
SheetList
.
GetNext
()
)
{
{
DrawList
=
sheet
->
LastDrawList
();
DrawList
=
sheet
->
LastDrawList
();
wxString
path
=
sheet
->
PathHumanReadable
();
wxString
path
=
sheet
->
PathHumanReadable
();
while
(
DrawList
)
while
(
DrawList
)
{
{
switch
(
DrawList
->
Type
()
)
switch
(
DrawList
->
Type
()
)
{
{
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_GLOBALLABEL
:
case
TYPE_SCH_GLOBALLABEL
:
ItemCount
++
;
ItemCount
++
;
if
(
List
)
if
(
List
)
{
{
List
->
m_LabelType
=
DrawList
->
Type
();
List
->
m_LabelType
=
DrawList
->
Type
();
snprintf
(
List
->
m_SheetPath
,
sizeof
(
List
->
m_SheetPath
),
snprintf
(
List
->
m_SheetPath
,
sizeof
(
List
->
m_SheetPath
),
"%s"
,
CONV_TO_UTF8
(
path
)
);
"%s"
,
CONV_TO_UTF8
(
path
)
);
List
->
m_Label
=
DrawList
;
List
->
m_Label
=
DrawList
;
List
++
;
List
++
;
}
}
break
;
break
;
case
DRAW_SHEET_STRUCT_TYPE
:
case
DRAW_SHEET_STRUCT_TYPE
:
{
{
#define Sheet ( (DrawSheetStruct*) DrawList )
#define Sheet ( (DrawSheetStruct*) DrawList )
SheetLabel
=
Sheet
->
m_Label
;
SheetLabel
=
Sheet
->
m_Label
;
while
(
SheetLabel
!=
NULL
)
while
(
SheetLabel
!=
NULL
)
{
{
if
(
List
)
if
(
List
)
{
{
List
->
m_LabelType
=
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
;
List
->
m_LabelType
=
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
;
snprintf
(
List
->
m_SheetPath
,
sizeof
(
List
->
m_SheetPath
),
snprintf
(
List
->
m_SheetPath
,
sizeof
(
List
->
m_SheetPath
),
"%s"
,
CONV_TO_UTF8
(
path
)
);
"%s"
,
CONV_TO_UTF8
(
path
)
);
List
->
m_Label
=
SheetLabel
;
List
->
m_Label
=
SheetLabel
;
List
++
;
List
++
;
}
}
ItemCount
++
;
ItemCount
++
;
SheetLabel
=
(
Hierarchical_PIN_Sheet_Struct
*
)
(
SheetLabel
->
Pnext
);
SheetLabel
=
(
Hierarchical_PIN_Sheet_Struct
*
)
(
SheetLabel
->
Pnext
);
}
}
}
}
break
;
break
;
default
:
default
:
break
;
break
;
}
}
DrawList
=
DrawList
->
Pnext
;
DrawList
=
DrawList
->
Pnext
;
}
}
}
}
return
ItemCount
;
return
ItemCount
;
}
}
/**********************************************************/
/**********************************************************/
static
int
ListTriComposantByVal
(
ListComponent
*
Objet1
,
static
int
ListTriComposantByVal
(
ListComponent
*
Objet1
,
ListComponent
*
Objet2
)
ListComponent
*
Objet2
)
/**********************************************************/
/**********************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
/* Routine de comparaison pour le tri du Tableau par qsort()
* Les composants sont tries
* Les composants sont tries
* par valeur
* par valeur
* si meme valeur: par reference
* si meme valeur: par reference
* si meme valeur: par numero d'unite
* si meme valeur: par numero d'unite
*/
*/
{
{
int
ii
;
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
const
wxString
*
Text1
,
*
Text2
;
if
(
(
Objet1
==
NULL
)
&&
(
Objet2
==
NULL
)
)
if
(
(
Objet1
==
NULL
)
&&
(
Objet2
==
NULL
)
)
return
0
;
return
0
;
if
(
Objet1
==
NULL
)
if
(
Objet1
==
NULL
)
return
-
1
;
return
-
1
;
if
(
Objet2
==
NULL
)
if
(
Objet2
==
NULL
)
return
1
;
return
1
;
if
(
(
Objet1
->
m_Comp
==
NULL
)
&&
(
Objet2
->
m_Comp
==
NULL
)
)
if
(
(
Objet1
->
m_Comp
==
NULL
)
&&
(
Objet2
->
m_Comp
==
NULL
)
)
return
0
;
return
0
;
if
(
Objet1
->
m_Comp
==
NULL
)
if
(
Objet1
->
m_Comp
==
NULL
)
return
-
1
;
return
-
1
;
if
(
Objet2
->
m_Comp
==
NULL
)
if
(
Objet2
->
m_Comp
==
NULL
)
return
1
;
return
1
;
Text1
=
&
(
Objet1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text1
=
&
(
Objet1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
Objet2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
Objet2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
ii
=
strcmp
(
Objet1
->
m_Ref
,
Objet2
->
m_Ref
);
ii
=
strcmp
(
Objet1
->
m_Ref
,
Objet2
->
m_Ref
);
}
}
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
ii
=
Objet1
->
m_Unit
-
Objet2
->
m_Unit
;
ii
=
Objet1
->
m_Unit
-
Objet2
->
m_Unit
;
}
}
return
ii
;
return
ii
;
}
}
/**********************************************************/
/**********************************************************/
static
int
ListTriComposantByRef
(
ListComponent
*
Objet1
,
static
int
ListTriComposantByRef
(
ListComponent
*
Objet1
,
ListComponent
*
Objet2
)
ListComponent
*
Objet2
)
/**********************************************************/
/**********************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
/* Routine de comparaison pour le tri du Tableau par qsort()
* Les composants sont tries
* Les composants sont tries
* par reference
* par reference
* si meme referenece: par valeur
* si meme referenece: par valeur
* si meme valeur: par numero d'unite
* si meme valeur: par numero d'unite
*/
*/
{
{
int
ii
;
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
const
wxString
*
Text1
,
*
Text2
;
if
(
(
Objet1
==
NULL
)
&&
(
Objet2
==
NULL
)
)
if
(
(
Objet1
==
NULL
)
&&
(
Objet2
==
NULL
)
)
return
0
;
return
0
;
if
(
Objet1
==
NULL
)
if
(
Objet1
==
NULL
)
return
-
1
;
return
-
1
;
if
(
Objet2
==
NULL
)
if
(
Objet2
==
NULL
)
return
1
;
return
1
;
if
(
(
Objet1
->
m_Comp
==
NULL
)
&&
(
Objet2
->
m_Comp
==
NULL
)
)
if
(
(
Objet1
->
m_Comp
==
NULL
)
&&
(
Objet2
->
m_Comp
==
NULL
)
)
return
0
;
return
0
;
if
(
Objet1
->
m_Comp
==
NULL
)
if
(
Objet1
->
m_Comp
==
NULL
)
return
-
1
;
return
-
1
;
if
(
Objet2
->
m_Comp
==
NULL
)
if
(
Objet2
->
m_Comp
==
NULL
)
return
1
;
return
1
;
ii
=
strcmp
(
Objet1
->
m_Ref
,
Objet2
->
m_Ref
);
ii
=
strcmp
(
Objet1
->
m_Ref
,
Objet2
->
m_Ref
);
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
Text1
=
&
(
Objet1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text1
=
&
(
Objet1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
Objet2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
Objet2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
}
}
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
ii
=
Objet1
->
m_Unit
-
Objet2
->
m_Unit
;
ii
=
Objet1
->
m_Unit
-
Objet2
->
m_Unit
;
}
}
return
ii
;
return
ii
;
}
}
/******************************************************************/
/******************************************************************/
static
int
ListTriGLabelByVal
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
)
static
int
ListTriGLabelByVal
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
)
/*******************************************************************/
/*******************************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
/* Routine de comparaison pour le tri du Tableau par qsort()
* Les labels sont tries
* Les labels sont tries
* par comparaison ascii
* par comparaison ascii
* si meme valeur: par numero de sheet
* si meme valeur: par numero de sheet
*/
*/
{
{
int
ii
;
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
const
wxString
*
Text1
,
*
Text2
;
if
(
Objet1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
if
(
Objet1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet1
->
m_Label
)
->
m_Text
;
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet1
->
m_Label
)
->
m_Text
;
else
else
Text1
=
&
(
(
SCH_TEXT
*
)
Objet1
->
m_Label
)
->
m_Text
;
Text1
=
&
(
(
SCH_TEXT
*
)
Objet1
->
m_Label
)
->
m_Text
;
if
(
Objet2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
if
(
Objet2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet2
->
m_Label
)
->
m_Text
;
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet2
->
m_Label
)
->
m_Text
;
else
else
Text2
=
&
(
(
SCH_TEXT
*
)
Objet2
->
m_Label
)
->
m_Text
;
Text2
=
&
(
(
SCH_TEXT
*
)
Objet2
->
m_Label
)
->
m_Text
;
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
ii
=
strcmp
(
Objet1
->
m_SheetPath
,
Objet2
->
m_SheetPath
);
ii
=
strcmp
(
Objet1
->
m_SheetPath
,
Objet2
->
m_SheetPath
);
}
}
return
ii
;
return
ii
;
}
}
/*******************************************************************/
/*******************************************************************/
static
int
ListTriGLabelBySheet
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
)
static
int
ListTriGLabelBySheet
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
)
/*******************************************************************/
/*******************************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
/* Routine de comparaison pour le tri du Tableau par qsort()
* Les labels sont tries
* Les labels sont tries
* par sheet number
* par sheet number
* si meme valeur, par ordre alphabetique
* si meme valeur, par ordre alphabetique
*/
*/
{
{
int
ii
;
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
const
wxString
*
Text1
,
*
Text2
;
ii
=
strcmp
(
Objet1
->
m_SheetPath
,
Objet2
->
m_SheetPath
);
ii
=
strcmp
(
Objet1
->
m_SheetPath
,
Objet2
->
m_SheetPath
);
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
if
(
Objet1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
if
(
Objet1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet1
->
m_Label
)
->
m_Text
;
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet1
->
m_Label
)
->
m_Text
;
else
else
Text1
=
&
(
(
SCH_TEXT
*
)
Objet1
->
m_Label
)
->
m_Text
;
Text1
=
&
(
(
SCH_TEXT
*
)
Objet1
->
m_Label
)
->
m_Text
;
if
(
Objet2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
if
(
Objet2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet2
->
m_Label
)
->
m_Text
;
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet2
->
m_Label
)
->
m_Text
;
else
else
Text2
=
&
(
(
SCH_TEXT
*
)
Objet2
->
m_Label
)
->
m_Text
;
Text2
=
&
(
(
SCH_TEXT
*
)
Objet2
->
m_Label
)
->
m_Text
;
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
}
}
return
ii
;
return
ii
;
}
}
/**************************************************************/
/**************************************************************/
static
void
DeleteSubCmp
(
ListComponent
*
List
,
int
NbItems
)
static
void
DeleteSubCmp
(
ListComponent
*
List
,
int
NbItems
)
/**************************************************************/
/**************************************************************/
/* Remove sub components from the list, when multiples parts per package are found in this list
/* Remove sub components from the list, when multiples parts per package are found in this list
* The component list **MUST** be sorted by reference and by unit number
* The component list **MUST** be sorted by reference and by unit number
*/
*/
{
{
int
ii
;
int
ii
;
SCH_COMPONENT
*
LibItem
;
SCH_COMPONENT
*
LibItem
;
wxString
OldName
,
CurrName
;
wxString
OldName
,
CurrName
;
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
{
{
LibItem
=
List
[
ii
].
m_Comp
;
LibItem
=
List
[
ii
].
m_Comp
;
if
(
LibItem
==
NULL
)
if
(
LibItem
==
NULL
)
continue
;
continue
;
CurrName
=
CONV_FROM_UTF8
(
List
[
ii
].
m_Ref
);
CurrName
=
CONV_FROM_UTF8
(
List
[
ii
].
m_Ref
);
if
(
!
OldName
.
IsEmpty
()
)
if
(
!
OldName
.
IsEmpty
()
)
{
{
if
(
OldName
==
CurrName
)
// CurrName is a subpart of OldName: remove it
if
(
OldName
==
CurrName
)
// CurrName is a subpart of OldName: remove it
{
{
List
[
ii
].
m_Comp
=
NULL
;
List
[
ii
].
m_Comp
=
NULL
;
List
[
ii
].
m_SheetList
.
Clear
();
List
[
ii
].
m_SheetList
.
Clear
();
List
[
ii
].
m_Ref
[
0
]
=
0
;
List
[
ii
].
m_Ref
[
0
]
=
0
;
}
}
}
}
OldName
=
CurrName
;
OldName
=
CurrName
;
}
}
}
}
/*******************************************************************************************/
/*******************************************************************************************/
void
WinEDA_Build_BOM_Frame
::
PrintFieldData
(
FILE
*
f
,
SCH_COMPONENT
*
DrawLibItem
,
void
WinEDA_Build_BOM_Frame
::
PrintFieldData
(
FILE
*
f
,
SCH_COMPONENT
*
DrawLibItem
,
bool
CompactForm
)
bool
CompactForm
)
/*******************************************************************************************/
/*******************************************************************************************/
{
{
wxCheckBox
*
FieldListCtrl
[]
=
{
wxCheckBox
*
FieldListCtrl
[]
=
{
m_AddField1
,
m_AddField1
,
m_AddField2
,
m_AddField2
,
m_AddField3
,
m_AddField3
,
m_AddField4
,
m_AddField4
,
m_AddField5
,
m_AddField5
,
m_AddField6
,
m_AddField6
,
m_AddField7
,
m_AddField7
,
m_AddField8
m_AddField8
};
};
int
ii
;
int
ii
;
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
0
];
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
0
];
if
(
CompactForm
)
if
(
CompactForm
)
{
{
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
FOOTPRINT
].
m_Text
)
);
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
FOOTPRINT
].
m_Text
)
);
}
}
else
if
(
m_AddFootprintField
->
IsChecked
()
)
else
if
(
m_AddFootprintField
->
IsChecked
()
)
fprintf
(
f
,
"; %-12s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
FOOTPRINT
].
m_Text
)
);
fprintf
(
f
,
"; %-12s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
FOOTPRINT
].
m_Text
)
);
for
(
ii
=
FIELD1
;
ii
<=
FIELD8
;
ii
++
)
for
(
ii
=
FIELD1
;
ii
<=
FIELD8
;
ii
++
)
{
{
FieldCtrl
=
FieldListCtrl
[
ii
-
FIELD1
];
FieldCtrl
=
FieldListCtrl
[
ii
-
FIELD1
];
if
(
FieldCtrl
==
NULL
)
if
(
FieldCtrl
==
NULL
)
continue
;
continue
;
if
(
!
FieldCtrl
->
IsChecked
()
)
if
(
!
FieldCtrl
->
IsChecked
()
)
continue
;
continue
;
if
(
CompactForm
)
if
(
CompactForm
)
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
ii
].
m_Text
)
);
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
ii
].
m_Text
)
);
else
else
fprintf
(
f
,
"; %-12s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
ii
].
m_Text
)
);
fprintf
(
f
,
"; %-12s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
ii
].
m_Text
)
);
}
}
}
}
/*********************************************************************************************/
/*********************************************************************************************/
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByRef
(
FILE
*
f
,
ListComponent
*
List
,
int
NbItems
,
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByRef
(
FILE
*
f
,
ListComponent
*
List
,
int
NbItems
,
bool
CompactForm
,
bool
aIncludeSubComponents
)
bool
CompactForm
,
bool
aIncludeSubComponents
)
/*********************************************************************************************/
/*********************************************************************************************/
/* Print the B.O.M sorted by reference
/* Print the B.O.M sorted by reference
*/
*/
{
{
int
ii
,
Multi
,
Unit
;
int
ii
,
Multi
,
Unit
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
SCH_COMPONENT
*
DrawLibItem
;
SCH_COMPONENT
*
DrawLibItem
;
EDA_LibComponentStruct
*
Entry
;
EDA_LibComponentStruct
*
Entry
;
char
CmpName
[
80
];
char
CmpName
[
80
];
wxString
msg
;
wxString
msg
;
if
(
CompactForm
)
if
(
CompactForm
)
{
{
wxCheckBox
*
FieldListCtrl
[
FIELD8
-
FIELD1
+
1
]
=
{
wxCheckBox
*
FieldListCtrl
[
FIELD8
-
FIELD1
+
1
]
=
{
m_AddField1
,
m_AddField1
,
m_AddField2
,
m_AddField2
,
m_AddField3
,
m_AddField3
,
m_AddField4
,
m_AddField4
,
m_AddField5
,
m_AddField5
,
m_AddField6
,
m_AddField6
,
m_AddField7
,
m_AddField7
,
m_AddField8
m_AddField8
};
};
// Print comment line:
// Print comment line:
fprintf
(
f
,
"ref%cvalue"
,
s_ExportSeparatorSymbol
);
fprintf
(
f
,
"ref%cvalue"
,
s_ExportSeparatorSymbol
);
if
(
aIncludeSubComponents
)
if
(
aIncludeSubComponents
)
fprintf
(
f
,
"%csheet path"
,
s_ExportSeparatorSymbol
);
fprintf
(
f
,
"%csheet path"
,
s_ExportSeparatorSymbol
);
fprintf
(
f
,
"%cfootprint"
,
s_ExportSeparatorSymbol
);
fprintf
(
f
,
"%cfootprint"
,
s_ExportSeparatorSymbol
);
for
(
ii
=
FIELD1
;
ii
<=
FIELD8
;
ii
++
)
for
(
ii
=
FIELD1
;
ii
<=
FIELD8
;
ii
++
)
{
{
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
ii
-
FIELD1
];
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
ii
-
FIELD1
];
if
(
FieldCtrl
==
NULL
)
if
(
FieldCtrl
==
NULL
)
continue
;
continue
;
if
(
!
FieldCtrl
->
IsChecked
()
)
if
(
!
FieldCtrl
->
IsChecked
()
)
continue
;
continue
;
msg
=
_
(
"Field"
);
msg
=
_
(
"Field"
);
fprintf
(
f
,
"%c%s%d"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
msg
),
ii
-
FIELD1
+
1
);
fprintf
(
f
,
"%c%s%d"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
msg
),
ii
-
FIELD1
+
1
);
}
}
fprintf
(
f
,
"
\n
"
);
fprintf
(
f
,
"
\n
"
);
}
}
else
else
{
{
msg
=
_
(
"
\n
#Cmp ( order = Reference )"
);
msg
=
_
(
"
\n
#Cmp ( order = Reference )"
);
if
(
aIncludeSubComponents
)
if
(
aIncludeSubComponents
)
msg
<<
_
(
" (with SubCmp)"
);
msg
<<
_
(
" (with SubCmp)"
);
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
msg
)
);
}
}
// Print list of items
// Print list of items
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
{
{
DrawList
=
List
[
ii
].
m_Comp
;
DrawList
=
List
[
ii
].
m_Comp
;
if
(
DrawList
==
NULL
)
if
(
DrawList
==
NULL
)
continue
;
continue
;
if
(
DrawList
->
Type
()
!=
TYPE_SCH_COMPONENT
)
if
(
DrawList
->
Type
()
!=
TYPE_SCH_COMPONENT
)
continue
;
continue
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
DrawList
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
DrawList
;
if
(
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
if
(
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
continue
;
continue
;
Multi
=
0
;
Multi
=
0
;
Unit
=
' '
;
Unit
=
' '
;
Entry
=
FindLibPart
(
DrawLibItem
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
Entry
=
FindLibPart
(
DrawLibItem
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
if
(
Entry
)
if
(
Entry
)
Multi
=
Entry
->
m_UnitCount
;
Multi
=
Entry
->
m_UnitCount
;
if
(
(
Multi
>
1
)
&&
aIncludeSubComponents
)
if
(
(
Multi
>
1
)
&&
aIncludeSubComponents
)
Unit
=
List
[
ii
].
m_Unit
+
'A'
-
1
;
Unit
=
List
[
ii
].
m_Unit
+
'A'
-
1
;
sprintf
(
CmpName
,
"%s"
,
List
[
ii
].
m_Ref
);
sprintf
(
CmpName
,
"%s"
,
List
[
ii
].
m_Ref
);
if
(
!
CompactForm
||
Unit
!=
' '
)
if
(
!
CompactForm
||
Unit
!=
' '
)
sprintf
(
CmpName
+
strlen
(
CmpName
),
"%c"
,
Unit
);
sprintf
(
CmpName
+
strlen
(
CmpName
),
"%c"
,
Unit
);
if
(
CompactForm
)
if
(
CompactForm
)
fprintf
(
f
,
"%s%c%s"
,
CmpName
,
s_ExportSeparatorSymbol
,
fprintf
(
f
,
"%s%c%s"
,
CmpName
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
)
);
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
)
);
else
else
fprintf
(
f
,
"| %-10s %-12s"
,
CmpName
,
fprintf
(
f
,
"| %-10s %-12s"
,
CmpName
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
)
);
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
)
);
if
(
aIncludeSubComponents
)
if
(
aIncludeSubComponents
)
{
{
msg
=
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
msg
=
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
if
(
CompactForm
)
if
(
CompactForm
)
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
msg
)
);
else
else
fprintf
(
f
,
" (Sheet %s)"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
" (Sheet %s)"
,
CONV_TO_UTF8
(
msg
)
);
}
}
PrintFieldData
(
f
,
DrawLibItem
,
CompactForm
);
PrintFieldData
(
f
,
DrawLibItem
,
CompactForm
);
fprintf
(
f
,
"
\n
"
);
fprintf
(
f
,
"
\n
"
);
}
}
if
(
!
CompactForm
)
if
(
!
CompactForm
)
{
{
msg
=
_
(
"#End Cmp
\n
"
);
msg
=
_
(
"#End Cmp
\n
"
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
}
}
return
0
;
return
0
;
}
}
/*********************************************************************************************/
/*********************************************************************************************/
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByVal
(
FILE
*
f
,
ListComponent
*
List
,
int
NbItems
,
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByVal
(
FILE
*
f
,
ListComponent
*
List
,
int
NbItems
,
bool
aIncludeSubComponents
)
bool
aIncludeSubComponents
)
/**********************************************************************************************/
/**********************************************************************************************/
{
{
int
ii
,
Multi
;
int
ii
,
Multi
;
wxChar
Unit
;
wxChar
Unit
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
SCH_COMPONENT
*
DrawLibItem
;
SCH_COMPONENT
*
DrawLibItem
;
EDA_LibComponentStruct
*
Entry
;
EDA_LibComponentStruct
*
Entry
;
char
CmpName
[
80
];
char
CmpName
[
80
];
wxString
msg
;
wxString
msg
;
msg
=
_
(
"
\n
#Cmp ( order = Value )"
);
msg
=
_
(
"
\n
#Cmp ( order = Value )"
);
if
(
aIncludeSubComponents
)
if
(
aIncludeSubComponents
)
msg
<<
_
(
" (with SubCmp)"
);
msg
<<
_
(
" (with SubCmp)"
);
msg
<<
wxT
(
"
\n
"
);
msg
<<
wxT
(
"
\n
"
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
{
{
DrawList
=
List
[
ii
].
m_Comp
;
DrawList
=
List
[
ii
].
m_Comp
;
if
(
DrawList
==
NULL
)
if
(
DrawList
==
NULL
)
continue
;
continue
;
if
(
DrawList
->
Type
()
!=
TYPE_SCH_COMPONENT
)
if
(
DrawList
->
Type
()
!=
TYPE_SCH_COMPONENT
)
continue
;
continue
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
DrawList
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
DrawList
;
if
(
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
if
(
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
continue
;
continue
;
Multi
=
0
;
Multi
=
0
;
Unit
=
' '
;
Unit
=
' '
;
Entry
=
FindLibPart
(
DrawLibItem
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
Entry
=
FindLibPart
(
DrawLibItem
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
if
(
Entry
)
if
(
Entry
)
Multi
=
Entry
->
m_UnitCount
;
Multi
=
Entry
->
m_UnitCount
;
if
(
(
Multi
>
1
)
&&
aIncludeSubComponents
)
if
(
(
Multi
>
1
)
&&
aIncludeSubComponents
)
{
{
Unit
=
List
[
ii
].
m_Unit
+
'A'
-
1
;
Unit
=
List
[
ii
].
m_Unit
+
'A'
-
1
;
}
}
sprintf
(
CmpName
,
"%s%c"
,
List
[
ii
].
m_Ref
,
Unit
);
sprintf
(
CmpName
,
"%s%c"
,
List
[
ii
].
m_Ref
,
Unit
);
fprintf
(
f
,
"| %-12s %-10s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
),
CmpName
);
fprintf
(
f
,
"| %-12s %-10s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
),
CmpName
);
// print the sheet path
// print the sheet path
if
(
aIncludeSubComponents
)
if
(
aIncludeSubComponents
)
{
{
msg
=
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
msg
=
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
fprintf
(
f
,
" (Sheet %s)"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
" (Sheet %s)"
,
CONV_TO_UTF8
(
msg
)
);
}
}
PrintFieldData
(
f
,
DrawLibItem
);
PrintFieldData
(
f
,
DrawLibItem
);
fprintf
(
f
,
"
\n
"
);
fprintf
(
f
,
"
\n
"
);
}
}
msg
=
_
(
"#End Cmp
\n
"
);
msg
=
_
(
"#End Cmp
\n
"
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
return
0
;
return
0
;
}
}
/******************************************************************/
/******************************************************************/
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
List
,
int
NbItems
)
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
List
,
int
NbItems
)
/******************************************************************/
/******************************************************************/
{
{
int
ii
,
jj
;
int
ii
,
jj
;
SCH_LABEL
*
DrawTextItem
;
SCH_LABEL
*
DrawTextItem
;
Hierarchical_PIN_Sheet_Struct
*
DrawSheetLabel
;
Hierarchical_PIN_Sheet_Struct
*
DrawSheetLabel
;
ListLabel
*
LabelItem
;
ListLabel
*
LabelItem
;
wxString
msg
,
sheetpath
;
wxString
msg
,
sheetpath
;
wxString
labeltype
;
wxString
labeltype
;
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
{
{
LabelItem
=
&
List
[
ii
];
LabelItem
=
&
List
[
ii
];
switch
(
LabelItem
->
m_LabelType
)
switch
(
LabelItem
->
m_LabelType
)
{
{
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_GLOBALLABEL
:
case
TYPE_SCH_GLOBALLABEL
:
DrawTextItem
=
(
SCH_LABEL
*
)
(
LabelItem
->
m_Label
);
DrawTextItem
=
(
SCH_LABEL
*
)
(
LabelItem
->
m_Label
);
if
(
LabelItem
->
m_LabelType
==
TYPE_SCH_HIERLABEL
)
if
(
LabelItem
->
m_LabelType
==
TYPE_SCH_HIERLABEL
)
labeltype
=
wxT
(
"Hierarchical"
);
labeltype
=
wxT
(
"Hierarchical"
);
else
else
labeltype
=
wxT
(
"Global "
);
labeltype
=
wxT
(
"Global "
);
sheetpath
=
CONV_FROM_UTF8
(
LabelItem
->
m_SheetPath
);
sheetpath
=
CONV_FROM_UTF8
(
LabelItem
->
m_SheetPath
);
msg
.
Printf
(
msg
.
Printf
(
_
(
"> %-28.28s %s (Sheet %s) pos: %3.3f, %3.3f
\n
"
),
_
(
"> %-28.28s %s (Sheet %s) pos: %3.3f, %3.3f
\n
"
),
DrawTextItem
->
m_Text
.
GetData
(),
DrawTextItem
->
m_Text
.
GetData
(),
labeltype
.
GetData
(),
labeltype
.
GetData
(),
sheetpath
.
GetData
(),
sheetpath
.
GetData
(),
(
float
)
DrawTextItem
->
m_Pos
.
x
/
1000
,
(
float
)
DrawTextItem
->
m_Pos
.
x
/
1000
,
(
float
)
DrawTextItem
->
m_Pos
.
y
/
1000
);
(
float
)
DrawTextItem
->
m_Pos
.
y
/
1000
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
break
;
break
;
case
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
:
case
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
:
{
{
DrawSheetLabel
=
(
Hierarchical_PIN_Sheet_Struct
*
)
LabelItem
->
m_Label
;
DrawSheetLabel
=
(
Hierarchical_PIN_Sheet_Struct
*
)
LabelItem
->
m_Label
;
jj
=
DrawSheetLabel
->
m_Shape
;
jj
=
DrawSheetLabel
->
m_Shape
;
if
(
jj
<
0
)
if
(
jj
<
0
)
jj
=
NET_TMAX
;
jj
=
NET_TMAX
;
if
(
jj
>
NET_TMAX
)
if
(
jj
>
NET_TMAX
)
jj
=
4
;
jj
=
4
;
wxString
labtype
=
CONV_FROM_UTF8
(
SheetLabelType
[
jj
]
);
wxString
labtype
=
CONV_FROM_UTF8
(
SheetLabelType
[
jj
]
);
msg
.
Printf
(
msg
.
Printf
(
_
(
"> %-28.28s PinSheet %-7.7s (Sheet %s) pos: %3.3f, %3.3f
\n
"
),
_
(
"> %-28.28s PinSheet %-7.7s (Sheet %s) pos: %3.3f, %3.3f
\n
"
),
DrawSheetLabel
->
m_Text
.
GetData
(),
DrawSheetLabel
->
m_Text
.
GetData
(),
labtype
.
GetData
(),
labtype
.
GetData
(),
LabelItem
->
m_SheetPath
,
LabelItem
->
m_SheetPath
,
(
float
)
DrawSheetLabel
->
m_Pos
.
x
/
1000
,
(
float
)
DrawSheetLabel
->
m_Pos
.
x
/
1000
,
(
float
)
DrawSheetLabel
->
m_Pos
.
y
/
1000
);
(
float
)
DrawSheetLabel
->
m_Pos
.
y
/
1000
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
}
}
break
;
break
;
default
:
default
:
break
;
break
;
}
}
}
}
msg
=
_
(
"#End labels
\n
"
);
msg
=
_
(
"#End labels
\n
"
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
return
0
;
return
0
;
}
}
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