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 rs = aView->GetPainter()->GetSettings();
|
||||
|
||||
gal.SetLineWidth( (float) aView->ToWorld( POLY_LINE_WIDTH ) );
|
||||
gal.DrawPolyline( m_lockedChain );
|
||||
if( m_lockedChain.PointCount() >= 2 )
|
||||
{
|
||||
gal.SetLineWidth( (float) aView->ToWorld( POLY_LINE_WIDTH ) );
|
||||
gal.DrawPolyline( m_lockedChain );
|
||||
}
|
||||
|
||||
// draw the leader line in a different color
|
||||
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
|
||||
gal.DrawPolyline( m_leaderChain );
|
||||
if( m_leaderChain.PointCount() >= 2 )
|
||||
{
|
||||
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.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||
VECTOR2I cursorPos = grid.BestSnapAnchor(
|
||||
evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), layers );
|
||||
VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position()
|
||||
: m_controls->GetMousePosition(),
|
||||
layers );
|
||||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( ( sourceZone && sourceZone->GetHV45() ) || constrainAngle || evt->Modifier( MD_CTRL ) )
|
||||
|
@ -1557,13 +1558,14 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||
|
||||
auto cleanup = [&] () {
|
||||
polyGeomMgr.Reset();
|
||||
started = false;
|
||||
grid.ClearSkipPoint();
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
};
|
||||
auto cleanup = [&] ()
|
||||
{
|
||||
polyGeomMgr.Reset();
|
||||
started = false;
|
||||
grid.ClearSkipPoint();
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
};
|
||||
|
||||
if( evt->IsCancelInteractive())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue