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
97884551
Commit
97884551
authored
Feb 22, 2012
by
Marco Mattila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make single part per line BOM generation compare all component fields.
parent
0a68744e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
135 deletions
+63
-135
component_references_lister.cpp
eeschema/component_references_lister.cpp
+7
-0
dialog_build_BOM.cpp
eeschema/dialogs/dialog_build_BOM.cpp
+30
-135
netlist.h
eeschema/netlist.h
+2
-0
sch_component.cpp
eeschema/sch_component.cpp
+21
-0
sch_component.h
eeschema/sch_component.h
+3
-0
No files found.
eeschema/component_references_lister.cpp
View file @
97884551
...
@@ -42,6 +42,13 @@
...
@@ -42,6 +42,13 @@
//#define USE_OLD_ALGO
//#define USE_OLD_ALGO
void
SCH_REFERENCE_LIST
::
RemoveItem
(
int
aIndex
)
{
if
(
aIndex
<
componentFlatList
.
size
()
)
componentFlatList
.
erase
(
componentFlatList
.
begin
()
+
aIndex
);
}
bool
SCH_REFERENCE_LIST
::
sortByXPosition
(
const
SCH_REFERENCE
&
item1
,
bool
SCH_REFERENCE_LIST
::
sortByXPosition
(
const
SCH_REFERENCE
&
item1
,
const
SCH_REFERENCE
&
item2
)
const
SCH_REFERENCE
&
item2
)
{
{
...
...
eeschema/dialogs/dialog_build_BOM.cpp
View file @
97884551
...
@@ -852,150 +852,45 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
...
@@ -852,150 +852,45 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
}
}
/* Bom Output format option - single part per line
int
DIALOG_BUILD_BOM
::
PrintComponentsListByPart
(
FILE
*
aFile
,
SCH_REFERENCE_LIST
&
aList
,
* a common part being defined as have a common value.
* This is true for most designs but will produce an
* incorrect output if two or more parts with the same
* value have different footprints, tolerances, voltage
* rating, etc. Also useful if the following fields
* are edited:
* FIELD1 - manufacture
* FIELD2 - manufacture part number
* FIELD3 - distributor part number
*/
int
DIALOG_BUILD_BOM
::
PrintComponentsListByPart
(
FILE
*
f
,
SCH_REFERENCE_LIST
&
aList
,
bool
aIncludeSubComponents
)
bool
aIncludeSubComponents
)
{
{
int
qty
=
0
;
int
index
=
0
;
wxString
refName
;
while
(
index
<
aList
.
GetCount
()
)
wxString
fullRefName
;
// reference + part Id (for multiple parts per package
wxString
valName
;
#if defined(KICAD_GOST)
wxString
footName
;
wxString
datsName
;
#endif
wxString
refNames
;
wxString
lastRef
;
wxString
unitId
;
SCH_COMPONENT
*
currCmp
;
SCH_COMPONENT
*
nextCmp
;
SCH_COMPONENT
dummyCmp
;
// A dummy component, to store fields
for
(
unsigned
ii
=
0
;
ii
<
aList
.
GetCount
();
ii
++
)
{
{
currCmp
=
aList
[
ii
].
GetComponent
();
SCH_COMPONENT
*
component
=
aList
[
index
].
GetComponent
();
wxString
referenceListStr
;
if
(
ii
<
aList
.
GetCount
()
-
1
)
int
qty
=
1
;
nextCmp
=
aList
[
ii
+
1
].
GetComponent
();
referenceListStr
.
append
(
aList
[
index
].
GetRef
()
);
else
for
(
unsigned
int
i
=
index
+
1
;
i
<
aList
.
GetCount
();
)
nextCmp
=
NULL
;
// Store fields. Store non empty fields only.
for
(
int
jj
=
FOOTPRINT
;
jj
<
currCmp
->
GetFieldCount
();
jj
++
)
{
{
// Ensure fields exists in dummy component
if
(
*
(
aList
[
i
].
GetComponent
())
==
*
component
)
if
(
dummyCmp
.
GetFieldCount
()
<=
jj
)
{
dummyCmp
.
AddField
(
*
currCmp
->
GetField
(
jj
)
);
referenceListStr
.
append
(
wxT
(
" "
)
+
aList
[
i
].
GetRef
()
);
aList
.
RemoveItem
(
i
);
// store useful data
qty
++
;
if
(
!
currCmp
->
GetField
(
jj
)
->
m_Text
.
IsEmpty
()
)
}
dummyCmp
.
GetField
(
jj
)
->
m_Text
=
currCmp
->
GetField
(
jj
)
->
m_Text
;
else
i
++
;
// Increment index only when current item is not removed from the list
}
}
refName
=
aList
[
ii
].
GetRef
();
// Write value, quantity and list of references
valName
=
currCmp
->
GetField
(
VALUE
)
->
m_Text
;
fprintf
(
aFile
,
"%15s%c%3d%c
\"
%s
\"
"
,
TO_UTF8
(
component
->
GetField
(
VALUE
)
->
GetText
()
),
s_ExportSeparatorSymbol
,
qty
,
s_ExportSeparatorSymbol
,
TO_UTF8
(
referenceListStr
)
);
#if defined(KICAD_GOST)
// Write the rest of the fields if required
footName
=
currCmp
->
GetField
(
FOOTPRINT
)
->
m_Text
;
#if defined( KICAD_GOST )
datsName
=
currCmp
->
GetField
(
DATASHEET
)
->
m_Text
;
fprintf
(
aFile
,
"%c%20s"
,
s_ExportSeparatorSymbol
,
TO_UTF8
(
component
->
GetField
(
DATASHEET
)
->
GetText
()
)
);
#endif
#endif
for
(
int
i
=
FOOTPRINT
;
i
<
component
->
GetFieldCount
();
i
++
)
int
multi
=
0
;
if
(
IsFieldChecked
(
i
)
)
fprintf
(
aFile
,
"%c%15s"
,
s_ExportSeparatorSymbol
,
if
(
aIncludeSubComponents
)
TO_UTF8
(
component
->
GetField
(
i
)
->
GetText
()
)
);
{
fprintf
(
aFile
,
"
\n
"
);
LIB_COMPONENT
*
entry
=
CMP_LIBRARY
::
FindLibraryComponent
(
currCmp
->
GetLibName
()
);
index
++
;
if
(
entry
)
multi
=
entry
->
GetPartCount
();
if
(
multi
<=
1
)
multi
=
0
;
}
if
(
multi
&&
aList
[
ii
].
GetUnit
()
>
0
)
unitId
.
Printf
(
wxT
(
"%c"
),
'A'
-
1
+
aList
[
ii
].
GetUnit
()
);
else
unitId
.
Empty
();
fullRefName
=
refName
+
unitId
;
if
(
refNames
.
IsEmpty
()
)
refNames
=
fullRefName
;
else
refNames
<<
wxT
(
", "
)
<<
fullRefName
;
// In multi parts per package, we have the reference more than once
// but we must count only one package
if
(
lastRef
!=
refName
)
qty
++
;
lastRef
=
refName
;
// if the next component has same value the line will be printed after.
#if defined(KICAD_GOST)
if
(
nextCmp
&&
nextCmp
->
GetField
(
VALUE
)
->
m_Text
.
CmpNoCase
(
valName
)
==
0
&&
nextCmp
->
GetField
(
FOOTPRINT
)
->
m_Text
.
CmpNoCase
(
footName
)
==
0
&&
nextCmp
->
GetField
(
DATASHEET
)
->
m_Text
.
CmpNoCase
(
datsName
)
==
0
)
#else
if
(
nextCmp
&&
nextCmp
->
GetField
(
VALUE
)
->
m_Text
.
CmpNoCase
(
valName
)
==
0
)
#endif
continue
;
// Print line for the current component value:
fprintf
(
f
,
"%15s%c%3d"
,
TO_UTF8
(
valName
),
s_ExportSeparatorSymbol
,
qty
);
if
(
IsFieldChecked
(
FOOTPRINT
)
)
fprintf
(
f
,
"%c%15s"
,
s_ExportSeparatorSymbol
,
#if defined(KICAD_GOST)
TO_UTF8
(
footName
)
);
#else
TO_UTF8
(
currCmp
->
GetField
(
FOOTPRINT
)
->
m_Text
)
);
#endif
#if defined(KICAD_GOST)
fprintf
(
f
,
"%c%20s"
,
s_ExportSeparatorSymbol
,
TO_UTF8
(
datsName
)
);
#endif
// wrap the field in quotes, since it has commas in it.
fprintf
(
f
,
"%c
\"
%s
\"
"
,
s_ExportSeparatorSymbol
,
TO_UTF8
(
refNames
)
);
// print fields, on demand
int
last_nonempty_field_idx
=
0
;
for
(
int
jj
=
FOOTPRINT
;
jj
<
dummyCmp
.
GetFieldCount
();
jj
++
)
{
if
(
!
dummyCmp
.
GetField
(
jj
)
->
m_Text
.
IsEmpty
()
)
last_nonempty_field_idx
=
jj
;
}
for
(
int
jj
=
FIELD1
;
jj
<=
last_nonempty_field_idx
;
jj
++
)
{
if
(
IsFieldChecked
(
jj
)
)
fprintf
(
f
,
"%c%4s"
,
s_ExportSeparatorSymbol
,
TO_UTF8
(
dummyCmp
.
GetField
(
jj
)
->
m_Text
)
);
}
fprintf
(
f
,
"
\n
"
);
// Clear strings and values, to prepare next component
qty
=
0
;
refNames
.
Empty
();
for
(
int
jj
=
FOOTPRINT
;
jj
<
dummyCmp
.
GetFieldCount
();
jj
++
)
dummyCmp
.
GetField
(
jj
)
->
m_Text
.
Empty
();
}
}
return
0
;
return
0
;
}
}
...
...
eeschema/netlist.h
View file @
97884551
...
@@ -220,6 +220,8 @@ public:
...
@@ -220,6 +220,8 @@ public:
componentFlatList
.
push_back
(
aItem
);
componentFlatList
.
push_back
(
aItem
);
}
}
void
RemoveItem
(
int
aIndex
);
/**
/**
* Function RemoveSubComponentsFromList
* Function RemoveSubComponentsFromList
* Remove sub components from the list, when multiples parts per package are
* Remove sub components from the list, when multiples parts per package are
...
...
eeschema/sch_component.cpp
View file @
97884551
...
@@ -1780,6 +1780,27 @@ bool SCH_COMPONENT::operator <( const SCH_ITEM& aItem ) const
...
@@ -1780,6 +1780,27 @@ bool SCH_COMPONENT::operator <( const SCH_ITEM& aItem ) const
}
}
bool
SCH_COMPONENT
::
operator
==
(
const
SCH_COMPONENT
&
aComponent
)
const
{
if
(
GetFieldCount
()
!=
aComponent
.
GetFieldCount
()
)
return
false
;
for
(
int
i
=
VALUE
;
i
<
GetFieldCount
();
i
++
)
{
if
(
GetField
(
i
)
->
GetText
().
Cmp
(
aComponent
.
GetField
(
i
)
->
GetText
()
)
!=
0
)
return
false
;
}
return
true
;
}
bool
SCH_COMPONENT
::
operator
!=
(
const
SCH_COMPONENT
&
aComponent
)
const
{
return
!
(
*
this
==
aComponent
);
}
SCH_ITEM
&
SCH_COMPONENT
::
operator
=
(
const
SCH_ITEM
&
aItem
)
SCH_ITEM
&
SCH_COMPONENT
::
operator
=
(
const
SCH_ITEM
&
aItem
)
{
{
wxCHECK_MSG
(
Type
()
==
aItem
.
Type
(),
*
this
,
wxCHECK_MSG
(
Type
()
==
aItem
.
Type
(),
*
this
,
...
...
eeschema/sch_component.h
View file @
97884551
...
@@ -401,6 +401,9 @@ public:
...
@@ -401,6 +401,9 @@ public:
virtual
bool
operator
<
(
const
SCH_ITEM
&
aItem
)
const
;
virtual
bool
operator
<
(
const
SCH_ITEM
&
aItem
)
const
;
bool
operator
==
(
const
SCH_COMPONENT
&
aComponent
)
const
;
bool
operator
!=
(
const
SCH_COMPONENT
&
aComponent
)
const
;
SCH_ITEM
&
operator
=
(
const
SCH_ITEM
&
aItem
);
SCH_ITEM
&
operator
=
(
const
SCH_ITEM
&
aItem
);
/**
/**
...
...
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