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
6b500d60
Commit
6b500d60
authored
Apr 28, 2013
by
Lorenzo Marcantonio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted macros to inline template function
parent
3b1ddd95
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
77 deletions
+59
-77
common.h
include/common.h
+0
-2
macros.h
include/macros.h
+57
-71
class_track.cpp
pcbnew/class_track.cpp
+0
-2
editrack.cpp
pcbnew/editrack.cpp
+1
-1
specctra_import.cpp
pcbnew/specctra_import.cpp
+1
-1
No files found.
include/common.h
View file @
6b500d60
...
...
@@ -116,8 +116,6 @@ enum pseudokeys {
#define TEXT_ORIENT_HORIZ 0
#define TEXT_ORIENT_VERT 900
#define ON 1
#define OFF 0
//-----<KiROUND KIT>------------------------------------------------------------
...
...
include/macros.h
View file @
6b500d60
...
...
@@ -13,6 +13,8 @@
* converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
* wxstring is a wxString, not a wxT() or _(). The scope of the return value
* is very limited and volatile, but can be used with printf() style functions well.
* NOTE: Trying to convert it to a function is tricky because of the
* type of the parameter!
*/
#define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() )
...
...
@@ -20,7 +22,6 @@
* function FROM_UTF8
* converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
*/
//#define FROM_UTF8( cstring ) wxString::FromUTF8( cstring )
static
inline
wxString
FROM_UTF8
(
const
char
*
cstring
)
{
wxString
line
=
wxString
::
FromUTF8
(
cstring
);
...
...
@@ -56,82 +57,67 @@ static inline const wxChar* GetChars( const wxString& s )
#endif
}
#define NEGATE( x ) (x = -x)
// This really need a function? anyway is used *a lot* of times
template
<
class
T
>
inline
void
NEGATE
(
T
&
x
)
{
x
=
-
x
;
}
/// # of elements in an array
#define DIM( x ) unsigned( sizeof(x) / sizeof( (x)[0] ) ) // not size_t
inline
double
DEG2RAD
(
double
deg
)
{
return
deg
*
M_PI
/
180
.
0
;
}
inline
double
RAD2DEG
(
double
rad
)
{
return
rad
*
180
.
0
/
M_PI
;
}
#define DEG2RAD( Deg ) ( (Deg) * M_PI / 180.0 )
#define RAD2DEG( Rad ) ( (Rad) * 180.0 / M_PI )
// Normalize angle to be in the -360.0 .. 360.0:
#define NORMALIZE_ANGLE_360( Angle ) { \
while( Angle < -3600 ) \
Angle += 3600; \
while( Angle > 3600 ) \
Angle -= 3600; }
/* Normalize angle to be in the 0.0 .. 360.0 range: */
#define NORMALIZE_ANGLE_POS( Angle ) { \
while( Angle < 0 ) \
Angle += 3600; \
while( Angle >= 3600 ) \
Angle -= 3600; }
#define NEGATE_AND_NORMALIZE_ANGLE_POS( Angle ) { \
Angle = -Angle; \
while( Angle < 0 ) \
Angle += 3600; \
while( Angle >= 3600 ) \
Angle -= 3600; }
/* Normalize angle to be in the -90.0 .. 90.0 range */
#define NORMALIZE_ANGLE_90( Angle ) { \
while( Angle < -900 ) \
Angle += 1800; \
while( Angle > 900 ) \
Angle -= 1800; }
/* Normalize angle to be in the -180.0 .. 180.0 range */
#define NORMALIZE_ANGLE_180( Angle ) { \
while( Angle <= -1800 ) \
Angle += 3600; \
while( Angle > 1800 ) \
Angle -= 3600; }
/*****************************/
/* macro to exchange 2 items */
/*****************************/
/*
* The EXCHG macro uses BOOST_TYPEOF for compilers that do not have native
* typeof support (MSVC). Please do not attempt to qualify these macros
* within #ifdef compiler definitions pragmas. BOOST_TYPEOF is smart enough
* to check for native typeof support and use it instead of it's own
* implementation. These macros effectively compile to nothing on platforms
* with native typeof support.
*/
/// Normalize angle to be in the -360.0 .. 360.0:
template
<
class
T
>
inline
void
NORMALIZE_ANGLE_360
(
T
&
Angle
)
{
while
(
Angle
<
-
3600
)
Angle
+=
3600
;
while
(
Angle
>
3600
)
Angle
-=
3600
;
}
/// Normalize angle to be in the 0.0 .. 360.0 range:
template
<
class
T
>
inline
void
NORMALIZE_ANGLE_POS
(
T
&
Angle
)
{
while
(
Angle
<
0
)
Angle
+=
3600
;
while
(
Angle
>=
3600
)
Angle
-=
3600
;
}
template
<
class
T
>
inline
void
NEGATE_AND_NORMALIZE_ANGLE_POS
(
T
&
Angle
)
{
Angle
=
-
Angle
;
while
(
Angle
<
0
)
Angle
+=
3600
;
while
(
Angle
>=
3600
)
Angle
-=
3600
;
}
/// Normalize angle to be in the -90.0 .. 90.0 range
template
<
class
T
>
inline
void
NORMALIZE_ANGLE_90
(
T
&
Angle
)
{
while
(
Angle
<
-
900
)
Angle
+=
1800
;
while
(
Angle
>
900
)
Angle
-=
1800
;
}
#include <boost/typeof/typeof.hpp>
// we have to register the types used with the typeof keyword with boost
BOOST_TYPEOF_REGISTER_TYPE
(
wxPoint
)
BOOST_TYPEOF_REGISTER_TYPE
(
wxSize
)
BOOST_TYPEOF_REGISTER_TYPE
(
wxString
)
class
DrawSheetLabelStruct
;
BOOST_TYPEOF_REGISTER_TYPE
(
DrawSheetLabelStruct
*
)
class
EDA_ITEM
;
BOOST_TYPEOF_REGISTER_TYPE
(
EDA_ITEM
*
)
class
D_PAD
;
BOOST_TYPEOF_REGISTER_TYPE
(
D_PAD
*
)
BOOST_TYPEOF_REGISTER_TYPE
(
const
D_PAD
*
)
class
BOARD_ITEM
;
BOOST_TYPEOF_REGISTER_TYPE
(
BOARD_ITEM
*
)
#define EXCHG( a, b ) { BOOST_TYPEOF( a ) __temp__ = (a); \
(a) = (b); \
(b) = __temp__; }
/// Normalize angle to be in the -180.0 .. 180.0 range
template
<
class
T
>
inline
void
NORMALIZE_ANGLE_180
(
T
&
Angle
)
{
while
(
Angle
<=
-
1800
)
Angle
+=
3600
;
while
(
Angle
>
1800
)
Angle
-=
3600
;
}
/// Exchange two values; std::swap works only with arguments of the
// same type; here the compiler will figure out what to do (I hope)
template
<
class
T
,
class
T2
>
inline
void
EXCHG
(
T
&
a
,
T2
&
b
)
{
T
temp
=
a
;
a
=
b
;
b
=
temp
;
}
#endif
/* ifdef MACRO_H */
pcbnew/class_track.cpp
View file @
6b500d60
...
...
@@ -162,8 +162,6 @@ wxString SEGZONE::GetSelectMenuText() const
NETINFO_ITEM
*
net
;
BOARD
*
board
=
GetBoard
();
text
<<
_
(
"Zone"
)
<<
wxT
(
" "
)
<<
wxString
::
Format
(
wxT
(
"(%08lX)"
),
m_TimeStamp
);
if
(
board
)
{
net
=
board
->
FindNet
(
GetNet
()
);
...
...
pcbnew/editrack.cpp
View file @
6b500d60
pcbnew/specctra_import.cpp
View file @
6b500d60
...
...
@@ -320,7 +320,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
else
// VIA_MICROVIA or VIA_BLIND_BURIED
{
LAYER_NUM
topLayerNdx
=
UNDEFINED_LAYER
;
LAYER_NUM
botLayerNdx
=
7000
;
LAYER_NUM
botLayerNdx
=
7000
;
// Ask Dick if this number loses its magic
int
viaDiam
=
-
1
;
for
(
int
i
=
0
;
i
<
shapeCount
;
++
i
)
...
...
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