Cleanup: remove unnecessary macros EXCHG and NEGATE. add MIRROR macro.

This commit is contained in:
unknown 2015-06-26 15:41:56 +02:00 committed by jean-pierre charras
parent 3e398ce1c6
commit 71b3125d8e
61 changed files with 238 additions and 299 deletions

View File

@ -219,7 +219,7 @@ void EDA_3D_CANVAS::draw3DGrid( double aGriSizeMM )
wxSize brd_size = getBoardSize(); wxSize brd_size = getBoardSize();
wxPoint brd_center_pos = getBoardCenter(); 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 xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2; int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;

View File

@ -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 const int delta = 50; // increment (in 0.1 degrees) to draw circles
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
/* Please NOTE the different sign due to Y-axis flip */ /* 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 ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
orient = AddAngles( orient, 900 ); orient = AddAngles( orient, 900 );
} }

View File

@ -280,7 +280,7 @@ double RoundTo0( double x, double precision )
long long ix = KiROUND( x * precision ); long long ix = KiROUND( x * precision );
if ( x < 0.0 ) if ( x < 0.0 )
NEGATE( ix ); ix = -ix;
int remainder = ix % 10; // remainder is in precision mm 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 ix += 10 - remainder; // round to near number
if ( x < 0 ) if ( x < 0 )
NEGATE( ix ); ix = -ix;
return (double) ix / precision; return (double) ix / precision;
} }

View File

@ -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, it is CW. So transform it to CCW
if( StAngle > EndAngle ) if( StAngle > EndAngle )
{ {
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
DPOINT centre_dev = userToDeviceCoordinates( centre ); DPOINT centre_dev = userToDeviceCoordinates( centre );
@ -536,7 +536,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
* (Oval vertical orientation 0) */ * (Oval vertical orientation 0) */
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
orient = AddAngles( orient, 900 ); orient = AddAngles( orient, 900 );
} }

View File

@ -459,7 +459,7 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub
&& trace_mode == FILLED ) && trace_mode == FILLED )
{ {
if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */ 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 ); DPOINT pos_dev = userToDeviceCoordinates( pos );
selectAperture( size, APERTURE::Oval ); selectAperture( size, APERTURE::Oval );
@ -469,7 +469,7 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub
{ {
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
if( orient < 2700 ) if( orient < 2700 )
orient += 900; orient += 900;
@ -512,7 +512,7 @@ void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
{ {
case 900: case 900:
case 2700: // rotation of 90 degrees or 270 swaps sizes case 2700: // rotation of 90 degrees or 270 swaps sizes
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
// Pass through // Pass through
case 0: case 0:

View File

@ -460,7 +460,7 @@ void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
*/ */
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
orient = AddAngles( orient, 900 ); orient = AddAngles( orient, 900 );
} }

View File

@ -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 const int delta = 50; // increment (in 0.1 degrees) to draw circles
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );

View File

@ -98,7 +98,7 @@ void PSLIKE_PLOTTER::FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize,
// The pad is reduced to an oval by dy > dx // The pad is reduced to an oval by dy > dx
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
aPadOrient = AddAngles( aPadOrient, 900 ); aPadOrient = AddAngles( aPadOrient, 900 );
} }
@ -514,7 +514,7 @@ void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
return; return;
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
@ -528,7 +528,7 @@ void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
{ {
StAngle = 1800.0 -StAngle; StAngle = 1800.0 -StAngle;
EndAngle = 1800.0 -EndAngle; EndAngle = 1800.0 -EndAngle;
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
else else
{ {

View File

@ -352,7 +352,7 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
return; return;
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
setFillMode( fill ); setFillMode( fill );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
@ -374,7 +374,7 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
{ {
StAngle = 1800.0 -StAngle; StAngle = 1800.0 -StAngle;
EndAngle = 1800.0 -EndAngle; EndAngle = 1800.0 -EndAngle;
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
else else
{ {

View File

@ -174,8 +174,8 @@ void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
if( aArcAngle < 0 ) if( aArcAngle < 0 )
{ {
EXCHG( arc_start, arc_end ); std::swap( arc_start, arc_end );
NEGATE( aArcAngle ); aArcAngle = -aArcAngle;
} }
// Compute the ends of segments and creates poly // Compute the ends of segments and creates poly

View File

@ -477,7 +477,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
wxSize size = GetSize(); wxSize size = GetSize();
if( IsMirrored() ) if( IsMirrored() )
NEGATE( size.x ); size.x = -size.x;
s_cornerBuffer = &aCornerBuffer; s_cornerBuffer = &aCornerBuffer;
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText

View File

@ -153,7 +153,7 @@ bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart,
// To have only one case to examine, ensure aEnd.y > aStart.y // To have only one case to examine, ensure aEnd.y > aStart.y
if( 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 ) if( aRefPoint.y <= aEnd.y && aRefPoint.y >= aStart.y )
return true; return true;
@ -186,7 +186,7 @@ bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart,
// To have only one case to examine, ensure xf > xi // To have only one case to examine, ensure xf > xi
if( aEnd.x < aStart.x ) 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 ) if( aRefPoint.x <= aEnd.x && aRefPoint.x >= aStart.x )
return true; return true;

View File

@ -166,7 +166,7 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
for( size_t ii = 0; ii < selections.GetCount(); ii++ ) for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{ {
int jj = selections[ii]; int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1] ); std::swap( libnames[jj], libnames[jj-1] );
} }
m_ListEquiv->Set( libnames ); m_ListEquiv->Set( libnames );
@ -201,7 +201,7 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveDown( wxCommandEvent& event )
for( int ii = selections.GetCount()-1; ii >= 0; ii-- ) for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{ {
int jj = selections[ii]; int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]); std::swap( libnames[jj], libnames[jj+1]);
} }
m_ListEquiv->Set( libnames ); m_ListEquiv->Set( libnames );

View File

@ -171,7 +171,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
pt = GetScreen()->m_BlockLocate.Centre(); pt = GetScreen()->m_BlockLocate.Centre();
pt = GetNearestGridPosition( pt ); pt = GetNearestGridPosition( pt );
NEGATE( pt.y ); pt.y = -pt.y;
if( GetCurPart() ) if( GetCurPart() )
{ {
@ -261,7 +261,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
SaveCopyInUndoList( GetCurPart() ); SaveCopyInUndoList( GetCurPart() );
pt = GetScreen()->m_BlockLocate.GetMoveVector(); pt = GetScreen()->m_BlockLocate.GetMoveVector();
NEGATE( pt.y ); pt.y = -pt.y;
if( GetCurPart() ) if( GetCurPart() )
GetCurPart()->CopySelectedItems( pt ); GetCurPart()->CopySelectedItems( pt );
@ -280,7 +280,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
pt = GetScreen()->m_BlockLocate.Centre(); pt = GetScreen()->m_BlockLocate.Centre();
pt = GetNearestGridPosition( pt ); pt = GetNearestGridPosition( pt );
NEGATE( pt.y ); pt.y = -pt.y;
if( GetCurPart() ) if( GetCurPart() )
{ {

View File

@ -288,7 +288,7 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem
end = 0; end = 0;
if( begin > end ) if( begin > end )
EXCHG( begin, end ); std::swap( begin, end );
member = begin; member = begin;
tmp = busName; tmp = busName;

View File

@ -344,9 +344,7 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
dc.SetUserScale( scale, scale ); dc.SetUserScale( scale, scale );
wxPoint offset = bBox.Centre(); wxPoint offset = -bBox.Centre();
NEGATE( offset.x );
NEGATE( offset.y );
// Avoid rendering when either dimension is zero // Avoid rendering when either dimension is zero
int width, height; int width, height;

View File

@ -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 // 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 // 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 ); coordText = StringFromValue( g_UserUnit, coord.y );
posYTextCtrl->SetValue( coordText ); 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 // 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 // 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 ); field.SetTextPosition( pos );

View File

@ -164,7 +164,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonUpClick( wxCommandEvent& event )
for( size_t ii = 0; ii < selections.GetCount(); ii++ ) for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{ {
int jj = selections[ii]; int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1]); std::swap( libnames[jj], libnames[jj-1]);
} }
m_ListLibr->Set(libnames); m_ListLibr->Set(libnames);
@ -198,7 +198,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonDownClick( wxCommandEvent& event )
for( int ii = selections.GetCount()-1; ii >= 0; ii-- ) for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{ {
int jj = selections[ii]; int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]); std::swap( libnames[jj], libnames[jj+1]);
} }
m_ListLibr->Set( libnames ); m_ListLibr->Set( libnames );

View File

@ -195,7 +195,7 @@ bool LIB_ARC::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM
// TODO: use aTransMat to calculates parameters // TODO: use aTransMat to calculates parameters
wxPoint relativePosition = aPosition; wxPoint relativePosition = aPosition;
NEGATE( relativePosition.y ); // reverse Y axis relativePosition.y = -relativePosition.y; // reverse Y axis
int distance = KiROUND( GetLineLength( m_Pos, relativePosition ) ); 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 // relative to the start point to end point vector lies
if( CrossProduct( startEndVector, startRelativePositionVector ) < 0 ) 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 // 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 -= aCenter.x;
m_ArcEnd.x *= -1; m_ArcEnd.x *= -1;
m_ArcEnd.x += aCenter.x; m_ArcEnd.x += aCenter.x;
EXCHG( m_ArcStart, m_ArcEnd ); std::swap( m_ArcStart, m_ArcEnd );
EXCHG( m_t1, m_t2 ); std::swap( m_t1, m_t2 );
m_t1 = 1800 - m_t1; m_t1 = 1800 - m_t1;
m_t2 = 1800 - m_t2; m_t2 = 1800 - m_t2;
if( m_t1 > 3600 || m_t2 > 3600 ) 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 -= aCenter.y;
m_ArcEnd.y *= -1; m_ArcEnd.y *= -1;
m_ArcEnd.y += aCenter.y; m_ArcEnd.y += aCenter.y;
EXCHG( m_ArcStart, m_ArcEnd ); std::swap( m_ArcStart, m_ArcEnd );
EXCHG( m_t1, m_t2 ); std::swap( m_t1, m_t2 );
m_t1 = - m_t1; m_t1 = - m_t1;
m_t2 = - m_t2; m_t2 = - m_t2;
if( m_t1 > 3600 || m_t2 > 3600 ) 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 ) if( swap )
{ {
EXCHG( pos1.x, pos2.x ); std::swap( pos1.x, pos2.x );
EXCHG( pos1.y, pos2.y ); std::swap( pos1.y, pos2.y );
} }
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
@ -515,8 +515,8 @@ start(%d, %d), end(%d, %d), radius %d" ),
if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) ) if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) )
{ {
EXCHG( endPos.x, startPos.x ); std::swap( endPos.x, startPos.x );
EXCHG( endPos.y, startPos.y ); std::swap( endPos.y, startPos.y );
} }
/* Start with the start and end point of the arc. */ /* Start with the start and end point of the arc. */

View File

@ -721,7 +721,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
if( m_updateText ) if( m_updateText )
{ {
EXCHG( m_Text, m_savedText ); std::swap( m_Text, m_savedText );
m_updateText = false; m_updateText = false;
} }

View File

@ -2085,13 +2085,13 @@ const EDA_RECT LIB_PIN::GetBoundingBox() const
case PIN_DOWN: case PIN_DOWN:
RotatePoint( &begin, wxPoint( 0, 0 ), 900 ); RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
RotatePoint( &end, wxPoint( 0, 0 ), 900 ); RotatePoint( &end, wxPoint( 0, 0 ), 900 );
NEGATE( begin.x ); begin.x = -begin.x;
NEGATE( end.x ); end.x = -end.x;
break; break;
case PIN_LEFT: case PIN_LEFT:
NEGATE( begin.x ); begin.x = -begin.x;
NEGATE( end.x ); end.x = -end.x;
break; break;
case PIN_RIGHT: case PIN_RIGHT:

View File

@ -538,7 +538,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
if( m_updateText ) if( m_updateText )
{ {
EXCHG( m_Text, m_savedText ); std::swap( m_Text, m_savedText );
m_updateText = false; m_updateText = false;
} }

View File

@ -127,8 +127,8 @@ void SCH_BITMAP::SwapData( SCH_ITEM* aItem )
GetChars( aItem->GetClass() ) ) ); GetChars( aItem->GetClass() ) ) );
SCH_BITMAP* item = (SCH_BITMAP*) aItem; SCH_BITMAP* item = (SCH_BITMAP*) aItem;
EXCHG( m_Pos, item->m_Pos ); std::swap( m_Pos, item->m_Pos );
EXCHG( m_Image, item->m_Image ); std::swap( m_Image, item->m_Image );
} }
@ -223,10 +223,7 @@ wxSize SCH_BITMAP::GetSize() const
*/ */
void SCH_BITMAP::MirrorX( int aXaxis_position ) void SCH_BITMAP::MirrorX( int aXaxis_position )
{ {
m_Pos.y -= aXaxis_position; MIRROR( m_Pos.y, aXaxis_position );
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
m_Image->Mirror( true ); m_Image->Mirror( true );
} }
@ -236,9 +233,7 @@ void SCH_BITMAP::MirrorX( int aXaxis_position )
*/ */
void SCH_BITMAP::MirrorY( int aYaxis_position ) void SCH_BITMAP::MirrorY( int aYaxis_position )
{ {
m_Pos.x -= aYaxis_position; MIRROR( m_Pos.x, aYaxis_position );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
m_Image->Mirror( false ); m_Image->Mirror( false );
} }

View File

@ -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 ); SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) ); wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
EXCHG( m_pos, item->m_pos ); std::swap( m_pos, item->m_pos );
EXCHG( m_size, item->m_size ); 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 ) void SCH_BUS_ENTRY_BASE::MirrorX( int aXaxis_position )
{ {
m_pos.y -= aXaxis_position; MIRROR( m_pos.y, aXaxis_position );
NEGATE( m_pos.y ); m_size.y = -m_size.y;
m_pos.y += aXaxis_position;
NEGATE( m_size.y );
} }
void SCH_BUS_ENTRY_BASE::MirrorY( int aYaxis_position ) void SCH_BUS_ENTRY_BASE::MirrorY( int aYaxis_position )
{ {
m_pos.x -= aYaxis_position; MIRROR( m_pos.x, aYaxis_position );
NEGATE( m_pos.x ); m_size.x = -m_size.x;
m_pos.x += aYaxis_position;
NEGATE( m_size.x );
} }

View File

@ -698,11 +698,11 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
SCH_COMPONENT* component = (SCH_COMPONENT*) aItem; SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
EXCHG( m_part_name, component->m_part_name ); std::swap( m_part_name, component->m_part_name );
EXCHG( m_part, component->m_part ); std::swap( m_part, component->m_part );
EXCHG( m_Pos, component->m_Pos ); std::swap( m_Pos, component->m_Pos );
EXCHG( m_unit, component->m_unit ); std::swap( m_unit, component->m_unit );
EXCHG( m_convert, component->m_convert ); std::swap( m_convert, component->m_convert );
TRANSFORM tmp = m_transform; TRANSFORM tmp = m_transform;
@ -723,7 +723,7 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
GetField( ii )->SetParent( this ); 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: // H and W must be > 0:
if( x2 < x1 ) if( x2 < x1 )
EXCHG( x2, x1 ); std::swap( x2, x1 );
if( y2 < y1 ) if( y2 < y1 )
EXCHG( y2, y1 ); std::swap( y2, y1 );
bBox.SetX( x1 ); bBox.SetX( x1 );
bBox.SetY( y1 ); bBox.SetY( y1 );
@ -1547,9 +1547,7 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position )
int dx = m_Pos.x; int dx = m_Pos.x;
SetOrientation( CMP_MIRROR_Y ); SetOrientation( CMP_MIRROR_Y );
m_Pos.x -= aYaxis_position; MIRROR( m_Pos.x, aYaxis_position );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
dx -= m_Pos.x; // dx,0 is the move vector for this transform dx -= m_Pos.x; // dx,0 is the move vector for this transform
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
@ -1567,9 +1565,7 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position )
int dy = m_Pos.y; int dy = m_Pos.y;
SetOrientation( CMP_MIRROR_X ); SetOrientation( CMP_MIRROR_X );
m_Pos.y -= aXaxis_position; MIRROR( m_Pos.y, aXaxis_position );
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
dy -= m_Pos.y; // dy,0 is the move vector for this transform dy -= m_Pos.y; // dy,0 is the move vector for this transform
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )

View File

@ -238,18 +238,18 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
SCH_FIELD* item = (SCH_FIELD*) aItem; SCH_FIELD* item = (SCH_FIELD*) aItem;
EXCHG( m_Text, item->m_Text ); std::swap( m_Text, item->m_Text );
EXCHG( m_Layer, item->m_Layer ); std::swap( m_Layer, item->m_Layer );
EXCHG( m_Pos, item->m_Pos ); std::swap( m_Pos, item->m_Pos );
EXCHG( m_Size, item->m_Size ); std::swap( m_Size, item->m_Size );
EXCHG( m_Thickness, item->m_Thickness ); std::swap( m_Thickness, item->m_Thickness );
EXCHG( m_Orient, item->m_Orient ); std::swap( m_Orient, item->m_Orient );
EXCHG( m_Mirror, item->m_Mirror ); std::swap( m_Mirror, item->m_Mirror );
EXCHG( m_Attributs, item->m_Attributs ); std::swap( m_Attributs, item->m_Attributs );
EXCHG( m_Italic, item->m_Italic ); std::swap( m_Italic, item->m_Italic );
EXCHG( m_Bold, item->m_Bold ); std::swap( m_Bold, item->m_Bold );
EXCHG( m_HJustify, item->m_HJustify ); std::swap( m_HJustify, item->m_HJustify );
EXCHG( m_VJustify, item->m_VJustify ); 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, // Due to the Y axis direction, we must mirror the bounding box,
// relative to the text position: // relative to the text position:
begin.y -= pos.y; MIRROR( begin.y, pos.y );
end.y -= pos.y; MIRROR( end.y, pos.y );
NEGATE( begin.y );
NEGATE( end.y );
begin.y += pos.y;
end.y += pos.y;
// Now, apply the component transform (mirror/rot) // Now, apply the component transform (mirror/rot)
begin = parentComponent->GetTransform().TransformCoordinate( begin ); begin = parentComponent->GetTransform().TransformCoordinate( begin );

View File

@ -74,7 +74,7 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap junction data with invalid item." ) ); wxT( "Cannot swap junction data with invalid item." ) );
SCH_JUNCTION* item = (SCH_JUNCTION*) aItem; 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 ) void SCH_JUNCTION::MirrorX( int aXaxis_position )
{ {
m_pos.y -= aXaxis_position; MIRROR( m_pos.y, aXaxis_position );
NEGATE( m_pos.y );
m_pos.y += aXaxis_position;
} }
void SCH_JUNCTION::MirrorY( int aYaxis_position ) void SCH_JUNCTION::MirrorY( int aYaxis_position )
{ {
m_pos.x -= aYaxis_position; MIRROR( m_pos.x, aYaxis_position );
NEGATE( m_pos.x );
m_pos.x += aYaxis_position;
} }

View File

@ -250,23 +250,15 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
void SCH_LINE::MirrorX( int aXaxis_position ) void SCH_LINE::MirrorX( int aXaxis_position )
{ {
m_start.y -= aXaxis_position; MIRROR( m_start.y, aXaxis_position );
NEGATE( m_start.y ); MIRROR( m_end.y, aXaxis_position );
m_start.y += aXaxis_position;
m_end.y -= aXaxis_position;
NEGATE( m_end.y );
m_end.y += aXaxis_position;
} }
void SCH_LINE::MirrorY( int aYaxis_position ) void SCH_LINE::MirrorY( int aYaxis_position )
{ {
m_start.x -= aYaxis_position; MIRROR( m_start.x, aYaxis_position );
NEGATE( m_start.x ); MIRROR( m_end.x, aYaxis_position );
m_start.x += aYaxis_position;
m_end.x -= aYaxis_position;
NEGATE( m_end.x );
m_end.x += aYaxis_position;
} }
@ -313,7 +305,7 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
} }
else if( m_end == aLine->m_end ) 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 ) else if( m_end != aLine->m_start )
{ {

View File

@ -63,8 +63,8 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap no connect data with invalid item." ) ); wxT( "Cannot swap no connect data with invalid item." ) );
SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem; SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem;
EXCHG( m_pos, item->m_pos ); std::swap( m_pos, item->m_pos );
EXCHG( m_size, item->m_size ); 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 ) void SCH_NO_CONNECT::MirrorX( int aXaxis_position )
{ {
m_pos.y -= aXaxis_position; MIRROR( m_pos.y, aXaxis_position );
NEGATE( m_pos.y );
m_pos.y += aXaxis_position;
} }
void SCH_NO_CONNECT::MirrorY( int aYaxis_position ) void SCH_NO_CONNECT::MirrorY( int aYaxis_position )
{ {
m_pos.x -= aYaxis_position; MIRROR( m_pos.x, aYaxis_position );
NEGATE( m_pos.x );
m_pos.x += aYaxis_position;
} }

View File

@ -319,11 +319,11 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem )
SCH_SHEET* sheet = ( SCH_SHEET* ) aItem; SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
EXCHG( m_pos, sheet->m_pos ); std::swap( m_pos, sheet->m_pos );
EXCHG( m_size, sheet->m_size ); std::swap( m_size, sheet->m_size );
EXCHG( m_name, sheet->m_name ); std::swap( m_name, sheet->m_name );
EXCHG( m_sheetNameSize, sheet->m_sheetNameSize ); std::swap( m_sheetNameSize, sheet->m_sheetNameSize );
EXCHG( m_fileNameSize, sheet->m_fileNameSize ); std::swap( m_fileNameSize, sheet->m_fileNameSize );
m_pins.swap( sheet->m_pins ); m_pins.swap( sheet->m_pins );
// Ensure sheet labels have their .m_Parent member pointing really on their // 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 ) if( m_size.x < 0 )
{ {
m_pos.x += m_size.x; m_pos.x += m_size.x;
NEGATE( m_size.x ); m_size.x = -m_size.x;
} }
if( m_size.y < 0 ) if( m_size.y < 0 )
{ {
m_pos.y += m_size.y; m_pos.y += m_size.y;
NEGATE( m_size.y ); m_size.y = -m_size.y;
} }
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins ) 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 ) void SCH_SHEET::MirrorX( int aXaxis_position )
{ {
m_pos.y -= aXaxis_position; MIRROR( m_pos.y, aXaxis_position );
NEGATE( m_pos.y );
m_pos.y += aXaxis_position;
m_pos.y -= m_size.y; m_pos.y -= m_size.y;
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins ) 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 ) void SCH_SHEET::MirrorY( int aYaxis_position )
{ {
m_pos.x -= aYaxis_position; MIRROR( m_pos.x, aYaxis_position );
NEGATE( m_pos.x );
m_pos.x += aYaxis_position;
m_pos.x -= m_size.x; m_pos.x -= m_size.x;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )

View File

@ -204,9 +204,7 @@ void SCH_TEXT::MirrorY( int aYaxis_position )
break; break;
} }
m_Pos.x -= aYaxis_position; MIRROR( m_Pos.x, aYaxis_position );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
} }
@ -228,9 +226,8 @@ void SCH_TEXT::MirrorX( int aXaxis_position )
default: default:
break; break;
} }
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y ); MIRROR( m_Pos.y, aXaxis_position );
m_Pos.y += aXaxis_position;
} }
@ -306,18 +303,18 @@ void SCH_TEXT::SwapData( SCH_ITEM* aItem )
{ {
SCH_TEXT* item = (SCH_TEXT*) aItem; SCH_TEXT* item = (SCH_TEXT*) aItem;
EXCHG( m_Text, item->m_Text ); std::swap( m_Text, item->m_Text );
EXCHG( m_Pos, item->m_Pos ); std::swap( m_Pos, item->m_Pos );
EXCHG( m_Size, item->m_Size ); std::swap( m_Size, item->m_Size );
EXCHG( m_Thickness, item->m_Thickness ); std::swap( m_Thickness, item->m_Thickness );
EXCHG( m_shape, item->m_shape ); std::swap( m_shape, item->m_shape );
EXCHG( m_Orient, item->m_Orient ); std::swap( m_Orient, item->m_Orient );
EXCHG( m_Layer, item->m_Layer ); std::swap( m_Layer, item->m_Layer );
EXCHG( m_HJustify, item->m_HJustify ); std::swap( m_HJustify, item->m_HJustify );
EXCHG( m_VJustify, item->m_VJustify ); std::swap( m_VJustify, item->m_VJustify );
EXCHG( m_isDangling, item->m_isDangling ); std::swap( m_isDangling, item->m_isDangling );
EXCHG( m_schematicOrientation, item->m_schematicOrientation ); 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 ); GRSetDrawMode( DC, DrawMode );
wxPoint text_offset = aOffset + GetSchematicTextOffset(); 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 ); 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) if( m_isDangling && panel)
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
@ -859,9 +856,7 @@ void SCH_LABEL::MirrorX( int aXaxis_position )
break; break;
} }
m_Pos.y -= aXaxis_position; MIRROR( m_Pos.y, aXaxis_position );
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
} }
@ -1140,9 +1135,7 @@ void SCH_GLOBALLABEL::MirrorY( int aYaxis_position )
break; break;
} }
m_Pos.x -= aYaxis_position; MIRROR( m_Pos.x, aYaxis_position );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
} }
@ -1159,9 +1152,7 @@ void SCH_GLOBALLABEL::MirrorX( int aXaxis_position )
break; break;
} }
m_Pos.y -= aXaxis_position; MIRROR( m_Pos.y, aXaxis_position );
NEGATE( m_Pos.y );
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; int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); 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_RECT* clipbox = panel? panel->GetClipBox() : NULL;
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); 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 ); CreateGraphicShape( Poly, m_Pos + aOffset );
GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); 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 ); 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(); wxPoint text_offset = offset + GetSchematicTextOffset();
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); 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 ); CreateGraphicShape( Poly, m_Pos + offset );
GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
@ -1750,9 +1741,7 @@ void SCH_HIERLABEL::MirrorY( int aYaxis_position )
break; break;
} }
m_Pos.x -= aYaxis_position; MIRROR( m_Pos.x, aYaxis_position );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
} }
@ -1769,9 +1758,7 @@ void SCH_HIERLABEL::MirrorX( int aXaxis_position )
break; break;
} }
m_Pos.y -= aXaxis_position; MIRROR( m_Pos.y, aXaxis_position );
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
} }

View File

@ -143,7 +143,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
double rotation; double rotation;
if( mapExposure( aParent ) == false ) if( mapExposure( aParent ) == false )
{ {
EXCHG(aColor, aAltColor); std::swap( aColor, aAltColor );
} }
switch( primitive_id ) switch( primitive_id )

View File

@ -111,7 +111,7 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
wxPoint abPos = aXYPosition + m_imageParams->m_ImageJustifyOffset; wxPoint abPos = aXYPosition + m_imageParams->m_ImageJustifyOffset;
if( m_swapAxis ) if( m_swapAxis )
EXCHG( abPos.x, abPos.y ); std::swap( abPos.x, abPos.y );
abPos += m_layerOffset + m_imageParams->m_ImageOffset; abPos += m_layerOffset + m_imageParams->m_ImageOffset;
abPos.x = KiROUND( abPos.x * m_drawScale.x ); 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 // Negate A axis if mirrored
if( m_mirrorA ) 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 // abPos.y must be negated when no mirror, because draw axis is top to bottom
if( !m_mirrorB ) if( !m_mirrorB )
NEGATE( abPos.y ); abPos.y = -abPos.y;
return abPos; return abPos;
} }
@ -138,10 +138,10 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) const
wxPoint xyPos = aABPosition; wxPoint xyPos = aABPosition;
if( m_mirrorA ) if( m_mirrorA )
NEGATE( xyPos.x ); xyPos.x = -xyPos.x;
if( !m_mirrorB ) if( !m_mirrorB )
NEGATE( xyPos.y ); xyPos.y = -xyPos.y;
double rotation = m_lyrRotation * 10 + m_imageParams->m_ImageRotation * 10; 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; xyPos -= m_layerOffset + m_imageParams->m_ImageOffset;
if( m_swapAxis ) if( m_swapAxis )
EXCHG( xyPos.x, xyPos.y ); std::swap( xyPos.x, xyPos.y );
return xyPos - m_imageParams->m_ImageJustifyOffset; 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 ) if( !isDark )
{ {
// draw in background color ("negative" color) // draw in background color ("negative" color)
EXCHG( color, alt_color ); std::swap( color, alt_color );
} }
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
@ -470,7 +470,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
// make calculations more easy if ensure start.x < end.x // make calculations more easy if ensure start.x < end.x
// (only 2 quadrants to consider) // (only 2 quadrants to consider)
if( start.x > end.x ) if( start.x > end.x )
EXCHG( start, end ); std::swap( start, end );
// calculate values relative to start point: // calculate values relative to start point:
wxPoint delta = end - start; wxPoint delta = end - start;
@ -481,7 +481,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
bool change = delta.y < 0; bool change = delta.y < 0;
if( change ) if( change )
NEGATE( delta.y); delta.y = -delta.y;
// Now create the full polygon. // Now create the full polygon.
// Due to previous changes, the shape is always something like // 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++ ) for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ )
{ {
if( change ) if( change )
NEGATE( m_PolyCorners[ii].y); m_PolyCorners[ii].y = -m_PolyCorners[ii].y;
m_PolyCorners[ii] += start; m_PolyCorners[ii] += start;
} }

View File

@ -291,8 +291,8 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
} }
// Reverse Y axis: // Reverse Y axis:
NEGATE( seg_start.y ); seg_start.y = -seg_start.y;
NEGATE( seg_end.y ); seg_end.y = -seg_end.y;
writePcbLineItem( isArc, seg_start, seg_end, aGbrItem->m_Size.x, aLayer, angle ); 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; seg_end = aGbrItem->m_End;
// Reverse Y axis: // Reverse Y axis:
NEGATE( seg_start.y ); seg_start.y = -seg_start.y;
NEGATE( seg_end.y ); seg_end.y = -seg_end.y;
writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer ); 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 ) ); -RAD2DECIDEG( DELTA_ANGLE * ii ) );
seg_end = curr_end; seg_end = curr_end;
// Reverse Y axis: // Reverse Y axis:
NEGATE( seg_start.y ); seg_start.y = -seg_start.y;
NEGATE( seg_end.y ); seg_end.y = -seg_end.y;
writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer ); writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
curr_start = curr_end; 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_start = curr_start;
seg_end = end; seg_end = end;
// Reverse Y axis: // Reverse Y axis:
NEGATE( seg_start.y ); seg_start.y = -seg_start.y;
NEGATE( seg_end.y ); seg_end.y = -seg_end.y;
writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer ); 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; wxPoint via_pos = aGbrItem->m_Start;
int width = (aGbrItem->m_Size.x + aGbrItem->m_Size.y) / 2; int width = (aGbrItem->m_Size.x + aGbrItem->m_Size.y) / 2;
// Reverse Y axis: // Reverse Y axis:
NEGATE( via_pos.y ); via_pos.y = -via_pos.y;
// Layers are Front to Back // Layers are Front to Back
fprintf( m_fp, " (via (at %s %s) (size %s)", fprintf( m_fp, " (via (at %s %s) (size %s)",

View File

@ -252,7 +252,7 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* ---S--- * ---S---
* 3 | 4 * 3 | 4
*/ */
NEGATE( center.x); center.x = -center.x;
} }
else if( (delta.x >= 0) && (delta.y < 0) ) 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--- * ---S---
* C | 4 * C | 4
*/ */
NEGATE( center.x); center.x = -center.x;
NEGATE( center.y); center.y = -center.y;
} }
else else
{ {
@ -280,7 +280,7 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* ---S--- * ---S---
* E | C * E | C
*/ */
NEGATE( center.y); center.y = -center.y;
} }
// Due to your draw arc function, we need this: // Due to your draw arc function, we need this:

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 1992-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -84,23 +84,21 @@ static inline const wxChar* GetChars( const wxString& s )
#endif #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 /// # of elements in an array
#define DIM( x ) unsigned( sizeof(x) / sizeof( (x)[0] ) ) // not size_t #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 * Function MIRROR
// this soon or late) * Mirror @a aPoint in @a aMirrorRef.
template <class T, class T2> inline void EXCHG( T& a, T2& b ) */
template<typename T>
void MIRROR( T& aPoint, const T& aMirrorRef )
{ {
T temp = a; aPoint = -( aPoint - aMirrorRef ) + aMirrorRef;
a = b;
b = temp;
} }
/** /**
* Function Clamp * Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work * limits @a value within the range @a lower <= @a value <= @a upper. It will work

View File

@ -936,7 +936,7 @@ double compute_Ratsnest_PlaceModule( BOARD* aBrd )
// ttry to have always dx >= dy to calculate the cost of the rastsnet // ttry to have always dx >= dy to calculate the cost of the rastsnet
if( dx < dy ) if( dx < dy )
EXCHG( dx, dy ); std::swap( dx, dy );
// Cost of the connection = lenght + penalty due to the slope // Cost of the connection = lenght + penalty due to the slope
// dx is the biggest lenght relative to the X or Y axis // dx is the biggest lenght relative to the X or Y axis

View File

@ -114,7 +114,7 @@ void PlacePad( D_PAD* aPad, int color, int marge, int op_logic )
// Orientation turned 90 deg. // Orientation turned 90 deg.
if( aPad->GetOrientation() == 900 || aPad->GetOrientation() == 2700 ) if( aPad->GetOrientation() == 900 || aPad->GetOrientation() == 2700 )
{ {
EXCHG( dx, dy ); std::swap( dx, dy );
} }
TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - 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( x0 == x1 ) // Vertical.
{ {
if( y1 < y0 ) if( y1 < y0 )
EXCHG( y0, y1 ); std::swap( y0, y1 );
dy = y0 / RoutingMatrix.m_GridRouting; dy = y0 / RoutingMatrix.m_GridRouting;
lim = y1 / 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( y0 == y1 ) // Horizontal
{ {
if( x1 < x0 ) if( x1 < x0 )
EXCHG( x0, x1 ); std::swap( x0, x1 );
dx = x0 / RoutingMatrix.m_GridRouting; dx = x0 / RoutingMatrix.m_GridRouting;
lim = x1 / 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 ) if( x1 < x0 )
{ {
EXCHG( x1, x0 ); EXCHG( y1, y0 ); std::swap( x1, x0 );
std::swap( y1, y0 );
} }
dx = x0 / RoutingMatrix.m_GridRouting; 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 ) if( y1 < y0 )
{ {
EXCHG( x1, x0 ); std::swap( x1, x0 );
EXCHG( y1, y0 ); std::swap( y1, y0 );
} }
dy = y0 / RoutingMatrix.m_GridRouting; 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 // Make coordinate ux1 tj > ux0 to simplify calculations
if( ux1 < ux0 ) if( ux1 < ux0 )
{ {
EXCHG( ux1, ux0 ); std::swap( ux1, ux0 );
EXCHG( uy1, uy0 ); std::swap( uy1, uy0 );
} }
// Calculating the incrementing the Y axis // Calculating the incrementing the Y axis

View File

@ -484,7 +484,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
int py = pt_cur_ch->m_PadStart->GetPosition().y; int py = pt_cur_ch->m_PadStart->GetPosition().y;
if( ( ( int( pt_cur_ch->m_PadStart->GetOrientation() ) / 900 ) & 1 ) != 0 ) 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 ) ) if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route; 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; py = pt_cur_ch->m_PadEnd->GetPosition().y;
if( ( ( int( pt_cur_ch->m_PadEnd->GetOrientation() ) / 900) & 1 ) != 0 ) 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 ) ) if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route; goto end_of_route;

View File

@ -606,11 +606,11 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
pad->SetX0( pad->GetPosition().x ); pad->SetX0( pad->GetPosition().x );
tmp = pad->GetOffset(); tmp = pad->GetOffset();
NEGATE( tmp.x ); tmp.x = -tmp.x;
pad->SetOffset( tmp ); pad->SetOffset( tmp );
tmpz = pad->GetDelta(); tmpz = pad->GetDelta();
NEGATE( tmpz.x ); tmpz.x = -tmpz.x;
pad->SetDelta( tmpz ); pad->SetDelta( tmpz );
pad->SetOrientation( 1800 - pad->GetOrientation() ); pad->SetOrientation( 1800 - pad->GetOrientation() );

View File

@ -258,7 +258,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
wxSize size = textmod->GetSize(); wxSize size = textmod->GetSize();
if( textmod->IsMirrored() ) if( textmod->IsMirrored() )
NEGATE( size.x ); size.x = -size.x;
DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK,
textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetShownText(), textmod->GetDrawRotation(), size,
@ -380,7 +380,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
wxSize size = GetSize(); wxSize size = GetSize();
if( IsMirrored() ) if( IsMirrored() )
NEGATE( size.x ); size.x = -size.x;
s_cornerBuffer = &aCornerBuffer; s_cornerBuffer = &aCornerBuffer;
s_textWidth = GetThickness() + ( 2 * aClearanceValue ); s_textWidth = GetThickness() + ( 2 * aClearanceValue );
@ -886,9 +886,9 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
if( dx < dy ) if( dx < dy )
{ {
EXCHG( dx, dy ); std::swap( dx, dy );
supp_angle = 900; 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 int deltasize = dx - dy; // = distance between shape position and the 2 demi-circle ends centre

View File

@ -225,7 +225,7 @@ void BOARD_ITEM::SwapData( BOARD_ITEM* aImage )
TRACK* track = (TRACK*) this; TRACK* track = (TRACK*) this;
TRACK* image = (TRACK*) aImage; 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. // swap start, end, width and shape for track and image.
wxPoint exchp = track->GetStart(); wxPoint exchp = track->GetStart();
@ -258,7 +258,7 @@ void BOARD_ITEM::SwapData( BOARD_ITEM* aImage )
if( viaimage->IsDrillDefault() ) if( viaimage->IsDrillDefault() )
itmp = -1; itmp = -1;
EXCHG(itmp, drilltmp ); std::swap(itmp, drilltmp );
if( drilltmp > 0 ) if( drilltmp > 0 )
via->SetDrill( drilltmp ); via->SetDrill( drilltmp );

View File

@ -1409,7 +1409,7 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
aEndLayer = aStartLayer; aEndLayer = aStartLayer;
if( aEndLayer < aStartLayer ) if( aEndLayer < aStartLayer )
EXCHG( aEndLayer, aStartLayer ); std::swap( aEndLayer, aStartLayer );
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ ) for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
{ {

View File

@ -136,9 +136,7 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
m_End.y = aCentre.y - (m_End.y - aCentre.y); m_End.y = aCentre.y - (m_End.y - aCentre.y);
if( m_Shape == S_ARC ) if( m_Shape == S_ARC )
{ m_Angle = -m_Angle;
NEGATE( m_Angle );
}
SetLayer( FlipLayer( GetLayer() ) ); SetLayer( FlipLayer( GetLayer() ) );
} }
@ -294,12 +292,12 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( !panel->GetPrintMirrored() ) if( !panel->GetPrintMirrored() )
{ {
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
else // Mirrored mode: arc orientation is reversed else // Mirrored mode: arc orientation is reversed
{ {
if( StAngle < EndAngle ) if( StAngle < EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
if( filled ) if( filled )

View File

@ -197,12 +197,12 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( !panel->GetPrintMirrored() ) if( !panel->GetPrintMirrored() )
{ {
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
else // Mirrored mode: arc orientation is reversed else // Mirrored mode: arc orientation is reversed
{ {
if( StAngle < EndAngle ) if( StAngle < EndAngle )
EXCHG( StAngle, EndAngle ); std::swap( StAngle, EndAngle );
} }
if( filled ) if( filled )
@ -311,15 +311,15 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre )
pt.y += aCentre.y; pt.y += aCentre.y;
SetEnd( pt ); SetEnd( pt );
NEGATE( m_Start0.y ); m_Start0.y = -m_Start0.y;
NEGATE( m_End0.y ); m_End0.y = -m_End0.y;
break; break;
case S_POLYGON: case S_POLYGON:
// polygon corners coordinates are always relative to the // polygon corners coordinates are always relative to the
// footprint position, orientation 0 // footprint position, orientation 0
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) 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() ) ); SetLayer( FlipLayer( GetLayer() ) );

View File

@ -954,7 +954,7 @@ void MODULE::Flip( const wxPoint& aCentre )
SetLayer( FlipLayer( GetLayer() ) ); SetLayer( FlipLayer( GetLayer() ) );
// Reverse mirror orientation. // Reverse mirror orientation.
NEGATE( m_Orient ); m_Orient = -m_Orient;
NORMALIZE_ANGLE_POS( m_Orient ); NORMALIZE_ANGLE_POS( m_Orient );
// Mirror pads to other side of board about the x axis, i.e. vertically. // Mirror pads to other side of board about the x axis, i.e. vertically.

View File

@ -285,9 +285,9 @@ void D_PAD::Flip( const wxPoint& aCentre )
SetY( y ); SetY( y );
NEGATE( m_Pos0.y ); m_Pos0.y = -m_Pos0.y;
NEGATE( m_Offset.y ); m_Offset.y = -m_Offset.y;
NEGATE( m_DeltaSize.y ); m_DeltaSize.y = -m_DeltaSize.y;
SetOrientation( -GetOrientation() ); SetOrientation( -GetOrientation() );

View File

@ -412,7 +412,7 @@ void VIA::SetLayerPair( LAYER_ID aTopLayer, LAYER_ID aBottomLayer )
} }
if( aBottomLayer < aTopLayer ) if( aBottomLayer < aTopLayer )
EXCHG( aBottomLayer, aTopLayer ); std::swap( aBottomLayer, aTopLayer );
m_Layer = aTopLayer; m_Layer = aTopLayer;
m_BottomLayer = aBottomLayer; m_BottomLayer = aBottomLayer;
@ -430,7 +430,7 @@ void VIA::LayerPair( LAYER_ID* top_layer, LAYER_ID* bottom_layer ) const
t_layer = m_Layer; t_layer = m_Layer;
if( b_layer < t_layer ) if( b_layer < t_layer )
EXCHG( b_layer, t_layer ); std::swap( b_layer, t_layer );
} }
if( top_layer ) if( top_layer )
@ -1502,8 +1502,8 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
if( EndPad ) if( EndPad )
Track->SetState( BEGIN_ONPAD, true ); Track->SetState( BEGIN_ONPAD, true );
EXCHG( Track->m_Start, Track->m_End ); std::swap( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end ); std::swap( Track->start, Track->end );
ok = 1; ok = 1;
return ok; return ok;
} }
@ -1546,8 +1546,8 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
if( EndPad ) if( EndPad )
Track->SetState( BEGIN_ONPAD, true ); Track->SetState( BEGIN_ONPAD, true );
EXCHG( Track->m_Start, Track->m_End ); std::swap( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end ); std::swap( Track->start, Track->end );
break; break;
case 1: case 1:

View File

@ -773,8 +773,7 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
{ {
for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ ) for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ )
{ {
int py = m_Poly->m_CornersList.GetY( ic ) - mirror_ref.y; int py = mirror_ref.y - m_Poly->m_CornersList.GetY( ic );
NEGATE( py );
m_Poly->m_CornersList.SetY( ic, py + mirror_ref.y ); 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: */ /* mirror filled areas: */
for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ ) for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ )
{ {
int py = m_FilledPolysList.GetY( ic ) - mirror_ref.y; int py = mirror_ref.y - m_FilledPolysList.GetY( ic );
NEGATE( py );
m_FilledPolysList.SetY( ic, py + mirror_ref.y ); m_FilledPolysList.SetY( ic, py + mirror_ref.y );
} }
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ ) for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
{ {
m_FillSegmList[ic].m_Start.y -= mirror_ref.y; MIRROR( m_FillSegmList[ic].m_Start.y, mirror_ref.y );
NEGATE( m_FillSegmList[ic].m_Start.y ); MIRROR( m_FillSegmList[ic].m_End.y, mirror_ref.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;
} }
} }

View File

@ -502,7 +502,7 @@ int CONNECTIONS::Merge_PadsSubNets( int aOldSubNet, int aNewSubNet )
return 0; return 0;
if( (aOldSubNet > 0) && (aOldSubNet < aNewSubNet) ) if( (aOldSubNet > 0) && (aOldSubNet < aNewSubNet) )
EXCHG( aOldSubNet, aNewSubNet ); std::swap( aOldSubNet, aNewSubNet );
// Examine connections between intersecting pads // Examine connections between intersecting pads
for( unsigned ii = 0; ii < m_sortedPads.size(); ii++ ) for( unsigned ii = 0; ii < m_sortedPads.size(); ii++ )
@ -532,7 +532,7 @@ int CONNECTIONS::Merge_SubNets( int aOldSubNet, int aNewSubNet )
return 0; return 0;
if( (aOldSubNet > 0) && (aOldSubNet < aNewSubNet) ) if( (aOldSubNet > 0) && (aOldSubNet < aNewSubNet) )
EXCHG( aOldSubNet, aNewSubNet ); std::swap( aOldSubNet, aNewSubNet );
curr_track = (TRACK*)m_firstTrack; curr_track = (TRACK*)m_firstTrack;

View File

@ -350,11 +350,11 @@ void DIALOG_PAD_PROPERTIES::initValues()
if( m_isFlipped ) if( m_isFlipped )
{ {
wxPoint pt = m_dummyPad->GetOffset(); wxPoint pt = m_dummyPad->GetOffset();
NEGATE( pt.y ); pt.y = -pt.y;
m_dummyPad->SetOffset( pt ); m_dummyPad->SetOffset( pt );
wxSize sz = m_dummyPad->GetDelta(); wxSize sz = m_dummyPad->GetDelta();
NEGATE( sz.y ); sz.y = -sz.y;
m_dummyPad->SetDelta( sz ); m_dummyPad->SetDelta( sz );
// flip pad's layers // flip pad's layers
@ -457,7 +457,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
angle = m_currentPad->GetOrientation() - module->GetOrientation(); angle = m_currentPad->GetOrientation() - module->GetOrientation();
if( m_isFlipped ) if( m_isFlipped )
NEGATE( angle ); angle = -angle;
m_dummyPad->SetOrientation( angle ); m_dummyPad->SetOrientation( angle );
} }

View File

@ -126,7 +126,7 @@ void DRAG_SEGM_PICKER::SetTrackEndsCoordinates( wxPoint aOffset )
RotatePoint(&padoffset, curr_rot_offset); RotatePoint(&padoffset, curr_rot_offset);
if( flip ) if( flip )
NEGATE( padoffset.y ); padoffset.y = -padoffset.y;
m_Track->SetStart( m_Pad_Start->GetPosition() - aOffset + padoffset ); 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 ); RotatePoint( &padoffset, curr_rot_offset );
if( flip ) if( flip )
NEGATE( padoffset.y ); padoffset.y = -padoffset.y;
m_Track->SetEnd( m_Pad_End->GetPosition() - aOffset + padoffset ); m_Track->SetEnd( m_Pad_End->GetPosition() - aOffset + padoffset );
} }

View File

@ -213,7 +213,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
refvia->LayerPair( &layer1, &layer2 ); refvia->LayerPair( &layer1, &layer2 );
if( layer1 > layer2 ) if( layer1 > layer2 )
EXCHG( layer1, layer2 ); std::swap( layer1, layer2 );
if( layer2 == B_Cu && layer1 == m_pcb->GetDesignSettings().GetCopperLayerCount() - 2 ) if( layer2 == B_Cu && layer1 == m_pcb->GetDesignSettings().GetCopperLayerCount() - 2 )
err = false; err = false;
@ -416,7 +416,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
// Ensure segStartPoint.x <= segEndPoint.x // Ensure segStartPoint.x <= segEndPoint.x
if( 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 */ 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 // Test if segments are crossing
if( segStartPoint.y > segEndPoint.y ) if( segStartPoint.y > segEndPoint.y )
EXCHG( segStartPoint.y, segEndPoint.y ); std::swap( segStartPoint.y, segEndPoint.y );
if( (segStartPoint.y < 0) && (segEndPoint.y > 0) ) if( (segStartPoint.y < 0) && (segEndPoint.y > 0) )
{ {
@ -633,7 +633,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
if( swap_pads ) if( swap_pads )
{ {
EXCHG( aRefPad, aPad ); std::swap( aRefPad, aPad );
relativePadPos = -relativePadPos; relativePadPos = -relativePadPos;
} }
@ -678,7 +678,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
{ {
if( (pad_angle == 900) || (pad_angle == 2700) ) if( (pad_angle == 900) || (pad_angle == 2700) )
{ {
EXCHG( size.x, size.y ); std::swap( size.x, size.y );
} }
// Test DRC: // Test DRC:
@ -877,7 +877,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi
*/ */
if( padHalfsize.x > padHalfsize.y ) if( padHalfsize.x > padHalfsize.y )
{ {
EXCHG( padHalfsize.x, padHalfsize.y ); std::swap( padHalfsize.x, padHalfsize.y );
orient = AddAngles( orient, 900 ); orient = AddAngles( orient, 900 );
} }
@ -1061,7 +1061,7 @@ bool DRC::checkLine( wxPoint aSegStart, wxPoint aSegEnd )
int temp; int temp;
if( aSegStart.x > aSegEnd.x ) if( aSegStart.x > aSegEnd.x )
EXCHG( aSegStart, aSegEnd ); std::swap( aSegStart, aSegEnd );
if( (aSegEnd.x < m_xcliplo) || (aSegStart.x > m_xcliphi) ) if( (aSegEnd.x < m_xcliplo) || (aSegStart.x > m_xcliphi) )
{ {

View File

@ -633,7 +633,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
wxSize size = text->GetSize(); wxSize size = text->GetSize();
if( text->IsMirrored() ) if( text->IsMirrored() )
NEGATE( size.x ); size.x = -size.x;
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText 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(); wxSize size = module->GetSize();
if( module->IsMirrored() ) 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_layer = module->GetLayer();
model_vrml->s_text_width = module->GetThickness(); 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 ) if( isFlipped )
{ {
rotx += 180.0; rotx += 180.0;
NEGATE( roty ); roty = -roty;
NEGATE( rotz ); rotz = -rotz;
} }
// Do some quaternion munching // 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; double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0;
if( isFlipped ) if( isFlipped )
NEGATE( offsetz ); offsetz = -offsetz;
else // In normal mode, Y axis is reversed in Pcbnew. else // In normal mode, Y axis is reversed in Pcbnew.
NEGATE( offsety ); offsety = -offsety;
RotatePoint( &offsetx, &offsety, aModule->GetOrientation() ); RotatePoint( &offsetx, &offsety, aModule->GetOrientation() );

View File

@ -619,7 +619,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
if( (aFirstLayer >= 0) && (aLastLayer >= 0) ) if( (aFirstLayer >= 0) && (aLastLayer >= 0) )
{ {
if( aFirstLayer > aLastLayer ) if( aFirstLayer > aLastLayer )
EXCHG( aFirstLayer, aLastLayer ); std::swap( aFirstLayer, aLastLayer );
} }
if ( aGenerateNPTH_list && aMerge_PTH_NPTH ) if ( aGenerateNPTH_list && aMerge_PTH_NPTH )

View File

@ -245,21 +245,21 @@ void PCB_BASE_FRAME::RotatePad( D_PAD* aPad, wxDC* DC )
module->Draw( m_canvas, DC, GR_XOR ); module->Draw( m_canvas, DC, GR_XOR );
wxSize sz = aPad->GetSize(); wxSize sz = aPad->GetSize();
EXCHG( sz.x, sz.y ); std::swap( sz.x, sz.y );
aPad->SetSize( sz ); aPad->SetSize( sz );
sz = aPad->GetDrillSize(); sz = aPad->GetDrillSize();
EXCHG( sz.x, sz.y ); std::swap( sz.x, sz.y );
aPad->SetDrillSize( sz ); aPad->SetDrillSize( sz );
wxPoint pt = aPad->GetOffset(); wxPoint pt = aPad->GetOffset();
EXCHG( pt.x, pt.y ); std::swap( pt.x, pt.y );
aPad->SetOffset( pt ); aPad->SetOffset( pt );
aPad->SetOffset( wxPoint( aPad->GetOffset().x, -aPad->GetOffset().y ) ); aPad->SetOffset( wxPoint( aPad->GetOffset().x, -aPad->GetOffset().y ) );
sz = aPad->GetDelta(); sz = aPad->GetDelta();
EXCHG( sz.x, sz.y ); std::swap( sz.x, sz.y );
sz.x = -sz.x; sz.x = -sz.x;
aPad->SetDelta( sz ); aPad->SetDelta( sz );

View File

@ -465,7 +465,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
{ {
orientation += 900.0; orientation += 900.0;
size = padsize.x; size = padsize.x;
EXCHG( padsize.x, padsize.y ); std::swap( padsize.x, padsize.y );
} }
else if( padsize.x == padsize.y ) else if( padsize.x == padsize.y )
{ {

View File

@ -223,7 +223,7 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, EDA_COLOR_T aColo
thickness = pt_texte->GetThickness(); thickness = pt_texte->GetThickness();
if( pt_texte->IsMirrored() ) 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. // 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 // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size

View File

@ -374,7 +374,7 @@ static int tst_links_between_blocks( NETINFO_ITEM* aNetinfo,
min_id = best_link->m_PadEnd->GetSubRatsnest(); min_id = best_link->m_PadEnd->GetSubRatsnest();
if( min_id > subratsnest_id ) if( min_id > subratsnest_id )
EXCHG( min_id, subratsnest_id ); std::swap( min_id, subratsnest_id );
// Merge the 2 blocks in one sub ratsnest: // Merge the 2 blocks in one sub ratsnest:
for( unsigned ii = 0; ii < aNetinfo->m_PadInNetList.size(); ii++ ) for( unsigned ii = 0; ii < aNetinfo->m_PadInNetList.size(); ii++ )

View File

@ -866,7 +866,7 @@ PADSTACK* SPECCTRA_DB::makeVia( const ::VIA* aVia )
int botLayer = kicadLayer2pcb[botLayerNum]; int botLayer = kicadLayer2pcb[botLayerNum];
if( topLayer > botLayer ) if( topLayer > botLayer )
EXCHG( topLayer, botLayer ); std::swap( topLayer, botLayer );
return makeVia( aVia->GetWidth(), aVia->GetDrillValue(), 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 ) ); wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), prox ) );
angle = -angle; angle = -angle;
EXCHG( start, end ); std::swap( start, end );
} }
wxPoint nextPt; wxPoint nextPt;
@ -1241,7 +1241,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), prox ) ); wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), prox ) );
angle = -angle; angle = -angle;
EXCHG( start, end ); std::swap( start, end );
} }
wxPoint nextPt; wxPoint nextPt;

View File

@ -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 // Here we have 2 items connected by the same area have 2 differents subnets: merge subnets
if( (subnet > old_subnet) || ( subnet <= 0) ) if( (subnet > old_subnet) || ( subnet <= 0) )
EXCHG( subnet, old_subnet ); std::swap( subnet, old_subnet );
for( unsigned jj = 0; jj < Candidates.size(); jj++ ) for( unsigned jj = 0; jj < Candidates.size(); jj++ )
{ {