pcbnew: Add corners in polygons
Allow corner adding to polygons in both module editor and board editor. The board editor was already allowed but only through special types. The module editor is now sychronized to the same process and both recognize standard context menus Fixes: lp:1782966 * https://bugs.launchpad.net/kicad/+bug/1782966
This commit is contained in:
parent
e7c51a6a6c
commit
06ac172c27
|
@ -657,8 +657,17 @@ void POINT_EDITOR::updatePoints()
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
{
|
{
|
||||||
const auto& points = segment->BuildPolyPointsList();
|
const auto& points = segment->BuildPolyPointsList();
|
||||||
for( unsigned i = 0; i < points.size(); i++ )
|
|
||||||
|
if( m_editPoints->PointsSize() != (unsigned) points.size() )
|
||||||
{
|
{
|
||||||
|
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] );
|
m_editPoints->Point( i ).SetPosition( points[i] );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -826,7 +835,8 @@ bool POINT_EDITOR::addCornerCondition( const SELECTION& aSelection )
|
||||||
// Works only for zones and line segments
|
// Works only for zones and line segments
|
||||||
return item->Type() == PCB_ZONE_AREA_T ||
|
return item->Type() == PCB_ZONE_AREA_T ||
|
||||||
( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
|
( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
|
||||||
static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
|
( static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT ||
|
||||||
|
static_cast<DRAWSEGMENT*>( item )->GetShape() == S_POLYGON ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -887,17 +897,23 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
|
const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
|
||||||
BOARD_COMMIT commit( frame );
|
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<DRAWSEGMENT*>( item )->GetShape() == S_POLYGON ) )
|
||||||
{
|
{
|
||||||
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
|
|
||||||
SHAPE_POLY_SET* zoneOutline = zone->Outline();
|
|
||||||
|
|
||||||
commit.Modify( zone );
|
|
||||||
|
|
||||||
unsigned int nearestIdx = 0;
|
unsigned int nearestIdx = 0;
|
||||||
unsigned int nextNearestIdx = 0;
|
unsigned int nextNearestIdx = 0;
|
||||||
unsigned int nearestDist = INT_MAX;
|
unsigned int nearestDist = INT_MAX;
|
||||||
unsigned int firstPointInContour = 0;
|
unsigned int firstPointInContour = 0;
|
||||||
|
SHAPE_POLY_SET* zoneOutline;
|
||||||
|
|
||||||
|
if( moduleEdge )
|
||||||
|
zoneOutline = &( static_cast<DRAWSEGMENT*>( item )->GetPolyShape() );
|
||||||
|
else
|
||||||
|
zoneOutline = static_cast<ZONE_CONTAINER*>( item )->Outline();
|
||||||
|
|
||||||
|
commit.Modify( item );
|
||||||
|
|
||||||
// Search the best outline segment to add a new corner
|
// Search the best outline segment to add a new corner
|
||||||
// and therefore break this segment into two segments
|
// 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:
|
// Add corner between nearestIdx and nextNearestIdx:
|
||||||
zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
|
zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
|
||||||
zone->Hatch();
|
|
||||||
|
// In board editor, we re-hatch the zone item
|
||||||
|
if( !moduleEdge )
|
||||||
|
static_cast<ZONE_CONTAINER*>( item )->Hatch();
|
||||||
|
|
||||||
|
|
||||||
commit.Push( _( "Add a zone corner" ) );
|
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<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT ) )
|
||||||
{
|
{
|
||||||
bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
|
|
||||||
|
|
||||||
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
|
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
|
||||||
|
|
||||||
if( segment->GetShape() == S_SEGMENT )
|
if( segment->GetShape() == S_SEGMENT )
|
||||||
|
|
Loading…
Reference in New Issue