Don't allow preview to try and draw empty polygons.
Fixes https://gitlab.com/kicad/code/kicad/issues/5314
This commit is contained in:
parent
591e1c5de9
commit
c71bb246e6
|
@ -57,14 +57,26 @@ void POLYGON_ITEM::drawPreviewShape( KIGFX::VIEW* aView ) const
|
||||||
auto& gal = *aView->GetGAL();
|
auto& gal = *aView->GetGAL();
|
||||||
auto rs = aView->GetPainter()->GetSettings();
|
auto rs = aView->GetPainter()->GetSettings();
|
||||||
|
|
||||||
gal.SetLineWidth( (float) aView->ToWorld( POLY_LINE_WIDTH ) );
|
if( m_lockedChain.PointCount() >= 2 )
|
||||||
gal.DrawPolyline( m_lockedChain );
|
{
|
||||||
|
gal.SetLineWidth( (float) aView->ToWorld( POLY_LINE_WIDTH ) );
|
||||||
|
gal.DrawPolyline( m_lockedChain );
|
||||||
|
}
|
||||||
|
|
||||||
// draw the leader line in a different color
|
// draw the leader line in a different color
|
||||||
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
|
if( m_leaderChain.PointCount() >= 2 )
|
||||||
gal.DrawPolyline( m_leaderChain );
|
{
|
||||||
|
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
|
||||||
|
gal.DrawPolyline( m_leaderChain );
|
||||||
|
}
|
||||||
|
|
||||||
gal.DrawPolygon( m_polyfill );
|
for( int j = 0; j < m_polyfill.OutlineCount(); ++j )
|
||||||
|
{
|
||||||
|
const SHAPE_LINE_CHAIN& outline = m_polyfill.COutline( j );
|
||||||
|
|
||||||
|
if( outline.PointCount() >= 2 )
|
||||||
|
gal.DrawPolygon( outline );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1548,8 +1548,9 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor(
|
VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position()
|
||||||
evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), layers );
|
: m_controls->GetMousePosition(),
|
||||||
|
layers );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
m_controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
if( ( sourceZone && sourceZone->GetHV45() ) || constrainAngle || evt->Modifier( MD_CTRL ) )
|
if( ( sourceZone && sourceZone->GetHV45() ) || constrainAngle || evt->Modifier( MD_CTRL ) )
|
||||||
|
@ -1557,13 +1558,14 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
else
|
else
|
||||||
polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||||
|
|
||||||
auto cleanup = [&] () {
|
auto cleanup = [&] ()
|
||||||
polyGeomMgr.Reset();
|
{
|
||||||
started = false;
|
polyGeomMgr.Reset();
|
||||||
grid.ClearSkipPoint();
|
started = false;
|
||||||
m_controls->SetAutoPan( false );
|
grid.ClearSkipPoint();
|
||||||
m_controls->CaptureCursor( false );
|
m_controls->SetAutoPan( false );
|
||||||
};
|
m_controls->CaptureCursor( false );
|
||||||
|
};
|
||||||
|
|
||||||
if( evt->IsCancelInteractive())
|
if( evt->IsCancelInteractive())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue