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
Hide 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
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
)
netBuffer
.
push_back
(
m_NetInfo
.
GetNetItem
(
ii
)
);
if
(
net
->
GetNet
()
>
0
)
netBuffer
.
push_back
(
*
net
);
}
// sort the list
...
...
pcbnew/class_board.h
View file @
441e0317
...
...
@@ -845,6 +845,24 @@ public:
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
* @return the number of nets (NETINFO_ITEM)
...
...
pcbnew/class_netclass.cpp
View file @
441e0317
...
...
@@ -203,12 +203,10 @@ void BOARD::SynchronizeNetsAndNetClasses()
// set all NETs to the default NETCLASS, then later override some
// as we go through the NETCLASSes.
int
count
=
m_NetInfo
.
GetNetCount
(
);
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
)
net
->
SetClass
(
m_NetClasses
.
GetDefault
()
);
net
->
SetClass
(
m_NetClasses
.
GetDefault
()
);
}
// Add netclass name and pointer to nets. If a net is in more than one netclass,
...
...
@@ -248,21 +246,18 @@ void BOARD::SynchronizeNetsAndNetClasses()
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
();
// because of the std:map<> this should be fast, and because of
// prior logic, netclass should not be NULL.
NETCLASS
*
netclass
=
m_NetClasses
.
Find
(
classname
);
// because of the std:map<> this should be fast, and because of
// prior logic, netclass should not be NULL.
NETCLASS
*
netclass
=
m_NetClasses
.
Find
(
classname
);
wxASSERT
(
netclass
);
wxASSERT
(
netclass
);
netclass
->
Add
(
net
->
GetNetname
()
);
}
netclass
->
Add
(
net
->
GetNetname
()
);
}
// D(printf("stop\n");)
...
...
@@ -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_drill %s)
\n
"
,
FMT_IU
(
GetuViaDrill
()
).
c_str
()
);
for
(
NETCLASS
::
const_iterator
it
=
begin
();
it
!=
end
();
++
it
)
aFormatter
->
Print
(
aNestLevel
+
1
,
"(add_net %s)
\n
"
,
aFormatter
->
Quotew
(
*
it
).
c_str
()
);
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
,
")
\n\n
"
);
}
pcbnew/class_netinfo.h
View file @
441e0317
...
...
@@ -214,6 +214,66 @@ public:
typedef
boost
::
unordered_map
<
const
wxString
,
NETINFO_ITEM
*
,
WXSTRING_HASH
>
NETNAMES_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
:
/**
* Function DeleteData
...
...
pcbnew/class_netinfolist.cpp
View file @
441e0317
...
...
@@ -90,8 +90,8 @@ void NETINFO_LIST::buildListOfNets()
buildPadsFullList
();
// Restore the initial state of NETINFO_ITEMs
for
(
unsigned
i
=
0
;
i
<
GetNetCount
();
++
i
)
GetNetItem
(
i
)
->
Clear
();
for
(
NETINFO_LIST
::
iterator
net
(
begin
()
),
netEnd
(
end
()
);
net
!=
netEnd
;
++
net
)
net
->
Clear
();
// Assign pads to appropriate NETINFO_ITEMs
for
(
unsigned
ii
=
0
;
ii
<
m_PadsFullList
.
size
();
ii
++
)
...
...
pcbnew/kicad_plugin.cpp
View file @
441e0317
...
...
@@ -654,14 +654,19 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
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
)
{
NETINFO_ITEM
*
net
=
aBoard
->
FindNet
(
i
);
m_out
->
Print
(
aNestLevel
,
"(net %d %s)
\n
"
,
net
->
GetNet
(),
m_out
->
Quotew
(
net
->
GetNetname
()
).
c_str
()
);
if
(
net
->
GetNodesCount
()
>
0
)
// save only not empty nets
{
m_out
->
Print
(
aNestLevel
,
"(net %d %s)
\n
"
,
net
->
GetNet
(),
m_out
->
Quotew
(
net
->
GetNetname
()
).
c_str
()
);
}
}
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