diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index a7fe7722a4..4fccadd49e 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -657,9 +657,18 @@ void POINT_EDITOR::updatePoints() case S_POLYGON: { const auto& points = segment->BuildPolyPointsList(); - for( unsigned i = 0; i < points.size(); i++ ) + + if( m_editPoints->PointsSize() != (unsigned) points.size() ) { - m_editPoints->Point( i ).SetPosition( points[i] ); + getView()->Remove( m_editPoints.get() ); + m_editedPoint = nullptr; + m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() ); + getView()->Add( m_editPoints.get() ); + } + else + { + for( unsigned i = 0; i < points.size(); i++ ) + m_editPoints->Point( i ).SetPosition( points[i] ); } break; } @@ -826,7 +835,8 @@ bool POINT_EDITOR::addCornerCondition( const SELECTION& aSelection ) // Works only for zones and line segments return item->Type() == PCB_ZONE_AREA_T || ( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) && - static_cast( item )->GetShape() == S_SEGMENT ); + ( static_cast( item )->GetShape() == S_SEGMENT || + static_cast( item )->GetShape() == S_POLYGON ) ); } @@ -887,17 +897,23 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent ) const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition(); BOARD_COMMIT commit( frame ); - if( item->Type() == PCB_ZONE_AREA_T ) + bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T; + + if( item->Type() == PCB_ZONE_AREA_T || + ( moduleEdge && static_cast( item )->GetShape() == S_POLYGON ) ) { - ZONE_CONTAINER* zone = static_cast( item ); - SHAPE_POLY_SET* zoneOutline = zone->Outline(); - - commit.Modify( zone ); - unsigned int nearestIdx = 0; unsigned int nextNearestIdx = 0; unsigned int nearestDist = INT_MAX; unsigned int firstPointInContour = 0; + SHAPE_POLY_SET* zoneOutline; + + if( moduleEdge ) + zoneOutline = &( static_cast( item )->GetPolyShape() ); + else + zoneOutline = static_cast( item )->Outline(); + + commit.Modify( item ); // Search the best outline segment to add a new corner // and therefore break this segment into two segments @@ -944,15 +960,18 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent ) // Add corner between nearestIdx and nextNearestIdx: zoneOutline->InsertVertex( nextNearestIdx, nearestPoint ); - zone->Hatch(); + + // In board editor, we re-hatch the zone item + if( !moduleEdge ) + static_cast( item )->Hatch(); + commit.Push( _( "Add a zone corner" ) ); } - else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) + else if( item->Type() == PCB_LINE_T || + ( moduleEdge && static_cast( item )->GetShape() == S_SEGMENT ) ) { - bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T; - DRAWSEGMENT* segment = static_cast( item ); if( segment->GetShape() == S_SEGMENT )