Minor cleanup and removal of stale comments.

This commit is contained in:
Jeff Young 2023-08-27 10:21:47 +01:00
parent 67bd2139ad
commit c48084bbbf
1 changed files with 11 additions and 23 deletions

View File

@ -117,8 +117,6 @@ std::unique_ptr<ZONE> ZONE_CREATE_HELPER::createNewZone( bool aKeepout )
if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON ) if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON )
{ {
// Get the current default settings for zones
// Show options dialog // Show options dialog
int dialogResult; int dialogResult;
@ -177,16 +175,15 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, const ZONE& aCutout )
SHAPE_POLY_SET originalOutline( *aZone.Outline() ); SHAPE_POLY_SET originalOutline( *aZone.Outline() );
originalOutline.BooleanSubtract( *aCutout.Outline(), SHAPE_POLY_SET::PM_FAST ); originalOutline.BooleanSubtract( *aCutout.Outline(), SHAPE_POLY_SET::PM_FAST );
// After substracting the hole, originalOutline can have more than one // After substracting the hole, originalOutline can have more than one main outline.
// main outline. // But a zone can have only one main outline, so create as many zones as originalOutline
// But a zone can have only one main outline, so create as many zones as // contains main outlines:
// originalOutline contains main outlines:
for( int outline = 0; outline < originalOutline.OutlineCount(); outline++ ) for( int outline = 0; outline < originalOutline.OutlineCount(); outline++ )
{ {
auto newZoneOutline = new SHAPE_POLY_SET; auto newZoneOutline = new SHAPE_POLY_SET;
newZoneOutline->AddOutline( originalOutline.Outline( outline ) ); newZoneOutline->AddOutline( originalOutline.Outline( outline ) );
// Add holes (if any) to thez new zone outline: // Add holes (if any) to the new zone outline:
for (int hole = 0; hole < originalOutline.HoleCount( outline ) ; hole++ ) for (int hole = 0; hole < originalOutline.HoleCount( outline ) ; hole++ )
newZoneOutline->AddHole( originalOutline.CHole( outline, hole ) ); newZoneOutline->AddHole( originalOutline.CHole( outline, hole ) );
@ -200,9 +197,6 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, const ZONE& aCutout )
} }
commit.Remove( &aZone ); commit.Remove( &aZone );
// TODO Refill zones when KiCad supports auto re-fill
commit.Push( _( "Add Zone Cutout" ) ); commit.Push( _( "Add Zone Cutout" ) );
// Select the new zone and set it as the source for the next cutout // Select the new zone and set it as the source for the next cutout
@ -249,11 +243,7 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE> aZone )
PCB_SHAPE* poly = new PCB_SHAPE( m_tool.m_frame->GetModel() ); PCB_SHAPE* poly = new PCB_SHAPE( m_tool.m_frame->GetModel() );
poly->SetShape( SHAPE_T::POLY ); poly->SetShape( SHAPE_T::POLY );
poly->SetFilled( layer != Edge_Cuts && layer != F_CrtYd && layer != B_CrtYd );
if( layer == Edge_Cuts || layer == F_CrtYd || layer == B_CrtYd )
poly->SetFilled( false );
else
poly->SetFilled( true );
poly->SetStroke( STROKE_PARAMS( board->GetDesignSettings().GetLineThickness( layer ), poly->SetStroke( STROKE_PARAMS( board->GetDesignSettings().GetLineThickness( layer ),
PLOT_DASH_TYPE::SOLID ) ); PLOT_DASH_TYPE::SOLID ) );
@ -261,9 +251,9 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE> aZone )
poly->SetPolyShape( *aZone->Outline() ); poly->SetPolyShape( *aZone->Outline() );
commit.Add( poly ); commit.Add( poly );
m_tool.GetManager()->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, poly );
commit.Push( _( "Add Polygon" ) ); commit.Push( _( "Add Polygon" ) );
m_tool.GetManager()->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, poly );
break; break;
} }
} }
@ -273,7 +263,6 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE> aZone )
bool ZONE_CREATE_HELPER::OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr ) bool ZONE_CREATE_HELPER::OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr )
{ {
// if we don't have a zone, create one // if we don't have a zone, create one
// the user's choice here can affect things like the colour of the preview
if( !m_zone ) if( !m_zone )
{ {
if( m_params.m_sourceZone ) if( m_params.m_sourceZone )
@ -323,17 +312,16 @@ void ZONE_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
} }
else else
{ {
// if m_params.m_mode == DRAWING_TOOL::ZONE_MODE::CUTOUT, m_zone // if m_params.m_mode == DRAWING_TOOL::ZONE_MODE::CUTOUT, m_zone will be merged to the
// will be merged to the existing zone as a new hole. // existing zone as a new hole.
m_zone->Outline()->NewOutline(); m_zone->Outline()->NewOutline();
auto* outline = m_zone->Outline(); auto* outline = m_zone->Outline();
for( int i = 0; i < finalPoints.PointCount(); ++i ) for( int i = 0; i < finalPoints.PointCount(); ++i )
outline->Append( finalPoints.CPoint( i ) ); outline->Append( finalPoints.CPoint( i ) );
// In DEG45 mode, we may have intermediate points in the leader that should be // In DEG45 mode, we may have intermediate points in the leader that should be included
// included as they are shown in the preview. These typically maintain the // as they are shown in the preview. These typically maintain the 45 constraint
// 45 constraint
if( aMgr.GetLeaderMode() == POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45 ) if( aMgr.GetLeaderMode() == POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45 )
{ {
const SHAPE_LINE_CHAIN leaderPts = aMgr.GetLeaderLinePoints(); const SHAPE_LINE_CHAIN leaderPts = aMgr.GetLeaderLinePoints();