kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #18953
Re: [PATCH] Cleanup: remove unnecessary macros
On Fri, Jun 26, 2015 at 08:45:08AM +0200, jp charras wrote:
> I am *not* convinced by replacing
> > m_pos.x -= aYaxis_position;
> > NEGATE( m_pos.x );
> > m_pos.x += aYaxis_position;
>
> by
> > m_pos.x = 2 * aYaxis_position - m_pos.x;
>
> When you read the last form, it is not clear this is a mirroring
> relative to the aYaxis_position X position.
>
> At least for me, it is not "a lot clearer...", this is quite the opposite.
>
> Perhaps a macro like MIRROR( m_pos.x, aYaxis_position )
> is "a lot clearer..."
Yup, that's fair. I still think that "m_pos.x = 2 *....." is clearer
than the original, but that's a matter of opinion, and I _do_ like
MIRROR(). That's even clearer still. Done - modified patch attached.
>
> By the way, for me:
> "x = -x" looks better than "x *= -1"
> an should be faster to calculate.
Also done. "x = -x" is more technically correct, so I can appreciate
that (and in the case of C++ objects, will call the correct operator -
unary negation instead of multiplication).
To nitpick a bit, it's NOT faster to calculate. gcc compiles "x *= -1"
to a "negl" instruction just like "x = -x" even on the lowest
optimization setting; clang does not do this optimization on -O0 but
does it on all higher settings. (And even if they didn't perform this
optimization, the difference is _incredibly_ negligible compared to
everything else being done in the vicinity.)
--
Chris
commit 081a9e5958b1b5c0d8553e2a32d311debdc143c1
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
Date: Fri Jun 26 01:28:30 2015 -0400
Remove unnecessary macros EXCHG and NEGATE
diff --git a/3d-viewer/3d_draw_helper_functions.cpp b/3d-viewer/3d_draw_helper_functions.cpp
index 577be18..39fd62e 100644
--- a/3d-viewer/3d_draw_helper_functions.cpp
+++ b/3d-viewer/3d_draw_helper_functions.cpp
@@ -219,7 +219,7 @@ void EDA_3D_CANVAS::draw3DGrid( double aGriSizeMM )
wxSize brd_size = getBoardSize();
wxPoint brd_center_pos = getBoardCenter();
- NEGATE( brd_center_pos.y );
+ brd_center_pos.y = -brd_center_pos.y;
int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp
index 427a094..3150d2c 100644
--- a/common/class_plotter.cpp
+++ b/common/class_plotter.cpp
@@ -150,7 +150,7 @@ void PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int r
const int delta = 50; // increment (in 0.1 degrees) to draw circles
if( StAngle > EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
SetCurrentLineWidth( width );
/* Please NOTE the different sign due to Y-axis flip */
@@ -406,7 +406,7 @@ void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, double orient
if( size.x > size.y )
{
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
}
diff --git a/common/common.cpp b/common/common.cpp
index 6018e71..e00e1d5 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -280,7 +280,7 @@ double RoundTo0( double x, double precision )
long long ix = KiROUND( x * precision );
if ( x < 0.0 )
- NEGATE( ix );
+ ix = -ix;
int remainder = ix % 10; // remainder is in precision mm
@@ -290,7 +290,7 @@ double RoundTo0( double x, double precision )
ix += 10 - remainder; // round to near number
if ( x < 0 )
- NEGATE( ix );
+ ix = -ix;
return (double) ix / precision;
}
diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp
index 545b5ca..da5ef03 100644
--- a/common/common_plotDXF_functions.cpp
+++ b/common/common_plotDXF_functions.cpp
@@ -508,7 +508,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
// If StAngle > EndAngle, it is CW. So transform it to CCW
if( StAngle > EndAngle )
{
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
DPOINT centre_dev = userToDeviceCoordinates( centre );
@@ -536,7 +536,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
* (Oval vertical orientation 0) */
if( size.x > size.y )
{
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
}
diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp
index a2a912f..2e041e6 100644
--- a/common/common_plotGERBER_functions.cpp
+++ b/common/common_plotGERBER_functions.cpp
@@ -459,7 +459,7 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub
&& trace_mode == FILLED )
{
if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
DPOINT pos_dev = userToDeviceCoordinates( pos );
selectAperture( size, APERTURE::Oval );
@@ -469,7 +469,7 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub
{
if( size.x > size.y )
{
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
if( orient < 2700 )
orient += 900;
@@ -512,7 +512,7 @@ void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
{
case 900:
case 2700: // rotation of 90 degrees or 270 swaps sizes
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
// Pass through
case 0:
diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp
index 514b53d..697b1a8 100644
--- a/common/common_plotHPGL_functions.cpp
+++ b/common/common_plotHPGL_functions.cpp
@@ -460,7 +460,7 @@ void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
*/
if( size.x > size.y )
{
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
}
diff --git a/common/common_plotPDF_functions.cpp b/common/common_plotPDF_functions.cpp
index b06950e..3fc8c4f 100644
--- a/common/common_plotPDF_functions.cpp
+++ b/common/common_plotPDF_functions.cpp
@@ -223,7 +223,7 @@ void PDF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
const int delta = 50; // increment (in 0.1 degrees) to draw circles
if( StAngle > EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
SetCurrentLineWidth( width );
diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp
index 409e8d6..22b1de5 100644
--- a/common/common_plotPS_functions.cpp
+++ b/common/common_plotPS_functions.cpp
@@ -98,7 +98,7 @@ void PSLIKE_PLOTTER::FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize,
// The pad is reduced to an oval by dy > dx
if( size.x > size.y )
{
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
aPadOrient = AddAngles( aPadOrient, 900 );
}
@@ -514,7 +514,7 @@ void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
return;
if( StAngle > EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
SetCurrentLineWidth( width );
@@ -528,7 +528,7 @@ void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
{
StAngle = 1800.0 -StAngle;
EndAngle = 1800.0 -EndAngle;
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
else
{
diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp
index e79bcd0..2984660 100644
--- a/common/common_plotSVG_functions.cpp
+++ b/common/common_plotSVG_functions.cpp
@@ -352,7 +352,7 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
return;
if( StAngle > EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
setFillMode( fill );
SetCurrentLineWidth( width );
@@ -374,7 +374,7 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
{
StAngle = 1800.0 -StAngle;
EndAngle = 1800.0 -EndAngle;
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
else
{
diff --git a/common/convert_basic_shapes_to_polygon.cpp b/common/convert_basic_shapes_to_polygon.cpp
index b13e4b6..38c5b79 100644
--- a/common/convert_basic_shapes_to_polygon.cpp
+++ b/common/convert_basic_shapes_to_polygon.cpp
@@ -174,8 +174,8 @@ void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
if( aArcAngle < 0 )
{
- EXCHG( arc_start, arc_end );
- NEGATE( aArcAngle );
+ std::swap( arc_start, arc_end );
+ aArcAngle = -aArcAngle;
}
// Compute the ends of segments and creates poly
diff --git a/common/eda_text.cpp b/common/eda_text.cpp
index 8f49a48..476d7e4 100644
--- a/common/eda_text.cpp
+++ b/common/eda_text.cpp
@@ -477,7 +477,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
wxSize size = GetSize();
if( IsMirrored() )
- NEGATE( size.x );
+ size.x = -size.x;
s_cornerBuffer = &aCornerBuffer;
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText
diff --git a/common/trigo.cpp b/common/trigo.cpp
index f814fd7..4f29125 100644
--- a/common/trigo.cpp
+++ b/common/trigo.cpp
@@ -153,7 +153,7 @@ bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart,
// To have only one case to examine, ensure aEnd.y > aStart.y
if( aEnd.y < aStart.y )
- EXCHG( aStart.y, aEnd.y );
+ std::swap( aStart.y, aEnd.y );
if( aRefPoint.y <= aEnd.y && aRefPoint.y >= aStart.y )
return true;
@@ -186,7 +186,7 @@ bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart,
// To have only one case to examine, ensure xf > xi
if( aEnd.x < aStart.x )
- EXCHG( aStart.x, aEnd.x );
+ std::swap( aStart.x, aEnd.x );
if( aRefPoint.x <= aEnd.x && aRefPoint.x >= aStart.x )
return true;
diff --git a/cvpcb/dialogs/dialog_config_equfiles.cpp b/cvpcb/dialogs/dialog_config_equfiles.cpp
index 807139b..3ae03fd 100644
--- a/cvpcb/dialogs/dialog_config_equfiles.cpp
+++ b/cvpcb/dialogs/dialog_config_equfiles.cpp
@@ -166,7 +166,7 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
- EXCHG( libnames[jj], libnames[jj-1] );
+ std::swap( libnames[jj], libnames[jj-1] );
}
m_ListEquiv->Set( libnames );
@@ -201,7 +201,7 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveDown( wxCommandEvent& event )
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
- EXCHG( libnames[jj], libnames[jj+1]);
+ std::swap( libnames[jj], libnames[jj+1]);
}
m_ListEquiv->Set( libnames );
diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp
index 5fed110..256f74e 100644
--- a/eeschema/block_libedit.cpp
+++ b/eeschema/block_libedit.cpp
@@ -171,7 +171,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
pt = GetScreen()->m_BlockLocate.Centre();
pt = GetNearestGridPosition( pt );
- NEGATE( pt.y );
+ pt.y = -pt.y;
if( GetCurPart() )
{
@@ -261,7 +261,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
SaveCopyInUndoList( GetCurPart() );
pt = GetScreen()->m_BlockLocate.GetMoveVector();
- NEGATE( pt.y );
+ pt.y = -pt.y;
if( GetCurPart() )
GetCurPart()->CopySelectedItems( pt );
@@ -280,7 +280,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
pt = GetScreen()->m_BlockLocate.Centre();
pt = GetNearestGridPosition( pt );
- NEGATE( pt.y );
+ pt.y = -pt.y;
if( GetCurPart() )
{
diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp
index 3052e59..169a28f 100644
--- a/eeschema/class_netlist_object.cpp
+++ b/eeschema/class_netlist_object.cpp
@@ -288,7 +288,7 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem
end = 0;
if( begin > end )
- EXCHG( begin, end );
+ std::swap( begin, end );
member = begin;
tmp = busName;
diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp
index 64bf53b..83d2d14 100644
--- a/eeschema/dialogs/dialog_choose_component.cpp
+++ b/eeschema/dialogs/dialog_choose_component.cpp
@@ -344,9 +344,7 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
dc.SetUserScale( scale, scale );
- wxPoint offset = bBox.Centre();
- NEGATE( offset.x );
- NEGATE( offset.y );
+ wxPoint offset = -bBox.Centre();
// Avoid rendering when either dimension is zero
int width, height;
diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
index 1de0d49..2628be6 100644
--- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
+++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
@@ -726,7 +726,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
// Note: the Y axis for components in lib is from bottom to top
// and the screen axis is top to bottom: we must change the y coord sign for editing
- NEGATE( coord.y );
+ coord.y = -coord.y;
coordText = StringFromValue( g_UserUnit, coord.y );
posYTextCtrl->SetValue( coordText );
}
@@ -798,7 +798,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
// Note: the Y axis for components in lib is from bottom to top
// and the screen axis is top to bottom: we must change the y coord sign for editing
- NEGATE( pos.y );
+ pos.y = -pos.y;
field.SetTextPosition( pos );
diff --git a/eeschema/dialogs/dialog_eeschema_config.cpp b/eeschema/dialogs/dialog_eeschema_config.cpp
index 17d110f..148b035 100644
--- a/eeschema/dialogs/dialog_eeschema_config.cpp
+++ b/eeschema/dialogs/dialog_eeschema_config.cpp
@@ -164,7 +164,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonUpClick( wxCommandEvent& event )
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
- EXCHG( libnames[jj], libnames[jj-1]);
+ std::swap( libnames[jj], libnames[jj-1]);
}
m_ListLibr->Set(libnames);
@@ -198,7 +198,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonDownClick( wxCommandEvent& event )
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
- EXCHG( libnames[jj], libnames[jj+1]);
+ std::swap( libnames[jj], libnames[jj+1]);
}
m_ListLibr->Set( libnames );
diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp
index ad3f5a2..68f52ef 100644
--- a/eeschema/lib_arc.cpp
+++ b/eeschema/lib_arc.cpp
@@ -195,7 +195,7 @@ bool LIB_ARC::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM
// TODO: use aTransMat to calculates parameters
wxPoint relativePosition = aPosition;
- NEGATE( relativePosition.y ); // reverse Y axis
+ relativePosition.y = -relativePosition.y; // reverse Y axis
int distance = KiROUND( GetLineLength( m_Pos, relativePosition ) );
@@ -220,7 +220,7 @@ bool LIB_ARC::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM
// relative to the start point to end point vector lies
if( CrossProduct( startEndVector, startRelativePositionVector ) < 0 )
{
- EXCHG( crossProductStart, crossProductEnd );
+ std::swap( crossProductStart, crossProductEnd );
}
// When the cross products have a different sign, the point lies in sector
@@ -294,8 +294,8 @@ void LIB_ARC::MirrorHorizontal( const wxPoint& aCenter )
m_ArcEnd.x -= aCenter.x;
m_ArcEnd.x *= -1;
m_ArcEnd.x += aCenter.x;
- EXCHG( m_ArcStart, m_ArcEnd );
- EXCHG( m_t1, m_t2 );
+ std::swap( m_ArcStart, m_ArcEnd );
+ std::swap( m_t1, m_t2 );
m_t1 = 1800 - m_t1;
m_t2 = 1800 - m_t2;
if( m_t1 > 3600 || m_t2 > 3600 )
@@ -321,8 +321,8 @@ void LIB_ARC::MirrorVertical( const wxPoint& aCenter )
m_ArcEnd.y -= aCenter.y;
m_ArcEnd.y *= -1;
m_ArcEnd.y += aCenter.y;
- EXCHG( m_ArcStart, m_ArcEnd );
- EXCHG( m_t1, m_t2 );
+ std::swap( m_ArcStart, m_ArcEnd );
+ std::swap( m_t1, m_t2 );
m_t1 = - m_t1;
m_t2 = - m_t2;
if( m_t1 > 3600 || m_t2 > 3600 )
@@ -439,8 +439,8 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
if( swap )
{
- EXCHG( pos1.x, pos2.x );
- EXCHG( pos1.y, pos2.y );
+ std::swap( pos1.x, pos2.x );
+ std::swap( pos1.y, pos2.y );
}
GRSetDrawMode( aDC, aDrawMode );
@@ -515,8 +515,8 @@ start(%d, %d), end(%d, %d), radius %d" ),
if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) )
{
- EXCHG( endPos.x, startPos.x );
- EXCHG( endPos.y, startPos.y );
+ std::swap( endPos.x, startPos.x );
+ std::swap( endPos.y, startPos.y );
}
/* Start with the start and end point of the arc. */
diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp
index a223b34..231f5b6 100644
--- a/eeschema/lib_field.cpp
+++ b/eeschema/lib_field.cpp
@@ -721,7 +721,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
if( m_updateText )
{
- EXCHG( m_Text, m_savedText );
+ std::swap( m_Text, m_savedText );
m_updateText = false;
}
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index 7496009..d1a116d 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -2085,13 +2085,13 @@ const EDA_RECT LIB_PIN::GetBoundingBox() const
case PIN_DOWN:
RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
RotatePoint( &end, wxPoint( 0, 0 ), 900 );
- NEGATE( begin.x );
- NEGATE( end.x );
+ begin.x = -begin.x;
+ end.x = -end.x;
break;
case PIN_LEFT:
- NEGATE( begin.x );
- NEGATE( end.x );
+ begin.x = -begin.x;
+ end.x = -end.x;
break;
case PIN_RIGHT:
diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp
index 3947e2c..10c831b 100644
--- a/eeschema/lib_text.cpp
+++ b/eeschema/lib_text.cpp
@@ -538,7 +538,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
if( m_updateText )
{
- EXCHG( m_Text, m_savedText );
+ std::swap( m_Text, m_savedText );
m_updateText = false;
}
diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp
index 43b344e..90e25da 100644
--- a/eeschema/sch_bitmap.cpp
+++ b/eeschema/sch_bitmap.cpp
@@ -127,8 +127,8 @@ void SCH_BITMAP::SwapData( SCH_ITEM* aItem )
GetChars( aItem->GetClass() ) ) );
SCH_BITMAP* item = (SCH_BITMAP*) aItem;
- EXCHG( m_Pos, item->m_Pos );
- EXCHG( m_Image, item->m_Image );
+ std::swap( m_Pos, item->m_Pos );
+ std::swap( m_Image, item->m_Image );
}
@@ -223,10 +223,7 @@ wxSize SCH_BITMAP::GetSize() const
*/
void SCH_BITMAP::MirrorX( int aXaxis_position )
{
- m_Pos.y -= aXaxis_position;
- NEGATE( m_Pos.y );
- m_Pos.y += aXaxis_position;
-
+ MIRROR( m_Pos.y, aXaxis_position );
m_Image->Mirror( true );
}
@@ -236,9 +233,7 @@ void SCH_BITMAP::MirrorX( int aXaxis_position )
*/
void SCH_BITMAP::MirrorY( int aYaxis_position )
{
- m_Pos.x -= aYaxis_position;
- NEGATE( m_Pos.x );
- m_Pos.x += aYaxis_position;
+ MIRROR( m_Pos.x, aYaxis_position );
m_Image->Mirror( false );
}
diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp
index 52c37b7..0064c34 100644
--- a/eeschema/sch_bus_entry.cpp
+++ b/eeschema/sch_bus_entry.cpp
@@ -89,8 +89,8 @@ void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem )
SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
- EXCHG( m_pos, item->m_pos );
- EXCHG( m_size, item->m_size );
+ std::swap( m_pos, item->m_pos );
+ std::swap( m_size, item->m_size );
}
@@ -215,19 +215,15 @@ void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
void SCH_BUS_ENTRY_BASE::MirrorX( int aXaxis_position )
{
- m_pos.y -= aXaxis_position;
- NEGATE( m_pos.y );
- m_pos.y += aXaxis_position;
- NEGATE( m_size.y );
+ MIRROR( m_pos.y, aXaxis_position );
+ m_size.y = -m_size.y;
}
void SCH_BUS_ENTRY_BASE::MirrorY( int aYaxis_position )
{
- m_pos.x -= aYaxis_position;
- NEGATE( m_pos.x );
- m_pos.x += aYaxis_position;
- NEGATE( m_size.x );
+ MIRROR( m_pos.x, aYaxis_position );
+ m_size.x = -m_size.x;
}
diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp
index ddf2f14..3b77132 100644
--- a/eeschema/sch_component.cpp
+++ b/eeschema/sch_component.cpp
@@ -698,11 +698,11 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
- EXCHG( m_part_name, component->m_part_name );
- EXCHG( m_part, component->m_part );
- EXCHG( m_Pos, component->m_Pos );
- EXCHG( m_unit, component->m_unit );
- EXCHG( m_convert, component->m_convert );
+ std::swap( m_part_name, component->m_part_name );
+ std::swap( m_part, component->m_part );
+ std::swap( m_Pos, component->m_Pos );
+ std::swap( m_unit, component->m_unit );
+ std::swap( m_convert, component->m_convert );
TRANSFORM tmp = m_transform;
@@ -723,7 +723,7 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
GetField( ii )->SetParent( this );
}
- EXCHG( m_PathsAndReferences, component->m_PathsAndReferences );
+ std::swap( m_PathsAndReferences, component->m_PathsAndReferences );
}
@@ -1472,10 +1472,10 @@ EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const
// H and W must be > 0:
if( x2 < x1 )
- EXCHG( x2, x1 );
+ std::swap( x2, x1 );
if( y2 < y1 )
- EXCHG( y2, y1 );
+ std::swap( y2, y1 );
bBox.SetX( x1 );
bBox.SetY( y1 );
@@ -1547,9 +1547,7 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position )
int dx = m_Pos.x;
SetOrientation( CMP_MIRROR_Y );
- m_Pos.x -= aYaxis_position;
- NEGATE( m_Pos.x );
- m_Pos.x += aYaxis_position;
+ MIRROR( m_Pos.x, aYaxis_position );
dx -= m_Pos.x; // dx,0 is the move vector for this transform
for( int ii = 0; ii < GetFieldCount(); ii++ )
@@ -1567,9 +1565,7 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position )
int dy = m_Pos.y;
SetOrientation( CMP_MIRROR_X );
- m_Pos.y -= aXaxis_position;
- NEGATE( m_Pos.y );
- m_Pos.y += aXaxis_position;
+ MIRROR( m_Pos.y, aXaxis_position );
dy -= m_Pos.y; // dy,0 is the move vector for this transform
for( int ii = 0; ii < GetFieldCount(); ii++ )
diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp
index a2b2775..46b8834 100644
--- a/eeschema/sch_field.cpp
+++ b/eeschema/sch_field.cpp
@@ -238,18 +238,18 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
SCH_FIELD* item = (SCH_FIELD*) aItem;
- EXCHG( m_Text, item->m_Text );
- EXCHG( m_Layer, item->m_Layer );
- EXCHG( m_Pos, item->m_Pos );
- EXCHG( m_Size, item->m_Size );
- EXCHG( m_Thickness, item->m_Thickness );
- EXCHG( m_Orient, item->m_Orient );
- EXCHG( m_Mirror, item->m_Mirror );
- EXCHG( m_Attributs, item->m_Attributs );
- EXCHG( m_Italic, item->m_Italic );
- EXCHG( m_Bold, item->m_Bold );
- EXCHG( m_HJustify, item->m_HJustify );
- EXCHG( m_VJustify, item->m_VJustify );
+ std::swap( m_Text, item->m_Text );
+ std::swap( m_Layer, item->m_Layer );
+ std::swap( m_Pos, item->m_Pos );
+ std::swap( m_Size, item->m_Size );
+ std::swap( m_Thickness, item->m_Thickness );
+ std::swap( m_Orient, item->m_Orient );
+ std::swap( m_Mirror, item->m_Mirror );
+ std::swap( m_Attributs, item->m_Attributs );
+ std::swap( m_Italic, item->m_Italic );
+ std::swap( m_Bold, item->m_Bold );
+ std::swap( m_HJustify, item->m_HJustify );
+ std::swap( m_VJustify, item->m_VJustify );
}
@@ -285,12 +285,8 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const
// Due to the Y axis direction, we must mirror the bounding box,
// relative to the text position:
- begin.y -= pos.y;
- end.y -= pos.y;
- NEGATE( begin.y );
- NEGATE( end.y );
- begin.y += pos.y;
- end.y += pos.y;
+ MIRROR( begin.y, pos.y );
+ MIRROR( end.y, pos.y );
// Now, apply the component transform (mirror/rot)
begin = parentComponent->GetTransform().TransformCoordinate( begin );
diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp
index a12f21b..9c08b63 100644
--- a/eeschema/sch_junction.cpp
+++ b/eeschema/sch_junction.cpp
@@ -74,7 +74,7 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap junction data with invalid item." ) );
SCH_JUNCTION* item = (SCH_JUNCTION*) aItem;
- EXCHG( m_pos, item->m_pos );
+ std::swap( m_pos, item->m_pos );
}
@@ -128,17 +128,13 @@ void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffs
void SCH_JUNCTION::MirrorX( int aXaxis_position )
{
- m_pos.y -= aXaxis_position;
- NEGATE( m_pos.y );
- m_pos.y += aXaxis_position;
+ MIRROR( m_pos.y, aXaxis_position );
}
void SCH_JUNCTION::MirrorY( int aYaxis_position )
{
- m_pos.x -= aYaxis_position;
- NEGATE( m_pos.x );
- m_pos.x += aYaxis_position;
+ MIRROR( m_pos.x, aYaxis_position );
}
diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp
index a786332..72efb5c 100644
--- a/eeschema/sch_line.cpp
+++ b/eeschema/sch_line.cpp
@@ -250,23 +250,15 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
void SCH_LINE::MirrorX( int aXaxis_position )
{
- m_start.y -= aXaxis_position;
- NEGATE( m_start.y );
- m_start.y += aXaxis_position;
- m_end.y -= aXaxis_position;
- NEGATE( m_end.y );
- m_end.y += aXaxis_position;
+ MIRROR( m_start.y, aXaxis_position );
+ MIRROR( m_end.y, aXaxis_position );
}
void SCH_LINE::MirrorY( int aYaxis_position )
{
- m_start.x -= aYaxis_position;
- NEGATE( m_start.x );
- m_start.x += aYaxis_position;
- m_end.x -= aYaxis_position;
- NEGATE( m_end.x );
- m_end.x += aYaxis_position;
+ MIRROR( m_start.x, aYaxis_position );
+ MIRROR( m_end.x, aYaxis_position );
}
@@ -313,7 +305,7 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
}
else if( m_end == aLine->m_end )
{
- EXCHG( aLine->m_start, aLine->m_end );
+ std::swap( aLine->m_start, aLine->m_end );
}
else if( m_end != aLine->m_start )
{
diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp
index 694069d..dd1e978 100644
--- a/eeschema/sch_no_connect.cpp
+++ b/eeschema/sch_no_connect.cpp
@@ -63,8 +63,8 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap no connect data with invalid item." ) );
SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem;
- EXCHG( m_pos, item->m_pos );
- EXCHG( m_size, item->m_size );
+ std::swap( m_pos, item->m_pos );
+ std::swap( m_size, item->m_size );
}
@@ -153,17 +153,13 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
void SCH_NO_CONNECT::MirrorX( int aXaxis_position )
{
- m_pos.y -= aXaxis_position;
- NEGATE( m_pos.y );
- m_pos.y += aXaxis_position;
+ MIRROR( m_pos.y, aXaxis_position );
}
void SCH_NO_CONNECT::MirrorY( int aYaxis_position )
{
- m_pos.x -= aYaxis_position;
- NEGATE( m_pos.x );
- m_pos.x += aYaxis_position;
+ MIRROR( m_pos.x, aYaxis_position );
}
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index 8910ad2..c9afde7 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -319,11 +319,11 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem )
SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
- EXCHG( m_pos, sheet->m_pos );
- EXCHG( m_size, sheet->m_size );
- EXCHG( m_name, sheet->m_name );
- EXCHG( m_sheetNameSize, sheet->m_sheetNameSize );
- EXCHG( m_fileNameSize, sheet->m_fileNameSize );
+ std::swap( m_pos, sheet->m_pos );
+ std::swap( m_size, sheet->m_size );
+ std::swap( m_name, sheet->m_name );
+ std::swap( m_sheetNameSize, sheet->m_sheetNameSize );
+ std::swap( m_fileNameSize, sheet->m_fileNameSize );
m_pins.swap( sheet->m_pins );
// Ensure sheet labels have their .m_Parent member pointing really on their
@@ -844,13 +844,13 @@ void SCH_SHEET::Rotate(wxPoint aPosition)
if( m_size.x < 0 )
{
m_pos.x += m_size.x;
- NEGATE( m_size.x );
+ m_size.x = -m_size.x;
}
if( m_size.y < 0 )
{
m_pos.y += m_size.y;
- NEGATE( m_size.y );
+ m_size.y = -m_size.y;
}
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
@@ -862,9 +862,7 @@ void SCH_SHEET::Rotate(wxPoint aPosition)
void SCH_SHEET::MirrorX( int aXaxis_position )
{
- m_pos.y -= aXaxis_position;
- NEGATE( m_pos.y );
- m_pos.y += aXaxis_position;
+ MIRROR( m_pos.y, aXaxis_position );
m_pos.y -= m_size.y;
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
@@ -876,9 +874,7 @@ void SCH_SHEET::MirrorX( int aXaxis_position )
void SCH_SHEET::MirrorY( int aYaxis_position )
{
- m_pos.x -= aYaxis_position;
- NEGATE( m_pos.x );
- m_pos.x += aYaxis_position;
+ MIRROR( m_pos.x, aYaxis_position );
m_pos.x -= m_size.x;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index 762ffbd..c84852c 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -204,9 +204,7 @@ void SCH_TEXT::MirrorY( int aYaxis_position )
break;
}
- m_Pos.x -= aYaxis_position;
- NEGATE( m_Pos.x );
- m_Pos.x += aYaxis_position;
+ MIRROR( m_Pos.x, aYaxis_position );
}
@@ -228,9 +226,8 @@ void SCH_TEXT::MirrorX( int aXaxis_position )
default:
break;
}
- m_Pos.y -= aXaxis_position;
- NEGATE( m_Pos.y );
- m_Pos.y += aXaxis_position;
+
+ MIRROR( m_Pos.y, aXaxis_position );
}
@@ -306,18 +303,18 @@ void SCH_TEXT::SwapData( SCH_ITEM* aItem )
{
SCH_TEXT* item = (SCH_TEXT*) aItem;
- EXCHG( m_Text, item->m_Text );
- EXCHG( m_Pos, item->m_Pos );
- EXCHG( m_Size, item->m_Size );
- EXCHG( m_Thickness, item->m_Thickness );
- EXCHG( m_shape, item->m_shape );
- EXCHG( m_Orient, item->m_Orient );
+ std::swap( m_Text, item->m_Text );
+ std::swap( m_Pos, item->m_Pos );
+ std::swap( m_Size, item->m_Size );
+ std::swap( m_Thickness, item->m_Thickness );
+ std::swap( m_shape, item->m_shape );
+ std::swap( m_Orient, item->m_Orient );
- EXCHG( m_Layer, item->m_Layer );
- EXCHG( m_HJustify, item->m_HJustify );
- EXCHG( m_VJustify, item->m_VJustify );
- EXCHG( m_isDangling, item->m_isDangling );
- EXCHG( m_schematicOrientation, item->m_schematicOrientation );
+ std::swap( m_Layer, item->m_Layer );
+ std::swap( m_HJustify, item->m_HJustify );
+ std::swap( m_VJustify, item->m_VJustify );
+ std::swap( m_isDangling, item->m_isDangling );
+ std::swap( m_schematicOrientation, item->m_schematicOrientation );
}
@@ -356,9 +353,9 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
GRSetDrawMode( DC, DrawMode );
wxPoint text_offset = aOffset + GetSchematicTextOffset();
- EXCHG( linewidth, m_Thickness ); // Set the minimum width
+ std::swap( linewidth, m_Thickness ); // Set the minimum width
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
- EXCHG( linewidth, m_Thickness ); // set initial value
+ std::swap( linewidth, m_Thickness ); // set initial value
if( m_isDangling && panel)
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
@@ -859,9 +856,7 @@ void SCH_LABEL::MirrorX( int aXaxis_position )
break;
}
- m_Pos.y -= aXaxis_position;
- NEGATE( m_Pos.y );
- m_Pos.y += aXaxis_position;
+ MIRROR( m_Pos.y, aXaxis_position );
}
@@ -1140,9 +1135,7 @@ void SCH_GLOBALLABEL::MirrorY( int aYaxis_position )
break;
}
- m_Pos.x -= aYaxis_position;
- NEGATE( m_Pos.x );
- m_Pos.x += aYaxis_position;
+ MIRROR( m_Pos.x, aYaxis_position );
}
@@ -1159,9 +1152,7 @@ void SCH_GLOBALLABEL::MirrorX( int aXaxis_position )
break;
}
- m_Pos.y -= aXaxis_position;
- NEGATE( m_Pos.y );
- m_Pos.y += aXaxis_position;
+ MIRROR( m_Pos.y, aXaxis_position );
}
@@ -1274,10 +1265,10 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
- EXCHG( linewidth, m_Thickness ); // Set the minimum width
+ std::swap( linewidth, m_Thickness ); // Set the minimum width
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
- EXCHG( linewidth, m_Thickness ); // set initial value
+ std::swap( linewidth, m_Thickness ); // set initial value
CreateGraphicShape( Poly, m_Pos + aOffset );
GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
@@ -1606,10 +1597,10 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
GRSetDrawMode( DC, DrawMode );
- EXCHG( linewidth, m_Thickness ); // Set the minimum width
+ std::swap( linewidth, m_Thickness ); // Set the minimum width
wxPoint text_offset = offset + GetSchematicTextOffset();
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
- EXCHG( linewidth, m_Thickness ); // set initial value
+ std::swap( linewidth, m_Thickness ); // set initial value
CreateGraphicShape( Poly, m_Pos + offset );
GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
@@ -1750,9 +1741,7 @@ void SCH_HIERLABEL::MirrorY( int aYaxis_position )
break;
}
- m_Pos.x -= aYaxis_position;
- NEGATE( m_Pos.x );
- m_Pos.x += aYaxis_position;
+ MIRROR( m_Pos.x, aYaxis_position );
}
@@ -1769,9 +1758,7 @@ void SCH_HIERLABEL::MirrorX( int aXaxis_position )
break;
}
- m_Pos.y -= aXaxis_position;
- NEGATE( m_Pos.y );
- m_Pos.y += aXaxis_position;
+ MIRROR( m_Pos.y, aXaxis_position );
}
diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp
index 3ea8764..0c48a5b 100644
--- a/gerbview/class_aperture_macro.cpp
+++ b/gerbview/class_aperture_macro.cpp
@@ -143,7 +143,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
double rotation;
if( mapExposure( aParent ) == false )
{
- EXCHG(aColor, aAltColor);
+ std::swap( aColor, aAltColor );
}
switch( primitive_id )
diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp
index 02bf826..0e36b73 100644
--- a/gerbview/class_gerber_draw_item.cpp
+++ b/gerbview/class_gerber_draw_item.cpp
@@ -111,7 +111,7 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
wxPoint abPos = aXYPosition + m_imageParams->m_ImageJustifyOffset;
if( m_swapAxis )
- EXCHG( abPos.x, abPos.y );
+ std::swap( abPos.x, abPos.y );
abPos += m_layerOffset + m_imageParams->m_ImageOffset;
abPos.x = KiROUND( abPos.x * m_drawScale.x );
@@ -123,11 +123,11 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
// Negate A axis if mirrored
if( m_mirrorA )
- NEGATE( abPos.x );
+ abPos.x = -abPos.x;
// abPos.y must be negated when no mirror, because draw axis is top to bottom
if( !m_mirrorB )
- NEGATE( abPos.y );
+ abPos.y = -abPos.y;
return abPos;
}
@@ -138,10 +138,10 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) const
wxPoint xyPos = aABPosition;
if( m_mirrorA )
- NEGATE( xyPos.x );
+ xyPos.x = -xyPos.x;
if( !m_mirrorB )
- NEGATE( xyPos.y );
+ xyPos.y = -xyPos.y;
double rotation = m_lyrRotation * 10 + m_imageParams->m_ImageRotation * 10;
@@ -153,7 +153,7 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) const
xyPos -= m_layerOffset + m_imageParams->m_ImageOffset;
if( m_swapAxis )
- EXCHG( xyPos.x, xyPos.y );
+ std::swap( xyPos.x, xyPos.y );
return xyPos - m_imageParams->m_ImageJustifyOffset;
}
@@ -344,7 +344,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
if( !isDark )
{
// draw in background color ("negative" color)
- EXCHG( color, alt_color );
+ std::swap( color, alt_color );
}
GRSetDrawMode( aDC, aDrawMode );
@@ -470,7 +470,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
// make calculations more easy if ensure start.x < end.x
// (only 2 quadrants to consider)
if( start.x > end.x )
- EXCHG( start, end );
+ std::swap( start, end );
// calculate values relative to start point:
wxPoint delta = end - start;
@@ -481,7 +481,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
bool change = delta.y < 0;
if( change )
- NEGATE( delta.y);
+ delta.y = -delta.y;
// Now create the full polygon.
// Due to previous changes, the shape is always something like
@@ -516,7 +516,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ )
{
if( change )
- NEGATE( m_PolyCorners[ii].y);
+ m_PolyCorners[ii].y = -m_PolyCorners[ii].y;
m_PolyCorners[ii] += start;
}
diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index fc81b54..d73a831 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -291,8 +291,8 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
}
// Reverse Y axis:
- NEGATE( seg_start.y );
- NEGATE( seg_end.y );
+ seg_start.y = -seg_start.y;
+ seg_end.y = -seg_end.y;
writePcbLineItem( isArc, seg_start, seg_end, aGbrItem->m_Size.x, aLayer, angle );
}
@@ -327,8 +327,8 @@ void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem
seg_end = aGbrItem->m_End;
// Reverse Y axis:
- NEGATE( seg_start.y );
- NEGATE( seg_end.y );
+ seg_start.y = -seg_start.y;
+ seg_end.y = -seg_end.y;
writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
}
@@ -382,8 +382,8 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem,
-RAD2DECIDEG( DELTA_ANGLE * ii ) );
seg_end = curr_end;
// Reverse Y axis:
- NEGATE( seg_start.y );
- NEGATE( seg_end.y );
+ seg_start.y = -seg_start.y;
+ seg_end.y = -seg_end.y;
writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
curr_start = curr_end;
}
@@ -393,8 +393,8 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem,
seg_start = curr_start;
seg_end = end;
// Reverse Y axis:
- NEGATE( seg_start.y );
- NEGATE( seg_end.y );
+ seg_start.y = -seg_start.y;
+ seg_end.y = -seg_end.y;
writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
}
}
@@ -419,7 +419,7 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem
wxPoint via_pos = aGbrItem->m_Start;
int width = (aGbrItem->m_Size.x + aGbrItem->m_Size.y) / 2;
// Reverse Y axis:
- NEGATE( via_pos.y );
+ via_pos.y = -via_pos.y;
// Layers are Front to Back
fprintf( m_fp, " (via (at %s %s) (size %s)",
diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp
index 1207616..3d8ec54 100644
--- a/gerbview/rs274d.cpp
+++ b/gerbview/rs274d.cpp
@@ -252,7 +252,7 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* ---S---
* 3 | 4
*/
- NEGATE( center.x);
+ center.x = -center.x;
}
else if( (delta.x >= 0) && (delta.y < 0) )
{
@@ -270,8 +270,8 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* ---S---
* C | 4
*/
- NEGATE( center.x);
- NEGATE( center.y);
+ center.x = -center.x;
+ center.y = -center.y;
}
else
{
@@ -280,7 +280,7 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* ---S---
* E | C
*/
- NEGATE( center.y);
+ center.y = -center.y;
}
// Due to your draw arc function, we need this:
diff --git a/include/macros.h b/include/macros.h
index 8bdcafa..7a40492 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -84,23 +84,21 @@ static inline const wxChar* GetChars( const wxString& s )
#endif
}
-// This really needs a function? well, it 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
-/// Exchange two values
-// std::swap works only with arguments of the same type (which is saner);
-// here the compiler will figure out what to do (I hope to get rid of
-// this soon or late)
-template <class T, class T2> inline void EXCHG( T& a, T2& b )
+
+/**
+ * Function MIRROR
+ * Mirror @a aPoint in @a aMirrorRef.
+ */
+template<typename T>
+void MIRROR( T& aPoint, const T& aMirrorRef )
{
- T temp = a;
- a = b;
- b = temp;
+ aPoint = -( aPoint - aMirrorRef ) + aMirrorRef;
}
+
/**
* Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
diff --git a/pcbnew/autorouter/auto_place_footprints.cpp b/pcbnew/autorouter/auto_place_footprints.cpp
index 277aaca..d6d25a1 100644
--- a/pcbnew/autorouter/auto_place_footprints.cpp
+++ b/pcbnew/autorouter/auto_place_footprints.cpp
@@ -936,7 +936,7 @@ double compute_Ratsnest_PlaceModule( BOARD* aBrd )
// ttry to have always dx >= dy to calculate the cost of the rastsnet
if( dx < dy )
- EXCHG( dx, dy );
+ std::swap( dx, dy );
// Cost of the connection = lenght + penalty due to the slope
// dx is the biggest lenght relative to the X or Y axis
diff --git a/pcbnew/autorouter/graphpcb.cpp b/pcbnew/autorouter/graphpcb.cpp
index 0aacee6..259b859 100644
--- a/pcbnew/autorouter/graphpcb.cpp
+++ b/pcbnew/autorouter/graphpcb.cpp
@@ -114,7 +114,7 @@ void PlacePad( D_PAD* aPad, int color, int marge, int op_logic )
// Orientation turned 90 deg.
if( aPad->GetOrientation() == 900 || aPad->GetOrientation() == 2700 )
{
- EXCHG( dx, dy );
+ std::swap( dx, dy );
}
TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy,
@@ -345,7 +345,7 @@ void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color, i
if( x0 == x1 ) // Vertical.
{
if( y1 < y0 )
- EXCHG( y0, y1 );
+ std::swap( y0, y1 );
dy = y0 / RoutingMatrix.m_GridRouting;
lim = y1 / RoutingMatrix.m_GridRouting;
@@ -372,7 +372,7 @@ void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color, i
if( y0 == y1 ) // Horizontal
{
if( x1 < x0 )
- EXCHG( x0, x1 );
+ std::swap( x0, x1 );
dx = x0 / RoutingMatrix.m_GridRouting;
lim = x1 / RoutingMatrix.m_GridRouting;
@@ -401,7 +401,8 @@ void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color, i
{
if( x1 < x0 )
{
- EXCHG( x1, x0 ); EXCHG( y1, y0 );
+ std::swap( x1, x0 );
+ std::swap( y1, y0 );
}
dx = x0 / RoutingMatrix.m_GridRouting;
@@ -438,8 +439,8 @@ void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color, i
{
if( y1 < y0 )
{
- EXCHG( x1, x0 );
- EXCHG( y1, y0 );
+ std::swap( x1, x0 );
+ std::swap( y1, y0 );
}
dy = y0 / RoutingMatrix.m_GridRouting;
@@ -643,8 +644,8 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer
// Make coordinate ux1 tj > ux0 to simplify calculations
if( ux1 < ux0 )
{
- EXCHG( ux1, ux0 );
- EXCHG( uy1, uy0 );
+ std::swap( ux1, ux0 );
+ std::swap( uy1, uy0 );
}
// Calculating the incrementing the Y axis
diff --git a/pcbnew/autorouter/solve.cpp b/pcbnew/autorouter/solve.cpp
index dbc9c68..c10e57f 100644
--- a/pcbnew/autorouter/solve.cpp
+++ b/pcbnew/autorouter/solve.cpp
@@ -484,7 +484,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
int py = pt_cur_ch->m_PadStart->GetPosition().y;
if( ( ( int( pt_cur_ch->m_PadStart->GetOrientation() ) / 900 ) & 1 ) != 0 )
- EXCHG( dx, dy );
+ std::swap( dx, dy );
if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route;
@@ -499,7 +499,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
py = pt_cur_ch->m_PadEnd->GetPosition().y;
if( ( ( int( pt_cur_ch->m_PadEnd->GetOrientation() ) / 900) & 1 ) != 0 )
- EXCHG( dx, dy );
+ std::swap( dx, dy );
if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route;
diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp
index 047dd86..972de85 100644
--- a/pcbnew/block_module_editor.cpp
+++ b/pcbnew/block_module_editor.cpp
@@ -606,11 +606,11 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
pad->SetX0( pad->GetPosition().x );
tmp = pad->GetOffset();
- NEGATE( tmp.x );
+ tmp.x = -tmp.x;
pad->SetOffset( tmp );
tmpz = pad->GetDelta();
- NEGATE( tmpz.x );
+ tmpz.x = -tmpz.x;
pad->SetDelta( tmpz );
pad->SetOrientation( 1800 - pad->GetOrientation() );
diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp
index a326945..f4623c2 100644
--- a/pcbnew/board_items_to_polygon_shape_transform.cpp
+++ b/pcbnew/board_items_to_polygon_shape_transform.cpp
@@ -258,7 +258,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
wxSize size = textmod->GetSize();
if( textmod->IsMirrored() )
- NEGATE( size.x );
+ size.x = -size.x;
DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK,
textmod->GetShownText(), textmod->GetDrawRotation(), size,
@@ -380,7 +380,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
wxSize size = GetSize();
if( IsMirrored() )
- NEGATE( size.x );
+ size.x = -size.x;
s_cornerBuffer = &aCornerBuffer;
s_textWidth = GetThickness() + ( 2 * aClearanceValue );
@@ -886,9 +886,9 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
if( dx < dy )
{
- EXCHG( dx, dy );
+ std::swap( dx, dy );
supp_angle = 900;
- EXCHG( copper_thickness.x, copper_thickness.y );
+ std::swap( copper_thickness.x, copper_thickness.y );
}
int deltasize = dx - dy; // = distance between shape position and the 2 demi-circle ends centre
diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp
index fff523b..8e0a629 100644
--- a/pcbnew/board_undo_redo.cpp
+++ b/pcbnew/board_undo_redo.cpp
@@ -225,7 +225,7 @@ void BOARD_ITEM::SwapData( BOARD_ITEM* aImage )
TRACK* track = (TRACK*) this;
TRACK* image = (TRACK*) aImage;
- EXCHG(track->m_Layer, image->m_Layer );
+ std::swap(track->m_Layer, image->m_Layer );
// swap start, end, width and shape for track and image.
wxPoint exchp = track->GetStart();
@@ -258,7 +258,7 @@ void BOARD_ITEM::SwapData( BOARD_ITEM* aImage )
if( viaimage->IsDrillDefault() )
itmp = -1;
- EXCHG(itmp, drilltmp );
+ std::swap(itmp, drilltmp );
if( drilltmp > 0 )
via->SetDrill( drilltmp );
diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp
index 862ab31..579f535 100644
--- a/pcbnew/class_board.cpp
+++ b/pcbnew/class_board.cpp
@@ -1409,7 +1409,7 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
aEndLayer = aStartLayer;
if( aEndLayer < aStartLayer )
- EXCHG( aEndLayer, aStartLayer );
+ std::swap( aEndLayer, aStartLayer );
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
{
diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp
index 53c2f4b..9460268 100644
--- a/pcbnew/class_drawsegment.cpp
+++ b/pcbnew/class_drawsegment.cpp
@@ -136,9 +136,7 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
m_End.y = aCentre.y - (m_End.y - aCentre.y);
if( m_Shape == S_ARC )
- {
- NEGATE( m_Angle );
- }
+ m_Angle = -m_Angle;
SetLayer( FlipLayer( GetLayer() ) );
}
@@ -294,12 +292,12 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( !panel->GetPrintMirrored() )
{
if( StAngle > EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
else // Mirrored mode: arc orientation is reversed
{
if( StAngle < EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
if( filled )
diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp
index 041d3cc..c79daa2 100644
--- a/pcbnew/class_edge_mod.cpp
+++ b/pcbnew/class_edge_mod.cpp
@@ -197,12 +197,12 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( !panel->GetPrintMirrored() )
{
if( StAngle > EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
else // Mirrored mode: arc orientation is reversed
{
if( StAngle < EndAngle )
- EXCHG( StAngle, EndAngle );
+ std::swap( StAngle, EndAngle );
}
if( filled )
@@ -311,15 +311,15 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre )
pt.y += aCentre.y;
SetEnd( pt );
- NEGATE( m_Start0.y );
- NEGATE( m_End0.y );
+ m_Start0.y = -m_Start0.y;
+ m_End0.y = -m_End0.y;
break;
case S_POLYGON:
// polygon corners coordinates are always relative to the
// footprint position, orientation 0
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
- NEGATE( m_PolyPoints[ii].y );
+ m_PolyPoints[ii].y = -m_PolyPoints[ii].y;
}
SetLayer( FlipLayer( GetLayer() ) );
diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp
index e8e6944..093df74 100644
--- a/pcbnew/class_module.cpp
+++ b/pcbnew/class_module.cpp
@@ -954,7 +954,7 @@ void MODULE::Flip( const wxPoint& aCentre )
SetLayer( FlipLayer( GetLayer() ) );
// Reverse mirror orientation.
- NEGATE( m_Orient );
+ m_Orient = -m_Orient;
NORMALIZE_ANGLE_POS( m_Orient );
// Mirror pads to other side of board about the x axis, i.e. vertically.
diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp
index 9845a72..ddfef77 100644
--- a/pcbnew/class_pad.cpp
+++ b/pcbnew/class_pad.cpp
@@ -285,9 +285,9 @@ void D_PAD::Flip( const wxPoint& aCentre )
SetY( y );
- NEGATE( m_Pos0.y );
- NEGATE( m_Offset.y );
- NEGATE( m_DeltaSize.y );
+ m_Pos0.y = -m_Pos0.y;
+ m_Offset.y = -m_Offset.y;
+ m_DeltaSize.y = -m_DeltaSize.y;
SetOrientation( -GetOrientation() );
diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp
index 0d0723b..3aa14f3 100644
--- a/pcbnew/class_track.cpp
+++ b/pcbnew/class_track.cpp
@@ -412,7 +412,7 @@ void VIA::SetLayerPair( LAYER_ID aTopLayer, LAYER_ID aBottomLayer )
}
if( aBottomLayer < aTopLayer )
- EXCHG( aBottomLayer, aTopLayer );
+ std::swap( aBottomLayer, aTopLayer );
m_Layer = aTopLayer;
m_BottomLayer = aBottomLayer;
@@ -430,7 +430,7 @@ void VIA::LayerPair( LAYER_ID* top_layer, LAYER_ID* bottom_layer ) const
t_layer = m_Layer;
if( b_layer < t_layer )
- EXCHG( b_layer, t_layer );
+ std::swap( b_layer, t_layer );
}
if( top_layer )
@@ -1502,8 +1502,8 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
if( EndPad )
Track->SetState( BEGIN_ONPAD, true );
- EXCHG( Track->m_Start, Track->m_End );
- EXCHG( Track->start, Track->end );
+ std::swap( Track->m_Start, Track->m_End );
+ std::swap( Track->start, Track->end );
ok = 1;
return ok;
}
@@ -1546,8 +1546,8 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
if( EndPad )
Track->SetState( BEGIN_ONPAD, true );
- EXCHG( Track->m_Start, Track->m_End );
- EXCHG( Track->start, Track->end );
+ std::swap( Track->m_Start, Track->m_End );
+ std::swap( Track->start, Track->end );
break;
case 1:
diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp
index 8c52288..abec9ae 100644
--- a/pcbnew/class_zone.cpp
+++ b/pcbnew/class_zone.cpp
@@ -773,8 +773,7 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
{
for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ )
{
- int py = m_Poly->m_CornersList.GetY( ic ) - mirror_ref.y;
- NEGATE( py );
+ int py = mirror_ref.y - m_Poly->m_CornersList.GetY( ic );
m_Poly->m_CornersList.SetY( ic, py + mirror_ref.y );
}
@@ -783,19 +782,14 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
/* mirror filled areas: */
for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ )
{
- int py = m_FilledPolysList.GetY( ic ) - mirror_ref.y;
- NEGATE( py );
+ int py = mirror_ref.y - m_FilledPolysList.GetY( ic );
m_FilledPolysList.SetY( ic, py + mirror_ref.y );
}
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
{
- m_FillSegmList[ic].m_Start.y -= mirror_ref.y;
- NEGATE( m_FillSegmList[ic].m_Start.y );
- m_FillSegmList[ic].m_Start.y += mirror_ref.y;
- m_FillSegmList[ic].m_End.y -= mirror_ref.y;
- NEGATE( m_FillSegmList[ic].m_End.y );
- m_FillSegmList[ic].m_End.y += mirror_ref.y;
+ MIRROR( m_FillSegmList[ic].m_Start.y, mirror_ref.y );
+ MIRROR( m_FillSegmList[ic].m_End.y, mirror_ref.y );
}
}
diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp
index b52166c..848c30b 100644
--- a/pcbnew/connect.cpp
+++ b/pcbnew/connect.cpp
@@ -502,7 +502,7 @@ int CONNECTIONS::Merge_PadsSubNets( int aOldSubNet, int aNewSubNet )
return 0;
if( (aOldSubNet > 0) && (aOldSubNet < aNewSubNet) )
- EXCHG( aOldSubNet, aNewSubNet );
+ std::swap( aOldSubNet, aNewSubNet );
// Examine connections between intersecting pads
for( unsigned ii = 0; ii < m_sortedPads.size(); ii++ )
@@ -532,7 +532,7 @@ int CONNECTIONS::Merge_SubNets( int aOldSubNet, int aNewSubNet )
return 0;
if( (aOldSubNet > 0) && (aOldSubNet < aNewSubNet) )
- EXCHG( aOldSubNet, aNewSubNet );
+ std::swap( aOldSubNet, aNewSubNet );
curr_track = (TRACK*)m_firstTrack;
diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp
index 2cbc4cb..a30c352 100644
--- a/pcbnew/dialogs/dialog_pad_properties.cpp
+++ b/pcbnew/dialogs/dialog_pad_properties.cpp
@@ -350,11 +350,11 @@ void DIALOG_PAD_PROPERTIES::initValues()
if( m_isFlipped )
{
wxPoint pt = m_dummyPad->GetOffset();
- NEGATE( pt.y );
+ pt.y = -pt.y;
m_dummyPad->SetOffset( pt );
wxSize sz = m_dummyPad->GetDelta();
- NEGATE( sz.y );
+ sz.y = -sz.y;
m_dummyPad->SetDelta( sz );
// flip pad's layers
@@ -457,7 +457,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
angle = m_currentPad->GetOrientation() - module->GetOrientation();
if( m_isFlipped )
- NEGATE( angle );
+ angle = -angle;
m_dummyPad->SetOrientation( angle );
}
diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp
index 3b8a89f..52e7327 100644
--- a/pcbnew/dragsegm.cpp
+++ b/pcbnew/dragsegm.cpp
@@ -126,7 +126,7 @@ void DRAG_SEGM_PICKER::SetTrackEndsCoordinates( wxPoint aOffset )
RotatePoint(&padoffset, curr_rot_offset);
if( flip )
- NEGATE( padoffset.y );
+ padoffset.y = -padoffset.y;
m_Track->SetStart( m_Pad_Start->GetPosition() - aOffset + padoffset );
}
@@ -139,7 +139,7 @@ void DRAG_SEGM_PICKER::SetTrackEndsCoordinates( wxPoint aOffset )
RotatePoint( &padoffset, curr_rot_offset );
if( flip )
- NEGATE( padoffset.y );
+ padoffset.y = -padoffset.y;
m_Track->SetEnd( m_Pad_End->GetPosition() - aOffset + padoffset );
}
diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp
index ded598c..3973337 100644
--- a/pcbnew/drc_clearance_test_functions.cpp
+++ b/pcbnew/drc_clearance_test_functions.cpp
@@ -213,7 +213,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
refvia->LayerPair( &layer1, &layer2 );
if( layer1 > layer2 )
- EXCHG( layer1, layer2 );
+ std::swap( layer1, layer2 );
if( layer2 == B_Cu && layer1 == m_pcb->GetDesignSettings().GetCopperLayerCount() - 2 )
err = false;
@@ -416,7 +416,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
// Ensure segStartPoint.x <= segEndPoint.x
if( segStartPoint.x > segEndPoint.x )
- EXCHG( segStartPoint.x, segEndPoint.x );
+ std::swap( segStartPoint.x, segEndPoint.x );
if( segStartPoint.x > (-w_dist) && segStartPoint.x < (m_segmLength + w_dist) ) /* possible error drc */
{
@@ -480,7 +480,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
// Test if segments are crossing
if( segStartPoint.y > segEndPoint.y )
- EXCHG( segStartPoint.y, segEndPoint.y );
+ std::swap( segStartPoint.y, segEndPoint.y );
if( (segStartPoint.y < 0) && (segEndPoint.y > 0) )
{
@@ -633,7 +633,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
if( swap_pads )
{
- EXCHG( aRefPad, aPad );
+ std::swap( aRefPad, aPad );
relativePadPos = -relativePadPos;
}
@@ -678,7 +678,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
{
if( (pad_angle == 900) || (pad_angle == 2700) )
{
- EXCHG( size.x, size.y );
+ std::swap( size.x, size.y );
}
// Test DRC:
@@ -877,7 +877,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi
*/
if( padHalfsize.x > padHalfsize.y )
{
- EXCHG( padHalfsize.x, padHalfsize.y );
+ std::swap( padHalfsize.x, padHalfsize.y );
orient = AddAngles( orient, 900 );
}
@@ -1061,7 +1061,7 @@ bool DRC::checkLine( wxPoint aSegStart, wxPoint aSegEnd )
int temp;
if( aSegStart.x > aSegEnd.x )
- EXCHG( aSegStart, aSegEnd );
+ std::swap( aSegStart, aSegEnd );
if( (aSegEnd.x < m_xcliplo) || (aSegStart.x > m_xcliphi) )
{
diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp
index 0dce853..07c8b41 100644
--- a/pcbnew/exporters/export_vrml.cpp
+++ b/pcbnew/exporters/export_vrml.cpp
@@ -633,7 +633,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
wxSize size = text->GetSize();
if( text->IsMirrored() )
- NEGATE( size.x );
+ size.x = -size.x;
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText
@@ -929,7 +929,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module )
wxSize size = module->GetSize();
if( module->IsMirrored() )
- NEGATE( size.x ); // Text is mirrored
+ size.x = -size.x; // Text is mirrored
model_vrml->s_text_layer = module->GetLayer();
model_vrml->s_text_width = module->GetThickness();
@@ -1279,8 +1279,8 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
if( isFlipped )
{
rotx += 180.0;
- NEGATE( roty );
- NEGATE( rotz );
+ roty = -roty;
+ rotz = -rotz;
}
// Do some quaternion munching
@@ -1313,9 +1313,9 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0;
if( isFlipped )
- NEGATE( offsetz );
+ offsetz = -offsetz;
else // In normal mode, Y axis is reversed in Pcbnew.
- NEGATE( offsety );
+ offsety = -offsety;
RotatePoint( &offsetx, &offsety, aModule->GetOrientation() );
diff --git a/pcbnew/exporters/gendrill_Excellon_writer.cpp b/pcbnew/exporters/gendrill_Excellon_writer.cpp
index 149f13e..7b2f6e9 100644
--- a/pcbnew/exporters/gendrill_Excellon_writer.cpp
+++ b/pcbnew/exporters/gendrill_Excellon_writer.cpp
@@ -619,7 +619,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
if( (aFirstLayer >= 0) && (aLastLayer >= 0) )
{
if( aFirstLayer > aLastLayer )
- EXCHG( aFirstLayer, aLastLayer );
+ std::swap( aFirstLayer, aLastLayer );
}
if ( aGenerateNPTH_list && aMerge_PTH_NPTH )
diff --git a/pcbnew/pad_edition_functions.cpp b/pcbnew/pad_edition_functions.cpp
index f6cd9f3..5d97c5a 100644
--- a/pcbnew/pad_edition_functions.cpp
+++ b/pcbnew/pad_edition_functions.cpp
@@ -245,21 +245,21 @@ void PCB_BASE_FRAME::RotatePad( D_PAD* aPad, wxDC* DC )
module->Draw( m_canvas, DC, GR_XOR );
wxSize sz = aPad->GetSize();
- EXCHG( sz.x, sz.y );
+ std::swap( sz.x, sz.y );
aPad->SetSize( sz );
sz = aPad->GetDrillSize();
- EXCHG( sz.x, sz.y );
+ std::swap( sz.x, sz.y );
aPad->SetDrillSize( sz );
wxPoint pt = aPad->GetOffset();
- EXCHG( pt.x, pt.y );
+ std::swap( pt.x, pt.y );
aPad->SetOffset( pt );
aPad->SetOffset( wxPoint( aPad->GetOffset().x, -aPad->GetOffset().y ) );
sz = aPad->GetDelta();
- EXCHG( sz.x, sz.y );
+ std::swap( sz.x, sz.y );
sz.x = -sz.x;
aPad->SetDelta( sz );
diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp
index bd7775b..cd814a5 100644
--- a/pcbnew/pcb_painter.cpp
+++ b/pcbnew/pcb_painter.cpp
@@ -465,7 +465,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
{
orientation += 900.0;
size = padsize.x;
- EXCHG( padsize.x, padsize.y );
+ std::swap( padsize.x, padsize.y );
}
else if( padsize.x == padsize.y )
{
diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp
index 887ff9c..99b600a 100644
--- a/pcbnew/plot_brditems_plotter.cpp
+++ b/pcbnew/plot_brditems_plotter.cpp
@@ -223,7 +223,7 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, EDA_COLOR_T aColo
thickness = pt_texte->GetThickness();
if( pt_texte->IsMirrored() )
- NEGATE( size.x ); // Text is mirrored
+ size.x = -size.x; // Text is mirrored
// Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
// but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp
index f1eb0c7..b388085 100644
--- a/pcbnew/ratsnest.cpp
+++ b/pcbnew/ratsnest.cpp
@@ -374,7 +374,7 @@ static int tst_links_between_blocks( NETINFO_ITEM* aNetinfo,
min_id = best_link->m_PadEnd->GetSubRatsnest();
if( min_id > subratsnest_id )
- EXCHG( min_id, subratsnest_id );
+ std::swap( min_id, subratsnest_id );
// Merge the 2 blocks in one sub ratsnest:
for( unsigned ii = 0; ii < aNetinfo->m_PadInNetList.size(); ii++ )
diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp
index 7a0f08d..401b0ea 100644
--- a/pcbnew/specctra_export.cpp
+++ b/pcbnew/specctra_export.cpp
@@ -866,7 +866,7 @@ PADSTACK* SPECCTRA_DB::makeVia( const ::VIA* aVia )
int botLayer = kicadLayer2pcb[botLayerNum];
if( topLayer > botLayer )
- EXCHG( topLayer, botLayer );
+ std::swap( topLayer, botLayer );
return makeVia( aVia->GetWidth(), aVia->GetDrillValue(), topLayer, botLayer );
}
@@ -1106,7 +1106,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), prox ) );
angle = -angle;
- EXCHG( start, end );
+ std::swap( start, end );
}
wxPoint nextPt;
@@ -1241,7 +1241,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), prox ) );
angle = -angle;
- EXCHG( start, end );
+ std::swap( start, end );
}
wxPoint nextPt;
diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp
index 50127d0..3f45b06 100644
--- a/pcbnew/zones_polygons_test_connections.cpp
+++ b/pcbnew/zones_polygons_test_connections.cpp
@@ -392,7 +392,7 @@ void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode )
// Here we have 2 items connected by the same area have 2 differents subnets: merge subnets
if( (subnet > old_subnet) || ( subnet <= 0) )
- EXCHG( subnet, old_subnet );
+ std::swap( subnet, old_subnet );
for( unsigned jj = 0; jj < Candidates.size(); jj++ )
{
Follow ups
References