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
441e0317
Commit
441e0317
authored
Jan 16, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added iterators for NETINFO_LIST (as net codes for existing net codes may be not consecutive).
parent
af7520cc
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
29 deletions
+115
-29
class_board.cpp
pcbnew/class_board.cpp
+4
-3
class_board.h
pcbnew/class_board.h
+18
-0
class_netclass.cpp
pcbnew/class_netclass.cpp
+20
-18
class_netinfo.h
pcbnew/class_netinfo.h
+60
-0
class_netinfolist.cpp
pcbnew/class_netinfolist.cpp
+2
-2
kicad_plugin.cpp
pcbnew/kicad_plugin.cpp
+11
-6
No files found.
pcbnew/class_board.cpp
View file @
441e0317
...
@@ -1440,10 +1440,11 @@ int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCoun
...
@@ -1440,10 +1440,11 @@ int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCoun
netBuffer
.
reserve
(
m_NetInfo
.
GetNetCount
()
);
netBuffer
.
reserve
(
m_NetInfo
.
GetNetCount
()
);
for
(
unsigned
ii
=
1
;
ii
<
m_NetInfo
.
GetNetCount
();
ii
++
)
for
(
NETINFO_LIST
::
iterator
net
(
m_NetInfo
.
begin
()
),
netEnd
(
m_NetInfo
.
end
()
);
net
!=
netEnd
;
++
net
)
{
{
if
(
m_NetInfo
.
GetNetItem
(
ii
)
->
GetNet
()
>
0
)
if
(
net
->
GetNet
()
>
0
)
netBuffer
.
push_back
(
m_NetInfo
.
GetNetItem
(
ii
)
);
netBuffer
.
push_back
(
*
net
);
}
}
// sort the list
// sort the list
...
...
pcbnew/class_board.h
View file @
441e0317
...
@@ -845,6 +845,24 @@ public:
...
@@ -845,6 +845,24 @@ public:
m_NetInfo
.
AppendNet
(
aNewNet
);
m_NetInfo
.
AppendNet
(
aNewNet
);
}
}
/**
* Function BeginNets
* @return iterator to the first element of the NETINFO_ITEMs list
*/
NETINFO_LIST
::
iterator
BeginNets
()
const
{
return
m_NetInfo
.
begin
();
}
/**
* Function EndNets
* @return iterator to the last element of the NETINFO_ITEMs list
*/
NETINFO_LIST
::
iterator
EndNets
()
const
{
return
m_NetInfo
.
end
();
}
/**
/**
* Function GetNetCount
* Function GetNetCount
* @return the number of nets (NETINFO_ITEM)
* @return the number of nets (NETINFO_ITEM)
...
...
pcbnew/class_netclass.cpp
View file @
441e0317
...
@@ -203,11 +203,9 @@ void BOARD::SynchronizeNetsAndNetClasses()
...
@@ -203,11 +203,9 @@ void BOARD::SynchronizeNetsAndNetClasses()
// set all NETs to the default NETCLASS, then later override some
// set all NETs to the default NETCLASS, then later override some
// as we go through the NETCLASSes.
// as we go through the NETCLASSes.
int
count
=
m_NetInfo
.
GetNetCount
(
);
for
(
NETINFO_LIST
::
iterator
net
(
m_NetInfo
.
begin
()
),
netEnd
(
m_NetInfo
.
end
()
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
net
!=
netEnd
;
++
net
)
{
{
NETINFO_ITEM
*
net
=
FindNet
(
i
);
if
(
net
)
net
->
SetClass
(
m_NetClasses
.
GetDefault
()
);
net
->
SetClass
(
m_NetClasses
.
GetDefault
()
);
}
}
...
@@ -248,10 +246,8 @@ void BOARD::SynchronizeNetsAndNetClasses()
...
@@ -248,10 +246,8 @@ void BOARD::SynchronizeNetsAndNetClasses()
m_NetClasses
.
GetDefault
()
->
Clear
();
m_NetClasses
.
GetDefault
()
->
Clear
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
for
(
NETINFO_LIST
::
iterator
net
(
m_NetInfo
.
begin
()
),
netEnd
(
m_NetInfo
.
end
()
);
{
net
!=
netEnd
;
++
net
)
NETINFO_ITEM
*
net
=
FindNet
(
i
);
if
(
net
)
{
{
const
wxString
&
classname
=
net
->
GetClassName
();
const
wxString
&
classname
=
net
->
GetClassName
();
...
@@ -263,7 +259,6 @@ void BOARD::SynchronizeNetsAndNetClasses()
...
@@ -263,7 +259,6 @@ void BOARD::SynchronizeNetsAndNetClasses()
netclass
->
Add
(
net
->
GetNetname
()
);
netclass
->
Add
(
net
->
GetNetname
()
);
}
}
}
// D(printf("stop\n");)
// D(printf("stop\n");)
}
}
...
@@ -337,8 +332,15 @@ void NETCLASS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
...
@@ -337,8 +332,15 @@ void NETCLASS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter
->
Print
(
aNestLevel
+
1
,
"(uvia_dia %s)
\n
"
,
FMT_IU
(
GetuViaDiameter
()
).
c_str
()
);
aFormatter
->
Print
(
aNestLevel
+
1
,
"(uvia_dia %s)
\n
"
,
FMT_IU
(
GetuViaDiameter
()
).
c_str
()
);
aFormatter
->
Print
(
aNestLevel
+
1
,
"(uvia_drill %s)
\n
"
,
FMT_IU
(
GetuViaDrill
()
).
c_str
()
);
aFormatter
->
Print
(
aNestLevel
+
1
,
"(uvia_drill %s)
\n
"
,
FMT_IU
(
GetuViaDrill
()
).
c_str
()
);
for
(
NETCLASS
::
const_iterator
it
=
begin
();
it
!=
end
();
++
it
)
for
(
NETCLASS
::
const_iterator
it
=
begin
();
it
!=
end
();
++
it
)
{
NETINFO_ITEM
*
netinfo
=
m_Parent
->
FindNet
(
*
it
);
if
(
netinfo
&&
netinfo
->
GetNodesCount
()
>
0
)
{
aFormatter
->
Print
(
aNestLevel
+
1
,
"(add_net %s)
\n
"
,
aFormatter
->
Quotew
(
*
it
).
c_str
()
);
aFormatter
->
Print
(
aNestLevel
+
1
,
"(add_net %s)
\n
"
,
aFormatter
->
Quotew
(
*
it
).
c_str
()
);
}
}
aFormatter
->
Print
(
aNestLevel
,
")
\n\n
"
);
aFormatter
->
Print
(
aNestLevel
,
")
\n\n
"
);
}
}
pcbnew/class_netinfo.h
View file @
441e0317
...
@@ -214,6 +214,66 @@ public:
...
@@ -214,6 +214,66 @@ public:
typedef
boost
::
unordered_map
<
const
wxString
,
NETINFO_ITEM
*
,
WXSTRING_HASH
>
NETNAMES_MAP
;
typedef
boost
::
unordered_map
<
const
wxString
,
NETINFO_ITEM
*
,
WXSTRING_HASH
>
NETNAMES_MAP
;
typedef
boost
::
unordered_map
<
const
int
,
NETINFO_ITEM
*>
NETCODES_MAP
;
typedef
boost
::
unordered_map
<
const
int
,
NETINFO_ITEM
*>
NETCODES_MAP
;
///> Wrapper class, so you can iterate through NETINFO_ITEM*s, not
///> std::pair<int/wxString, NETINFO_ITEM*>
class
iterator
{
public
:
iterator
(
NETNAMES_MAP
::
const_iterator
aIter
)
:
m_iterator
(
aIter
)
{
}
/// pre-increment operator
const
iterator
&
operator
++
()
{
++
m_iterator
;
return
*
this
;
}
/// post-increment operator
iterator
operator
++
(
int
)
{
iterator
ret
=
*
this
;
++
m_iterator
;
return
ret
;
}
NETINFO_ITEM
*
operator
*
()
const
{
return
m_iterator
->
second
;
}
NETINFO_ITEM
*
operator
->
()
const
{
return
m_iterator
->
second
;
}
bool
operator
!=
(
const
iterator
&
aOther
)
const
{
return
m_iterator
!=
aOther
.
m_iterator
;
}
bool
operator
==
(
const
iterator
&
aOther
)
const
{
return
m_iterator
==
aOther
.
m_iterator
;
}
private
:
NETNAMES_MAP
::
const_iterator
m_iterator
;
};
iterator
begin
()
const
{
return
iterator
(
m_netNames
.
begin
()
);
}
iterator
end
()
const
{
return
iterator
(
m_netNames
.
end
()
);
}
private
:
private
:
/**
/**
* Function DeleteData
* Function DeleteData
...
...
pcbnew/class_netinfolist.cpp
View file @
441e0317
...
@@ -90,8 +90,8 @@ void NETINFO_LIST::buildListOfNets()
...
@@ -90,8 +90,8 @@ void NETINFO_LIST::buildListOfNets()
buildPadsFullList
();
buildPadsFullList
();
// Restore the initial state of NETINFO_ITEMs
// Restore the initial state of NETINFO_ITEMs
for
(
unsigned
i
=
0
;
i
<
GetNetCount
();
++
i
)
for
(
NETINFO_LIST
::
iterator
net
(
begin
()
),
netEnd
(
end
()
);
net
!=
netEnd
;
++
net
)
GetNetItem
(
i
)
->
Clear
();
net
->
Clear
();
// Assign pads to appropriate NETINFO_ITEMs
// Assign pads to appropriate NETINFO_ITEMs
for
(
unsigned
ii
=
0
;
ii
<
m_PadsFullList
.
size
();
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
m_PadsFullList
.
size
();
ii
++
)
...
...
pcbnew/kicad_plugin.cpp
View file @
441e0317
...
@@ -654,15 +654,20 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
...
@@ -654,15 +654,20 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out
->
Print
(
aNestLevel
,
")
\n\n
"
);
m_out
->
Print
(
aNestLevel
,
")
\n\n
"
);
int
netcount
=
aBoard
->
GetNetCount
();
// Unconditionally save the unconnected net
m_out
->
Print
(
aNestLevel
,
"(net 0
\"\"
)
\n
"
);
for
(
int
i
=
0
;
i
<
netcount
;
++
i
)
// and now the rest of nets
for
(
NETINFO_LIST
::
iterator
net
(
aBoard
->
BeginNet
()
),
netEnd
(
aBoard
->
EndNet
()
);
net
!=
netEnd
;
++
net
)
{
if
(
net
->
GetNodesCount
()
>
0
)
// save only not empty nets
{
{
NETINFO_ITEM
*
net
=
aBoard
->
FindNet
(
i
);
m_out
->
Print
(
aNestLevel
,
"(net %d %s)
\n
"
,
m_out
->
Print
(
aNestLevel
,
"(net %d %s)
\n
"
,
net
->
GetNet
(),
net
->
GetNet
(),
m_out
->
Quotew
(
net
->
GetNetname
()
).
c_str
()
);
m_out
->
Quotew
(
net
->
GetNetname
()
).
c_str
()
);
}
}
}
m_out
->
Print
(
0
,
"
\n
"
);
m_out
->
Print
(
0
,
"
\n
"
);
...
...
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