More NULL expunging.

This commit is contained in:
Wayne Stambaugh 2021-07-19 19:56:05 -04:00
parent 75190370dd
commit cf00319c85
137 changed files with 4805 additions and 4379 deletions

View File

@ -1,7 +1,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) 2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.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
@ -67,7 +67,7 @@ ACTION_PLUGIN* ACTION_PLUGINS::GetActionByMenu( int aMenu )
return m_actionsList[i]; return m_actionsList[i];
} }
return NULL; return nullptr;
} }
@ -87,7 +87,7 @@ ACTION_PLUGIN* ACTION_PLUGINS::GetActionByButton( int aButton )
return m_actionsList[i]; return m_actionsList[i];
} }
return NULL; return nullptr;
} }
@ -107,7 +107,7 @@ ACTION_PLUGIN* ACTION_PLUGINS::GetActionByPath(const wxString& aPath)
} }
} }
return NULL; return nullptr;
} }
@ -125,7 +125,7 @@ ACTION_PLUGIN* ACTION_PLUGINS::GetAction( const wxString& aName )
return action; return action;
} }
return NULL; return nullptr;
} }
@ -190,6 +190,7 @@ bool ACTION_PLUGINS::deregister_object( void* aObject )
if( action->GetObject() == aObject ) if( action->GetObject() == aObject )
{ {
m_actionsList.erase( m_actionsList.begin() + i ); m_actionsList.erase( m_actionsList.begin() + i );
//m_actionsListMenu.erase( m_actionsListMenu.begin() + i ); //m_actionsListMenu.erase( m_actionsListMenu.begin() + i );
delete action; delete action;
return true; return true;

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.
* *
* Created on: 11 Mar 2016, author John Beard * Created on: 11 Mar 2016, author John Beard
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.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
@ -64,7 +64,7 @@ void ARRAY_CREATOR::Invoke()
int ret = dialog.ShowModal(); int ret = dialog.ShowModal();
if( ret != wxID_OK || array_opts == NULL ) if( ret != wxID_OK || array_opts == nullptr )
return; return;
BOARD_COMMIT commit( &m_parent ); BOARD_COMMIT commit( &m_parent );

View File

@ -3,9 +3,9 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* *
* Copyright (C) 1992-2020 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -139,6 +139,7 @@ int AR_AUTOPLACER::genPlacementRoutingMatrix()
m_matrix.TraceSegmentPcb( (PCB_SHAPE*) drawing, CELL_IS_HOLE | CELL_IS_EDGE, m_matrix.TraceSegmentPcb( (PCB_SHAPE*) drawing, CELL_IS_HOLE | CELL_IS_EDGE,
m_matrix.m_GridRouting, AR_MATRIX::WRITE_CELL ); m_matrix.m_GridRouting, AR_MATRIX::WRITE_CELL );
} }
break; break;
default: default:
@ -272,7 +273,7 @@ bool AR_AUTOPLACER::fillMatrix()
void AR_AUTOPLACER::rotateFootprint( FOOTPRINT* aFootprint, double angle, bool incremental ) void AR_AUTOPLACER::rotateFootprint( FOOTPRINT* aFootprint, double angle, bool incremental )
{ {
if( aFootprint == NULL ) if( aFootprint == nullptr )
return; return;
if( incremental ) if( incremental )
@ -296,6 +297,7 @@ void AR_AUTOPLACER::addFpBody( wxPoint aStart, wxPoint aEnd, LSET aLayerMask )
m_fpAreaTop.Append( aEnd.x, aEnd.y ); m_fpAreaTop.Append( aEnd.x, aEnd.y );
m_fpAreaTop.Append( aStart.x, aEnd.y ); m_fpAreaTop.Append( aStart.x, aEnd.y );
} }
if( aLayerMask[ B_Cu ] ) if( aLayerMask[ B_Cu ] )
{ {
m_fpAreaBottom.NewOutline(); m_fpAreaBottom.NewOutline();
@ -320,6 +322,7 @@ void AR_AUTOPLACER::addPad( PAD* aPad, int aClearance )
m_fpAreaTop.Append( bbox.GetRight(), bbox.GetBottom() ); m_fpAreaTop.Append( bbox.GetRight(), bbox.GetBottom() );
m_fpAreaTop.Append( bbox.GetLeft(), bbox.GetBottom() ); m_fpAreaTop.Append( bbox.GetLeft(), bbox.GetBottom() );
} }
if( aPad->IsOnLayer( B_Cu ) ) if( aPad->IsOnLayer( B_Cu ) )
{ {
m_fpAreaBottom.NewOutline(); m_fpAreaBottom.NewOutline();
@ -407,7 +410,7 @@ void AR_AUTOPLACER::genModuleOnRoutingMatrix( FOOTPRINT* Module )
layerMask.set( B_Cu ); layerMask.set( B_Cu );
m_matrix.TraceFilledRectangle( ox, oy, fx, fy, layerMask, m_matrix.TraceFilledRectangle( ox, oy, fx, fy, layerMask,
CELL_IS_MODULE, AR_MATRIX::WRITE_OR_CELL ); CELL_IS_MODULE, AR_MATRIX::WRITE_OR_CELL );
// Trace pads + clearance areas. // Trace pads + clearance areas.
for( PAD* pad : Module->Pads() ) for( PAD* pad : Module->Pads() )
@ -429,12 +432,6 @@ void AR_AUTOPLACER::genModuleOnRoutingMatrix( FOOTPRINT* Module )
} }
/* Test if the rectangular area (ux, ux .. y0, y1):
* - is a free zone (except OCCUPED_By_MODULE returns)
* - is on the working surface of the board (otherwise returns OUT_OF_BOARD)
*
* Returns OUT_OF_BOARD, or OCCUPED_By_MODULE or FREE_CELL if OK
*/
int AR_AUTOPLACER::testRectangle( const EDA_RECT& aRect, int side ) int AR_AUTOPLACER::testRectangle( const EDA_RECT& aRect, int side )
{ {
EDA_RECT rect = aRect; EDA_RECT rect = aRect;
@ -488,10 +485,6 @@ int AR_AUTOPLACER::testRectangle( const EDA_RECT& aRect, int side )
} }
/* Calculates and returns the clearance area of the rectangular surface
* aRect):
* (Sum of cells in terms of distance)
*/
unsigned int AR_AUTOPLACER::calculateKeepOutArea( const EDA_RECT& aRect, int side ) unsigned int AR_AUTOPLACER::calculateKeepOutArea( const EDA_RECT& aRect, int side )
{ {
wxPoint start = aRect.GetOrigin(); wxPoint start = aRect.GetOrigin();
@ -541,10 +534,6 @@ unsigned int AR_AUTOPLACER::calculateKeepOutArea( const EDA_RECT& aRect, int sid
} }
/* Test if the footprint can be placed on the board.
* Returns the value TstRectangle().
* Module is known by its bounding box
*/
int AR_AUTOPLACER::testFootprintOnBoard( FOOTPRINT* aFootprint, bool TstOtherSide, int AR_AUTOPLACER::testFootprintOnBoard( FOOTPRINT* aFootprint, bool TstOtherSide,
const wxPoint& aOffset ) const wxPoint& aOffset )
{ {
@ -693,7 +682,8 @@ const PAD* AR_AUTOPLACER::nearestPad( FOOTPRINT *aRefFP, PAD* aRefPad, const wxP
if( pad->GetNetCode() != aRefPad->GetNetCode() || pad->GetNetCode() <= 0 ) if( pad->GetNetCode() != aRefPad->GetNetCode() || pad->GetNetCode() <= 0 )
continue; continue;
auto dist = (VECTOR2I( aRefPad->GetPosition() - aOffset ) - VECTOR2I( pad->GetPosition() ) ).EuclideanNorm(); auto dist = ( VECTOR2I( aRefPad->GetPosition() - aOffset ) -
VECTOR2I( pad->GetPosition() ) ).EuclideanNorm();
if ( dist < nearestDist ) if ( dist < nearestDist )
{ {
@ -737,7 +727,7 @@ double AR_AUTOPLACER::computePlacementRatsnestCost( FOOTPRINT *aFootprint, const
dx = abs( dx ); dx = abs( dx );
dy = abs( dy ); dy = abs( dy );
// 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 ratsnest
if( dx < dy ) if( dx < dy )
std::swap( dx, dy ); std::swap( dx, dy );
@ -776,7 +766,7 @@ static bool sortFootprintsByRatsnestSize( FOOTPRINT* ref, FOOTPRINT* compare )
} }
FOOTPRINT* AR_AUTOPLACER::pickFootprint( ) FOOTPRINT* AR_AUTOPLACER::pickFootprint()
{ {
std::vector<FOOTPRINT*> fpList; std::vector<FOOTPRINT*> fpList;
@ -947,8 +937,8 @@ AR_RESULT AR_AUTOPLACER::AutoplaceFootprints( std::vector<FOOTPRINT*>& aFootprin
//m_frame->SetStatusText( msg ); //m_frame->SetStatusText( msg );
if( m_progressReporter ) if( m_progressReporter )
m_progressReporter->SetTitle( wxString::Format( m_progressReporter->SetTitle( wxString::Format( _( "Autoplacing %s" ),
_( "Autoplacing %s" ), footprint->GetReference() ) ); footprint->GetReference() ) );
double initialOrient = footprint->GetOrientation(); double initialOrient = footprint->GetOrientation();
@ -1061,6 +1051,7 @@ end_of_tst:
break; break;
} }
} }
cnt++; cnt++;
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -60,14 +60,10 @@ bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert )
if( !aNoAssert ) if( !aNoAssert )
wxASSERT( m_netinfo ); wxASSERT( m_netinfo );
return ( m_netinfo != NULL ); return ( m_netinfo != nullptr );
} }
/*
* This method returns the Default netclass for nets which don't have their own, and the
* Orphaned netclass for unassigned nets (netCode == 0)
*/
NETCLASS* BOARD_CONNECTED_ITEM::GetEffectiveNetclass() const NETCLASS* BOARD_CONNECTED_ITEM::GetEffectiveNetclass() const
{ {
// NB: we must check the net first, as when it is 0 GetNetClass() will return the // NB: we must check the net first, as when it is 0 GetNetClass() will return the
@ -79,9 +75,6 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetEffectiveNetclass() const
} }
/*
* Returns the item's "own" clearance (ie: that not affected by other items).
*/
int BOARD_CONNECTED_ITEM::GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource ) const int BOARD_CONNECTED_ITEM::GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource ) const
{ {
DRC_CONSTRAINT constraint; DRC_CONSTRAINT constraint;

View File

@ -46,7 +46,7 @@ public:
static inline bool ClassOf( const EDA_ITEM* aItem ) static inline bool ClassOf( const EDA_ITEM* aItem )
{ {
if( aItem == NULL ) if( aItem == nullptr )
return false; return false;
switch( aItem->Type() ) switch( aItem->Type() )

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -57,7 +57,7 @@ BOARD* BOARD_ITEM::GetBoard() const
if( parent ) if( parent )
return parent->GetBoard(); return parent->GetBoard();
return NULL; return nullptr;
} }
@ -135,7 +135,8 @@ void BOARD_ITEM::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBu
int aError, ERROR_LOC aErrorLoc, int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth ) const bool ignoreLineWidth ) const
{ {
wxASSERT_MSG( false, "Called TransformShapeWithClearanceToPolygon() on unsupported BOARD_ITEM." ); wxASSERT_MSG( false,
"Called TransformShapeWithClearanceToPolygon() on unsupported BOARD_ITEM." );
}; };
@ -147,7 +148,7 @@ bool BOARD_ITEM::ptr_cmp::operator() ( const BOARD_ITEM* a, const BOARD_ITEM* b
if( a->GetLayer() != b->GetLayer() ) if( a->GetLayer() != b->GetLayer() )
return a->GetLayer() < b->GetLayer(); return a->GetLayer() < b->GetLayer();
if( a->m_Uuid != b->m_Uuid ) // shopuld be always the case foer valid boards if( a->m_Uuid != b->m_Uuid ) // should be always the case for valid boards
return a->m_Uuid < b->m_Uuid; return a->m_Uuid < b->m_Uuid;
return a < b; return a < b;

View File

@ -55,6 +55,7 @@ struct TSEGM_2_POLY_PRMS
SHAPE_POLY_SET* m_cornerBuffer; SHAPE_POLY_SET* m_cornerBuffer;
}; };
TSEGM_2_POLY_PRMS prms; TSEGM_2_POLY_PRMS prms;
@ -67,7 +68,8 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData )
} }
void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aOutlines ) const
{ {
int maxError = GetDesignSettings().m_MaxError; int maxError = GetDesignSettings().m_MaxError;
@ -120,16 +122,16 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_
const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item ); const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
shape->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError, shape->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE ); ERROR_INSIDE );
}
break; break;
}
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
text->TransformTextShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError, text->TransformTextShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE ); ERROR_INSIDE );
}
break; break;
}
default: default:
break; break;
@ -164,11 +166,13 @@ void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff
case PAD_SHAPE::CIRCLE: case PAD_SHAPE::CIRCLE:
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE ) if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
continue; continue;
break; break;
case PAD_SHAPE::OVAL: case PAD_SHAPE::OVAL:
if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE ) if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
continue; continue;
break; break;
default: default:
@ -283,12 +287,6 @@ void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCorner
} }
/**
* Convert the text to a polygonSet describing the actual character strokes (one per segment).
* @aCornerBuffer = SHAPE_POLY_SET to store the polygon corners
* @aClearanceValue = the clearance around the text
* @aError = the maximum error to allow when approximating curves
*/
void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const int aError, ERROR_LOC aErrorLoc ) const
@ -302,8 +300,9 @@ void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
if( IsMirrored() ) if( IsMirrored() )
size.x = -size.x; size.x = -size.x;
GRText( NULL, GetTextPos(), BLACK, GetShownText(), GetDrawRotation(), size, GetHorizJustify(), GRText( nullptr, GetTextPos(), BLACK, GetShownText(), GetDrawRotation(), size,
GetVertJustify(), penWidth, IsItalic(), IsBold(), addTextSegmToPoly, &prms ); GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(),
addTextSegmToPoly, &prms );
} }
@ -383,15 +382,9 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
} }
/**
* Convert the text to a polygonSet describing the actual character strokes (one per segment).
* @aCornerBuffer = SHAPE_POLY_SET to store the polygon corners
* @aClearanceValue = the clearance around the text
* @aError = the maximum error to allow when approximating curves
*/
void PCB_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, void PCB_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue, PCB_LAYER_ID aLayer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc ) const int aError, ERROR_LOC aErrorLoc ) const
{ {
wxSize size = GetTextSize(); wxSize size = GetTextSize();
@ -405,15 +398,15 @@ void PCB_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCorner
prms.m_error = aError; prms.m_error = aError;
COLOR4D color; // not actually used, but needed by GRText COLOR4D color; // not actually used, but needed by GRText
GRText( NULL, GetTextPos(), color, GetShownText(), GetTextAngle(), size, GetHorizJustify(), GRText( nullptr, GetTextPos(), color, GetShownText(), GetTextAngle(), size, GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold(), addTextSegmToPoly, &prms ); GetVertJustify(), penWidth, IsItalic(), IsBold(), addTextSegmToPoly, &prms );
} }
void PCB_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, void PCB_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc, int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const bool aIgnoreLineWidth ) const
{ {
EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &aCornerBuffer, aClearance ); EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &aCornerBuffer, aClearance );
} }
@ -441,6 +434,7 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), width, aError, TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), width, aError,
aErrorLoc ); aErrorLoc );
} }
break; break;
case PCB_SHAPE_TYPE::RECT: case PCB_SHAPE_TYPE::RECT:
@ -463,8 +457,9 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc ); TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc ); TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc );
} }
}
break; break;
}
case PCB_SHAPE_TYPE::ARC: case PCB_SHAPE_TYPE::ARC:
TransformArcToPolygon( aCornerBuffer, GetArcStart(), GetArcMid(), GetArcEnd(), width, TransformArcToPolygon( aCornerBuffer, GetArcStart(), GetArcMid(), GetArcEnd(), width,
@ -518,8 +513,9 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
pt1 = pt2; pt1 = pt2;
} }
} }
}
break; break;
}
case PCB_SHAPE_TYPE::CURVE: // Bezier curve case PCB_SHAPE_TYPE::CURVE: // Bezier curve
{ {
@ -530,10 +526,12 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
for( unsigned ii = 1; ii < poly.size(); ii++ ) for( unsigned ii = 1; ii < poly.size(); ii++ )
{ {
TransformOvalToPolygon( aCornerBuffer, poly[ii - 1], poly[ii], width, aError, aErrorLoc ); TransformOvalToPolygon( aCornerBuffer, poly[ii - 1], poly[ii], width, aError,
aErrorLoc );
} }
}
break; break;
}
default: default:
wxFAIL_MSG( "PCB_SHAPE::TransformShapeWithClearanceToPolygon no implementation for " wxFAIL_MSG( "PCB_SHAPE::TransformShapeWithClearanceToPolygon no implementation for "
@ -557,8 +555,8 @@ void PCB_TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
{ {
int radius = ( m_Width / 2 ) + aClearanceValue; int radius = ( m_Width / 2 ) + aClearanceValue;
TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aError, aErrorLoc ); TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aError, aErrorLoc );
}
break; break;
}
case PCB_ARC_T: case PCB_ARC_T:
{ {
@ -567,17 +565,17 @@ void PCB_TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
TransformArcToPolygon( aCornerBuffer, arc->GetStart(), arc->GetMid(), TransformArcToPolygon( aCornerBuffer, arc->GetStart(), arc->GetMid(),
arc->GetEnd(), width, aError, aErrorLoc ); arc->GetEnd(), width, aError, aErrorLoc );
}
break; break;
}
default: default:
{ {
int width = m_Width + ( 2 * aClearanceValue ); int width = m_Width + ( 2 * aClearanceValue );
TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError, aErrorLoc ); TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError, aErrorLoc );
}
break; break;
} }
}
} }
@ -633,8 +631,8 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
TransformTrapezoidToPolygon( outline, padShapePos, m_size, angle, ddx, ddy, TransformTrapezoidToPolygon( outline, padShapePos, m_size, angle, ddx, ddy,
aClearanceValue, aError, aErrorLoc ); aClearanceValue, aError, aErrorLoc );
aCornerBuffer.Append( outline ); aCornerBuffer.Append( outline );
}
break; break;
}
case PAD_SHAPE::CHAMFERED_RECT: case PAD_SHAPE::CHAMFERED_RECT:
case PAD_SHAPE::ROUNDRECT: case PAD_SHAPE::ROUNDRECT:
@ -648,8 +646,8 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
doChamfer ? GetChamferPositions() : 0, doChamfer ? GetChamferPositions() : 0,
aClearanceValue, aError, aErrorLoc ); aClearanceValue, aError, aErrorLoc );
aCornerBuffer.Append( outline ); aCornerBuffer.Append( outline );
}
break; break;
}
case PAD_SHAPE::CUSTOM: case PAD_SHAPE::CUSTOM:
{ {
@ -676,8 +674,8 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
} }
aCornerBuffer.Append( outline ); aCornerBuffer.Append( outline );
}
break; break;
}
default: default:
wxFAIL_MSG( "PAD::TransformShapeWithClearanceToPolygon no implementation for " wxFAIL_MSG( "PAD::TransformShapeWithClearanceToPolygon no implementation for "
@ -748,7 +746,8 @@ void PCB_DIMENSION_BASE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& a
} }
else else
{ {
wxFAIL_MSG( "PCB_DIMENSION_BASE::TransformShapeWithClearanceToPolygon unexpected shape type." ); wxFAIL_MSG( "PCB_DIMENSION_BASE::TransformShapeWithClearanceToPolygon unexpected "
"shape type." );
} }
} }
} }

View File

@ -210,7 +210,9 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve
} }
} }
else else
{
wxMessageBox( _( "All dielectric thickness layers are locked" ) ); wxMessageBox( _( "All dielectric thickness layers are locked" ) );
}
computeBoardThickness(); computeBoardThickness();
} }
@ -227,7 +229,7 @@ void PANEL_SETUP_BOARD_STACKUP::disconnectEvents()
{ {
cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
NULL, this ); nullptr, this );
} }
wxButton* matButt = dynamic_cast<wxButton*>( item ); wxButton* matButt = dynamic_cast<wxButton*>( item );
@ -236,7 +238,7 @@ void PANEL_SETUP_BOARD_STACKUP::disconnectEvents()
{ {
matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
NULL, this ); nullptr, this );
} }
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item ); wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item );
@ -245,7 +247,7 @@ void PANEL_SETUP_BOARD_STACKUP::disconnectEvents()
{ {
textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
NULL, this ); nullptr, this );
} }
} }
} }
@ -391,7 +393,7 @@ void PANEL_SETUP_BOARD_STACKUP::onExportToClipboard( wxCommandEvent& event )
if( !transferDataFromUIToStackup() ) if( !transferDataFromUIToStackup() )
return; return;
// Build a ascii representation of stackup and copy it in the clipboard // Build a ASCII representation of stackup and copy it in the clipboard
wxString report = BuildStackupReport( m_stackup, m_units ); wxString report = BuildStackupReport( m_stackup, m_units );
wxLogNull doNotLog; // disable logging of failed clipboard actions wxLogNull doNotLog; // disable logging of failed clipboard actions
@ -631,8 +633,7 @@ void PANEL_SETUP_BOARD_STACKUP::showOnlyActiveLayers()
} }
void PANEL_SETUP_BOARD_STACKUP::addMaterialChooser( wxWindowID aId, void PANEL_SETUP_BOARD_STACKUP::addMaterialChooser( wxWindowID aId, const wxString* aMaterialName,
const wxString * aMaterialName,
BOARD_STACKUP_ROW_UI_ITEM& aUiRowItem ) BOARD_STACKUP_ROW_UI_ITEM& aUiRowItem )
{ {
wxBoxSizer* bSizerMat = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bSizerMat = new wxBoxSizer( wxHORIZONTAL );
@ -651,12 +652,12 @@ void PANEL_SETUP_BOARD_STACKUP::addMaterialChooser( wxWindowID aId,
bSizerMat->Add( textCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); bSizerMat->Add( textCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
wxButton* m_buttonMat = new wxButton( m_scGridWin, aId, _( "..." ), wxDefaultPosition, wxButton* m_buttonMat = new wxButton( m_scGridWin, aId, _( "..." ), wxDefaultPosition,
wxDefaultSize, wxBU_EXACTFIT ); wxDefaultSize, wxBU_EXACTFIT );
bSizerMat->Add( m_buttonMat, 0, wxALIGN_CENTER_VERTICAL, 2 ); bSizerMat->Add( m_buttonMat, 0, wxALIGN_CENTER_VERTICAL, 2 );
m_buttonMat->Connect( wxEVT_COMMAND_BUTTON_CLICKED, m_buttonMat->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
NULL, this ); nullptr, this );
m_controlItemsList.push_back( m_buttonMat ); m_controlItemsList.push_back( m_buttonMat );
aUiRowItem.m_MaterialCtrl = textCtrl; aUiRowItem.m_MaterialCtrl = textCtrl;
@ -761,7 +762,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
m_controlItemsList.push_back( textCtrl ); m_controlItemsList.push_back( textCtrl );
textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
NULL, this ); nullptr, this );
ui_row_item.m_ThicknessCtrl = textCtrl; ui_row_item.m_ThicknessCtrl = textCtrl;
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC ) if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
@ -1021,7 +1022,8 @@ bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup()
else else
{ {
success = false; success = false;
error_msg << _( "Incorrect value for Epsilon R (Epsilon R must be positive or null if not used)" ); error_msg << _( "Incorrect value for Epsilon R (Epsilon R must be positive or "
"null if not used)" );
} }
} }
@ -1041,7 +1043,8 @@ bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup()
if( !error_msg.IsEmpty() ) if( !error_msg.IsEmpty() )
error_msg << "\n"; error_msg << "\n";
error_msg << _( "Incorrect value for Loss tg (Loss tg must be positive or null if not used)" ); error_msg << _( "Incorrect value for Loss tg (Loss tg must be positive or null "
"if not used)" );
} }
} }
@ -1266,8 +1269,7 @@ void PANEL_SETUP_BOARD_STACKUP::onColorSelected( wxCommandEvent& event )
combo->SetString( idx, label ); combo->SetString( idx, label );
wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y ); wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ), LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ), COLOR4D( color ) );
COLOR4D( color ) );
combo->SetItemBitmap( combo->GetCount()-1, layerbmp ); combo->SetItemBitmap( combo->GetCount()-1, layerbmp );
} }
} }
@ -1506,7 +1508,7 @@ wxBitmapComboBox* PANEL_SETUP_BOARD_STACKUP::createBmComboBox( BOARD_STACKUP_ITE
combo->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
NULL, this ); nullptr, this );
return combo; return combo;
} }
@ -1530,7 +1532,7 @@ void drawBitmap( wxBitmap& aBitmap, wxColor aColor )
} }
p = rowStart; p = rowStart;
p.OffsetY(data, 1); p.OffsetY( data, 1 );
} }
} }

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) 2009-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2009-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -64,6 +64,7 @@ public:
int m_Id; int m_Id;
int m_Count; int m_Count;
}; };
WX_DECLARE_LIST( BOM_ENTRY, BOM_ENTRY_LIST ); WX_DECLARE_LIST( BOM_ENTRY, BOM_ENTRY_LIST );
WX_DEFINE_LIST( BOM_ENTRY_LIST ) WX_DEFINE_LIST( BOM_ENTRY_LIST )
@ -97,7 +98,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
fp_bom = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); fp_bom = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( fp_bom == NULL ) if( fp_bom == nullptr )
{ {
msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() ); msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
DisplayError( this, msg ); DisplayError( this, msg );
@ -169,7 +170,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
// We do not need this object, now: remove it from list and delete it // We do not need this object, now: remove it from list and delete it
list.DeleteObject( curEntry ); list.DeleteObject( curEntry );
delete (curEntry); delete curEntry;
} }
fclose( fp_bom ); fclose( fp_bom );

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-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.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
@ -231,7 +231,6 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
#endif #endif
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_PAD_T: case PCB_PAD_T:
@ -243,8 +242,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
// for through pads: pads on Front or Back board sides must be visible // for through pads: pads on Front or Back board sides must be visible
pad = static_cast<PAD*>( item ); pad = static_cast<PAD*>( item );
if( (pad->GetAttribute() != PAD_ATTRIB::SMD) && if( ( pad->GetAttribute() != PAD_ATTRIB::SMD ) &&
(pad->GetAttribute() != PAD_ATTRIB::CONN) ) // a hole is present, so multiple layers ( pad->GetAttribute() != PAD_ATTRIB::CONN ) ) // a hole is present, so multiple layers
{ {
// proceed to the common tests below, but without the parent footprint test, // proceed to the common tests below, but without the parent footprint test,
// by leaving footprint==NULL, but having pad != null // by leaving footprint==NULL, but having pad != null
@ -265,6 +264,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
case PCB_ARC_T: case PCB_ARC_T:
if( m_Guide->IgnoreTracks() ) if( m_Guide->IgnoreTracks() )
goto exit; goto exit;
break; break;
case PCB_FP_ZONE_T: case PCB_FP_ZONE_T:
@ -295,46 +295,50 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
break; break;
case PCB_FP_TEXT_T: case PCB_FP_TEXT_T:
{
FP_TEXT *text = static_cast<FP_TEXT*>( item );
if( m_Guide->IgnoreHiddenFPText() && !text->IsVisible() )
goto exit;
if( m_Guide->IgnoreFPTextOnBack() && IsBackLayer( text->GetLayer() ) )
goto exit;
if( m_Guide->IgnoreFPTextOnFront() && IsFrontLayer( text->GetLayer() ) )
goto exit;
/* The three text types have different criteria: reference
* and value have their own ignore flags; user text instead
* follows their layer visibility. Checking this here is
* simpler than later (when layer visibility is checked for
* other entities) */
switch( text->GetType() )
{ {
FP_TEXT *text = static_cast<FP_TEXT*>( item ); case FP_TEXT::TEXT_is_REFERENCE:
if( m_Guide->IgnoreHiddenFPText() && !text->IsVisible() ) if( m_Guide->IgnoreFPReferences() )
goto exit; goto exit;
if( m_Guide->IgnoreFPTextOnBack() && IsBackLayer( text->GetLayer() ) ) break;
case FP_TEXT::TEXT_is_VALUE:
if( m_Guide->IgnoreFPValues() )
goto exit; goto exit;
if( m_Guide->IgnoreFPTextOnFront() && IsFrontLayer( text->GetLayer() ) ) break;
case FP_TEXT::TEXT_is_DIVERS:
if( !m_Guide->IsLayerVisible( text->GetLayer() )
&& m_Guide->IgnoreNonVisibleLayers() )
goto exit; goto exit;
/* The three text types have different criteria: reference break;
* and value have their own ignore flags; user text instead
* follows their layer visibility. Checking this here is
* simpler than later (when layer visibility is checked for
* other entities) */
switch( text->GetType() )
{
case FP_TEXT::TEXT_is_REFERENCE:
if( m_Guide->IgnoreFPReferences() )
goto exit;
break;
case FP_TEXT::TEXT_is_VALUE:
if( m_Guide->IgnoreFPValues() )
goto exit;
break;
case FP_TEXT::TEXT_is_DIVERS:
if( !m_Guide->IsLayerVisible( text->GetLayer() )
&& m_Guide->IgnoreNonVisibleLayers() )
goto exit;
break;
}
// Extract the footprint since it could be hidden
footprint = static_cast<FOOTPRINT*>( item->GetParent() );
} }
// Extract the footprint since it could be hidden
footprint = static_cast<FOOTPRINT*>( item->GetParent() );
break; break;
}
case PCB_FP_SHAPE_T: case PCB_FP_SHAPE_T:
shape = static_cast<FP_SHAPE*>( item ); shape = static_cast<FP_SHAPE*>( item );
@ -360,10 +364,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
if( footprint ) // true from case PCB_PAD_T, PCB_FP_TEXT_T, or PCB_FOOTPRINT_T if( footprint ) // true from case PCB_PAD_T, PCB_FP_TEXT_T, or PCB_FOOTPRINT_T
{ {
if( m_Guide->IgnoreFootprintsOnBack() && ( footprint->GetLayer() == B_Cu) ) if( m_Guide->IgnoreFootprintsOnBack() && ( footprint->GetLayer() == B_Cu ) )
goto exit; goto exit;
if( m_Guide->IgnoreFootprintsOnFront() && ( footprint->GetLayer() == F_Cu) ) if( m_Guide->IgnoreFootprintsOnFront() && ( footprint->GetLayer() == F_Cu ) )
goto exit; goto exit;
} }
@ -579,7 +583,7 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
// the Inspect() function. // the Inspect() function.
SetRefPos( aRefPos ); SetRefPos( aRefPos );
aItem->Visit( m_inspector, NULL, m_scanTypes ); aItem->Visit( m_inspector, nullptr, m_scanTypes );
// record the length of the primary list before concatenating on to it. // record the length of the primary list before concatenating on to it.
m_PrimaryLength = m_list.size(); m_PrimaryLength = m_list.size();
@ -606,7 +610,7 @@ void PCB_TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[]
{ {
Empty(); // empty any existing collection Empty(); // empty any existing collection
aBoard->Visit( m_inspector, NULL, aScanList ); aBoard->Visit( m_inspector, nullptr, aScanList );
} }
@ -625,5 +629,5 @@ void PCB_LAYER_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[]
{ {
Empty(); Empty();
aBoard->Visit( m_inspector, NULL, aScanList ); aBoard->Visit( m_inspector, nullptr, aScanList );
} }

View File

@ -85,9 +85,9 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
line[sizeof(line) - 1] = 0; line[sizeof(line) - 1] = 0;
idcmd = strtok( line, " \n\r" ); idcmd = strtok( line, " \n\r" );
text = strtok( NULL, "\"\n\r" ); text = strtok( nullptr, "\"\n\r" );
if( idcmd == NULL ) if( idcmd == nullptr )
return; return;
if( strcmp( idcmd, "$NET:" ) == 0 ) if( strcmp( idcmd, "$NET:" ) == 0 )
@ -108,6 +108,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
SetMsgPanel( items ); SetMsgPanel( items );
} }
} }
if( strcmp( idcmd, "$NETS:" ) == 0 ) if( strcmp( idcmd, "$NETS:" ) == 0 )
{ {
if( !crossProbingSettings.auto_highlight ) if( !crossProbingSettings.auto_highlight )
@ -148,10 +149,10 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
{ {
wxString pinName = FROM_UTF8( text ); wxString pinName = FROM_UTF8( text );
text = strtok( NULL, " \n\r" ); text = strtok( nullptr, " \n\r" );
if( text && strcmp( text, "$PART:" ) == 0 ) if( text && strcmp( text, "$PART:" ) == 0 )
text = strtok( NULL, "\"\n\r" ); text = strtok( nullptr, "\"\n\r" );
modName = FROM_UTF8( text ); modName = FROM_UTF8( text );
@ -163,9 +164,9 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( pad ) if( pad )
netcode = pad->GetNetCode(); netcode = pad->GetNetCode();
if( footprint == NULL ) if( footprint == nullptr )
msg.Printf( _( "%s not found" ), modName ); msg.Printf( _( "%s not found" ), modName );
else if( pad == NULL ) else if( pad == nullptr )
msg.Printf( _( "%s pin %s not found" ), modName, pinName ); msg.Printf( _( "%s pin %s not found" ), modName, pinName );
else else
msg.Printf( _( "%s pin %s found" ), modName, pinName ); msg.Printf( _( "%s pin %s found" ), modName, pinName );
@ -284,7 +285,8 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
// The "fabs" on x ensures the right answer when the view is flipped // The "fabs" on x ensures the right answer when the view is flipped
screenSize.x = std::max( 10.0, fabs( screenSize.x ) ); screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
screenSize.y = std::max( 10.0, screenSize.y ); screenSize.y = std::max( 10.0, screenSize.y );
double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) ); double ratio = std::max( fabs( bbSize.x / screenSize.x ),
fabs( bbSize.y / screenSize.y ) );
// Try not to zoom on every cross-probe; it gets very noisy // Try not to zoom on every cross-probe; it gets very noisy
if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) ) if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
@ -309,19 +311,23 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
double currTextHeight = Millimeter2iu( DEFAULT_TEXT_SIZE ); double currTextHeight = Millimeter2iu( DEFAULT_TEXT_SIZE );
double compRatio = bbSize.y / currTextHeight; // Ratio of component to text height double compRatio = bbSize.y / currTextHeight; // Ratio of component to text height
double compRatioBent = 1.0; // This will end up as the scaling factor we apply to "ratio"
// This is similar to the original KiCad code that scaled the zoom to make sure components // This will end up as the scaling factor we apply to "ratio".
// were visible on screen. It's simply a ratio of screen size to component size, and its double compRatioBent = 1.0;
// job is to zoom in to make the component fullscreen. Earlier in the code the
// component BBox is given a 20% margin to add some breathing room. We compare // This is similar to the original KiCad code that scaled the zoom to make sure
// the height of this enlarged component bbox to the default text height. If a component // components were visible on screen. It's simply a ratio of screen size to
// will end up with the sides clipped, we adjust later to make sure it fits on screen. // component size, and its job is to zoom in to make the component fullscreen.
// Earlier in the code the component BBox is given a 20% margin to add some
// breathing room. We compare the height of this enlarged component bbox to the
// default text height. If a component will end up with the sides clipped, we
// adjust later to make sure it fits on screen.
// //
// The "fabs" on x ensures the right answer when the view is flipped // The "fabs" on x ensures the right answer when the view is flipped
screenSize.x = std::max( 10.0, fabs( screenSize.x ) ); screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
screenSize.y = std::max( 10.0, screenSize.y ); screenSize.y = std::max( 10.0, screenSize.y );
double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) ); double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
// Original KiCad code for how much to scale the zoom // Original KiCad code for how much to scale the zoom
double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ), double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ),
fabs( bbSize.y / screenSize.y ) ); fabs( bbSize.y / screenSize.y ) );
@ -369,19 +375,23 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
} }
} }
else else
{
compRatioBent = lut.front().second; // Small component default compRatioBent = lut.front().second; // Small component default
}
// If the width of the part we're probing is bigger than what the screen width will be // If the width of the part we're probing is bigger than what the screen width will be
// after the zoom, then punt and use the KiCad zoom algorithm since it guarantees the // after the zoom, then punt and use the KiCad zoom algorithm since it guarantees the
// part's width will be encompassed within the screen. This will apply to parts that are // part's width will be encompassed within the screen. This will apply to parts that
// much wider than they are tall. // are much wider than they are tall.
if( bbSize.x > screenSize.x * ratio * compRatioBent ) if( bbSize.x > screenSize.x * ratio * compRatioBent )
{ {
ratio = kicadRatio; // Use standard KiCad zoom algorithm for parts too wide to fit screen // Use standard KiCad zoom algorithm for parts too wide to fit screen/
ratio = kicadRatio;
compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
wxLogTrace( "CROSS_PROBE_SCALE", wxLogTrace( "CROSS_PROBE_SCALE",
"Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio ); "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f",
ratio );
} }
// Now that "compRatioBent" holds our final scaling factor we apply it to the original // Now that "compRatioBent" holds our final scaling factor we apply it to the original
@ -389,15 +399,18 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
ratio *= compRatioBent; ratio *= compRatioBent;
bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
// Try not to zoom on every cross-probe; it gets very noisy // Try not to zoom on every cross-probe; it gets very noisy
if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom ) if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
view->SetScale( view->GetScale() / ratio ); view->SetScale( view->GetScale() / ratio );
#endif // ifndef DEFAULT_PCBNEW_CODE #endif // ifndef DEFAULT_PCBNEW_CODE
} }
view->SetCenter( bbox.Centre() ); view->SetCenter( bbox.Centre() );
} }
view->UpdateAllLayersColor(); view->UpdateAllLayersColor();
// Ensure the display is refreshed, because in some installs the refresh is done only // Ensure the display is refreshed, because in some installs the refresh is done only
// when the gal canvas has the focus, and that is not the case when crossprobing from // when the gal canvas has the focus, and that is not the case when crossprobing from
// Eeschema: // Eeschema:
@ -419,36 +432,33 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
return StrPrintf( "$PART: \"%s\"", TO_UTF8( footprint->GetReference() ) ); return StrPrintf( "$PART: \"%s\"", TO_UTF8( footprint->GetReference() ) );
case PCB_PAD_T: case PCB_PAD_T:
{ {
footprint = static_cast<FOOTPRINT*>( aItem->GetParent() ); footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
wxString pad = static_cast<PAD*>( aItem )->GetName(); wxString pad = static_cast<PAD*>( aItem )->GetName();
return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"", return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"", TO_UTF8( footprint->GetReference() ),
TO_UTF8( footprint->GetReference() ), TO_UTF8( pad ) );
TO_UTF8( pad ) ); }
}
case PCB_FP_TEXT_T: case PCB_FP_TEXT_T:
{ {
footprint = static_cast<FOOTPRINT*>( aItem->GetParent() ); footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
FP_TEXT* text = static_cast<FP_TEXT*>( aItem ); FP_TEXT* text = static_cast<FP_TEXT*>( aItem );
const char* text_key; const char* text_key;
/* This can't be a switch since the break need to pull out /* This can't be a switch since the break need to pull out
* from the outer switch! */ * from the outer switch! */
if( text->GetType() == FP_TEXT::TEXT_is_REFERENCE ) if( text->GetType() == FP_TEXT::TEXT_is_REFERENCE )
text_key = "$REF:"; text_key = "$REF:";
else if( text->GetType() == FP_TEXT::TEXT_is_VALUE ) else if( text->GetType() == FP_TEXT::TEXT_is_VALUE )
text_key = "$VAL:"; text_key = "$VAL:";
else else
break; break;
return StrPrintf( "$PART: \"%s\" %s \"%s\"", return StrPrintf( "$PART: \"%s\" %s \"%s\"", TO_UTF8( footprint->GetReference() ), text_key,
TO_UTF8( footprint->GetReference() ), TO_UTF8( text->GetText() ) );
text_key, }
TO_UTF8( text->GetText() ) );
}
default: default:
break; break;
@ -458,14 +468,6 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
} }
/* Send a remote command to Eeschema via a socket,
* aSyncItem = item to be located on schematic (footprint, pin or text)
* Commands are
* $PART: "reference" put cursor on component anchor
* $PART: "reference" $PAD: "pad number" put cursor on the component pin
* $PART: "reference" $REF: "reference" put cursor on the component ref
* $PART: "reference" $VAL: "value" put cursor on the component value
*/
void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem ) void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem )
{ {
std::string packet = FormatProbeItem( aSyncItem ); std::string packet = FormatProbeItem( aSyncItem );
@ -473,7 +475,9 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem )
if( !packet.empty() ) if( !packet.empty() )
{ {
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
{
SendCommand( MSG_TO_SCH, packet ); SendCommand( MSG_TO_SCH, packet );
}
else else
{ {
// Typically ExpressMail is going to be s-expression packets, but since // Typically ExpressMail is going to be s-expression packets, but since
@ -492,7 +496,9 @@ void PCB_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
if( !packet.empty() ) if( !packet.empty() )
{ {
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
{
SendCommand( MSG_TO_SCH, packet ); SendCommand( MSG_TO_SCH, packet );
}
else else
{ {
// Typically ExpressMail is going to be s-expression packets, but since // Typically ExpressMail is going to be s-expression packets, but since
@ -539,8 +545,8 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
netlist.Format( "pcb_netlist", &sf, 0, CTL_OMIT_FILTERS ); netlist.Format( "pcb_netlist", &sf, 0, CTL_OMIT_FILTERS );
payload = sf.GetString(); payload = sf.GetString();
}
break; break;
}
case MAIL_PCB_UPDATE_LINKS: case MAIL_PCB_UPDATE_LINKS:
try try
@ -564,6 +570,7 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
assert( false ); // should never happen assert( false ); // should never happen
return; return;
} }
break; break;
case MAIL_CROSS_PROBE: case MAIL_CROSS_PROBE:
@ -596,8 +603,9 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( importFormat >= 0 ) if( importFormat >= 0 )
importFile( path, importFormat ); importFile( path, importFormat );
}
break; break;
}
// many many others. // many many others.
default: default:

View File

@ -48,6 +48,7 @@
using std::placeholders::_1; using std::placeholders::_1;
DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
PAGED_DIALOG( aFrame, _( "Board Setup" ), false, PAGED_DIALOG( aFrame, _( "Board Setup" ), false,
_( "Import Settings from Another Board..." ) ), _( "Import Settings from Another Board..." ) ),
@ -88,6 +89,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) ); m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) );
m_layerSetupPage = 1; m_layerSetupPage = 1;
m_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) ); m_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) );
// Change this value if m_physicalStackup is not the page 2 of m_treebook // Change this value if m_physicalStackup is not the page 2 of m_treebook
m_physicalStackupPage = 2; // The page number (from 0) to select the m_physicalStackup panel m_physicalStackupPage = 2; // The page number (from 0) to select the m_physicalStackup panel
m_treebook->AddSubPage( m_boardFinish, _( "Board Finish" ) ); m_treebook->AddSubPage( m_boardFinish, _( "Board Finish" ) );
@ -111,7 +113,8 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
// Connect Events // Connect Events
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED, m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this ); wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ),
nullptr, this );
finishDialogSettings(); finishDialogSettings();
} }
@ -120,7 +123,8 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
DIALOG_BOARD_SETUP::~DIALOG_BOARD_SETUP() DIALOG_BOARD_SETUP::~DIALOG_BOARD_SETUP()
{ {
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED, m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this ); wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ),
nullptr, this );
} }
@ -160,7 +164,6 @@ void DIALOG_BOARD_SETUP::OnPageChange( wxBookCtrlEvent& event )
} }
// Run Import Settings... action
void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event ) void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
{ {
DIALOG_IMPORT_SETTINGS importDlg( this, m_frame ); DIALOG_IMPORT_SETTINGS importDlg( this, m_frame );

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) 2019 Alexander Shuklin, jasuramme@gmail.com * Copyright (C) 2019 Alexander Shuklin, jasuramme@gmail.com
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.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
@ -45,8 +45,9 @@
#define ROW_BOARD_HEIGHT 1 #define ROW_BOARD_HEIGHT 1
#define ROW_BOARD_AREA 2 #define ROW_BOARD_AREA 2
/** /**
* Struct containing the dialog last saved state * The dialog last saved state.
*/ */
struct DIALOG_BOARD_STATISTICS_SAVED_STATE struct DIALOG_BOARD_STATISTICS_SAVED_STATE
{ {
@ -69,6 +70,7 @@ struct DIALOG_BOARD_STATISTICS_SAVED_STATE
// used to reinit last state after a project change // used to reinit last state after a project change
}; };
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState; static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState;
DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame ) : DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame ) :
@ -81,7 +83,9 @@ DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame )
m_parentFrame = aParentFrame; m_parentFrame = aParentFrame;
m_gridDrills->UseNativeColHeader(); m_gridDrills->UseNativeColHeader();
m_gridDrills->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_BOARD_STATISTICS::drillGridSort ), NULL, this ); m_gridDrills->Connect( wxEVT_GRID_COL_SORT,
wxGridEventHandler( DIALOG_BOARD_STATISTICS::drillGridSort ),
nullptr, this );
m_checkBoxExcludeComponentsNoPins->SetValue( s_savedDialogState.excludeNoPins ); m_checkBoxExcludeComponentsNoPins->SetValue( s_savedDialogState.excludeNoPins );
m_checkBoxSubtractHoles->SetValue( s_savedDialogState.subtractHoles ); m_checkBoxSubtractHoles->SetValue( s_savedDialogState.subtractHoles );
@ -103,6 +107,7 @@ DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame )
m_gridBoard->SetCellAlignment( 2, 0, wxALIGN_LEFT, wxALIGN_CENTRE ); m_gridBoard->SetCellAlignment( 2, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
wxGrid* grids[] = { m_gridComponents, m_gridPads, m_gridVias, m_gridBoard }; wxGrid* grids[] = { m_gridComponents, m_gridPads, m_gridVias, m_gridBoard };
for( auto& grid : grids ) for( auto& grid : grids )
{ {
// Remove wxgrid's selection boxes // Remove wxgrid's selection boxes
@ -130,6 +135,7 @@ DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame )
m_sdbControlSizerCancel->SetLabel( _( "Close" ) ); m_sdbControlSizerCancel->SetLabel( _( "Close" ) );
} }
void DIALOG_BOARD_STATISTICS::refreshItemsTypes() void DIALOG_BOARD_STATISTICS::refreshItemsTypes()
{ {
m_componentsTypes.clear(); m_componentsTypes.clear();
@ -167,6 +173,7 @@ void DIALOG_BOARD_STATISTICS::refreshItemsTypes()
m_gridVias->AppendRows( appendRows ); m_gridVias->AppendRows( appendRows );
} }
bool DIALOG_BOARD_STATISTICS::TransferDataToWindow() bool DIALOG_BOARD_STATISTICS::TransferDataToWindow()
{ {
refreshItemsTypes(); refreshItemsTypes();
@ -178,6 +185,7 @@ bool DIALOG_BOARD_STATISTICS::TransferDataToWindow()
return true; return true;
} }
void DIALOG_BOARD_STATISTICS::getDataFromPCB() void DIALOG_BOARD_STATISTICS::getDataFromPCB()
{ {
BOARD* board = m_parentFrame->GetBoard(); BOARD* board = m_parentFrame->GetBoard();
@ -348,6 +356,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
} }
} }
void DIALOG_BOARD_STATISTICS::updateWidets() void DIALOG_BOARD_STATISTICS::updateWidets()
{ {
int totalPads = 0; int totalPads = 0;
@ -356,8 +365,8 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
for( const auto& type : m_padsTypes ) for( const auto& type : m_padsTypes )
{ {
m_gridPads->SetCellValue( currentRow, COL_LABEL, type.title ); m_gridPads->SetCellValue( currentRow, COL_LABEL, type.title );
m_gridPads->SetCellValue( m_gridPads->SetCellValue( currentRow, COL_AMOUNT,
currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), type.qty ) ); wxString::Format( wxT( "%i " ), type.qty ) );
totalPads += type.qty; totalPads += type.qty;
currentRow++; currentRow++;
} }
@ -371,8 +380,7 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
for( const auto& type : m_viasTypes ) for( const auto& type : m_viasTypes )
{ {
m_gridVias->SetCellValue( currentRow, COL_LABEL, type.title ); m_gridVias->SetCellValue( currentRow, COL_LABEL, type.title );
m_gridVias->SetCellValue( m_gridVias->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( "%i ", type.qty ) );
currentRow, COL_AMOUNT, wxString::Format( "%i ", type.qty ) );
totalVias += type.qty; totalVias += type.qty;
currentRow++; currentRow++;
} }
@ -416,7 +424,8 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT, m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT,
MessageTextFromValue( GetUserUnits(), m_boardHeight ) + " " ); MessageTextFromValue( GetUserUnits(), m_boardHeight ) + " " );
m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT, m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT,
MessageTextFromValue( GetUserUnits(), m_boardArea, true, EDA_DATA_TYPE::AREA ) ); MessageTextFromValue( GetUserUnits(), m_boardArea, true,
EDA_DATA_TYPE::AREA ) );
} }
else else
{ {
@ -436,6 +445,7 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
adjustDrillGridColumns(); adjustDrillGridColumns();
} }
void DIALOG_BOARD_STATISTICS::updateDrillGrid() void DIALOG_BOARD_STATISTICS::updateDrillGrid()
{ {
BOARD* board = m_parentFrame->GetBoard(); BOARD* board = m_parentFrame->GetBoard();
@ -488,8 +498,10 @@ void DIALOG_BOARD_STATISTICS::updateDrillGrid()
} }
} }
void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString& aStr,
bool aUseRowLabels, bool aUseColLabels, bool aUseFirstColAsLabel ) bool aUseRowLabels, bool aUseColLabels,
bool aUseFirstColAsLabel )
{ {
std::vector<int> widths( aGrid->GetNumberCols(), 0 ); std::vector<int> widths( aGrid->GetNumberCols(), 0 );
int rowLabelsWidth = 0; int rowLabelsWidth = 0;
@ -530,6 +542,7 @@ void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString&
tmp.Printf( " %*s |", widths[col], aGrid->GetColLabelValue( col ) ); tmp.Printf( " %*s |", widths[col], aGrid->GetColLabelValue( col ) );
else else
tmp.Printf( " %*s |", widths[col], aGrid->GetCellValue( 0, col ) ); tmp.Printf( " %*s |", widths[col], aGrid->GetCellValue( 0, col ) );
aStr << tmp; aStr << tmp;
} }
@ -572,6 +585,7 @@ void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString&
tmp.Printf( "|%-*s |", widths[0], aGrid->GetCellValue( row, 0 ) ); tmp.Printf( "|%-*s |", widths[0], aGrid->GetCellValue( row, 0 ) );
else else
tmp.Printf( "|" ); tmp.Printf( "|" );
aStr << tmp; aStr << tmp;
for( int col = firstCol; col < aGrid->GetNumberCols(); col++ ) for( int col = firstCol; col < aGrid->GetNumberCols(); col++ )
@ -579,10 +593,12 @@ void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString&
tmp.Printf( " %*s |", widths[col], aGrid->GetCellValue( row, col ) ); tmp.Printf( " %*s |", widths[col], aGrid->GetCellValue( row, col ) );
aStr << tmp; aStr << tmp;
} }
aStr << "\n"; aStr << "\n";
} }
} }
void DIALOG_BOARD_STATISTICS::adjustDrillGridColumns() void DIALOG_BOARD_STATISTICS::adjustDrillGridColumns()
{ {
int newTotalWidth = m_gridDrills->GetClientSize().GetWidth(); int newTotalWidth = m_gridDrills->GetClientSize().GetWidth();
@ -605,7 +621,7 @@ void DIALOG_BOARD_STATISTICS::adjustDrillGridColumns()
m_gridDrills->Refresh(); m_gridDrills->Refresh();
} }
// If any checkbox clicked, we have to refresh dialog data
void DIALOG_BOARD_STATISTICS::checkboxClicked( wxCommandEvent& aEvent ) void DIALOG_BOARD_STATISTICS::checkboxClicked( wxCommandEvent& aEvent )
{ {
s_savedDialogState.excludeNoPins = m_checkBoxExcludeComponentsNoPins->GetValue(); s_savedDialogState.excludeNoPins = m_checkBoxExcludeComponentsNoPins->GetValue();
@ -617,6 +633,7 @@ void DIALOG_BOARD_STATISTICS::checkboxClicked( wxCommandEvent& aEvent )
drillsPanel->Layout(); drillsPanel->Layout();
} }
void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent ) void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
{ {
FILE* outFile; FILE* outFile;
@ -639,7 +656,7 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
outFile = wxFopen( saveFileDialog.GetPath(), "wt" ); outFile = wxFopen( saveFileDialog.GetPath(), "wt" );
if( outFile == NULL ) if( outFile == nullptr )
{ {
msg.Printf( _( "Failed to create file '%s'." ), saveFileDialog.GetPath() ); msg.Printf( _( "Failed to create file '%s'." ), saveFileDialog.GetPath() );
DisplayErrorMessage( this, msg ); DisplayErrorMessage( this, msg );
@ -656,9 +673,12 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
if( m_hasOutline ) if( m_hasOutline )
{ {
msg << wxS( "- " ) << _( "Width" ) << wxS( ": " ) << MessageTextFromValue( GetUserUnits(), m_boardWidth ) << "\n"; msg << wxS( "- " ) << _( "Width" ) << wxS( ": " ) <<
msg << wxS( "- " ) << _( "Height" ) << wxS( ": " )<< MessageTextFromValue( GetUserUnits(), m_boardHeight ) << "\n"; MessageTextFromValue( GetUserUnits(), m_boardWidth ) << "\n";
msg << wxS( "- " ) << _( "Area" ) + wxS( ": " ) << MessageTextFromValue( GetUserUnits(), m_boardArea, true, EDA_DATA_TYPE::AREA ); msg << wxS( "- " ) << _( "Height" ) << wxS( ": " ) <<
MessageTextFromValue( GetUserUnits(), m_boardHeight ) << "\n";
msg << wxS( "- " ) << _( "Area" ) + wxS( ": " ) <<
MessageTextFromValue( GetUserUnits(), m_boardArea, true, EDA_DATA_TYPE::AREA );
msg << "\n"; msg << "\n";
} }
else else
@ -687,6 +707,7 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
wxString tmp; wxString tmp;
widths.reserve( labels.size() ); widths.reserve( labels.size() );
for( const auto& label : labels ) for( const auto& label : labels )
widths.push_back( label.size() ); widths.push_back( label.size() );
@ -731,6 +752,7 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
fclose( outFile ); fclose( outFile );
} }
void DIALOG_BOARD_STATISTICS::drillGridSize( wxSizeEvent& aEvent ) void DIALOG_BOARD_STATISTICS::drillGridSize( wxSizeEvent& aEvent )
{ {
aEvent.Skip(); aEvent.Skip();
@ -748,6 +770,7 @@ void DIALOG_BOARD_STATISTICS::drillGridSort( wxGridEvent& aEvent )
updateDrillGrid(); updateDrillGrid();
} }
DIALOG_BOARD_STATISTICS::~DIALOG_BOARD_STATISTICS() DIALOG_BOARD_STATISTICS::~DIALOG_BOARD_STATISTICS()
{ {
} }

View File

@ -1,7 +1,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) 2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.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
@ -65,15 +65,17 @@ WX_HTML_REPORT_BOX* DIALOG_CONSTRAINTS_REPORTER::AddPage( const wxString& aTitle
WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition, WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
wxHW_SCROLLBAR_AUTO|wxBORDER_SIMPLE ); wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
sizer->Add( reporter, 1, wxEXPAND|wxALL, 5 ); sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
panel->SetSizer( sizer ); panel->SetSizer( sizer );
panel->Layout(); panel->Layout();
m_notebook->AddPage( panel, aTitle ); m_notebook->AddPage( panel, aTitle );
reporter->SetUnits( m_frame->GetUserUnits() ); reporter->SetUnits( m_frame->GetUserUnits() );
reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked ), NULL, this ); reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
wxHtmlLinkEventHandler( DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked ),
nullptr, this );
return reporter; return reporter;
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.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
@ -153,8 +153,6 @@ void DIALOG_DRC::initValues()
} }
// PROGRESS_REPORTER calls
bool DIALOG_DRC::updateUI() bool DIALOG_DRC::updateUI()
{ {
double cur = (double) m_progress.load() / m_maxProgress; double cur = (double) m_progress.load() / m_maxProgress;
@ -502,8 +500,9 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
modified = true; modified = true;
} }
}
break; break;
}
case 2: case 2:
{ {
@ -522,8 +521,9 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
modified = true; modified = true;
} }
}
break; break;
}
case 3: case 3:
{ {
@ -531,8 +531,8 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
BOARD_INSPECTION_TOOL* inspectionTool = toolMgr->GetTool<BOARD_INSPECTION_TOOL>(); BOARD_INSPECTION_TOOL* inspectionTool = toolMgr->GetTool<BOARD_INSPECTION_TOOL>();
inspectionTool->InspectDRCError( node->m_RcItem ); inspectionTool->InspectDRCError( node->m_RcItem );
}
break; break;
}
case 4: case 4:
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR; bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR;
@ -582,8 +582,8 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
// Rebuild model and view // Rebuild model and view
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider );
modified = true; modified = true;
}
break; break;
}
case 7: case 7:
m_frame->ShowBoardSetupDialog( _( "Violation Severity" ) ); m_frame->ShowBoardSetupDialog( _( "Violation Severity" ) );
@ -786,7 +786,7 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName )
{ {
FILE* fp = wxFopen( aFullFileName, wxT( "w" ) ); FILE* fp = wxFopen( aFullFileName, wxT( "w" ) );
if( fp == NULL ) if( fp == nullptr )
return false; return false;
std::map<KIID, EDA_ITEM*> itemMap; std::map<KIID, EDA_ITEM*> itemMap;
@ -959,7 +959,9 @@ void DIALOG_DRC::updateDisplayedCounts()
m_Notebook->SetPageText( 1, msg ); m_Notebook->SetPageText( 1, msg );
if( m_footprintTestsRun ) if( m_footprintTestsRun )
{
msg.sprintf( m_footprintsTitleTemplate, numFootprints ); msg.sprintf( m_footprintsTitleTemplate, numFootprints );
}
else else
{ {
msg = m_footprintsTitleTemplate; msg = m_footprintsTitleTemplate;

View File

@ -4,7 +4,7 @@
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.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
@ -49,15 +49,19 @@
#include <fp_lib_table.h> #include <fp_lib_table.h>
int DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::m_page = 0; // remember the last open page during session // Remember the last open page during session.
int DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::m_page = 0;
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aParent, DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(
FOOTPRINT* aFootprint ) : FOOTPRINT_EDIT_FRAME* aParent,
FOOTPRINT* aFootprint ) :
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE( aParent ), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE( aParent ),
m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ), m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ),
m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ), m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl,
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ), m_SolderMaskMarginUnits ),
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl,
m_SolderPasteMarginUnits ),
m_inSelect( false ) m_inSelect( false )
{ {
m_frame = aParent; m_frame = aParent;
@ -89,6 +93,7 @@ DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( FO
m_itemsGrid->ShowHideColumns( m_frame->GetSettings()->m_FootprintTextShownColumns ); m_itemsGrid->ShowHideColumns( m_frame->GetSettings()->m_FootprintTextShownColumns );
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>(); PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
if( cfg->m_lastFootprint3dDir.IsEmpty() ) if( cfg->m_lastFootprint3dDir.IsEmpty() )
{ {
wxGetEnv( KICAD6_3DMODEL_DIR, &cfg->m_lastFootprint3dDir ); wxGetEnv( KICAD6_3DMODEL_DIR, &cfg->m_lastFootprint3dDir );
@ -158,7 +163,9 @@ DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( FO
m_button3DShapeRemove->SetBitmap( KiBitmap( BITMAPS::small_trash ) ); m_button3DShapeRemove->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
// wxFormBuilder doesn't include this event... // wxFormBuilder doesn't include this event...
m_itemsGrid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridCellChanging ), NULL, this ); m_itemsGrid->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridCellChanging ),
nullptr, this );
finishDialogSettings(); finishDialogSettings();
} }
@ -172,7 +179,9 @@ DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::~DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR()
// Prevents crash bug in wxGrid's d'tor // Prevents crash bug in wxGrid's d'tor
m_itemsGrid->DestroyTable( m_texts ); m_itemsGrid->DestroyTable( m_texts );
m_itemsGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridCellChanging ), NULL, this ); m_itemsGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridCellChanging ),
nullptr, this );
// Delete the GRID_TRICKS. // Delete the GRID_TRICKS.
m_itemsGrid->PopEventHandler( true ); m_itemsGrid->PopEventHandler( true );
@ -283,6 +292,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow()
wxString default_path; wxString default_path;
wxGetEnv( KICAD6_3DMODEL_DIR, &default_path ); wxGetEnv( KICAD6_3DMODEL_DIR, &default_path );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
default_path.Replace( wxT( "/" ), wxT( "\\" ) ); default_path.Replace( wxT( "/" ), wxT( "\\" ) );
#endif #endif
@ -396,7 +406,7 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::On3DModelCellChanged( wxGridEvent& a
filename.insert( 0, wxT( ":" ) ); filename.insert( 0, wxT( ":" ) );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// In Kicad files, filenames and paths are stored using Unix notation // In KiCad files, filenames and paths are stored using Unix notation
filename.Replace( wxT( "\\" ), wxT( "/" ) ); filename.Replace( wxT( "\\" ), wxT( "/" ) );
#endif #endif
@ -482,7 +492,7 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
filename = alias + wxT( ":" ) + shortPath; filename = alias + wxT( ":" ) + shortPath;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// In Kicad files, filenames and paths are stored using Unix notation // In KiCad files, filenames and paths are stored using Unix notation
model.m_Filename.Replace( "\\", "/" ); model.m_Filename.Replace( "\\", "/" );
#endif #endif
@ -690,6 +700,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
// A -50% margin ratio means no paste on a pad, the ratio must be >= -50% // A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
if( dtmp < -50.0 ) if( dtmp < -50.0 )
dtmp = -50.0; dtmp = -50.0;
// A margin ratio is always <= 0 // A margin ratio is always <= 0
// 0 means use full pad copper area // 0 means use full pad copper area
if( dtmp > 0.0 ) if( dtmp > 0.0 )
@ -832,7 +843,7 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
if( m_itemsGrid->IsCellEditControlShown() ) if( m_itemsGrid->IsCellEditControlShown() )
{ {
// Currently: nonthing to do // Currently: nothing to do
} }
// Handle a delayed focus. The delay allows us to: // Handle a delayed focus. The delay allows us to:

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) 2009-2016 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr * Copyright (C) 2009-2016 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -33,6 +33,7 @@
#include <tools/global_edit_tool.h> #include <tools/global_edit_tool.h>
#include "dialog_global_edit_tracks_and_vias_base.h" #include "dialog_global_edit_tracks_and_vias_base.h"
// Columns of netclasses grid // Columns of netclasses grid
enum { enum {
GRID_NAME = 0, GRID_NAME = 0,
@ -133,7 +134,9 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT
m_netclassGrid->SetCellHighlightPenWidth( 0 ); m_netclassGrid->SetCellHighlightPenWidth( 0 );
m_sdbSizerOK->SetDefault(); m_sdbSizerOK->SetDefault();
m_netFilter->Connect( NET_SELECTED, wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), NULL, this ); m_netFilter->Connect( NET_SELECTED,
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ),
nullptr, this );
finishDialogSettings(); finishDialogSettings();
} }
@ -151,7 +154,9 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS()
g_layerFilter = m_layerFilter->GetLayerSelection(); g_layerFilter = m_layerFilter->GetLayerSelection();
g_filterSelected = m_selectedItemsFilter->GetValue(); g_filterSelected = m_selectedItemsFilter->GetValue();
m_netFilter->Disconnect( NET_SELECTED, wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), NULL, this ); m_netFilter->Disconnect( NET_SELECTED,
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ),
nullptr, this );
delete[] m_originalColWidths; delete[] m_originalColWidths;
} }
@ -210,6 +215,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid()
SET_NETCLASS_VALUE( 1, GRID_uVIADRILL, defaultNetclass->GetuViaDrill() ); SET_NETCLASS_VALUE( 1, GRID_uVIADRILL, defaultNetclass->GetuViaDrill() );
int row = 2; int row = 2;
for( const auto& netclass : netclasses ) for( const auto& netclass : netclasses )
{ {
m_netclassGrid->SetCellValue( row, GRID_NAME, netclass.first ); m_netclassGrid->SetCellValue( row, GRID_NAME, netclass.first );
@ -237,7 +243,7 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
else if( item ) else if( item )
m_netclassFilter->SetStringSelection( item->GetNet()->GetNetClassName() ); m_netclassFilter->SetStringSelection( item->GetNet()->GetNetClassName() );
if( g_filterByNet && m_brd->FindNet( g_netFilter ) != NULL ) if( g_filterByNet && m_brd->FindNet( g_netFilter ) != nullptr )
{ {
m_netFilter->SetSelectedNet( g_netFilter ); m_netFilter->SetSelectedNet( g_netFilter );
m_netFilterOpt->SetValue( true ); m_netFilterOpt->SetValue( true );

View File

@ -7,7 +7,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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -67,9 +67,10 @@ DIALOG_PAD_PRIMITIVES_PROPERTIES::DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aP
finishDialogSettings(); finishDialogSettings();
} }
bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow() bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow()
{ {
if( m_shape == NULL ) if( m_shape == nullptr )
return false; return false;
m_thickness.SetValue( m_shape->GetWidth() ); m_thickness.SetValue( m_shape->GetWidth() );
@ -169,6 +170,7 @@ bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow()
return true; return true;
} }
bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow() bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow()
{ {
if( m_thickness.GetValue() == 0 && !m_filledCtrl->GetValue() ) if( m_thickness.GetValue() == 0 && !m_filledCtrl->GetValue() )
@ -201,6 +203,7 @@ bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow()
// the start point in m_End // the start point in m_End
m_shape->SetStart( wxPoint( m_endX.GetValue(), m_endY.GetValue() ) ); m_shape->SetStart( wxPoint( m_endX.GetValue(), m_endY.GetValue() ) );
m_shape->SetEnd( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) ); m_shape->SetEnd( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) );
// arc angle // arc angle
m_shape->SetAngle( m_radius.GetValue() ); m_shape->SetAngle( m_radius.GetValue() );
break; break;
@ -249,7 +252,9 @@ DIALOG_PAD_PRIMITIVE_POLY_PROPS::DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aPar
m_sdbSizerOK->SetDefault(); m_sdbSizerOK->SetDefault();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
m_gridCornersList->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging ), NULL, this ); m_gridCornersList->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging ),
nullptr, this );
// Now all widgets have the size fixed, call FinishDialogSettings // Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings(); finishDialogSettings();
@ -258,13 +263,15 @@ DIALOG_PAD_PRIMITIVE_POLY_PROPS::DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aPar
DIALOG_PAD_PRIMITIVE_POLY_PROPS::~DIALOG_PAD_PRIMITIVE_POLY_PROPS() DIALOG_PAD_PRIMITIVE_POLY_PROPS::~DIALOG_PAD_PRIMITIVE_POLY_PROPS()
{ {
m_gridCornersList->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging ), NULL, this ); m_gridCornersList->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging ),
nullptr, this );
} }
bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow() bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow()
{ {
if( m_shape == NULL ) if( m_shape == nullptr )
return false; return false;
m_thickness.SetValue( m_shape->GetWidth() ); m_thickness.SetValue( m_shape->GetWidth() );
@ -285,6 +292,7 @@ bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow()
// enter others corner coordinates // enter others corner coordinates
wxString msg; wxString msg;
for( unsigned row = 0; row < m_currPoints.size(); ++row ) for( unsigned row = 0; row < m_currPoints.size(); ++row )
{ {
// Row label is "Corner x" // Row label is "Corner x"
@ -321,7 +329,6 @@ bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::Validate()
} }
// test for a valid polygon (a not self intersectiong polygon)
bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate( bool aRemoveRedundantCorners ) bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate( bool aRemoveRedundantCorners )
{ {
if( !m_gridCornersList->CommitPendingChanges() ) if( !m_gridCornersList->CommitPendingChanges() )
@ -413,6 +420,7 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonAdd( wxCommandEvent& event )
m_panelPoly->Refresh(); m_panelPoly->Refresh();
} }
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonDelete( wxCommandEvent& event ) void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonDelete( wxCommandEvent& event )
{ {
if( !m_gridCornersList->CommitPendingChanges() ) if( !m_gridCornersList->CommitPendingChanges() )
@ -442,12 +450,14 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonDelete( wxCommandEvent& event )
TransferDataToWindow(); TransferDataToWindow();
m_gridCornersList->ForceRefresh(); m_gridCornersList->ForceRefresh();
// select the row previous to the last deleted row // select the row previous to the last deleted row
m_gridCornersList->SelectRow( std::max( 0, selections[ 0 ] - 1 ) ); m_gridCornersList->SelectRow( std::max( 0, selections[ 0 ] - 1 ) );
m_panelPoly->Refresh(); m_panelPoly->Refresh();
} }
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel( wxPaintEvent& event ) void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel( wxPaintEvent& event )
{ {
wxPaintDC dc( m_panelPoly ); wxPaintDC dc( m_panelPoly );
@ -476,8 +486,8 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel( wxPaintEvent& event )
// Draw X and Y axis. This is particularly useful to show the // Draw X and Y axis. This is particularly useful to show the
// reference position of basic shape // reference position of basic shape
// Axis are drawn before the polygon to avoid masking segments on axis // Axis are drawn before the polygon to avoid masking segments on axis
GRLine( NULL, &dc, -dc_size.x, 0, dc_size.x, 0, 0, LIGHTBLUE ); // X axis GRLine( nullptr, &dc, -dc_size.x, 0, dc_size.x, 0, 0, LIGHTBLUE ); // X axis
GRLine( NULL, &dc, 0, -dc_size.y, 0, dc_size.y, 0, LIGHTBLUE ); // Y axis GRLine( nullptr, &dc, 0, -dc_size.y, 0, dc_size.y, 0, LIGHTBLUE ); // Y axis
// Draw polygon. // Draw polygon.
// The selected edge(s) are shown in selectcolor, the others in normalcolor. // The selected edge(s) are shown in selectcolor, the others in normalcolor.
@ -498,23 +508,27 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel( wxPaintEvent& event )
if( jj >= m_currPoints.size() ) if( jj >= m_currPoints.size() )
jj = 0; jj = 0;
GRLine( NULL, &dc, m_currPoints[ii] * scale, m_currPoints[jj] * scale, m_thickness.GetValue() * scale, color ); GRLine( nullptr, &dc, m_currPoints[ii] * scale, m_currPoints[jj] * scale,
m_thickness.GetValue() * scale, color );
} }
event.Skip(); event.Skip();
} }
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPolyPanelResize( wxSizeEvent& event ) void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPolyPanelResize( wxSizeEvent& event )
{ {
m_panelPoly->Refresh(); m_panelPoly->Refresh();
event.Skip(); event.Skip();
} }
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onGridSelect( wxGridRangeSelectEvent& event ) void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onGridSelect( wxGridRangeSelectEvent& event )
{ {
m_panelPoly->Refresh(); m_panelPoly->Refresh();
} }
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging( wxGridEvent& event ) void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging( wxGridEvent& event )
{ {
int row = event.GetRow(); int row = event.GetRow();
@ -535,8 +549,6 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging( wxGridEvent& event )
} }
// A dialog to apply geometry transforms to a shape or set of shapes
// (move, rotate around origin, scaling factor, duplication).
DIALOG_PAD_PRIMITIVES_TRANSFORM::DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, DIALOG_PAD_PRIMITIVES_TRANSFORM::DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent,
PCB_BASE_FRAME* aFrame, PCB_BASE_FRAME* aFrame,
std::vector<std::shared_ptr<PCB_SHAPE>>& aList, std::vector<std::shared_ptr<PCB_SHAPE>>& aList,
@ -597,8 +609,10 @@ void DIALOG_PAD_PRIMITIVES_TRANSFORM::Transform( std::vector<std::shared_ptr<PCB
{ {
std::shared_ptr<PCB_SHAPE> shape; std::shared_ptr<PCB_SHAPE> shape;
if( aList == NULL ) if( aList == nullptr )
{
shape = m_list[idx]; shape = m_list[idx];
}
else else
{ {
aList->emplace_back( std::make_shared<PCB_SHAPE>( *m_list[idx] ) ); aList->emplace_back( std::make_shared<PCB_SHAPE>( *m_list[idx] ) );

View File

@ -3,8 +3,8 @@
* *
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -66,6 +66,7 @@ static PAD_SHAPE code_shape[] =
PAD_SHAPE::CUSTOM // choice = PAD_SHAPE::CUSTOM_RECT_ANCHOR PAD_SHAPE::CUSTOM // choice = PAD_SHAPE::CUSTOM_RECT_ANCHOR
}; };
// the ordered index of the pad shape wxChoice in dialog. // the ordered index of the pad shape wxChoice in dialog.
// keep it consistent with code_shape[] and dialog strings // keep it consistent with code_shape[] and dialog strings
enum CODE_CHOICE enum CODE_CHOICE
@ -81,6 +82,7 @@ enum CODE_CHOICE
CHOICE_SHAPE_CUSTOM_RECT_ANCHOR CHOICE_SHAPE_CUSTOM_RECT_ANCHOR
}; };
static PAD_ATTRIB code_type[] = static PAD_ATTRIB code_type[] =
{ {
PAD_ATTRIB::PTH, PAD_ATTRIB::PTH,
@ -91,13 +93,15 @@ static PAD_ATTRIB code_type[] =
// only on tech layers (usually only on paste layer // only on tech layers (usually only on paste layer
}; };
// Thse define have the same value as the m_PadType wxChoice GetSelected() return value
// These define have the same value as the m_PadType wxChoice GetSelected() return value
#define PTH_DLG_TYPE 0 #define PTH_DLG_TYPE 0
#define SMD_DLG_TYPE 1 #define SMD_DLG_TYPE 1
#define CONN_DLG_TYPE 2 #define CONN_DLG_TYPE 2
#define NPTH_DLG_TYPE 3 #define NPTH_DLG_TYPE 3
#define APERTURE_DLG_TYPE 4 #define APERTURE_DLG_TYPE 4
void PCB_BASE_FRAME::ShowPadPropertiesDialog( PAD* aPad ) void PCB_BASE_FRAME::ShowPadPropertiesDialog( PAD* aPad )
{ {
DIALOG_PAD_PROPERTIES dlg( this, aPad ); DIALOG_PAD_PROPERTIES dlg( this, aPad );
@ -164,7 +168,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_nonCopperWarningIcon->SetBitmap( KiBitmap( BITMAPS::dialog_warning ) ); m_nonCopperWarningIcon->SetBitmap( KiBitmap( BITMAPS::dialog_warning ) );
m_padMaster = m_parent->GetDesignSettings().m_Pad_Master.get(); m_padMaster = m_parent->GetDesignSettings().m_Pad_Master.get();
m_dummyPad = new PAD( (FOOTPRINT*) NULL ); m_dummyPad = new PAD( (FOOTPRINT*) nullptr );
if( aPad ) if( aPad )
{ {
@ -209,7 +213,9 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_sdbSizerOK->SetDefault(); m_sdbSizerOK->SetDefault();
m_canUpdate = true; m_canUpdate = true;
m_PadNetSelector->Connect( NET_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES::OnValuesChanged ), NULL, this ); m_PadNetSelector->Connect( NET_SELECTED,
wxCommandEventHandler( DIALOG_PAD_PROPERTIES::OnValuesChanged ),
nullptr, this );
// Now all widgets have the size fixed, call FinishDialogSettings // Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings(); finishDialogSettings();
@ -221,14 +227,17 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
DIALOG_PAD_PROPERTIES::~DIALOG_PAD_PROPERTIES() DIALOG_PAD_PROPERTIES::~DIALOG_PAD_PROPERTIES()
{ {
m_PadNetSelector->Disconnect( NET_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES::OnValuesChanged ), NULL, this ); m_PadNetSelector->Disconnect( NET_SELECTED,
wxCommandEventHandler( DIALOG_PAD_PROPERTIES::OnValuesChanged ),
nullptr, this );
delete m_dummyPad; delete m_dummyPad;
delete m_axisOrigin; delete m_axisOrigin;
} }
bool DIALOG_PAD_PROPERTIES::m_sketchPreview = false; // Stores the pad draw option during a session // Store the pad draw option during a session.
bool DIALOG_PAD_PROPERTIES::m_sketchPreview = false;
void DIALOG_PAD_PROPERTIES::OnInitDialog( wxInitDialogEvent& event ) void DIALOG_PAD_PROPERTIES::OnInitDialog( wxInitDialogEvent& event )
@ -308,6 +317,7 @@ void DIALOG_PAD_PROPERTIES::prepareCanvas()
// gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid: // gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid:
double gridsize = 0.001 * IU_PER_MM; double gridsize = 0.001 * IU_PER_MM;
view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) ); view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) );
// And do not show the grid: // And do not show the grid:
view->GetGAL()->SetGridVisibility( false ); view->GetGAL()->SetGridVisibility( false );
view->Add( m_dummyPad ); view->Add( m_dummyPad );
@ -691,7 +701,8 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList()
for( wxString& s : bs_info ) for( wxString& s : bs_info )
s.Empty(); s.Empty();
bs_info[4] = _( "width" ) + wxS( " " )+ MessageTextFromValue( m_units, primitive->GetWidth() ); bs_info[4] = _( "width" ) + wxS( " " )+ MessageTextFromValue( m_units,
primitive->GetWidth() );
switch( primitive->GetShape() ) switch( primitive->GetShape() )
{ {
@ -710,7 +721,8 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList()
case PCB_SHAPE_TYPE::ARC: // Arc with rounded ends case PCB_SHAPE_TYPE::ARC: // Arc with rounded ends
bs_info[0] = _( "Arc" ); bs_info[0] = _( "Arc" );
bs_info[1] = _( "center" ) + wxS( " " )+ formatCoord( m_units, primitive->GetCenter() ); bs_info[1] = _( "center" ) + wxS( " " )+ formatCoord( m_units, primitive->GetCenter() );
bs_info[2] = _( "start" ) + wxS( " " )+ formatCoord( m_units, primitive->GetArcStart() ); bs_info[2] = _( "start" ) + wxS( " " )+ formatCoord( m_units,
primitive->GetArcStart() );
bs_info[3] = _( "angle" ) + wxS( " " )+ FormatAngle( primitive->GetAngle() ); bs_info[3] = _( "angle" ) + wxS( " " )+ FormatAngle( primitive->GetAngle() );
break; break;
@ -721,7 +733,8 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList()
bs_info[0] = _( "circle" ); bs_info[0] = _( "circle" );
bs_info[1] = formatCoord( m_units, primitive->GetStart() ); bs_info[1] = formatCoord( m_units, primitive->GetStart() );
bs_info[2] = _( "radius" ) + wxS( " " )+ MessageTextFromValue( m_units, primitive->GetRadius() ); bs_info[2] = _( "radius" ) + wxS( " " )+ MessageTextFromValue( m_units,
primitive->GetRadius() );
break; break;
case PCB_SHAPE_TYPE::POLYGON: // polygon case PCB_SHAPE_TYPE::POLYGON: // polygon
@ -747,6 +760,7 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList()
m_listCtrlPrimitives->SetColumnWidth( ii, wxLIST_AUTOSIZE ); m_listCtrlPrimitives->SetColumnWidth( ii, wxLIST_AUTOSIZE );
} }
void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event ) void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event )
{ {
redraw(); redraw();
@ -776,7 +790,6 @@ void DIALOG_PAD_PROPERTIES::onChangePadMode( wxCommandEvent& event )
} }
void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
{ {
switch( m_PadShapeSelector->GetSelection() ) switch( m_PadShapeSelector->GetSelection() )
@ -798,8 +811,9 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
// A reasonable default (from IPC-7351C) // A reasonable default (from IPC-7351C)
if( m_dummyPad->GetRoundRectRadiusRatio() == 0.0 ) if( m_dummyPad->GetRoundRectRadiusRatio() == 0.0 )
m_tcCornerSizeRatio->ChangeValue( "25" ); m_tcCornerSizeRatio->ChangeValue( "25" );
}
break; break;
}
case CHOICE_SHAPE_CHAMFERED_RECT: case CHOICE_SHAPE_CHAMFERED_RECT:
m_shapePropsBook->SetSelection( 3 ); m_shapePropsBook->SetSelection( 3 );
@ -820,8 +834,8 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
m_cbTopRight->SetValue( false ); m_cbTopRight->SetValue( false );
m_cbBottomLeft->SetValue( false ); m_cbBottomLeft->SetValue( false );
m_cbBottomRight->SetValue( false ); m_cbBottomRight->SetValue( false );
break;
} }
break;
case CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT: case CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT:
m_shapePropsBook->SetSelection( 4 ); m_shapePropsBook->SetSelection( 4 );
@ -1197,7 +1211,6 @@ void DIALOG_PAD_PROPERTIES::OnSetCopperLayers( wxCommandEvent& event )
} }
// Called when select/deselect a layer.
void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
{ {
transferDataToPad( m_dummyPad ); transferDataToPad( m_dummyPad );
@ -1205,7 +1218,6 @@ void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
} }
// test if all values are acceptable for the pad
bool DIALOG_PAD_PROPERTIES::padValuesOK() bool DIALOG_PAD_PROPERTIES::padValuesOK()
{ {
bool error = transferDataToPad( m_dummyPad ); bool error = transferDataToPad( m_dummyPad );
@ -1292,7 +1304,7 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
// Some pads need a positive solder paste clearance (mainly for BGA with small pads) // Some pads need a positive solder paste clearance (mainly for BGA with small pads)
// However, a positive value can create issues if the resulting shape is too big. // However, a positive value can create issues if the resulting shape is too big.
// (like a solder paste creating a solder paste area on a neighbour pad or on the solder mask) // (like a solder paste creating a solder paste area on a neighbor pad or on the solder mask)
// So we could ask for user to confirm the choice // So we could ask for user to confirm the choice
// For now we just check for disappearing paste // For now we just check for disappearing paste
wxSize paste_size; wxSize paste_size;
@ -1541,6 +1553,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
return false; return false;
transferDataToPad( m_padMaster ); transferDataToPad( m_padMaster );
// m_padMaster is a pattern: ensure there is no net for this pad: // m_padMaster is a pattern: ensure there is no net for this pad:
m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED ); m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
@ -2035,8 +2048,8 @@ void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
if( m_canUpdate ) if( m_canUpdate )
{ {
transferDataToPad( m_dummyPad ); transferDataToPad( m_dummyPad );
// If the pad size has changed, update the displayed values
// for rounded rect pads // If the pad size has changed, update the displayed values for rounded rect pads.
updateRoundRectCornerValues(); updateRoundRectCornerValues();
redraw(); redraw();
@ -2093,20 +2106,18 @@ void DIALOG_PAD_PROPERTIES::OnPrimitiveSelection( wxListEvent& event )
} }
/// Called on a double click on the basic shapes list
void DIALOG_PAD_PROPERTIES::onPrimitiveDClick( wxMouseEvent& event ) void DIALOG_PAD_PROPERTIES::onPrimitiveDClick( wxMouseEvent& event )
{ {
editPrimitive(); editPrimitive();
} }
// Called on a click on basic shapes list panel button
void DIALOG_PAD_PROPERTIES::onEditPrimitive( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::onEditPrimitive( wxCommandEvent& event )
{ {
editPrimitive(); editPrimitive();
} }
// Called on a click on basic shapes list panel button
void DIALOG_PAD_PROPERTIES::onDeletePrimitive( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::onDeletePrimitive( wxCommandEvent& event )
{ {
long select = m_listCtrlPrimitives->GetFirstSelected(); long select = m_listCtrlPrimitives->GetFirstSelected();

View File

@ -280,7 +280,6 @@ void DIALOG_PRINT_PCBNEW::createLeftPanel()
sizerLeft->Add( copperLabel, 0, wxRIGHT, 5 ); sizerLeft->Add( copperLabel, 0, wxRIGHT, 5 );
sizerLeft->Add( m_listCopperLayers, 1, wxEXPAND | wxBOTTOM | wxRIGHT, 5 ); sizerLeft->Add( m_listCopperLayers, 1, wxEXPAND | wxBOTTOM | wxRIGHT, 5 );
// Technical layer list // Technical layer list
auto technicalLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY, auto technicalLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY,
_( "Technical layers:" ) ); _( "Technical layers:" ) );
@ -290,22 +289,22 @@ void DIALOG_PRINT_PCBNEW::createLeftPanel()
sizerRight->Add( technicalLabel, 0, wxLEFT, 5 ); sizerRight->Add( technicalLabel, 0, wxLEFT, 5 );
sizerRight->Add( m_listTechLayers, 1, wxEXPAND | wxBOTTOM | wxLEFT, 5 ); sizerRight->Add( m_listTechLayers, 1, wxEXPAND | wxBOTTOM | wxLEFT, 5 );
// Layer list layout // Layer list layout
wxBoxSizer* bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL );
bLayerListsSizer->Add( sizerLeft, 1, wxEXPAND, 5 ); bLayerListsSizer->Add( sizerLeft, 1, wxEXPAND, 5 );
bLayerListsSizer->Add( sizerRight, 1, wxEXPAND, 5 ); bLayerListsSizer->Add( sizerRight, 1, wxEXPAND, 5 );
// Select/Unselect all buttons // Select/Unselect all buttons
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) ); m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) );
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY,
_( "Deselect all" ) ); _( "Deselect all" ) );
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onSelectAllClick ), NULL, this ); wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onSelectAllClick ),
nullptr, this );
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onDeselectAllClick ), NULL, this ); wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onDeselectAllClick ),
nullptr, this );
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
buttonSizer->Add( m_buttonSelectAll, 1, wxRIGHT | wxTOP | wxBOTTOM, 5 ); buttonSizer->Add( m_buttonSelectAll, 1, wxRIGHT | wxTOP | wxBOTTOM, 5 );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -36,6 +36,7 @@
#define LAYER_LIST_COLUMN_NAME 2 #define LAYER_LIST_COLUMN_NAME 2
#define LAYER_LIST_ROW_ALL_INNER_LAYERS 1 #define LAYER_LIST_ROW_ALL_INNER_LAYERS 1
class DIALOG_RULE_AREA_PROPERTIES : public DIALOG_RULE_AREA_PROPERTIES_BASE class DIALOG_RULE_AREA_PROPERTIES : public DIALOG_RULE_AREA_PROPERTIES_BASE
{ {
public: public:
@ -150,15 +151,21 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow()
if( m_zonesettings.m_Layers.count() == 0 ) if( m_zonesettings.m_Layers.count() == 0 )
{ {
DisplayError( NULL, _( "No layers selected." ) ); DisplayError( this, _( "No layers selected." ) );
return false; return false;
} }
switch( m_OutlineDisplayCtrl->GetSelection() ) switch( m_OutlineDisplayCtrl->GetSelection() )
{ {
case 0: m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break; case 0:
case 1: m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break; m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH;
case 2: m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break; break;
case 1:
m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE;
break;
case 2:
m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL;
break;
} }
auto cfg = m_parent->GetPcbNewSettings(); auto cfg = m_parent->GetPcbNewSettings();

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) 2004-2018 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2004-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 2010-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2010-2021 KiCad Developers, see AUTHORS.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
@ -38,6 +38,7 @@
#include <math/util.h> // for KiROUND #include <math/util.h> // for KiROUND
#include <scintilla_tricks.h> #include <scintilla_tricks.h>
DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BOARD_ITEM* aItem ) : DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BOARD_ITEM* aItem ) :
DIALOG_TEXT_PROPERTIES_BASE( aParent ), DIALOG_TEXT_PROPERTIES_BASE( aParent ),
m_Parent( aParent ), m_Parent( aParent ),
@ -158,7 +159,8 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
// wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set, // wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set,
// so we have to listen to wxEVT_CHAR_HOOK events instead. // so we have to listen to wxEVT_CHAR_HOOK events instead.
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXT_PROPERTIES::OnCharHook ), NULL, this ); Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXT_PROPERTIES::OnCharHook ),
nullptr, this );
finishDialogSettings(); finishDialogSettings();
} }
@ -166,13 +168,13 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES() DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES()
{ {
Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXT_PROPERTIES::OnCharHook ), NULL, this ); Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXT_PROPERTIES::OnCharHook ),
nullptr, this );
delete m_scintillaTricks; delete m_scintillaTricks;
} }
// Launch the text properties dialog in quasi modal mode.
void PCB_BASE_EDIT_FRAME::ShowTextPropertiesDialog( BOARD_ITEM* aText ) void PCB_BASE_EDIT_FRAME::ShowTextPropertiesDialog( BOARD_ITEM* aText )
{ {
DIALOG_TEXT_PROPERTIES dlg( this, aText ); DIALOG_TEXT_PROPERTIES dlg( this, aText );

View File

@ -1,7 +1,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) 2020 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2020-2021 KiCad Developers, see change_log.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
@ -57,19 +57,14 @@ void DRC_RULES_PARSER::reportError( const wxString& aMessage )
if( m_reporter ) if( m_reporter )
{ {
wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ), wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ), CurLineNumber(),
CurLineNumber(), CurOffset(), first, rest );
CurOffset(),
first,
rest );
m_reporter->Report( msg, RPT_SEVERITY_ERROR ); m_reporter->Report( msg, RPT_SEVERITY_ERROR );
} }
else else
{ {
wxString msg = wxString::Format( _( "ERROR: %s%s" ), wxString msg = wxString::Format( _( "ERROR: %s%s" ), first, rest );
first,
rest );
THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
@ -128,7 +123,7 @@ void DRC_RULES_PARSER::Parse( std::vector<DRC_RULE*>& aRules, REPORTER* aReporte
if( (int) token == DSN_NUMBER ) if( (int) token == DSN_NUMBER )
{ {
m_requiredVersion = (int)strtol( CurText(), NULL, 10 ); m_requiredVersion = (int)strtol( CurText(), nullptr, 10 );
m_tooRecent = ( m_requiredVersion > DRC_RULE_FILE_VERSION ); m_tooRecent = ( m_requiredVersion > DRC_RULE_FILE_VERSION );
token = NextTok(); token = NextTok();
} }
@ -158,8 +153,7 @@ void DRC_RULES_PARSER::Parse( std::vector<DRC_RULE*>& aRules, REPORTER* aReporte
break; break;
default: default:
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
FromUTF8(),
"'rule', 'version'" ); "'rule', 'version'" );
reportError( msg ); reportError( msg );
parseUnknown(); parseUnknown();
@ -220,8 +214,7 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE()
if( (int) NextTok() != DSN_RIGHT ) if( (int) NextTok() != DSN_RIGHT )
{ {
reportError( wxString::Format( _( "Unrecognized item '%s'." ), reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
FromUTF8() ) );
parseUnknown(); parseUnknown();
} }
@ -237,8 +230,7 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE()
return rule; return rule;
default: default:
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
FromUTF8(),
"'constraint', 'condition', 'disallow'" ); "'constraint', 'condition', 'disallow'" );
reportError( msg ); reportError( msg );
parseUnknown(); parseUnknown();
@ -264,10 +256,10 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
if( (int) token == DSN_RIGHT || token == T_EOF ) if( (int) token == DSN_RIGHT || token == T_EOF )
{ {
msg.Printf( _( "Missing constraint type.| Expected %s." ), msg.Printf( _( "Missing constraint type.| Expected %s." ),
"'clearance', 'hole_clearance', 'edge_clearance', 'hole', 'hole_to_hole', " "'clearance', 'hole_clearance', 'edge_clearance', 'hole', 'hole_to_hole', "
"'courtyard_clearance', 'silk_clearance', 'track_width', 'annular_width', " "'courtyard_clearance', 'silk_clearance', 'track_width', 'annular_width', "
"'disallow', 'length', 'skew', 'via_count', 'diff_pair_gap' or " "'disallow', 'length', 'skew', 'via_count', 'diff_pair_gap' or "
"'diff_pair_uncoupled'" ); "'diff_pair_uncoupled'" );
reportError( msg ); reportError( msg );
return; return;
} }
@ -290,8 +282,7 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
case T_diff_pair_gap: constraint.m_Type = DIFF_PAIR_GAP_CONSTRAINT; break; case T_diff_pair_gap: constraint.m_Type = DIFF_PAIR_GAP_CONSTRAINT; break;
case T_diff_pair_uncoupled: constraint.m_Type = DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT; break; case T_diff_pair_uncoupled: constraint.m_Type = DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT; break;
default: default:
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
FromUTF8(),
"'clearance', 'hole_clearance', 'edge_clearance', 'hole', hole_to_hole'," "'clearance', 'hole_clearance', 'edge_clearance', 'hole', hole_to_hole',"
"'courtyard_clearance', 'silk_clearance', 'track_width', 'annular_width', " "'courtyard_clearance', 'silk_clearance', 'track_width', 'annular_width', "
"'disallow', 'length', 'skew', 'diff_pair_gap' or 'diff_pair_uncoupled'." ); "'disallow', 'length', 'skew', 'diff_pair_gap' or 'diff_pair_uncoupled'." );
@ -323,8 +314,7 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
return; return;
default: default:
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
FromUTF8(),
"'track', 'via', 'micro_via', 'buried_via', 'pad', 'zone', 'text', " "'track', 'via', 'micro_via', 'buried_via', 'pad', 'zone', 'text', "
"'graphic', 'hole' or 'footprint'." ); "'graphic', 'hole' or 'footprint'." );
reportError( msg ); reportError( msg );
@ -441,18 +431,13 @@ void DRC_RULES_PARSER::parseValueWithUnits( const wxString& aExpr, int& aResult
if( m_reporter ) if( m_reporter )
{ {
wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ), wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ),
CurLineNumber(), CurLineNumber(), CurOffset() + aOffset, first, rest );
CurOffset() + aOffset,
first,
rest );
m_reporter->Report( msg, RPT_SEVERITY_ERROR ); m_reporter->Report( msg, RPT_SEVERITY_ERROR );
} }
else else
{ {
wxString msg = wxString::Format( _( "ERROR: %s%s" ), wxString msg = wxString::Format( _( "ERROR: %s%s" ), first, rest );
first,
rest );
THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(), THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(),
CurOffset() + aOffset ); CurOffset() + aOffset );
@ -508,8 +493,7 @@ LSET DRC_RULES_PARSER::parseLayer()
if( (int) NextTok() != DSN_RIGHT ) if( (int) NextTok() != DSN_RIGHT )
{ {
reportError( wxString::Format( _( "Unrecognized item '%s'." ), reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
FromUTF8() ) );
parseUnknown(); parseUnknown();
} }

View File

@ -1,7 +1,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) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -37,7 +37,7 @@ bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName )
{ {
FILE* cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) ); FILE* cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) );
if( cmpFile == NULL ) if( cmpFile == nullptr )
return false; return false;
fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) ); fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );

View File

@ -6,6 +6,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) 2013 Cirilo Bernardo * Copyright (C) 2013 Cirilo Bernardo
* Copyright (C) 2021 KiCad Developers, see AUTHORS.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
@ -48,16 +49,17 @@
#endif #endif
#include <convert_to_biu.h> // to define Millimeter2iu(x) #include <convert_to_biu.h> // to define Millimeter2iu(x)
// assumed default graphical line thickness: == 0.1mm // assumed default graphical line thickness: == 0.1mm
#define LINE_WIDTH (Millimeter2iu( 0.1 )) #define LINE_WIDTH (Millimeter2iu( 0.1 ))
static FILENAME_RESOLVER* resolver; static FILENAME_RESOLVER* resolver;
/** /**
* Function idf_export_outline * Retrieve line segment information from the edge layer and compiles the data into a form
* retrieves line segment information from the edge layer and compiles * which can be output as an IDFv3 compliant #BOARD_OUTLINE section.
* the data into a form which can be output as an IDFv3 compliant
* BOARD_OUTLINE section.
*/ */
static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard ) static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
{ {
@ -67,7 +69,7 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
IDF_POINT sp, ep; // start and end points from KiCad item IDF_POINT sp, ep; // start and end points from KiCad item
std::list< IDF_SEGMENT* > lines; // IDF intermediate form of KiCad graphical item std::list< IDF_SEGMENT* > lines; // IDF intermediate form of KiCad graphical item
IDF_OUTLINE* outline = NULL; // graphical items forming an outline or cutout IDF_OUTLINE* outline = nullptr; // graphical items forming an outline or cutout
// NOTE: IMPLEMENTATION // NOTE: IMPLEMENTATION
// If/when component cutouts are allowed, we must implement them separately. Cutouts // If/when component cutouts are allowed, we must implement them separately. Cutouts
@ -88,86 +90,90 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
switch( graphic->GetShape() ) switch( graphic->GetShape() )
{ {
case PCB_SHAPE_TYPE::SEGMENT: case PCB_SHAPE_TYPE::SEGMENT:
{
if( ( graphic->GetStart().x == graphic->GetEnd().x )
&& ( graphic->GetStart().y == graphic->GetEnd().y ) )
{ {
if( ( graphic->GetStart().x == graphic->GetEnd().x ) break;
&& ( graphic->GetStart().y == graphic->GetEnd().y ) )
{
break;
}
sp.x = graphic->GetStart().x * scale + offX;
sp.y = -graphic->GetStart().y * scale + offY;
ep.x = graphic->GetEnd().x * scale + offX;
ep.y = -graphic->GetEnd().y * scale + offY;
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep );
if( seg )
lines.push_back( seg );
} }
sp.x = graphic->GetStart().x * scale + offX;
sp.y = -graphic->GetStart().y * scale + offY;
ep.x = graphic->GetEnd().x * scale + offX;
ep.y = -graphic->GetEnd().y * scale + offY;
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep );
if( seg )
lines.push_back( seg );
break; break;
}
case PCB_SHAPE_TYPE::RECT: case PCB_SHAPE_TYPE::RECT:
{
if( ( graphic->GetStart().x == graphic->GetEnd().x )
&& ( graphic->GetStart().y == graphic->GetEnd().y ) )
{ {
if( ( graphic->GetStart().x == graphic->GetEnd().x ) break;
&& ( graphic->GetStart().y == graphic->GetEnd().y ) )
{
break;
}
double top = graphic->GetStart().y * scale + offY;
double left = graphic->GetStart().x * scale + offX;
double bottom = graphic->GetEnd().y * scale + offY;
double right = graphic->GetEnd().x * scale + offX;
IDF_POINT corners[4];
corners[0] = IDF_POINT( left, top );
corners[1] = IDF_POINT( right, top );
corners[2] = IDF_POINT( right, bottom );
corners[3] = IDF_POINT( left, bottom );
lines.push_back( new IDF_SEGMENT( corners[0], corners[1] ) );
lines.push_back( new IDF_SEGMENT( corners[1], corners[2] ) );
lines.push_back( new IDF_SEGMENT( corners[2], corners[3] ) );
lines.push_back( new IDF_SEGMENT( corners[3], corners[0] ) );
} }
double top = graphic->GetStart().y * scale + offY;
double left = graphic->GetStart().x * scale + offX;
double bottom = graphic->GetEnd().y * scale + offY;
double right = graphic->GetEnd().x * scale + offX;
IDF_POINT corners[4];
corners[0] = IDF_POINT( left, top );
corners[1] = IDF_POINT( right, top );
corners[2] = IDF_POINT( right, bottom );
corners[3] = IDF_POINT( left, bottom );
lines.push_back( new IDF_SEGMENT( corners[0], corners[1] ) );
lines.push_back( new IDF_SEGMENT( corners[1], corners[2] ) );
lines.push_back( new IDF_SEGMENT( corners[2], corners[3] ) );
lines.push_back( new IDF_SEGMENT( corners[3], corners[0] ) );
break; break;
}
case PCB_SHAPE_TYPE::ARC: case PCB_SHAPE_TYPE::ARC:
{
if( ( graphic->GetCenter().x == graphic->GetArcStart().x )
&& ( graphic->GetCenter().y == graphic->GetArcStart().y ) )
{ {
if( ( graphic->GetCenter().x == graphic->GetArcStart().x ) break;
&& ( graphic->GetCenter().y == graphic->GetArcStart().y ) )
{
break;
}
sp.x = graphic->GetCenter().x * scale + offX;
sp.y = -graphic->GetCenter().y * scale + offY;
ep.x = graphic->GetArcStart().x * scale + offX;
ep.y = -graphic->GetArcStart().y * scale + offY;
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep, -graphic->GetAngle() / 10.0, true );
if( seg )
lines.push_back( seg );
} }
sp.x = graphic->GetCenter().x * scale + offX;
sp.y = -graphic->GetCenter().y * scale + offY;
ep.x = graphic->GetArcStart().x * scale + offX;
ep.y = -graphic->GetArcStart().y * scale + offY;
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep, -graphic->GetAngle() / 10.0, true );
if( seg )
lines.push_back( seg );
break; break;
}
case PCB_SHAPE_TYPE::CIRCLE: case PCB_SHAPE_TYPE::CIRCLE:
{ {
if( graphic->GetRadius() == 0 ) if( graphic->GetRadius() == 0 )
break; break;
sp.x = graphic->GetCenter().x * scale + offX; sp.x = graphic->GetCenter().x * scale + offX;
sp.y = -graphic->GetCenter().y * scale + offY; sp.y = -graphic->GetCenter().y * scale + offY;
ep.x = sp.x - graphic->GetRadius() * scale; ep.x = sp.x - graphic->GetRadius() * scale;
ep.y = sp.y; ep.y = sp.y;
// Circles must always have an angle of +360 deg. to appease
// quirky MCAD implementations of IDF. // Circles must always have an angle of +360 deg. to appease
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep, 360.0, true ); // quirky MCAD implementations of IDF.
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep, 360.0, true );
if( seg )
lines.push_back( seg );
if( seg )
lines.push_back( seg );
}
break; break;
}
default: default:
break; break;
@ -191,7 +197,7 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
goto UseBoundingBox; goto UseBoundingBox;
aIDFBoard.AddBoardOutline( outline ); aIDFBoard.AddBoardOutline( outline );
outline = NULL; outline = nullptr;
// get all cutouts and write them out // get all cutouts and write them out
while( !lines.empty() ) while( !lines.empty() )
@ -208,7 +214,7 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
} }
aIDFBoard.AddBoardOutline( outline ); aIDFBoard.AddBoardOutline( outline );
outline = NULL; outline = nullptr;
} }
return; return;
@ -275,11 +281,9 @@ UseBoundingBox:
/** /**
* Function idf_export_footprint * Retrieve information from all board footprints, adds drill holes to the DRILLED_HOLES or
* retrieves information from all board footprints, adds drill holes to * BOARD_OUTLINE section as appropriate, Compiles data for the PLACEMENT section and compiles
* the DRILLED_HOLES or BOARD_OUTLINE section as appropriate, * data for the library ELECTRICAL section.
* compiles data for the PLACEMENT section and compiles data for
* the library ELECTRICAL section.
*/ */
static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard ) static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard )
{ {
@ -407,7 +411,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
// add any valid models to the library item list // add any valid models to the library item list
std::string refdes; std::string refdes;
IDF3_COMPONENT* comp = NULL; IDF3_COMPONENT* comp = nullptr;
auto sM = aFootprint->Models().begin(); auto sM = aFootprint->Models().begin();
auto eM = aFootprint->Models().end(); auto eM = aFootprint->Models().end();
@ -474,14 +478,14 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
while( rotz <= -360.0 ) rotz += 360.0; while( rotz <= -360.0 ) rotz += 360.0;
} }
if( comp == NULL ) if( comp == nullptr )
comp = aIDFBoard.FindComponent( refdes ); comp = aIDFBoard.FindComponent( refdes );
if( comp == NULL ) if( comp == nullptr )
{ {
comp = new IDF3_COMPONENT( &aIDFBoard ); comp = new IDF3_COMPONENT( &aIDFBoard );
if( comp == NULL ) if( comp == nullptr )
throw( std::runtime_error( aIDFBoard.GetError() ) ); throw( std::runtime_error( aIDFBoard.GetError() ) );
comp->SetRefDes( refdes ); comp->SetRefDes( refdes );
@ -570,7 +574,6 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
} }
} }
// create the local data ... // create the local data ...
IDF3_COMP_OUTLINE_DATA* data = new IDF3_COMP_OUTLINE_DATA( comp, outline ); IDF3_COMP_OUTLINE_DATA* data = new IDF3_COMP_OUTLINE_DATA( comp, outline );
@ -582,9 +585,8 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
/** /**
* Function Export_IDF3 * Generate IDFv3 compliant board (*.emn) and library (*.emp) files representing the user's
* generates IDFv3 compliant board (*.emn) and library (*.emp) * PCB design.
* files representing the user's PCB design.
*/ */
bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName,
bool aUseThou, double aXRef, double aYRef ) bool aUseThou, double aXRef, double aYRef )

View File

@ -56,7 +56,7 @@
EXPORTER_PCB_VRML::EXPORTER_PCB_VRML() : EXPORTER_PCB_VRML::EXPORTER_PCB_VRML() :
m_OutputPCB( (SGNODE*) NULL ) m_OutputPCB( nullptr )
{ {
m_ReuseDef = true; m_ReuseDef = true;
m_precision = 6; m_precision = 6;
@ -101,10 +101,10 @@ EXPORTER_PCB_VRML::~EXPORTER_PCB_VRML()
// destroy any unassociated material appearances // destroy any unassociated material appearances
for( int j = 0; j < VRML_COLOR_LAST; ++j ) for( int j = 0; j < VRML_COLOR_LAST; ++j )
{ {
if( m_sgmaterial[j] && NULL == S3D::GetSGNodeParent( m_sgmaterial[j] ) ) if( m_sgmaterial[j] && nullptr == S3D::GetSGNodeParent( m_sgmaterial[j] ) )
S3D::DestroyNode( m_sgmaterial[j] ); S3D::DestroyNode( m_sgmaterial[j] );
m_sgmaterial[j] = NULL; m_sgmaterial[j] = nullptr;
} }
if( !m_components.empty() ) if( !m_components.empty() )
@ -114,7 +114,7 @@ EXPORTER_PCB_VRML::~EXPORTER_PCB_VRML()
for( auto i : m_components ) for( auto i : m_components )
{ {
tmp.Attach( i ); tmp.Attach( i );
tmp.SetParent( NULL ); tmp.SetParent( nullptr );
} }
m_components.clear(); m_components.clear();
@ -176,6 +176,7 @@ bool EXPORTER_PCB_VRML::GetLayer3D( LAYER_NUM layer, VRML_LAYER** vlayer )
void EXPORTER_PCB_VRML::ExportVrmlSolderMask() void EXPORTER_PCB_VRML::ExportVrmlSolderMask()
{ {
SHAPE_POLY_SET holes, outlines = m_pcbOutlines; SHAPE_POLY_SET holes, outlines = m_pcbOutlines;
// holes is the solder mask opening. // holes is the solder mask opening.
// the actual shape is the negative shape of mask opening. // the actual shape is the negative shape of mask opening.
PCB_LAYER_ID pcb_layer = F_Mask; PCB_LAYER_ID pcb_layer = F_Mask;
@ -198,7 +199,6 @@ void EXPORTER_PCB_VRML::ExportVrmlSolderMask()
} }
// Build and export the 4 layers F_Cu, B_Cu, F_silk, B_Silk
void EXPORTER_PCB_VRML::ExportStandardLayers() void EXPORTER_PCB_VRML::ExportStandardLayers()
{ {
SHAPE_POLY_SET outlines; SHAPE_POLY_SET outlines;
@ -227,16 +227,15 @@ void EXPORTER_PCB_VRML::ExportStandardLayers()
} }
} }
// static var. for dealing with text
static EXPORTER_PCB_VRML* model_vrml; static EXPORTER_PCB_VRML* model_vrml;
void EXPORTER_PCB_VRML::write_triangle_bag( std::ostream& aOut_file, const VRML_COLOR& aColor, void EXPORTER_PCB_VRML::write_triangle_bag( std::ostream& aOut_file, const VRML_COLOR& aColor,
VRML_LAYER* aLayer, bool aPlane, bool aTop, VRML_LAYER* aLayer, bool aPlane, bool aTop,
double aTop_z, double aBottom_z ) double aTop_z, double aBottom_z )
{ {
/* A lot of nodes are not required, but blender sometimes chokes // A lot of nodes are not required, but blender sometimes chokes without them.
* without them */
static const char* shape_boiler[] = static const char* shape_boiler[] =
{ {
"Transform {\n", "Transform {\n",
@ -273,7 +272,9 @@ void EXPORTER_PCB_VRML::write_triangle_bag( std::ostream& aOut_file, const VRML_
while( marker_found < 4 ) while( marker_found < 4 )
{ {
if( shape_boiler[lineno] ) if( shape_boiler[lineno] )
{
aOut_file << shape_boiler[lineno]; aOut_file << shape_boiler[lineno];
}
else else
{ {
marker_found++; marker_found++;
@ -335,8 +336,7 @@ void EXPORTER_PCB_VRML::write_triangle_bag( std::ostream& aOut_file, const VRML_
} }
void EXPORTER_PCB_VRML::writeLayers( const char* aFileName, void EXPORTER_PCB_VRML::writeLayers( const char* aFileName, OSTREAM* aOutputFile )
OSTREAM* aOutputFile )
{ {
// VRML_LAYER board; // VRML_LAYER board;
m_3D_board.Tesselate( &m_holes ); m_3D_board.Tesselate( &m_holes );
@ -374,13 +374,15 @@ void EXPORTER_PCB_VRML::writeLayers( const char* aFileName,
{ {
write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_PASTE ), write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_PASTE ),
&m_top_paste, true, true, &m_top_paste, true, true,
GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
0 ); 0 );
} }
else else
{ {
create_vrml_plane( m_OutputPCB, VRML_COLOR_PASTE, &m_top_paste, create_vrml_plane( m_OutputPCB, VRML_COLOR_PASTE, &m_top_paste,
GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
true ); true );
} }
@ -391,13 +393,15 @@ void EXPORTER_PCB_VRML::writeLayers( const char* aFileName,
{ {
write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_SOLDMASK ), write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_SOLDMASK ),
&m_top_soldermask, true, true, &m_top_soldermask, true, true,
GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
0 ); 0 );
} }
else else
{ {
create_vrml_plane( m_OutputPCB, VRML_COLOR_SOLDMASK, &m_top_soldermask, create_vrml_plane( m_OutputPCB, VRML_COLOR_SOLDMASK, &m_top_soldermask,
GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
true ); true );
} }
@ -429,7 +433,8 @@ void EXPORTER_PCB_VRML::writeLayers( const char* aFileName,
else else
{ {
create_vrml_plane( m_OutputPCB, VRML_COLOR_PASTE, &m_bot_paste, create_vrml_plane( m_OutputPCB, VRML_COLOR_PASTE, &m_bot_paste,
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
false ); false );
} }
@ -440,31 +445,37 @@ void EXPORTER_PCB_VRML::writeLayers( const char* aFileName,
{ {
write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_SOLDMASK ), write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_SOLDMASK ),
&m_bot_soldermask, true, false, &m_bot_soldermask, true, false,
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
0 ); 0 );
} }
else else
{ {
create_vrml_plane( m_OutputPCB, VRML_COLOR_SOLDMASK, &m_bot_soldermask, create_vrml_plane( m_OutputPCB, VRML_COLOR_SOLDMASK, &m_bot_soldermask,
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale,
false ); false );
} }
// VRML_LAYER PTH; // VRML_LAYER PTH;
m_plated_holes.Tesselate( NULL, true ); m_plated_holes.Tesselate( nullptr, true );
if( m_UseInlineModelsInBrdfile ) if( m_UseInlineModelsInBrdfile )
{ {
write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_PASTE ), write_triangle_bag( *aOutputFile, GetColor( VRML_COLOR_PASTE ),
&m_plated_holes, false, false, &m_plated_holes, false, false,
GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) *
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale ); m_BoardToVrmlScale,
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale );
} }
else else
{ {
create_vrml_shell( m_OutputPCB, VRML_COLOR_PASTE, &m_plated_holes, create_vrml_shell( m_OutputPCB, VRML_COLOR_PASTE, &m_plated_holes,
GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale, GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) *
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * m_BoardToVrmlScale ); m_BoardToVrmlScale,
GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) *
m_BoardToVrmlScale );
} }
// VRML_LAYER m_top_silk; // VRML_LAYER m_top_silk;
@ -559,7 +570,6 @@ void EXPORTER_PCB_VRML::ExportVrmlPolygonSet( VRML_LAYER* aVlayer, const SHAPE_P
} }
// board edges and cutouts
void EXPORTER_PCB_VRML::ExportVrmlBoard() void EXPORTER_PCB_VRML::ExportVrmlBoard()
{ {
if( !m_Pcb->GetBoardPolygonOutlines( m_pcbOutlines ) ) if( !m_Pcb->GetBoardPolygonOutlines( m_pcbOutlines ) )
@ -578,7 +588,7 @@ void EXPORTER_PCB_VRML::ExportVrmlBoard()
for( int j = 0; j < outline.PointCount(); j++ ) for( int j = 0; j < outline.PointCount(); j++ )
{ {
m_3D_board.AddVertex( seg, (double)outline.CPoint(j).x * m_BoardToVrmlScale, m_3D_board.AddVertex( seg, (double)outline.CPoint(j).x * m_BoardToVrmlScale,
-((double)outline.CPoint(j).y * m_BoardToVrmlScale ) ); -((double)outline.CPoint(j).y * m_BoardToVrmlScale ) );
} }
@ -600,7 +610,7 @@ void EXPORTER_PCB_VRML::ExportVrmlBoard()
for( int j = 0; j < hole.PointCount(); j++ ) for( int j = 0; j < hole.PointCount(); j++ )
{ {
m_holes.AddVertex( seg, (double) hole.CPoint(j).x * m_BoardToVrmlScale, m_holes.AddVertex( seg, (double) hole.CPoint(j).x * m_BoardToVrmlScale,
-( (double) hole.CPoint(j).y * m_BoardToVrmlScale ) ); -( (double) hole.CPoint(j).y * m_BoardToVrmlScale ) );
} }
m_holes.EnsureWinding( seg, true ); m_holes.EnsureWinding( seg, true );
@ -608,9 +618,10 @@ void EXPORTER_PCB_VRML::ExportVrmlBoard()
} }
} }
// Max error allowed to approximate a circle by segments, in mm
static const double err_approx_max = 0.005; static const double err_approx_max = 0.005;
void EXPORTER_PCB_VRML::ExportVrmlViaHoles() void EXPORTER_PCB_VRML::ExportVrmlViaHoles()
{ {
PCB_LAYER_ID top_layer, bottom_layer; PCB_LAYER_ID top_layer, bottom_layer;
@ -784,7 +795,7 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream
{ {
SGNODE* mod3d = (SGNODE*) m_Cache3Dmodels->Load( sM->m_Filename ); SGNODE* mod3d = (SGNODE*) m_Cache3Dmodels->Load( sM->m_Filename );
if( NULL == mod3d ) if( nullptr == mod3d )
{ {
++sM; ++sM;
continue; continue;
@ -830,8 +841,8 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream
if( isFlipped ) if( isFlipped )
offsetz = -offsetz; offsetz = -offsetz;
else // In normal mode, Y axis is reversed in Pcbnew. else
offsety = -offsety; offsety = -offsety; // In normal mode, Y axis is reversed in Pcbnew.
RotatePoint( &offsetx, &offsety, aFootprint->GetOrientation() ); RotatePoint( &offsetx, &offsety, aFootprint->GetOrientation() );
@ -923,7 +934,7 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream
modelShape->SetTranslation( trans ); modelShape->SetTranslation( trans );
modelShape->SetScale( SGPOINT( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z ) ); modelShape->SetScale( SGPOINT( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z ) );
if( NULL == S3D::GetSGNodeParent( mod3d ) ) if( nullptr == S3D::GetSGNodeParent( mod3d ) )
{ {
m_components.push_back( mod3d ); m_components.push_back( mod3d );
modelShape->AddChildNode( mod3d ); modelShape->AddChildNode( mod3d );
@ -1003,10 +1014,10 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt
{ {
// merge footprints in the .vrml board file // merge footprints in the .vrml board file
for( FOOTPRINT* footprint : pcb->Footprints() ) for( FOOTPRINT* footprint : pcb->Footprints() )
model3d.ExportVrmlFootprint( footprint, NULL ); model3d.ExportVrmlFootprint( footprint, nullptr );
// write out the board and all layers // write out the board and all layers
model3d.writeLayers( TO_UTF8( aFullFileName ), NULL ); model3d.writeLayers( TO_UTF8( aFullFileName ), nullptr );
} }
} }
catch( const std::exception& e ) catch( const std::exception& e )
@ -1075,12 +1086,12 @@ SGNODE* EXPORTER_PCB_VRML::getSGColor( VRML_COLOR_INDEX colorIdx )
if( colorIdx == -1 ) if( colorIdx == -1 )
colorIdx = VRML_COLOR_PCB; colorIdx = VRML_COLOR_PCB;
else if( colorIdx == VRML_COLOR_LAST ) else if( colorIdx == VRML_COLOR_LAST )
return NULL; return nullptr;
if( m_sgmaterial[colorIdx] ) if( m_sgmaterial[colorIdx] )
return m_sgmaterial[colorIdx]; return m_sgmaterial[colorIdx];
IFSG_APPEARANCE vcolor( (SGNODE*) NULL ); IFSG_APPEARANCE vcolor( (SGNODE*) nullptr );
VRML_COLOR* cp = &vrml_colors_list[colorIdx]; VRML_COLOR* cp = &vrml_colors_list[colorIdx];
vcolor.SetSpecular( cp->spec_red, cp->spec_grn, cp->spec_blu ); vcolor.SetSpecular( cp->spec_red, cp->spec_grn, cp->spec_blu );
@ -1098,7 +1109,7 @@ SGNODE* EXPORTER_PCB_VRML::getSGColor( VRML_COLOR_INDEX colorIdx )
void EXPORTER_PCB_VRML::create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX colorID, void EXPORTER_PCB_VRML::create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX colorID,
VRML_LAYER* layer, double top_z, bool aTopPlane ) VRML_LAYER* layer, double top_z, bool aTopPlane )
{ {
std::vector< double > vertices; std::vector< double > vertices;
std::vector< int > idxPlane; std::vector< int > idxPlane;
@ -1110,7 +1121,8 @@ void EXPORTER_PCB_VRML::create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR
if( ( idxPlane.size() % 3 ) ) if( ( idxPlane.size() % 3 ) )
{ {
throw( std::runtime_error( "[BUG] index lists are not a multiple of 3 (not a triangle list)" ) ); throw( std::runtime_error( "[BUG] index lists are not a multiple of 3 (not a triangle "
"list)" ) );
} }
std::vector< SGPOINT > vlist; std::vector< SGPOINT > vlist;
@ -1122,7 +1134,7 @@ void EXPORTER_PCB_VRML::create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR
// create the intermediate scenegraph // create the intermediate scenegraph
IFSG_TRANSFORM tx0( PcbOutput.GetRawPtr() ); // tx0 = Transform for this outline IFSG_TRANSFORM tx0( PcbOutput.GetRawPtr() ); // tx0 = Transform for this outline
IFSG_SHAPE shape( tx0 ); // shape will hold (a) all vertices and (b) a local list of normals IFSG_SHAPE shape( tx0 ); // shape will hold (a) all vertices and (b) a local list of normals
IFSG_FACESET face( shape ); // this face shall represent the top and bottom planes IFSG_FACESET face( shape ); // this face shall represent the top and bottom planes
IFSG_COORDS cp( face ); // coordinates for all faces IFSG_COORDS cp( face ); // coordinates for all faces
cp.SetCoordsList( nvert, &vlist[0] ); cp.SetCoordsList( nvert, &vlist[0] );
@ -1145,9 +1157,9 @@ void EXPORTER_PCB_VRML::create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR
// assign a color from the palette // assign a color from the palette
SGNODE* modelColor = getSGColor( colorID ); SGNODE* modelColor = getSGColor( colorID );
if( NULL != modelColor ) if( nullptr != modelColor )
{ {
if( NULL == S3D::GetSGNodeParent( modelColor ) ) if( nullptr == S3D::GetSGNodeParent( modelColor ) )
shape.AddChildNode( modelColor ); shape.AddChildNode( modelColor );
else else
shape.AddRefNode( modelColor ); shape.AddRefNode( modelColor );
@ -1156,7 +1168,7 @@ void EXPORTER_PCB_VRML::create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR
void EXPORTER_PCB_VRML::create_vrml_shell( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX colorID, void EXPORTER_PCB_VRML::create_vrml_shell( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX colorID,
VRML_LAYER* layer, double top_z, double bottom_z ) VRML_LAYER* layer, double top_z, double bottom_z )
{ {
std::vector< double > vertices; std::vector< double > vertices;
std::vector< int > idxPlane; std::vector< int > idxPlane;
@ -1190,7 +1202,7 @@ void EXPORTER_PCB_VRML::create_vrml_shell( IFSG_TRANSFORM& PcbOutput, VRML_COLOR
// create the intermediate scenegraph // create the intermediate scenegraph
IFSG_TRANSFORM tx0( PcbOutput.GetRawPtr() ); // tx0 = Transform for this outline IFSG_TRANSFORM tx0( PcbOutput.GetRawPtr() ); // tx0 = Transform for this outline
IFSG_SHAPE shape( tx0 ); // shape will hold (a) all vertices and (b) a local list of normals IFSG_SHAPE shape( tx0 ); // shape will hold (a) all vertices and (b) a local list of normals
IFSG_FACESET face( shape ); // this face shall represent the top and bottom planes IFSG_FACESET face( shape ); // this face shall represent the top and bottom planes
IFSG_COORDS cp( face ); // coordinates for all faces IFSG_COORDS cp( face ); // coordinates for all faces
cp.SetCoordsList( nvert, &vlist[0] ); cp.SetCoordsList( nvert, &vlist[0] );
@ -1212,9 +1224,9 @@ void EXPORTER_PCB_VRML::create_vrml_shell( IFSG_TRANSFORM& PcbOutput, VRML_COLOR
// assign a color from the palette // assign a color from the palette
SGNODE* modelColor = getSGColor( colorID ); SGNODE* modelColor = getSGColor( colorID );
if( NULL != modelColor ) if( nullptr != modelColor )
{ {
if( NULL == S3D::GetSGNodeParent( modelColor ) ) if( nullptr == S3D::GetSGNodeParent( modelColor ) )
shape.AddChildNode( modelColor ); shape.AddChildNode( modelColor );
else else
shape.AddRefNode( modelColor ); shape.AddRefNode( modelColor );

View File

@ -7,7 +7,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) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -44,6 +44,7 @@
#include <gendrill_file_writer_base.h> #include <gendrill_file_writer_base.h>
#include <pcb_painter.h> #include <pcb_painter.h>
/* Conversion utilities - these will be used often in there... */ /* Conversion utilities - these will be used often in there... */
inline double diameter_in_inches( double ius ) inline double diameter_in_inches( double ius )
{ {
@ -72,7 +73,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
double scale = 1.0; double scale = 1.0;
wxPoint offset = GetOffset(); wxPoint offset = GetOffset();
PLOTTER* plotter = NULL; PLOTTER* plotter = nullptr;
PAGE_INFO dummy( PAGE_INFO::A4, false ); PAGE_INFO dummy( PAGE_INFO::A4, false );
int bottom_limit = 0; // Y coord limit of page. 0 mean do not use int bottom_limit = 0; // Y coord limit of page. 0 mean do not use
@ -157,8 +158,8 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
plotter->SetPageSettings( pageA4 ); plotter->SetPageSettings( pageA4 );
plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
break;
} }
break;
case PLOT_FORMAT::DXF: case PLOT_FORMAT::DXF:
{ {
@ -172,8 +173,8 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
plotter = dxf_plotter; plotter = dxf_plotter;
plotter->SetPageSettings( page_info ); plotter->SetPageSettings( page_info );
plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false );
break;
} }
break;
} }
plotter->SetCreator( wxT( "PCBNEW" ) ); plotter->SetCreator( wxT( "PCBNEW" ) );
@ -233,6 +234,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
// Print a list of symbols used. // Print a list of symbols used.
int charSize = Millimeter2iu( 2 ); // text size in IUs int charSize = Millimeter2iu( 2 ); // text size in IUs
// real char scale will be 1/scale, because the global plot scale is scale // real char scale will be 1/scale, because the global plot scale is scale
// for scale < 1.0 ( plot bigger actual size) // for scale < 1.0 ( plot bigger actual size)
// Therefore charScale = 1.0 / scale keep the initial charSize // Therefore charScale = 1.0 / scale keep the initial charSize
@ -276,6 +278,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
} }
int plot_diam = KiROUND( tool.m_Diameter ); int plot_diam = KiROUND( tool.m_Diameter );
// For markers plotted with the comment, keep marker size <= text height // For markers plotted with the comment, keep marker size <= text height
plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) ); plot_diam = std::min( plot_diam, KiROUND( charSize * charScale ) );
int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 ); int x = KiROUND( plotX - textmarginaftersymbol * charScale - plot_diam / 2.0 );
@ -302,7 +305,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
sprintf( line, "(%d holes + 1 slot)", tool.m_TotalCount - 1 ); sprintf( line, "(%d holes + 1 slot)", tool.m_TotalCount - 1 );
else // if ( toolm_OvalCount > 1 ) else // if ( toolm_OvalCount > 1 )
sprintf( line, "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount, sprintf( line, "(%d holes + %d slots)", tool.m_TotalCount - tool.m_OvalCount,
tool.m_OvalCount ); tool.m_OvalCount );
msg += FROM_UTF8( line ); msg += FROM_UTF8( line );
@ -452,7 +455,7 @@ bool GENDRILL_WRITER_BASE::plotDrillMarks( PLOTTER* aPlotter )
if( hole.m_Hole_Shape != 0 ) if( hole.m_Hole_Shape != 0 )
{ {
wxSize oblong_size = hole.m_Hole_Size; wxSize oblong_size = hole.m_Hole_Size;
aPlotter->FlashPadOval( pos, oblong_size, hole.m_Hole_Orient, SKETCH, NULL ); aPlotter->FlashPadOval( pos, oblong_size, hole.m_Hole_Orient, SKETCH, nullptr );
} }
} }

View File

@ -1,7 +1,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) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.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
@ -22,7 +22,7 @@
*/ */
/* /*
* 1 - create ascii files for automatic placement of smd components * 1 - create ASCII files for automatic placement of smd components
* 2 - create a footprint report (pos and footprint descr) (ascii file) * 2 - create a footprint report (pos and footprint descr) (ascii file)
*/ */
@ -75,15 +75,6 @@ public:
} }
private: private:
PCB_EDIT_FRAME* m_parent;
PCB_PLOT_PARAMS m_plotOpts;
REPORTER* m_reporter;
static int m_unitsOpt;
static int m_fileOpt;
static int m_fileFormat;
static bool m_includeBoardEdge;
void initDialog(); void initDialog();
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) override; void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) override;
void OnGenerate( wxCommandEvent& event ) override; void OnGenerate( wxCommandEvent& event ) override;
@ -116,11 +107,13 @@ private:
m_cbIncludeBoardEdge->Enable( m_rbFormat->GetSelection() == 2 ); m_cbIncludeBoardEdge->Enable( m_rbFormat->GetSelection() == 2 );
} }
/** Creates files in text or csv format /**
* Creates files in text or csv format
*/ */
bool CreateAsciiFiles(); bool CreateAsciiFiles();
/** Creates placement files in gerber format /**
* Creates placement files in gerber format
*/ */
bool CreateGerberFiles(); bool CreateGerberFiles();
@ -139,6 +132,15 @@ private:
{ {
return m_excludeTH->GetValue(); return m_excludeTH->GetValue();
} }
PCB_EDIT_FRAME* m_parent;
PCB_PLOT_PARAMS m_plotOpts;
REPORTER* m_reporter;
static int m_unitsOpt;
static int m_fileOpt;
static int m_fileFormat;
static bool m_includeBoardEdge;
}; };
@ -148,7 +150,6 @@ int DIALOG_GEN_FOOTPRINT_POSITION::m_fileFormat = 0;
bool DIALOG_GEN_FOOTPRINT_POSITION::m_includeBoardEdge = false; bool DIALOG_GEN_FOOTPRINT_POSITION::m_includeBoardEdge = false;
void DIALOG_GEN_FOOTPRINT_POSITION::initDialog() void DIALOG_GEN_FOOTPRINT_POSITION::initDialog()
{ {
m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) ); m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
@ -197,13 +198,15 @@ void DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEve
wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath(); wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath();
if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) )
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), wxMessageBox( _( "Cannot make path relative (target volume different from board "
"file volume)!" ),
_( "Plot Output Directory" ), wxOK | wxICON_ERROR ); _( "Plot Output Directory" ), wxOK | wxICON_ERROR );
} }
m_outputDirectoryName->SetValue( dirName.GetFullPath() ); m_outputDirectoryName->SetValue( dirName.GetFullPath() );
} }
void DIALOG_GEN_FOOTPRINT_POSITION::OnGenerate( wxCommandEvent& event ) void DIALOG_GEN_FOOTPRINT_POSITION::OnGenerate( wxCommandEvent& event )
{ {
m_fileOpt = m_radioBoxFilesCount->GetSelection(); m_fileOpt = m_radioBoxFilesCount->GetSelection();
@ -234,6 +237,7 @@ void DIALOG_GEN_FOOTPRINT_POSITION::OnGenerate( wxCommandEvent& event )
CreateAsciiFiles(); CreateAsciiFiles();
} }
bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles() bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles()
{ {
BOARD* brd = m_parent->GetBoard(); BOARD* brd = m_parent->GetBoard();
@ -364,10 +368,12 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
if( singleFile ) if( singleFile )
{ {
bottomSide = true; bottomSide = true;
fn.SetName( fn.GetName() + wxT( "-" ) + wxT("all") ); fn.SetName( fn.GetName() + wxT( "-" ) + wxT( "all" ) );
} }
else else
{
fn.SetName( fn.GetName() + wxT( "-" ) + PLACE_FILE_EXPORTER::GetFrontSideName().c_str() ); fn.SetName( fn.GetName() + wxT( "-" ) + PLACE_FILE_EXPORTER::GetFrontSideName().c_str() );
}
if( useCSVfmt ) if( useCSVfmt )
@ -376,7 +382,9 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
fn.SetExt( wxT( "csv" ) ); fn.SetExt( wxT( "csv" ) );
} }
else else
{
fn.SetExt( FootprintPlaceFileExtension ); fn.SetExt( FootprintPlaceFileExtension );
}
int fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), int fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(),
ExcludeAllTH(), topSide, bottomSide, ExcludeAllTH(), topSide, bottomSide,
@ -419,7 +427,9 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
fn.SetExt( wxT( "csv" ) ); fn.SetExt( wxT( "csv" ) );
} }
else else
{
fn.SetExt( FootprintPlaceFileExtension ); fn.SetExt( FootprintPlaceFileExtension );
}
fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), ExcludeAllTH(), fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), ExcludeAllTH(),
topSide, bottomSide, useCSVfmt, useAuxOrigin ); topSide, bottomSide, useCSVfmt, useAuxOrigin );
@ -470,13 +480,13 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
bool aBottomSide, bool aFormatCSV, bool aBottomSide, bool aFormatCSV,
bool aUseAuxOrigin ) bool aUseAuxOrigin )
{ {
FILE * file = NULL; FILE * file = nullptr;
if( !aFullFileName.IsEmpty() ) if( !aFullFileName.IsEmpty() )
{ {
file = wxFopen( aFullFileName, wxT( "wt" ) ); file = wxFopen( aFullFileName, wxT( "wt" ) );
if( file == NULL ) if( file == nullptr )
return -1; return -1;
} }
@ -519,6 +529,7 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM ); bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM );
wxString msg; wxString msg;
if( success ) if( success )
{ {
msg.Printf( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() ); msg.Printf( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() );
@ -532,13 +543,12 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
} }
} }
/* Print a footprint report.
*/
bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM ) bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM )
{ {
FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) ); FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
if( rptfile == NULL ) if( rptfile == nullptr )
return false; return false;
std::string data; std::string data;

View File

@ -51,16 +51,18 @@
#include <reporter.h> #include <reporter.h>
#include <gbr_metadata.h> #include <gbr_metadata.h>
// Oblong holes can be drilled by a "canned slot" command (G85) or a routing command // Oblong holes can be drilled by a "canned slot" command (G85) or a routing command
// a linear routing command (G01) is perhaps more usual for drill files // a linear routing command (G01) is perhaps more usual for drill files
// //
// set m_useRouteModeForOval to false to use a canned slot hole (old way) // set m_useRouteModeForOval to false to use a canned slot hole (old way)
// set m_useRouteModeForOval to true (preferred mode) to use a linear routed hole (new way) // set m_useRouteModeForOval to true (preferred mode) to use a linear routed hole (new way)
EXCELLON_WRITER::EXCELLON_WRITER( BOARD* aPcb ) EXCELLON_WRITER::EXCELLON_WRITER( BOARD* aPcb )
: GENDRILL_WRITER_BASE( aPcb ) : GENDRILL_WRITER_BASE( aPcb )
{ {
m_file = NULL; m_file = nullptr;
m_zeroFormat = DECIMAL_FORMAT; m_zeroFormat = DECIMAL_FORMAT;
m_conversionUnits = 0.0001; m_conversionUnits = 0.0001;
m_mirror = false; m_mirror = false;
@ -108,13 +110,14 @@ void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
FILE* file = wxFopen( fullFilename, wxT( "w" ) ); FILE* file = wxFopen( fullFilename, wxT( "w" ) );
if( file == NULL ) if( file == nullptr )
{ {
if( aReporter ) if( aReporter )
{ {
msg.Printf( _( "Failed to create file '%s'." ), fullFilename ); msg.Printf( _( "Failed to create file '%s'." ), fullFilename );
aReporter->Report( msg, RPT_SEVERITY_ERROR ); aReporter->Report( msg, RPT_SEVERITY_ERROR );
} }
break; break;
} }
else else
@ -205,6 +208,7 @@ int EXCELLON_WRITER::createDrillFile( FILE* aFile, DRILL_LAYER_PAIR aLayerPair,
#if USE_ATTRIB_FOR_HOLES #if USE_ATTRIB_FOR_HOLES
writeHoleAttribute( tool_descr.m_HoleAttribute ); writeHoleAttribute( tool_descr.m_HoleAttribute );
#endif #endif
// if units are mm, the resolution is 0.001 mm (3 digits in mantissa) // if units are mm, the resolution is 0.001 mm (3 digits in mantissa)
// if units are inches, the resolution is 0.1 mil (4 digits in mantissa) // if units are inches, the resolution is 0.1 mil (4 digits in mantissa)
if( m_unitsMetric ) if( m_unitsMetric )
@ -344,10 +348,8 @@ int EXCELLON_WRITER::createDrillFile( FILE* aFile, DRILL_LAYER_PAIR aLayerPair,
} }
void EXCELLON_WRITER::SetFormat( bool aMetric, void EXCELLON_WRITER::SetFormat( bool aMetric, ZEROS_FMT aZerosFmt, int aLeftDigits,
ZEROS_FMT aZerosFmt, int aRightDigits )
int aLeftDigits,
int aRightDigits )
{ {
m_unitsMetric = aMetric; m_unitsMetric = aMetric;
m_zeroFormat = aZerosFmt; m_zeroFormat = aZerosFmt;
@ -477,8 +479,7 @@ void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoo
} }
void EXCELLON_WRITER::writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, void EXCELLON_WRITER::writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType )
TYPE_FILE aHolesType )
{ {
fputs( "M48\n", m_file ); // The beginning of a header fputs( "M48\n", m_file ); // The beginning of a header
@ -567,7 +568,7 @@ void EXCELLON_WRITER::writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair,
void EXCELLON_WRITER::writeEXCELLONEndOfFile() void EXCELLON_WRITER::writeEXCELLONEndOfFile()
{ {
//add if minimal here // add if minimal here
fputs( "T0\nM30\n", m_file ); fputs( "T0\nM30\n", m_file );
fclose( m_file ); fclose( m_file );
} }

View File

@ -84,8 +84,9 @@ void GERBER_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory, b
// The file is created if it has holes, or if it is the non plated drill file // The file is created if it has holes, or if it is the non plated drill file
// to be sure the NPTH file is up to date in separate files mode. // to be sure the NPTH file is up to date in separate files mode.
// Also a PTH drill/map file is always created, to be sure at least one plated hole drill file // Also a PTH drill/map file is always created, to be sure at least one plated hole drill
// is created (do not create any PTH drill file can be seen as not working drill generator). // file is created (do not create any PTH drill file can be seen as not working drill
// generator).
if( getHolesCount() > 0 || doing_npth || pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) ) if( getHolesCount() > 0 || doing_npth || pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
{ {
fn = getDrillFileName( pair, doing_npth, false ); fn = getDrillFileName( pair, doing_npth, false );
@ -104,6 +105,7 @@ void GERBER_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory, b
msg.Printf( _( "Failed to create file '%s'." ), fullFilename ); msg.Printf( _( "Failed to create file '%s'." ), fullFilename );
aReporter->Report( msg, RPT_SEVERITY_ERROR ); aReporter->Report( msg, RPT_SEVERITY_ERROR );
} }
break; break;
} }
else else
@ -123,11 +125,13 @@ void GERBER_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory, b
CreateMapFilesSet( aPlotDirectory, aReporter ); CreateMapFilesSet( aPlotDirectory, aReporter );
} }
#if !FLASH_OVAL_HOLE #if !FLASH_OVAL_HOLE
// A helper class to transform an oblong hole to a segment // A helper class to transform an oblong hole to a segment
static void convertOblong2Segment( wxSize aSize, double aOrient, wxPoint& aStart, wxPoint& aEnd ); static void convertOblong2Segment( wxSize aSize, double aOrient, wxPoint& aStart, wxPoint& aEnd );
#endif #endif
int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth, int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
DRILL_LAYER_PAIR aLayerPair ) DRILL_LAYER_PAIR aLayerPair )
{ {
@ -145,6 +149,7 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
// Add the standard X2 header, without FileFunction // Add the standard X2 header, without FileFunction
AddGerberX2Header( &plotter, m_pcb ); AddGerberX2Header( &plotter, m_pcb );
plotter.SetViewport( m_offset, IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false ); plotter.SetViewport( m_offset, IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false );
// has meaning only for gerber plotter. Must be called only after SetViewport // has meaning only for gerber plotter. Must be called only after SetViewport
plotter.SetGerberCoordinatesFormat( 6 ); plotter.SetGerberCoordinatesFormat( 6 );
plotter.SetCreator( wxT( "PCBNEW" ) ); plotter.SetCreator( wxT( "PCBNEW" ) );
@ -189,7 +194,7 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
if( !last_item_is_via ) if( !last_item_is_via )
{ {
// be sure the current object attribute is cleared for vias // be sure the current object attribute is cleared for vias
plotter.EndBlock( NULL ); plotter.EndBlock( nullptr );
} }
last_item_is_via = true; last_item_is_via = true;
@ -200,11 +205,13 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
const PAD* pad = dyn_cast<const PAD*>( hole_descr.m_ItemParent ); const PAD* pad = dyn_cast<const PAD*>( hole_descr.m_ItemParent );
if( pad->GetProperty() == PAD_PROP::CASTELLATED ) if( pad->GetProperty() == PAD_PROP::CASTELLATED )
{
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDDRILL ); gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDDRILL );
}
else else
{ {
// Good practice of oblong pad holes (slots) is to use a specific aperture for routing, not used // Good practice of oblong pad holes (slots) is to use a specific aperture for
// in drill commands // routing, not used in drill commands.
if( hole_descr.m_Hole_Shape ) if( hole_descr.m_Hole_Shape )
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL ); gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL );
else else
@ -220,23 +227,21 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
if( hole_descr.m_Hole_Shape ) if( hole_descr.m_Hole_Shape )
{ {
#if FLASH_OVAL_HOLE // set to 1 to use flashed oblong holes, #if FLASH_OVAL_HOLE // set to 1 to use flashed oblong holes,
// 0 to draw them as a line. // 0 to draw them as a line.
plotter.FlashPadOval( hole_pos, hole_descr.m_Hole_Size, plotter.FlashPadOval( hole_pos, hole_descr.m_Hole_Size,
hole_descr.m_Hole_Orient, FILLED, &gbr_metadata ); hole_descr.m_Hole_Orient, FILLED, &gbr_metadata );
#else #else
// Use routing for oblong hole (Slots) // Use routing for oblong hole (Slots)
wxPoint start, end; wxPoint start, end;
convertOblong2Segment( hole_descr.m_Hole_Size, convertOblong2Segment( hole_descr.m_Hole_Size, hole_descr.m_Hole_Orient, start, end );
hole_descr.m_Hole_Orient, start, end );
int width = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y ); int width = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
if ( width == 0 ) if ( width == 0 )
continue; continue;
plotter.ThickSegment( start+hole_pos, end+hole_pos, plotter.ThickSegment( start+hole_pos, end+hole_pos, width, FILLED, &gbr_metadata );
width, FILLED, &gbr_metadata ); #endif
#endif
} }
else else
{ {
@ -280,6 +285,7 @@ void convertOblong2Segment( wxSize aSize, double aOrient, wxPoint& aStart, wxPoi
} }
#endif #endif
void GERBER_WRITER::SetFormat( int aRightDigits ) void GERBER_WRITER::SetFormat( int aRightDigits )
{ {
/* Set conversion scale depending on drill file units */ /* Set conversion scale depending on drill file units */

View File

@ -7,7 +7,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) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -47,17 +47,18 @@ public:
} }
/** /**
* Function SetFormat * Initialize internal parameters to match the given format.
* Initialize internal parameters to match the given format *
* @param aRightDigits = number of digits for mantissa part of coordinates (5 or 6) * @param aRightDigits is the number of digits for mantissa part of coordinates (5 or 6).
*/ */
void SetFormat( int aRightDigits = 6 ); void SetFormat( int aRightDigits = 6 );
/** /**
* Function SetOptions * Initialize internal parameters to match drill options.
* Initialize internal parameters to match drill options *
* note: PTH and NPTH are always separate files in Gerber format * @note PTH and NPTH are always separate files in Gerber format.
* @param aOffset = drill coordinates offset *
* @param aOffset is the drill coordinates offset.
*/ */
void SetOptions( wxPoint aOffset ) void SetOptions( wxPoint aOffset )
{ {
@ -66,38 +67,38 @@ public:
} }
/** /**
* Function CreateDrillandMapFilesSet * Create the full set of Excellon drill file for the board filenames are computed from
* Creates the full set of Excellon drill file for the board * the board name, and layers id.
* filenames are computed from the board name, and layers id *
* @param aPlotDirectory = the output folder * @param aPlotDirectory is the output folder.
* @param aGenDrill = true to generate the EXCELLON drill file * @param aGenDrill set to true to generate the EXCELLON drill file.
* @param aGenMap = true to generate a drill map file * @param aGenMap set to true to generate a drill map file.
* @param aReporter = a REPORTER to return activity or any message (can be NULL) * @param aReporter is a #REPORTER to return activity or any message (can be NULL).
*/ */
void CreateDrillandMapFilesSet( const wxString& aPlotDirectory, void CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
bool aGenDrill, bool aGenMap, bool aGenDrill, bool aGenMap,
REPORTER * aReporter = NULL ); REPORTER * aReporter = nullptr );
private: private:
/** /**
* Function createDrillFile * Create an Excellon drill file.
* Creates an Excellon drill file *
* @param aFullFilename = the full filename * @param aFullFilename is the full file name.
* @param aIsNpth = true for a NPTH file, false for a PTH file * @param aIsNpth set to true for a NPTH file or false for a PTH file.
* @param aLayerPair = first board layer and the last board layer for this drill file * @param aLayerPair is the first board layer and the last board layer for this drill file
* for blind buried vias, they are not always top and bottom layers * for blind buried vias, they are not always top and bottom layers/
* @return hole count, or -1 if the file cannot be created * @return hole count or -1 if the file cannot be created.
*/ */
int createDrillFile( wxString& aFullFilename, bool aIsNpth, DRILL_LAYER_PAIR aLayerPair ); int createDrillFile( wxString& aFullFilename, bool aIsNpth, DRILL_LAYER_PAIR aLayerPair );
/** /**
* @return a filename which identify the drill file function. * @param aPair is the layer pair.
* it is the board name with the layer pair names added, and for separate * @param aNPTH set to true to generate the filename of NPTH holes.
* (PTH and NPTH) files, "-NPH" or "-NPTH" added * @param aMerge_PTH_NPTH set to true to generate the filename of a file which contains both
* @param aPair = the layer pair * NPH and NPTH holes
* @param aNPTH = true to generate the filename of NPTH holes * @return a filename which identify the drill file function. It is the board name with the
* @param aMerge_PTH_NPTH = true to generate the filename of a file which containd both * layer pair names added, and for separate (PTH and NPTH) files, "-NPH" or "-NPTH"
* NPH and NPTH holes * added.
*/ */
virtual const wxString getDrillFileName( DRILL_LAYER_PAIR aPair, bool aNPTH, virtual const wxString getDrillFileName( DRILL_LAYER_PAIR aPair, bool aNPTH,
bool aMerge_PTH_NPTH ) const override; bool aMerge_PTH_NPTH ) const override;

View File

@ -197,7 +197,9 @@ bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileNa
return true; return true;
} }
else else
{
return false; return false;
}
} }
@ -694,7 +696,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
unsigned startTime = GetRunningMicroSecs(); unsigned startTime = GetRunningMicroSecs();
#endif #endif
loadedBoard = pi->Load( fullFileName, NULL, &props, &Prj(), &progressReporter ); loadedBoard = pi->Load( fullFileName, nullptr, &props, &Prj(), &progressReporter );
#if USE_INSTRUMENTATION #if USE_INSTRUMENTATION
unsigned stopTime = GetRunningMicroSecs(); unsigned stopTime = GetRunningMicroSecs();
@ -1007,7 +1009,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
wxASSERT( tempFile.IsAbsolute() ); wxASSERT( tempFile.IsAbsolute() );
pi->Save( tempFile.GetFullPath(), GetBoard(), NULL ); pi->Save( tempFile.GetFullPath(), GetBoard(), nullptr );
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {
@ -1108,7 +1110,7 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject
wxASSERT( pcbFileName.IsAbsolute() ); wxASSERT( pcbFileName.IsAbsolute() );
pi->Save( pcbFileName.GetFullPath(), GetBoard(), NULL ); pi->Save( pcbFileName.GetFullPath(), GetBoard(), nullptr );
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {

View File

@ -323,7 +323,7 @@ public:
*/ */
void SetLastEditTime( timestamp_t aTime ) { m_lastEditTime = aTime; } void SetLastEditTime( timestamp_t aTime ) { m_lastEditTime = aTime; }
void SetLastEditTime() { m_lastEditTime = time( NULL ); } void SetLastEditTime() { m_lastEditTime = time( nullptr ); }
timestamp_t GetLastEditTime() const { return m_lastEditTime; } timestamp_t GetLastEditTime() const { return m_lastEditTime; }
/** /**

View File

@ -612,7 +612,8 @@ bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
if( IsContentModified() ) if( IsContentModified() )
{ {
// Shutdown blocks must be determined and vetoed as early as possible // Shutdown blocks must be determined and vetoed as early as possible
if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION ) if( KIPLATFORM::APP::SupportsShutdownBlockReason() &&
aEvent.GetId() == wxEVT_QUERY_END_SESSION )
{ {
aEvent.Veto(); aEvent.Veto();
return false; return false;
@ -639,7 +640,7 @@ bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::doCloseWindow() void FOOTPRINT_EDIT_FRAME::doCloseWindow()
{ {
// No more vetos // No more vetos
GetCanvas()->SetEventDispatcher( NULL ); GetCanvas()->SetEventDispatcher( nullptr );
GetCanvas()->StopDrawing(); GetCanvas()->StopDrawing();
// Do not show the layer manager during closing to avoid flicker // Do not show the layer manager during closing to avoid flicker
@ -677,7 +678,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEve
{ {
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false ); PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != NULL ); aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
} }
@ -827,7 +828,7 @@ void FOOTPRINT_EDIT_FRAME::initLibraryTree()
if( GFootprintList.GetCount() == 0 ) if( GFootprintList.GetCount() == 0 )
GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" ); GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter ); GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
progressReporter.Show( false ); progressReporter.Show( false );
if( GFootprintList.GetErrorCount() ) if( GFootprintList.GetErrorCount() )
@ -851,12 +852,12 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
if( aProgress ) if( aProgress )
{ {
WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 ); WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter ); GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
progressReporter.Show( false ); progressReporter.Show( false );
} }
else else
{ {
GFootprintList.ReadFootprintFiles( fpTable, NULL, NULL ); GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
} }
// Sync the LIB_TREE to the FOOTPRINT_INFO list // Sync the LIB_TREE to the FOOTPRINT_INFO list

View File

@ -43,7 +43,7 @@ using namespace std::placeholders;
void FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( wxCommandEvent& event )
{ {
LoadFootprintFromBoard( NULL ); LoadFootprintFromBoard( nullptr );
} }
@ -209,8 +209,9 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
commit.Push( _( "Edit Zone" ) ); commit.Push( _( "Edit Zone" ) );
zoneSettings.ExportSetting( *static_cast<ZONE*>( aItem ) ); zoneSettings.ExportSetting( *static_cast<ZONE*>( aItem ) );
} }
break;
} }
break;
case PCB_GROUP_T: case PCB_GROUP_T:
m_toolManager->RunAction( PCB_ACTIONS::groupProperties, true, aItem ); m_toolManager->RunAction( PCB_ACTIONS::groupProperties, true, aItem );
@ -282,7 +283,8 @@ void FOOTPRINT_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
msg.Printf( _( "The current configuration does not include a library named '%s'.\n" msg.Printf( _( "The current configuration does not include a library named '%s'.\n"
"Use Manage Footprint Libraries to edit the configuration." ), "Use Manage Footprint Libraries to edit the configuration." ),
fpFileName.GetPath() ); fpFileName.GetPath() );
DisplayErrorMessage( this, _( "Library not found in footprint library table." ), msg ); DisplayErrorMessage( this, _( "Library not found in footprint library table." ),
msg );
break; break;
} }

View File

@ -47,7 +47,7 @@ void FOOTPRINT_INFO_IMPL::load()
const FOOTPRINT* footprint = fptable->GetEnumeratedFootprint( m_nickname, m_fpname ); const FOOTPRINT* footprint = fptable->GetEnumeratedFootprint( m_nickname, m_fpname );
if( footprint == NULL ) // Should happen only with malformed/broken libraries if( footprint == nullptr ) // Should happen only with malformed/broken libraries
{ {
m_pad_count = 0; m_pad_count = 0;
m_unique_pad_count = 0; m_unique_pad_count = 0;
@ -87,6 +87,7 @@ bool FOOTPRINT_LIST_IMPL::CatchErrors( const std::function<void()>& aFunc )
{ {
m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) ); m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
} }
return false; return false;
} }
@ -137,7 +138,6 @@ bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxStri
loader.SetList( this ); loader.SetList( this );
loader.Start( aTable, aNickname ); loader.Start( aTable, aNickname );
while( !m_cancelled && (int)m_count_finished.load() < m_loader->m_total_libs ) while( !m_cancelled && (int)m_count_finished.load() < m_loader->m_total_libs )
{ {
if( m_progress_reporter && !m_progress_reporter->KeepRefreshing() ) if( m_progress_reporter && !m_progress_reporter->KeepRefreshing() )
@ -166,7 +166,7 @@ bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxStri
} }
if( m_cancelled ) if( m_cancelled )
m_list_timestamp = 0; // God knows what we got before we were cancelled m_list_timestamp = 0; // God knows what we got before we were canceled
else else
m_list_timestamp = generatedTimestamp; m_list_timestamp = generatedTimestamp;
@ -189,7 +189,9 @@ void FOOTPRINT_LIST_IMPL::startWorkers( FP_LIB_TABLE* aTable, wxString const* aN
m_queue_out.clear(); m_queue_out.clear();
if( aNickname ) if( aNickname )
{
m_queue_in.push( *aNickname ); m_queue_in.push( *aNickname );
}
else else
{ {
for( auto const& nickname : aTable->GetLogicalLibs() ) for( auto const& nickname : aTable->GetLogicalLibs() )
@ -204,6 +206,7 @@ void FOOTPRINT_LIST_IMPL::startWorkers( FP_LIB_TABLE* aTable, wxString const* aN
} }
} }
void FOOTPRINT_LIST_IMPL::stopWorkers() void FOOTPRINT_LIST_IMPL::stopWorkers()
{ {
std::lock_guard<std::mutex> lock1( m_join ); std::lock_guard<std::mutex> lock1( m_join );
@ -219,11 +222,12 @@ void FOOTPRINT_LIST_IMPL::stopWorkers()
m_queue_in.clear(); m_queue_in.clear();
m_count_finished.store( 0 ); m_count_finished.store( 0 );
// If we have cancelled in the middle of a load, clear our timestamp to re-load next time // If we have canceled in the middle of a load, clear our timestamp to re-load next time
if( m_cancelled ) if( m_cancelled )
m_list_timestamp = 0; m_list_timestamp = 0;
} }
bool FOOTPRINT_LIST_IMPL::joinWorkers() bool FOOTPRINT_LIST_IMPL::joinWorkers()
{ {
{ {
@ -242,7 +246,7 @@ bool FOOTPRINT_LIST_IMPL::joinWorkers()
LOCALE_IO toggle_locale; LOCALE_IO toggle_locale;
// Parse the footprints in parallel. WARNING! This requires changing the locale, which is // Parse the footprints in parallel. WARNING! This requires changing the locale, which is
// GLOBAL. It is only threadsafe to construct the LOCALE_IO before the threads are created, // GLOBAL. It is only thread safe to construct the LOCALE_IO before the threads are created,
// destroy it after they finish, and block the main (GUI) thread while they work. Any deviation // destroy it after they finish, and block the main (GUI) thread while they work. Any deviation
// from this will cause nasal demons. // from this will cause nasal demons.
// //
@ -313,11 +317,12 @@ bool FOOTPRINT_LIST_IMPL::joinWorkers()
while( queue_parsed.pop( fpi ) ) while( queue_parsed.pop( fpi ) )
m_list.push_back( std::move( fpi ) ); m_list.push_back( std::move( fpi ) );
std::sort( m_list.begin(), m_list.end(), []( std::unique_ptr<FOOTPRINT_INFO> const& lhs, std::sort( m_list.begin(), m_list.end(),
std::unique_ptr<FOOTPRINT_INFO> const& rhs ) -> bool []( std::unique_ptr<FOOTPRINT_INFO> const& lhs,
{ std::unique_ptr<FOOTPRINT_INFO> const& rhs ) -> bool
return *lhs < *rhs; {
} ); return *lhs < *rhs;
} );
return m_errors.empty(); return m_errors.empty();
} }

View File

@ -2,8 +2,8 @@
* 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) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.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
@ -144,7 +144,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
libSizer->Add( m_libFilter, 0, wxEXPAND, 5 ); libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize, m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
0, NULL, wxLB_HSCROLL | wxNO_BORDER ); 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
libSizer->Add( m_libList, 1, wxEXPAND, 5 ); libSizer->Add( m_libList, 1, wxEXPAND, 5 );
libPanel->SetSizer( libSizer ); libPanel->SetSizer( libSizer );
@ -163,7 +163,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 ); fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize, m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
0, NULL, wxLB_HSCROLL | wxNO_BORDER ); 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
fpSizer->Add( m_fpList, 1, wxEXPAND, 5 ); fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
fpPanel->SetSizer( fpSizer ); fpPanel->SetSizer( fpSizer );
@ -312,14 +312,18 @@ void FOOTPRINT_VIEWER_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) ); mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) ); mgr->SetConditions( ACTIONS::millimetersUnits,
CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) ); mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) ); mgr->SetConditions( ACTIONS::zoomTool,
mgr->SetConditions( ACTIONS::measureTool, CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) ); CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) ); mgr->SetConditions( ACTIONS::measureTool,
CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
mgr->SetConditions( ACTIONS::selectionTool,
CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) ); mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) ); mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
@ -358,7 +362,9 @@ void FOOTPRINT_VIEWER_FRAME::doCloseWindow()
// window to be destroyed by the caller of KIWAY_PLAYER::ShowModal() // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
} }
else else
{
Destroy(); Destroy();
}
} }
@ -441,7 +447,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
wxString nickname = getCurNickname(); wxString nickname = getCurNickname();
fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname ); fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? nullptr : &nickname );
if( fp_info_list->GetErrorCount() ) if( fp_info_list->GetErrorCount() )
{ {
@ -498,7 +504,9 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
ClickOnFootprintList( dummy ); ClickOnFootprintList( dummy );
} }
else else
{
setCurFootprintName( wxEmptyString ); setCurFootprintName( wxEmptyString );
}
} }
else else
{ {
@ -564,7 +572,9 @@ void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
AddFootprintToPCB( dummy ); AddFootprintToPCB( dummy );
} }
else else
{
aEvent.Skip(); aEvent.Skip();
}
} }
@ -656,11 +666,10 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {
wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'." wxString msg =
"\n\n%s" ), wxString::Format( _( "Could not load footprint '%s' from library '%s'."
getCurFootprintName(), "\n\n%s" ),
getCurNickname(), getCurFootprintName(), getCurNickname(), ioe.Problem() );
ioe.Problem() );
DisplayError( this, msg ); DisplayError( this, msg );
} }
@ -698,7 +707,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
{ {
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false ); PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
if( pcbframe == NULL ) // happens when the board editor is not active (or closed) if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
{ {
DisplayErrorMessage( this, _( "No board currently open." ) ); DisplayErrorMessage( this, _( "No board currently open." ) );
return; return;
@ -726,7 +735,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
// (Can be stored flipped if the lib is an archive built from a board) // (Can be stored flipped if the lib is an archive built from a board)
if( newFootprint->IsFlipped() ) if( newFootprint->IsFlipped() )
newFootprint->Flip( newFootprint->GetPosition(), newFootprint->Flip( newFootprint->GetPosition(),
pcbframe->Settings().m_FlipLeftRight ); pcbframe->Settings().m_FlipLeftRight );
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls(); KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
VECTOR2D cursorPos = viewControls->GetCursorPosition(); VECTOR2D cursorPos = viewControls->GetCursorPosition();

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) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es> * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
* Copyright (C) 2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.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
@ -64,7 +64,7 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_LIST::GetWizard( const wxString& aName )
return wizard; return wizard;
} }
return NULL; return nullptr;
} }

View File

@ -3,8 +3,8 @@
* *
* Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es> * Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
* Copyright (C) 2012-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.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
@ -79,10 +79,10 @@ END_EVENT_TABLE()
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent, FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType ) : FRAME_T aFrameType ) :
PCB_BASE_EDIT_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ), PCB_BASE_EDIT_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP, : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
FOOTPRINT_WIZARD_FRAME_NAME ), FOOTPRINT_WIZARD_FRAME_NAME ),
m_wizardListShown( false ) m_wizardListShown( false )
{ {
wxASSERT( aFrameType == FRAME_FOOTPRINT_WIZARD ); wxASSERT( aFrameType == FRAME_FOOTPRINT_WIZARD );
@ -162,7 +162,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
m_parametersPanel = new wxPanel( this, wxID_ANY ); m_parametersPanel = new wxPanel( this, wxID_ANY );
m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST, m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
wxDefaultPosition, wxDefaultSize, 0, NULL, wxDefaultPosition, wxDefaultSize, 0, nullptr,
wxLB_HSCROLL | wxNO_BORDER ); wxLB_HSCROLL | wxNO_BORDER );
auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY, auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
@ -254,7 +254,6 @@ void FOOTPRINT_WIZARD_FRAME::doCloseWindow()
if( !IsDismissed() ) if( !IsDismissed() )
DismissModal( false ); DismissModal( false );
} }
// else do nothing
} }
@ -313,7 +312,9 @@ void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
SetMsgPanel( items ); SetMsgPanel( items );
} }
else else
{
ClearMsgPanel(); ClearMsgPanel();
}
} }
@ -341,13 +342,13 @@ void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
m_parameterGrid->Connect( wxEVT_SIZE, m_parameterGrid->Connect( wxEVT_SIZE,
wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ), wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ),
NULL, this ); nullptr, this );
} }
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
{ {
if( m_pageList == NULL ) if( m_pageList == nullptr )
return; return;
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
@ -358,7 +359,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
m_pageList->Clear(); m_pageList->Clear();
int max_page = footprintWizard->GetNumParameterPages(); int max_page = footprintWizard->GetNumParameterPages();
for( int i = 0; i<max_page; i++ ) for( int i = 0; i < max_page; i++ )
{ {
wxString name = footprintWizard->GetParameterPageName( i ); wxString name = footprintWizard->GetParameterPageName( i );
m_pageList->Append( name ); m_pageList->Append( name );
@ -375,12 +376,12 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{ {
if( m_parameterGrid == NULL ) if( m_parameterGrid == nullptr )
return; return;
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
if( footprintWizard == NULL ) if( footprintWizard == nullptr )
return; return;
m_parameterGrid->Freeze(); m_parameterGrid->Freeze();
@ -406,7 +407,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
wxString designator, name, value, units, hint; wxString designator, name, value, units, hint;
for( unsigned int i = 0; i< namesList.size(); i++ ) for( unsigned int i = 0; i < namesList.size(); i++ )
{ {
designator = designatorsList[i]; designator = designatorsList[i];
name = namesList[i]; name = namesList[i];
@ -438,16 +439,15 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
options.Add( tokenizer.GetNextToken() ); options.Add( tokenizer.GetNextToken() );
} }
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) ); m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE,
new wxGridCellChoiceEditor( options ) );
units = wxT( "" ); units = wxT( "" );
} }
// Integer parameters else if( units == WIZARD_PARAM_UNITS_INTEGER ) // Integer parameters
else if( units == WIZARD_PARAM_UNITS_INTEGER )
{ {
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor ); m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
} }
// Non-integer numerical parameters
else if( ( units == WIZARD_PARAM_UNITS_MM ) || else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
( units == WIZARD_PARAM_UNITS_MILS ) || ( units == WIZARD_PARAM_UNITS_MILS ) ||
( units == WIZARD_PARAM_UNITS_FLOAT ) || ( units == WIZARD_PARAM_UNITS_FLOAT ) ||
@ -455,6 +455,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
( units == WIZARD_PARAM_UNITS_DEGREES ) || ( units == WIZARD_PARAM_UNITS_DEGREES ) ||
( units == WIZARD_PARAM_UNITS_PERCENT ) ) ( units == WIZARD_PARAM_UNITS_PERCENT ) )
{ {
// Non-integer numerical parameters
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor ); m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
// Convert separators to the locale-specific character // Convert separators to the locale-specific character
@ -478,7 +479,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns() void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns()
{ {
// Parameter grid is not yet configured // Parameter grid is not yet configured
if( ( m_parameterGrid == NULL ) || ( m_parameterGrid->GetNumberCols() == 0 ) ) if( ( m_parameterGrid == nullptr ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
return; return;
// first auto-size the columns to ensure enough space around text // first auto-size the columns to ensure enough space around text

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.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
@ -41,6 +41,7 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
wxString msg; wxString msg;
@ -70,8 +71,8 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
default: default:
wxFAIL_MSG( wxString::Format( wxFAIL_MSG( wxString::Format(
"FOOTPRINT_WIZARD_FRAME::Process_Special_Functions error: id = %d", "FOOTPRINT_WIZARD_FRAME::Process_Special_Functions error: id = %d",
event.GetId() ) ); event.GetId() ) );
break; break;
} }
} }
@ -134,14 +135,14 @@ void FOOTPRINT_WIZARD_FRAME::DisplayBuildMessage( wxString& aMessage )
FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_FRAME::GetMyWizard() FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_FRAME::GetMyWizard()
{ {
if( m_wizardName.Length() == 0 ) if( m_wizardName.Length() == 0 )
return NULL; return nullptr;
FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARD_LIST::GetWizard( m_wizardName ); FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARD_LIST::GetWizard( m_wizardName );
if( !footprintWizard ) if( !footprintWizard )
{ {
wxMessageBox( _( "Couldn't reload footprint wizard" ) ); wxMessageBox( _( "Couldn't reload footprint wizard" ) );
return NULL; return nullptr;
} }
return footprintWizard; return footprintWizard;
@ -161,7 +162,7 @@ FOOTPRINT* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
return footprint; return footprint;
} }
return NULL; return nullptr;
} }
@ -205,7 +206,7 @@ void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event )
{ {
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
if ( footprintWizard == NULL ) if ( footprintWizard == nullptr )
return; return;
footprintWizard->ResetParameters(); footprintWizard->ResetParameters();
@ -216,10 +217,12 @@ void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event )
DisplayWizardInfos(); DisplayWizardInfos();
} }
// This is a flag to avoid reentering of ParametersUpdated // This is a flag to avoid reentering of ParametersUpdated
// that can happen in some cases // that can happen in some cases
static bool lock_update_prms = false; static bool lock_update_prms = false;
void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
{ {
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

View File

@ -2,8 +2,8 @@
* 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) 2016 CERN * Copyright (C) 2016 CERN
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Janito V. Ferreira Filho * @author Janito V. Ferreira Filho
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.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
@ -72,12 +72,13 @@ bool SVG_IMPORT_PLUGIN::Load( const wxString& aFileName )
bool SVG_IMPORT_PLUGIN::Import() bool SVG_IMPORT_PLUGIN::Import()
{ {
for( NSVGshape* shape = m_parsedImage->shapes; shape != NULL; shape = shape->next ) for( NSVGshape* shape = m_parsedImage->shapes; shape != nullptr; shape = shape->next )
{ {
double lineWidth = shape->strokeWidth; double lineWidth = shape->strokeWidth;
for( NSVGpath* path = shape->paths; path != NULL; path = path->next ) for( NSVGpath* path = shape->paths; path != nullptr; path = path->next )
DrawPath( path->pts, path->npts, path->closed, shape->fill.type == NSVG_PAINT_COLOR, lineWidth ); DrawPath( path->pts, path->npts, path->closed, shape->fill.type == NSVG_PAINT_COLOR,
lineWidth );
} }
return true; return true;
@ -108,7 +109,8 @@ double SVG_IMPORT_PLUGIN::GetImageWidth() const
} }
void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aClosedPath, bool aFilled, double aLineWidth ) void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aClosedPath,
bool aFilled, double aLineWidth )
{ {
std::vector< VECTOR2D > collectedPathPoints; std::vector< VECTOR2D > collectedPathPoints;
@ -123,7 +125,7 @@ void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aCl
void SVG_IMPORT_PLUGIN::DrawCubicBezierPath( const float* aPoints, int aNumPoints, void SVG_IMPORT_PLUGIN::DrawCubicBezierPath( const float* aPoints, int aNumPoints,
std::vector< VECTOR2D >& aGeneratedPoints ) std::vector< VECTOR2D >& aGeneratedPoints )
{ {
const int pointsPerSegment = 4; const int pointsPerSegment = 4;
const int curveSpecificPointsPerSegment = 3; const int curveSpecificPointsPerSegment = 3;
@ -141,7 +143,7 @@ void SVG_IMPORT_PLUGIN::DrawCubicBezierPath( const float* aPoints, int aNumPoint
void SVG_IMPORT_PLUGIN::DrawCubicBezierCurve( const float* aPoints, void SVG_IMPORT_PLUGIN::DrawCubicBezierCurve( const float* aPoints,
std::vector< VECTOR2D >& aGeneratedPoints ) std::vector< VECTOR2D >& aGeneratedPoints )
{ {
auto start = getBezierPoint( aPoints, 0.0f ); auto start = getBezierPoint( aPoints, 0.0f );
auto end = getBezierPoint( aPoints, 1.0f ); auto end = getBezierPoint( aPoints, 1.0f );
@ -195,7 +197,7 @@ static VECTOR2D getBezierPoint( const float* aPoints, float aStep )
static VECTOR2D getPointInLine( const VECTOR2D& aLineStart, const VECTOR2D& aLineEnd, static VECTOR2D getPointInLine( const VECTOR2D& aLineStart, const VECTOR2D& aLineEnd,
float aDistance ) float aDistance )
{ {
return aLineStart + ( aLineEnd - aLineStart ) * aDistance; return aLineStart + ( aLineEnd - aLineStart ) * aDistance;
} }
@ -233,8 +235,9 @@ static VECTOR2D calculateBezierBoundingBoxExtremity( const float* aCurvePoints,
static void segmentBezierCurve( const VECTOR2D& aStart, const VECTOR2D& aEnd, float aOffset, static void segmentBezierCurve( const VECTOR2D& aStart, const VECTOR2D& aEnd, float aOffset,
float aStep, const float* aCurvePoints, float aSegmentationThreshold, float aStep, const float* aCurvePoints,
std::vector< VECTOR2D >& aGeneratedPoints ) float aSegmentationThreshold,
std::vector< VECTOR2D >& aGeneratedPoints )
{ {
VECTOR2D middle = getBezierPoint( aCurvePoints, aOffset + aStep ); VECTOR2D middle = getBezierPoint( aCurvePoints, aOffset + aStep );
float distanceToPreviousSegment = distanceFromPointToLine( middle, aStart, aEnd ); float distanceToPreviousSegment = distanceFromPointToLine( middle, aStart, aEnd );
@ -242,30 +245,31 @@ static void segmentBezierCurve( const VECTOR2D& aStart, const VECTOR2D& aEnd, fl
if( distanceToPreviousSegment > aSegmentationThreshold ) if( distanceToPreviousSegment > aSegmentationThreshold )
{ {
createNewBezierCurveSegments( aStart, middle, aEnd, aOffset, aStep, aCurvePoints, createNewBezierCurveSegments( aStart, middle, aEnd, aOffset, aStep, aCurvePoints,
aSegmentationThreshold, aGeneratedPoints ); aSegmentationThreshold, aGeneratedPoints );
} }
} }
static void createNewBezierCurveSegments( const VECTOR2D& aStart, const VECTOR2D& aMiddle, static void createNewBezierCurveSegments( const VECTOR2D& aStart, const VECTOR2D& aMiddle,
const VECTOR2D& aEnd, float aOffset, float aStep, const float* aCurvePoints, const VECTOR2D& aEnd, float aOffset, float aStep,
float aSegmentationThreshold, std::vector< VECTOR2D >& aGeneratedPoints ) const float* aCurvePoints, float aSegmentationThreshold,
std::vector< VECTOR2D >& aGeneratedPoints )
{ {
float newStep = aStep / 2.f; float newStep = aStep / 2.f;
float offsetAfterMiddle = aOffset + aStep; float offsetAfterMiddle = aOffset + aStep;
segmentBezierCurve( aStart, aMiddle, aOffset, newStep, aCurvePoints, aSegmentationThreshold, segmentBezierCurve( aStart, aMiddle, aOffset, newStep, aCurvePoints, aSegmentationThreshold,
aGeneratedPoints ); aGeneratedPoints );
aGeneratedPoints.push_back( aMiddle ); aGeneratedPoints.push_back( aMiddle );
segmentBezierCurve( aMiddle, aEnd, offsetAfterMiddle, newStep, aCurvePoints, segmentBezierCurve( aMiddle, aEnd, offsetAfterMiddle, newStep, aCurvePoints,
aSegmentationThreshold, aGeneratedPoints ); aSegmentationThreshold, aGeneratedPoints );
} }
static float distanceFromPointToLine( const VECTOR2D& aPoint, const VECTOR2D& aLineStart, static float distanceFromPointToLine( const VECTOR2D& aPoint, const VECTOR2D& aLineStart,
const VECTOR2D& aLineEnd ) const VECTOR2D& aLineEnd )
{ {
auto lineDirection = aLineEnd - aLineStart; auto lineDirection = aLineEnd - aLineStart;
auto lineNormal = lineDirection.Perpendicular().Resize( 1.f ); auto lineNormal = lineDirection.Perpendicular().Resize( 1.f );

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-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -42,7 +42,7 @@
bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal ) bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal )
{ {
if( GetBoard() == NULL ) if( GetBoard() == nullptr )
return false; return false;
if( aQuery && !GetBoard()->IsEmpty() ) if( aQuery && !GetBoard()->IsEmpty() )
@ -96,7 +96,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal )
bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
{ {
if( GetBoard() == NULL ) if( GetBoard() == nullptr )
return false; return false;
bool is_last_fp_from_brd = IsCurrentFPFromBoard(); bool is_last_fp_from_brd = IsCurrentFPFromBoard();

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) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.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
@ -111,7 +111,7 @@ const wxString IO_MGR::GetFileExtension( PCB_FILE_T aFileType )
wxString ext = wxEmptyString; wxString ext = wxEmptyString;
PLUGIN* plugin = PluginFind( aFileType ); PLUGIN* plugin = PluginFind( aFileType );
if( plugin != NULL ) if( plugin != nullptr )
{ {
ext = plugin->GetFileExtension(); ext = plugin->GetFileExtension();
PluginRelease( plugin ); PluginRelease( plugin );

View File

@ -1,7 +1,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) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.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
@ -80,7 +80,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create microwave footprint" ), value ); WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create microwave footprint" ), value );
if( dlg.ShowQuasiModal() != wxID_OK ) if( dlg.ShowQuasiModal() != wxID_OK )
return NULL; // cancelled by user return nullptr; // cancelled by user
value = dlg.GetValue(); value = dlg.GetValue();
gap_size = ValueFromString( editFrame.GetUserUnits(), value ); gap_size = ValueFromString( editFrame.GetUserUnits(), value );
@ -95,7 +95,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
_( "Create microwave footprint" ), msg ); _( "Create microwave footprint" ), msg );
if( angledlg.ShowQuasiModal() != wxID_OK ) if( angledlg.ShowQuasiModal() != wxID_OK )
return NULL; // cancelled by user return nullptr; // cancelled by user
msg = angledlg.GetValue(); msg = angledlg.GetValue();
@ -112,7 +112,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
} }
if( abort ) if( abort )
return NULL; return nullptr;
footprint = createBaseFootprint( cmp_name, text_size, pad_count ); footprint = createBaseFootprint( cmp_name, text_size, pad_count );
auto it = footprint->Pads().begin(); auto it = footprint->Pads().begin();
@ -145,7 +145,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
pad->SetShape( PAD_SHAPE::CUSTOM ); pad->SetShape( PAD_SHAPE::CUSTOM );
pad->SetAnchorPadShape( PAD_SHAPE::RECT ); pad->SetAnchorPadShape( PAD_SHAPE::RECT );
int numPoints = (angle / 50) + 3; // Note: angles are in 0.1 degrees int numPoints = ( angle / 50 ) + 3; // Note: angles are in 0.1 degrees
std::vector<wxPoint> polyPoints; std::vector<wxPoint> polyPoints;
polyPoints.reserve( numPoints ); polyPoints.reserve( numPoints );
@ -169,8 +169,8 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
polyPoints.push_back( polyPoints[0] ); polyPoints.push_back( polyPoints[0] );
pad->AddPrimitivePoly( polyPoints, 0, true ); // add a polygonal basic shape pad->AddPrimitivePoly( polyPoints, 0, true ); // add a polygonal basic shape
}
break; break;
}
default: default:
break; break;

View File

@ -4,7 +4,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -57,22 +57,13 @@ static int PolyShapeType;
/**************** Polygon Shapes ***********************/
enum id_mw_cmd { enum id_mw_cmd {
ID_READ_SHAPE_FILE = 1000 ID_READ_SHAPE_FILE = 1000
}; };
/* Setting polynomial form parameters
*/
class MWAVE_POLYGONAL_SHAPE_DLG : public wxDialog class MWAVE_POLYGONAL_SHAPE_DLG : public wxDialog
{ {
private:
PCB_EDIT_FRAME* m_Parent;
wxRadioBox* m_ShapeOptionCtrl;
EDA_SIZE_CTRL* m_SizeCtrl;
public: public:
MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos ); MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos );
~MWAVE_POLYGONAL_SHAPE_DLG() { }; ~MWAVE_POLYGONAL_SHAPE_DLG() { };
@ -82,8 +73,8 @@ private:
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
/** /**
* Function ReadDataShapeDescr * Read a description shape file.
* read a description shape file *
* File format is * File format is
* Unit=MM * Unit=MM
* XScale=271.501 * XScale=271.501
@ -100,6 +91,10 @@ private:
void ReadDataShapeDescr( wxCommandEvent& event ); void ReadDataShapeDescr( wxCommandEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
PCB_EDIT_FRAME* m_Parent;
wxRadioBox* m_ShapeOptionCtrl;
EDA_SIZE_CTRL* m_SizeCtrl;
}; };
@ -172,7 +167,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
wxString fullFileName; wxString fullFileName;
wxString mask = wxFileSelectorDefaultWildcardStr; wxString mask = wxFileSelectorDefaultWildcardStr;
fullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ), lastpath, fullFileName = EDA_FILE_SELECTOR( _( "Read Shape Description File" ), lastpath,
fullFileName, wxEmptyString, mask, this, fullFileName, wxEmptyString, mask, this,
wxFD_OPEN, true ); wxFD_OPEN, true );
@ -185,7 +180,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
FILE* File = wxFopen( fullFileName, wxT( "rt" ) ); FILE* File = wxFopen( fullFileName, wxT( "rt" ) );
if( File == NULL ) if( File == nullptr )
{ {
DisplayError( this, _( "File not found" ) ); DisplayError( this, _( "File not found" ) );
return; return;
@ -203,7 +198,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
{ {
char* Line = reader.Line(); char* Line = reader.Line();
char* param1 = strtok( Line, " =\n\r" ); char* param1 = strtok( Line, " =\n\r" );
char* param2 = strtok( NULL, " \t\n\r" ); char* param2 = strtok( nullptr, " \t\n\r" );
if( strncasecmp( param1, "Unit", 4 ) == 0 ) if( strncasecmp( param1, "Unit", 4 ) == 0 )
{ {
@ -223,7 +218,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
{ {
Line = reader.Line(); Line = reader.Line();
param1 = strtok( Line, " \t\n\r" ); param1 = strtok( Line, " \t\n\r" );
param2 = strtok( NULL, " \t\n\r" ); param2 = strtok( nullptr, " \t\n\r" );
if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 ) if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
break; break;
@ -265,7 +260,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
if( ret != wxID_OK ) if( ret != wxID_OK )
{ {
PolyEdges.clear(); PolyEdges.clear();
return NULL; return nullptr;
} }
if( PolyShapeType == 2 ) // mirrored if( PolyShapeType == 2 ) // mirrored
@ -277,13 +272,13 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) ) if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
{ {
editFrame.ShowInfoBarError( _( "Shape has a null size." ) ); editFrame.ShowInfoBarError( _( "Shape has a null size." ) );
return NULL; return nullptr;
} }
if( PolyEdges.size() == 0 ) if( PolyEdges.size() == 0 )
{ {
editFrame.ShowInfoBarError( _( "Shape has no points." ) ); editFrame.ShowInfoBarError( _( "Shape has no points." ) );
return NULL; return nullptr;
} }
cmp_name = wxT( "muwave_polygon" ); cmp_name = wxT( "muwave_polygon" );
@ -351,8 +346,9 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
} }
shape->SetPolyPoints( polyPoints ); shape->SetPolyPoints( polyPoints );
// Set the polygon outline thickness to 0, only the polygonal shape is filled // Set the polygon outline thickness to 0, only the polygonal shape is filled
// without extra thickness // without extra thickness.
shape->SetWidth( 0 ); shape->SetWidth( 0 );
PolyEdges.clear(); PolyEdges.clear();

View File

@ -183,7 +183,7 @@ class NETINFO_MAPPING
public: public:
NETINFO_MAPPING() NETINFO_MAPPING()
{ {
m_board = NULL; m_board = nullptr;
} }

View File

@ -7,7 +7,7 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -38,10 +38,6 @@
#include <pad.h> #include <pad.h>
/*********************************************************/
/* class NETINFO_ITEM: handle data relative to a given net */
/*********************************************************/
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) : NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
BOARD_ITEM( aParent, PCB_NETINFO_T ), BOARD_ITEM( aParent, PCB_NETINFO_T ),
m_netCode( aNetCode ), m_netCode( aNetCode ),
@ -80,7 +76,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANE
aList.emplace_back( _( "Net Code" ), wxString::Format( "%d", GetNetCode() ) ); aList.emplace_back( _( "Net Code" ), wxString::Format( "%d", GetNetCode() ) );
// Warning: for netcode == NETINFO_LIST::ORPHANED, the parent or the board can be NULL // Warning: for netcode == NETINFO_LIST::ORPHANED, the parent or the board can be NULL
BOARD * board = m_parent ? m_parent->GetBoard() : NULL; BOARD * board = m_parent ? m_parent->GetBoard() : nullptr;
if( board ) if( board )
{ {

View File

@ -1,7 +1,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) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -67,7 +67,7 @@ NETINFO_ITEM* NETINFO_LIST::GetNetItem( int aNetCode ) const
if( result != m_netCodes.end() ) if( result != m_netCodes.end() )
return (*result).second; return (*result).second;
return NULL; return nullptr;
} }
@ -78,7 +78,7 @@ NETINFO_ITEM* NETINFO_LIST::GetNetItem( const wxString& aNetName ) const
if( result != m_netNames.end() ) if( result != m_netNames.end() )
return (*result).second; return (*result).second;
return NULL; return nullptr;
} }
@ -135,22 +135,22 @@ void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
// if there is a net with such name then just assign the correct number // if there is a net with such name then just assign the correct number
NETINFO_ITEM* sameName = GetNetItem( aNewElement->GetNetname() ); NETINFO_ITEM* sameName = GetNetItem( aNewElement->GetNetname() );
if( sameName != NULL ) if( sameName != nullptr )
{ {
aNewElement->m_netCode = sameName->GetNetCode(); aNewElement->m_netCode = sameName->GetNetCode();
return; return;
} }
// be sure that net codes are consecutive
// negative net code means that it has to be auto assigned
else if( aNewElement->m_netCode != (int) m_netCodes.size() || aNewElement->m_netCode < 0 ) else if( aNewElement->m_netCode != (int) m_netCodes.size() || aNewElement->m_netCode < 0 )
{ {
// be sure that net codes are consecutive
// negative net code means that it has to be auto assigned
aNewElement->m_netCode = getFreeNetCode(); aNewElement->m_netCode = getFreeNetCode();
} }
// net names & codes are supposed to be unique // net names & codes are supposed to be unique
assert( GetNetItem( aNewElement->GetNetname() ) == NULL ); assert( GetNetItem( aNewElement->GetNetname() ) == nullptr );
assert( GetNetItem( aNewElement->GetNetCode() ) == NULL ); assert( GetNetItem( aNewElement->GetNetCode() ) == nullptr );
// add an entry for fast look up by a net name using a map // add an entry for fast look up by a net name using a map
m_netNames.insert( std::make_pair( aNewElement->GetNetname(), aNewElement ) ); m_netNames.insert( std::make_pair( aNewElement->GetNetname(), aNewElement ) );

View File

@ -4,7 +4,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 CERN * Copyright (C) 2015 CERN
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* *
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
@ -438,7 +438,9 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
} }
} }
else else
{
cachePinFunction( pad, pinFunction ); cachePinFunction( pad, pinFunction );
}
// Test if new footprint pad has no net (pads not on copper layers have no net). // Test if new footprint pad has no net (pads not on copper layers have no net).
if( !net.IsValid() || !pad->IsOnCopperLayer() ) if( !net.IsValid() || !pad->IsOnCopperLayer() )
@ -481,7 +483,9 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
} }
else else
{
cacheNetname( pad, wxEmptyString ); cacheNetname( pad, wxEmptyString );
}
} }
else // New footprint pad has a net. else // New footprint pad has a net.
{ {
@ -601,6 +605,7 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
for( int ii = 0; ii < (int) aNetlist.GetCount(); ii++ ) for( int ii = 0; ii < (int) aNetlist.GetCount(); ii++ )
{ {
const COMPONENT* component = aNetlist.GetComponent( ii ); const COMPONENT* component = aNetlist.GetComponent( ii );
for( unsigned jj = 0; jj < component->GetNetCount(); jj++ ) for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
{ {
const COMPONENT_NET& net = component->GetNet( jj ); const COMPONENT_NET& net = component->GetNet( jj );
@ -776,7 +781,7 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
int count = 0; int count = 0;
wxString netname; wxString netname;
wxString msg; wxString msg;
PAD* previouspad = NULL; PAD* previouspad = nullptr;
// We need the pad list for next tests. // We need the pad list for next tests.

View File

@ -6,8 +6,8 @@
* 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) 1992-2011 Jean-Pierre Charras. * Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@verizon.net>. * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>.
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -37,7 +37,7 @@ void LEGACY_NETLIST_READER::LoadNetlist()
{ {
int state = 0; int state = 0;
bool is_comment = false; bool is_comment = false;
COMPONENT* component = NULL; COMPONENT* component = nullptr;
while( m_lineReader->ReadLine() ) while( m_lineReader->ReadLine() )
{ {
@ -46,7 +46,7 @@ void LEGACY_NETLIST_READER::LoadNetlist()
if( is_comment ) // Comments in progress if( is_comment ) // Comments in progress
{ {
// Test for end of the current comment // Test for end of the current comment
if( ( line = strchr( line, '}' ) ) == NULL ) if( ( line = strchr( line, '}' ) ) == nullptr )
continue; continue;
is_comment = false; is_comment = false;
@ -63,7 +63,7 @@ void LEGACY_NETLIST_READER::LoadNetlist()
continue; continue;
} }
if( ( line = strchr( line, '}' ) ) == NULL ) if( ( line = strchr( line, '}' ) ) == nullptr )
continue; continue;
} }
@ -81,7 +81,7 @@ void LEGACY_NETLIST_READER::LoadNetlist()
if( state >= 3 ) // Pad descriptions are read here. if( state >= 3 ) // Pad descriptions are read here.
{ {
wxASSERT( component != NULL ); wxASSERT( component != nullptr );
loadNet( line, component ); loadNet( line, component );
state--; state--;
@ -113,7 +113,7 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
// Sample component line: /68183921-93a5-49ac-91b0-49d05a0e1647 $noname R20 4.7K {Lib=R} // Sample component line: /68183921-93a5-49ac-91b0-49d05a0e1647 $noname R20 4.7K {Lib=R}
// Read time stamp (first word) // Read time stamp (first word)
if( ( text = strtok( line, " ()\t\n" ) ) == NULL ) if( ( text = strtok( line, " ()\t\n" ) ) == nullptr )
{ {
msg = _( "Cannot parse time stamp in symbol section of netlist." ); msg = _( "Cannot parse time stamp in symbol section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(), THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(),
@ -123,7 +123,7 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
KIID_PATH path( FROM_UTF8( text ) ); KIID_PATH path( FROM_UTF8( text ) );
// Read footprint name (second word) // Read footprint name (second word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL ) if( ( text = strtok( nullptr, " ()\t\n" ) ) == nullptr )
{ {
msg = _( "Cannot parse footprint name in symbol section of netlist." ); msg = _( "Cannot parse footprint name in symbol section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(), THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
@ -137,7 +137,7 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
footprintName = wxEmptyString; footprintName = wxEmptyString;
// Read schematic reference designator (third word) // Read schematic reference designator (third word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL ) if( ( text = strtok( nullptr, " ()\t\n" ) ) == nullptr )
{ {
msg = _( "Cannot parse reference designator in symbol section of netlist." ); msg = _( "Cannot parse reference designator in symbol section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(), THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
@ -147,7 +147,7 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
reference = FROM_UTF8( text ); reference = FROM_UTF8( text );
// Read schematic value (forth word) // Read schematic value (forth word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL ) if( ( text = strtok( nullptr, " ()\t\n" ) ) == nullptr )
{ {
msg = _( "Cannot parse value in symbol section of netlist." ); msg = _( "Cannot parse value in symbol section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(), THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
@ -158,7 +158,7 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
// Read component name (fifth word) {Lib=C} // Read component name (fifth word) {Lib=C}
// This is an optional field (a comment), which does not always exists // This is an optional field (a comment), which does not always exists
if( ( text = strtok( NULL, " ()\t\n" ) ) != NULL ) if( ( text = strtok( nullptr, " ()\t\n" ) ) != nullptr )
{ {
name = FROM_UTF8( text ).AfterFirst( wxChar( '=' ) ).BeforeLast( wxChar( '}' ) ); name = FROM_UTF8( text ).AfterFirst( wxChar( '=' ) ).BeforeLast( wxChar( '}' ) );
} }
@ -184,7 +184,7 @@ void LEGACY_NETLIST_READER::loadNet( char* aText, COMPONENT* aComponent )
strncpy( line, aText, sizeof( line ) ); strncpy( line, aText, sizeof( line ) );
line[ sizeof(line) - 1 ] = '\0'; line[ sizeof(line) - 1 ] = '\0';
if( ( p = strtok( line, " ()\t\n" ) ) == NULL ) if( ( p = strtok( line, " ()\t\n" ) ) == nullptr )
{ {
msg = _( "Cannot parse pin name in symbol net section of netlist." ); msg = _( "Cannot parse pin name in symbol net section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(), THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(),
@ -193,7 +193,7 @@ void LEGACY_NETLIST_READER::loadNet( char* aText, COMPONENT* aComponent )
wxString pinName = FROM_UTF8( p ); wxString pinName = FROM_UTF8( p );
if( ( p = strtok( NULL, " ()\t\n" ) ) == NULL ) if( ( p = strtok( nullptr, " ()\t\n" ) ) == nullptr )
{ {
msg = _( "Cannot parse net name in symbol net section of netlist." ); msg = _( "Cannot parse net name in symbol net section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(), THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(),
@ -214,15 +214,15 @@ void LEGACY_NETLIST_READER::loadFootprintFilters()
wxArrayString filters; wxArrayString filters;
wxString cmpRef; wxString cmpRef;
char* line; char* line;
COMPONENT* component = NULL; // Suppress compil warning COMPONENT* component = nullptr; // Suppress compile warning
while( ( line = m_lineReader->ReadLine() ) != NULL ) while( ( line = m_lineReader->ReadLine() ) != nullptr )
{ {
if( strncasecmp( line, "$endlist", 8 ) == 0 ) // end of list for the current component if( strncasecmp( line, "$endlist", 8 ) == 0 ) // end of list for the current component
{ {
wxASSERT( component != NULL ); wxASSERT( component != nullptr );
component->SetFootprintFilters( filters ); component->SetFootprintFilters( filters );
component = NULL; component = nullptr;
filters.Clear(); filters.Clear();
continue; continue;
} }
@ -240,7 +240,7 @@ void LEGACY_NETLIST_READER::loadFootprintFilters()
component = m_netlist->GetComponentByReference( cmpRef ); component = m_netlist->GetComponentByReference( cmpRef );
// Cannot happen if the netlist is valid. // Cannot happen if the netlist is valid.
if( component == NULL ) if( component == nullptr )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Cannot find symbol %s in footprint filter section of netlist." ), msg.Printf( _( "Cannot find symbol %s in footprint filter section of netlist." ),
@ -259,3 +259,6 @@ void LEGACY_NETLIST_READER::loadFootprintFilters()
} }
} }
} }
// LocalWords: EDA Charras pcb netlist noname cmp endlist
// LocalWords: endfootprintlist

View File

@ -5,8 +5,8 @@
* 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) 1992-2011 Jean-Pierre Charras. * Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@verizon.net>. * Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@gmail.com>.
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -51,9 +51,11 @@ NETLIST_READER::NETLIST_FILE_T NETLIST_READER::GuessNetlistFileType( LINE_READER
// depending on the tool which created the file // depending on the tool which created the file
wxRegEx reOrcad( wxT( "(?i)[ ]*\\([ \t]+{+" ), wxRE_ADVANCED ); wxRegEx reOrcad( wxT( "(?i)[ ]*\\([ \t]+{+" ), wxRE_ADVANCED );
wxASSERT( reOrcad.IsValid() ); wxASSERT( reOrcad.IsValid() );
// Our legacy netlist format starts by "# EESchema Netlist " // Our legacy netlist format starts by "# EESchema Netlist "
wxRegEx reLegacy( wxT( "(?i)#[ \t]+EESchema[ \t]+Netlist[ \t]+" ), wxRE_ADVANCED ); wxRegEx reLegacy( wxT( "(?i)#[ \t]+EESchema[ \t]+Netlist[ \t]+" ), wxRE_ADVANCED );
wxASSERT( reLegacy.IsValid() ); wxASSERT( reLegacy.IsValid() );
// Our new netlist format starts by "(export (version " // Our new netlist format starts by "(export (version "
wxRegEx reKicad( wxT( "[ ]*\\(export[ ]+" ), wxRE_ADVANCED ); wxRegEx reKicad( wxT( "[ ]*\\(export[ ]+" ), wxRE_ADVANCED );
wxASSERT( reKicad.IsValid() ); wxASSERT( reKicad.IsValid() );
@ -80,16 +82,17 @@ NETLIST_READER* NETLIST_READER::GetNetlistReader( NETLIST* aNetlist,
const wxString& aNetlistFileName, const wxString& aNetlistFileName,
const wxString& aCompFootprintFileName ) const wxString& aCompFootprintFileName )
{ {
wxASSERT( aNetlist != NULL ); wxASSERT( aNetlist != nullptr );
std::unique_ptr<FILE_LINE_READER> file_rdr = std::make_unique<FILE_LINE_READER>( aNetlistFileName ); std::unique_ptr<FILE_LINE_READER> file_rdr =
std::make_unique<FILE_LINE_READER>( aNetlistFileName );
NETLIST_FILE_T type = GuessNetlistFileType( file_rdr.get() ); NETLIST_FILE_T type = GuessNetlistFileType( file_rdr.get() );
file_rdr->Rewind(); file_rdr->Rewind();
// The component footprint link reader is NULL if no file name was specified. // The component footprint link reader is NULL if no file name was specified.
std::unique_ptr<CMP_READER> cmp_rdr( aCompFootprintFileName.IsEmpty() ? std::unique_ptr<CMP_READER> cmp_rdr( aCompFootprintFileName.IsEmpty() ?
NULL : nullptr :
new CMP_READER( new FILE_LINE_READER( aCompFootprintFileName ) ) ); new CMP_READER( new FILE_LINE_READER( aCompFootprintFileName ) ) );
switch( type ) switch( type )
@ -105,13 +108,13 @@ NETLIST_READER* NETLIST_READER::GetNetlistReader( NETLIST* aNetlist,
break; break;
} }
return NULL; return nullptr;
} }
bool CMP_READER::Load( NETLIST* aNetlist ) bool CMP_READER::Load( NETLIST* aNetlist )
{ {
wxCHECK_MSG( aNetlist != NULL,true, wxT( "No netlist passed to CMP_READER::Load()" ) ); wxCHECK_MSG( aNetlist != nullptr, true, wxT( "No netlist passed to CMP_READER::Load()" ) );
wxString reference; // Stores value read from line like Reference = BUS1; wxString reference; // Stores value read from line like Reference = BUS1;
wxString timestamp; // Stores value read from line like TimeStamp = /32307DE2/AA450F67; wxString timestamp; // Stores value read from line like TimeStamp = /32307DE2/AA450F67;

View File

@ -45,7 +45,7 @@ void COMPONENT::SetFootprint( FOOTPRINT* aFootprint )
if( !m_kiids.empty() ) if( !m_kiids.empty() )
path.push_back( m_kiids.front() ); path.push_back( m_kiids.front() );
if( aFootprint == NULL ) if( aFootprint == nullptr )
return; return;
aFootprint->SetReference( m_reference ); aFootprint->SetReference( m_reference );
@ -150,7 +150,7 @@ void NETLIST::AddComponent( COMPONENT* aComponent )
COMPONENT* NETLIST::GetComponentByReference( const wxString& aReference ) COMPONENT* NETLIST::GetComponentByReference( const wxString& aReference )
{ {
COMPONENT* component = NULL; COMPONENT* component = nullptr;
for( unsigned i = 0; i < m_components.size(); i++ ) for( unsigned i = 0; i < m_components.size(); i++ )
{ {

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -54,6 +54,7 @@
using KIGFX::PCB_PAINTER; using KIGFX::PCB_PAINTER;
using KIGFX::PCB_RENDER_SETTINGS; using KIGFX::PCB_RENDER_SETTINGS;
PAD::PAD( FOOTPRINT* parent ) : PAD::PAD( FOOTPRINT* parent ) :
BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) BOARD_CONNECTED_ITEM( parent, PCB_PAD_T )
{ {
@ -67,21 +68,23 @@ PAD::PAD( FOOTPRINT* parent ) :
m_pos = GetParent()->GetPosition(); m_pos = GetParent()->GetPosition();
} }
SetShape( PAD_SHAPE::CIRCLE ); // Default pad shape is PAD_CIRCLE. SetShape( PAD_SHAPE::CIRCLE ); // Default pad shape is PAD_CIRCLE.
SetAnchorPadShape( PAD_SHAPE::CIRCLE ); // Default shape for custom shaped pads SetAnchorPadShape( PAD_SHAPE::CIRCLE ); // Default shape for custom shaped pads
// is PAD_CIRCLE. // is PAD_CIRCLE.
SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); // Default pad drill shape is a circle. SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); // Default pad drill shape is a circle.
m_attribute = PAD_ATTRIB::PTH; // Default pad type is plated through hole m_attribute = PAD_ATTRIB::PTH; // Default pad type is plated through hole
SetProperty( PAD_PROP::NONE ); // no special fabrication property SetProperty( PAD_PROP::NONE ); // no special fabrication property
m_localClearance = 0; m_localClearance = 0;
m_localSolderMaskMargin = 0; m_localSolderMaskMargin = 0;
m_localSolderPasteMargin = 0; m_localSolderPasteMargin = 0;
m_localSolderPasteMarginRatio = 0.0; m_localSolderPasteMarginRatio = 0.0;
// Parameters for round rect only: // Parameters for round rect only:
m_roundedCornerScale = 0.25; // from IPC-7351C standard m_roundedCornerScale = 0.25; // from IPC-7351C standard
// Parameters for chamfered rect only: // Parameters for chamfered rect only:
m_chamferScale = 0.2; // Size of chamfer: ratio of smallest of X,Y size m_chamferScale = 0.2; // Size of chamfer: ratio of smallest of X,Y size
m_chamferPositions = RECT_NO_CHAMFER; // No chamfered corner m_chamferPositions = RECT_NO_CHAMFER; // No chamfered corner
m_zoneConnection = ZONE_CONNECTION::INHERITED; // Use parent setting by default m_zoneConnection = ZONE_CONNECTION::INHERITED; // Use parent setting by default
m_thermalWidth = 0; // Use parent setting by default m_thermalWidth = 0; // Use parent setting by default
@ -221,15 +224,15 @@ bool PAD::FlashLayer( int aLayer ) const
if( GetAttribute() != PAD_ATTRIB::PTH ) if( GetAttribute() != PAD_ATTRIB::PTH )
return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ); return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
/// Heatsink pads always get copper /// Heat sink pads always get copper
if( GetProperty() == PAD_PROP::HEATSINK ) if( GetProperty() == PAD_PROP::HEATSINK )
return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ); return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
if( !m_removeUnconnectedLayer ) if( !m_removeUnconnectedLayer )
return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ); return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
/// Plated through hole pads need copper on the top/bottom layers for proper soldering // Plated through hole pads need copper on the top/bottom layers for proper soldering
/// Unless the user has removed them in the pad dialog // Unless the user has removed them in the pad dialog
if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) ) if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) )
return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ); return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
@ -338,7 +341,9 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
case PAD_SHAPE::OVAL: case PAD_SHAPE::OVAL:
if( m_size.x == m_size.y ) // the oval pad is in fact a circle if( m_size.x == m_size.y ) // the oval pad is in fact a circle
{
add( new SHAPE_CIRCLE( shapePos, m_size.x / 2 ) ); add( new SHAPE_CIRCLE( shapePos, m_size.x / 2 ) );
}
else else
{ {
wxSize half_size = m_size / 2; wxSize half_size = m_size / 2;
@ -347,6 +352,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
RotatePoint( &half_len, m_orient ); RotatePoint( &half_len, m_orient );
add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) ); add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) );
} }
break; break;
case PAD_SHAPE::RECT: case PAD_SHAPE::RECT:
@ -460,7 +466,6 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
wxSize( bbox.GetWidth(), bbox.GetHeight() ) ); wxSize( bbox.GetWidth(), bbox.GetHeight() ) );
// Hole shape // Hole shape
//
wxSize half_size = m_drill / 2; wxSize half_size = m_drill / 2;
int half_width = std::min( half_size.x, half_size.y ); int half_width = std::min( half_size.x, half_size.y );
wxPoint half_len( half_size.x - half_width, half_size.y - half_width ); wxPoint half_len( half_size.x - half_width, half_size.y - half_width );
@ -471,7 +476,6 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
half_width * 2 ); half_width * 2 );
// All done // All done
//
m_shapesDirty = false; m_shapesDirty = false;
} }
@ -489,7 +493,6 @@ void PAD::BuildEffectivePolygon() const
int maxError = board ? board->GetDesignSettings().m_MaxError : ARC_HIGH_DEF; int maxError = board ? board->GetDesignSettings().m_MaxError : ARC_HIGH_DEF;
// Polygon // Polygon
//
m_effectivePolygon = std::make_shared<SHAPE_POLY_SET>(); m_effectivePolygon = std::make_shared<SHAPE_POLY_SET>();
TransformShapeWithClearanceToPolygon( *m_effectivePolygon, UNDEFINED_LAYER, 0, maxError, TransformShapeWithClearanceToPolygon( *m_effectivePolygon, UNDEFINED_LAYER, 0, maxError,
ERROR_INSIDE ); ERROR_INSIDE );
@ -498,7 +501,6 @@ void PAD::BuildEffectivePolygon() const
// //
// PADSTACKS TODO: these will both need to cycle through all layers to get the largest // PADSTACKS TODO: these will both need to cycle through all layers to get the largest
// values.... // values....
//
m_effectiveBoundingRadius = 0; m_effectiveBoundingRadius = 0;
for( int cnt = 0; cnt < m_effectivePolygon->OutlineCount(); ++cnt ) for( int cnt = 0; cnt < m_effectivePolygon->OutlineCount(); ++cnt )
@ -513,7 +515,6 @@ void PAD::BuildEffectivePolygon() const
} }
// All done // All done
//
m_polyDirty = false; m_polyDirty = false;
} }
@ -533,7 +534,7 @@ void PAD::SetDrawCoord()
m_pos = m_pos0; m_pos = m_pos0;
if( parentFootprint == NULL ) if( parentFootprint == nullptr )
return; return;
double angle = parentFootprint->GetOrientation(); double angle = parentFootprint->GetOrientation();
@ -549,7 +550,7 @@ void PAD::SetLocalCoord()
{ {
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent ); FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
if( parentFootprint == NULL ) if( parentFootprint == nullptr )
{ {
m_pos0 = m_pos; m_pos0 = m_pos;
return; return;
@ -646,7 +647,6 @@ void PAD::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
} }
// Flip (mirror) the basic shapes (primitives), in custom pads
void PAD::FlipPrimitives( bool aFlipLeftRight ) void PAD::FlipPrimitives( bool aFlipLeftRight )
{ {
for( std::shared_ptr<PCB_SHAPE>& primitive : m_editPrimitives ) for( std::shared_ptr<PCB_SHAPE>& primitive : m_editPrimitives )
@ -656,7 +656,6 @@ void PAD::FlipPrimitives( bool aFlipLeftRight )
} }
// Returns the position of the pad.
wxPoint PAD::ShapePos() const wxPoint PAD::ShapePos() const
{ {
if( m_offset.x == 0 && m_offset.y == 0 ) if( m_offset.x == 0 && m_offset.y == 0 )
@ -695,8 +694,6 @@ int PAD::GetLocalClearance( wxString* aSource ) const
} }
// Mask margins handling:
int PAD::GetSolderMaskMargin() const int PAD::GetSolderMaskMargin() const
{ {
// The pad inherits the margin only to calculate a default shape, // The pad inherits the margin only to calculate a default shape,
@ -897,7 +894,8 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
aList.emplace_back( ShowPadShape(), props ); aList.emplace_back( ShowPadShape(), props );
if( ( GetShape() == PAD_SHAPE::CIRCLE || GetShape() == PAD_SHAPE::OVAL ) && m_size.x == m_size.y ) if( ( GetShape() == PAD_SHAPE::CIRCLE || GetShape() == PAD_SHAPE::OVAL ) &&
m_size.x == m_size.y )
{ {
aList.emplace_back( _( "Diameter" ), MessageTextFromValue( units, m_size.x ) ); aList.emplace_back( _( "Diameter" ), MessageTextFromValue( units, m_size.x ) );
} }
@ -1012,7 +1010,8 @@ int PAD::Compare( const PAD* padref, const PAD* padcmp )
{ {
int diff; int diff;
if( ( diff = static_cast<int>( padref->GetShape() ) - static_cast<int>( padcmp->GetShape() ) ) != 0 ) if( ( diff = static_cast<int>( padref->GetShape() ) -
static_cast<int>( padcmp->GetShape() ) ) != 0 )
return diff; return diff;
if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0) if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0)
@ -1042,7 +1041,7 @@ int PAD::Compare( const PAD* padref, const PAD* padcmp )
if( ( diff = padref->m_deltaSize.y - padcmp->m_deltaSize.y ) != 0 ) if( ( diff = padref->m_deltaSize.y - padcmp->m_deltaSize.y ) != 0 )
return diff; return diff;
// TODO: test custom shapes // TODO: test custom shapes
// Dick: specctra_export needs this // Dick: specctra_export needs this
// Lorenzo: gencad also needs it to implement padstacks! // Lorenzo: gencad also needs it to implement padstacks!
@ -1087,7 +1086,7 @@ wxString PAD::ShowPadShape() const
case PAD_SHAPE::ROUNDRECT: return _( "Roundrect" ); case PAD_SHAPE::ROUNDRECT: return _( "Roundrect" );
case PAD_SHAPE::CHAMFERED_RECT: return _( "Chamferedrect" ); case PAD_SHAPE::CHAMFERED_RECT: return _( "Chamferedrect" );
case PAD_SHAPE::CUSTOM: return _( "CustomShape" ); case PAD_SHAPE::CUSTOM: return _( "CustomShape" );
default: return wxT( "???" ); default: return wxT( "???" );
} }
} }
@ -1100,7 +1099,7 @@ wxString PAD::ShowPadAttr() const
case PAD_ATTRIB::SMD: return _( "SMD" ); case PAD_ATTRIB::SMD: return _( "SMD" );
case PAD_ATTRIB::CONN: return _( "Conn" ); case PAD_ATTRIB::CONN: return _( "Conn" );
case PAD_ATTRIB::NPTH: return _( "NPTH" ); case PAD_ATTRIB::NPTH: return _( "NPTH" );
default: return wxT( "???" ); default: return wxT( "???" );
} }
} }
@ -1532,7 +1531,7 @@ static struct PAD_DESC
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Parent" ), propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Parent" ),
NO_SETTER( PAD, wxString ), &PAD::GetParentAsString ) ); NO_SETTER( PAD, wxString ), &PAD::GetParentAsString ) );
// TODO delta, dirill shape offset, layerset, zone connection // TODO delta, drill shape offset, layer set, zone connection
} }
} _PAD_DESC; } _PAD_DESC;

View File

@ -4,7 +4,7 @@
* Copyright (C) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -153,7 +153,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs()
} }
catch( ... ) catch( ... )
{ {
DisplayErrorMessage( NULL, _( "Error loading project footprint library table." ) ); DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
} }
} }
@ -465,7 +465,6 @@ EDA_3D_VIEWER_FRAME* PCB_BASE_FRAME::CreateAndShow3D_Frame()
} }
// Note: virtual, overridden in PCB_EDIT_FRAME;
void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
{ {
PCB_LAYER_ID preslayer = GetActiveLayer(); PCB_LAYER_ID preslayer = GetActiveLayer();
@ -533,9 +532,6 @@ GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
} }
/*
* Display the grid status.
*/
void PCB_BASE_FRAME::DisplayGridMsg() void PCB_BASE_FRAME::DisplayGridMsg()
{ {
wxString line; wxString line;
@ -548,9 +544,6 @@ void PCB_BASE_FRAME::DisplayGridMsg()
} }
/*
* Update the status bar information.
*/
void PCB_BASE_FRAME::UpdateStatusBar() void PCB_BASE_FRAME::UpdateStatusBar()
{ {
EDA_DRAW_FRAME::UpdateStatusBar(); EDA_DRAW_FRAME::UpdateStatusBar();
@ -691,6 +684,7 @@ FOOTPRINT_EDITOR_SETTINGS* PCB_BASE_FRAME::GetFootprintEditorSettings() const
return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>(); return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
} }
MAGNETIC_SETTINGS* PCB_BASE_FRAME::GetMagneticItemsSettings() MAGNETIC_SETTINGS* PCB_BASE_FRAME::GetMagneticItemsSettings()
{ {
wxCHECK( m_settings, nullptr ); wxCHECK( m_settings, nullptr );

View File

@ -3,8 +3,8 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -289,12 +289,13 @@ void PCB_DIMENSION_BASE::Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight
} }
void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
std::vector<MSG_PANEL_ITEM>& aList )
{ {
// for now, display only the text within the DIMENSION using class PCB_TEXT. // for now, display only the text within the DIMENSION using class PCB_TEXT.
wxString msg; wxString msg;
wxCHECK_RET( m_parent != NULL, wxT( "PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) ); wxCHECK_RET( m_parent != nullptr, wxT( "PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) );
aList.emplace_back( _( "Dimension" ), m_text.GetShownText() ); aList.emplace_back( _( "Dimension" ), m_text.GetShownText() );
@ -436,9 +437,7 @@ const EDA_RECT PCB_DIMENSION_BASE::GetBoundingBox() const
wxString PCB_DIMENSION_BASE::GetSelectMenuText( EDA_UNITS aUnits ) const wxString PCB_DIMENSION_BASE::GetSelectMenuText( EDA_UNITS aUnits ) const
{ {
return wxString::Format( _( "Dimension '%s' on %s" ), return wxString::Format( _( "Dimension '%s' on %s" ), GetText(), GetLayerName() );
GetText(),
GetLayerName() );
} }
@ -471,6 +470,7 @@ OPT_VECTOR2I PCB_DIMENSION_BASE::segPolyIntersection( const SHAPE_POLY_SET& aPol
endpoint = *intersection; endpoint = *intersection;
} }
} }
if( start == endpoint ) if( start == endpoint )
return NULLOPT; return NULLOPT;
@ -529,6 +529,7 @@ void PCB_DIM_ALIGNED::SwapData( BOARD_ITEM* aImage )
Update(); Update();
} }
BITMAPS PCB_DIM_ALIGNED::GetMenuImage() const BITMAPS PCB_DIM_ALIGNED::GetMenuImage() const
{ {
return BITMAPS::add_aligned_dimension; return BITMAPS::add_aligned_dimension;
@ -830,6 +831,7 @@ void PCB_DIM_ORTHOGONAL::updateText()
int textOffsetDistance = m_text.GetEffectiveTextPenWidth() + m_text.GetTextHeight(); int textOffsetDistance = m_text.GetEffectiveTextPenWidth() + m_text.GetTextHeight();
VECTOR2I textOffset; VECTOR2I textOffset;
if( m_orientation == DIR::HORIZONTAL ) if( m_orientation == DIR::HORIZONTAL )
textOffset.y = -textOffsetDistance; textOffset.y = -textOffsetDistance;
else else
@ -847,6 +849,7 @@ void PCB_DIM_ORTHOGONAL::updateText()
if( m_keepTextAligned ) if( m_keepTextAligned )
{ {
double textAngle; double textAngle;
if( abs( crossbarCenter.x ) > abs( crossbarCenter.y ) ) if( abs( crossbarCenter.x ) > abs( crossbarCenter.y ) )
textAngle = 0; textAngle = 0;
else else

View File

@ -2,6 +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) 2014-2017 CERN * Copyright (C) 2014-2017 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -52,6 +53,7 @@
using namespace std::placeholders; using namespace std::placeholders;
const LAYER_NUM GAL_LAYER_ORDER[] = const LAYER_NUM GAL_LAYER_ORDER[] =
{ {
LAYER_GP_OVERLAY, LAYER_GP_OVERLAY,
@ -147,6 +149,7 @@ PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal ); m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal );
m_view->SetPainter( m_painter.get() ); m_view->SetPainter( m_painter.get() );
// This fixes the zoom in and zoom out limits: // This fixes the zoom in and zoom out limits:
m_view->SetScaleLimits( ZOOM_MAX_LIMIT_PCBNEW, ZOOM_MIN_LIMIT_PCBNEW ); m_view->SetScaleLimits( ZOOM_MAX_LIMIT_PCBNEW, ZOOM_MIN_LIMIT_PCBNEW );
@ -291,7 +294,8 @@ void PCB_DRAW_PANEL_GAL::SetHighContrastLayer( PCB_LAYER_ID aLayer )
LAYER_PAD_FR_NETNAMES, LAYER_PAD_BK_NETNAMES, LAYER_PAD_NETNAMES, LAYER_PAD_FR_NETNAMES, LAYER_PAD_BK_NETNAMES, LAYER_PAD_NETNAMES,
ZONE_LAYER_FOR( aLayer ), ZONE_LAYER_FOR( aLayer ),
LAYER_PADS_TH, LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES, LAYER_PADS_TH, LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES,
LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_HOLES, LAYER_VIA_HOLEWALLS, LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_HOLES,
LAYER_VIA_HOLEWALLS,
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS, LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS,
LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY,
LAYER_RATSNEST, LAYER_CURSOR, LAYER_ANCHOR LAYER_RATSNEST, LAYER_CURSOR, LAYER_ANCHOR
@ -325,7 +329,8 @@ void PCB_DRAW_PANEL_GAL::SetTopLayer( PCB_LAYER_ID aLayer )
// Layers that should always have on-top attribute enabled // Layers that should always have on-top attribute enabled
const std::vector<LAYER_NUM> layers = { const std::vector<LAYER_NUM> layers = {
LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_HOLES, LAYER_VIA_HOLEWALLS, LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_HOLES,
LAYER_VIA_HOLEWALLS,
LAYER_VIA_NETNAMES, LAYER_VIA_NETNAMES,
LAYER_PADS_TH, LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES, LAYER_PADS_TH, LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES,
LAYER_PAD_NETNAMES, LAYER_PAD_NETNAMES,
@ -348,7 +353,7 @@ void PCB_DRAW_PANEL_GAL::SetTopLayer( PCB_LAYER_ID aLayer )
LAYER_PAD_BK_NETNAMES, NETNAMES_LAYER_INDEX( B_Cu ) LAYER_PAD_BK_NETNAMES, NETNAMES_LAYER_INDEX( B_Cu )
}; };
const std::vector<LAYER_NUM>* extraLayers = NULL; const std::vector<LAYER_NUM>* extraLayers = nullptr;
// Bring a few more extra layers to the top depending on the selected board side // Bring a few more extra layers to the top depending on the selected board side
if( IsFrontLayer( aLayer ) ) if( IsFrontLayer( aLayer ) )
@ -479,7 +484,7 @@ void PCB_DRAW_PANEL_GAL::OnShow()
try try
{ {
// Check if the current rendering backend can be properly initialized // Check if the current rendering back end can be properly initialized
m_view->UpdateItems(); m_view->UpdateItems();
} }
catch( const std::runtime_error& e ) catch( const std::runtime_error& e )
@ -563,9 +568,13 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
m_view->SetRequired( GetNetnameLayer( layer ), layer ); m_view->SetRequired( GetNetnameLayer( layer ), layer );
} }
else if( IsNonCopperLayer( layer ) ) else if( IsNonCopperLayer( layer ) )
{
m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer ); m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
}
else if( IsNetnameLayer( layer ) ) else if( IsNetnameLayer( layer ) )
{
m_view->SetLayerDisplayOnly( layer ); m_view->SetLayerDisplayOnly( layer );
}
} }
m_view->SetLayerTarget( LAYER_ANCHOR, KIGFX::TARGET_NONCACHED ); m_view->SetLayerTarget( LAYER_ANCHOR, KIGFX::TARGET_NONCACHED );

View File

@ -176,9 +176,9 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
{ {
m_maximizeByDefault = true; m_maximizeByDefault = true;
m_showBorderAndTitleBlock = true; // true to display sheet references m_showBorderAndTitleBlock = true; // true to display sheet references
m_SelTrackWidthBox = NULL; m_SelTrackWidthBox = nullptr;
m_SelViaSizeBox = NULL; m_SelViaSizeBox = nullptr;
m_SelLayerBox = NULL; m_SelLayerBox = nullptr;
m_show_layer_manager_tools = true; m_show_layer_manager_tools = true;
m_hasAutoSave = true; m_hasAutoSave = true;
@ -429,7 +429,7 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
if( screen != NULL ) if( screen != nullptr )
{ {
drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) ); drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) );
drawingSheet->SetSheetCount( screen->GetPageCount() ); drawingSheet->SetSheetCount( screen->GetPageCount() );
@ -553,7 +553,7 @@ void PCB_EDIT_FRAME::setupUIConditions()
if( SCRIPTING::IsWxAvailable() ) if( SCRIPTING::IsWxAvailable() )
mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( cond.ScriptingConsoleVisible() ) ); mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( cond.ScriptingConsoleVisible() ) );
auto enableZoneControlConition = auto enableZoneControlConition =
[this] ( const SELECTION& ) [this] ( const SELECTION& )
{ {
@ -1279,6 +1279,7 @@ void PCB_EDIT_FRAME::UpdateUserInterface()
{ {
// Canonical name // Canonical name
layerEnum.Map( *seq, LSET::Name( *seq ) ); layerEnum.Map( *seq, LSET::Name( *seq ) );
// User name // User name
layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) ); layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
} }
@ -1511,7 +1512,7 @@ void PCB_EDIT_FRAME::PythonSyncEnvironmentVariables()
for( auto& var : vars ) for( auto& var : vars )
UpdatePythonEnvVar( var.first, var.second.GetValue() ); UpdatePythonEnvVar( var.first, var.second.GetValue() );
// Because the env vars can de modified by the python scripts (rewritten in UTF8), // Because the env vars can be modified by the python scripts (rewritten in UTF8),
// regenerate them (in Unicode) for our normal environment // regenerate them (in Unicode) for our normal environment
for( auto& var : vars ) for( auto& var : vars )
wxSetEnv( var.first, var.second.GetValue() ); wxSetEnv( var.first, var.second.GetValue() );
@ -1532,7 +1533,7 @@ void PCB_EDIT_FRAME::PythonSyncProjectName()
void PCB_EDIT_FRAME::ShowFootprintPropertiesDialog( FOOTPRINT* aFootprint ) void PCB_EDIT_FRAME::ShowFootprintPropertiesDialog( FOOTPRINT* aFootprint )
{ {
if( aFootprint == NULL ) if( aFootprint == nullptr )
return; return;
DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint ); DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint );

View File

@ -412,7 +412,7 @@ public:
* \a aStoreInNewLib as true. * \a aStoreInNewLib as true.
*/ */
void ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString, void ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString,
wxString* aLibPath = NULL ); wxString* aLibPath = nullptr );
/** /**
* Create a BOM file from the current loaded board. * Create a BOM file from the current loaded board.

View File

@ -771,7 +771,7 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
// Default font settings // Default font settings
m_gal->ResetTextAttributes(); m_gal->ResetTextAttributes();
m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) ); m_gal->SetStrokeColor( m_pcbSettings.GetColor( nullptr, aLayer ) );
// Set the text position to the pad shape position (the pad position is not the best place) // Set the text position to the pad shape position (the pad position is not the best place)
VECTOR2D textpos( 0.0, 0.0 ); VECTOR2D textpos( 0.0, 0.0 );
@ -1006,6 +1006,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->Restore(); m_gal->Restore();
} }
return; return;
} }
else if( aLayer == LAYER_PAD_HOLEWALLS ) else if( aLayer == LAYER_PAD_HOLEWALLS )
@ -1157,8 +1158,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( effectiveWidth > 0 ) if( effectiveWidth > 0 )
m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, effectiveWidth ); m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, effectiveWidth );
}
break; break;
}
case SH_CIRCLE: case SH_CIRCLE:
{ {
@ -1167,8 +1169,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( effectiveRadius > 0 ) if( effectiveRadius > 0 )
m_gal->DrawCircle( circle->GetCenter(), effectiveRadius ); m_gal->DrawCircle( circle->GetCenter(), effectiveRadius );
}
break; break;
}
case SH_RECT: case SH_RECT:
{ {
@ -1207,8 +1210,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
{ {
m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() ); m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
} }
}
break; break;
}
case SH_SIMPLE: case SH_SIMPLE:
{ {
@ -1242,8 +1246,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 ); m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
} }
} }
}
break; break;
}
default: default:
// Better not get here; we already pre-flighted the shapes... // Better not get here; we already pre-flighted the shapes...
@ -1360,6 +1365,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->DrawSegment( start, end, thickness ); m_gal->DrawSegment( start, end, thickness );
} }
break; break;
case PCB_SHAPE_TYPE::RECT: case PCB_SHAPE_TYPE::RECT:
@ -1397,8 +1403,9 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->DrawPolygon( poly ); m_gal->DrawPolygon( poly );
} }
} }
}
break; break;
}
case PCB_SHAPE_TYPE::ARC: case PCB_SHAPE_TYPE::ARC:
if( sketch ) if( sketch )
@ -1488,8 +1495,9 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
if( parentFootprint ) if( parentFootprint )
m_gal->Restore(); m_gal->Restore();
}
break; break;
}
case PCB_SHAPE_TYPE::CURVE: case PCB_SHAPE_TYPE::CURVE:
if( sketch ) if( sketch )
@ -1514,6 +1522,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
VECTOR2D( aShape->GetBezierC2() ), VECTOR2D( aShape->GetBezierC2() ),
VECTOR2D( aShape->GetEnd() ), thickness ); VECTOR2D( aShape->GetEnd() ), thickness );
} }
break; break;
case PCB_SHAPE_TYPE::LAST: case PCB_SHAPE_TYPE::LAST:

View File

@ -1,7 +1,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) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -70,7 +70,7 @@ static bool setInt( int* aTarget, int aValue, int aMin, int aMax )
temp = aMax; temp = aMax;
*aTarget = temp; *aTarget = temp;
return (temp == aValue); return ( temp == aValue );
} }
@ -84,10 +84,9 @@ static bool setDouble( double* aTarget, double aValue, double aMin, double aMax
temp = aMax; temp = aMax;
*aTarget = temp; *aTarget = temp;
return (temp == aValue); return ( temp == aValue );
} }
// PCB_PLOT_PARAMS
PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
{ {
@ -97,6 +96,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
m_includeGerberNetlistInfo = true; m_includeGerberNetlistInfo = true;
m_createGerberJobFile = true; m_createGerberJobFile = true;
m_gerberPrecision = gbrDefaultPrecision; m_gerberPrecision = gbrDefaultPrecision;
// we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm // we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm
m_svgPrecision = SVG_PRECISION_DEFAULT; m_svgPrecision = SVG_PRECISION_DEFAULT;
m_svgUseInch = false; m_svgUseInch = false;
@ -131,19 +131,22 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
m_layerSelection = LSET( 7, F_SilkS, B_SilkS, F_Mask, B_Mask, m_layerSelection = LSET( 7, F_SilkS, B_SilkS, F_Mask, B_Mask,
F_Paste, B_Paste, Edge_Cuts ) F_Paste, B_Paste, Edge_Cuts )
| LSET::AllCuMask(); | LSET::AllCuMask();
// This parameter controls if the NPTH pads will be plotted or not // This parameter controls if the NPTH pads will be plotted or not
// it is a "local" parameter // it is a "local" parameter
m_skipNPTH_Pads = false; m_skipNPTH_Pads = false;
m_sketchPadLineWidth = Millimeter2iu( 0.1 ); // line width to plot items in outline mode // line width to plot items in outline mode.
m_sketchPadLineWidth = Millimeter2iu( 0.1 );
m_default_colors = std::make_shared<COLOR_SETTINGS>(); m_default_colors = std::make_shared<COLOR_SETTINGS>();
m_colors = m_default_colors.get(); m_colors = m_default_colors.get();
} }
void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision ) void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision )
{ {
// Currently geber files use mm. // Currently Gerber files use mm.
// accepted precision is only 6 (max value, this is the resolution of Pcbnew) // accepted precision is only 6 (max value, this is the resolution of Pcbnew)
// or 5, min value for professional boards, when 6 creates problems // or 5, min value for professional boards, when 6 creates problems
// to board makers. // to board makers.
@ -152,13 +155,14 @@ void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision )
gbrDefaultPrecision; gbrDefaultPrecision;
} }
void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision, bool aUseInch ) void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision, bool aUseInch )
{ {
m_svgUseInch = aUseInch; m_svgUseInch = aUseInch;
m_svgPrecision = Clamp( SVG_PRECISION_MIN, aPrecision, SVG_PRECISION_MAX ); m_svgPrecision = Clamp( SVG_PRECISION_MIN, aPrecision, SVG_PRECISION_MAX );
} }
// PLEASE NOTE: only plot dialog options are processed
void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
int aNestLevel, int aControl ) const int aNestLevel, int aControl ) const
{ {
@ -185,8 +189,9 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_creategerberjobfile ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_creategerberjobfile ),
GetCreateGerberJobFile() ? trueStr : falseStr ); GetCreateGerberJobFile() ? trueStr : falseStr );
if( m_gerberPrecision != gbrDefaultPrecision ) // save this option only if it is not the default value, // save this option only if it is not the default value,
// to avoid incompatibility with older Pcbnew version // to avoid incompatibility with older Pcbnew version
if( m_gerberPrecision != gbrDefaultPrecision )
aFormatter->Print( aNestLevel+1, "(%s %d)\n", aFormatter->Print( aNestLevel+1, "(%s %d)\n",
getTokenName( T_gerberprecision ), m_gerberPrecision ); getTokenName( T_gerberprecision ), m_gerberPrecision );
@ -262,76 +267,112 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
{ {
if( m_layerSelection != aPcbPlotParams.m_layerSelection ) if( m_layerSelection != aPcbPlotParams.m_layerSelection )
return false; return false;
if( m_useGerberProtelExtensions != aPcbPlotParams.m_useGerberProtelExtensions ) if( m_useGerberProtelExtensions != aPcbPlotParams.m_useGerberProtelExtensions )
return false; return false;
if( m_gerberDisableApertMacros != aPcbPlotParams.m_gerberDisableApertMacros ) if( m_gerberDisableApertMacros != aPcbPlotParams.m_gerberDisableApertMacros )
return false; return false;
if( m_useGerberX2format != aPcbPlotParams.m_useGerberX2format ) if( m_useGerberX2format != aPcbPlotParams.m_useGerberX2format )
return false; return false;
if( m_includeGerberNetlistInfo != aPcbPlotParams.m_includeGerberNetlistInfo ) if( m_includeGerberNetlistInfo != aPcbPlotParams.m_includeGerberNetlistInfo )
return false; return false;
if( m_createGerberJobFile != aPcbPlotParams.m_createGerberJobFile ) if( m_createGerberJobFile != aPcbPlotParams.m_createGerberJobFile )
return false; return false;
if( m_gerberPrecision != aPcbPlotParams.m_gerberPrecision ) if( m_gerberPrecision != aPcbPlotParams.m_gerberPrecision )
return false; return false;
if( m_excludeEdgeLayer != aPcbPlotParams.m_excludeEdgeLayer ) if( m_excludeEdgeLayer != aPcbPlotParams.m_excludeEdgeLayer )
return false; return false;
if( m_plotFrameRef != aPcbPlotParams.m_plotFrameRef ) if( m_plotFrameRef != aPcbPlotParams.m_plotFrameRef )
return false; return false;
if( m_plotViaOnMaskLayer != aPcbPlotParams.m_plotViaOnMaskLayer ) if( m_plotViaOnMaskLayer != aPcbPlotParams.m_plotViaOnMaskLayer )
return false; return false;
if( m_plotMode != aPcbPlotParams.m_plotMode ) if( m_plotMode != aPcbPlotParams.m_plotMode )
return false; return false;
if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode ) if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode )
return false; return false;
if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits ) if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits )
return false; return false;
if( m_svgPrecision != aPcbPlotParams.m_svgPrecision ) if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
return false; return false;
if( m_svgUseInch != aPcbPlotParams.m_svgUseInch ) if( m_svgUseInch != aPcbPlotParams.m_svgUseInch )
return false; return false;
if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin ) if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin )
return false; return false;
if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum ) if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum )
return false; return false;
if( m_HPGLPenSpeed != aPcbPlotParams.m_HPGLPenSpeed ) if( m_HPGLPenSpeed != aPcbPlotParams.m_HPGLPenSpeed )
return false; return false;
if( m_HPGLPenDiam != aPcbPlotParams.m_HPGLPenDiam ) if( m_HPGLPenDiam != aPcbPlotParams.m_HPGLPenDiam )
return false; return false;
if( m_negative != aPcbPlotParams.m_negative ) if( m_negative != aPcbPlotParams.m_negative )
return false; return false;
if( m_A4Output != aPcbPlotParams.m_A4Output ) if( m_A4Output != aPcbPlotParams.m_A4Output )
return false; return false;
if( m_plotReference != aPcbPlotParams.m_plotReference ) if( m_plotReference != aPcbPlotParams.m_plotReference )
return false; return false;
if( m_plotValue != aPcbPlotParams.m_plotValue ) if( m_plotValue != aPcbPlotParams.m_plotValue )
return false; return false;
if( m_plotInvisibleText != aPcbPlotParams.m_plotInvisibleText ) if( m_plotInvisibleText != aPcbPlotParams.m_plotInvisibleText )
return false; return false;
if( m_sketchPadsOnFabLayers != aPcbPlotParams.m_sketchPadsOnFabLayers ) if( m_sketchPadsOnFabLayers != aPcbPlotParams.m_sketchPadsOnFabLayers )
return false; return false;
if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk ) if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk )
return false; return false;
if( m_format != aPcbPlotParams.m_format ) if( m_format != aPcbPlotParams.m_format )
return false; return false;
if( m_mirror != aPcbPlotParams.m_mirror ) if( m_mirror != aPcbPlotParams.m_mirror )
return false; return false;
if( m_drillMarks != aPcbPlotParams.m_drillMarks ) if( m_drillMarks != aPcbPlotParams.m_drillMarks )
return false; return false;
if( m_scaleSelection != aPcbPlotParams.m_scaleSelection ) if( m_scaleSelection != aPcbPlotParams.m_scaleSelection )
return false; return false;
if( m_autoScale != aPcbPlotParams.m_autoScale ) if( m_autoScale != aPcbPlotParams.m_autoScale )
return false; return false;
if( m_scale != aPcbPlotParams.m_scale ) if( m_scale != aPcbPlotParams.m_scale )
return false; return false;
if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX ) if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX )
return false; return false;
if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY ) if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY )
return false; return false;
if( m_widthAdjust != aPcbPlotParams.m_widthAdjust ) if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
return false; return false;
if( m_textMode != aPcbPlotParams.m_textMode ) if( m_textMode != aPcbPlotParams.m_textMode )
return false; return false;
if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) ) if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) )
return false; return false;
@ -351,8 +392,6 @@ bool PCB_PLOT_PARAMS::SetHPGLPenSpeed( int aValue )
} }
// PCB_PLOT_PARAMS_PARSER
PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) : PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) :
PCB_PLOT_PARAMS_LEXER( aReader ) PCB_PLOT_PARAMS_LEXER( aReader )
{ {
@ -385,29 +424,31 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
switch( token ) switch( token )
{ {
case T_layerselection: case T_layerselection:
{
token = NeedSYMBOLorNUMBER();
const std::string& cur = CurStr();
if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
{ {
token = NeedSYMBOLorNUMBER(); // It's not possible to convert a legacy Cu layer number to a new Cu layer
// number without knowing the number or total Cu layers in the legacy board.
const std::string& cur = CurStr(); // We do not have that information here, so simply set all layers ON. User
// can turn them off in the UI.
if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack. aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS ) | LSET::AllCuMask();
{
// It's not possible to convert a legacy Cu layer number to a new Cu layer
// number without knowing the number or total Cu layers in the legacy board.
// We do not have that information here, so simply set all layers ON. User
// can turn them off in the UI.
aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS)
| LSET::AllCuMask();
}
else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
{
// skip the leading 2 0x bytes.
aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str()+2, cur.size()-2 );
}
else
Expecting( "integer or hex layerSelection" );
} }
else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
{
// skip the leading 2 0x bytes.
aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str() + 2, cur.size() - 2 );
}
else
{
Expecting( "integer or hex layerSelection" );
}
break; break;
}
case T_disableapertmacros: case T_disableapertmacros:
aPcbPlotParams->m_gerberDisableApertMacros = parseBool(); aPcbPlotParams->m_gerberDisableApertMacros = parseBool();
@ -430,7 +471,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
break; break;
case T_gerberprecision: case T_gerberprecision:
aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision-1, aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision - 1,
gbrDefaultPrecision); gbrDefaultPrecision);
break; break;
@ -467,13 +508,11 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
break; break;
case T_hpglpennumber: case T_hpglpennumber:
aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN, aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN, HPGL_PEN_NUMBER_MAX );
HPGL_PEN_NUMBER_MAX );
break; break;
case T_hpglpenspeed: case T_hpglpenspeed:
aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN, aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX );
HPGL_PEN_SPEED_MAX );
break; break;
case T_hpglpendiameter: case T_hpglpendiameter:
@ -481,7 +520,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
break; break;
case T_hpglpenoverlay: case T_hpglpenoverlay:
// No more used. juste here for compatibility with old versions // No more used. just here for compatibility with old versions
parseInt( 0, HPGL_PEN_DIAMETER_MAX ); parseInt( 0, HPGL_PEN_DIAMETER_MAX );
break; break;
@ -599,7 +638,7 @@ double PCB_PLOT_PARAMS_PARSER::parseDouble()
if( token != T_NUMBER ) if( token != T_NUMBER )
Expecting( T_NUMBER ); Expecting( T_NUMBER );
double val = strtod( CurText(), NULL ); double val = strtod( CurText(), nullptr );
return val; return val;
} }

View File

@ -3,8 +3,8 @@
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -104,7 +104,7 @@ double PCB_SHAPE::GetLength() const
default: default:
wxASSERT_MSG( false, "PCB_SHAPE::GetLength not implemented for shape" wxASSERT_MSG( false, "PCB_SHAPE::GetLength not implemented for shape"
+ ShowShape( GetShape() ) ); + ShowShape( GetShape() ) );
break; break;
} }
@ -188,8 +188,8 @@ void PCB_SHAPE::Scale( double aScale )
} }
SetPolyPoints( pts ); SetPolyPoints( pts );
}
break; break;
}
default: default:
break; break;
@ -400,7 +400,7 @@ wxPoint PCB_SHAPE::GetArcMid() const
case PCB_SHAPE_TYPE::ARC: case PCB_SHAPE_TYPE::ARC:
// rotate the starting point of the arc, given by m_End, through half // rotate the starting point of the arc, given by m_End, through half
// the angle m_Angle to get the middle of the arc. // the angle m_Angle to get the middle of the arc.
// m_Start is the arc centre // m_Start is the arc center
endPoint = m_end; // m_End = start point of arc endPoint = m_end; // m_End = start point of arc
RotatePoint( &endPoint, m_start, -m_angle / 2.0 ); RotatePoint( &endPoint, m_start, -m_angle / 2.0 );
break; break;
@ -420,13 +420,14 @@ double PCB_SHAPE::GetArcAngleStart() const
GetArcStart().x - GetCenter().x ); GetArcStart().x - GetCenter().x );
// Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
// because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg. // because 180 deg and -180 are very near angles when mapping between -180 ... 180 deg.
// and this is not easy to handle in calculations // and this is not easy to handle in calculations
NORMALIZE_ANGLE_POS( angleStart ); NORMALIZE_ANGLE_POS( angleStart );
return angleStart; return angleStart;
} }
double PCB_SHAPE::GetArcAngleEnd() const double PCB_SHAPE::GetArcAngleEnd() const
{ {
// due to the Y axis orient atan2 needs - y value // due to the Y axis orient atan2 needs - y value
@ -434,7 +435,7 @@ double PCB_SHAPE::GetArcAngleEnd() const
GetArcEnd().x - GetCenter().x ); GetArcEnd().x - GetCenter().x );
// Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
// because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg. // because 180 deg and -180 are very near angles when mapping between -180 ... 180 deg.
// and this is not easy to handle in calculations // and this is not easy to handle in calculations
NORMALIZE_ANGLE_POS( angleStart ); NORMALIZE_ANGLE_POS( angleStart );
@ -490,7 +491,7 @@ void PCB_SHAPE::SetAngle( double aAngle, bool aUpdateEnd )
FOOTPRINT* PCB_SHAPE::GetParentFootprint() const FOOTPRINT* PCB_SHAPE::GetParentFootprint() const
{ {
if( !m_parent || m_parent->Type() != PCB_FOOTPRINT_T ) if( !m_parent || m_parent->Type() != PCB_FOOTPRINT_T )
return NULL; return nullptr;
return (FOOTPRINT*) m_parent; return (FOOTPRINT*) m_parent;
} }
@ -593,8 +594,9 @@ const EDA_RECT PCB_SHAPE::GetBoundingBox() const
for( wxPoint& pt : pts ) for( wxPoint& pt : pts )
bbox.Merge( pt ); bbox.Merge( pt );
}
break; break;
}
case PCB_SHAPE_TYPE::SEGMENT: case PCB_SHAPE_TYPE::SEGMENT:
bbox.SetEnd( m_end ); bbox.SetEnd( m_end );
@ -628,8 +630,9 @@ const EDA_RECT PCB_SHAPE::GetBoundingBox() const
bbox.Merge( pt ); bbox.Merge( pt );
} }
}
break; break;
}
case PCB_SHAPE_TYPE::CURVE: case PCB_SHAPE_TYPE::CURVE:
bbox.Merge( m_bezierC1 ); bbox.Merge( m_bezierC1 );
@ -671,8 +674,9 @@ bool PCB_SHAPE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
if( abs( radius - dist ) <= maxdist ) if( abs( radius - dist ) <= maxdist )
return true; return true;
} }
}
break; break;
}
case PCB_SHAPE_TYPE::ARC: case PCB_SHAPE_TYPE::ARC:
{ {
@ -685,7 +689,7 @@ bool PCB_SHAPE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
// For arcs, the test point angle must be >= arc angle start // For arcs, the test point angle must be >= arc angle start
// and <= arc angle end // and <= arc angle end
// However angle values > 360 deg are not easy to handle // However angle values > 360 deg are not easy to handle
// so we calculate the relative angle between arc start point and teast point // so we calculate the relative angle between arc start point and test point
// this relative arc should be < arc angle if arc angle > 0 (CW arc) // this relative arc should be < arc angle if arc angle > 0 (CW arc)
// and > arc angle if arc angle < 0 (CCW arc) // and > arc angle if arc angle < 0 (CCW arc)
double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
@ -695,7 +699,7 @@ bool PCB_SHAPE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
// Calculate relative angle between the starting point of the arc, and the test point // Calculate relative angle between the starting point of the arc, and the test point
arc_hittest -= arc_angle_start; arc_hittest -= arc_angle_start;
// Normalise arc_hittest between 0 ... 360 deg // Normalize arc_hittest between 0 ... 360 deg
NORMALIZE_ANGLE_POS( arc_hittest ); NORMALIZE_ANGLE_POS( arc_hittest );
// Check angle: inside the arc angle when it is > 0 // Check angle: inside the arc angle when it is > 0
@ -711,8 +715,9 @@ bool PCB_SHAPE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
return true; return true;
} }
} }
}
break; break;
}
case PCB_SHAPE_TYPE::CURVE: case PCB_SHAPE_TYPE::CURVE:
const_cast<PCB_SHAPE*>( this )->RebuildBezierToSegmentsPointsList( m_width ); const_cast<PCB_SHAPE*>( this )->RebuildBezierToSegmentsPointsList( m_width );
@ -756,8 +761,9 @@ bool PCB_SHAPE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
return true; return true;
} }
} }
}
break; break;
}
case PCB_SHAPE_TYPE::POLYGON: case PCB_SHAPE_TYPE::POLYGON:
if( IsFilled() ) if( IsFilled() )
@ -796,7 +802,9 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
case PCB_SHAPE_TYPE::CIRCLE: case PCB_SHAPE_TYPE::CIRCLE:
// Test if area intersects or contains the circle: // Test if area intersects or contains the circle:
if( aContained ) if( aContained )
{
return arect.Contains( bb ); return arect.Contains( bb );
}
else else
{ {
// If the rectangle does not intersect the bounding box, this is a much quicker test // If the rectangle does not intersect the bounding box, this is a much quicker test
@ -809,6 +817,7 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() ); return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
} }
} }
break; break;
case PCB_SHAPE_TYPE::ARC: case PCB_SHAPE_TYPE::ARC:
@ -817,9 +826,9 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
{ {
return arect.Contains( bb ); return arect.Contains( bb );
} }
// Test if the rect crosses the arc
else else
{ {
// Test if the rect crosses the arc
arcRect = bb.Common( arect ); arcRect = bb.Common( arect );
/* All following tests must pass: /* All following tests must pass:
@ -829,6 +838,7 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
return arcRect.Intersects( arect ) && return arcRect.Intersects( arect ) &&
arcRect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() ); arcRect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
} }
break; break;
case PCB_SHAPE_TYPE::RECT: case PCB_SHAPE_TYPE::RECT:
@ -910,6 +920,7 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
return true; return true;
} }
} }
break; break;
case PCB_SHAPE_TYPE::CURVE: case PCB_SHAPE_TYPE::CURVE:
@ -942,8 +953,8 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
return true; return true;
} }
} }
break;
break;
default: default:
wxFAIL_MSG( "PCB_SHAPE::HitTest (rect) not implemented for " wxFAIL_MSG( "PCB_SHAPE::HitTest (rect) not implemented for "
@ -957,9 +968,7 @@ bool PCB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
wxString PCB_SHAPE::GetSelectMenuText( EDA_UNITS aUnits ) const wxString PCB_SHAPE::GetSelectMenuText( EDA_UNITS aUnits ) const
{ {
return wxString::Format( _( "%s on %s" ), return wxString::Format( _( "%s on %s" ), ShowShape( m_shape ), GetLayerName() );
ShowShape( m_shape ),
GetLayerName() );
} }
@ -1141,8 +1150,9 @@ std::vector<SHAPE*> PCB_SHAPE::MakeEffectiveShapes() const
effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_width ) ); effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_width ) );
effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_width ) ); effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_width ) );
} }
}
break; break;
}
case PCB_SHAPE_TYPE::CIRCLE: case PCB_SHAPE_TYPE::CIRCLE:
{ {
@ -1203,8 +1213,9 @@ std::vector<SHAPE*> PCB_SHAPE::MakeEffectiveShapes() const
for( int i = 0; i < l.SegmentCount(); i++ ) for( int i = 0; i < l.SegmentCount(); i++ )
effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ), m_width ) ); effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ), m_width ) );
} }
}
break; break;
}
default: default:
wxFAIL_MSG( "PCB_SHAPE::MakeEffectiveShapes unsupported PCB_SHAPE shape: " wxFAIL_MSG( "PCB_SHAPE::MakeEffectiveShapes unsupported PCB_SHAPE shape: "
@ -1285,7 +1296,8 @@ void PCB_SHAPE::SwapData( BOARD_ITEM* aImage )
} }
bool PCB_SHAPE::cmp_drawings::operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const bool PCB_SHAPE::cmp_drawings::operator()( const BOARD_ITEM* aFirst,
const BOARD_ITEM* aSecond ) const
{ {
if( aFirst->Type() != aSecond->Type() ) if( aFirst->Type() != aSecond->Type() )
return aFirst->Type() < aSecond->Type(); return aFirst->Type() < aSecond->Type();

View File

@ -42,7 +42,7 @@ class MSG_PANEL_ITEM;
class PCB_SHAPE : public BOARD_ITEM class PCB_SHAPE : public BOARD_ITEM
{ {
public: public:
PCB_SHAPE( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_SHAPE_T ); PCB_SHAPE( BOARD_ITEM* aParent = nullptr, KICAD_T idtype = PCB_SHAPE_T );
// Do not create a copy constructor & operator=. // Do not create a copy constructor & operator=.
// The ones generated by the compiler are adequate. // The ones generated by the compiler are adequate.
@ -139,8 +139,7 @@ public:
void SetEndX( int x ) { m_end.x = x; } void SetEndX( int x ) { m_end.x = x; }
/** /**
* Function GetThirdPoint * Return the third point of the graphic.
* returns the third point point of the graphic
*/ */
const wxPoint& GetThirdPoint() const { return m_thirdPoint; } const wxPoint& GetThirdPoint() const { return m_thirdPoint; }
int GetThirdPointY() { return m_thirdPoint.y; } int GetThirdPointY() { return m_thirdPoint.y; }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -74,7 +74,8 @@ static struct IFACE : public KIFACE_I
void OnKifaceEnd() override; void OnKifaceEnd() override;
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
int aCtlBits = 0 ) override
{ {
switch( aClassId ) switch( aClassId )
{ {
@ -136,12 +137,14 @@ static struct IFACE : public KIFACE_I
} }
/** /**
* Function IfaceOrAddress * Return a pointer to the requested object.
* return a pointer to the requested object. The safest way to use this is to retrieve *
* a pointer to a static instance of an interface, similar to how the KIFACE interface * The safest way to use this is to retrieve a pointer to a static instance of an interface,
* is exported. But if you know what you are doing use it to retrieve anything you want. * similar to how the KIFACE interface is exported. But if you know what you are doing use
* it to retrieve anything you want.
*
* @param aDataId identifies which object you want the address of. * @param aDataId identifies which object you want the address of.
* @return void* - and must be cast into the know type. * @return the object which must be cast into the know type.
*/ */
void* IfaceOrAddress( int aDataId ) override void* IfaceOrAddress( int aDataId ) override
{ {
@ -168,7 +171,6 @@ static struct IFACE : public KIFACE_I
} }
/** /**
* Function SaveFileAs
* Saving a file under a different name is delegated to the various KIFACEs because * Saving a file under a different name is delegated to the various KIFACEs because
* the project doesn't know the internal format of the various files (which may have * the project doesn't know the internal format of the various files (which may have
* paths in them that need updating). * paths in them that need updating).
@ -181,6 +183,7 @@ static struct IFACE : public KIFACE_I
} // namespace } // namespace
using namespace PCB; using namespace PCB;
@ -198,6 +201,7 @@ MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BAS
return &kiface; return &kiface;
} }
#if defined( BUILD_KIWAY_DLL ) #if defined( BUILD_KIWAY_DLL )
PGM_BASE& Pgm() PGM_BASE& Pgm()
{ {
@ -205,6 +209,7 @@ PGM_BASE& Pgm()
return *process; return *process;
} }
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. // Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull() PGM_BASE* PgmOrNull()
{ {
@ -212,6 +217,7 @@ PGM_BASE* PgmOrNull()
} }
#endif #endif
/// The global footprint library table. This is not dynamically allocated because /// The global footprint library table. This is not dynamically allocated because
/// in a multiple project environment we must keep its address constant (since it is /// in a multiple project environment we must keep its address constant (since it is
/// the fallback table for multiple projects). /// the fallback table for multiple projects).
@ -223,7 +229,6 @@ FP_LIB_TABLE GFootprintTable;
FOOTPRINT_LIST_IMPL GFootprintList; FOOTPRINT_LIST_IMPL GFootprintList;
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
{ {
// This is process-level-initialization, not project-level-initialization of the DSO. // This is process-level-initialization, not project-level-initialization of the DSO.
@ -237,7 +242,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
if( !fn.FileExists() ) if( !fn.FileExists() )
{ {
DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG fpDialog( NULL ); DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG fpDialog( nullptr );
fpDialog.ShowModal(); fpDialog.ShowModal();
} }
@ -261,7 +266,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
"Please edit this global footprint library table in Preferences menu." "Please edit this global footprint library table in Preferences menu."
); );
DisplayErrorMessage( NULL, msg, ioe.What() ); DisplayErrorMessage( nullptr, msg, ioe.What() );
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -260,10 +260,12 @@ static const wxString GetGerberFilePolarityAttribute( LAYER_NUM aLayer )
return filePolarity; return filePolarity;
} }
/* Add some X2 attributes to the file header, as defined in the /* Add some X2 attributes to the file header, as defined in the
* Gerber file format specification J4 and "Revision 2015.06" * Gerber file format specification J4 and "Revision 2015.06"
*/ */
// A helper function to convert a X2 attribute string to a X1 structured comment: // A helper function to convert a X2 attribute string to a X1 structured comment:
static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMode ) static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMode )
{ {
@ -295,9 +297,9 @@ void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard, bool aUseX1Compa
// Creates the TF,.ProjectId. Format is (from Gerber file format doc): // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
// %TF.ProjectId,<project id>,<project GUID>,<revision id>*% // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
// <project id> is the name of the project, restricted to basic ASCII symbols only, // <project id> is the name of the project, restricted to basic ASCII symbols only,
// Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files). // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in
// and comma not accepted // gerber files) and comma not accepted.
// All illegal chars will be replaced by underscore // All illegal chars will be replaced by underscore.
// //
// <project GUID> is a string which is an unique id of a project. // <project GUID> is a string which is an unique id of a project.
// However Kicad does not handle such a project GUID, so it is built from the board name // However Kicad does not handle such a project GUID, so it is built from the board name
@ -348,8 +350,8 @@ void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard, bool aUseX1Compa
} }
void AddGerberX2Attribute( PLOTTER* aPlotter, void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard, LAYER_NUM aLayer,
const BOARD* aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode ) bool aUseX1CompatibilityMode )
{ {
AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode ); AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode );
@ -401,7 +403,7 @@ void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir,
PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD* aBoard ) PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD* aBoard )
{ {
m_plotter = NULL; m_plotter = nullptr;
m_board = aBoard; m_board = aBoard;
m_plotLayer = UNDEFINED_LAYER; m_plotLayer = UNDEFINED_LAYER;
} }
@ -416,7 +418,6 @@ PLOT_CONTROLLER::~PLOT_CONTROLLER()
/* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as
* C/POSIX using a LOCALE_IO object on the stack. This even when * C/POSIX using a LOCALE_IO object on the stack. This even when
* opening/closing the plotfile, since some drivers do I/O even then */ * opening/closing the plotfile, since some drivers do I/O even then */
void PLOT_CONTROLLER::ClosePlot() void PLOT_CONTROLLER::ClosePlot()
{ {
LOCALE_IO toggle; LOCALE_IO toggle;
@ -428,13 +429,13 @@ void PLOT_CONTROLLER::ClosePlot()
delete m_plotter->RenderSettings(); delete m_plotter->RenderSettings();
delete m_plotter; delete m_plotter;
m_plotter = NULL; m_plotter = nullptr;
} }
} }
bool PLOT_CONTROLLER::OpenPlotfile( bool PLOT_CONTROLLER::OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat,
const wxString& aSuffix, PLOT_FORMAT aFormat, const wxString& aSheetDesc ) const wxString& aSheetDesc )
{ {
LOCALE_IO toggle; LOCALE_IO toggle;
@ -472,7 +473,7 @@ bool PLOT_CONTROLLER::OpenPlotfile(
m_plotFile.GetFullPath(), aSheetDesc ); m_plotFile.GetFullPath(), aSheetDesc );
} }
return( m_plotter != NULL ); return ( m_plotter != nullptr );
} }

View File

@ -8,7 +8,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) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -207,11 +207,12 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
} }
/* /**
* Plot a copper layer or mask. * Plot a copper layer or mask.
*
* Silk screen layers are not plotted here. * Silk screen layers are not plotted here.
*/ */
void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
const PCB_PLOT_PARAMS& aPlotOpt ) const PCB_PLOT_PARAMS& aPlotOpt )
{ {
BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt ); BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
@ -240,7 +241,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// Plot footprint pads // Plot footprint pads
for( FOOTPRINT* footprint : aBoard->Footprints() ) for( FOOTPRINT* footprint : aBoard->Footprints() )
{ {
aPlotter->StartBlock( NULL ); aPlotter->StartBlock( nullptr );
for( PAD* pad : footprint->Pads() ) for( PAD* pad : footprint->Pads() )
{ {
@ -368,7 +369,8 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// which can create bad shapes if margin.x is < 0 // which can create bad shapes if margin.x is < 0
int maxError = aBoard->GetDesignSettings().m_MaxError; int maxError = aBoard->GetDesignSettings().m_MaxError;
int numSegs = GetArcToSegmentCount( mask_clearance, maxError, 360.0 ); int numSegs = GetArcToSegmentCount( mask_clearance, maxError, 360.0 );
outline.InflateWithLinkedHoles( mask_clearance, numSegs, SHAPE_POLY_SET::PM_FAST ); outline.InflateWithLinkedHoles( mask_clearance, numSegs,
SHAPE_POLY_SET::PM_FAST );
dummy.DeletePrimitivesList(); dummy.DeletePrimitivesList();
dummy.AddPrimitivePoly( outline, 0, true ); dummy.AddPrimitivePoly( outline, 0, true );
@ -391,8 +393,8 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
pad->SetRoundRectCornerRadius( std::max( initial_radius + mask_clearance, 0 ) ); pad->SetRoundRectCornerRadius( std::max( initial_radius + mask_clearance, 0 ) );
itemplotter.PlotPad( pad, color, padPlotMode ); itemplotter.PlotPad( pad, color, padPlotMode );
}
break; break;
}
case PAD_SHAPE::CHAMFERED_RECT: case PAD_SHAPE::CHAMFERED_RECT:
if( mask_clearance == 0 ) if( mask_clearance == 0 )
@ -417,7 +419,8 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
int numSegs = GetArcToSegmentCount( mask_clearance, maxError, 360.0 ); int numSegs = GetArcToSegmentCount( mask_clearance, maxError, 360.0 );
dummy.TransformShapeWithClearanceToPolygon( outline, UNDEFINED_LAYER, 0, dummy.TransformShapeWithClearanceToPolygon( outline, UNDEFINED_LAYER, 0,
maxError, ERROR_INSIDE ); maxError, ERROR_INSIDE );
outline.InflateWithLinkedHoles( mask_clearance, numSegs, SHAPE_POLY_SET::PM_FAST ); outline.InflateWithLinkedHoles( mask_clearance, numSegs,
SHAPE_POLY_SET::PM_FAST );
// Initialize the dummy pad shape: // Initialize the dummy pad shape:
dummy.SetAnchorPadShape( PAD_SHAPE::CIRCLE ); dummy.SetAnchorPadShape( PAD_SHAPE::CIRCLE );
@ -434,6 +437,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
itemplotter.PlotPad( &dummy, color, padPlotMode ); itemplotter.PlotPad( &dummy, color, padPlotMode );
} }
break; break;
case PAD_SHAPE::CUSTOM: case PAD_SHAPE::CUSTOM:
@ -443,6 +447,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
PAD dummy( *pad ); PAD dummy( *pad );
SHAPE_POLY_SET shape; SHAPE_POLY_SET shape;
pad->MergePrimitivesAsPolygon( &shape, UNDEFINED_LAYER ); pad->MergePrimitivesAsPolygon( &shape, UNDEFINED_LAYER );
// Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate() // Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
// which can create bad shapes if margin.x is < 0 // which can create bad shapes if margin.x is < 0
int maxError = aBoard->GetDesignSettings().m_MaxError; int maxError = aBoard->GetDesignSettings().m_MaxError;
@ -458,9 +463,9 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
dummy.SetSize( padPlotsSize ); dummy.SetSize( padPlotsSize );
itemplotter.PlotPad( &dummy, color, padPlotMode ); itemplotter.PlotPad( &dummy, color, padPlotMode );
}
break; break;
} }
}
// Restore the pad parameters modified by the plot code // Restore the pad parameters modified by the plot code
pad->SetSize( padSize ); pad->SetSize( padSize );
@ -469,7 +474,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
pad->SetRoundRectCornerRadius( padCornerRadius ); pad->SetRoundRectCornerRadius( padCornerRadius );
} }
aPlotter->EndBlock( NULL ); aPlotter->EndBlock( nullptr );
} }
// Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true, // Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true,
@ -485,7 +490,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET ); gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
} }
aPlotter->StartBlock( NULL ); aPlotter->StartBlock( nullptr );
for( const PCB_TRACK* track : aBoard->Tracks() ) for( const PCB_TRACK* track : aBoard->Tracks() )
{ {
@ -539,14 +544,15 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
COLOR4D color = aPlotOpt.ColorSettings()->GetColor( COLOR4D color = aPlotOpt.ColorSettings()->GetColor(
LAYER_VIAS + static_cast<int>( via->GetViaType() ) ); LAYER_VIAS + static_cast<int>( via->GetViaType() ) );
// Set plot color (change WHITE to LIGHTGRAY because the white items are not seen on a // Set plot color (change WHITE to LIGHTGRAY because the white items are not seen on a
// white paper or screen // white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY ); aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY );
aPlotter->FlashPadCircle( via->GetStart(), diameter, plotMode, &gbr_metadata ); aPlotter->FlashPadCircle( via->GetStart(), diameter, plotMode, &gbr_metadata );
} }
aPlotter->EndBlock( NULL ); aPlotter->EndBlock( nullptr );
aPlotter->StartBlock( NULL ); aPlotter->StartBlock( nullptr );
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
// Plot tracks (not vias) : // Plot tracks (not vias) :
@ -582,13 +588,12 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode, aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode,
&gbr_metadata ); &gbr_metadata );
} }
} }
aPlotter->EndBlock( NULL ); aPlotter->EndBlock( nullptr );
// Plot filled ares // Plot filled ares
aPlotter->StartBlock( NULL ); aPlotter->StartBlock( nullptr );
NETINFO_ITEM nonet( aBoard ); NETINFO_ITEM nonet( aBoard );
@ -622,7 +627,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
} }
} }
aPlotter->EndBlock( NULL ); aPlotter->EndBlock( nullptr );
// Adding drill marks, if required and if the plotter is able to plot them: // Adding drill marks, if required and if the plotter is able to plot them:
if( aPlotOpt.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE ) if( aPlotOpt.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE )
@ -689,8 +694,8 @@ static const PCB_LAYER_ID plot_seq[] = {
}; };
/* /**
* Plot outlines of copper, for copper layer * Plot outlines of copper layer.
*/ */
void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask, void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
const PCB_PLOT_PARAMS& aPlotOpt ) const PCB_PLOT_PARAMS& aPlotOpt )
@ -718,7 +723,8 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
for( int kk = 0; kk <= outlines.HoleCount(ii); kk++ ) for( int kk = 0; kk <= outlines.HoleCount(ii); kk++ )
{ {
cornerList.clear(); cornerList.clear();
const SHAPE_LINE_CHAIN& path = (kk == 0) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 ); const SHAPE_LINE_CHAIN& path =
( kk == 0 ) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 );
aPlotter->PlotPoly( path, FILL_TYPE::NO_FILL ); aPlotter->PlotPoly( path, FILL_TYPE::NO_FILL );
} }
@ -750,7 +756,7 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
const SHAPE_SEGMENT* seg = pad->GetEffectiveHoleShape(); const SHAPE_SEGMENT* seg = pad->GetEffectiveHoleShape();
aPlotter->ThickSegment( (wxPoint) seg->GetSeg().A, aPlotter->ThickSegment( (wxPoint) seg->GetSeg().A,
(wxPoint) seg->GetSeg().B, (wxPoint) seg->GetSeg().B,
seg->GetWidth(), SKETCH, NULL ); seg->GetWidth(), SKETCH, nullptr );
} }
} }
} }
@ -770,7 +776,9 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
} }
/* Plot a solder mask layer. /**
* Plot a solder mask layer.
*
* Solder mask layers have a minimum thickness value and cannot be drawn like standard layers, * Solder mask layers have a minimum thickness value and cannot be drawn like standard layers,
* unless the minimum thickness is 0. * unless the minimum thickness is 0.
* Currently the algo is: * Currently the algo is:
@ -845,6 +853,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// inflate value to build final polygons // inflate value to build final polygons
// After calculations the remaining polygons are polygons to plot // After calculations the remaining polygons are polygons to plot
SHAPE_POLY_SET areas; SHAPE_POLY_SET areas;
// Will contain exact shapes of all items on solder mask // Will contain exact shapes of all items on solder mask
SHAPE_POLY_SET initialPolys; SHAPE_POLY_SET initialPolys;
@ -914,6 +923,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// add shapes inflated by aMinThickness/2 in areas // add shapes inflated by aMinThickness/2 in areas
zone->TransformSmoothedOutlineToPolygon( areas, inflate + zone_margin, boardOutline ); zone->TransformSmoothedOutlineToPolygon( areas, inflate + zone_margin, boardOutline );
// add shapes with their exact mask layer size in initialPolys // add shapes with their exact mask layer size in initialPolys
zone->TransformSmoothedOutlineToPolygon( initialPolys, zone_margin, boardOutline ); zone->TransformSmoothedOutlineToPolygon( initialPolys, zone_margin, boardOutline );
} }
@ -935,6 +945,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
ZONE zone( aBoard ); ZONE zone( aBoard );
zone.SetMinThickness( 0 ); // trace polygons only zone.SetMinThickness( 0 ); // trace polygons only
zone.SetLayer( layer ); zone.SetLayer( layer );
// Combine the current areas to initial areas. This is mandatory because inflate/deflate // Combine the current areas to initial areas. This is mandatory because inflate/deflate
// transform is not perfect, and we want the initial areas perfectly kept // transform is not perfect, and we want the initial areas perfectly kept
areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST ); areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST );
@ -1059,8 +1070,10 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard,
aPlotter->SetPageSettings( *sheet_info ); aPlotter->SetPageSettings( *sheet_info );
aPlotter->SetViewport( offset, IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() ); aPlotter->SetViewport( offset, IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() );
// Has meaning only for gerber plotter. Must be called only after SetViewport // Has meaning only for gerber plotter. Must be called only after SetViewport
aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() ); aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() );
// Has meaning only for SVG plotter. Must be called only after SetViewport // Has meaning only for SVG plotter. Must be called only after SetViewport
aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision(), aPlotOpts->GetSvgUseInch() ); aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision(), aPlotOpts->GetSvgUseInch() );
@ -1104,13 +1117,14 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS
/** /**
* Open a new plotfile using the options (and especially the format) specified in the options * Open a new plotfile using the options (and especially the format) specified in the options
* and prepare the page for plotting. * and prepare the page for plotting.
* Return the plotter object if OK, NULL if the file is not created (or has a problem) *
* @return the plotter object if OK, NULL if the file is not created (or has a problem).
*/ */
PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer,
const wxString& aFullFileName, const wxString& aSheetDesc ) const wxString& aFullFileName, const wxString& aSheetDesc )
{ {
// Create the plotter driver and set the few plotter specific options // Create the plotter driver and set the few plotter specific options
PLOTTER* plotter = NULL; PLOTTER* plotter = nullptr;
switch( aPlotOpts->GetFormat() ) switch( aPlotOpts->GetFormat() )
{ {
@ -1153,7 +1167,7 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL
default: default:
wxASSERT( false ); wxASSERT( false );
return NULL; return nullptr;
} }
KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS(); KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS();
@ -1216,5 +1230,5 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL
delete plotter->RenderSettings(); delete plotter->RenderSettings();
delete plotter; delete plotter;
return NULL; return nullptr;
} }

View File

@ -1,7 +1,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) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -69,10 +69,6 @@
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
/* class BRDITEMS_PLOTTER is a helper class to plot board items
* and a group of board items
*/
COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer ) const COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer ) const
{ {
COLOR4D color = ColorSettings()->GetColor( aLayer ); COLOR4D color = ColorSettings()->GetColor( aLayer );
@ -105,6 +101,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, COLOR4D aColor, OUTLINE_MODE aP
{ {
gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL ); gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
gbr_metadata.SetCopper( true ); gbr_metadata.SetCopper( true );
// Gives a default attribute, for instance for pads used as tracks in net ties: // Gives a default attribute, for instance for pads used as tracks in net ties:
// Connector pads and SMD pads are on external layers // Connector pads and SMD pads are on external layers
// if on internal layers, they are certainly used as net tie // if on internal layers, they are certainly used as net tie
@ -160,7 +157,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, COLOR4D aColor, OUTLINE_MODE aP
break; break;
case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only) case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
// with solder paste and mask // with solder paste and mask
if( plotOnExternalCopperLayer ) if( plotOnExternalCopperLayer )
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF ); gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
break; break;
@ -336,7 +333,6 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
} }
// plot items like text and graphics, but not tracks and footprints
void BRDITEMS_PLOTTER::PlotBoardGraphicItems() void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
{ {
for( BOARD_ITEM* item : m_board->Drawings() ) for( BOARD_ITEM* item : m_board->Drawings() )
@ -516,7 +512,6 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire )
} }
// Plot footprints graphic items (outlines)
void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
{ {
for( const BOARD_ITEM* item : aFootprint->GraphicalItems() ) for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
@ -529,7 +524,6 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
} }
//* Plot a graphic item (outline) relative to a footprint
void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape ) void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape )
{ {
if( aShape->Type() != PCB_FP_SHAPE_T ) if( aShape->Type() != PCB_FP_SHAPE_T )
@ -676,6 +670,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape )
} }
} }
} }
break; break;
case PCB_SHAPE_TYPE::CURVE: case PCB_SHAPE_TYPE::CURVE:
@ -690,7 +685,6 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape )
} }
// Plot a PCB Text, i.e. a text found on a copper or technical layer
void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText ) void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
{ {
wxString shownText( aText->GetShownText() ); wxString shownText( aText->GetShownText() );
@ -818,8 +812,8 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, const SHAPE_POLY_SET&
} }
} }
static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline,
outline, &gbr_metadata ); &gbr_metadata );
} }
else else
{ {
@ -859,8 +853,6 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, const SHAPE_POLY_SET&
} }
/* Plot items type PCB_SHAPE on layers allowed by aLayerMask
*/
void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape ) void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
{ {
if( !m_layerMask[aShape->GetLayer()] ) if( !m_layerMask[aShape->GetLayer()] )
@ -941,6 +933,7 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
if( !sketch && aShape->IsFilled() ) if( !sketch && aShape->IsFilled() )
{ {
m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata ); m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
// Draw the polygon: only one polygon is expected // Draw the polygon: only one polygon is expected
// However we provide a multi polygon shape drawing // However we provide a multi polygon shape drawing
// ( for the future or to show a non expected shape ) // ( for the future or to show a non expected shape )
@ -979,8 +972,9 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
m_plotter->PlotPoly( poly, FILL_TYPE::FILLED_SHAPE, -1, &gbr_metadata ); m_plotter->PlotPoly( poly, FILL_TYPE::FILLED_SHAPE, -1, &gbr_metadata );
} }
}
break; break;
}
default: default:
wxASSERT_MSG( false, "Unhandled PCB_SHAPE shape" ); wxASSERT_MSG( false, "Unhandled PCB_SHAPE shape" );
@ -989,9 +983,6 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
} }
/** Helper function to plot a single drill mark. It compensate and clamp
* the drill mark size depending on the current plot options
*/
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos, void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos,
wxSize aDrillSize, const wxSize &aPadSize, wxSize aDrillSize, const wxSize &aPadSize,
double aOrientation, int aSmallDrill ) double aOrientation, int aSmallDrill )
@ -1008,11 +999,11 @@ void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wx
{ {
aDrillSize.y -= getFineWidthAdj(); aDrillSize.y -= getFineWidthAdj();
aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 ); aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL ); m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), nullptr );
} }
else else
{ {
m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL ); m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), nullptr );
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2012 Lorenzo Marcantonio, <l.marcantonio@logossrl.com> * Copyright (C) 2012 Lorenzo Marcantonio, <l.marcantonio@logossrl.com>
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -39,8 +39,7 @@ class BOARD;
/** /**
* Batch plotter state object. Keeps the plot options and handles multiple * Batch plotter state object. Keeps the plot options and handles multiple
* plot requests * plot requests. Useful in Python scripts.
* Especially useful in Python scripts
*/ */
class PLOT_CONTROLLER class PLOT_CONTROLLER
{ {
@ -48,7 +47,8 @@ public:
/** Batch plotter constructor, nothing interesting here */ /** Batch plotter constructor, nothing interesting here */
PLOT_CONTROLLER( BOARD *aBoard ); PLOT_CONTROLLER( BOARD *aBoard );
/** Batch plotter destructor, ensures that the last plot is closed /**
* Ensure that the last plot is closed.
*/ */
~PLOT_CONTROLLER(); ~PLOT_CONTROLLER();
@ -62,24 +62,25 @@ public:
/** /**
* @return true if a plotter is initialized and can be used * @return true if a plotter is initialized and can be used.
*/ */
bool IsPlotOpen() const { return m_plotter != NULL; } bool IsPlotOpen() const { return m_plotter != nullptr; }
/** Close the current plot, nothing happens if it isn't open /**
* Close the current plot, nothing happens if it isn't open.
*/ */
void ClosePlot(); void ClosePlot();
/** Open a new plotfile; works as a factory for plotter objects /** Open a new plotfile; works as a factory for plotter objects/
*
* @param aSuffix is a string added to the base filename (derived from * @param aSuffix is a string added to the base filename (derived from
* the board filename) to identify the plot file * the board filename) to identify the plot file.
* @param aFormat is the plot file format identifier * @param aFormat is the plot file format identifier.
* @param aSheetDesc
*/ */
bool OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat, const wxString& aSheetDesc ); bool OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat, const wxString& aSheetDesc );
/** Plot a single layer on the current plotfile /**
* m_plotLayer is the layer to plot * Plot a single layer on the current plotfile m_plotLayer is the layer to plot.
*/ */
bool PlotLayer(); bool PlotLayer();
@ -94,15 +95,15 @@ public:
const wxString GetPlotDirName() { return m_plotFile.GetPathWithSep(); } const wxString GetPlotDirName() { return m_plotFile.GetPathWithSep(); }
/** /**
* Plotters can plot in Black and White mode or Color mode * Choose color or bland and white plot mode.
* SetColorMode activate/de-actiavte the Color mode. *
* @param aColorMode = true to activate the plot color mode * @param aColorMode set to true to activate the plot color mode or false for black and white.
*/ */
void SetColorMode( bool ); void SetColorMode( bool aColorMode );
/** /**
* @return true if the current plot color mode is Color, * @return true if the current plot color mode is color or false if the current plot color
* false if the current plot color mode is Black and White * mode is black and white.
*/ */
bool GetColorMode(); bool GetColorMode();

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) 2020 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com> * Copyright (C) 2020 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -141,7 +141,7 @@ void CADSTAR_PCB_ARCHIVE_PARSER::LAYERDEFS::Parse( XNODE* aNode, PARSER_CONTEXT*
{ {
wxASSERT( aNode->GetName() == wxT( "LAYERDEFS" ) ); wxASSERT( aNode->GetName() == wxT( "LAYERDEFS" ) );
wxXmlAttribute* xmlAttribute = NULL; wxXmlAttribute* xmlAttribute = nullptr;
XNODE* cNode = aNode->GetChildren(); XNODE* cNode = aNode->GetChildren();
@ -592,7 +592,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::COPPERCODE::Parse( XNODE* aNode, PARSER_CONTEXT
} }
void CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::REASSIGN::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::REASSIGN::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
wxASSERT( aNode->GetName() == wxT( "SPACEREASSIGN" ) ); wxASSERT( aNode->GetName() == wxT( "SPACEREASSIGN" ) );
@ -976,6 +977,7 @@ void CADSTAR_PCB_ARCHIVE_PARSER::TECHNOLOGY_SECTION::Parse( XNODE* aNode, PARSER
} }
} }
CADSTAR_PCB_ARCHIVE_PARSER::PAD_SIDE CADSTAR_PCB_ARCHIVE_PARSER::GetPadSide( CADSTAR_PCB_ARCHIVE_PARSER::PAD_SIDE CADSTAR_PCB_ARCHIVE_PARSER::GetPadSide(
const wxString& aPadSideString ) const wxString& aPadSideString )
{ {
@ -1231,7 +1233,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::ARROW::Parse( XNODE* aNode, PARSER_C
} }
void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::TEXTFORMAT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::TEXTFORMAT::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
wxASSERT( aNode->GetName() == wxT( "DIMTEXT" ) ); wxASSERT( aNode->GetName() == wxT( "DIMTEXT" ) );
@ -1256,7 +1259,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::TEXTFORMAT::Parse( XNODE* aNode, PAR
} }
void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
wxASSERT( aNode->GetName() == wxT( "EXTLINE" ) ); wxASSERT( aNode->GetName() == wxT( "EXTLINE" ) );
@ -1931,7 +1935,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::PIN::Parse( XNODE* aNode, PARSER_CONTE
} }
void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::JUNCTION_PCB::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::JUNCTION_PCB::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
ParseIdentifiers( aNode, aContext ); ParseIdentifiers( aNode, aContext );
XNODE* cNode = aNode->GetChildren(); XNODE* cNode = aNode->GetChildren();
@ -1980,7 +1985,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::VIA::Parse( XNODE* aNode, PARSER_CONTE
} }
void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::COPPER_TERMINAL::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::COPPER_TERMINAL::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
wxASSERT( aNode->GetName() == wxT( "COPTERM" ) ); wxASSERT( aNode->GetName() == wxT( "COPTERM" ) );
@ -1990,7 +1996,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::COPPER_TERMINAL::Parse( XNODE* aNode,
} }
XNODE* CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE_VERTEX::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) XNODE* CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE_VERTEX::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
wxASSERT( aNode->GetName() == wxT( "ROUTEWIDTH" ) ); wxASSERT( aNode->GetName() == wxT( "ROUTEWIDTH" ) );
@ -2045,7 +2052,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE::Parse( XNODE* aNode, PARSER_CON
} }
void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::CONNECTION_PCB::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::CONNECTION_PCB::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
ParseIdentifiers( aNode, aContext ); ParseIdentifiers( aNode, aContext );
@ -2267,7 +2275,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::Parse( XNODE* aNode, PARSER_CONTEXT*
} }
void CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::COPPER_TERM::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) void CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::COPPER_TERM::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{ {
wxASSERT( aNode->GetName() == wxT( "TERM" ) ); wxASSERT( aNode->GetName() == wxT( "TERM" ) );

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) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -116,6 +116,7 @@ static wxString makeKey( const wxString& aFirst, const wxString& aSecond )
return key; return key;
} }
/// interpret special characters in Eagle text and converts them to KiCAD notation /// interpret special characters in Eagle text and converts them to KiCAD notation
static wxString interpret_text( const wxString& aText ) static wxString interpret_text( const wxString& aText )
{ {
@ -225,7 +226,6 @@ void ERULES::parse( wxXmlNode* aRules, std::function<void()> aCheckpoint )
psElongationLong = wxAtoi( value ); psElongationLong = wxAtoi( value );
else if( name == "psElongationOffset" ) else if( name == "psElongationOffset" )
psElongationOffset = wxAtoi( value ); psElongationOffset = wxAtoi( value );
else if( name == "mvStopFrame" ) else if( name == "mvStopFrame" )
value.ToCDouble( &mvStopFrame ); value.ToCDouble( &mvStopFrame );
else if( name == "mvCreamFrame" ) else if( name == "mvCreamFrame" )
@ -238,28 +238,24 @@ void ERULES::parse( wxXmlNode* aRules, std::function<void()> aCheckpoint )
mlMinCreamFrame = parseEagle( value ); mlMinCreamFrame = parseEagle( value );
else if( name == "mlMaxCreamFrame" ) else if( name == "mlMaxCreamFrame" )
mlMaxCreamFrame = parseEagle( value ); mlMaxCreamFrame = parseEagle( value );
else if( name == "srRoundness" ) else if( name == "srRoundness" )
value.ToCDouble( &srRoundness ); value.ToCDouble( &srRoundness );
else if( name == "srMinRoundness" ) else if( name == "srMinRoundness" )
srMinRoundness = parseEagle( value ); srMinRoundness = parseEagle( value );
else if( name == "srMaxRoundness" ) else if( name == "srMaxRoundness" )
srMaxRoundness = parseEagle( value ); srMaxRoundness = parseEagle( value );
else if( name == "psTop" ) else if( name == "psTop" )
psTop = wxAtoi( value ); psTop = wxAtoi( value );
else if( name == "psBottom" ) else if( name == "psBottom" )
psBottom = wxAtoi( value ); psBottom = wxAtoi( value );
else if( name == "psFirst" ) else if( name == "psFirst" )
psFirst = wxAtoi( value ); psFirst = wxAtoi( value );
else if( name == "rvPadTop" ) else if( name == "rvPadTop" )
value.ToCDouble( &rvPadTop ); value.ToCDouble( &rvPadTop );
else if( name == "rlMinPadTop" ) else if( name == "rlMinPadTop" )
rlMinPadTop = parseEagle( value ); rlMinPadTop = parseEagle( value );
else if( name == "rlMaxPadTop" ) else if( name == "rlMaxPadTop" )
rlMaxPadTop = parseEagle( value ); rlMaxPadTop = parseEagle( value );
else if( name == "rvViaOuter" ) else if( name == "rvViaOuter" )
value.ToCDouble( &rvViaOuter ); value.ToCDouble( &rvViaOuter );
else if( name == "rlMinViaOuter" ) else if( name == "rlMinViaOuter" )
@ -286,10 +282,10 @@ EAGLE_PLUGIN::EAGLE_PLUGIN() :
{ {
using namespace std::placeholders; using namespace std::placeholders;
init( NULL ); init( nullptr );
clear_cu_map(); clear_cu_map();
RegisterLayerMappingCallback( std::bind( RegisterLayerMappingCallback( std::bind( &EAGLE_PLUGIN::DefaultLayerMappingCallback,
&EAGLE_PLUGIN::DefaultLayerMappingCallback, this, _1 ) ); this, _1 ) );
} }
@ -322,7 +318,7 @@ void EAGLE_PLUGIN::checkpoint()
if( ++m_doneCount > m_lastProgressCount + PROGRESS_DELTA ) if( ++m_doneCount > m_lastProgressCount + PROGRESS_DELTA )
{ {
m_progressReporter->SetCurrentProgress( ( (double) m_doneCount ) m_progressReporter->SetCurrentProgress( ( (double) m_doneCount )
/ std::max( 1U, m_totalCount ) ); / std::max( 1U, m_totalCount ) );
if( !m_progressReporter->KeepRefreshing() ) if( !m_progressReporter->KeepRefreshing() )
THROW_IO_ERROR( ( "Open cancelled by user." ) ); THROW_IO_ERROR( ( "Open cancelled by user." ) );
@ -358,7 +354,7 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
m_board->SetFileName( aFileName ); m_board->SetFileName( aFileName );
// delete on exception, if I own m_board, according to aAppendToMe // delete on exception, if I own m_board, according to aAppendToMe
unique_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); unique_ptr<BOARD> deleter( aAppendToMe ? nullptr : m_board );
try try
{ {
@ -371,6 +367,7 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
} }
wxFileName fn = aFileName; wxFileName fn = aFileName;
// Load the document // Load the document
wxFFileInputStream stream( fn.GetFullPath() ); wxFFileInputStream stream( fn.GetFullPath() );
wxXmlDocument xmlDocument; wxXmlDocument xmlDocument;
@ -416,7 +413,6 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
// should be empty, else missing m_xpath->pop() // should be empty, else missing m_xpath->pop()
wxASSERT( m_xpath->Contents().size() == 0 ); wxASSERT( m_xpath->Contents().size() == 0 );
} }
// Catch all exceptions thrown from the parser.
catch( const XML_PARSER_ERROR &exc ) catch( const XML_PARSER_ERROR &exc )
{ {
wxString errmsg = exc.what(); wxString errmsg = exc.what();
@ -468,7 +464,7 @@ void EAGLE_PLUGIN::init( const PROPERTIES* aProperties )
m_xpath->clear(); m_xpath->clear();
m_pads_to_nets.clear(); m_pads_to_nets.clear();
m_board = NULL; m_board = nullptr;
m_props = aProperties; m_props = aProperties;
@ -642,6 +638,7 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) ); m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
m_board->SetLayerType( layer, LT_SIGNAL ); m_board->SetLayerType( layer, LT_SIGNAL );
} }
// could map the colors here // could map the colors here
} }
} }
@ -650,6 +647,7 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
#define DIMENSION_PRECISION 1 // 0.001 mm #define DIMENSION_PRECISION 1 // 0.001 mm
void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
{ {
if( !aGraphics ) if( !aGraphics )
@ -749,10 +747,14 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
pcbtxt->SetTextAngle( sign * 90 * 10 ); pcbtxt->SetTextAngle( sign * 90 * 10 );
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
} }
else // Ok so text is not at 90,180 or 270 so do some funny stuff to get placement right else
{ {
// Ok so text is not at 90,180 or 270 so do some funny stuff to get
// placement right.
if( ( degrees > 0 ) && ( degrees < 90 ) ) if( ( degrees > 0 ) && ( degrees < 90 ) )
{
pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 ); pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
}
else if( ( degrees > 90 ) && ( degrees < 180 ) ) else if( ( degrees > 90 ) && ( degrees < 180 ) )
{ {
pcbtxt->SetTextAngle( sign * ( t.rot->degrees + 180 ) * 10 ); pcbtxt->SetTextAngle( sign * ( t.rot->degrees + 180 ) * 10 );
@ -814,6 +816,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
break; break;
} }
} }
m_xpath->pop(); m_xpath->pop();
} }
else if( grName == "circle" ) else if( grName == "circle" )
@ -836,6 +839,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
// approximate circle as polygon with a edge every 10 degree // approximate circle as polygon with a edge every 10 degree
wxPoint center( kicad_x( c.x ), kicad_y( c.y ) ); wxPoint center( kicad_x( c.x ), kicad_y( c.y ) );
int outlineRadius = radius + ( width / 2 ); int outlineRadius = radius + ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 ) for( int angle = 0; angle < 360; angle += 10 )
{ {
wxPoint rotatedPoint( outlineRadius, 0 ); wxPoint rotatedPoint( outlineRadius, 0 );
@ -847,6 +851,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
{ {
zone->NewHole(); zone->NewHole();
int innerRadius = radius - ( width / 2 ); int innerRadius = radius - ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 ) for( int angle = 0; angle < 360; angle += 10 )
{ {
wxPoint rotatedPoint( innerRadius, 0 ); wxPoint rotatedPoint( innerRadius, 0 );
@ -875,6 +880,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
shape->SetWidth( width ); shape->SetWidth( width );
} }
} }
m_xpath->pop(); m_xpath->pop();
} }
else if( grName == "rectangle" ) else if( grName == "rectangle" )
@ -953,7 +959,8 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
if( d.dimensionType ) if( d.dimensionType )
{ {
// Eagle dimension graphic arms may have different lengths, but they look // Eagle dimension graphic arms may have different lengths, but they look
// incorrect in KiCad (the graphic is tilted). Make them even length in such case. // incorrect in KiCad (the graphic is tilted). Make them even length in
// such case.
if( *d.dimensionType == "horizontal" ) if( *d.dimensionType == "horizontal" )
{ {
int newY = ( d.y1.ToPcbUnits() + d.y2.ToPcbUnits() ) / 2; int newY = ( d.y1.ToPcbUnits() + d.y2.ToPcbUnits() ) / 2;
@ -970,6 +977,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
dimension->SetLayer( layer ); dimension->SetLayer( layer );
dimension->SetPrecision( DIMENSION_PRECISION ); dimension->SetPrecision( DIMENSION_PRECISION );
// The origin and end are assumed to always be in this order from eagle // The origin and end are assumed to always be in this order from eagle
dimension->SetStart( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) ); dimension->SetStart( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) ); dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
@ -992,6 +1000,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
// Get next graphic // Get next graphic
gr = gr->GetNext(); gr = gr->GetNext();
} }
m_xpath->pop(); m_xpath->pop();
} }
@ -1162,15 +1171,17 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
footprint->SetValue( FROM_UTF8( e.value.c_str() ) ); footprint->SetValue( FROM_UTF8( e.value.c_str() ) );
if( !e.smashed ) if( !e.smashed )
{ // Not smashed so show NAME & VALUE {
// Not smashed so show NAME & VALUE
if( valueNamePresetInPackageLayout ) if( valueNamePresetInPackageLayout )
footprint->Value().SetVisible( true ); // Only if place holder in package layout footprint->Value().SetVisible( true ); // Only if place holder in package layout
if( refanceNamePresetInPackageLayout ) if( refanceNamePresetInPackageLayout )
footprint->Reference().SetVisible( true ); // Only if place holder in package layout footprint->Reference().SetVisible( true ); // Only if place holder in package layout
} }
else if( *e.smashed == true ) else if( *e.smashed == true )
{ // Smashed so set default to no show for NAME and VALUE {
// Smashed so set default to no show for NAME and VALUE
footprint->Value().SetVisible( false ); footprint->Value().SetVisible( false );
footprint->Reference().SetVisible( false ); footprint->Reference().SetVisible( false );
@ -1212,9 +1223,10 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
{ {
wxString reference = e.name; wxString reference = e.name;
// EAGLE allows references to be single digits. This breaks KiCad netlisting, which requires // EAGLE allows references to be single digits. This breaks KiCad
// parts to have non-digit + digit annotation. If the reference begins with a number, // netlisting, which requires parts to have non-digit + digit
// we prepend 'UNK' (unknown) for the symbol designator // annotation. If the reference begins with a number, we prepend
// 'UNK' (unknown) for the symbol designator.
if( reference.find_first_not_of( "0123456789" ) == wxString::npos ) if( reference.find_first_not_of( "0123456789" ) == wxString::npos )
reference.Prepend( "UNK" ); reference.Prepend( "UNK" );
@ -1226,12 +1238,14 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
break; break;
} }
case EATTR::NAME : case EATTR::NAME :
if( refanceNamePresetInPackageLayout ) if( refanceNamePresetInPackageLayout )
{ {
footprint->SetReference( "NAME" ); footprint->SetReference( "NAME" );
footprint->Reference().SetVisible( true ); footprint->Reference().SetVisible( true );
} }
break; break;
case EATTR::BOTH : case EATTR::BOTH :
@ -1254,8 +1268,10 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
} }
} }
else else
{
// No display, so default is visible, and show value of NAME // No display, so default is visible, and show value of NAME
footprint->Reference().SetVisible( true ); footprint->Reference().SetVisible( true );
}
} }
else if( a.name == "VALUE" ) else if( a.name == "VALUE" )
{ {
@ -1339,12 +1355,11 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
|| p.layer == EAGLE_LAYER::BRESTRICT || p.layer == EAGLE_LAYER::BRESTRICT
|| p.layer == EAGLE_LAYER::VRESTRICT ); || p.layer == EAGLE_LAYER::VRESTRICT );
if( layer == UNDEFINED_LAYER ) { if( layer == UNDEFINED_LAYER )
wxLogMessage( wxString::Format( {
_( "Ignoring a polygon since Eagle layer '%s' (%d) " wxLogMessage( wxString::Format( _( "Ignoring a polygon since Eagle layer '%s' (%d) "
"was not mapped" ), "was not mapped" ),
eagle_layer_name( p.layer ), eagle_layer_name( p.layer ), p.layer ) );
p.layer ) );
return nullptr; return nullptr;
} }
@ -1395,17 +1410,15 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
wxPoint( kicad_x( v2.x ), kicad_y( v2.y ) ), wxPoint( kicad_x( v2.x ), kicad_y( v2.y ) ),
*v1.curve ); *v1.curve );
double angle = DEG2RAD( *v1.curve ); double angle = DEG2RAD( *v1.curve );
double end_angle = atan2( kicad_y( v2.y ) - center.y, double end_angle = atan2( kicad_y( v2.y ) - center.y, kicad_x( v2.x ) - center.x );
kicad_x( v2.x ) - center.x ); double radius = sqrt( pow( center.x - kicad_x( v1.x ), 2 )
double radius = sqrt( pow( center.x - kicad_x( v1.x ), 2 ) + pow( center.y - kicad_y( v1.y ), 2 ) );
+ pow( center.y - kicad_y( v1.y ), 2 ) );
int segCount = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF, *v1.curve ); int segCount = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF, *v1.curve );
double delta_angle = angle / segCount; double delta_angle = angle / segCount;
for( double a = end_angle + angle; for( double a = end_angle + angle; fabs( a - end_angle ) > fabs( delta_angle );
fabs( a - end_angle ) > fabs( delta_angle ); a -= delta_angle )
a -= delta_angle )
{ {
polygon.Append( KiROUND( radius * cos( a ) ) + center.x, polygon.Append( KiROUND( radius * cos( a ) ) + center.x,
KiROUND( radius * sin( a ) ) + center.y ); KiROUND( radius * sin( a ) ) + center.y );
@ -1502,7 +1515,8 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
{ {
// Smashed part ? // Smashed part ?
if( aAttr ) if( aAttr )
{ // Yes {
// Yes
const EATTR& a = *aAttr; const EATTR& a = *aAttr;
if( a.value ) if( a.value )
@ -1615,8 +1629,10 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
; ;
} }
} }
else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans <attribute> else
{ {
// Part is not smash so use Lib default for NAME/VALUE // the text is per the original
// package, sans <attribute>.
double degrees = ( aFPText->GetTextAngle() + aFootprint->GetOrientation() ) / 10; double degrees = ( aFPText->GetTextAngle() + aFootprint->GetOrientation() ) / 10;
// @todo there are a few more cases than these to contend with: // @todo there are a few more cases than these to contend with:
@ -1648,28 +1664,20 @@ FOOTPRINT* EAGLE_PLUGIN::makeFootprint( wxXmlNode* aPackage, const wxString& aPk
if( itemName == "description" ) if( itemName == "description" )
m->SetDescription( FROM_UTF8( packageItem->GetNodeContent().c_str() ) ); m->SetDescription( FROM_UTF8( packageItem->GetNodeContent().c_str() ) );
else if( itemName == "wire" ) else if( itemName == "wire" )
packageWire( m.get(), packageItem ); packageWire( m.get(), packageItem );
else if( itemName == "pad" ) else if( itemName == "pad" )
packagePad( m.get(), packageItem ); packagePad( m.get(), packageItem );
else if( itemName == "text" ) else if( itemName == "text" )
packageText( m.get(), packageItem ); packageText( m.get(), packageItem );
else if( itemName == "rectangle" ) else if( itemName == "rectangle" )
packageRectangle( m.get(), packageItem ); packageRectangle( m.get(), packageItem );
else if( itemName == "polygon" ) else if( itemName == "polygon" )
packagePolygon( m.get(), packageItem ); packagePolygon( m.get(), packageItem );
else if( itemName == "circle" ) else if( itemName == "circle" )
packageCircle( m.get(), packageItem ); packageCircle( m.get(), packageItem );
else if( itemName == "hole" ) else if( itemName == "hole" )
packageHole( m.get(), packageItem, false ); packageHole( m.get(), packageItem, false );
else if( itemName == "smd" ) else if( itemName == "smd" )
packageSMD( m.get(), packageItem ); packageSMD( m.get(), packageItem );
@ -1692,8 +1700,7 @@ void EAGLE_PLUGIN::packageWire( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
{ {
wxLogMessage( wxString::Format( _( "Ignoring a wire since Eagle layer '%s' (%d) " wxLogMessage( wxString::Format( _( "Ignoring a wire since Eagle layer '%s' (%d) "
"was not mapped" ), "was not mapped" ),
eagle_layer_name( w.layer ), eagle_layer_name( w.layer ), w.layer ) );
w.layer ) );
return; return;
} }
@ -1865,8 +1872,7 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
{ {
wxLogMessage( wxString::Format( _( "Ignoring a text since Eagle layer '%s' (%d) " wxLogMessage( wxString::Format( _( "Ignoring a text since Eagle layer '%s' (%d) "
"was not mapped" ), "was not mapped" ),
eagle_layer_name( t.layer ), eagle_layer_name( t.layer ), t.layer ) );
t.layer ) );
return; return;
} }
@ -1892,7 +1898,6 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
txt->SetLayer( layer ); txt->SetLayer( layer );
double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
int textThickness = KiROUND( t.size.ToPcbUnits() * ratio / 100 ); int textThickness = KiROUND( t.size.ToPcbUnits() * ratio / 100 );
@ -1912,9 +1917,13 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
double degrees = t.rot->degrees; double degrees = t.rot->degrees;
if( degrees == 90 || t.rot->spin ) if( degrees == 90 || t.rot->spin )
{
txt->SetTextAngle( sign * degrees * 10 ); txt->SetTextAngle( sign * degrees * 10 );
}
else if( degrees == 180 ) else if( degrees == 180 )
{
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
}
else if( degrees == 270 ) else if( degrees == 270 )
{ {
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
@ -2003,8 +2012,7 @@ void EAGLE_PLUGIN::packageRectangle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) c
{ {
wxLogMessage( wxString::Format( _( "Ignoring a rectangle since Eagle layer '%s' (%d) " wxLogMessage( wxString::Format( _( "Ignoring a rectangle since Eagle layer '%s' (%d) "
"was not mapped" ), "was not mapped" ),
eagle_layer_name( r.layer ), eagle_layer_name( r.layer ), r.layer ) );
r.layer ) );
return; return;
} }
@ -2070,14 +2078,13 @@ void EAGLE_PLUGIN::packagePolygon( FOOTPRINT* aFootprint, wxXmlNode* aTree ) con
if( v1.curve ) if( v1.curve )
{ {
EVERTEX v2 = vertices[i + 1]; EVERTEX v2 = vertices[i + 1];
wxPoint center = ConvertArcCenter( wxPoint center =
wxPoint( kicad_x( v1.x ), kicad_y( v1.y ) ), ConvertArcCenter( wxPoint( kicad_x( v1.x ), kicad_y( v1.y ) ),
wxPoint( kicad_x( v2.x ), kicad_y( v2.y ) ), *v1.curve ); wxPoint( kicad_x( v2.x ), kicad_y( v2.y ) ), *v1.curve );
double angle = DEG2RAD( *v1.curve ); double angle = DEG2RAD( *v1.curve );
double end_angle = atan2( kicad_y( v2.y ) - center.y, double end_angle = atan2( kicad_y( v2.y ) - center.y, kicad_x( v2.x ) - center.x );
kicad_x( v2.x ) - center.x );
double radius = sqrt( pow( center.x - kicad_x( v1.x ), 2 ) double radius = sqrt( pow( center.x - kicad_x( v1.x ), 2 )
+ pow( center.y - kicad_y( v1.y ), 2 ) ); + pow( center.y - kicad_y( v1.y ), 2 ) );
// Don't allow a zero-radius curve // Don't allow a zero-radius curve
if( KiROUND( radius ) == 0 ) if( KiROUND( radius ) == 0 )
@ -2118,8 +2125,7 @@ void EAGLE_PLUGIN::packagePolygon( FOOTPRINT* aFootprint, wxXmlNode* aTree ) con
{ {
wxLogMessage( wxString::Format( _( "Ignoring a polygon since Eagle layer '%s' (%d) " wxLogMessage( wxString::Format( _( "Ignoring a polygon since Eagle layer '%s' (%d) "
"was not mapped" ), "was not mapped" ),
eagle_layer_name( p.layer ), eagle_layer_name( p.layer ), p.layer ) );
p.layer ) );
return; return;
} }
@ -2139,6 +2145,7 @@ void EAGLE_PLUGIN::packagePolygon( FOOTPRINT* aFootprint, wxXmlNode* aTree ) con
} }
} }
void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
{ {
ECIRCLE e( aTree ); ECIRCLE e( aTree );
@ -2158,6 +2165,7 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons
// approximate circle as polygon with a edge every 10 degree // approximate circle as polygon with a edge every 10 degree
wxPoint center( kicad_x( e.x ), kicad_y( e.y ) ); wxPoint center( kicad_x( e.x ), kicad_y( e.y ) );
int outlineRadius = radius + ( width / 2 ); int outlineRadius = radius + ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 ) for( int angle = 0; angle < 360; angle += 10 )
{ {
wxPoint rotatedPoint( outlineRadius, 0 ); wxPoint rotatedPoint( outlineRadius, 0 );
@ -2169,6 +2177,7 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons
{ {
zone->NewHole(); zone->NewHole();
int innerRadius = radius - ( width / 2 ); int innerRadius = radius - ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 ) for( int angle = 0; angle < 360; angle += 10 )
{ {
wxPoint rotatedPoint( innerRadius, 0 ); wxPoint rotatedPoint( innerRadius, 0 );
@ -2188,8 +2197,7 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons
{ {
wxLogMessage( wxString::Format( _( "Ignoring a circle since Eagle layer '%s' (%d) " wxLogMessage( wxString::Format( _( "Ignoring a circle since Eagle layer '%s' (%d) "
"was not mapped" ), "was not mapped" ),
eagle_layer_name( e.layer ), eagle_layer_name( e.layer ), e.layer ) );
e.layer ) );
return; return;
} }
@ -2294,8 +2302,9 @@ void EAGLE_PLUGIN::packageSMD( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
int minPadSize = std::min( padSize.x, padSize.y ); int minPadSize = std::min( padSize.x, padSize.y );
// Rounded rectangle pads // Rounded rectangle pads
int roundRadius = eagleClamp( m_rules->srMinRoundness * 2, int roundRadius =
(int)( minPadSize * m_rules->srRoundness ), m_rules->srMaxRoundness * 2 ); eagleClamp( m_rules->srMinRoundness * 2, (int) ( minPadSize * m_rules->srRoundness ),
m_rules->srMaxRoundness * 2 );
if( e.roundness || roundRadius > 0 ) if( e.roundness || roundRadius > 0 )
{ {
@ -2313,8 +2322,8 @@ void EAGLE_PLUGIN::packageSMD( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
pad->SetOrientation( e.rot->degrees * 10 ); pad->SetOrientation( e.rot->degrees * 10 );
pad->SetLocalSolderPasteMargin( -eagleClamp( m_rules->mlMinCreamFrame, pad->SetLocalSolderPasteMargin( -eagleClamp( m_rules->mlMinCreamFrame,
(int) ( m_rules->mvCreamFrame * minPadSize ), (int) ( m_rules->mvCreamFrame * minPadSize ),
m_rules->mlMaxCreamFrame ) ); m_rules->mlMaxCreamFrame ) );
// Solder mask // Solder mask
if( e.stop && *e.stop == false ) // enabled by default if( e.stop && *e.stop == false ) // enabled by default
@ -2348,9 +2357,10 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const
// Solder mask // Solder mask
const wxSize& padSize( aPad->GetSize() ); const wxSize& padSize( aPad->GetSize() );
aPad->SetLocalSolderMaskMargin( eagleClamp( m_rules->mlMinStopFrame, aPad->SetLocalSolderMaskMargin(
(int)( m_rules->mvStopFrame * std::min( padSize.x, padSize.y ) ), eagleClamp( m_rules->mlMinStopFrame,
m_rules->mlMaxStopFrame ) ); (int) ( m_rules->mvStopFrame * std::min( padSize.x, padSize.y ) ),
m_rules->mlMaxStopFrame ) );
// Solid connection to copper zones // Solid connection to copper zones
if( aEaglePad.thermals && !*aEaglePad.thermals ) if( aEaglePad.thermals && !*aEaglePad.thermals )
@ -2421,15 +2431,15 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
wxPoint center; wxPoint center;
int width = w.width.ToPcbUnits(); int width = w.width.ToPcbUnits();
if( width < m_min_trace ) if( width < m_min_trace )
m_min_trace = width; m_min_trace = width;
if( w.curve ) if( w.curve )
{ {
center = ConvertArcCenter( center = ConvertArcCenter( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ),
wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ), wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ),
wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ), *w.curve );
*w.curve );
angle = DEG2RAD( *w.curve ); angle = DEG2RAD( *w.curve );
@ -2439,7 +2449,8 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
radius = sqrt( pow( center.x - kicad_x( w.x1 ), 2 ) + radius = sqrt( pow( center.x - kicad_x( w.x1 ), 2 ) +
pow( center.y - kicad_y( w.y1 ), 2 ) ); pow( center.y - kicad_y( w.y1 ), 2 ) );
int segs = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF, *w.curve ); int segs = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF,
*w.curve );
delta_angle = angle / segs; delta_angle = angle / segs;
} }
@ -2480,7 +2491,6 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
m_xpath->pop(); m_xpath->pop();
} }
else if( itemName == "via" ) else if( itemName == "via" )
{ {
m_xpath->push( "via" ); m_xpath->push( "via" );
@ -2489,8 +2499,7 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
PCB_LAYER_ID layer_front_most = kicad_layer( v.layer_front_most ); PCB_LAYER_ID layer_front_most = kicad_layer( v.layer_front_most );
PCB_LAYER_ID layer_back_most = kicad_layer( v.layer_back_most ); PCB_LAYER_ID layer_back_most = kicad_layer( v.layer_back_most );
if( IsCopperLayer( layer_front_most ) && if( IsCopperLayer( layer_front_most ) && IsCopperLayer( layer_back_most ) )
IsCopperLayer( layer_back_most ) )
{ {
int kidiam; int kidiam;
int drillz = v.drill.ToPcbUnits(); int drillz = v.drill.ToPcbUnits();
@ -2519,9 +2528,10 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
if( !v.diam || via->GetWidth() <= via->GetDrill() ) if( !v.diam || via->GetWidth() <= via->GetDrill() )
{ {
double annulus = eagleClamp( m_rules->rlMinViaOuter, double annulus =
(double)( via->GetWidth() / 2 - via->GetDrill() ), eagleClamp( m_rules->rlMinViaOuter,
m_rules->rlMaxViaOuter ); (double) ( via->GetWidth() / 2 - via->GetDrill() ),
m_rules->rlMaxViaOuter );
via->SetWidth( drillz + 2 * annulus ); via->SetWidth( drillz + 2 * annulus );
} }
@ -2597,7 +2607,9 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
// therefore omit this signal/net. // therefore omit this signal/net.
} }
else else
{
netCode++; netCode++;
}
// Get next signal // Get next signal
net = net->GetNext(); net = net->GetNext();
@ -2606,6 +2618,7 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
m_xpath->pop(); // "signals.signal" m_xpath->pop(); // "signals.signal"
} }
std::map<wxString, PCB_LAYER_ID> EAGLE_PLUGIN::DefaultLayerMappingCallback( std::map<wxString, PCB_LAYER_ID> EAGLE_PLUGIN::DefaultLayerMappingCallback(
const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector ) const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector )
{ {
@ -2620,6 +2633,7 @@ std::map<wxString, PCB_LAYER_ID> EAGLE_PLUGIN::DefaultLayerMappingCallback(
return layer_map; return layer_map;
} }
void EAGLE_PLUGIN::mapEagleLayersToKicad() void EAGLE_PLUGIN::mapEagleLayersToKicad()
{ {
std::vector<INPUT_LAYER_DESC> inputDescs; std::vector<INPUT_LAYER_DESC> inputDescs;
@ -2649,18 +2663,21 @@ void EAGLE_PLUGIN::mapEagleLayersToKicad()
dynamic_cast<wxWindow*>( m_progressReporter )->Show(); dynamic_cast<wxWindow*>( m_progressReporter )->Show();
} }
PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
{ {
auto result = m_layer_map.find( eagle_layer_name( aEagleLayer ) ); auto result = m_layer_map.find( eagle_layer_name( aEagleLayer ) );
return result == m_layer_map.end() ? UNDEFINED_LAYER : result->second; return result == m_layer_map.end() ? UNDEFINED_LAYER : result->second;
} }
std::tuple<PCB_LAYER_ID, LSET, bool> EAGLE_PLUGIN::defaultKicadLayer( int aEagleLayer ) const std::tuple<PCB_LAYER_ID, LSET, bool> EAGLE_PLUGIN::defaultKicadLayer( int aEagleLayer ) const
{ {
// eagle copper layer: // eagle copper layer:
if( aEagleLayer >= 1 && aEagleLayer < int( arrayDim( m_cu_map ) ) ) if( aEagleLayer >= 1 && aEagleLayer < int( arrayDim( m_cu_map ) ) )
{ {
LSET copperLayers; LSET copperLayers;
for( int copperLayer : m_cu_map ) for( int copperLayer : m_cu_map )
{ {
if( copperLayer >= 0 ) if( copperLayer >= 0 )
@ -2893,7 +2910,7 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath )
m_xpath->push( "eagle.drawing.library" ); m_xpath->push( "eagle.drawing.library" );
wxXmlNode* library = drawingChildren["library"]; wxXmlNode* library = drawingChildren["library"];
loadLibrary( library, NULL ); loadLibrary( library, nullptr );
m_xpath->pop(); m_xpath->pop();
m_mod_time = modtime; m_mod_time = modtime;
@ -2950,8 +2967,7 @@ void EAGLE_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxS
FOOTPRINT* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, FOOTPRINT* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
const wxString& aFootprintName, const wxString& aFootprintName, bool aKeepUUID,
bool aKeepUUID,
const PROPERTIES* aProperties ) const PROPERTIES* aProperties )
{ {
init( aProperties ); init( aProperties );
@ -2959,7 +2975,7 @@ FOOTPRINT* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
FOOTPRINT_MAP::const_iterator it = m_templates.find( aFootprintName ); FOOTPRINT_MAP::const_iterator it = m_templates.find( aFootprintName );
if( it == m_templates.end() ) if( it == m_templates.end() )
return NULL; return nullptr;
// Return a copy of the template // Return a copy of the template
FOOTPRINT* copy = (FOOTPRINT*) it->second->Duplicate(); FOOTPRINT* copy = (FOOTPRINT*) it->second->Duplicate();
@ -2971,47 +2987,4 @@ FOOTPRINT* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
void EAGLE_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const void EAGLE_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
{ {
PLUGIN::FootprintLibOptions( aListToAppendTo ); PLUGIN::FootprintLibOptions( aListToAppendTo );
/*
(*aListToAppendTo)["ignore_duplicates"] = UTF8( _( "Ignore duplicately named footprints within "
"the same Eagle library. "
"Only the first similarly named footprint "
"will be loaded." ) );
*/
} }
/*
void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{
// Eagle lovers apply here.
}
void EAGLE_PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
const PROPERTIES* aProperties )
{
}
void EAGLE_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
{
}
void EAGLE_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
}
bool EAGLE_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
}
bool EAGLE_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
{
return true;
}
*/

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) 2020 BeagleBoard Foundation * Copyright (C) 2020 BeagleBoard Foundation
* Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2020-2021 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
@ -36,8 +36,8 @@
FABMASTER_PLUGIN::FABMASTER_PLUGIN() FABMASTER_PLUGIN::FABMASTER_PLUGIN()
{ {
m_board = NULL; m_board = nullptr;
m_props = NULL; m_props = nullptr;
} }

View File

@ -1,7 +1,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) 2020 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.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
@ -36,16 +36,11 @@
class FABMASTER_PLUGIN : public PLUGIN class FABMASTER_PLUGIN : public PLUGIN
{ {
public: public:
const wxString PluginName() const override;
// -----<PUBLIC PLUGIN API>-------------------------------------------------- BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr,
const wxString PluginName() const override; PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
BOARD* Load( const wxString& aFileName,
BOARD* aAppendToMe,
const PROPERTIES* aProperties = NULL,
PROJECT* aProject = nullptr,
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
const wxString GetFileExtension() const override; const wxString GetFileExtension() const override;
@ -55,8 +50,6 @@ public:
return 0; return 0;
} }
// -----</PUBLIC PLUGIN API>-------------------------------------------------
FABMASTER_PLUGIN(); FABMASTER_PLUGIN();
~FABMASTER_PLUGIN(); ~FABMASTER_PLUGIN();
@ -67,4 +60,4 @@ private:
FABMASTER m_fabmaster; FABMASTER m_fabmaster;
}; };
#endif // PCAD_PLUGIN_H_ #endif // FABMASTER_PLUGIN_H_

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) 2012 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -98,8 +98,7 @@ static inline long parseInt( const wxString& aValue, double aScalar )
/** /**
* GPCB_FPL_CACHE_ITEM * helper class for creating a footprint library cache.
* is helper class for creating a footprint library cache.
* *
* The new footprint library design is a file path of individual footprint files * The new footprint library design is a file path of individual footprint files
* that contain a single footprint per file. This class is a helper only for the * that contain a single footprint per file. This class is a helper only for the
@ -108,14 +107,15 @@ static inline long parseInt( const wxString& aValue, double aScalar )
*/ */
class GPCB_FPL_CACHE_ITEM class GPCB_FPL_CACHE_ITEM
{ {
WX_FILENAME m_filename; ///< The full file name and path of the footprint to cache.
std::unique_ptr<FOOTPRINT> m_footprint;
public: public:
GPCB_FPL_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ); GPCB_FPL_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
WX_FILENAME GetFileName() const { return m_filename; } WX_FILENAME GetFileName() const { return m_filename; }
FOOTPRINT* GetFootprint() const { return m_footprint.get(); } FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
private:
WX_FILENAME m_filename; ///< The full file name and path of the footprint to cache.
std::unique_ptr<FOOTPRINT> m_footprint;
}; };
@ -131,47 +131,6 @@ typedef boost::ptr_map< std::string, GPCB_FPL_CACHE_ITEM > FOOTPRINT_MAP;
class GPCB_FPL_CACHE class GPCB_FPL_CACHE
{ {
GPCB_PLUGIN* m_owner; ///< Plugin object that owns the cache.
wxFileName m_lib_path; ///< The path of the library.
FOOTPRINT_MAP m_footprints; ///< Map of footprint file name to FOOTPRINT*.
bool m_cache_dirty; ///< Stored separately because it's expensive to check
///< m_cache_timestamp against all the files.
long long m_cache_timestamp; ///< A hash of the timestamps for all the footprint
///< files.
FOOTPRINT* parseFOOTPRINT( LINE_READER* aLineReader );
/**
* Function testFlags
* tests \a aFlag for \a aMask or \a aName.
* @param aFlag = List of flags to test against: can be a bit field flag or a list name flag
* a bit field flag is an hexadecimal value: Ox00020000
* a list name flag is a string list of flags, comma separated like square,option1
* @param aMask = flag list to test
* @param aName = flag name to find in list
* @return true if found
*/
bool testFlags( const wxString& aFlag, long aMask, const wxChar* aName );
/**
* Function parseParameters
* extracts parameters and tokens from \a aLineReader and adds them to \a aParameterList.
*
* Delimiter characters are:
* [ ] ( ) Begin and end of parameter list and units indicator
* " is a string delimiter
* space is the param separator
* The first word is the keyword
* the second item is one of ( or [
* other are parameters (number or delimited string)
* last parameter is ) or ]
*
* @param aParameterList This list of parameters parsed.
* @param aLineReader The line reader object to parse.
*/
void parseParameters( wxArrayString& aParameterList, LINE_READER* aLineReader );
public: public:
GPCB_FPL_CACHE( GPCB_PLUGIN* aOwner, const wxString& aLibraryPath ); GPCB_FPL_CACHE( GPCB_PLUGIN* aOwner, const wxString& aLibraryPath );
@ -190,18 +149,58 @@ public:
void Remove( const wxString& aFootprintName ); void Remove( const wxString& aFootprintName );
/** /**
* Function GetTimestamp
* Generate a timestamp representing all source files in the cache (including the * Generate a timestamp representing all source files in the cache (including the
* parent directory). * parent directory).
*
* Timestamps should not be considered ordered. They either match or they don't. * Timestamps should not be considered ordered. They either match or they don't.
*/ */
static long long GetTimestamp( const wxString& aLibPath ); static long long GetTimestamp( const wxString& aLibPath );
/** /**
* Function IsModified
* Return true if the cache is not up-to-date. * Return true if the cache is not up-to-date.
*/ */
bool IsModified(); bool IsModified();
private:
FOOTPRINT* parseFOOTPRINT( LINE_READER* aLineReader );
/**
* Test \a aFlag for \a aMask or \a aName.
*
* @param aFlag is a list of flags to test against: can be a bit field flag or a list name flag
* a bit field flag is an hexadecimal value: Ox00020000 a list name flag is a
* string list of flags, comma separated like square,option1.
* @param aMask is the flag list to test.
* @param aName is the flag name to find in list.
* @return true if found.
*/
bool testFlags( const wxString& aFlag, long aMask, const wxChar* aName );
/**
* Extract parameters and tokens from \a aLineReader and adds them to \a aParameterList.
*
* Delimiter characters are:
* [ ] ( ) Begin and end of parameter list and units indicator
* " is a string delimiter
* space is the param separator
* The first word is the keyword
* the second item is one of ( or [
* other are parameters (number or delimited string)
* last parameter is ) or ]
*
* @param aParameterList This list of parameters parsed.
* @param aLineReader The line reader object to parse.
*/
void parseParameters( wxArrayString& aParameterList, LINE_READER* aLineReader );
GPCB_PLUGIN* m_owner; ///< Plugin object that owns the cache.
wxFileName m_lib_path; ///< The path of the library.
FOOTPRINT_MAP m_footprints; ///< Map of footprint file name to FOOTPRINT*.
bool m_cache_dirty; ///< Stored separately because it's expensive to check
///< m_cache_timestamp against all the files.
long long m_cache_timestamp; ///< A hash of the timestamps for all the footprint
///< files.
}; };
@ -317,14 +316,15 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
#define NEW_GPCB_UNIT_CONV ( 0.01*IU_PER_MILS ) #define NEW_GPCB_UNIT_CONV ( 0.01*IU_PER_MILS )
int paramCnt; int paramCnt;
double conv_unit = NEW_GPCB_UNIT_CONV; // GPCB unit = 0.01 mils and Pcbnew 0.1
// GPCB unit = 0.01 mils and Pcbnew 0.1.
double conv_unit = NEW_GPCB_UNIT_CONV;
wxPoint textPos; wxPoint textPos;
wxString msg; wxString msg;
wxArrayString parameters; wxArrayString parameters;
std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( nullptr ); std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( nullptr );
if( aLineReader->ReadLine() == nullptr )
if( aLineReader->ReadLine() == NULL )
{ {
msg = aLineReader->GetSource() + ": empty file"; msg = aLineReader->GetSource() + ": empty file";
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
@ -374,6 +374,7 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
// Read value // Read value
if( paramCnt > 10 ) if( paramCnt > 10 )
footprint->SetValue( parameters[5] ); footprint->SetValue( parameters[5] );
// With gEDA/pcb, value is meaningful after instantiation, only, so it's // With gEDA/pcb, value is meaningful after instantiation, only, so it's
// often empty in bare footprints. // often empty in bare footprints.
if( footprint->Value().GetText().IsEmpty() ) if( footprint->Value().GetText().IsEmpty() )
@ -449,8 +450,8 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
conv_unit = NEW_GPCB_UNIT_CONV; conv_unit = NEW_GPCB_UNIT_CONV;
} }
wxLogTrace( wxLogTrace( traceGedaPcbPlugin, wxT( "%s parameter count = %d." ),
traceGedaPcbPlugin, wxT( "%s parameter count = %d." ), parameters[0], paramCnt ); parameters[0], paramCnt );
// Parse a line with format: ElementLine [X1 Y1 X2 Y2 Thickness] // Parse a line with format: ElementLine [X1 Y1 X2 Y2 Thickness]
if( parameters[0].CmpNoCase( wxT( "ElementLine" ) ) == 0 ) if( parameters[0].CmpNoCase( wxT( "ElementLine" ) ) == 0 )
@ -590,8 +591,7 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
wxPoint padPos( (x1 + x2) / 2, (y1 + y2) / 2 ); wxPoint padPos( (x1 + x2) / 2, (y1 + y2) / 2 );
pad->SetSize( wxSize( KiROUND( EuclideanNorm( delta ) ) + width, pad->SetSize( wxSize( KiROUND( EuclideanNorm( delta ) ) + width, width ) );
width ) );
// Set the relative position before adjusting the absolute position // Set the relative position before adjusting the absolute position
pad->SetPos0( padPos ); pad->SetPos0( padPos );

File diff suppressed because it is too large Load Diff

View File

@ -211,7 +211,7 @@ private:
FP_TEXT* parseFP_TEXT(); FP_TEXT* parseFP_TEXT();
FP_SHAPE* parseFP_SHAPE(); FP_SHAPE* parseFP_SHAPE();
PAD* parsePAD( FOOTPRINT* aParent = NULL ); PAD* parsePAD( FOOTPRINT* aParent = nullptr );
// Parse only the (option ...) inside a pad description // Parse only the (option ...) inside a pad description
bool parsePAD_option( PAD* aPad ); bool parsePAD_option( PAD* aPad );
@ -322,7 +322,7 @@ private:
inline int parseInt() inline int parseInt()
{ {
return (int)strtol( CurText(), NULL, 10 ); return (int)strtol( CurText(), nullptr, 10 );
} }
inline int parseInt( const char* aExpected ) inline int parseInt( const char* aExpected )
@ -334,7 +334,7 @@ private:
inline long parseHex() inline long parseHex()
{ {
NextTok(); NextTok();
return strtol( CurText(), NULL, 16 ); return strtol( CurText(), nullptr, 16 );
} }
bool parseBool(); bool parseBool();

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2008, 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -41,9 +41,11 @@ namespace PCAD2KICAD {
// PCAD stroke font average ratio of width to size // PCAD stroke font average ratio of width to size
const double TEXT_WIDTH_TO_SIZE_AVERAGE = 0.5; const double TEXT_WIDTH_TO_SIZE_AVERAGE = 0.5;
// PCAD proportions of stroke font // PCAD proportions of stroke font
const double STROKE_HEIGHT_TO_SIZE = 0.656; const double STROKE_HEIGHT_TO_SIZE = 0.656;
const double STROKE_WIDTH_TO_SIZE = 0.69; const double STROKE_WIDTH_TO_SIZE = 0.69;
// TrueType font // TrueType font
const double TRUETYPE_HEIGHT_TO_SIZE = 0.585; const double TRUETYPE_HEIGHT_TO_SIZE = 0.585;
const double TRUETYPE_WIDTH_TO_SIZE = 0.585; const double TRUETYPE_WIDTH_TO_SIZE = 0.585;
@ -51,6 +53,7 @@ const double TRUETYPE_THICK_PER_HEIGHT = 0.073;
const double TRUETYPE_BOLD_THICK_MUL = 1.6; const double TRUETYPE_BOLD_THICK_MUL = 1.6;
const long TRUETYPE_BOLD_MIN_WEIGHT = 700; const long TRUETYPE_BOLD_MIN_WEIGHT = 700;
wxString GetWord( wxString* aStr ) wxString GetWord( wxString* aStr )
{ {
wxString result = wxEmptyString; wxString result = wxEmptyString;
@ -100,7 +103,7 @@ XNODE* FindPinMap( XNODE* aNode )
{ {
XNODE* result, * lNode; XNODE* result, * lNode;
result = NULL; result = nullptr;
lNode = FindNode( aNode, wxT( "attachedPattern" ) ); lNode = FindNode( aNode, wxT( "attachedPattern" ) );
if( lNode ) if( lNode )
@ -110,7 +113,8 @@ XNODE* FindPinMap( XNODE* aNode )
} }
double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, const wxString& aActualConversion ) double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe,
const wxString& aActualConversion )
{ {
wxString ls; wxString ls;
double i; double i;
@ -145,11 +149,13 @@ double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, const wxStrin
if( u == wxT( 'm' ) ) if( u == wxT( 'm' ) )
{ {
ls.ToCDouble( &i ); ls.ToCDouble( &i );
#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID #ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
if( aActualConversion == wxT( "SCH" ) if( aActualConversion == wxT( "SCH" )
|| aActualConversion == wxT( "SCHLIB" ) ) || aActualConversion == wxT( "SCHLIB" ) )
i = i * (0.0254 / 0.025); i = i * (0.0254 / 0.025);
#endif #endif
i = Millimeter2iu( i ); i = Millimeter2iu( i );
} }
else else
@ -159,7 +165,9 @@ double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, const wxStrin
} }
} }
else else
{
i = 0.0; i = 0.0;
}
if( ( aActualConversion == wxT( "PCB" ) || aActualConversion == wxT( "SCH" ) ) if( ( aActualConversion == wxT( "PCB" ) || aActualConversion == wxT( "SCH" ) )
&& aAxe == wxT( 'Y' ) ) && aAxe == wxT( 'Y' ) )
@ -243,55 +251,41 @@ wxString ValidateReference( wxString aRef )
} }
void SetWidth( wxString aStr, void SetWidth( wxString aStr, const wxString& aDefaultMeasurementUnit, int* aWidth,
const wxString& aDefaultMeasurementUnit,
int* aWidth,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
*aWidth = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, *aWidth = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, aDefaultMeasurementUnit ),
aDefaultMeasurementUnit ), wxT( ' ' ), wxT( ' ' ), aActualConversion );
aActualConversion );
} }
void SetHeight( wxString aStr, void SetHeight( wxString aStr, const wxString& aDefaultMeasurementUnit, int* aHeight,
const wxString& aDefaultMeasurementUnit,
int* aHeight,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
*aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, aDefaultMeasurementUnit ),
aDefaultMeasurementUnit ), wxT( ' ' ), wxT( ' ' ), aActualConversion );
aActualConversion );
} }
void SetPosition( wxString aStr, void SetPosition( wxString aStr, const wxString& aDefaultMeasurementUnit, int* aX, int* aY,
const wxString& aDefaultMeasurementUnit,
int* aX,
int* aY,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
*aX = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, *aX = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, aDefaultMeasurementUnit ),
aDefaultMeasurementUnit ), wxT( 'X' ), wxT( 'X' ), aActualConversion );
aActualConversion ); *aY = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, aDefaultMeasurementUnit ),
*aY = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr, wxT( 'Y' ), aActualConversion );
aDefaultMeasurementUnit ), wxT( 'Y' ),
aActualConversion );
} }
void SetDoublePrecisionPosition( wxString aStr, void SetDoublePrecisionPosition( wxString aStr, const wxString& aDefaultMeasurementUnit, double* aX,
const wxString& aDefaultMeasurementUnit, double* aY, const wxString& aActualConversion )
double* aX,
double* aY,
const wxString& aActualConversion )
{ {
*aX = StrToDoublePrecisionUnits( GetAndCutWordWithMeasureUnits( &aStr, *aX = StrToDoublePrecisionUnits(
aDefaultMeasurementUnit ), wxT( 'X' ), GetAndCutWordWithMeasureUnits( &aStr, aDefaultMeasurementUnit ), wxT( 'X' ),
aActualConversion ); aActualConversion );
*aY = StrToDoublePrecisionUnits( GetAndCutWordWithMeasureUnits( &aStr, *aY = StrToDoublePrecisionUnits(
aDefaultMeasurementUnit ), wxT( 'Y' ), GetAndCutWordWithMeasureUnits( &aStr, aDefaultMeasurementUnit ), wxT( 'Y' ),
aActualConversion ); aActualConversion );
} }
@ -322,22 +316,17 @@ TTEXT_JUSTIFY GetJustifyIdentificator( const wxString& aJustify )
} }
void SetTextParameters( XNODE* aNode, void SetTextParameters( XNODE* aNode, TTEXTVALUE* aTextValue,
TTEXTVALUE* aTextValue, const wxString& aDefaultMeasurementUnit, const wxString& aActualConversion )
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion )
{ {
XNODE* tNode; XNODE* tNode;
wxString str; wxString str;
tNode = FindNode( aNode, wxT( "pt" ) ); tNode = FindNode( aNode, wxT( "pt" ) );
if( tNode ) if( tNode )
SetPosition( tNode->GetNodeContent(), SetPosition( tNode->GetNodeContent(), aDefaultMeasurementUnit, &aTextValue->textPositionX,
aDefaultMeasurementUnit, &aTextValue->textPositionY, aActualConversion );
&aTextValue->textPositionX,
&aTextValue->textPositionY,
aActualConversion );
tNode = FindNode( aNode, wxT( "rotation" ) ); tNode = FindNode( aNode, wxT( "rotation" ) );
@ -376,9 +365,7 @@ void SetTextParameters( XNODE* aNode,
} }
void SetFontProperty( XNODE* aNode, void SetFontProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aDefaultMeasurementUnit,
TTEXTVALUE* aTextValue,
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
wxString n, propValue; wxString n, propValue;
@ -389,6 +376,7 @@ void SetFontProperty( XNODE* aNode,
aNode = aNode->GetParent(); aNode = aNode->GetParent();
aNode = FindNode( aNode, wxT( "library" ) ); aNode = FindNode( aNode, wxT( "library" ) );
if( aNode ) if( aNode )
aNode = FindNode( aNode, wxT( "textStyleDef" ) ); aNode = FindNode( aNode, wxT( "textStyleDef" ) );
@ -413,6 +401,7 @@ void SetFontProperty( XNODE* aNode,
aNode = FindNode( aNode, wxT( "font" ) ); aNode = FindNode( aNode, wxT( "font" ) );
fontType = FindNodeGetContent( aNode, wxT( "fontType" ) ); fontType = FindNodeGetContent( aNode, wxT( "fontType" ) );
if( ( aTextValue->isTrueType && ( fontType != wxT( "TrueType" ) ) ) || if( ( aTextValue->isTrueType && ( fontType != wxT( "TrueType" ) ) ) ||
( !aTextValue->isTrueType && ( fontType != wxT( "Stroke" ) ) ) ) ( !aTextValue->isTrueType && ( fontType != wxT( "Stroke" ) ) ) )
aNode = aNode->GetNext(); aNode = aNode->GetNext();
@ -425,6 +414,7 @@ void SetFontProperty( XNODE* aNode,
aTextValue->isItalic = ( propValue == wxT( "True" ) ); aTextValue->isItalic = ( propValue == wxT( "True" ) );
propValue = FindNodeGetContent( aNode, wxT( "fontWeight" ) ); propValue = FindNodeGetContent( aNode, wxT( "fontWeight" ) );
if( propValue != wxEmptyString ) if( propValue != wxEmptyString )
{ {
long fontWeight; long fontWeight;
@ -437,6 +427,7 @@ void SetFontProperty( XNODE* aNode,
XNODE* lNode; XNODE* lNode;
lNode = FindNode( aNode, wxT( "fontHeight" ) ); lNode = FindNode( aNode, wxT( "fontHeight" ) );
if( lNode ) if( lNode )
SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit, SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&aTextValue->textHeight, aActualConversion ); &aTextValue->textHeight, aActualConversion );
@ -444,12 +435,14 @@ void SetFontProperty( XNODE* aNode,
if( aTextValue->isTrueType ) if( aTextValue->isTrueType )
{ {
aTextValue->textstrokeWidth = TRUETYPE_THICK_PER_HEIGHT * aTextValue->textHeight; aTextValue->textstrokeWidth = TRUETYPE_THICK_PER_HEIGHT * aTextValue->textHeight;
if( aTextValue->isBold ) if( aTextValue->isBold )
aTextValue->textstrokeWidth *= TRUETYPE_BOLD_THICK_MUL; aTextValue->textstrokeWidth *= TRUETYPE_BOLD_THICK_MUL;
} }
else else
{ {
lNode = FindNode( aNode, wxT( "strokeWidth" ) ); lNode = FindNode( aNode, wxT( "strokeWidth" ) );
if( lNode ) if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&aTextValue->textstrokeWidth, aActualConversion ); &aTextValue->textstrokeWidth, aActualConversion );
@ -518,21 +511,16 @@ void CorrectTextPosition( TTEXTVALUE* aValue )
int posX = 0; int posX = 0;
int posY = 0; int posY = 0;
if( aValue->justify == LowerLeft || if( aValue->justify == LowerLeft || aValue->justify == Left || aValue->justify == UpperLeft )
aValue->justify == Left ||
aValue->justify == UpperLeft )
posX += cl * cm; posX += cl * cm;
else if( aValue->justify == LowerRight || else if( aValue->justify == LowerRight || aValue->justify == Right ||
aValue->justify == Right ||
aValue->justify == UpperRight ) aValue->justify == UpperRight )
posX -= cl * cm; posX -= cl * cm;
if( aValue->justify == LowerLeft || if( aValue->justify == LowerLeft || aValue->justify == LowerCenter ||
aValue->justify == LowerCenter ||
aValue->justify == LowerRight ) aValue->justify == LowerRight )
posY -= ch; posY -= ch;
else if( aValue->justify == UpperLeft || else if( aValue->justify == UpperLeft || aValue->justify == UpperCenter ||
aValue->justify == UpperCenter ||
aValue->justify == UpperRight ) aValue->justify == UpperRight )
posY += ch; posY += ch;
@ -569,9 +557,10 @@ XNODE* FindNode( XNODE* aChild, const wxString& aTag )
aChild = aChild->GetNext(); aChild = aChild->GetNext();
} }
return NULL; return nullptr;
} }
wxString FindNodeGetContent( XNODE* aChild, const wxString& aTag ) wxString FindNodeGetContent( XNODE* aChild, const wxString& aTag )
{ {
wxString str = wxEmptyString; wxString str = wxEmptyString;
@ -588,6 +577,7 @@ wxString FindNodeGetContent( XNODE* aChild, const wxString& aTag )
return str; return str;
} }
void InitTTextValue( TTEXTVALUE* aTextValue ) void InitTTextValue( TTEXTVALUE* aTextValue )
{ {
aTextValue->text = wxEmptyString; aTextValue->text = wxEmptyString;

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) 2012 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -41,10 +41,11 @@
using namespace PCAD2KICAD; using namespace PCAD2KICAD;
PCAD_PLUGIN::PCAD_PLUGIN() PCAD_PLUGIN::PCAD_PLUGIN()
{ {
m_board = NULL; m_board = nullptr;
m_props = NULL; m_props = nullptr;
} }
@ -84,7 +85,7 @@ BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
LoadInputFile( aFileName, &xmlDoc ); LoadInputFile( aFileName, &xmlDoc );
pcb.ParseBoard( NULL, &xmlDoc, wxT( "PCB" ) ); pcb.ParseBoard( nullptr, &xmlDoc, wxT( "PCB" ) );
pcb.AddToBoard(); pcb.AddToBoard();
return m_board; return m_board;

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -42,6 +42,7 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) const PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) const
{ {
auto it = m_LayersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
@ -52,6 +53,7 @@ PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) const
return it->second.KiCadLayer; return it->second.KiCadLayer;
} }
LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) const LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) const
{ {
auto it = m_LayersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
@ -62,6 +64,7 @@ LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) const
return it->second.layerType; return it->second.layerType;
} }
wxString PCB::GetLayerNetNameRef( int aPCadLayer ) const wxString PCB::GetLayerNetNameRef( int aPCadLayer ) const
{ {
auto it = m_LayersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
@ -72,6 +75,7 @@ wxString PCB::GetLayerNetNameRef( int aPCadLayer ) const
return it->second.netNameRef; return it->second.netNameRef;
} }
PCB::PCB( BOARD* aBoard ) : PCB::PCB( BOARD* aBoard ) :
PCB_FOOTPRINT( this, aBoard ) PCB_FOOTPRINT( this, aBoard )
{ {
@ -137,7 +141,7 @@ int PCB::GetNetCode( const wxString& aNetName ) const
XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const
{ {
XNODE* result = NULL, * lNode; XNODE* result = nullptr, * lNode;
wxString propValue; wxString propValue;
lNode = FindNode( aNode, wxT( "compDef" ) ); lNode = FindNode( aNode, wxT( "compDef" ) );
@ -151,7 +155,7 @@ XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const
if( propValue == aName ) if( propValue == aName )
{ {
result = lNode; result = lNode;
lNode = NULL; lNode = nullptr;
} }
} }
@ -163,10 +167,8 @@ XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const
} }
void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aPatGraphRefName,
const wxString& aPatGraphRefName, const wxString& aXmlName, const wxString& aActualConversion )
const wxString& aXmlName,
const wxString& aActualConversion )
{ {
XNODE* tNode, * t1Node; XNODE* tNode, * t1Node;
wxString n, nnew, pn, propValue, str; wxString n, nnew, pn, propValue, str;
@ -204,7 +206,7 @@ void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue,
str.Trim( true ); str.Trim( true );
nnew = n; // new file version nnew = n; // new file version
n = n + wxT( ' ' ) + str; // old file version n = n + wxT( ' ' ) + str; // old file version
tNode = NULL; tNode = nullptr;
} }
} }
} }
@ -234,10 +236,8 @@ void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue,
} }
void PCB::DoPCBComponents( XNODE* aNode, void PCB::DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString& aActualConversion,
wxXmlDocument* aXmlDoc, wxStatusBar* aStatusBar )
const wxString& aActualConversion,
wxStatusBar* aStatusBar )
{ {
XNODE* lNode, * tNode, * mNode; XNODE* lNode, * tNode, * mNode;
PCB_FOOTPRINT* fp; PCB_FOOTPRINT* fp;
@ -250,7 +250,7 @@ void PCB::DoPCBComponents( XNODE* aNode,
while( lNode ) while( lNode )
{ {
fp = NULL; fp = nullptr;
if( lNode->GetName() == wxT( "pattern" ) ) if( lNode->GetName() == wxT( "pattern" ) )
{ {
@ -268,6 +268,7 @@ void PCB::DoPCBComponents( XNODE* aNode,
fp = new PCB_FOOTPRINT( this, m_board ); fp = new PCB_FOOTPRINT( this, m_board );
mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) ); mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) );
if( mNode ) if( mNode )
mNode->GetAttribute( wxT( "Name" ), &fp->m_patGraphRefName ); mNode->GetAttribute( wxT( "Name" ), &fp->m_patGraphRefName );
@ -346,10 +347,12 @@ void PCB::DoPCBComponents( XNODE* aNode,
fp->m_compRef.Trim( true ); fp->m_compRef.Trim( true );
} }
tNode = NULL; tNode = nullptr;
} }
else else
{
tNode = tNode->GetNext(); tNode = tNode->GetNext();
}
} }
} }
@ -462,24 +465,6 @@ int PCB::FindLayer( const wxString& aLayerName ) const
} }
/* KiCad layers
* 0 Copper layer
* 1 to 14 Inner layers
* 15 Component layer
* 16 Copper side adhesive layer Technical layers
* 17 Component side adhesive layer
* 18 Copper side Solder paste layer
* 19 Component Solder paste layer
* 20 Copper side Silk screen layer
* 21 Component Silk screen layer
* 22 Copper side Solder mask layer
* 23 Component Solder mask layer
* 24 Draw layer (Used for general drawings)
* 25 Comment layer (Other layer used for general drawings)
* 26 ECO1 layer (Other layer used for general drawings) // BUG
* 26 ECO2 layer (Other layer used for general drawings) // BUG 27
* 27 Edge layer. Items on Edge layer are seen on all layers // BUG 28
*/
void PCB::MapLayer( XNODE* aNode ) void PCB::MapLayer( XNODE* aNode )
{ {
wxString lName, layerType; wxString lName, layerType;
@ -490,27 +475,49 @@ void PCB::MapLayer( XNODE* aNode )
lName = lName.MakeUpper(); lName = lName.MakeUpper();
if( lName == wxT( "TOP ASSY" ) ) if( lName == wxT( "TOP ASSY" ) )
{
KiCadLayer = F_Fab; KiCadLayer = F_Fab;
}
else if( lName == wxT( "TOP SILK" ) ) else if( lName == wxT( "TOP SILK" ) )
{
KiCadLayer = F_SilkS; KiCadLayer = F_SilkS;
}
else if( lName == wxT( "TOP PASTE" ) ) else if( lName == wxT( "TOP PASTE" ) )
{
KiCadLayer = F_Paste; KiCadLayer = F_Paste;
}
else if( lName == wxT( "TOP MASK" ) ) else if( lName == wxT( "TOP MASK" ) )
{
KiCadLayer = F_Mask; KiCadLayer = F_Mask;
}
else if( lName == wxT( "TOP" ) ) else if( lName == wxT( "TOP" ) )
{
KiCadLayer = F_Cu; KiCadLayer = F_Cu;
}
else if( lName == wxT( "BOTTOM" ) ) else if( lName == wxT( "BOTTOM" ) )
{
KiCadLayer = B_Cu; KiCadLayer = B_Cu;
}
else if( lName == wxT( "BOT MASK" ) ) else if( lName == wxT( "BOT MASK" ) )
{
KiCadLayer = B_Mask; KiCadLayer = B_Mask;
}
else if( lName == wxT( "BOT PASTE" ) ) else if( lName == wxT( "BOT PASTE" ) )
{
KiCadLayer = B_Paste; KiCadLayer = B_Paste;
}
else if( lName == wxT( "BOT SILK" ) ) else if( lName == wxT( "BOT SILK" ) )
{
KiCadLayer = B_SilkS; KiCadLayer = B_SilkS;
}
else if( lName == wxT( "BOT ASSY" ) ) else if( lName == wxT( "BOT ASSY" ) )
{
KiCadLayer = B_Fab; KiCadLayer = B_Fab;
}
else if( lName == wxT( "BOARD" ) ) else if( lName == wxT( "BOARD" ) )
{
KiCadLayer = Edge_Cuts; KiCadLayer = Edge_Cuts;
}
else else
{ {
int layernum = FindLayer( lName ); int layernum = FindLayer( lName );
@ -540,8 +547,10 @@ void PCB::MapLayer( XNODE* aNode )
if( layerType == wxT( "NonSignal" ) ) if( layerType == wxT( "NonSignal" ) )
newlayer.layerType = LAYER_TYPE_NONSIGNAL; newlayer.layerType = LAYER_TYPE_NONSIGNAL;
if( layerType == wxT( "Signal" ) ) if( layerType == wxT( "Signal" ) )
newlayer.layerType = LAYER_TYPE_SIGNAL; newlayer.layerType = LAYER_TYPE_SIGNAL;
if( layerType == wxT( "Plane" ) ) if( layerType == wxT( "Plane" ) )
newlayer.layerType = LAYER_TYPE_PLANE; newlayer.layerType = LAYER_TYPE_PLANE;
} }
@ -560,12 +569,15 @@ int PCB::FindOutlinePoint( const VERTICES_ARRAY* aOutline, wxRealPoint aPoint )
int i; int i;
for( i = 0; i < (int) aOutline->GetCount(); i++ ) for( i = 0; i < (int) aOutline->GetCount(); i++ )
{
if( *((*aOutline)[i]) == aPoint ) if( *((*aOutline)[i]) == aPoint )
return i; return i;
}
return -1; return -1;
} }
/*int cmpFunc( wxRealPoint **first, wxRealPoint **second ) /*int cmpFunc( wxRealPoint **first, wxRealPoint **second )
{ {
return sqrt( pow( (double) aPointA.x - (double) aPointB.x, 2 ) + return sqrt( pow( (double) aPointA.x - (double) aPointB.x, 2 ) +
@ -573,12 +585,12 @@ int PCB::FindOutlinePoint( const VERTICES_ARRAY* aOutline, wxRealPoint aPoint )
return 0; return 0;
}*/ }*/
double PCB::GetDistance( const wxRealPoint* aPoint1, const wxRealPoint* aPoint2 ) const double PCB::GetDistance( const wxRealPoint* aPoint1, const wxRealPoint* aPoint2 ) const
{ {
return sqrt( ( aPoint1->x - aPoint2->x ) * return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
( aPoint1->x - aPoint2->x ) + ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
( aPoint1->y - aPoint2->y ) *
( aPoint1->y - aPoint2->y ) );
} }
void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion ) void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion )
@ -607,6 +619,7 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
if( GetKiCadLayer( PCadLayer ) == Edge_Cuts ) if( GetKiCadLayer( PCadLayer ) == Edge_Cuts )
{ {
lNode = iNode->GetChildren(); lNode = iNode->GetChildren();
while( lNode ) while( lNode )
{ {
if( lNode->GetName() == wxT( "line" ) ) if( lNode->GetName() == wxT( "line" ) )
@ -650,6 +663,7 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
for( j = i + 2; j < (int) m_BoardOutline.GetCount(); j++ ) for( j = i + 2; j < (int) m_BoardOutline.GetCount(); j++ )
{ {
distance = GetDistance( m_BoardOutline[i], m_BoardOutline[j] ); distance = GetDistance( m_BoardOutline[i], m_BoardOutline[j] );
if( distance < minDistance ) if( distance < minDistance )
{ {
minDistance = distance; minDistance = distance;
@ -672,7 +686,9 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
} }
} }
void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxString& aActualConversion )
void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
const wxString& aActualConversion )
{ {
XNODE* aNode;//, *aaNode; XNODE* aNode;//, *aaNode;
PCB_NET* net; PCB_NET* net;
@ -811,7 +827,7 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
// objects // objects
if( aNode->GetName() == wxT( "layerContents" ) ) if( aNode->GetName() == wxT( "layerContents" ) )
DoLayerContentsObjects( aNode, NULL, &m_PcbComponents, aStatusBar, DoLayerContentsObjects( aNode, nullptr, &m_PcbComponents, aStatusBar,
m_DefaultMeasurementUnit, aActualConversion ); m_DefaultMeasurementUnit, aActualConversion );
aNode = aNode->GetNext(); aNode = aNode->GetNext();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -44,6 +44,7 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
PCB_FOOTPRINT::PCB_FOOTPRINT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_FOOTPRINT::PCB_FOOTPRINT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard ) PCB_COMPONENT( aCallbacks, aBoard )
{ {
@ -70,7 +71,7 @@ XNODE* PCB_FOOTPRINT::FindModulePatternDefName( XNODE* aNode, const wxString& aN
XNODE* result, * lNode; XNODE* result, * lNode;
wxString propValue1, propValue2; wxString propValue1, propValue2;
result = NULL; result = nullptr;
lNode = FindNode( aNode, wxT( "patternDef" ) ); lNode = FindNode( aNode, wxT( "patternDef" ) );
while( lNode ) while( lNode )
@ -81,11 +82,10 @@ XNODE* PCB_FOOTPRINT::FindModulePatternDefName( XNODE* aNode, const wxString& aN
FindNode( lNode, FindNode( lNode,
wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue2 ); wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue2 );
if( ValidateName( propValue1 ) == aName if( ValidateName( propValue1 ) == aName || ValidateName( propValue2 ) == aName )
|| ValidateName( propValue2 ) == aName )
{ {
result = lNode; result = lNode;
lNode = NULL; lNode = nullptr;
} }
} }
@ -93,7 +93,7 @@ XNODE* PCB_FOOTPRINT::FindModulePatternDefName( XNODE* aNode, const wxString& aN
lNode = lNode->GetNext(); lNode = lNode->GetNext();
} }
if( result == NULL ) if( result == nullptr )
{ {
lNode = FindNode( aNode, wxT( "patternDefExtended" ) ); // New file format lNode = FindNode( aNode, wxT( "patternDefExtended" ) ); // New file format
@ -106,7 +106,7 @@ XNODE* PCB_FOOTPRINT::FindModulePatternDefName( XNODE* aNode, const wxString& aN
if( ValidateName( propValue1 ) == aName ) if( ValidateName( propValue1 ) == aName )
{ {
result = lNode; result = lNode;
lNode = NULL; lNode = nullptr;
} }
} }
@ -124,7 +124,7 @@ XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPat
XNODE* result, * pNode, * lNode; XNODE* result, * pNode, * lNode;
wxString propValue, patName; wxString propValue, patName;
result = NULL; result = nullptr;
pNode = aNode; // pattern; pNode = aNode; // pattern;
lNode = aNode; lNode = aNode;
@ -148,7 +148,7 @@ XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPat
pNode = lNode; // pattern; pNode = lNode; // pattern;
} }
lNode = NULL; lNode = nullptr;
if( pNode ) if( pNode )
lNode = FindNode( pNode, wxT( "multiLayer" ) ); // Old file format lNode = FindNode( pNode, wxT( "multiLayer" ) ); // Old file format
@ -182,7 +182,7 @@ XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPat
if( lNode ) if( lNode )
{ {
result = FindNode( lNode, wxT( "multiLayer" ) ); result = FindNode( lNode, wxT( "multiLayer" ) );
lNode = NULL; lNode = nullptr;
} }
} }
@ -197,13 +197,17 @@ XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPat
if( propValue == *aPatGraphRefName ) if( propValue == *aPatGraphRefName )
{ {
result = FindNode( lNode, wxT( "multiLayer" ) ); result = FindNode( lNode, wxT( "multiLayer" ) );
lNode = NULL; lNode = nullptr;
} }
else else
{
lNode = lNode->GetNext(); lNode = lNode->GetNext();
}
} }
else else
{
lNode = lNode->GetNext(); lNode = lNode->GetNext();
}
} }
} }
@ -211,16 +215,14 @@ XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPat
} }
void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode, void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode, PCB_FOOTPRINT* aFootprint,
PCB_FOOTPRINT* aFootprint, PCB_COMPONENTS_ARRAY* aList, wxStatusBar* aStatusBar,
PCB_COMPONENTS_ARRAY* aList, const wxString& aDefaultMeasurementUnit,
wxStatusBar* aStatusBar, const wxString& aActualConversion )
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion )
{ {
PCB_ARC* arc; PCB_ARC* arc;
PCB_POLYGON* polygon; PCB_POLYGON* polygon;
PCB_POLYGON *plane_layer = NULL; PCB_POLYGON *plane_layer = nullptr;
PCB_COPPER_POUR* copperPour; PCB_COPPER_POUR* copperPour;
PCB_CUTOUT* cutout; PCB_CUTOUT* cutout;
PCB_PLANE* plane; PCB_PLANE* plane;
@ -234,6 +236,7 @@ void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode,
long num = 0; long num = 0;
i = 0; i = 0;
// aStatusBar->SetStatusText( wxT( "Processing LAYER CONTENT OBJECTS " ) ); // aStatusBar->SetStatusText( wxT( "Processing LAYER CONTENT OBJECTS " ) );
if( FindNode( aNode, wxT( "layerNumRef" ) ) ) if( FindNode( aNode, wxT( "layerNumRef" ) ) )
FindNode( aNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &num ); FindNode( aNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &num );
@ -294,9 +297,7 @@ void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode,
// function CreatePCBModule(). However it is not clear whether the access is // function CreatePCBModule(). However it is not clear whether the access is
// required when the function DoLayerContentsObjects() is called from // required when the function DoLayerContentsObjects() is called from
// function ProcessXMLtoPCBLib(). // function ProcessXMLtoPCBLib().
SetFontProperty( tNode, SetFontProperty( tNode, &aFootprint->m_name, aDefaultMeasurementUnit,
&aFootprint->m_name,
aDefaultMeasurementUnit,
aActualConversion ); aActualConversion );
} }
} }
@ -316,15 +317,15 @@ void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode,
{ {
plane_layer_polygon = new VERTICES_ARRAY; plane_layer_polygon = new VERTICES_ARRAY;
wxASSERT( plane_layer ); wxASSERT( plane_layer );
plane_layer->FormPolygon( lNode, plane_layer_polygon, aDefaultMeasurementUnit, aActualConversion ); plane_layer->FormPolygon( lNode, plane_layer_polygon, aDefaultMeasurementUnit,
aActualConversion );
plane_layer->m_cutouts.Add( plane_layer_polygon ); plane_layer->m_cutouts.Add( plane_layer_polygon );
} }
else else
{ {
polygon = new PCB_POLYGON( m_callbacks, m_board, PCadLayer ); polygon = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
if( polygon->Parse( lNode,
aDefaultMeasurementUnit, if( polygon->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
aActualConversion ) )
aList->Add( polygon ); aList->Add( polygon );
else else
delete polygon; delete polygon;
@ -376,15 +377,15 @@ void PCB_FOOTPRINT::SetName( const wxString& aPin, const wxString& aName )
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ ) for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
{ {
if( m_FootprintItems[i]->m_objType == wxT( 'P' ) ) if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
if(( (PCB_PAD*) m_FootprintItems[i] )->m_Number == num ) {
if( ( (PCB_PAD*) m_FootprintItems[i] )->m_Number == num )
( (PCB_PAD*) m_FootprintItems[i] )->m_name.text = aName; ( (PCB_PAD*) m_FootprintItems[i] )->m_name.text = aName;
}
} }
} }
void PCB_FOOTPRINT::Parse( XNODE* aNode, wxStatusBar* aStatusBar, void PCB_FOOTPRINT::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
const wxString& aDefaultMeasurementUnit, const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion ) const wxString& aActualConversion )
{ {
@ -393,8 +394,7 @@ void PCB_FOOTPRINT::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
PCB_VIA* via; PCB_VIA* via;
wxString propValue, str; wxString propValue, str;
FindNode( aNode, wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), FindNode( aNode, wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue );
&propValue );
propValue.Trim( false ); propValue.Trim( false );
m_name.text = propValue; m_name.text = propValue;
@ -524,6 +524,7 @@ void PCB_FOOTPRINT::AddToBoard()
ref_text->SetType( FP_TEXT::TEXT_is_REFERENCE ); ref_text->SetType( FP_TEXT::TEXT_is_REFERENCE );
ref_text->SetPos0( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) ); ref_text->SetPos0( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) );
if( m_name.isTrueType ) if( m_name.isTrueType )
SetTextSizeFromTrueTypeFontHeight( ref_text, m_name.textHeight ); SetTextSizeFromTrueTypeFontHeight( ref_text, m_name.textHeight );
else else
@ -551,6 +552,7 @@ void PCB_FOOTPRINT::AddToBoard()
val_text->SetType( FP_TEXT::TEXT_is_VALUE ); val_text->SetType( FP_TEXT::TEXT_is_VALUE );
val_text->SetPos0( wxPoint( m_Value.correctedPositionX, m_Value.correctedPositionY ) ); val_text->SetPos0( wxPoint( m_Value.correctedPositionX, m_Value.correctedPositionY ) );
if( m_Value.isTrueType ) if( m_Value.isTrueType )
SetTextSizeFromTrueTypeFontHeight( val_text, m_Value.textHeight ); SetTextSizeFromTrueTypeFontHeight( val_text, m_Value.textHeight );
else else

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -38,6 +38,7 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard ) PCB_COMPONENT( aCallbacks, aBoard )
{ {
@ -118,6 +119,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultUnits,
if( lNode ) if( lNode )
{ {
lNode->GetAttribute( wxT( "Name" ), &propValue ); lNode->GetAttribute( wxT( "Name" ), &propValue );
//propValue.Trim( false ); //propValue.Trim( false );
m_defaultPinDes = propValue; m_defaultPinDes = propValue;
} }
@ -245,6 +247,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
pad->SetLayerSet( LSET( 3, F_Cu, F_Paste, F_Mask ) ); pad->SetLayerSet( LSET( 3, F_Cu, F_Paste, F_Mask ) );
else else
pad->SetLayerSet( LSET( 3, B_Cu, B_Paste, B_Mask ) ); pad->SetLayerSet( LSET( 3, B_Cu, B_Paste, B_Mask ) );
break; break;
} }
} }
@ -272,11 +275,17 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
pad->SetShape( PAD_SHAPE::CIRCLE ); pad->SetShape( PAD_SHAPE::CIRCLE );
} }
else if( padShapeName == wxT( "Rect" ) ) else if( padShapeName == wxT( "Rect" ) )
{
pad->SetShape( PAD_SHAPE::RECT ); pad->SetShape( PAD_SHAPE::RECT );
}
else if( padShapeName == wxT( "RndRect" ) ) else if( padShapeName == wxT( "RndRect" ) )
{
pad->SetShape( PAD_SHAPE::ROUNDRECT ); pad->SetShape( PAD_SHAPE::ROUNDRECT );
}
else if( padShapeName == wxT( "Polygon" ) ) else if( padShapeName == wxT( "Polygon" ) )
{
pad->SetShape( PAD_SHAPE::RECT ); // approximation pad->SetShape( PAD_SHAPE::RECT ); // approximation
}
pad->SetSize( wxSize( width, height ) ); pad->SetSize( wxSize( width, height ) );
pad->SetDelta( wxSize( 0, 0 ) ); pad->SetDelta( wxSize( 0, 0 ) );
@ -291,7 +300,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
// Set the proper net code // Set the proper net code
NETINFO_ITEM* netinfo = m_board->FindNet( m_net ); NETINFO_ITEM* netinfo = m_board->FindNet( m_net );
if( netinfo == NULL ) // I believe this should not happen, but just in case if( netinfo == nullptr ) // I believe this should not happen, but just in case
{ {
// It is a new net // It is a new net
netinfo = new NETINFO_ITEM( m_board, m_net ); netinfo = new NETINFO_ITEM( m_board, m_net );

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) 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.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
@ -36,11 +36,12 @@ namespace PCAD2KICAD {
static KEYWORD empty_keywords[1] = {}; static KEYWORD empty_keywords[1] = {};
static const char ACCEL_ASCII_KEYWORD[] = "ACCEL_ASCII"; static const char ACCEL_ASCII_KEYWORD[] = "ACCEL_ASCII";
void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc )
void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc )
{ {
char line[sizeof( ACCEL_ASCII_KEYWORD )]; char line[sizeof( ACCEL_ASCII_KEYWORD )];
int tok; int tok;
XNODE* iNode = NULL, *cNode = NULL; XNODE* iNode = nullptr, *cNode = nullptr;
wxString str, propValue, content; wxString str, propValue, content;
wxCSConv conv( wxT( "windows-1251" ) ); wxCSConv conv( wxT( "windows-1251" ) );
@ -80,6 +81,7 @@ void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc )
else if( cNode ) else if( cNode )
{ {
str = wxString( lexer.CurText(), conv ); str = wxString( lexer.CurText(), conv );
if( tok == DSN_STRING ) if( tok == DSN_STRING )
{ {
// update attribute // update attribute
@ -89,7 +91,9 @@ void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc )
iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str ); iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str );
} }
else else
{
iNode->AddAttribute( wxT( "Name" ), str ); iNode->AddAttribute( wxT( "Name" ), str );
}
} }
else if( str != wxEmptyString ) else if( str != wxEmptyString )
{ {
@ -99,9 +103,7 @@ void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc )
if( cNode->GetChildren() ) if( cNode->GetChildren() )
cNode->GetChildren()->SetContent( content ); cNode->GetChildren()->SetContent( content );
else else
cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE, cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE, wxEmptyString, content ) );
wxEmptyString,
content ) );
} }
} }
} }

View File

@ -57,6 +57,7 @@ PyObject* PYTHON_ACTION_PLUGIN::CallMethod( const char* aMethod, PyObject* aArgl
PyLOCK lock; PyLOCK lock;
PyErr_Clear(); PyErr_Clear();
// pFunc is a new reference to the desired method // pFunc is a new reference to the desired method
PyObject* pFunc = PyObject_GetAttrString( m_PyAction, aMethod ); PyObject* pFunc = PyObject_GetAttrString( m_PyAction, aMethod );
@ -67,8 +68,8 @@ PyObject* PYTHON_ACTION_PLUGIN::CallMethod( const char* aMethod, PyObject* aArgl
if( PyErr_Occurred() ) if( PyErr_Occurred() )
{ {
wxMessageBox( PyErrStringWithTraceback(), wxMessageBox( PyErrStringWithTraceback(),
_( "Exception on python action plugin code" ), _( "Exception on python action plugin code" ),
wxICON_ERROR | wxOK ); wxICON_ERROR | wxOK );
} }
if( result ) if( result )
@ -88,7 +89,7 @@ PyObject* PYTHON_ACTION_PLUGIN::CallMethod( const char* aMethod, PyObject* aArgl
Py_XDECREF( pFunc ); Py_XDECREF( pFunc );
} }
return NULL; return nullptr;
} }
@ -258,7 +259,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
ACTION_PLUGINS::SetActionRunning( false ); ACTION_PLUGINS::SetActionRunning( false );
// Get back the undo buffer to fix some modifications // Get back the undo buffer to fix some modifications
PICKED_ITEMS_LIST* oldBuffer = NULL; PICKED_ITEMS_LIST* oldBuffer = nullptr;
if( fromEmpty ) if( fromEmpty )
{ {
@ -313,6 +314,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
{ {
oldBuffer->PushItem( deletedItemsList.GetItemWrapper( i ) ); oldBuffer->PushItem( deletedItemsList.GetItemWrapper( i ) );
} }
// Find new footprints // Find new footprints
for( FOOTPRINT* item : currentPcb->Footprints() ) for( FOOTPRINT* item : currentPcb->Footprints() )
{ {
@ -379,12 +381,13 @@ void PCB_EDIT_FRAME::buildActionPluginMenus( ACTION_MENU* actionMenu )
{ {
wxMenuItem* item; wxMenuItem* item;
ACTION_PLUGIN* ap = ACTION_PLUGINS::GetAction( ii ); ACTION_PLUGIN* ap = ACTION_PLUGINS::GetAction( ii );
const wxBitmap& bitmap = ap->iconBitmap.IsOk() ? ap->iconBitmap : KiBitmap( BITMAPS::puzzle_piece ); const wxBitmap& bitmap = ap->iconBitmap.IsOk() ? ap->iconBitmap :
KiBitmap( BITMAPS::puzzle_piece );
item = AddMenuItem( actionMenu, wxID_ANY, ap->GetName(), ap->GetDescription(), bitmap ); item = AddMenuItem( actionMenu, wxID_ANY, ap->GetName(), ap->GetDescription(), bitmap );
Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED, Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginMenu ) ); wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginMenu ) );
ACTION_PLUGINS::SetActionMenu( ii, item->GetId() ); ACTION_PLUGINS::SetActionMenu( ii, item->GetId() );
} }
@ -414,11 +417,11 @@ void PCB_EDIT_FRAME::AddActionPluginTools()
else else
bitmap = KiScaledBitmap( BITMAPS::puzzle_piece, this ); bitmap = KiScaledBitmap( BITMAPS::puzzle_piece, this );
wxAuiToolBarItem* button = m_mainToolBar->AddTool( wxAuiToolBarItem* button = m_mainToolBar->AddTool( wxID_ANY, wxEmptyString,
wxID_ANY, wxEmptyString, bitmap, ap->GetName() ); bitmap, ap->GetName() );
Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED, Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginButton ) ); wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginButton ) );
// Link action plugin to button // Link action plugin to button
ACTION_PLUGINS::SetActionButton( ap, button->GetId() ); ACTION_PLUGINS::SetActionButton( ap, button->GetId() );
@ -459,7 +462,8 @@ std::vector<ACTION_PLUGIN*> PCB_EDIT_FRAME::GetOrderedActionPlugins()
} }
bool PCB_EDIT_FRAME::GetActionPluginButtonVisible( const wxString& aPluginPath, bool aPluginDefault ) bool PCB_EDIT_FRAME::GetActionPluginButtonVisible( const wxString& aPluginPath,
bool aPluginDefault )
{ {
auto& settings = m_settings->m_VisibleActionPlugins; auto& settings = m_settings->m_VisibleActionPlugins;

View File

@ -1,7 +1,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) 2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.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
@ -39,12 +39,6 @@
class PYTHON_ACTION_PLUGIN : public ACTION_PLUGIN class PYTHON_ACTION_PLUGIN : public ACTION_PLUGIN
{ {
PyObject* m_PyAction;
PyObject* CallMethod( const char* aMethod,
PyObject* aArglist = NULL );
wxString CallRetStrMethod( const char* aMethod,
PyObject* aArglist = NULL );
public: public:
PYTHON_ACTION_PLUGIN( PyObject* action ); PYTHON_ACTION_PLUGIN( PyObject* action );
~PYTHON_ACTION_PLUGIN(); ~PYTHON_ACTION_PLUGIN();
@ -56,6 +50,11 @@ public:
wxString GetPluginPath() override; wxString GetPluginPath() override;
void Run() override; void Run() override;
void* GetObject() override; void* GetObject() override;
private:
PyObject* m_PyAction;
PyObject* CallMethod( const char* aMethod, PyObject* aArglist = nullptr );
wxString CallRetStrMethod( const char* aMethod, PyObject* aArglist = nullptr );
}; };

View File

@ -89,7 +89,7 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aA
Py_XDECREF( pFunc ); Py_XDECREF( pFunc );
} }
return NULL; return nullptr;
} }
@ -127,8 +127,7 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod( const char* aMet
if( !PyList_Check( result ) ) if( !PyList_Check( result ) )
{ {
Py_DECREF( result ); Py_DECREF( result );
ret.Add( wxT( ret.Add( wxT( "PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
"PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
1 ); 1 );
return ret; return ret;
} }
@ -172,7 +171,7 @@ int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages()
PyLOCK lock; PyLOCK lock;
// Time to call the callback // Time to call the callback
PyObject* result = CallMethod( "GetNumParameterPages", NULL ); PyObject* result = CallMethod( "GetNumParameterPages", nullptr );
if( result ) if( result )
{ {
@ -327,7 +326,7 @@ void PYTHON_FOOTPRINT_WIZARD::ResetParameters()
{ {
PyLOCK lock; PyLOCK lock;
CallMethod( "ResetWizard", NULL ); CallMethod( "ResetWizard", nullptr );
} }
@ -339,13 +338,13 @@ FOOTPRINT* PYTHON_FOOTPRINT_WIZARD::GetFootprint( wxString * aMessages )
{ {
PyLOCK lock; PyLOCK lock;
PyObject* result = CallMethod( "GetFootprint", NULL ); PyObject* result = CallMethod( "GetFootprint", nullptr );
if( aMessages ) if( aMessages )
*aMessages = CallRetStrMethod( "GetBuildMessages", NULL ); *aMessages = CallRetStrMethod( "GetBuildMessages", nullptr );
if( !result ) if( !result )
return NULL; return nullptr;
PyObject* obj = PyObject_GetAttrString( result, "this" ); PyObject* obj = PyObject_GetAttrString( result, "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) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es> * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.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
@ -40,11 +40,6 @@
class PYTHON_FOOTPRINT_WIZARD : public FOOTPRINT_WIZARD class PYTHON_FOOTPRINT_WIZARD : public FOOTPRINT_WIZARD
{ {
PyObject* m_PyWizard;
PyObject* CallMethod( const char* aMethod, PyObject* aArglist = NULL );
wxString CallRetStrMethod( const char* aMethod, PyObject* aArglist = NULL );
wxArrayString CallRetArrayStrMethod( const char* aMethod, PyObject* aArglist = NULL );
public: public:
PYTHON_FOOTPRINT_WIZARD( PyObject* wizard ); PYTHON_FOOTPRINT_WIZARD( PyObject* wizard );
~PYTHON_FOOTPRINT_WIZARD(); ~PYTHON_FOOTPRINT_WIZARD();
@ -58,14 +53,22 @@ public:
wxArrayString GetParameterTypes( int aPage ) override; wxArrayString GetParameterTypes( int aPage ) override;
wxArrayString GetParameterValues( int aPage ) override; wxArrayString GetParameterValues( int aPage ) override;
wxArrayString GetParameterErrors( int aPage ) override; wxArrayString GetParameterErrors( int aPage ) override;
// must return an empty string or an error description: // must return an empty string or an error description:
wxString SetParameterValues( int aPage, wxArrayString& aValues ) override; wxString SetParameterValues( int aPage, wxArrayString& aValues ) override;
FOOTPRINT* GetFootprint( wxString * aMessages ) override; FOOTPRINT* GetFootprint( wxString * aMessages ) override;
void* GetObject() override; void* GetObject() override;
wxArrayString GetParameterHints( int aPage ) override; wxArrayString GetParameterHints( int aPage ) override;
wxArrayString GetParameterDesignators( int aPage = 0) override; wxArrayString GetParameterDesignators( int aPage = 0 ) override;
void ResetParameters() override; void ResetParameters() override;
private:
PyObject* CallMethod( const char* aMethod, PyObject* aArglist = nullptr );
wxString CallRetStrMethod( const char* aMethod, PyObject* aArglist = nullptr );
wxArrayString CallRetArrayStrMethod( const char* aMethod, PyObject* aArglist = nullptr );
PyObject* m_PyWizard;
}; };

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) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es> * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -52,8 +52,8 @@
/** /**
* Run a python method from the pcbnew module. * Run a python method from the pcbnew module.
* *
* @param aMethodName is the name of the method (like "pcbnew.myfunction" ) * @param aMethodName is the name of the method (like "pcbnew.myfunction" ).
* @param aNames will contain the returned string * @param aNames will contain the returned string.
*/ */
static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wxString& aNames ) static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wxString& aNames )
{ {
@ -84,13 +84,13 @@ static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wx
if( pobj ) if( pobj )
{ {
PyObject* str = PyDict_GetItemString(localDict, "result" ); PyObject* str = PyDict_GetItemString(localDict, "result" );
const char* str_res = NULL; const char* str_res = nullptr;
if(str) if(str)
{ {
PyObject* temp_bytes = PyUnicode_AsEncodedString( str, "UTF-8", "strict" ); PyObject* temp_bytes = PyUnicode_AsEncodedString( str, "UTF-8", "strict" );
if( temp_bytes != NULL ) if( temp_bytes != nullptr )
{ {
str_res = PyBytes_AS_STRING( temp_bytes ); str_res = PyBytes_AS_STRING( temp_bytes );
aNames = FROM_UTF8( str_res ); aNames = FROM_UTF8( str_res );
@ -98,7 +98,7 @@ static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wx
} }
else else
{ {
wxLogMessage( "cannot encode unicode python string" ); wxLogMessage( "cannot encode Unicode python string" );
} }
} }
else else
@ -151,6 +151,8 @@ void pcbnewGetWizardsBackTrace( wxString& aTrace )
aTrace << "\n**********************************\n"; aTrace << "\n**********************************\n";
} }
else else
{
aTrace += traces[ii] + "\n"; aTrace += traces[ii] + "\n";
}
} }
} }

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) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es> * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -52,8 +52,7 @@
#include <wx/app.h> #include <wx/app.h>
static PCB_EDIT_FRAME* s_PcbEditFrame = NULL; static PCB_EDIT_FRAME* s_PcbEditFrame = nullptr;
static SETTINGS_MANAGER* s_SettingsManager = nullptr; static SETTINGS_MANAGER* s_SettingsManager = nullptr;
@ -62,7 +61,7 @@ BOARD* GetBoard()
if( s_PcbEditFrame ) if( s_PcbEditFrame )
return s_PcbEditFrame->GetBoard(); return s_PcbEditFrame->GetBoard();
else else
return NULL; return nullptr;
} }
@ -188,7 +187,7 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat )
aBoard->BuildConnectivity(); aBoard->BuildConnectivity();
aBoard->SynchronizeNetsAndNetClasses(); aBoard->SynchronizeNetsAndNetClasses();
IO_MGR::Save( aFormat, aFileName, aBoard, NULL ); IO_MGR::Save( aFormat, aFileName, aBoard, nullptr );
wxFileName pro = aFileName; wxFileName pro = aFileName;
pro.SetExt( ProjectFileExtension ); pro.SetExt( ProjectFileExtension );
@ -267,10 +266,8 @@ bool ExportSpecctraDSN( wxString& aFullFilename )
} }
} }
bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles,
bool aExport3DFiles, bool aUseRelativePaths, bool aUseRelativePaths, const wxString& a3D_Subdir, double aXRef, double aYRef )
const wxString& a3D_Subdir,
double aXRef, double aYRef )
{ {
if( s_PcbEditFrame ) if( s_PcbEditFrame )
{ {

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) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es> * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
* Copyright (C) 2013-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.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
@ -48,73 +48,73 @@ BOARD* LoadBoard( wxString& aFileName );
SETTINGS_MANAGER* GetSettingsManager(); SETTINGS_MANAGER* GetSettingsManager();
/** /**
* Constructs a default BOARD with a tempoary (no filename) project * Construct a default BOARD with a temporary (no filename) project.
* @return the created board *
* @return the created board.
*/ */
BOARD* CreateEmptyBoard(); BOARD* CreateEmptyBoard();
// Boards can be saved only as .kicad_pcb file format, // Boards can be saved only as .kicad_pcb file format,
// so no option to choose the file format. // so no option to choose the file format.
bool SaveBoard( wxString& aFileName, BOARD* aBoard ); bool SaveBoard( wxString& aFileName, BOARD* aBoard );
/** /**
* will get the nicknames of all of the footprint libraries configured in * Get the nicknames of all of the footprint libraries configured in
* pcbnew in both the project and global library tables * pcbnew in both the project and global library tables.
* @return the list of footprint library nicknames, empty on error *
* @return the list of footprint library nicknames, empty on error.
*/ */
wxArrayString GetFootprintLibraries(); wxArrayString GetFootprintLibraries();
/** /**
* will get the names of all of the footprints available in a footprint library * Get the names of all of the footprints available in a footprint library.
* @param aNickName is the nickname specifying which footprint library to fetch *
* from * @param aNickName is the nickname specifying which footprint library to fetch from.
* @return the list of footprint names, empty on error * @return the list of footprint names, empty on error.
*/ */
wxArrayString GetFootprints( const wxString& aNickName ); wxArrayString GetFootprints( const wxString& aNickName );
/** /**
* will export the current BOARD to a specctra dsn file. * Will export the current BOARD to a specctra dsn file.
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the *
* specification. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the specification.
*
* @return true if OK * @return true if OK
*/ */
bool ExportSpecctraDSN( wxString& aFullFilename ); bool ExportSpecctraDSN( wxString& aFullFilename );
/** /**
* will export the current BOARD to a VRML (wrl) file. * Export the current BOARD to a VRML (wrl) file.
*
* See ExportVRML_File in pcb_edit_frame.h for detailed documentation. * See ExportVRML_File in pcb_edit_frame.h for detailed documentation.
* @return true if OK * @return true if OK.
*/ */
bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles,
bool aExport3DFiles, bool aUseRelativePaths, bool aUseRelativePaths, const wxString& a3D_Subdir, double aXRef, double aYRef );
const wxString& a3D_Subdir,
double aXRef, double aYRef );
/** /**
* will import a specctra *.ses file and use it to relocate MODULEs and * Import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and
* to replace all vias and tracks in an existing and loaded BOARD. * tracks in an existing and loaded #BOARD.
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the *
* specification. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the specification.
*
* @return true if OK * @return true if OK
*/ */
bool ImportSpecctraSES( wxString& aFullFilename ); bool ImportSpecctraSES( wxString& aFullFilename );
/** /**
* Function ExportFootprintsToLibrary
* Save footprints in a library: * Save footprints in a library:
* @param aStoreInNewLib:
* true : save footprints in a existing lib. Existing footprints will be kept
* or updated.
* This lib should be in fp lib table, and is type is .pretty
* false: save footprints in a new lib. It it is an existing lib,
* previous footprints will be removed
* *
* @param aLibName: * @param aStoreInNewLib set to true to save footprints in a existing lib. Existing footprints
* optional library name to create, stops dialog call. * will be kept or updated. This lib should be in fp lib table, and is
* must be called with aStoreInNewLib as true * type is .pretty. Set to false to save footprints in a new lib. If it
* is an existing lib, previous footprints will be removed.
*
* @param aLibName is the optional library name to create, stops dialog call. Must be called
* with \a aStoreInNewLib as true.
*/ */
bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString, bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString,
wxString* aLibPath = NULL ); wxString* aLibPath = nullptr );
/** /**
* Update the board display after modifying it by a python script * Update the board display after modifying it by a python script
@ -124,7 +124,7 @@ bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName =
* Could be deprecated because modifying a board (especially deleting items) outside * Could be deprecated because modifying a board (especially deleting items) outside
* a action plugin can crash Pcbnew. * a action plugin can crash Pcbnew.
*/ */
void Refresh(); void Refresh();
/** /**
* Update the layer manager and other widgets from the board setup * Update the layer manager and other widgets from the board setup
@ -135,7 +135,8 @@ void Refresh();
void UpdateUserInterface(); void UpdateUserInterface();
/** /**
* Returns the currently selected user unit value for the interface * Return the currently selected user unit value for the interface.
*
* @return 0 = Inches, 1=mm, -1 if the frame isn't set * @return 0 = Inches, 1=mm, -1 if the frame isn't set
*/ */
int GetUserUnits(); int GetUserUnits();
@ -146,16 +147,16 @@ int GetUserUnits();
bool IsActionRunning(); bool IsActionRunning();
/** /**
* Runs the DRC check on the given board and writes the results to a report file. * Run the DRC check on the given board and writes the results to a report file.
* Requires that the project for the board be loaded, and note that unlike the DRC dialog * Requires that the project for the board be loaded, and note that unlike the DRC dialog
* this does not attempt to fill zones, so zones must be valid before calling. * this does not attempt to fill zones, so zones must be valid before calling.
* *
* @param aBoard is a valid loaded board * @param aBoard is a valid loaded board.
* @param aFileName is the full path and name of the report file to write * @param aFileName is the full path and name of the report file to write.
* @param aUnits is the units to use in the report * @param aUnits is the units to use in the report.
* @param aReportAllTrackErrors controls whether all errors or just the first error is reported * @param aReportAllTrackErrors controls whether all errors or just the first error is reported
* for each track * for each track.
* @return true if successful, false if not * @return true if successful, false if not.
*/ */
bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
bool aReportAllTrackErrors ); bool aReportAllTrackErrors );

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) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es> * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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
@ -139,21 +139,22 @@
%{ %{
// called from pcbnew/swig/pcbnew_footprint_wizards.cpp // called from pcbnew/swig/pcbnew_footprint_wizards.cpp
FOOTPRINT* PyFootprint_to_FOOTPRINT(PyObject *obj0) FOOTPRINT* PyFootprint_to_FOOTPRINT( PyObject *obj0 )
{ {
void* argp; void* argp;
int res1 = SWIG_ConvertPtr(obj0, &argp,SWIGTYPE_p_FOOTPRINT, 0 | 0 ); int res1 = SWIG_ConvertPtr( obj0, &argp,SWIGTYPE_p_FOOTPRINT, 0 | 0 );
if (!SWIG_IsOK(res1)) if( !SWIG_IsOK( res1 ) )
{ {
SWIG_exception_fail(SWIG_ArgError(res1), "Converting object to FOOTPRINT*"); SWIG_exception_fail( SWIG_ArgError( res1 ), "Converting object to FOOTPRINT*" );
} }
return ( FOOTPRINT *) argp; return ( FOOTPRINT *) argp;
fail: fail:
return NULL; return nullptr;
} }
%} %}

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2017 CERN * Copyright (C) 2013-2017 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -81,7 +81,7 @@ static TOOL_ACTION ACT_AmplDecrease( "pcbnew.LengthTuner.AmplDecrease",
LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL() : LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL() :
TOOL_BASE( "pcbnew.LengthTuner" ) TOOL_BASE( "pcbnew.LengthTuner" )
{ {
// set the initial tune mode for the settings dialog, // set the initial tune mode for the settings dialog,
// in case the dialog is opened before the tool is activated the first time // in case the dialog is opened before the tool is activated the first time
m_lastTuneMode = PNS::ROUTER_MODE::PNS_MODE_TUNE_SINGLE; m_lastTuneMode = PNS::ROUTER_MODE::PNS_MODE_TUNE_SINGLE;
} }
@ -113,6 +113,7 @@ bool LENGTH_TUNER_TOOL::Init()
return true; return true;
} }
void LENGTH_TUNER_TOOL::Reset( RESET_REASON aReason ) void LENGTH_TUNER_TOOL::Reset( RESET_REASON aReason )
{ {
if( aReason == RUN ) if( aReason == RUN )
@ -166,12 +167,12 @@ void LENGTH_TUNER_TOOL::performTuning()
PNS_TUNE_STATUS_POPUP statusPopup( frame() ); PNS_TUNE_STATUS_POPUP statusPopup( frame() );
statusPopup.Popup(); statusPopup.Popup();
m_router->Move( end, NULL ); m_router->Move( end, nullptr );
updateStatusPopup( statusPopup ); updateStatusPopup( statusPopup );
auto setCursor = auto setCursor =
[&]() [&]()
{ {
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
}; };
@ -189,12 +190,12 @@ void LENGTH_TUNER_TOOL::performTuning()
else if( evt->IsMotion() ) else if( evt->IsMotion() )
{ {
end = evt->Position(); end = evt->Position();
m_router->Move( end, NULL ); m_router->Move( end, nullptr );
updateStatusPopup( statusPopup ); updateStatusPopup( statusPopup );
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
if( m_router->FixRoute( evt->Position(), NULL ) ) if( m_router->FixRoute( evt->Position(), nullptr ) )
break; break;
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
@ -203,31 +204,31 @@ void LENGTH_TUNER_TOOL::performTuning()
} }
else if( evt->IsAction( &ACT_EndTuning ) ) else if( evt->IsAction( &ACT_EndTuning ) )
{ {
if( m_router->FixRoute( end, NULL ) ) if( m_router->FixRoute( end, nullptr ) )
break; break;
} }
else if( evt->IsAction( &ACT_AmplDecrease ) ) else if( evt->IsAction( &ACT_AmplDecrease ) )
{ {
placer->AmplitudeStep( -1 ); placer->AmplitudeStep( -1 );
m_router->Move( end, NULL ); m_router->Move( end, nullptr );
updateStatusPopup( statusPopup ); updateStatusPopup( statusPopup );
} }
else if( evt->IsAction( &ACT_AmplIncrease ) ) else if( evt->IsAction( &ACT_AmplIncrease ) )
{ {
placer->AmplitudeStep( 1 ); placer->AmplitudeStep( 1 );
m_router->Move( end, NULL ); m_router->Move( end, nullptr );
updateStatusPopup( statusPopup ); updateStatusPopup( statusPopup );
} }
else if(evt->IsAction( &ACT_SpacingDecrease ) ) else if(evt->IsAction( &ACT_SpacingDecrease ) )
{ {
placer->SpacingStep( -1 ); placer->SpacingStep( -1 );
m_router->Move( end, NULL ); m_router->Move( end, nullptr );
updateStatusPopup( statusPopup ); updateStatusPopup( statusPopup );
} }
else if( evt->IsAction( &ACT_SpacingIncrease ) ) else if( evt->IsAction( &ACT_SpacingIncrease ) )
{ {
placer->SpacingStep( 1 ); placer->SpacingStep( 1 );
m_router->Move( end, NULL ); m_router->Move( end, nullptr );
updateStatusPopup( statusPopup ); updateStatusPopup( statusPopup );
} }
else if( evt->IsAction( &PCB_ACTIONS::lengthTunerSettingsDialog ) ) else if( evt->IsAction( &PCB_ACTIONS::lengthTunerSettingsDialog ) )
@ -253,10 +254,12 @@ void LENGTH_TUNER_TOOL::setTransitions()
{ {
Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneSingleTrace.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneSingleTrace.MakeEvent() );
Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPair.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPair.MakeEvent() );
Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPairSkew.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::MainLoop,
PCB_ACTIONS::routerTuneDiffPairSkew.MakeEvent() );
// in case tool is inactive, otherwise the event is handled in the tool loop // in case tool is inactive, otherwise the event is handled in the tool loop
Go( &LENGTH_TUNER_TOOL::meanderSettingsDialog, PCB_ACTIONS::lengthTunerSettingsDialog.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::meanderSettingsDialog,
PCB_ACTIONS::lengthTunerSettingsDialog.MakeEvent() );
} }
@ -274,9 +277,9 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
controls()->ShowCursor( true ); controls()->ShowCursor( true );
auto setCursor = auto setCursor =
[&]() [&]()
{ {
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
}; };
@ -332,6 +335,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
int LENGTH_TUNER_TOOL::meanderSettingsDialog( const TOOL_EVENT& aEvent ) int LENGTH_TUNER_TOOL::meanderSettingsDialog( const TOOL_EVENT& aEvent )
{ {
PNS::MEANDER_PLACER_BASE* placer = static_cast<PNS::MEANDER_PLACER_BASE*>( m_router->Placer() ); PNS::MEANDER_PLACER_BASE* placer = static_cast<PNS::MEANDER_PLACER_BASE*>( m_router->Placer() );

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2014 CERN * Copyright (C) 2013-2014 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -33,9 +33,10 @@ ROUTING_SETTINGS& ALGO_BASE::Settings() const
LOGGER* ALGO_BASE::Logger() LOGGER* ALGO_BASE::Logger()
{ {
return NULL; return nullptr;
} }
const BOX2I& ALGO_BASE::VisibleViewArea() const const BOX2I& ALGO_BASE::VisibleViewArea() const
{ {
return m_router->VisibleViewArea(); return m_router->VisibleViewArea();

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2015 CERN * Copyright (C) 2013-2015 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -33,6 +33,7 @@ namespace PNS {
class LINE; class LINE;
DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR( ITEM* aPrimP, ITEM* aPrimN ) DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR( ITEM* aPrimP, ITEM* aPrimN )
{ {
m_primP = aPrimP->Clone(); m_primP = aPrimP->Clone();
@ -54,13 +55,13 @@ DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR( const VECTOR2I& aAnchorP, const VECTOR2I&
{ {
m_anchorP = aAnchorP; m_anchorP = aAnchorP;
m_anchorN = aAnchorN; m_anchorN = aAnchorN;
m_primP = m_primN = NULL; m_primP = m_primN = nullptr;
} }
DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR( const DP_PRIMITIVE_PAIR& aOther ) DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR( const DP_PRIMITIVE_PAIR& aOther )
{ {
m_primP = m_primN = NULL; m_primP = m_primN = nullptr;
if( aOther.m_primP ) if( aOther.m_primP )
m_primP = aOther.m_primP->Clone(); m_primP = aOther.m_primP->Clone();
@ -114,6 +115,7 @@ DIRECTION_45 DP_PRIMITIVE_PAIR::anchorDirection( const ITEM* aItem, const VECTOR
return DIRECTION_45( aItem->Anchor( 1 ) - aItem->Anchor( 0 ) ); return DIRECTION_45( aItem->Anchor( 1 ) - aItem->Anchor( 0 ) );
} }
void DP_PRIMITIVE_PAIR::CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I& aMidpoint, void DP_PRIMITIVE_PAIR::CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I& aMidpoint,
VECTOR2I& aDirection ) const VECTOR2I& aDirection ) const
{ {
@ -200,10 +202,13 @@ void DP_GATEWAY::Reverse()
} }
bool DIFF_PAIR::BuildInitial( const DP_GATEWAY& aEntry, const DP_GATEWAY &aTarget, bool aPrefDiagonal ) bool DIFF_PAIR::BuildInitial( const DP_GATEWAY& aEntry, const DP_GATEWAY &aTarget,
bool aPrefDiagonal )
{ {
SHAPE_LINE_CHAIN p = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorP(), aTarget.AnchorP(), aPrefDiagonal ); SHAPE_LINE_CHAIN p = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorP(), aTarget.AnchorP(),
SHAPE_LINE_CHAIN n = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorN(), aTarget.AnchorN(), aPrefDiagonal ); aPrefDiagonal );
SHAPE_LINE_CHAIN n = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorN(), aTarget.AnchorN(),
aPrefDiagonal );
int mask = aEntry.AllowedAngles() | DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_OBTUSE; int mask = aEntry.AllowedAngles() | DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_OBTUSE;
@ -275,7 +280,9 @@ bool DIFF_PAIR::CheckConnectionAngle( const DIFF_PAIR& aOther, int aAllowedAngle
} }
if( m_n.SegmentCount() == 0 || aOther.m_n.SegmentCount() == 0 ) if( m_n.SegmentCount() == 0 || aOther.m_n.SegmentCount() == 0 )
{
checkN = true; checkN = true;
}
else else
{ {
DIRECTION_45 n0( m_n.CSegment( -1 ) ); DIRECTION_45 n0( m_n.CSegment( -1 ) );
@ -294,8 +301,8 @@ const DIFF_PAIR DP_GATEWAY::Entry() const
} }
void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries, void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries, const VECTOR2I& aCursorPos,
const VECTOR2I& aCursorPos, int aOrthoScore ) int aOrthoScore )
{ {
for( const DP_GATEWAY& g : aEntries.Gateways() ) for( const DP_GATEWAY& g : aEntries.Gateways() )
{ {
@ -309,7 +316,6 @@ void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries,
int dist_s = ( proj_s - aCursorPos ).EuclideanNorm(); int dist_s = ( proj_s - aCursorPos ).EuclideanNorm();
int dist_d = ( proj_d - aCursorPos ).EuclideanNorm(); int dist_d = ( proj_d - aCursorPos ).EuclideanNorm();
VECTOR2I proj = ( dist_s < dist_d ? proj_s : proj_d ); VECTOR2I proj = ( dist_s < dist_d ? proj_s : proj_d );
DP_GATEWAYS targets( m_gap ); DP_GATEWAYS targets( m_gap );
@ -329,8 +335,8 @@ void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries,
} }
bool DP_GATEWAYS::FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget, bool DP_GATEWAYS::FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget, bool aPrefDiagonal,
bool aPrefDiagonal, DIFF_PAIR& aDp ) DIFF_PAIR& aDp )
{ {
DP_CANDIDATE best; DP_CANDIDATE best;
@ -355,7 +361,8 @@ bool DP_GATEWAYS::FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget,
DIFF_PAIR l( m_gap ); DIFF_PAIR l( m_gap );
if( l.BuildInitial( g_entry, g_target, aPrefDiagonal ^ ( attempt ? true : false ) ) ) if( l.BuildInitial( g_entry, g_target,
aPrefDiagonal ^ ( attempt ? true : false ) ) )
{ {
best.p = l.CP(); best.p = l.CP();
best.n = l.CN(); best.n = l.CN();
@ -389,11 +396,13 @@ bool DP_GATEWAYS::checkDiagonalAlignment( const VECTOR2I& a, const VECTOR2I& b )
void DP_GATEWAYS::FilterByOrientation ( int aAngleMask, DIRECTION_45 aRefOrientation ) void DP_GATEWAYS::FilterByOrientation ( int aAngleMask, DIRECTION_45 aRefOrientation )
{ {
m_gateways.erase( m_gateways.erase(
std::remove_if( m_gateways.begin(), m_gateways.end(), [aAngleMask, aRefOrientation]( const DP_GATEWAY& dp) { std::remove_if( m_gateways.begin(), m_gateways.end(),
DIRECTION_45 orient( dp.AnchorP() - dp.AnchorN() ); [aAngleMask, aRefOrientation]( const DP_GATEWAY& dp)
return ( orient.Angle( aRefOrientation ) & aAngleMask ); {
} ), m_gateways.end() DIRECTION_45 orient( dp.AnchorP() - dp.AnchorN() );
); return ( orient.Angle( aRefOrientation ) & aAngleMask );
} ), m_gateways.end()
);
} }
static VECTOR2I makeGapVector( VECTOR2I dir, int length ) static VECTOR2I makeGapVector( VECTOR2I dir, int length )
@ -419,9 +428,9 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a
VECTOR2I p0_p, p0_n; VECTOR2I p0_p, p0_n;
int orthoFanDistance; int orthoFanDistance;
int diagFanDistance; int diagFanDistance;
const SHAPE* shP = NULL; const SHAPE* shP = nullptr;
if( aPair.PrimP() == NULL ) if( aPair.PrimP() == nullptr )
{ {
BuildGeneric( aPair.AnchorP(), aPair.AnchorN(), true ); BuildGeneric( aPair.AnchorP(), aPair.AnchorN(), true );
return; return;
@ -445,7 +454,7 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a
majorDirection = ( p0_p - p0_n ).Perpendicular(); majorDirection = ( p0_p - p0_n ).Perpendicular();
if( shP == NULL ) if( shP == nullptr )
return; return;
switch( shP->Type() ) switch( shP->Type() )
@ -555,8 +564,8 @@ void DP_GATEWAYS::BuildForCursor( const VECTOR2I& aCursorPos )
if( m_fitVias ) if( m_fitVias )
BuildGeneric( aCursorPos + dir, aCursorPos - dir, true, true ); BuildGeneric( aCursorPos + dir, aCursorPos - dir, true, true );
else else
m_gateways.emplace_back( aCursorPos + dir, m_gateways.emplace_back( aCursorPos + dir, aCursorPos - dir,
aCursorPos - dir, attempt ? true : false ); attempt ? true : false );
} }
} }
@ -569,8 +578,10 @@ void DP_GATEWAYS::buildEntries( const VECTOR2I& p0_p, const VECTOR2I& p0_n )
{ {
if( !g.HasEntryLines() ) if( !g.HasEntryLines() )
{ {
SHAPE_LINE_CHAIN lead_p = DIRECTION_45().BuildInitialTrace ( g.AnchorP(), p0_p, g.IsDiagonal() ).Reverse(); SHAPE_LINE_CHAIN lead_p = DIRECTION_45().BuildInitialTrace ( g.AnchorP(), p0_p,
SHAPE_LINE_CHAIN lead_n = DIRECTION_45().BuildInitialTrace ( g.AnchorN(), p0_n, g.IsDiagonal() ).Reverse(); g.IsDiagonal() ).Reverse();
SHAPE_LINE_CHAIN lead_n = DIRECTION_45().BuildInitialTrace ( g.AnchorN(), p0_n,
g.IsDiagonal() ).Reverse();
g.SetEntryLines( lead_p, lead_n ); g.SetEntryLines( lead_p, lead_n );
} }
} }
@ -628,7 +639,8 @@ void DP_GATEWAYS::buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsD
} }
void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool aBuildEntries, bool aViaMode ) void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool aBuildEntries,
bool aViaMode )
{ {
SEG st_p[2], st_n[2]; SEG st_p[2], st_n[2];
SEG d_n[2], d_p[2]; SEG d_n[2], d_p[2];
@ -659,7 +671,8 @@ void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool
if( !aViaMode ) if( !aViaMode )
{ {
m_gateways.emplace_back( m - dir, m + dir, diagColl, DIRECTION_45::ANG_RIGHT, prio ); m_gateways.emplace_back( m - dir, m + dir, diagColl, DIRECTION_45::ANG_RIGHT,
prio );
dir = makeGapVector( p0_n - p0_p, 2 * m_gap ); dir = makeGapVector( p0_n - p0_p, 2 * m_gap );
m_gateways.emplace_back( p0_p - dir, p0_p - dir + dir.Perpendicular(), diagColl ); m_gateways.emplace_back( p0_p - dir, p0_p - dir + dir.Perpendicular(), diagColl );
@ -681,6 +694,7 @@ void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool
if( d_n[i].Collinear( d_p[j] ) ) if( d_n[i].Collinear( d_p[j] ) )
ips[0] = OPT_VECTOR2I(); ips[0] = OPT_VECTOR2I();
if( st_p[i].Collinear( st_p[j] ) ) if( st_p[i].Collinear( st_p[j] ) )
ips[1] = OPT_VECTOR2I(); ips[1] = OPT_VECTOR2I();
@ -698,7 +712,8 @@ void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool
VECTOR2I g_p( ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) ); VECTOR2I g_p( ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
VECTOR2I g_n( ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) ); VECTOR2I g_n( ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
m_gateways.emplace_back( m + g_p, m + g_n, k == 0 ? true : false, DIRECTION_45::ANG_OBTUSE, prio ); m_gateways.emplace_back( m + g_p, m + g_n, k == 0 ? true : false,
DIRECTION_45::ANG_OBTUSE, prio );
} }
} }
} }
@ -742,7 +757,9 @@ void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool
DP_PRIMITIVE_PAIR DIFF_PAIR::EndingPrimitives() DP_PRIMITIVE_PAIR DIFF_PAIR::EndingPrimitives()
{ {
if( m_hasVias ) if( m_hasVias )
{
return DP_PRIMITIVE_PAIR( &m_via_p, &m_via_n ); return DP_PRIMITIVE_PAIR( &m_via_p, &m_via_n );
}
else else
{ {
const LINE lP( PLine() ); const LINE lP( PLine() );
@ -826,7 +843,8 @@ void DIFF_PAIR::CoupledSegmentPairs( COUPLED_SEGMENTS_VEC& aPairs ) const
int64_t dist = std::abs( sp.Distance( sn ) - m_width ); int64_t dist = std::abs( sp.Distance( sn ) - m_width );
if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) && commonParallelProjection( sp, sn, p_clip, n_clip ) ) if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) &&
commonParallelProjection( sp, sn, p_clip, n_clip ) )
{ {
const COUPLED_SEGMENTS spair( p_clip, sp, i, n_clip, sn, j ); const COUPLED_SEGMENTS spair( p_clip, sp, i, n_clip, sn, j );
aPairs.push_back( spair ); aPairs.push_back( spair );
@ -852,7 +870,7 @@ int64_t DIFF_PAIR::CoupledLength( const SHAPE_LINE_CHAIN& aP, const SHAPE_LINE_C
int64_t dist = std::abs( sp.Distance(sn) - m_width ); int64_t dist = std::abs( sp.Distance(sn) - m_width );
if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) && if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) &&
commonParallelProjection( sp, sn, p_clip, n_clip ) ) commonParallelProjection( sp, sn, p_clip, n_clip ) )
total += p_clip.Length(); total += p_clip.Length();
} }
} }
@ -868,6 +886,7 @@ double DIFF_PAIR::CoupledLength() const
CoupledSegmentPairs( pairs ); CoupledSegmentPairs( pairs );
double l = 0.0; double l = 0.0;
for( unsigned int i = 0; i < pairs.size(); i++ ) for( unsigned int i = 0; i < pairs.size(); i++ )
l += pairs[i].coupledP.Length(); l += pairs[i].coupledP.Length();
@ -901,7 +920,7 @@ int DIFF_PAIR::CoupledLength ( const SEG& aP, const SEG& aN ) const
int64_t dist = std::abs( aP.Distance( aN ) - m_width ); int64_t dist = std::abs( aP.Distance( aN ) - m_width );
if( aP.ApproxParallel( aN ) && m_gapConstraint.Matches( dist ) && if( aP.ApproxParallel( aN ) && m_gapConstraint.Matches( dist ) &&
commonParallelProjection ( aP, aN, p_clip, n_clip ) ) commonParallelProjection ( aP, aN, p_clip, n_clip ) )
return p_clip.Length(); return p_clip.Length();
return 0; return 0;

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2015 CERN * Copyright (C) 2013-2015 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -36,24 +36,18 @@ namespace PNS {
class DIFF_PAIR; class DIFF_PAIR;
/** /**
* DP_GATEWAY * Define a "gateway" for routing a differential pair - e.g. a pair of points (anchors) with
* * certain orientation, spacing and (optionally) predefined entry paths. The routing algorithm
* Defines a "gateway" for routing a differential pair - e.g. a pair of points (anchors) with certain * connects such gateways with parallel lines, thus creating a differential pair.
* orientation, spacing and (optionally) predefined entry paths. The routing algorithm connects such */
* gateways with parallel lines, thus creating a difrerential pair. class DP_GATEWAY
**/ {
class DP_GATEWAY {
public: public:
DP_GATEWAY( const VECTOR2I& aAnchorP, DP_GATEWAY( const VECTOR2I& aAnchorP, const VECTOR2I& aAnchorN, bool aIsDiagonal,
const VECTOR2I& aAnchorN, int aAllowedEntryAngles = DIRECTION_45::ANG_OBTUSE, int aPriority = 0 ) :
bool aIsDiagonal, m_anchorP( aAnchorP ),
int aAllowedEntryAngles = DIRECTION_45::ANG_OBTUSE, m_anchorN( aAnchorN ), m_isDiagonal( aIsDiagonal ),
int aPriority = 0 ) m_allowedEntryAngles( aAllowedEntryAngles ), m_priority( aPriority )
: m_anchorP( aAnchorP ),
m_anchorN( aAnchorN ),
m_isDiagonal( aIsDiagonal ),
m_allowedEntryAngles( aAllowedEntryAngles ),
m_priority( aPriority )
{ {
m_hasEntryLines = false; m_hasEntryLines = false;
} }
@ -63,9 +57,7 @@ public:
} }
/** /**
* Function IsDiagonal() * @return true if the gateway anchors lie on a diagonal line.
*
* @return true, if the gateway anchors lie on a diagonal line
*/ */
bool IsDiagonal() const bool IsDiagonal() const
{ {
@ -77,17 +69,12 @@ public:
const VECTOR2I& AnchorN() const { return m_anchorN; } const VECTOR2I& AnchorN() const { return m_anchorN; }
/** /**
* Function AllowedAngles() * @return a mask of 45-degree entry directions allowed for the gateway.
* */
* @return a mask of 45-degree entry directoins allowed for the
* gateway.
*/
int AllowedAngles () const { return m_allowedEntryAngles; } int AllowedAngles () const { return m_allowedEntryAngles; }
/** /**
* Function Priority() * @return priority/score value for gateway matching.
*
* @return priority/score value for gateway matching
*/ */
int Priority() const int Priority() const
{ {
@ -127,15 +114,13 @@ private:
}; };
/** /**
* DP_PRIMITIVE_PAIR * Store starting/ending primitives (pads, vias or segments) for a differential pair.
* */
* Stores staring/ending primitives (pads, vias or segments) for a differential pair.
**/
class DP_PRIMITIVE_PAIR class DP_PRIMITIVE_PAIR
{ {
public: public:
DP_PRIMITIVE_PAIR(): DP_PRIMITIVE_PAIR():
m_primP( NULL ), m_primN( NULL ) {}; m_primP( nullptr ), m_primN( nullptr ) {};
DP_PRIMITIVE_PAIR( const DP_PRIMITIVE_PAIR& aOther ); DP_PRIMITIVE_PAIR( const DP_PRIMITIVE_PAIR& aOther );
DP_PRIMITIVE_PAIR( ITEM* aPrimP, ITEM* aPrimN ); DP_PRIMITIVE_PAIR( ITEM* aPrimP, ITEM* aPrimN );
@ -159,7 +144,8 @@ public:
DIRECTION_45 DirN() const; DIRECTION_45 DirN() const;
void CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I& aMidpoint, VECTOR2I& aDirection ) const; void CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I& aMidpoint,
VECTOR2I& aDirection ) const;
void dump() void dump()
{ {
@ -176,86 +162,75 @@ private:
}; };
/** /**
* DP_GATEWAYS
*
* A set of gateways calculated for the cursor or starting/ending primitive pair. * A set of gateways calculated for the cursor or starting/ending primitive pair.
**/ */
class DP_GATEWAYS class DP_GATEWAYS
{ {
public: public:
DP_GATEWAYS( int aGap ): DP_GATEWAYS( int aGap ):
m_gap( aGap ), m_gap( aGap ),
m_viaGap( aGap ) m_viaGap( aGap )
{ {
// Do not leave uninitialized members, and keep static analyser quiet: // Do not leave uninitialized members, and keep static analyzer quiet:
m_viaDiameter = 0; m_viaDiameter = 0;
m_fitVias = true; m_fitVias = true;
} }
void Clear() void Clear() { m_gateways.clear(); }
{
m_gateways.clear();
}
void SetFitVias( bool aEnable, int aDiameter = 0, int aViaGap = -1 ) void SetFitVias( bool aEnable, int aDiameter = 0, int aViaGap = -1 )
{ {
m_fitVias = aEnable; m_fitVias = aEnable;
m_viaDiameter = aDiameter; m_viaDiameter = aDiameter;
if( aViaGap < 0 ) if( aViaGap < 0 )
m_viaGap = m_gap; m_viaGap = m_gap;
else else
m_viaGap = aViaGap; m_viaGap = aViaGap;
} }
void BuildForCursor( const VECTOR2I& aCursorPos ); void BuildForCursor( const VECTOR2I& aCursorPos );
void BuildOrthoProjections( DP_GATEWAYS &aEntries, const VECTOR2I& aCursorPos, int aOrthoScore ); void BuildOrthoProjections( DP_GATEWAYS& aEntries, const VECTOR2I& aCursorPos,
void BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool aBuildEntries = false, bool aViaMode = false ); int aOrthoScore );
void BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool aPreferDiagonal ); void BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool aBuildEntries = false,
bool aViaMode = false );
void BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool aPreferDiagonal );
bool FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget, bool aPrefDiagonal, DIFF_PAIR& aDp ); bool FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget, bool aPrefDiagonal,
DIFF_PAIR& aDp );
std::vector<DP_GATEWAY>& Gateways() std::vector<DP_GATEWAY>& Gateways() { return m_gateways; }
{
return m_gateways;
}
const std::vector<DP_GATEWAY>& CGateways() const const std::vector<DP_GATEWAY>& CGateways() const { return m_gateways; }
{
return m_gateways;
}
void FilterByOrientation( int aAngleMask, DIRECTION_45 aRefOrientation ); void FilterByOrientation( int aAngleMask, DIRECTION_45 aRefOrientation );
private: private:
struct DP_CANDIDATE struct DP_CANDIDATE
{ {
SHAPE_LINE_CHAIN p, n; SHAPE_LINE_CHAIN p, n;
VECTOR2I gw_p, gw_n; VECTOR2I gw_p, gw_n;
int score; int score;
}; };
bool checkDiagonalAlignment( const VECTOR2I& a, const VECTOR2I& b ) const; bool checkDiagonalAlignment( const VECTOR2I& a, const VECTOR2I& b ) const;
void buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsDiagonal ); void buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsDiagonal );
void buildEntries( const VECTOR2I& p0_p, const VECTOR2I& p0_n ); void buildEntries( const VECTOR2I& p0_p, const VECTOR2I& p0_n );
int m_gap; int m_gap;
int m_viaGap; int m_viaGap;
int m_viaDiameter; int m_viaDiameter;
bool m_fitVias; bool m_fitVias;
std::vector<DP_GATEWAY> m_gateways; std::vector<DP_GATEWAY> m_gateways;
}; };
/** /**
* DIFF_PAIR
*
* Basic class for a differential pair. Stores two PNS_LINEs (for positive and negative nets, * Basic class for a differential pair. Stores two PNS_LINEs (for positive and negative nets,
* respectively), the gap and coupling constraints. * respectively), the gap and coupling constraints.
**/ */
class DIFF_PAIR : public LINK_HOLDER class DIFF_PAIR : public LINK_HOLDER
{ {
public: public:
@ -341,7 +316,7 @@ public:
m_p = aLineP.CLine(); m_p = aLineP.CLine();
m_n = aLineN.CLine(); m_n = aLineN.CLine();
// Do not leave uninitialized members, and keep static analyser quiet: // Do not leave uninitialized members, and keep static analyzer quiet:
m_width = 0; m_width = 0;
m_gap = 0; m_gap = 0;
m_viaGap = 0; m_viaGap = 0;
@ -354,7 +329,11 @@ public:
return aItem && ITEM::DIFF_PAIR_T == aItem->Kind(); return aItem && ITEM::DIFF_PAIR_T == aItem->Kind();
} }
DIFF_PAIR* Clone() const override { assert( false ); return NULL; } DIFF_PAIR* Clone() const override
{
assert( false );
return nullptr;
}
virtual void ClearLinks() override virtual void ClearLinks() override
{ {

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2015 CERN * Copyright (C) 2013-2015 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -40,10 +40,10 @@ DIFF_PAIR_PLACER::DIFF_PAIR_PLACER( ROUTER* aRouter ) :
m_netP = 0; m_netP = 0;
m_netN = 0; m_netN = 0;
m_iteration = 0; m_iteration = 0;
m_world = NULL; m_world = nullptr;
m_shove = NULL; m_shove = nullptr;
m_currentNode = NULL; m_currentNode = nullptr;
m_lastNode = NULL; m_lastNode = nullptr;
m_placingVia = false; m_placingVia = false;
m_viaDiameter = 0; m_viaDiameter = 0;
m_viaDrill = 0; m_viaDrill = 0;
@ -53,7 +53,7 @@ DIFF_PAIR_PLACER::DIFF_PAIR_PLACER( ROUTER* aRouter ) :
m_startsOnVia = false; m_startsOnVia = false;
m_orthoMode = false; m_orthoMode = false;
m_snapOnTarget = false; m_snapOnTarget = false;
m_currentEndItem = NULL; m_currentEndItem = nullptr;
m_currentMode = RM_MarkObstacles; m_currentMode = RM_MarkObstacles;
m_currentTraceOk = false; m_currentTraceOk = false;
m_idle = true; m_idle = true;
@ -71,6 +71,7 @@ void DIFF_PAIR_PLACER::setWorld( NODE* aWorld )
m_world = aWorld; m_world = aWorld;
} }
const VIA DIFF_PAIR_PLACER::makeVia( const VECTOR2I& aP, int aNet ) const VIA DIFF_PAIR_PLACER::makeVia( const VECTOR2I& aP, int aNet )
{ {
const LAYER_RANGE layers( m_sizes.GetLayerTop(), m_sizes.GetLayerBottom() ); const LAYER_RANGE layers( m_sizes.GetLayerTop(), m_sizes.GetLayerBottom() );
@ -87,7 +88,7 @@ void DIFF_PAIR_PLACER::SetOrthoMode ( bool aOrthoMode )
m_orthoMode = aOrthoMode; m_orthoMode = aOrthoMode;
if( !m_idle ) if( !m_idle )
Move( m_currentEnd, NULL ); Move( m_currentEnd, nullptr );
} }
@ -96,7 +97,7 @@ bool DIFF_PAIR_PLACER::ToggleVia( bool aEnabled )
m_placingVia = aEnabled; m_placingVia = aEnabled;
if( !m_idle ) if( !m_idle )
Move( m_currentEnd, NULL ); Move( m_currentEnd, nullptr );
return true; return true;
} }
@ -121,7 +122,9 @@ bool DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNe
VIA virtHead = makeVia( aP, -1 ); VIA virtHead = makeVia( aP, -1 );
if( m_placingVia ) if( m_placingVia )
{
virtHead.SetDiameter( viaGap() + 2 * virtHead.Diameter() ); virtHead.SetDiameter( viaGap() + 2 * virtHead.Diameter() );
}
else else
{ {
virtHead.SetLayer( m_currentLayer ); virtHead.SetLayer( m_currentLayer );
@ -186,8 +189,8 @@ bool DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNe
} }
bool DIFF_PAIR_PLACER::attemptWalk( NODE* aNode, DIFF_PAIR* aCurrent, bool DIFF_PAIR_PLACER::attemptWalk( NODE* aNode, DIFF_PAIR* aCurrent, DIFF_PAIR& aWalk,
DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly ) bool aPFirst, bool aWindCw, bool aSolidsOnly )
{ {
WALKAROUND walkaround( aNode, Router() ); WALKAROUND walkaround( aNode, Router() );
WALKAROUND::WALKAROUND_STATUS wf1; WALKAROUND::WALKAROUND_STATUS wf1;
@ -393,7 +396,7 @@ void DIFF_PAIR_PLACER::FlipPosture()
m_startDiagonal = !m_startDiagonal; m_startDiagonal = !m_startDiagonal;
if( !m_idle ) if( !m_idle )
Move( m_currentEnd, NULL ); Move( m_currentEnd, nullptr );
} }
@ -423,7 +426,7 @@ bool DIFF_PAIR_PLACER::SetLayer( int aLayer )
m_currentLayer = aLayer; m_currentLayer = aLayer;
m_start = *m_prevPair; m_start = *m_prevPair;
initPlacement(); initPlacement();
Move( m_currentEnd, NULL ); Move( m_currentEnd, nullptr );
return true; return true;
} }
@ -494,6 +497,7 @@ bool DIFF_PAIR_PLACER::FindDpPrimitivePair( NODE* aWorld, const VECTOR2I& aP, IT
"from an existing differential pair make sure you are " "from an existing differential pair make sure you are "
"at the end." ); "at the end." );
} }
return false; return false;
} }
@ -508,6 +512,7 @@ bool DIFF_PAIR_PLACER::FindDpPrimitivePair( NODE* aWorld, const VECTOR2I& aP, IT
if( item->Kind() == aItem->Kind() ) if( item->Kind() == aItem->Kind() )
{ {
OPT_VECTOR2I anchor = getDanglingAnchor( aWorld, item ); OPT_VECTOR2I anchor = getDanglingAnchor( aWorld, item );
if( !anchor ) if( !anchor )
continue; continue;
@ -547,6 +552,7 @@ bool DIFF_PAIR_PLACER::FindDpPrimitivePair( NODE* aWorld, const VECTOR2I& aP, IT
"for coupled net \"%s\"." ), "for coupled net \"%s\"." ),
aWorld->GetRuleResolver()->NetName( coupledNet ) ); aWorld->GetRuleResolver()->NetName( coupledNet ) );
} }
return false; return false;
} }
@ -598,7 +604,7 @@ void DIFF_PAIR_PLACER::initPlacement()
{ {
m_idle = false; m_idle = false;
m_orthoMode = false; m_orthoMode = false;
m_currentEndItem = NULL; m_currentEndItem = nullptr;
m_startDiagonal = m_initialDiagonal; m_startDiagonal = m_initialDiagonal;
NODE* world = Router()->GetWorld(); NODE* world = Router()->GetWorld();
@ -608,14 +614,14 @@ void DIFF_PAIR_PLACER::initPlacement()
setWorld( rootNode ); setWorld( rootNode );
m_lastNode = NULL; m_lastNode = nullptr;
m_currentNode = rootNode; m_currentNode = rootNode;
m_currentMode = Settings().Mode(); m_currentMode = Settings().Mode();
if( m_shove ) if( m_shove )
delete m_shove; delete m_shove;
m_shove = NULL; m_shove = nullptr;
if( m_currentMode == RM_Shove || m_currentMode == RM_Smart ) if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
{ {
@ -666,10 +672,10 @@ bool DIFF_PAIR_PLACER::routeHead( const VECTOR2I& aP )
{ {
gwsTarget.BuildForCursor( fp ); gwsTarget.BuildForCursor( fp );
} }
// close to the initial segment extension line -> keep straight part only, project as close
// as possible to the cursor
else else
{ {
// close to the initial segment extension line -> keep straight part only, project
// as close as possible to the cursor.
gwsTarget.BuildForCursor( fpProj ); gwsTarget.BuildForCursor( fpProj );
gwsTarget.FilterByOrientation( DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_HALF_FULL, gwsTarget.FilterByOrientation( DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_HALF_FULL,
DIRECTION_45( dirV ) ); DIRECTION_45( dirV ) );
@ -709,14 +715,14 @@ bool DIFF_PAIR_PLACER::Move( const VECTOR2I& aP , ITEM* aEndItem )
m_fitOk = false; m_fitOk = false;
delete m_lastNode; delete m_lastNode;
m_lastNode = NULL; m_lastNode = nullptr;
bool retval = route( aP ); bool retval = route( aP );
NODE* latestNode = m_currentNode; NODE* latestNode = m_currentNode;
m_lastNode = latestNode->Branch(); m_lastNode = latestNode->Branch();
assert( m_lastNode != NULL ); assert( m_lastNode != nullptr );
m_currentEnd = aP; m_currentEnd = aP;
updateLeadingRatLine(); updateLeadingRatLine();
@ -818,8 +824,7 @@ bool DIFF_PAIR_PLACER::AbortPlacement()
bool DIFF_PAIR_PLACER::HasPlacedAnything() const bool DIFF_PAIR_PLACER::HasPlacedAnything() const
{ {
return m_currentTrace.CP().SegmentCount() > 0 || return m_currentTrace.CP().SegmentCount() > 0 || m_currentTrace.CN().SegmentCount() > 0;
m_currentTrace.CN().SegmentCount() > 0;
} }
@ -828,8 +833,8 @@ bool DIFF_PAIR_PLACER::CommitPlacement()
if( m_lastNode ) if( m_lastNode )
Router()->CommitRouting( m_lastNode ); Router()->CommitRouting( m_lastNode );
m_lastNode = NULL; m_lastNode = nullptr;
m_currentNode = NULL; m_currentNode = nullptr;
return true; return true;
} }

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2014 CERN * Copyright (C) 2013-2014 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -36,14 +36,14 @@ namespace PNS {
DP_MEANDER_PLACER::DP_MEANDER_PLACER( ROUTER* aRouter ) : DP_MEANDER_PLACER::DP_MEANDER_PLACER( ROUTER* aRouter ) :
MEANDER_PLACER_BASE( aRouter ) MEANDER_PLACER_BASE( aRouter )
{ {
m_world = NULL; m_world = nullptr;
m_currentNode = NULL; m_currentNode = nullptr;
m_padToDieP = 0; m_padToDieP = 0;
m_padToDieN = 0; m_padToDieN = 0;
// Init temporary variables (do not leave uninitialized members) // Init temporary variables (do not leave uninitialized members)
m_initialSegment = NULL; m_initialSegment = nullptr;
m_lastLength = 0; m_lastLength = 0;
m_lastStatus = TOO_SHORT; m_lastStatus = TOO_SHORT;
} }
@ -88,16 +88,16 @@ bool DP_MEANDER_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
if( !topo.AssembleDiffPair( m_initialSegment, m_originPair ) ) if( !topo.AssembleDiffPair( m_initialSegment, m_originPair ) )
{ {
Router()->SetFailureReason( _( "Unable to find complementary differential pair " Router()->SetFailureReason( _( "Unable to find complementary differential pair "
"net for length tuning. Make sure the names of the nets belonging " "net for length tuning. Make sure the names of the nets "
"to a differential pair end with either _N/_P or +/-." ) ); "belonging to a differential pair end with either _N/_P "
"or +/-." ) );
return false; return false;
} }
if( m_originPair.Gap() < 0 ) if( m_originPair.Gap() < 0 )
m_originPair.SetGap( Router()->Sizes().DiffPairGap() ); m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() || if( !m_originPair.PLine().SegmentCount() || !m_originPair.NLine().SegmentCount() )
!m_originPair.NLine().SegmentCount() )
return false; return false;
SOLID* padA = nullptr; SOLID* padA = nullptr;
@ -274,7 +274,8 @@ bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
m_lastLength += std::max( tunedP.Length(), tunedN.Length() ); m_lastLength += std::max( tunedP.Length(), tunedN.Length() );
int comp = compareWithTolerance( m_lastLength - m_settings.m_targetLength, 0, m_settings.m_lengthTolerance ); int comp = compareWithTolerance( m_lastLength - m_settings.m_targetLength, 0,
m_settings.m_lengthTolerance );
if( comp > 0 ) if( comp > 0 )
m_lastStatus = TOO_LONG; m_lastStatus = TOO_LONG;
@ -323,8 +324,7 @@ bool DP_MEANDER_PLACER::AbortPlacement()
bool DP_MEANDER_PLACER::HasPlacedAnything() const bool DP_MEANDER_PLACER::HasPlacedAnything() const
{ {
return m_originPair.CP().SegmentCount() > 0 || return m_originPair.CP().SegmentCount() > 0 || m_originPair.CN().SegmentCount() > 0;
m_originPair.CN().SegmentCount() > 0;
} }
@ -333,7 +333,7 @@ bool DP_MEANDER_PLACER::CommitPlacement()
if( m_currentNode ) if( m_currentNode )
Router()->CommitRouting( m_currentNode ); Router()->CommitRouting( m_currentNode );
m_currentNode = NULL; m_currentNode = nullptr;
return true; return true;
} }

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2014 CERN * Copyright (C) 2013-2014 CERN
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -34,8 +34,8 @@ DRAGGER::DRAGGER( ROUTER* aRouter ) :
m_initialVia( {} ), m_initialVia( {} ),
m_draggedVia( {} ) m_draggedVia( {} )
{ {
m_world = NULL; m_world = nullptr;
m_lastNode = NULL; m_lastNode = nullptr;
m_mode = DM_SEGMENT; m_mode = DM_SEGMENT;
m_draggedSegmentIndex = 0; m_draggedSegmentIndex = 0;
m_dragStatus = false; m_dragStatus = false;
@ -211,7 +211,7 @@ bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
ITEM* startItem = aPrimitives[0]; ITEM* startItem = aPrimitives[0];
m_lastNode = NULL; m_lastNode = nullptr;
m_draggedItems.Clear(); m_draggedItems.Clear();
m_currentMode = Settings().Mode(); m_currentMode = Settings().Mode();
m_freeAngleMode = (m_mode & DM_FREE_ANGLE); m_freeAngleMode = (m_mode & DM_FREE_ANGLE);
@ -229,7 +229,8 @@ bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
startItem->Unmark( MK_LOCKED ); startItem->Unmark( MK_LOCKED );
PNS_DBG( Dbg(), Message, wxString::Format( "StartDragging: item %p [kind %d]", startItem, (int) startItem->Kind() ) ); PNS_DBG( Dbg(), Message, wxString::Format( "StartDragging: item %p [kind %d]",
startItem, (int) startItem->Kind() ) );
switch( startItem->Kind() ) switch( startItem->Kind() )
{ {
@ -411,7 +412,8 @@ bool DRAGGER::dragViaWalkaround( const VIA_HANDLE& aHandle, NODE* aNode, const V
LINE draggedLine( *l ); LINE draggedLine( *l );
LINE walkLine( *l ); LINE walkLine( *l );
draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode ); draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ),
m_freeAngleMode );
draggedLine.ClearLinks(); draggedLine.ClearLinks();
if ( m_world->CheckColliding( &draggedLine ) ) if ( m_world->CheckColliding( &draggedLine ) )
@ -526,7 +528,8 @@ bool DRAGGER::tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk )
bool DRAGGER::dragWalkaround( const VECTOR2I& aP ) bool DRAGGER::dragWalkaround( const VECTOR2I& aP )
{ {
bool ok = false; bool ok = false;
// fixme: rewrite using shared_ptr...
// fixme: rewrite using shared_ptr...
if( m_lastNode ) if( m_lastNode )
{ {
delete m_lastNode; delete m_lastNode;
@ -569,7 +572,8 @@ bool DRAGGER::dragWalkaround( const VECTOR2I& aP )
m_lastNode->Remove( origLine ); m_lastNode->Remove( origLine );
optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP ); optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
} }
break;
break;
} }
case DM_VIA: // fixme... case DM_VIA: // fixme...
{ {
@ -591,7 +595,7 @@ bool DRAGGER::dragShove( const VECTOR2I& aP )
if( m_lastNode ) if( m_lastNode )
{ {
delete m_lastNode; delete m_lastNode;
m_lastNode = NULL; m_lastNode = nullptr;
} }
switch( m_mode ) switch( m_mode )
@ -614,7 +618,9 @@ bool DRAGGER::dragShove( const VECTOR2I& aP )
SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged ); SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
if( st == SHOVE::SH_OK ) if( st == SHOVE::SH_OK )
{
ok = true; ok = true;
}
else if( st == SHOVE::SH_HEAD_MODIFIED ) else if( st == SHOVE::SH_HEAD_MODIFIED )
{ {
dragged = m_shove->NewHead(); dragged = m_shove->NewHead();

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2014 CERN * Copyright (C) 2013-2014 CERN
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -71,7 +71,7 @@ void INDEX::Replace( ITEM* aOldItem, ITEM* aNewItem )
INDEX::NET_ITEMS_LIST* INDEX::GetItemsForNet( int aNet ) INDEX::NET_ITEMS_LIST* INDEX::GetItemsForNet( int aNet )
{ {
if( m_netMap.find( aNet ) == m_netMap.end() ) if( m_netMap.find( aNet ) == m_netMap.end() )
return NULL; return nullptr;
return &m_netMap[aNet]; return &m_netMap[aNet];
} }

View File

@ -75,8 +75,8 @@ public:
m_net = UnusedNet; m_net = UnusedNet;
m_movable = true; m_movable = true;
m_kind = aKind; m_kind = aKind;
m_parent = NULL; m_parent = nullptr;
m_owner = NULL; m_owner = nullptr;
m_marker = 0; m_marker = 0;
m_rank = -1; m_rank = -1;
m_routable = true; m_routable = true;

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2014 CERN * Copyright (C) 2013-2014 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -29,11 +29,8 @@
namespace PNS { namespace PNS {
/** /**
* ITEM_SET * Hold a list of board items, that can be filtered against net, kinds, layers, etc.
* */
* Holds a list of board items, that can be filtered against net, kinds,
* layers, etc.
**/
class LINE; class LINE;
class ITEM_SET class ITEM_SET
@ -95,7 +92,7 @@ public:
typedef std::vector<ENTRY> ENTRIES; typedef std::vector<ENTRY> ENTRIES;
ITEM_SET( ITEM* aInitialItem = NULL, bool aBecomeOwner = false ) ITEM_SET( ITEM* aInitialItem = nullptr, bool aBecomeOwner = false )
{ {
if( aInitialItem ) if( aInitialItem )
m_items.emplace_back( ENTRY( aInitialItem, aBecomeOwner ) ); m_items.emplace_back( ENTRY( aInitialItem, aBecomeOwner ) );
@ -224,7 +221,7 @@ public:
} }
} }
return NULL; return nullptr;
} }
private: private:

View File

@ -34,11 +34,11 @@
namespace PNS { namespace PNS {
/** /**
* Represents a 2D point on a given set of layers and belonging to a certain net, that links * A 2D point on a given set of layers and belonging to a certain net, that links
* together a number of board items. * together a number of board items.
* *
* A hash table of joints is used by the router to follow connectivity between the items. * A hash table of joints is used by the router to follow connectivity between the items.
**/ */
class JOINT : public ITEM class JOINT : public ITEM
{ {
public: public:
@ -92,7 +92,7 @@ public:
ITEM* Clone( ) const override ITEM* Clone( ) const override
{ {
assert( false ); assert( false );
return NULL; return nullptr;
} }
///< Return true if the joint is a trivial line corner, connecting two ///< Return true if the joint is a trivial line corner, connecting two
@ -159,7 +159,7 @@ public:
LINKED_ITEM* NextSegment( ITEM* aCurrent ) const LINKED_ITEM* NextSegment( ITEM* aCurrent ) const
{ {
if( !IsLineCorner() ) if( !IsLineCorner() )
return NULL; return nullptr;
return static_cast<LINKED_ITEM*>( m_linkedItems[m_linkedItems[0] == aCurrent ? 1 : 0] ); return static_cast<LINKED_ITEM*>( m_linkedItems[m_linkedItems[0] == aCurrent ? 1 : 0] );
} }
@ -172,7 +172,7 @@ public:
return static_cast<VIA*>( item ); return static_cast<VIA*>( item );
} }
return NULL; return nullptr;
} }

Some files were not shown because too many files have changed in this diff Show More