Formatting.

This commit is contained in:
Jeff Young 2022-06-01 23:55:59 +01:00
parent 40593930d0
commit f8829de5ea
1 changed files with 18 additions and 17 deletions

View File

@ -1216,14 +1216,11 @@ void PCB_POINT_EDITOR::updateItem() const
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) ) if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) )
shape->SetStart( m_editPoints->Point( BEZIER_CURVE_START ). shape->SetStart( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() );
GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) ) else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) )
shape->SetBezierC1( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ). shape->SetBezierC1( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() );
GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) ) else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) )
shape->SetBezierC2( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ). shape->SetBezierC2( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() );
GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) ) else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) )
shape->SetEnd( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() ); shape->SetEnd( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() );
@ -1256,7 +1253,7 @@ void PCB_POINT_EDITOR::updateItem() const
case PAD_SHAPE::CIRCLE: case PAD_SHAPE::CIRCLE:
{ {
VECTOR2I end = m_editPoints->Point( 0 ).GetPosition(); VECTOR2I end = m_editPoints->Point( 0 ).GetPosition();
int diameter = (int) EuclideanNorm( end - pad->GetPosition() ) * 2; int diameter = (int) EuclideanNorm( end - pad->GetPosition() ) * 2;
pad->SetSize( wxSize( diameter, diameter ) ); pad->SetSize( wxSize( diameter, diameter ) );
break; break;
@ -1301,7 +1298,7 @@ void PCB_POINT_EDITOR::updateItem() const
dist[3] = botLeft.y - center.y; dist[3] = botLeft.y - center.y;
} }
wxSize padSize( dist[0] + dist[2], dist[1] + dist[3] ); wxSize padSize( dist[0] + dist[2], dist[1] + dist[3] );
VECTOR2I deltaOffset( padSize.x / 2 - dist[2], padSize.y / 2 - dist[3] ); VECTOR2I deltaOffset( padSize.x / 2 - dist[2], padSize.y / 2 - dist[3] );
if( pad->GetOrientation() == ANGLE_90 || pad->GetOrientation() == ANGLE_270 ) if( pad->GetOrientation() == ANGLE_90 || pad->GetOrientation() == ANGLE_270 )
@ -2119,12 +2116,12 @@ bool PCB_POINT_EDITOR::removeCornerCondition( const SELECTION& )
return false; return false;
} }
auto vertex = findVertex( *polyset, *m_editedPoint ); std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX> vertex = findVertex( *polyset, *m_editedPoint );
if( !vertex.first ) if( !vertex.first )
return false; return false;
const auto& vertexIdx = vertex.second; const SHAPE_POLY_SET::VERTEX_INDEX& vertexIdx = vertex.second;
// Check if there are enough vertices so one can be removed without // Check if there are enough vertices so one can be removed without
// degenerating the polygon. // degenerating the polygon.
@ -2132,7 +2129,9 @@ bool PCB_POINT_EDITOR::removeCornerCondition( const SELECTION& )
// there are only 2 vertices left, a hole is removed). // there are only 2 vertices left, a hole is removed).
if( vertexIdx.m_contour == 0 && if( vertexIdx.m_contour == 0 &&
polyset->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 ) polyset->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
{
return false; return false;
}
// Remove corner does not work with lines // Remove corner does not work with lines
if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) ) if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
@ -2147,9 +2146,9 @@ int PCB_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
if( !m_editPoints ) if( !m_editPoints )
return 0; return 0;
EDA_ITEM* item = m_editPoints->GetParent(); EDA_ITEM* item = m_editPoints->GetParent();
PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>(); PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition(); const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
// called without an active edited polygon // called without an active edited polygon
if( !item || !canAddCorner( *item ) ) if( !item || !canAddCorner( *item ) )
@ -2174,7 +2173,9 @@ int PCB_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
zone->SetNeedRefill( true ); zone->SetNeedRefill( true );
} }
else else
{
zoneOutline = &( graphicItem->GetPolyShape() ); zoneOutline = &( graphicItem->GetPolyShape() );
}
commit.Modify( item ); commit.Modify( item );
@ -2210,10 +2211,10 @@ int PCB_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
} }
// Find the point on the closest segment // Find the point on the closest segment
auto& sideOrigin = zoneOutline->CVertex( nearestIdx ); const VECTOR2I& sideOrigin = zoneOutline->CVertex( nearestIdx );
auto& sideEnd = zoneOutline->CVertex( nextNearestIdx ); const VECTOR2I& sideEnd = zoneOutline->CVertex( nextNearestIdx );
SEG nearestSide( sideOrigin, sideEnd ); SEG nearestSide( sideOrigin, sideEnd );
VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos ); VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
// Do not add points that have the same coordinates as ones that already belong to polygon // Do not add points that have the same coordinates as ones that already belong to polygon
// instead, add a point in the middle of the side // instead, add a point in the middle of the side
@ -2233,7 +2234,7 @@ int PCB_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
{ {
commit.Modify( graphicItem ); commit.Modify( graphicItem );
SEG seg( graphicItem->GetStart(), graphicItem->GetEnd() ); SEG seg( graphicItem->GetStart(), graphicItem->GetEnd() );
VECTOR2I nearestPoint = seg.NearestPoint( cursorPos ); VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
// Move the end of the line to the break point.. // Move the end of the line to the break point..