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
e3b63f83
Commit
e3b63f83
authored
May 28, 2008
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c w patch, plus some attempt to move towards C++, removed some capitalized local variables
parent
1acc3813
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
318 additions
and
165 deletions
+318
-165
build_BOM.cpp
eeschema/build_BOM.cpp
+308
-159
netlist.h
eeschema/netlist.h
+10
-6
No files found.
eeschema/build_BOM.cpp
View file @
e3b63f83
...
...
@@ -23,19 +23,25 @@
#define EXT_LIST wxT( ".lst" )
// Exported functions
int
BuildComponentsListFromSchematic
(
ListComponent
*
List
);
int
BuildComponentsListFromSchematic
(
ListComponent
*
a
List
);
/* fonctions locales */
static
int
GenListeGLabels
(
ListLabel
*
List
);
static
int
ListTriComposantByRef
(
ListComponent
*
Objet1
,
ListComponent
*
Objet2
);
static
int
ListTriComposantByVal
(
ListComponent
*
Objet1
,
ListComponent
*
Objet2
);
static
int
ListTriGLabelBySheet
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
);
static
int
ListTriGLabelByVal
(
ListLabel
*
Objet1
,
ListLabel
*
Objet2
);
static
void
DeleteSubCmp
(
ListComponent
*
List
,
int
NbItems
);
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
List
,
int
NbItems
);
static
int
GenListeGLabels
(
ListLabel
*
aList
);
static
int
ListTriComposantByRef
(
ListComponent
*
obj1
,
ListComponent
*
obj2
);
static
int
ListTriComposantByVal
(
ListComponent
*
obj1
,
ListComponent
*
obj2
);
static
int
ListTriGLabelBySheet
(
ListLabel
*
obj1
,
ListLabel
*
obj2
);
static
int
ListTriGLabelByVal
(
ListLabel
*
obj1
,
ListLabel
*
obj2
);
static
void
DeleteSubCmp
(
ListComponent
*
aList
,
int
aItemCount
);
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
aList
,
int
aItemCount
);
int
RefDesStringCompare
(
char
*
obj1
,
char
*
obj2
);
int
SplitString
(
wxString
strToSplit
,
wxString
*
strBeginning
,
wxString
*
strDigits
,
wxString
*
strEnd
);
/* Local variables */
...
...
@@ -95,7 +101,7 @@ void WinEDA_Build_BOM_Frame::Create_BOM_Lists( bool aTypeFileIsExport,
/****************************************************************************/
void
WinEDA_Build_BOM_Frame
::
CreateExportList
(
const
wxString
&
FullFileName
,
void
WinEDA_Build_BOM_Frame
::
CreateExportList
(
const
wxString
&
a
FullFileName
,
bool
aIncludeSubComponents
)
/****************************************************************************/
...
...
@@ -106,42 +112,42 @@ void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& FullFileName,
*/
{
FILE
*
f
;
ListComponent
*
List
;
int
NbItems
;
ListComponent
*
a
List
;
int
itemCount
;
wxString
msg
;
/* Creation de la liste des elements */
if
(
(
f
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
if
(
(
f
=
wxFopen
(
a
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
{
msg
=
_
(
"Failed to open file "
);
msg
<<
FullFileName
;
msg
<<
a
FullFileName
;
DisplayError
(
this
,
msg
);
return
;
}
NbItems
=
BuildComponentsListFromSchematic
(
NULL
);
if
(
NbItems
)
itemCount
=
BuildComponentsListFromSchematic
(
NULL
);
if
(
itemCount
)
{
List
=
(
ListComponent
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListComponent
)
);
if
(
List
==
NULL
)
aList
=
(
ListComponent
*
)
MyZMalloc
(
itemCount
*
sizeof
(
ListComponent
)
);
if
(
a
List
==
NULL
)
{
fclose
(
f
);
return
;
}
BuildComponentsListFromSchematic
(
List
);
BuildComponentsListFromSchematic
(
a
List
);
/* sort component list */
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
qsort
(
aList
,
itemCount
,
sizeof
(
ListComponent
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByRef
);
if
(
!
aIncludeSubComponents
)
DeleteSubCmp
(
List
,
NbItems
);
DeleteSubCmp
(
aList
,
itemCount
);
/* create the file */
PrintComponentsListByRef
(
f
,
List
,
NbItems
,
TRUE
,
aIncludeSubComponents
);
PrintComponentsListByRef
(
f
,
aList
,
itemCount
,
TRUE
,
aIncludeSubComponents
);
MyFree
(
List
);
MyFree
(
a
List
);
}
fclose
(
f
);
...
...
@@ -149,7 +155,7 @@ void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& FullFileName,
/****************************************************************************/
void
WinEDA_Build_BOM_Frame
::
GenereListeOfItems
(
const
wxString
&
FullFileName
,
void
WinEDA_Build_BOM_Frame
::
GenereListeOfItems
(
const
wxString
&
a
FullFileName
,
bool
aIncludeSubComponents
)
/****************************************************************************/
...
...
@@ -159,32 +165,32 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& FullFileName,
*/
{
FILE
*
f
;
ListComponent
*
L
ist
;
ListLabel
*
L
istOfLabels
;
int
NbItems
;
ListComponent
*
l
ist
;
ListLabel
*
l
istOfLabels
;
int
itemCount
;
char
Line
[
1024
];
wxString
msg
;
/* Creation de la liste des elements */
if
(
(
f
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
if
(
(
f
=
wxFopen
(
a
FullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
{
msg
=
_
(
"Failed to open file "
);
msg
<<
FullFileName
;
msg
<<
a
FullFileName
;
DisplayError
(
this
,
msg
);
return
;
}
NbItems
=
BuildComponentsListFromSchematic
(
NULL
);
if
(
NbItems
)
itemCount
=
BuildComponentsListFromSchematic
(
NULL
);
if
(
itemCount
)
{
List
=
(
ListComponent
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListComponent
)
);
if
(
L
ist
==
NULL
)
// Error memory alloc
list
=
(
ListComponent
*
)
MyZMalloc
(
itemCount
*
sizeof
(
ListComponent
)
);
if
(
l
ist
==
NULL
)
// Error memory alloc
{
fclose
(
f
);
return
;
}
BuildComponentsListFromSchematic
(
L
ist
);
BuildComponentsListFromSchematic
(
l
ist
);
/* generation du fichier listing */
DateAndTime
(
Line
);
...
...
@@ -193,71 +199,71 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& FullFileName,
/* Tri et impression de la liste des composants */
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
qsort
(
list
,
itemCount
,
sizeof
(
ListComponent
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByRef
);
if
(
!
aIncludeSubComponents
)
DeleteSubCmp
(
List
,
NbItems
);
DeleteSubCmp
(
list
,
itemCount
);
// if( s_ListByRef )
if
(
m_ListCmpbyRefItems
->
GetValue
()
)
{
PrintComponentsListByRef
(
f
,
List
,
NbItems
,
false
,
aIncludeSubComponents
);
PrintComponentsListByRef
(
f
,
list
,
itemCount
,
false
,
aIncludeSubComponents
);
}
// if( s_ListByValue )
if
(
m_ListCmpbyValItems
->
GetValue
()
)
{
qsort
(
List
,
NbItems
,
sizeof
(
ListComponent
),
qsort
(
list
,
itemCount
,
sizeof
(
ListComponent
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriComposantByVal
);
PrintComponentsListByVal
(
f
,
List
,
NbItems
,
aIncludeSubComponents
);
PrintComponentsListByVal
(
f
,
list
,
itemCount
,
aIncludeSubComponents
);
}
MyFree
(
L
ist
);
MyFree
(
l
ist
);
}
/***************************************/
/* Generation liste des Labels globaux */
/***************************************/
NbItems
=
GenListeGLabels
(
NULL
);
if
(
NbItems
)
itemCount
=
GenListeGLabels
(
NULL
);
if
(
itemCount
)
{
ListOfLabels
=
(
ListLabel
*
)
MyZMalloc
(
NbItems
*
sizeof
(
ListLabel
)
);
if
(
L
istOfLabels
==
NULL
)
listOfLabels
=
(
ListLabel
*
)
MyZMalloc
(
itemCount
*
sizeof
(
ListLabel
)
);
if
(
l
istOfLabels
==
NULL
)
{
fclose
(
f
);
return
;
}
GenListeGLabels
(
L
istOfLabels
);
GenListeGLabels
(
l
istOfLabels
);
/* Tri de la liste */
// if( s_ListBySheet )
if
(
m_GenListLabelsbySheet
->
GetValue
()
)
{
qsort
(
ListOfLabels
,
NbItems
,
sizeof
(
ListLabel
),
qsort
(
listOfLabels
,
itemCount
,
sizeof
(
ListLabel
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriGLabelBySheet
);
msg
.
Printf
(
_
(
"
\n
#Global, Hierarchical Labels and PinSheets ( order = Sheet Number ) count = %d
\n
"
),
NbItems
);
itemCount
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
PrintListeGLabel
(
f
,
ListOfLabels
,
NbItems
);
PrintListeGLabel
(
f
,
listOfLabels
,
itemCount
);
}
// if( s_ListHierarchicalPinByName )
if
(
m_GenListLabelsbyVal
->
GetValue
()
)
{
qsort
(
ListOfLabels
,
NbItems
,
sizeof
(
ListLabel
),
qsort
(
listOfLabels
,
itemCount
,
sizeof
(
ListLabel
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
ListTriGLabelByVal
);
msg
.
Printf
(
_
(
"
\n
#Global, Hierarchical Labels and PinSheets ( order = Alphab. ) count = %d
\n\n
"
),
NbItems
);
itemCount
);
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
PrintListeGLabel
(
f
,
ListOfLabels
,
NbItems
);
PrintListeGLabel
(
f
,
listOfLabels
,
itemCount
);
}
MyFree
(
L
istOfLabels
);
MyFree
(
l
istOfLabels
);
}
msg
=
_
(
"
\n
#End List
\n
"
);
...
...
@@ -267,7 +273,7 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& FullFileName,
/*********************************************************/
int
BuildComponentsListFromSchematic
(
ListComponent
*
List
)
int
BuildComponentsListFromSchematic
(
ListComponent
*
a
List
)
/*********************************************************/
/* Creates the list of components found in the whole schematic
...
...
@@ -278,7 +284,7 @@ int BuildComponentsListFromSchematic( ListComponent* List )
* Also Initialise m_Father as pointer pointeur of the SCH_SCREN parent
*/
{
int
I
temCount
=
0
;
int
i
temCount
=
0
;
EDA_BaseStruct
*
SchItem
;
SCH_COMPONENT
*
DrawLibItem
;
DrawSheetPath
*
sheet
;
...
...
@@ -293,28 +299,32 @@ int BuildComponentsListFromSchematic( ListComponent* List )
if
(
SchItem
->
Type
()
!=
TYPE_SCH_COMPONENT
)
continue
;
I
temCount
++
;
i
temCount
++
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
SchItem
;
DrawLibItem
->
m_Parent
=
sheet
->
LastScreen
();
if
(
List
)
if
(
a
List
)
{
List
->
m_Comp
=
DrawLibItem
;
List
->
m_SheetList
=
*
sheet
;
List
->
m_Unit
=
DrawLibItem
->
GetUnitSelection
(
sheet
);
strncpy
(
List
->
m_Ref
,
aList
->
m_Comp
=
DrawLibItem
;
aList
->
m_SheetList
=
*
sheet
;
aList
->
m_Unit
=
DrawLibItem
->
GetUnitSelection
(
sheet
);
strncpy
(
aList
->
m_Ref
,
CONV_TO_UTF8
(
DrawLibItem
->
GetRef
(
sheet
)
),
sizeof
(
List
->
m_Ref
)
);
List
++
;
sizeof
(
aList
->
m_Ref
)
);
// @todo the above line is probably a bug, because it will not always nul terminate m_Ref.
aList
++
;
}
}
}
return
I
temCount
;
return
i
temCount
;
}
/*********************************************/
static
int
GenListeGLabels
(
ListLabel
*
L
ist
)
static
int
GenListeGLabels
(
ListLabel
*
l
ist
)
/*********************************************/
/* Count the Glabels, or fill the list Listwith Glabel pointers
...
...
@@ -322,7 +332,7 @@ static int GenListeGLabels( ListLabel* List )
* Else fill list of Glabels
*/
{
int
I
temCount
=
0
;
int
i
temCount
=
0
;
EDA_BaseStruct
*
DrawList
;
Hierarchical_PIN_Sheet_Struct
*
SheetLabel
;
DrawSheetPath
*
sheet
;
...
...
@@ -340,14 +350,14 @@ static int GenListeGLabels( ListLabel* List )
{
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_GLOBALLABEL
:
I
temCount
++
;
if
(
L
ist
)
i
temCount
++
;
if
(
l
ist
)
{
L
ist
->
m_LabelType
=
DrawList
->
Type
();
snprintf
(
List
->
m_SheetPath
,
sizeof
(
L
ist
->
m_SheetPath
),
l
ist
->
m_LabelType
=
DrawList
->
Type
();
snprintf
(
list
->
m_SheetPath
,
sizeof
(
l
ist
->
m_SheetPath
),
"%s"
,
CONV_TO_UTF8
(
path
)
);
L
ist
->
m_Label
=
DrawList
;
L
ist
++
;
l
ist
->
m_Label
=
DrawList
;
l
ist
++
;
}
break
;
...
...
@@ -357,15 +367,15 @@ static int GenListeGLabels( ListLabel* List )
SheetLabel
=
Sheet
->
m_Label
;
while
(
SheetLabel
!=
NULL
)
{
if
(
L
ist
)
if
(
l
ist
)
{
L
ist
->
m_LabelType
=
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
;
snprintf
(
List
->
m_SheetPath
,
sizeof
(
L
ist
->
m_SheetPath
),
l
ist
->
m_LabelType
=
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
;
snprintf
(
list
->
m_SheetPath
,
sizeof
(
l
ist
->
m_SheetPath
),
"%s"
,
CONV_TO_UTF8
(
path
)
);
L
ist
->
m_Label
=
SheetLabel
;
L
ist
++
;
l
ist
->
m_Label
=
SheetLabel
;
l
ist
++
;
}
I
temCount
++
;
i
temCount
++
;
SheetLabel
=
(
Hierarchical_PIN_Sheet_Struct
*
)
(
SheetLabel
->
Pnext
);
}
}
...
...
@@ -378,13 +388,13 @@ static int GenListeGLabels( ListLabel* List )
}
}
return
I
temCount
;
return
i
temCount
;
}
/**********************************************************/
static
int
ListTriComposantByVal
(
ListComponent
*
Objet
1
,
ListComponent
*
Objet
2
)
static
int
ListTriComposantByVal
(
ListComponent
*
obj
1
,
ListComponent
*
obj
2
)
/**********************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
...
...
@@ -397,31 +407,31 @@ static int ListTriComposantByVal( ListComponent* Objet1,
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
if
(
(
Objet1
==
NULL
)
&&
(
Objet
2
==
NULL
)
)
if
(
(
obj1
==
NULL
)
&&
(
obj
2
==
NULL
)
)
return
0
;
if
(
Objet
1
==
NULL
)
if
(
obj
1
==
NULL
)
return
-
1
;
if
(
Objet
2
==
NULL
)
if
(
obj
2
==
NULL
)
return
1
;
if
(
(
Objet1
->
m_Comp
==
NULL
)
&&
(
Objet
2
->
m_Comp
==
NULL
)
)
if
(
(
obj1
->
m_Comp
==
NULL
)
&&
(
obj
2
->
m_Comp
==
NULL
)
)
return
0
;
if
(
Objet
1
->
m_Comp
==
NULL
)
if
(
obj
1
->
m_Comp
==
NULL
)
return
-
1
;
if
(
Objet
2
->
m_Comp
==
NULL
)
if
(
obj
2
->
m_Comp
==
NULL
)
return
1
;
Text1
=
&
(
Objet
1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
Objet
2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text1
=
&
(
obj
1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
obj
2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
if
(
ii
==
0
)
{
ii
=
strcmp
(
Objet1
->
m_Ref
,
Objet
2
->
m_Ref
);
ii
=
RefDesStringCompare
(
obj1
->
m_Ref
,
obj
2
->
m_Ref
);
}
if
(
ii
==
0
)
{
ii
=
Objet1
->
m_Unit
-
Objet
2
->
m_Unit
;
ii
=
obj1
->
m_Unit
-
obj
2
->
m_Unit
;
}
return
ii
;
...
...
@@ -429,8 +439,8 @@ static int ListTriComposantByVal( ListComponent* Objet1,
/**********************************************************/
static
int
ListTriComposantByRef
(
ListComponent
*
Objet
1
,
ListComponent
*
Objet
2
)
static
int
ListTriComposantByRef
(
ListComponent
*
obj
1
,
ListComponent
*
obj
2
)
/**********************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
...
...
@@ -443,32 +453,32 @@ static int ListTriComposantByRef( ListComponent* Objet1,
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
if
(
(
Objet1
==
NULL
)
&&
(
Objet
2
==
NULL
)
)
if
(
(
obj1
==
NULL
)
&&
(
obj
2
==
NULL
)
)
return
0
;
if
(
Objet
1
==
NULL
)
if
(
obj
1
==
NULL
)
return
-
1
;
if
(
Objet
2
==
NULL
)
if
(
obj
2
==
NULL
)
return
1
;
if
(
(
Objet1
->
m_Comp
==
NULL
)
&&
(
Objet
2
->
m_Comp
==
NULL
)
)
if
(
(
obj1
->
m_Comp
==
NULL
)
&&
(
obj
2
->
m_Comp
==
NULL
)
)
return
0
;
if
(
Objet
1
->
m_Comp
==
NULL
)
if
(
obj
1
->
m_Comp
==
NULL
)
return
-
1
;
if
(
Objet
2
->
m_Comp
==
NULL
)
if
(
obj
2
->
m_Comp
==
NULL
)
return
1
;
ii
=
strcmp
(
Objet1
->
m_Ref
,
Objet
2
->
m_Ref
);
ii
=
RefDesStringCompare
(
obj1
->
m_Ref
,
obj
2
->
m_Ref
);
if
(
ii
==
0
)
{
Text1
=
&
(
Objet
1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
Objet
2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text1
=
&
(
obj
1
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
Text2
=
&
(
obj
2
->
m_Comp
->
m_Field
[
VALUE
].
m_Text
);
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
}
if
(
ii
==
0
)
{
ii
=
Objet1
->
m_Unit
-
Objet
2
->
m_Unit
;
ii
=
obj1
->
m_Unit
-
obj
2
->
m_Unit
;
}
return
ii
;
...
...
@@ -476,7 +486,7 @@ static int ListTriComposantByRef( ListComponent* Objet1,
/******************************************************************/
static
int
ListTriGLabelByVal
(
ListLabel
*
Objet1
,
ListLabel
*
Objet
2
)
static
int
ListTriGLabelByVal
(
ListLabel
*
obj1
,
ListLabel
*
obj
2
)
/*******************************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
...
...
@@ -488,21 +498,21 @@ static int ListTriGLabelByVal( ListLabel* Objet1, ListLabel* Objet2 )
int
ii
;
const
wxString
*
Text1
,
*
Text2
;
if
(
Objet
1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet
1
->
m_Label
)
->
m_Text
;
if
(
obj
1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
obj
1
->
m_Label
)
->
m_Text
;
else
Text1
=
&
(
(
SCH_TEXT
*
)
Objet
1
->
m_Label
)
->
m_Text
;
Text1
=
&
(
(
SCH_TEXT
*
)
obj
1
->
m_Label
)
->
m_Text
;
if
(
Objet
2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet
2
->
m_Label
)
->
m_Text
;
if
(
obj
2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
obj
2
->
m_Label
)
->
m_Text
;
else
Text2
=
&
(
(
SCH_TEXT
*
)
Objet
2
->
m_Label
)
->
m_Text
;
Text2
=
&
(
(
SCH_TEXT
*
)
obj
2
->
m_Label
)
->
m_Text
;
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
if
(
ii
==
0
)
{
ii
=
strcmp
(
Objet1
->
m_SheetPath
,
Objet
2
->
m_SheetPath
);
ii
=
strcmp
(
obj1
->
m_SheetPath
,
obj
2
->
m_SheetPath
);
}
return
ii
;
...
...
@@ -510,7 +520,7 @@ static int ListTriGLabelByVal( ListLabel* Objet1, ListLabel* Objet2 )
/*******************************************************************/
static
int
ListTriGLabelBySheet
(
ListLabel
*
Objet1
,
ListLabel
*
Objet
2
)
static
int
ListTriGLabelBySheet
(
ListLabel
*
obj1
,
ListLabel
*
obj
2
)
/*******************************************************************/
/* Routine de comparaison pour le tri du Tableau par qsort()
...
...
@@ -523,19 +533,19 @@ static int ListTriGLabelBySheet( ListLabel* Objet1, ListLabel* Objet2 )
const
wxString
*
Text1
,
*
Text2
;
ii
=
strcmp
(
Objet1
->
m_SheetPath
,
Objet
2
->
m_SheetPath
);
ii
=
strcmp
(
obj1
->
m_SheetPath
,
obj
2
->
m_SheetPath
);
if
(
ii
==
0
)
{
if
(
Objet
1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet
1
->
m_Label
)
->
m_Text
;
if
(
obj
1
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text1
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
obj
1
->
m_Label
)
->
m_Text
;
else
Text1
=
&
(
(
SCH_TEXT
*
)
Objet
1
->
m_Label
)
->
m_Text
;
Text1
=
&
(
(
SCH_TEXT
*
)
obj
1
->
m_Label
)
->
m_Text
;
if
(
Objet
2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
Objet
2
->
m_Label
)
->
m_Text
;
if
(
obj
2
->
m_LabelType
==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
)
Text2
=
&
(
(
Hierarchical_PIN_Sheet_Struct
*
)
obj
2
->
m_Label
)
->
m_Text
;
else
Text2
=
&
(
(
SCH_TEXT
*
)
Objet
2
->
m_Label
)
->
m_Text
;
Text2
=
&
(
(
SCH_TEXT
*
)
obj
2
->
m_Label
)
->
m_Text
;
ii
=
Text1
->
CmpNoCase
(
*
Text2
);
}
...
...
@@ -545,33 +555,36 @@ static int ListTriGLabelBySheet( ListLabel* Objet1, ListLabel* Objet2 )
/**************************************************************/
static
void
DeleteSubCmp
(
ListComponent
*
List
,
int
NbItems
)
static
void
DeleteSubCmp
(
ListComponent
*
aList
,
int
aItemCount
)
/**************************************************************/
/* 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
*/
{
int
ii
;
SCH_COMPONENT
*
LibItem
;
wxString
OldName
,
C
urrName
;
SCH_COMPONENT
*
libItem
;
wxString
oldName
;
wxString
c
urrName
;
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
int
ii
=
0
;
ii
<
aItemCount
;
ii
++
)
{
LibItem
=
List
[
ii
].
m_Comp
;
if
(
L
ibItem
==
NULL
)
libItem
=
a
List
[
ii
].
m_Comp
;
if
(
l
ibItem
==
NULL
)
continue
;
CurrName
=
CONV_FROM_UTF8
(
List
[
ii
].
m_Ref
);
if
(
!
OldName
.
IsEmpty
()
)
currName
=
CONV_FROM_UTF8
(
aList
[
ii
].
m_Ref
);
if
(
!
oldName
.
IsEmpty
()
)
{
if
(
OldName
==
CurrName
)
// CurrName is a subpart of O
ldName: remove it
if
(
oldName
==
currName
)
// currName is a subpart of o
ldName: remove it
{
List
[
ii
].
m_Comp
=
NULL
;
List
[
ii
].
m_SheetList
.
Clear
();
List
[
ii
].
m_Ref
[
0
]
=
0
;
a
List
[
ii
].
m_Comp
=
NULL
;
a
List
[
ii
].
m_SheetList
.
Clear
();
a
List
[
ii
].
m_Ref
[
0
]
=
0
;
}
}
OldName
=
C
urrName
;
oldName
=
c
urrName
;
}
}
...
...
@@ -581,7 +594,7 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
bool
CompactForm
)
/*******************************************************************************************/
{
wxCheckBox
*
FieldListCtrl
[]
=
{
static
const
wxCheckBox
*
FieldListCtrl
[]
=
{
m_AddField1
,
m_AddField2
,
m_AddField3
,
...
...
@@ -591,8 +604,9 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
m_AddField7
,
m_AddField8
};
int
ii
;
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
0
];
const
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
0
];
if
(
CompactForm
)
{
...
...
@@ -619,7 +633,7 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
/*********************************************************************************************/
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByRef
(
FILE
*
f
,
ListComponent
*
List
,
int
NbItems
,
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByRef
(
FILE
*
f
,
ListComponent
*
aList
,
int
aItemCount
,
bool
CompactForm
,
bool
aIncludeSubComponents
)
/*********************************************************************************************/
...
...
@@ -635,7 +649,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
if
(
CompactForm
)
{
wxCheckBox
*
FieldListCtrl
[
FIELD8
-
FIELD1
+
1
]
=
{
static
const
wxCheckBox
*
FieldListCtrl
[
FIELD8
-
FIELD1
+
1
]
=
{
m_AddField1
,
m_AddField2
,
m_AddField3
,
...
...
@@ -656,11 +670,13 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
for
(
ii
=
FIELD1
;
ii
<=
FIELD8
;
ii
++
)
{
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
ii
-
FIELD1
];
const
wxCheckBox
*
FieldCtrl
=
FieldListCtrl
[
ii
-
FIELD1
];
if
(
FieldCtrl
==
NULL
)
continue
;
if
(
!
FieldCtrl
->
IsChecked
()
)
continue
;
msg
=
_
(
"Field"
);
fprintf
(
f
,
"%c%s%d"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
msg
),
ii
-
FIELD1
+
1
);
}
...
...
@@ -677,9 +693,9 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
}
// Print list of items
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
ii
=
0
;
ii
<
aItemCount
;
ii
++
)
{
DrawList
=
List
[
ii
].
m_Comp
;
DrawList
=
a
List
[
ii
].
m_Comp
;
if
(
DrawList
==
NULL
)
continue
;
...
...
@@ -687,7 +703,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
continue
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
DrawList
;
if
(
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
if
(
a
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
continue
;
Multi
=
0
;
...
...
@@ -697,9 +713,9 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
Multi
=
Entry
->
m_UnitCount
;
if
(
(
Multi
>
1
)
&&
aIncludeSubComponents
)
Unit
=
List
[
ii
].
m_Unit
+
'A'
-
1
;
Unit
=
a
List
[
ii
].
m_Unit
+
'A'
-
1
;
sprintf
(
CmpName
,
"%s"
,
List
[
ii
].
m_Ref
);
sprintf
(
CmpName
,
"%s"
,
a
List
[
ii
].
m_Ref
);
if
(
!
CompactForm
||
Unit
!=
' '
)
sprintf
(
CmpName
+
strlen
(
CmpName
),
"%c"
,
Unit
);
...
...
@@ -712,7 +728,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
if
(
aIncludeSubComponents
)
{
msg
=
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
msg
=
a
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
if
(
CompactForm
)
fprintf
(
f
,
"%c%s"
,
s_ExportSeparatorSymbol
,
CONV_TO_UTF8
(
msg
)
);
else
...
...
@@ -734,17 +750,17 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ListComponent* Li
/*********************************************************************************************/
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByVal
(
FILE
*
f
,
ListComponent
*
List
,
int
NbItems
,
int
WinEDA_Build_BOM_Frame
::
PrintComponentsListByVal
(
FILE
*
f
,
ListComponent
*
aList
,
int
aItemCount
,
bool
aIncludeSubComponents
)
/**********************************************************************************************/
{
int
ii
,
Multi
;
wxChar
Unit
;
int
Multi
;
wxChar
Unit
;
EDA_BaseStruct
*
DrawList
;
SCH_COMPONENT
*
DrawLibItem
;
EDA_LibComponentStruct
*
Entry
;
char
CmpName
[
80
];
wxString
msg
;
char
CmpName
[
80
];
wxString
msg
;
msg
=
_
(
"
\n
#Cmp ( order = Value )"
);
...
...
@@ -753,17 +769,18 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, ListComponent* Li
msg
<<
wxT
(
"
\n
"
);
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
for
(
i
i
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
i
nt
ii
=
0
;
ii
<
aItemCount
;
ii
++
)
{
DrawList
=
List
[
ii
].
m_Comp
;
DrawList
=
a
List
[
ii
].
m_Comp
;
if
(
DrawList
==
NULL
)
continue
;
if
(
DrawList
->
Type
()
!=
TYPE_SCH_COMPONENT
)
continue
;
DrawLibItem
=
(
SCH_COMPONENT
*
)
DrawList
;
if
(
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
if
(
a
List
[
ii
].
m_Ref
[
0
]
==
'#'
)
continue
;
Multi
=
0
;
...
...
@@ -774,16 +791,16 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, ListComponent* Li
if
(
(
Multi
>
1
)
&&
aIncludeSubComponents
)
{
Unit
=
List
[
ii
].
m_Unit
+
'A'
-
1
;
Unit
=
a
List
[
ii
].
m_Unit
+
'A'
-
1
;
}
sprintf
(
CmpName
,
"%s%c"
,
List
[
ii
].
m_Ref
,
Unit
);
sprintf
(
CmpName
,
"%s%c"
,
a
List
[
ii
].
m_Ref
,
Unit
);
fprintf
(
f
,
"| %-12s %-10s"
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
),
CmpName
);
// print the sheet path
if
(
aIncludeSubComponents
)
{
msg
=
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
msg
=
a
List
[
ii
].
m_SheetList
.
PathHumanReadable
();
fprintf
(
f
,
" (Sheet %s)"
,
CONV_TO_UTF8
(
msg
)
);
}
...
...
@@ -799,7 +816,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, ListComponent* Li
/******************************************************************/
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
List
,
int
NbItems
)
static
int
PrintListeGLabel
(
FILE
*
f
,
ListLabel
*
aList
,
int
aItemCount
)
/******************************************************************/
{
int
ii
,
jj
;
...
...
@@ -809,19 +826,21 @@ static int PrintListeGLabel( FILE* f, ListLabel* List, int NbItems )
wxString
msg
,
sheetpath
;
wxString
labeltype
;
for
(
ii
=
0
;
ii
<
NbItems
;
ii
++
)
for
(
ii
=
0
;
ii
<
aItemCount
;
ii
++
)
{
LabelItem
=
&
List
[
ii
];
LabelItem
=
&
a
List
[
ii
];
switch
(
LabelItem
->
m_LabelType
)
{
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_GLOBALLABEL
:
DrawTextItem
=
(
SCH_LABEL
*
)
(
LabelItem
->
m_Label
);
if
(
LabelItem
->
m_LabelType
==
TYPE_SCH_HIERLABEL
)
labeltype
=
wxT
(
"Hierarchical"
);
else
labeltype
=
wxT
(
"Global "
);
sheetpath
=
CONV_FROM_UTF8
(
LabelItem
->
m_SheetPath
);
msg
.
Printf
(
_
(
"> %-28.28s %s (Sheet %s) pos: %3.3f, %3.3f
\n
"
),
...
...
@@ -863,3 +882,133 @@ static int PrintListeGLabel( FILE* f, ListLabel* List, int NbItems )
fprintf
(
f
,
CONV_TO_UTF8
(
msg
)
);
return
0
;
}
/********************************************/
int
RefDesStringCompare
(
char
*
obj1
,
char
*
obj2
)
/********************************************/
/* This function will act just like the strcmp function but correctly sort
* the numerical order in the string
* return -1 if first string is less than the second
* return 0 if the strings are equal
* return 1 if the first string is greater than the second
*/
{
/* The strings we are going to compare */
wxString
strFWord
;
wxString
strSWord
;
/* The different sections of the first string */
wxString
strFWordBeg
,
strFWordMid
,
strFWordEnd
;
/* The different sections of the second string */
wxString
strSWordBeg
,
strSWordMid
,
strSWordEnd
;
int
isEqual
=
0
;
/* The numerical results of a string compare */
int
iReturn
=
0
;
/* The variable that is being returned */
long
lFirstDigit
=
0
;
/* The converted middle section of the first string */
long
lSecondDigit
=
0
;
/* The converted middle section of the second string */
/* Since m_Ref is a char * it is ASCII */
strFWord
=
wxString
::
FromAscii
(
obj1
);
strSWord
=
wxString
::
FromAscii
(
obj2
);
/* Split the two string into seperate parts */
SplitString
(
strFWord
,
&
strFWordBeg
,
&
strFWordMid
,
&
strFWordEnd
);
SplitString
(
strSWord
,
&
strSWordBeg
,
&
strSWordMid
,
&
strSWordEnd
);
/* Compare the Beginning section of the strings */
isEqual
=
strFWordBeg
.
CmpNoCase
(
strSWordBeg
);
if
(
isEqual
>
0
)
iReturn
=
1
;
else
if
(
isEqual
<
0
)
iReturn
=
-
1
;
else
{
/* If the first sections are equal compare there digits */
strFWordMid
.
ToLong
(
&
lFirstDigit
);
strSWordMid
.
ToLong
(
&
lSecondDigit
);
if
(
lFirstDigit
>
lSecondDigit
)
iReturn
=
1
;
else
if
(
lFirstDigit
<
lSecondDigit
)
iReturn
=
-
1
;
else
{
/* If the first two sections are equal compare the endings */
isEqual
=
strFWordEnd
.
CmpNoCase
(
strSWordEnd
);
if
(
isEqual
>
0
)
iReturn
=
1
;
else
if
(
isEqual
<
0
)
iReturn
=
-
1
;
else
iReturn
=
0
;
}
}
return
iReturn
;
}
/**************************************************************************************************/
int
SplitString
(
wxString
strToSplit
,
wxString
*
strBeginning
,
wxString
*
strDigits
,
wxString
*
strEnd
)
/**************************************************************************************************/
/* This is the function that breaks a string into three parts.
* The alphabetic preamble
* The numeric part
* Any alphabetic ending
* For example C10A is split to C 10 A
*/
{
/* Clear all the return strings */
strBeginning
->
Clear
();
strDigits
->
Clear
();
strEnd
->
Clear
();
/* There no need to do anything if the string is empty */
if
(
strToSplit
.
length
()
==
0
)
return
0
;
/* Starting at the end of the string look for the first digit */
int
ii
;
for
(
ii
=
(
strToSplit
.
length
()
-
1
);
ii
>=
0
;
ii
--
)
{
if
(
isdigit
(
strToSplit
[
ii
]
)
)
break
;
}
/* If there were no digits then just set the single string */
if
(
ii
<
0
)
*
strBeginning
=
strToSplit
;
else
{
/* Since there is at least one digit this is the trailing string */
*
strEnd
=
strToSplit
.
substr
(
ii
+
1
);
/* Go to the end of the digits */
int
position
=
ii
+
1
;
for
(
;
ii
>=
0
;
ii
--
)
{
if
(
!
isdigit
(
strToSplit
[
ii
]
)
)
break
;
}
/* If all that was left was digits, then just set the digits string */
if
(
ii
<
0
)
*
strDigits
=
strToSplit
.
substr
(
0
,
position
);
/* We were only looking for the last set of digits everything else is part of the preamble */
else
{
*
strDigits
=
strToSplit
.
substr
(
ii
+
1
,
position
-
ii
-
1
);
*
strBeginning
=
strToSplit
.
substr
(
0
,
ii
+
1
);
}
}
return
0
;
}
eeschema/netlist.h
View file @
e3b63f83
...
...
@@ -14,8 +14,9 @@
#define ISBUS 1
#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
/* Id to select netlist type */
typedef
enu
m
{
enum
TypeNetFor
m
{
NET_TYPE_UNINIT
=
0
,
NET_TYPE_PCBNEW
,
NET_TYPE_ORCADPCB2
,
...
...
@@ -27,7 +28,7 @@ typedef enum {
* is the last id for user netlist format
*/
NET_TYPE_CUSTOM_MAX
=
NET_TYPE_CUSTOM1
+
CUSTOMPANEL_COUNTMAX
-
1
}
TypeNetForm
;
};
/* Max pin number per component and footprint */
...
...
@@ -90,23 +91,26 @@ public:
int
GetNet
()
const
{
return
m_NetCode
;
}
};
/* Structures pour memo et liste des elements */
typedef
struct
ListLabel
struct
ListLabel
{
int
m_LabelType
;
void
*
m_Label
;
char
m_SheetPath
[
256
];
}
ListLabel
;
};
// Used to create lists of components BOM, netlist generation)
typedef
struct
ListComponent
struct
ListComponent
{
SCH_COMPONENT
*
m_Comp
;
// pointer on the component in schematic
char
m_Ref
[
32
];
// component reference
int
m_Unit
;
// Unit value, for multiple parts per package
//have to store it here since the object references will be duplicated.
DrawSheetPath
m_SheetList
;
//composed of UIDs
}
ListComponent
;
};
/* Structure decrivant 1 composant de la schematique (for annotation ) */
struct
CmpListStruct
...
...
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