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
5d7410c9
Commit
5d7410c9
authored
Aug 03, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Plain Diff
Put netform.cpp functions into a class so scratch memory objects can be freed.
Improve code performance and appearance
parents
74b675c1
7146863b
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
459 additions
and
356 deletions
+459
-356
string.cpp
common/string.cpp
+110
-0
build_BOM.cpp
eeschema/build_BOM.cpp
+0
-125
class_drawsheetpath.cpp
eeschema/class_drawsheetpath.cpp
+14
-3
class_drawsheetpath.h
eeschema/class_drawsheetpath.h
+3
-3
class_netlist_object.cpp
eeschema/class_netlist_object.cpp
+1
-1
class_netlist_object.h
eeschema/class_netlist_object.h
+14
-0
class_pin.cpp
eeschema/class_pin.cpp
+0
-6
class_pin.h
eeschema/class_pin.h
+7
-1
classes_body_items.h
eeschema/classes_body_items.h
+2
-0
netform.cpp
eeschema/netform.cpp
+270
-203
netlist.cpp
eeschema/netlist.cpp
+1
-1
common.h
include/common.h
+1
-1
kicad_string.h
include/kicad_string.h
+23
-1
macros.h
include/macros.h
+13
-11
No files found.
common/string.cpp
View file @
5d7410c9
...
...
@@ -320,3 +320,113 @@ char* strupper( char* Text )
return
Text
;
}
int
RefDesStringCompare
(
const
wxString
&
strFWord
,
const
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 */
// Split the two strings into separate 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 their 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
)
{
// Clear all the return strings
strBeginning
->
Empty
();
strDigits
->
Empty
();
strEnd
->
Empty
();
// 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/build_BOM.cpp
View file @
5d7410c9
...
...
@@ -71,12 +71,6 @@ static bool SortLabelsBySheet( const LABEL_OBJECT& obj1,
static
void
DeleteSubCmp
(
std
::
vector
<
OBJ_CMP_TO_LIST
>&
aList
);
static
int
PrintListeGLabel
(
FILE
*
f
,
std
::
vector
<
LABEL_OBJECT
>&
aList
);
int
RefDesStringCompare
(
const
wxString
&
lhs
,
const
wxString
&
rhs
);
int
SplitString
(
wxString
strToSplit
,
wxString
*
strBeginning
,
wxString
*
strDigits
,
wxString
*
strEnd
);
// separator used in bom export to spreadsheet
static
char
s_ExportSeparatorSymbol
;
...
...
@@ -1049,122 +1043,3 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
}
/* 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
*/
int
RefDesStringCompare
(
const
wxString
&
strFWord
,
const
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 */
// Split the two string into separate 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
;
}
/* 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
*/
int
SplitString
(
wxString
strToSplit
,
wxString
*
strBeginning
,
wxString
*
strDigits
,
wxString
*
strEnd
)
{
// 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/class_drawsheetpath.cpp
View file @
5d7410c9
...
...
@@ -220,7 +220,7 @@ wxString SCH_SHEET_PATH::Path()
* (the "normal" path uses the time stamps which do not changes even when
* editing sheet parameters)
*/
wxString
SCH_SHEET_PATH
::
PathHumanReadable
()
wxString
SCH_SHEET_PATH
::
PathHumanReadable
()
const
{
wxString
s
,
t
;
...
...
@@ -355,6 +355,7 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData,
bool
SCH_SHEET_PATH
::
operator
=
(
const
SCH_SHEET_PATH
&
d1
)
{
m_numSheets
=
d1
.
m_numSheets
;
unsigned
i
;
for
(
i
=
0
;
i
<
m_numSheets
;
i
++
)
{
...
...
@@ -370,10 +371,11 @@ bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 )
}
bool
SCH_SHEET_PATH
::
operator
==
(
const
SCH_SHEET_PATH
&
d1
)
bool
SCH_SHEET_PATH
::
operator
==
(
const
SCH_SHEET_PATH
&
d1
)
const
{
if
(
m_numSheets
!=
d1
.
m_numSheets
)
return
false
;
for
(
unsigned
i
=
0
;
i
<
m_numSheets
;
i
++
)
{
if
(
m_sheets
[
i
]
!=
d1
.
m_sheets
[
i
]
)
...
...
@@ -384,15 +386,24 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 )
}
bool
SCH_SHEET_PATH
::
operator
!=
(
const
SCH_SHEET_PATH
&
d1
)
bool
SCH_SHEET_PATH
::
operator
!=
(
const
SCH_SHEET_PATH
&
d1
)
const
{
if
(
m_numSheets
!=
d1
.
m_numSheets
)
return
true
;
for
(
unsigned
i
=
0
;
i
<
m_numSheets
;
i
++
)
{
if
(
m_sheets
[
i
]
!=
d1
.
m_sheets
[
i
]
)
{
/*
printf( "micompare this:'%s' d1:'%s'\n",
CONV_TO_UTF8( PathHumanReadable() ),
CONV_TO_UTF8( d1.PathHumanReadable() ) );
*/
return
true
;
}
}
return
false
;
}
...
...
eeschema/class_drawsheetpath.h
View file @
5d7410c9
...
...
@@ -150,7 +150,7 @@ public:
* stamps in the path. (Time stamps do not change even when editing
* sheet parameters).
*/
wxString
PathHumanReadable
();
wxString
PathHumanReadable
()
const
;
/** Function BuildSheetPathInfoFromSheetPathValue
* Fill this with data to access to the hierarchical sheet known by its
...
...
@@ -207,9 +207,9 @@ public:
bool
operator
=
(
const
SCH_SHEET_PATH
&
d1
);
bool
operator
==
(
const
SCH_SHEET_PATH
&
d1
);
bool
operator
==
(
const
SCH_SHEET_PATH
&
d1
)
const
;
bool
operator
!=
(
const
SCH_SHEET_PATH
&
d1
);
bool
operator
!=
(
const
SCH_SHEET_PATH
&
d1
)
const
;
};
...
...
eeschema/class_netlist_object.cpp
View file @
5d7410c9
...
...
@@ -10,7 +10,6 @@
#include "class_netlist_object.h"
#if defined(DEBUG)
#include <iostream>
const
char
*
ShowType
(
NetObjetType
aType
)
...
...
@@ -134,3 +133,4 @@ NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
NETLIST_OBJECT
::~
NETLIST_OBJECT
()
{
}
eeschema/class_netlist_object.h
View file @
5d7410c9
...
...
@@ -6,6 +6,9 @@
#ifndef _CLASS_NETLIST_OBJECT_H_
#define _CLASS_NETLIST_OBJECT_H_
#include "class_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum )
/* Type of Net objects (wires, labels, pins...) */
enum
NetObjetType
{
NET_ITEM_UNSPECIFIED
,
// only for not yet initialized instances
...
...
@@ -105,6 +108,17 @@ public:
void
SetNet
(
int
aNetCode
)
{
m_NetCode
=
aNetCode
;
}
int
GetNet
()
const
{
return
m_NetCode
;
}
/**
* Function GetPinNum
* returns a pin number in wxString form. Pin numbers are not always
* numbers. "A23" would be a valid pin number.
*/
wxString
GetPinNumText
()
{
// hide the ugliness in here, but do it inline.
return
LIB_PIN
::
ReturnPinStringNum
(
m_PinNum
);
}
};
#endif // _CLASS_NETLIST_OBJECT_H_
eeschema/class_pin.cpp
View file @
5d7410c9
...
...
@@ -1485,12 +1485,6 @@ wxString LIB_PIN::ReturnPinStringNum( long aPinNum )
}
wxString
LIB_PIN
::
GetNumber
(
void
)
{
return
ReturnPinStringNum
(
m_PinNum
);
}
/** Function LIB_PIN::SetPinNumFromString()
* fill the buffer with pin num as a wxString
* Pin num is coded as a long
...
...
eeschema/class_pin.h
View file @
5d7410c9
...
...
@@ -7,6 +7,7 @@
#ifndef CLASS_PIN_H
#define CLASS_PIN_H
#include "classes_body_items.h"
#define TARGET_PIN_DIAM 12
/* Circle diameter drawn at the active end of
* pins */
...
...
@@ -159,7 +160,12 @@ public:
*/
void
ReturnPinStringNum
(
wxString
&
aStringBuffer
)
const
;
wxString
GetNumber
();
wxString
GetNumber
()
{
return
ReturnPinStringNum
(
m_PinNum
);
}
/** Function ReturnPinStringNum (static function)
* Pin num is coded as a long or 4 ascii chars
...
...
eeschema/classes_body_items.h
View file @
5d7410c9
...
...
@@ -7,6 +7,8 @@
#ifndef CLASSES_BODY_ITEMS_H
#define CLASSES_BODY_ITEMS_H
#include "base_struct.h"
class
LIB_COMPONENT
;
class
PLOTTER
;
...
...
eeschema/netform.cpp
View file @
5d7410c9
This diff is collapsed.
Click to expand it.
eeschema/netlist.cpp
View file @
5d7410c9
...
...
@@ -18,7 +18,7 @@
// Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST
g_NetObjectslist
;
//
#define NETLIST_DEBUG
#define NETLIST_DEBUG
static
void
PropageNetCode
(
int
OldNetCode
,
int
NewNetCode
,
int
IsBus
);
static
void
SheetLabelConnect
(
NETLIST_OBJECT
*
SheetLabel
);
...
...
include/common.h
View file @
5d7410c9
...
...
@@ -382,4 +382,4 @@ void MyFree( void* pt_mem );
void
*
MyZMalloc
(
size_t
nb_octets
);
void
*
MyMalloc
(
size_t
nb_octets
);
#endif
/
* __INCLUDE__COMMON_H__ */
#endif /
/ __INCLUDE__COMMON_H__
include/kicad_string.h
View file @
5d7410c9
...
...
@@ -79,5 +79,27 @@ bool WildCompareString( const wxString& pattern,
*/
char
*
to_point
(
char
*
Text
);
/**
* Function RefDesStringCompare
* acts just like the strcmp function but treats numbers within the string text
* correctly for sorting. eg. A10 > A2
* 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
*/
int
RefDesStringCompare
(
const
wxString
&
lhs
,
const
wxString
&
rhs
);
/**
* Function SplitString
* breaks a string into three parts.
* The alphabetic preamble
* The numeric part
* Any alphabetic ending
* For example C10A is split to C 10 A
*/
int
SplitString
(
wxString
strToSplit
,
wxString
*
strBeginning
,
wxString
*
strDigits
,
wxString
*
strEnd
);
#endif
/
* __INCLUDE__KICAD_STRING_H__ */
#endif /
/ __INCLUDE__KICAD_STRING_H__
include/macros.h
View file @
5d7410c9
...
...
@@ -16,20 +16,22 @@
/**
* Function GetChars
* returns a pointer to the actual character data, either 8 or
* 16 bits wide, depending on how the wxWidgets library was compiled.
* returns a wxChar* to the actual character data within a wxString, and is
* helpful for passing strings to wxString::Printf(wxT("%s"), GetChars(wxString) )
* <p>
* wxChar is defined to be <ul>
* <li> standard C style char when wxUSE_UNICODE==0 </li>
* <li> wchar_t when wxUSE_UNICODE==1 (the default). </li>
* <ul>
* i.e. it depends on how the wxWidgets library was compiled. There was a period
* during the development of wxWidgets 2.9 when GetData() was missing, so this
* function was used to provide insulation from that design change. It may
* no longer be needed, and is harmless. GetData() seems to be an acceptable
* alternative in all cases now.
*/
static
inline
const
wxChar
*
GetChars
(
wxString
s
)
static
inline
const
wxChar
*
GetChars
(
const
wxString
&
s
)
{
#if wxCHECK_VERSION( 2, 9, 0 )
/* To be Fixed:
* Currently, access to the actual character data in <wxString::Printf
* is a moving target
* So, with wxWidgets 2.9.0 this line is subject to change:
*/
// return (const wxChar*) s.wx_str();
return
(
const
wxChar
*
)
s
.
c_str
();
#else
return
s
.
GetData
();
...
...
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