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
9ec6139f
Commit
9ec6139f
authored
Jul 17, 2012
by
Marco Mattila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edit eeschema single part per line sorting code.
parent
9d8c684a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
49 deletions
+46
-49
component_references_lister.cpp
eeschema/component_references_lister.cpp
+39
-30
dialog_build_BOM.cpp
eeschema/dialogs/dialog_build_BOM.cpp
+7
-19
No files found.
eeschema/component_references_lister.cpp
View file @
9ec6139f
...
@@ -242,6 +242,18 @@ static bool engStrToDouble( wxString aStr, double* aDouble )
...
@@ -242,6 +242,18 @@ static bool engStrToDouble( wxString aStr, double* aDouble )
}
}
static
bool
splitRefStr
(
const
wxString
&
aRef
,
wxString
*
aStr
,
int
*
aNumber
)
{
static
wxRegEx
refRegEx
(
wxT
(
"^([a-zA-Z]+)([0-9]+)"
)
);
if
(
!
refRegEx
.
Matches
(
aRef
)
)
return
false
;
*
aStr
=
refRegEx
.
GetMatch
(
aRef
,
1
);
*
aNumber
=
wxAtoi
(
refRegEx
.
GetMatch
(
aRef
,
2
)
);
return
true
;
}
/* sort the list of references by value.
/* sort the list of references by value.
* Components are grouped by type and are sorted by value:
* Components are grouped by type and are sorted by value:
* The value of a component accept multiplier symbols (p, n, K ..)
* The value of a component accept multiplier symbols (p, n, K ..)
...
@@ -250,28 +262,22 @@ static bool engStrToDouble( wxString aStr, double* aDouble )
...
@@ -250,28 +262,22 @@ static bool engStrToDouble( wxString aStr, double* aDouble )
bool
SCH_REFERENCE_LIST
::
sortByValueOnly
(
const
SCH_REFERENCE
&
item1
,
bool
SCH_REFERENCE_LIST
::
sortByValueOnly
(
const
SCH_REFERENCE
&
item1
,
const
SCH_REFERENCE
&
item2
)
const
SCH_REFERENCE
&
item2
)
{
{
// First, group by type, assuming 2 first letter of references
// First, group by type according to reference text part (R, C, etc.)
// are different for different types of components.
wxString
text1
=
item1
.
GetComponent
()
->
GetField
(
REFERENCE
)
->
GetText
();
wxString
text1
=
item1
.
GetComponent
()
->
GetField
(
REFERENCE
)
->
GetText
().
Left
(
2
);
wxString
text2
=
item2
.
GetComponent
()
->
GetField
(
REFERENCE
)
->
GetText
();
wxString
text2
=
item2
.
GetComponent
()
->
GetField
(
REFERENCE
)
->
GetText
().
Left
(
2
);
wxString
refNameStr1
,
refNameStr2
;
if
(
text1
[
0
]
!=
text2
[
0
]
)
int
refNumber1
,
refNumber2
;
return
text1
[
0
]
<
text2
[
0
];
// Compare the second letter, if exists
if
(
text1
.
length
()
>
1
&&
text2
.
length
()
>
1
)
{
if
(
(
text1
[
1
]
<
'0'
)
||
(
text1
[
1
]
>
'9'
)
||
(
text2
[
1
]
<
'0'
)
||
(
text2
[
1
]
>
'9'
)
)
return
text1
[
1
]
<
text2
[
1
];
}
if
(
!
splitRefStr
(
text1
,
&
refNameStr1
,
&
refNumber1
)
)
return
false
;
// Inside a group of components of same value, it could be good to group per footprints
if
(
!
splitRefStr
(
text2
,
&
refNameStr2
,
&
refNumber2
)
)
text1
=
item1
.
GetComponent
()
->
GetField
(
FOOTPRINT
)
->
GetText
();
return
false
;
text2
=
item2
.
GetComponent
()
->
GetField
(
FOOTPRINT
)
->
GetText
();
int
same_footprint
=
text1
.
IsEmpty
()
||
text2
.
IsEmpty
();
int
ii
=
refNameStr1
.
CmpNoCase
(
refNameStr2
);
if
(
same_footprint
==
0
)
same_footprint
=
text1
.
CmpNoCase
(
text2
);
if
(
ii
!=
0
)
return
ii
<
0
;
// We can compare here 2 values relative to components of the same type
// We can compare here 2 values relative to components of the same type
// assuming references are correctly chosen
// assuming references are correctly chosen
...
@@ -292,25 +298,28 @@ bool SCH_REFERENCE_LIST::sortByValueOnly( const SCH_REFERENCE& item1,
...
@@ -292,25 +298,28 @@ bool SCH_REFERENCE_LIST::sortByValueOnly( const SCH_REFERENCE& item1,
if
(
!
match1
&&
match2
)
if
(
!
match1
&&
match2
)
return
false
;
return
false
;
if
(
match1
&&
match2
)
if
(
match1
&&
match2
&&
(
value1
!=
value2
)
)
{
if
(
value1
==
value2
)
return
same_footprint
<
0
;
return
value1
<
value2
;
return
value1
<
value2
;
}
// Inside a group of components of same value, it could be good to group per footprints
text1
=
item1
.
GetComponent
()
->
GetField
(
FOOTPRINT
)
->
GetText
();
text2
=
item2
.
GetComponent
()
->
GetField
(
FOOTPRINT
)
->
GetText
();
ii
=
text1
.
CmpNoCase
(
text2
);
if
(
ii
!=
0
)
return
ii
<
0
;
if
(
refNumber1
!=
refNumber2
)
return
refNumber1
<
refNumber2
;
// Fall back to normal string compare
// Fall back to normal string compare
i
nt
i
i
=
text1
.
CmpNoCase
(
text2
);
ii
=
text1
.
CmpNoCase
(
text2
);
if
(
ii
==
0
)
if
(
ii
==
0
)
{
ii
=
RefDesStringCompare
(
item1
.
GetRef
(),
item2
.
GetRef
()
);
ii
=
RefDesStringCompare
(
item1
.
GetRef
(),
item2
.
GetRef
()
);
}
if
(
ii
==
0
)
if
(
ii
==
0
)
{
ii
=
item1
.
m_Unit
-
item2
.
m_Unit
;
ii
=
item1
.
m_Unit
-
item2
.
m_Unit
;
}
return
ii
<
0
;
return
ii
<
0
;
}
}
...
...
eeschema/dialogs/dialog_build_BOM.cpp
View file @
9ec6139f
...
@@ -872,14 +872,14 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST
...
@@ -872,14 +872,14 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST
while
(
index
<
aList
.
GetCount
()
)
while
(
index
<
aList
.
GetCount
()
)
{
{
SCH_COMPONENT
*
component
=
aList
[
index
].
GetComponent
();
SCH_COMPONENT
*
component
=
aList
[
index
].
GetComponent
();
wx
ArrayString
referenceStrList
;
wx
String
referenceListStr
;
int
qty
=
1
;
int
qty
=
1
;
reference
StrList
.
Ad
d
(
aList
[
index
].
GetRef
()
);
reference
ListStr
.
appen
d
(
aList
[
index
].
GetRef
()
);
for
(
unsigned
int
i
=
index
+
1
;
i
<
aList
.
GetCount
();
)
for
(
unsigned
int
i
=
index
+
1
;
i
<
aList
.
GetCount
();
)
{
{
if
(
*
(
aList
[
i
].
GetComponent
())
==
*
component
)
if
(
*
(
aList
[
i
].
GetComponent
())
==
*
component
)
{
{
reference
StrList
.
Add
(
aList
[
i
].
GetRef
()
);
reference
ListStr
.
append
(
wxT
(
" "
)
+
aList
[
i
].
GetRef
()
);
aList
.
RemoveItem
(
i
);
aList
.
RemoveItem
(
i
);
qty
++
;
qty
++
;
}
}
...
@@ -887,22 +887,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST
...
@@ -887,22 +887,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST
i
++
;
// Increment index only when current item is not removed from the list
i
++
;
// Increment index only when current item is not removed from the list
}
}
referenceStrList
.
Sort
(
RefDesStringCompare
);
// Sort references for this component
// Write value, quantity and list of references
fprintf
(
aFile
,
"%15s%c%3d%c
\"
%s
\"
"
,
TO_UTF8
(
component
->
GetField
(
VALUE
)
->
GetText
()
),
// Write value, quantity
s_ExportSeparatorSymbol
,
qty
,
fprintf
(
aFile
,
"%15s%c%3d"
,
TO_UTF8
(
component
->
GetField
(
VALUE
)
->
GetText
()
),
s_ExportSeparatorSymbol
,
TO_UTF8
(
referenceListStr
)
);
s_ExportSeparatorSymbol
,
qty
);
// Write list of references
for
(
int
i
=
0
;
i
<
referenceStrList
.
Count
();
i
++
)
{
if
(
i
==
0
)
fprintf
(
aFile
,
"%c
\"
%s"
,
s_ExportSeparatorSymbol
,
TO_UTF8
(
referenceStrList
[
i
]
)
);
else
fprintf
(
aFile
,
" %s"
,
TO_UTF8
(
referenceStrList
[
i
]
)
);
}
if
(
referenceStrList
.
Count
()
)
fprintf
(
aFile
,
"
\"
"
);
// Write the rest of the fields if required
// Write the rest of the fields if required
#if defined( KICAD_GOST )
#if defined( KICAD_GOST )
...
...
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