Temporary fix of broken command add corner to zone in GAL mode.
Fixes: lp:1680339 https://bugs.launchpad.net/kicad/+bug/1680339
This commit is contained in:
parent
bf21640ae5
commit
ba37d6fca3
|
@ -202,7 +202,8 @@ void SHAPE_POLY_SET::InsertVertex( int aGlobalIndex, VECTOR2I aNewVertex )
|
||||||
if( aGlobalIndex < 0 )
|
if( aGlobalIndex < 0 )
|
||||||
aGlobalIndex = 0;
|
aGlobalIndex = 0;
|
||||||
|
|
||||||
if( aGlobalIndex >= TotalVertices() ){
|
if( aGlobalIndex >= TotalVertices() )
|
||||||
|
{
|
||||||
Append( aNewVertex );
|
Append( aNewVertex );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -781,15 +781,21 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
commit.Modify( zone );
|
commit.Modify( zone );
|
||||||
|
|
||||||
// Handle the last segment, so other segments can be easily handled in a loop
|
// Handle the last segment, so other segments can be easily handled in a loop
|
||||||
unsigned int nearestIdx = outline->TotalVertices() - 1, nextNearestIdx = 0;
|
unsigned int nearestIdx = 0;
|
||||||
SEG side( outline->Vertex( nearestIdx ), outline->Vertex( nextNearestIdx ) );
|
unsigned int nextNearestIdx = 0;
|
||||||
unsigned int nearestDist = side.Distance( cursorPos );
|
unsigned int nearestDist = INT_MAX;
|
||||||
|
|
||||||
for( int i = 0; i < outline->TotalVertices() - 1; ++i )
|
for( int i = 0; i < outline->TotalVertices(); ++i )
|
||||||
{
|
{
|
||||||
side = SEG( outline->Vertex( i ), outline->Vertex( i + 1 ) );
|
int jj = i+1;
|
||||||
|
|
||||||
|
if( jj >= outline->TotalVertices() )
|
||||||
|
jj = 0;
|
||||||
|
|
||||||
|
SEG side( outline->Vertex( i ), outline->Vertex( jj ) );
|
||||||
|
|
||||||
unsigned int distance = side.Distance( cursorPos );
|
unsigned int distance = side.Distance( cursorPos );
|
||||||
|
|
||||||
if( distance < nearestDist )
|
if( distance < nearestDist )
|
||||||
{
|
{
|
||||||
nearestDist = distance;
|
nearestDist = distance;
|
||||||
|
@ -798,6 +804,7 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find the point on the closest segment
|
// Find the point on the closest segment
|
||||||
VECTOR2I sideOrigin = outline->Vertex( nearestIdx );
|
VECTOR2I sideOrigin = outline->Vertex( nearestIdx );
|
||||||
VECTOR2I sideEnd = outline->Vertex( nextNearestIdx );
|
VECTOR2I sideEnd = outline->Vertex( nextNearestIdx );
|
||||||
|
@ -809,7 +816,9 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
|
if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
|
||||||
nearestPoint = ( sideOrigin + sideEnd ) / 2;
|
nearestPoint = ( sideOrigin + sideEnd ) / 2;
|
||||||
|
|
||||||
outline->InsertVertex( nearestIdx, nearestPoint );
|
// Add corner between nearestIdx and nextNearestIdx:
|
||||||
|
outline->InsertVertex( nextNearestIdx, nearestPoint );
|
||||||
|
zone->Hatch();
|
||||||
|
|
||||||
commit.Push( _( "Add a zone corner" ) );
|
commit.Push( _( "Add a zone corner" ) );
|
||||||
}
|
}
|
||||||
|
@ -853,6 +862,7 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
commit.Push( _( "Split segment" ) );
|
commit.Push( _( "Split segment" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePoints();
|
updatePoints();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue