Remove legacy segment-based zones.

Give the user the option of cancelling a file open if there are
segment zones; otherwise they're converted to polygon fills.

Fixes: lp:1823087
* https://bugs.launchpad.net/kicad/+bug/1823087
This commit is contained in:
Jeff Young 2019-04-10 10:19:16 +01:00
parent 2d7ef9813f
commit dae41b7460
46 changed files with 172 additions and 832 deletions

View File

@ -94,8 +94,6 @@ enum KICAD_T
PCB_MODULE_EDGE_T, ///< class EDGE_MODULE, a footprint edge
PCB_TRACE_T, ///< class TRACK, a track segment (segment on a copper layer)
PCB_VIA_T, ///< class VIA, a via (like a track segment on a copper layer)
PCB_SEGZONE_T, ///< class SEGZONE, a segment used to fill a zone area (segment on a
///< copper layer)
PCB_MARKER_T, ///< class MARKER_PCB, a marker used to show something
PCB_DIMENSION_T, ///< class DIMENSION, a dimension (graphic item)
PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item)

View File

@ -70,7 +70,7 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
TRACK* Track;
int nb_segm;
if( (track == NULL ) || (track->Type() == PCB_SEGZONE_T) )
if( track == NULL )
return;
m_canvas->CrossHairOff( DC ); // Erase cursor shape

View File

@ -566,7 +566,6 @@ void PCB_EDIT_FRAME::Block_Delete()
// These items are deleted, but not put in undo list
case PCB_MARKER_T: // a marker used to show something
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
item->UnLink();
itemsList->RemovePicker( ii );
ii--;
@ -626,12 +625,6 @@ void PCB_EDIT_FRAME::Block_Rotate()
case PCB_DIMENSION_T:
break;
// This item is not put in undo list
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii );
ii--;
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Rotate( ) error: unexpected type" ) );
break;
@ -695,13 +688,6 @@ void PCB_EDIT_FRAME::Block_Flip()
case PCB_DIMENSION_T:
break;
// This item is not put in undo list
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii );
ii--;
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
break;
@ -751,12 +737,6 @@ void PCB_EDIT_FRAME::Block_Move()
case PCB_DIMENSION_T:
break;
// This item is not put in undo list
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii );
ii--;
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Move( ) error: unexpected type" ) );
break;

View File

@ -183,7 +183,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_DIMENSION_T: // a dimension (graphic item)
case PCB_TARGET_T: // a target (graphic item)
case PCB_MARKER_T: // a marker used to show something
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
case PCB_ZONE_AREA_T:
itemsToDeselect.push_back( boardItem );

View File

@ -903,14 +903,6 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
break;
case PCB_SEGZONE_T:
if( aMode == ADD_APPEND )
m_SegZoneDeprecated.PushBack( (SEGZONE*) aBoardItem );
else
m_SegZoneDeprecated.PushFront( (SEGZONE*) aBoardItem );
break;
case PCB_MODULE_T:
if( aMode == ADD_APPEND )
m_Modules.PushBack( (MODULE*) aBoardItem );
@ -999,10 +991,6 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem )
m_Track.Remove( (TRACK*) aBoardItem );
break;
case PCB_SEGZONE_T:
m_SegZoneDeprecated.Remove( (SEGZONE*) aBoardItem );
break;
case PCB_DIMENSION_T:
case PCB_LINE_T:
case PCB_TEXT_T:
@ -1090,12 +1078,6 @@ int BOARD::GetNumSegmTrack() const
}
int BOARD::GetNumSegmZone() const
{
return m_SegZoneDeprecated.GetCount();
}
unsigned BOARD::GetNodesCount( int aNet )
{
unsigned retval = 0;
@ -1161,18 +1143,7 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
hasItems = true;
}
// Check segment zones
for( TRACK* track = m_SegZoneDeprecated; track; track = track->Next() )
{
if( !hasItems )
area = track->GetBoundingBox();
else
area.Merge( track->GetBoundingBox() );
hasItems = true;
}
// Check polygonal zones
// Check zones
for( auto aZone : m_ZoneDescriptorList )
{
if( !hasItems )
@ -1387,11 +1358,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
++p;
break;
case PCB_SEGZONE_T:
result = IterateForward( m_SegZoneDeprecated, inspector, testData, p );
++p;
break;
default: // catch EOT or ANY OTHER type here and return.
done = true;
break;

View File

@ -55,7 +55,6 @@ class PCB_EDIT_FRAME;
class PICKED_ITEMS_LIST;
class BOARD;
class ZONE_CONTAINER;
class SEGZONE;
class TRACK;
class D_PAD;
class MARKER_PCB;
@ -251,8 +250,6 @@ public:
DLIST<MODULE> m_Modules; // linked list of MODULEs
DLIST<TRACK> m_Track; // linked list of TRACKs and VIAs
DLIST<SEGZONE> m_SegZoneDeprecated; // linked list of SEGZONEs, for really very old boards
// should be removed one day
DLIST_ITERATOR_WRAPPER<TRACK> Tracks() { return DLIST_ITERATOR_WRAPPER<TRACK>(m_Track); }
DLIST_ITERATOR_WRAPPER<MODULE> Modules() { return DLIST_ITERATOR_WRAPPER<MODULE>(m_Modules); }
@ -275,8 +272,7 @@ public:
bool IsEmpty() const
{
return m_Drawings.GetCount() == 0 && m_Modules.GetCount() == 0 &&
m_Track.GetCount() == 0 && m_SegZoneDeprecated.GetCount() == 0;
return m_Drawings.GetCount() == 0 && m_Modules.GetCount() == 0 && m_Track.GetCount() == 0;
}
void Move( const wxPoint& aMoveVector ) override;
@ -698,9 +694,6 @@ public:
/** Functions to get some items count */
int GetNumSegmTrack() const;
/** Calculate the zone segment count */
int GetNumSegmZone() const;
/**
* Function GetNodesCount
* @param aNet Only count nodes belonging to this net

View File

@ -108,32 +108,6 @@ EDA_ITEM* TRACK::Clone() const
}
SEGZONE::SEGZONE( BOARD_ITEM* aParent ) :
TRACK( aParent, PCB_SEGZONE_T )
{
}
EDA_ITEM* SEGZONE::Clone() const
{
return new SEGZONE( *this );
}
wxString SEGZONE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
{
return wxString::Format( _( "Zone [%s] on %s" ),
UnescapeString( GetNetnameMsg() ),
GetLayerName() );
}
BITMAP_DEF SEGZONE::GetMenuImage() const
{
return add_zone_xpm;
}
VIA::VIA( BOARD_ITEM* aParent ) :
TRACK( aParent, PCB_VIA_T )
{
@ -454,26 +428,16 @@ void VIA::SanitizeLayers()
TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb )
{
TRACK* track;
// When reading from a file most of the items will already be in the correct order.
// Searching from the back therefore takes us from n^2 to essentially 0.
if( Type() == PCB_SEGZONE_T ) // Deprecated items, only found in very old boards
track = aPcb->m_SegZoneDeprecated.GetLast();
else
track = aPcb->m_Track.GetLast();
for( ; track; track = track->Back() )
for( TRACK* track = aPcb->m_Track.GetLast(); track; track = track->Back() )
{
if( GetNetCode() >= track->GetNetCode() )
return track->Next();
}
if( Type() == PCB_SEGZONE_T ) // Deprecated
return aPcb->m_SegZoneDeprecated.GetFirst();
else
return aPcb->m_Track.GetFirst();
return aPcb->m_Track.GetFirst();
}
@ -694,65 +658,6 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
}
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
const wxPoint& aOffset )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
if( displ_opts->m_DisplayZonesMode != 0 )
return;
BOARD* brd = GetBoard();
auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
return;
#ifdef USE_WX_OVERLAY
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
return;
#endif
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
{
PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
if( !IsOnLayer( curr_layer ) )
color = COLOR4D( DARKDARKGRAY );
}
if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
color.SetToLegacyHighlightColor();
color.a = 0.588;
GRSetDrawMode( aDC, aDrawMode );
// Draw track as line if width <= 1pixel:
if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
{
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
return;
}
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
{
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
}
else
{
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
m_Start.y + aOffset.y,
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
}
// No clearance or netnames for zones
}
void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
{
// Show the track and its netname on different layers
@ -1194,33 +1099,6 @@ void TRACK::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
}
void SEGZONE::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
{
wxString msg;
BOARD* board = GetBoard();
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Zone " ), DARKCYAN ) );
GetMsgPanelInfoBase_Common( aUnits, aList );
// Display layer
if( board )
msg = board->GetLayerName( m_Layer );
else
msg.Printf( wxT( "%d" ), m_Layer );
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
// Display width
msg = MessageTextFromValue( aUnits, m_Width );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
// Display segment length
msg = MessageTextFromValue( aUnits, GetLength() );
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
}
void VIA::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
{
wxString msg;

View File

@ -358,35 +358,6 @@ private:
};
class SEGZONE : public TRACK
{
public:
SEGZONE( BOARD_ITEM* aParent );
// Do not create a copy constructor. The one generated by the compiler is adequate.
wxString GetClass() const override
{
return wxT( "ZONE" );
}
SEGZONE* Next() const { return static_cast<SEGZONE*>( Pnext ); }
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override;
BITMAP_DEF GetMenuImage() const override;
EDA_ITEM* Clone() const override;
protected:
void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
};
class VIA : public TRACK
{
public:

View File

@ -459,7 +459,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
color.a = 0.588;
for ( int ic = 0; ic < m_FilledPolysList.OutlineCount(); ic++ )
for( int ic = 0; ic < m_FilledPolysList.OutlineCount(); ic++ )
{
const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( ic );
@ -485,40 +485,29 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
if( ( m_ZoneMinThickness > 1 ) || outline_mode )
{
int ilim = CornersBuffer.size() - 1;
int line_thickness = m_ZoneMinThickness;
for( int is = 0, ie = ilim; is <= ilim; ie = is, is++ )
{
// Draw only basic outlines, not extra segments.
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
GRCSegm( panel->GetClipBox(), DC,
CornersBuffer[is], CornersBuffer[ie], line_thickness, color );
{
GRCSegm( panel->GetClipBox(), DC, CornersBuffer[is], CornersBuffer[ie],
line_thickness, color );
}
else
GRFilledSegment( panel->GetClipBox(), DC,
CornersBuffer[is], CornersBuffer[ie], line_thickness, color );
{
GRFilledSegment( panel->GetClipBox(), DC, CornersBuffer[is], CornersBuffer[ie],
line_thickness, color );
}
}
}
// Draw areas:
if( m_FillMode != ZFM_SEGMENTS && !outline_mode )
GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0],
true, 0, color, color );
}
if( m_FillMode == ZFM_SEGMENTS && !outline_mode ) // filled with segments
{
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
// Draw fill:
if( !outline_mode )
{
wxPoint start = (wxPoint) ( m_FillSegmList[ic].A + VECTOR2I(offset) );
wxPoint end = (wxPoint) ( m_FillSegmList[ic].B + VECTOR2I(offset) );
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
GRCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y,
m_ZoneMinThickness, color );
else
GRFillCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y,
m_ZoneMinThickness, color );
GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0], true, 0,
color, color );
}
}
}
@ -882,11 +871,9 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL
switch( m_FillMode )
{
case ZFM_POLYGONS:
msg = _( "Polygons" ); break;
msg = _( "Solid" ); break;
case ZFM_HATCH_PATTERN:
msg = _( "Hatch Fill" ); break;
case ZFM_SEGMENTS: // Deprecated: found in old boards
msg = _( "Segments" ); break;
msg = _( "Hatched" ); break;
default:
msg = _( "Unknown" ); break;
}

View File

@ -74,8 +74,7 @@ public:
static inline bool ClassOf( const EDA_ITEM* aItem )
{
return aItem && ( ( PCB_ZONE_AREA_T == aItem->Type() ) ||
( PCB_SEGZONE_T == aItem->Type() ) );
return aItem && aItem->Type() == PCB_ZONE_AREA_T;
}
/**
@ -782,7 +781,6 @@ private:
/** How to fill areas:
* ZFM_POLYGONS => use solid polygons
* ZFM_SEGMENTS => fill by segments (deprecated).
* ZFM_HATCH_PATTERN => use a grid pattern as shape
*/
ZONE_FILL_MODE m_FillMode;

View File

@ -51,7 +51,6 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
PCB_PAD_T, // in modules
PCB_MODULE_TEXT_T, // in modules
PCB_MODULE_T, // in m_Modules
PCB_SEGZONE_T, // in m_Zones
PCB_ZONE_AREA_T, // in m_ZoneDescriptorList
EOT
};
@ -66,7 +65,6 @@ const KICAD_T GENERAL_COLLECTOR::BoardLevelItems[] = {
PCB_VIA_T,
PCB_TRACE_T,
PCB_MODULE_T,
PCB_SEGZONE_T,
PCB_ZONE_AREA_T,
EOT
};
@ -182,10 +180,6 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
breakhere++;
break;
case PCB_SEGZONE_T:
breakhere++;
break;
case PCB_TEXT_T:
breakhere++;
break;
@ -266,9 +260,6 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
goto exit;
break;
case PCB_SEGZONE_T:
break;
case PCB_ZONE_AREA_T:
zone = static_cast<ZONE_CONTAINER*>( item );
break;

View File

@ -78,7 +78,6 @@ bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem )
break;
}
case PCB_SEGZONE_T:
default:
return false;
}
@ -176,8 +175,6 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
break;
}
//N.B. SEGZONE items are deprecated and not to used for connectivity
case PCB_SEGZONE_T:
default:
return false;
}
@ -440,8 +437,6 @@ void CN_CONNECTIVITY_ALGO::Build( const std::vector<BOARD_ITEM*>& aItems )
break;
}
//N.B. SEGZONE items are deprecated and not to used for connectivity
case PCB_SEGZONE_T:
default:
break;
}

View File

@ -158,43 +158,17 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
(*m_Collector)[i]->Show( 0, std::cout );
#endif
/* Remove redundancies: sometime, legacy zones are found twice,
* because zones can be filled by overlapping segments (this is a fill option)
* Trigger the selection of the current edge for new-style zones
*/
timestamp_t timestampzone = 0;
// Trigger the selection of the current edge for zones
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{
item = (*m_Collector)[ii];
switch( item->Type() )
if( item->Type() == PCB_ZONE_AREA_T )
{
case PCB_SEGZONE_T:
// Found a TYPE ZONE
if( item->GetTimeStamp() == timestampzone ) // Remove it, redundant, zone already found
{
m_Collector->Remove( ii );
ii--;
}
else
{
timestampzone = item->GetTimeStamp();
}
break;
case PCB_ZONE_AREA_T:
{
/* We need to do the selection now because the menu text
* depends on it */
ZONE_CONTAINER *zone = static_cast<ZONE_CONTAINER*>( item );
int accuracy = KiROUND( 5 * guide.OnePixelInIU() );
zone->SetSelectedCorner( RefPos( true ), accuracy );
}
break;
default:
break;
// We need to do the selection now because the menu text depends on it
ZONE_CONTAINER *zone = static_cast<ZONE_CONTAINER*>( item );
int accuracy = KiROUND( 5 * guide.OnePixelInIU() );
zone->SetSelectedCorner( RefPos( true ), accuracy );
}
}

View File

@ -240,12 +240,6 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event )
}
}
for( TRACK* segm = GetBoard()->m_SegZoneDeprecated; segm; segm = segm->Next() )
{
// Note: deprecated zone segment fills only found in very old boards
hasChanges |= processBoardItem( this, commit, segm, new_layer );
}
for( BOARD_ITEM* zone : GetBoard()->Zones() )
{
hasChanges |= processBoardItem( this, commit, zone, new_layer );

View File

@ -462,7 +462,7 @@ void DRC::RunTests( wxTextCtrl* aMessages )
if( aMessages )
aMessages->AppendText( _( "Refilling all zones...\n" ) );
m_pcbEditorFrame->Fill_All_Zones( caller );
m_pcbEditorFrame->Fill_All_Zones();
}
else
{

View File

@ -111,7 +111,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
case ID_POPUP_PCB_DELETE_ZONE:
case ID_POPUP_PCB_DELETE_ZONE_CORNER:
case ID_POPUP_PCB_MOVE_ZONE_CORNER:
case ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT:
@ -499,21 +498,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_SETFLAGS_TRACK_MNU:
break;
case ID_POPUP_PCB_DELETE_ZONE:
m_canvas->MoveCursorToCrossHair();
if( GetCurItem() )
{
SEGZONE* zsegm = (SEGZONE*) GetCurItem();
int netcode = zsegm->GetNetCode();
Delete_OldZone_Fill( zsegm );
SetCurItem( NULL );
TestNetConnection( NULL, netcode );
OnModify();
SetMsgPanel( GetBoard() );
}
break;
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
Edit_Zone_Params( &dc, (ZONE_CONTAINER*) GetCurItem() );
SetCurItem( NULL ); // Outlines can have changed
@ -617,7 +601,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ALL_ZONES:
m_canvas->MoveCursorToCrossHair();
Fill_All_Zones( this );
Fill_All_Zones();
m_canvas->Refresh();
SetMsgPanel( GetBoard() );
break;
@ -638,9 +622,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
GetBoard()->m_SegZoneDeprecated.DeleteAll(); // remove deprecated zone segments used
// to fill zones in very old boards.
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{
// Remove filled areas in zone
@ -1293,10 +1274,6 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
Delete_Segment( DC, (TRACK*) Item );
break;
case PCB_SEGZONE_T:
Delete_OldZone_Fill( (SEGZONE*) Item );
break;
case PCB_ZONE_AREA_T:
{
SetCurItem( NULL );

View File

@ -1103,14 +1103,13 @@ static void CreateRoutesSection( FILE* aFile, BOARD* aPcb )
fprintf( aFile, "TRACK TRACK%d\n", track->GetWidth() );
}
if( (track->Type() == PCB_TRACE_T) || (track->Type() == PCB_SEGZONE_T) )
if( track->Type() == PCB_TRACE_T )
{
if( old_layer != track->GetLayer() )
{
old_layer = track->GetLayer();
fprintf( aFile, "LAYER %s\n",
GenCADLayerName( cu_count, track->GetLayer() ).c_str()
);
GenCADLayerName( cu_count, track->GetLayer() ).c_str() );
}
fprintf( aFile, "LINE %g %g %g %g\n",

View File

@ -576,7 +576,10 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( bds.m_CopperEdgeClearance == Millimeter2iu( LEGACY_COPPEREDGECLEARANCE ) )
bds.SetCopperEdgeClearance( inferLegacyEdgeClearance( loadedBoard ) );
GetScreen()->ClrModify();
if( loadedBoard->IsModified() )
OnModify();
else
GetScreen()->ClrModify();
if( pluginType == IO_MGR::LEGACY &&
loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION )

View File

@ -437,7 +437,6 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen
case PCB_TEXT_T:
case PCB_VIA_T:
case PCB_TRACE_T:
case PCB_SEGZONE_T:
case PCB_MARKER_T:
case PCB_DIMENSION_T:
case PCB_TARGET_T:

View File

@ -76,7 +76,6 @@ int PCB_EDIT_FRAME::SelectHighLight( wxDC* DC )
case PCB_TRACE_T:
case PCB_VIA_T:
case PCB_SEGZONE_T:
// since these classes are all derived from TRACK, use a common
// GetNet() function:
netcode = ( (TRACK*) item )->GetNetCode();

View File

@ -600,7 +600,6 @@ void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(drawings %d)\n", aBoard->Drawings().Size() );
m_out->Print( aNestLevel+1, "(tracks %d)\n", aBoard->GetNumSegmTrack() );
m_out->Print( aNestLevel+1, "(zones %d)\n", aBoard->GetNumSegmZone() );
m_out->Print( aNestLevel+1, "(modules %d)\n", aBoard->m_Modules.GetCount() );
m_out->Print( aNestLevel+1, "(nets %d)\n", m_mapping->GetSize() );
m_out->Print( aNestLevel, ")\n\n" );
@ -675,8 +674,7 @@ void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const
void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const
{
const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
for( NETINFO_MAPPING::iterator net = m_mapping->begin(), netEnd = m_mapping->end();
net != netEnd; ++net )
for( NETINFO_ITEM* net : *m_mapping )
{
m_out->Print( aNestLevel, "(net %d %s)\n",
m_mapping->Translate( net->GetNet() ),
@ -691,11 +689,9 @@ void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const
defaultNC.Format( m_out, aNestLevel, m_ctl );
// Save the rest of the net classes alphabetically.
for( NETCLASSES::const_iterator it = dsnSettings.m_NetClasses.begin();
it != dsnSettings.m_NetClasses.end();
++it )
for( const auto& it : dsnSettings.m_NetClasses )
{
NETCLASS netclass = *it->second;
NETCLASS netclass = *it.second;
filterNetClass( *aBoard, netclass ); // Remove empty nets (from a copy of a netclass)
netclass.Format( m_out, aNestLevel, m_ctl );
}
@ -1719,9 +1715,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( 0, " yes" );
// Default is polygon filled.
if( aZone->GetFillMode() == ZFM_SEGMENTS ) // Now deprecated. Should not be used
m_out->Print( 0, " (mode segment)" );
else if( aZone->GetFillMode() == ZFM_HATCH_PATTERN )
if( aZone->GetFillMode() == ZFM_HATCH_PATTERN )
m_out->Print( 0, " (mode hatch)" );
m_out->Print( 0, " (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)",

View File

@ -86,7 +86,7 @@
#include <convert_to_biu.h>
#include <trigo.h>
#include <build_version.h>
#include <confirm.h>
typedef LEGACY_PLUGIN::BIU BIU;
@ -496,7 +496,8 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
else if( TESTLINE( "$ZONE" ) )
{
loadTrackList( PCB_SEGZONE_T );
// No longer supported; discard segment fills
loadTrackList( NOT_USED );
}
else if( TESTLINE( "$GENERAL" ) )
@ -2306,10 +2307,12 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
flags = static_cast<STATUS_FLAGS>( flags_int );
if( aStructType==PCB_TRACE_T && type==1 )
makeType = PCB_VIA_T;
if( aStructType == PCB_TRACE_T )
makeType = ( type == 1 ) ? PCB_VIA_T : PCB_TRACE_T;
else if (aStructType == NOT_USED )
continue;
else
makeType = aStructType;
wxFAIL_MSG( "Segment type unknown" );
TRACK* newTrack;
@ -2323,10 +2326,6 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
case PCB_VIA_T:
newTrack = new VIA( m_board );
break;
case PCB_SEGZONE_T: // this is now deprecated, but exist in old boards
newTrack = new SEGZONE( m_board );
break;
}
newTrack->SetTimeStamp( (timestamp_t)timeStamp );
@ -2623,7 +2622,31 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
BIU thermalReliefGap = biuParse( data += 2 , &data ); // +=2 for " F"
BIU thermalReliefCopperBridge = biuParse( data );
zc->SetFillMode( fillmode ? ZFM_SEGMENTS : ZFM_POLYGONS );
if( fillmode)
{
// SEGMENT fill mode no longer supported. Make sure user is OK with converting them.
if( m_showLegacyZoneWarning )
{
KIDIALOG dlg( nullptr,
_( "The legacy segment fill mode is no longer supported.\n"
"Convert zones to polygon fills?"),
_( "Legacy Zone Warning" ),
wxYES_NO | wxICON_WARNING );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( dlg.ShowModal() == wxID_NO )
THROW_IO_ERROR( wxT( "CANCEL" ) );
m_showLegacyZoneWarning = false;
}
// User OK'd; switch to polygon mode
zc->SetFillMode( ZFM_POLYGONS );
m_board->SetModified();
}
else
zc->SetFillMode( ZFM_POLYGONS );
// @todo ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF: don't really want pcbnew.h
// in here, after all, its a PLUGIN and global data is evil.
@ -3063,6 +3086,7 @@ void LEGACY_PLUGIN::init( const PROPERTIES* aProperties )
m_loading_format_version = 0;
m_cu_count = 16;
m_board = NULL;
m_showLegacyZoneWarning = true;
m_props = aProperties;
// conversion factor for saving RAM BIUs to KICAD legacy file format.

View File

@ -53,7 +53,6 @@ class NETINFO_MAPPING;
class TEXTE_MODULE;
class EDGE_MODULE;
class TRACK;
class SEGZONE;
class D_PAD;
struct LP_CACHE;
@ -128,6 +127,7 @@ protected:
wxString m_field; ///< reused to stuff MODULE fields.
int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing?
LP_CACHE* m_cache;
bool m_showLegacyZoneWarning;
NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty nets
///< are stored with consecutive integers as net codes
@ -209,8 +209,8 @@ protected:
* Function loadTrackList
* reads a list of segments (Tracks and Vias, or Segzones)
*
* @param aStructType is either PCB_TRACE_T to indicate tracks and vias, or
* PCB_SEGZONE_T to indicate oldschool zone segments (before polygons came to be).
* @param aStructType is either PCB_TRACE_T to indicate tracks and vias, or NOT_USED
* to indicate oldschool zone segments (which are discarded).
*/
void loadTrackList( int aStructType );

View File

@ -228,10 +228,6 @@ void NETINFO_MAPPING::Update()
}
}
// Segzones (should be removed: used only in very old boards)
for( SEGZONE* zone = m_board->m_SegZoneDeprecated; zone; zone = zone->Next() )
nets.insert( zone->GetNetCode() );
// Prepare the new mapping
m_netMapping.clear();

View File

@ -196,11 +196,6 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
break;
case PCB_SEGZONE_T: // Item used to fill a zone
AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_ZONE,
_( "Delete Zone Filling" ), KiBitmap( delete_xpm ) );
break;
case PCB_ZONE_AREA_T: // Item used to handle a zone area (outlines, holes ...)
if( flags & IS_NEW )
{

View File

@ -177,10 +177,6 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard )
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
m_view->Add( module );
// Segzones (deprecated, equivalent of ZONE_CONTAINERfilled areas for very old boards)
for( SEGZONE* zone = aBoard->m_SegZoneDeprecated; zone; zone = zone->Next() )
m_view->Add( zone );
// DRC markers
for( int marker_idx = 0; marker_idx < aBoard->GetMARKERCount(); ++marker_idx )
{

View File

@ -40,7 +40,6 @@ class BOARD_ITEM_CONTAINER;
class TEXTE_PCB;
class MODULE;
class TRACK;
class SEGZONE;
class VIA;
class D_PAD;
class TEXTE_MODULE;
@ -1389,18 +1388,6 @@ public:
// zone handling
/**
* Function Delete_OldZone_Fill (obsolete)
* Used for compatibility with old boards
* Remove the zone filling which include the segment aZone, or the zone
* which have the given time stamp.
* For old boards, a zone is a group of SEGZONE segments which have the same TimeStamp
* @param aZone = zone segment within the zone to delete. Can be NULL
* @param aTimestamp = Timestamp for the zone to delete, used if aZone ==
* NULL
*/
void Delete_OldZone_Fill( SEGZONE* aZone, timestamp_t aTimestamp = 0 );
/**
* Function Delete_LastCreatedCorner
* Used only while creating a new zone outline
@ -1436,19 +1423,13 @@ public:
* The filling starts from starting points like pads, tracks.
* If exists the old filling is removed
* @param aZone = zone to fill
* @return error level (0 = no error)
*/
int Fill_Zone( ZONE_CONTAINER* aZone );
void Fill_Zone( ZONE_CONTAINER* aZone );
/**
* Function Fill_All_Zones
* Fill all zones on the board
* The old fillings are removed
* @param aActiveWindow = the current active window, if a progress bar is shown.
* the progress bar will be on top of aActiveWindow
* aActiveWindow = NULL to do not display a progress bar
*/
int Fill_All_Zones( wxWindow * aActiveWindow );
void Fill_All_Zones();
/**
* Function Check_All_Zones

View File

@ -157,16 +157,6 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
track->Draw( aPanel, DC, aDrawMode );
}
// SEGZONE is deprecated, only for compatibility with
// very old designs
for( SEGZONE* zone = m_SegZoneDeprecated; zone; zone = zone->Next() )
{
if( zone->IsMoving() )
continue;
zone->Draw( aPanel, DC, aDrawMode );
}
// Draw areas (i.e. zones)
for( int ii = 0; ii < GetAreaCount(); ii++ )
{

View File

@ -310,7 +310,6 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
// the "cast" applied in here clarifies which overloaded draw() is called
switch( item->Type() )
{
case PCB_SEGZONE_T:
case PCB_TRACE_T:
draw( static_cast<const TRACK*>( item ), aLayer );
break;

View File

@ -43,7 +43,6 @@ class TRACK;
class D_PAD;
class DRAWSEGMENT;
class MODULE;
class SEGZONE;
class ZONE_CONTAINER;
class TEXTE_PCB;
class TEXTE_MODULE;

View File

@ -56,6 +56,7 @@ using namespace PCB_KEYS_T;
void PCB_PARSER::init()
{
m_showLegacyZoneWarning = true;
m_tooRecent = false;
m_requiredVersion = 0;
m_layerIndices.clear();
@ -648,9 +649,6 @@ BOARD* PCB_PARSER::parseBOARD_unchecked()
visitItem( segm );
}
for( TRACK* segm = m_board->m_SegZoneDeprecated; segm; segm = segm->Next() )
visitItem( segm );
for( BOARD_ITEM* zone : m_board->Zones() )
visitItem( zone );
@ -3183,7 +3181,27 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER()
Expecting( "segment, hatch or polygon" );
if( token == T_segment ) // deprecated
zone->SetFillMode( ZFM_SEGMENTS );
{
// SEGMENT fill mode no longer supported. Make sure user is OK with converting them.
if( m_showLegacyZoneWarning )
{
KIDIALOG dlg( nullptr,
_( "The legacy segment fill mode is no longer supported.\n"
"Convert zones to polygon fills?"),
_( "Legacy Zone Warning" ),
wxYES_NO | wxICON_WARNING );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( dlg.ShowModal() == wxID_NO )
THROW_IO_ERROR( wxT( "CANCEL" ) );
m_showLegacyZoneWarning = false;
}
zone->SetFillMode( ZFM_POLYGONS );
m_board->SetModified();
}
else if( token == T_hatch )
zone->SetFillMode( ZFM_HATCH_PATTERN );
else

View File

@ -75,6 +75,8 @@ class PCB_PARSER : public PCB_LEXER
bool m_tooRecent; ///< true if version parses as later than supported
int m_requiredVersion; ///< set to the KiCad format version this board requires
bool m_showLegacyZoneWarning;
///> Converts net code using the mapping table if available,
///> otherwise returns unchanged net code if < 0 or if is is out of range
inline int getNetCode( int aNetCode )

View File

@ -113,7 +113,6 @@ enum pcbnew_ids
ID_POPUP_PCB_PLACE_ZONE_CORNER,
ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER,
ID_POPUP_PCB_EDIT_ZONE_PARAMS,
ID_POPUP_PCB_DELETE_ZONE,
ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE,
ID_POPUP_PCB_FILL_ALL_ZONES,
ID_POPUP_PCB_FILL_ZONE,

View File

@ -138,17 +138,6 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
}
aPlotter->EndBlock( NULL );
// Plot segments used to fill zone areas (deprecated, but here for very old boards
// compatibility):
for( SEGZONE* seg = aBoard->m_SegZoneDeprecated; seg; seg = seg->Next() )
{
if( !aLayerMask[ seg->GetLayer() ] )
continue;
aPlotter->ThickSegment( seg->GetStart(), seg->GetEnd(), seg->GetWidth(),
itemplotter.GetPlotMode(), NULL );
}
}
void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
@ -573,17 +562,6 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
aPlotter->EndBlock( NULL );
// Plot zones (deprecated, for very old boards compatibility):
for( TRACK* track = aBoard->m_SegZoneDeprecated; track; track = track->Next() )
{
if( !aLayerMask[track->GetLayer()] )
continue;
int width = track->GetWidth() + itemplotter.getFineWidthAdj();
aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode, NULL );
}
// Plot filled ares
aPlotter->StartBlock( NULL );
for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )

View File

@ -1,13 +1,7 @@
/**
* @file plot_brditems_plotter.cpp
* @brief basic plot functions to plot board items, or a group of board items.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -284,25 +278,11 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
{
switch( item->Type() )
{
case PCB_LINE_T:
PlotDrawSegment( (DRAWSEGMENT*) item);
break;
case PCB_TEXT_T:
PlotTextePcb( (TEXTE_PCB*) item );
break;
case PCB_DIMENSION_T:
PlotDimension( (DIMENSION*) item );
break;
case PCB_TARGET_T:
PlotPcbTarget( (PCB_TARGET*) item );
break;
case PCB_MARKER_T:
default:
break;
case PCB_LINE_T: PlotDrawSegment( (DRAWSEGMENT*) item); break;
case PCB_TEXT_T: PlotTextePcb( (TEXTE_PCB*) item ); break;
case PCB_DIMENSION_T: PlotDimension( (DIMENSION*) item ); break;
case PCB_TARGET_T: PlotPcbTarget( (PCB_TARGET*) item ); break;
default: break;
}
}
}
@ -341,9 +321,7 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, COLOR4D aColor )
MODULE* parent = static_cast<MODULE*> ( pt_texte->GetParent() );
gbr_metadata.SetCmpReference( parent->GetReference() );
m_plotter->Text( pos, aColor,
pt_texte->GetShownText(),
orient, size,
m_plotter->Text( pos, aColor, pt_texte->GetShownText(), orient, size,
pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
}
@ -539,10 +517,8 @@ void BRDITEMS_PLOTTER::Plot_1_EdgeModule( EDGE_MODULE* aEdge )
cornerList.reserve( polyPoints.size() );
for( unsigned ii = 0; ii < polyPoints.size(); ii++ )
for( wxPoint corner : polyPoints )
{
wxPoint corner = polyPoints[ii];
if( module )
{
RotatePoint( &corner, module->GetOrientation() );
@ -556,12 +532,12 @@ void BRDITEMS_PLOTTER::Plot_1_EdgeModule( EDGE_MODULE* aEdge )
{
for( size_t i = 1; i < cornerList.size(); i++ )
{
m_plotter->ThickSegment( cornerList[i-1], cornerList[i],
thickness, GetPlotMode(), &gbr_metadata );
m_plotter->ThickSegment( cornerList[i-1], cornerList[i], thickness,
GetPlotMode(), &gbr_metadata );
}
m_plotter->ThickSegment( cornerList.back(), cornerList.front(),
thickness, GetPlotMode(), &gbr_metadata );
m_plotter->ThickSegment( cornerList.back(), cornerList.front(), thickness,
GetPlotMode(), &gbr_metadata );
}
else
@ -592,9 +568,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
GBR_METADATA gbr_metadata;
if( IsCopperLayer( pt_texte->GetLayer() ) )
{
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
}
COLOR4D color = getColor( pt_texte->GetLayer() );
m_plotter->SetColor( color );
@ -690,43 +664,23 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
{
// First, close the outline
if( cornerList[0] != cornerList[cornerList.size() - 1] )
{
cornerList.push_back( cornerList[0] );
}
// Plot the current filled area and its outline
if( GetPlotMode() == FILLED )
{
// Plot the filled area polygon.
// The area can be filled by segments (outdated) or uses solid polygons
if( aZone->GetFillMode() != ZONE_FILL_MODE::ZFM_SEGMENTS ) // We are using solid polygons
{
m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
}
else // We are using areas filled by segments: plot segments and outline
{
for( unsigned iseg = 0; iseg < aZone->FillSegments().size(); iseg++ )
{
wxPoint start = (wxPoint) aZone->FillSegments()[iseg].A;
wxPoint end = (wxPoint) aZone->FillSegments()[iseg].B;
m_plotter->ThickSegment( start, end,
aZone->GetMinThickness(),
GetPlotMode(), &gbr_metadata );
}
// Plot the area outline only
if( aZone->GetMinThickness() > 0 )
m_plotter->PlotPoly( cornerList, NO_FILL, aZone->GetMinThickness() );
}
m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
}
else
{
if( aZone->GetMinThickness() > 0 )
{
for( unsigned jj = 1; jj<cornerList.size(); jj++ )
for( unsigned jj = 1; jj < cornerList.size(); jj++ )
{
m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
aZone->GetMinThickness(),
GetPlotMode(), &gbr_metadata );
}
}
m_plotter->SetCurrentLineWidth( -1 );
@ -759,9 +713,7 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg )
bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
if( isOnCopperLayer && aSeg->GetLayer() == Edge_Cuts ) // can happens when plotting copper layers
{
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
}
switch( aSeg->GetShape() )
{
@ -788,8 +740,10 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg )
const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
for( unsigned i = 1; i < bezierPoints.size(); i++ )
{
m_plotter->ThickSegment( bezierPoints[i - 1], bezierPoints[i],
thickness, GetPlotMode(), &gbr_metadata );
}
}
break;
@ -833,10 +787,9 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg )
/** Helper function to plot a single drill mark. It compensate and clamp
* the drill mark size depending on the current plot options
*/
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
const wxPoint &aDrillPos, wxSize aDrillSize,
const wxSize &aPadSize,
double aOrientation, int aSmallDrill )
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos,
wxSize aDrillSize, const wxSize &aPadSize,
double aOrientation, int aSmallDrill )
{
// Small drill marks have no significance when applied to slots
if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
@ -883,9 +836,11 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
const VIA* via = dyn_cast<const VIA*>( pts );
if( via )
{
plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(),
wxSize( via->GetDrillValue(), 0 ),
wxSize( via->GetWidth(), 0 ), 0, small_drill );
}
}
for( MODULE* Module = m_board->m_Modules; Module != NULL; Module = Module->Next() )

View File

@ -248,13 +248,6 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
itemsList.PushItem( picker );
}
// Append zones segm:
for( BOARD_ITEM* item = currentPcb->m_SegZoneDeprecated; item != NULL; item = item->Next() )
{
ITEM_PICKER picker( item, UR_CHANGED );
itemsList.PushItem( picker );
}
if( itemsList.GetCount() > 0 )
SaveCopyInUndoList( itemsList, UR_CHANGED, wxPoint( 0.0, 0.0 ) );
else
@ -306,7 +299,6 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
case PCB_TEXT_T:
case PCB_DIMENSION_T:
case PCB_TARGET_T:
case PCB_SEGZONE_T:
// If item has a list it's mean that the element is on the board
if( item->GetList() == NULL )
@ -375,15 +367,6 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
}
}
for( BOARD_ITEM* item = currentPcb->m_SegZoneDeprecated; item != NULL; item = item->Next() )
{
if( !oldBuffer->ContainsItem( item ) )
{
ITEM_PICKER picker( item, UR_NEW );
oldBuffer->PushItem( picker );
}
}
for( int ii = 0; ii < currentPcb->GetAreaCount(); ii++ )
{
if( !oldBuffer->ContainsItem( (EDA_ITEM*) currentPcb->GetArea( ii ) ) )

View File

@ -305,7 +305,6 @@ public:
static TOOL_ACTION zoneUnfill;
static TOOL_ACTION zoneUnfillAll;
static TOOL_ACTION zoneMerge;
static TOOL_ACTION zoneDeleteSegzone;
/// Duplicate zone onto another layer
static TOOL_ACTION zoneDuplicate;

View File

@ -312,8 +312,6 @@ bool PCB_EDITOR_CONTROL::Init()
menu.AddItem( PCB_ACTIONS::findMove, inactiveStateCondition );
menu.AddSeparator( inactiveStateCondition );
menu.AddItem( PCB_ACTIONS::zoneDeleteSegzone,
SELECTION_CONDITIONS::OnlyType( PCB_SEGZONE_T ) );
toolMenu.AddSubMenu( zoneMenu );
toolMenu.AddSubMenu( lockMenu );

View File

@ -58,10 +58,6 @@ TOOL_ACTION PCB_ACTIONS::zoneUnfillAll( "pcbnew.ZoneFiller.zoneUnfillAll",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZONE_REMOVE_FILLED ),
_( "Unfill All" ), _( "Unfill all zones" ) );
TOOL_ACTION PCB_ACTIONS::zoneDeleteSegzone( "pcbnew.ZoneFiller.zoneDeleteSegzone",
AS_GLOBAL, 0,
_( "Delete Zone Filling" ), _( "Delete Zone Filling" ), delete_xpm );
ZONE_FILLER_TOOL::ZONE_FILLER_TOOL() :
PCB_TOOL( "pcbnew.ZoneFiller" )
{
@ -157,34 +153,6 @@ int ZONE_FILLER_TOOL::ZoneUnfill( const TOOL_EVENT& aEvent )
}
int ZONE_FILLER_TOOL::SegzoneDeleteFill( const TOOL_EVENT& aEvent )
{
BOARD_COMMIT commit( this );
BOARD* board = (BOARD*) m_toolMgr->GetModel();
for( auto item : selection() )
{
assert( item->Type() == PCB_SEGZONE_T );
timestamp_t timestamp = item->GetTimeStamp(); // Save reference time stamp (aZone will be deleted)
SEGZONE* next;
for( SEGZONE* zone = board->m_SegZoneDeprecated; zone; zone = next )
{
next = zone->Next();
if( timestamp == zone->GetTimeStamp() )
commit.Remove( zone );
}
}
commit.Push( _( "Delete Zone Filling" ) );
canvas()->Refresh();
return 0;
}
int ZONE_FILLER_TOOL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
{
BOARD_COMMIT commit( this );
@ -211,5 +179,4 @@ void ZONE_FILLER_TOOL::setTransitions()
Go( &ZONE_FILLER_TOOL::ZoneFillAll, PCB_ACTIONS::zoneFillAll.MakeEvent() );
Go( &ZONE_FILLER_TOOL::ZoneUnfill, PCB_ACTIONS::zoneUnfill.MakeEvent() );
Go( &ZONE_FILLER_TOOL::ZoneUnfillAll, PCB_ACTIONS::zoneUnfillAll.MakeEvent() );
Go( &ZONE_FILLER_TOOL::SegzoneDeleteFill, PCB_ACTIONS::zoneDeleteSegzone.MakeEvent() );
}

View File

@ -50,9 +50,6 @@ public:
int ZoneUnfill( const TOOL_EVENT& aEvent );
int ZoneUnfillAll( const TOOL_EVENT& aEvent );
// Segzone action
int SegzoneDeleteFill( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -152,10 +152,6 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
itemsList.push_back( aPcb->GetArea( ii ) );
// Append zones segm (deprecated items):
for( item = aPcb->m_SegZoneDeprecated; item != NULL; item = item->Next() )
itemsList.push_back( item );
NETINFO_LIST& netInfo = aPcb->GetNetInfo();
for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )

View File

@ -52,6 +52,28 @@
#include "zone_filler.h"
class PROGRESS_REPORTER_HIDER
{
public:
PROGRESS_REPORTER_HIDER( WX_PROGRESS_REPORTER* aReporter )
{
m_reporter = aReporter;
if( aReporter )
aReporter->Hide();
}
~PROGRESS_REPORTER_HIDER()
{
if( m_reporter )
m_reporter->Show();
}
private:
WX_PROGRESS_REPORTER* m_reporter;
};
extern void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer,
const D_PAD& aPad, int aThermalGap, int aCopperThickness,
int aMinThicknessValue, int aCircleToSegmentsCount,
@ -60,6 +82,7 @@ extern void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer,
static double s_thermalRot = 450; // angle of stubs in thermal reliefs for round pads
static const bool s_DumpZonesWhenFilling = false;
ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) :
m_board( aBoard ), m_commit( aCommit ), m_progressReporter( nullptr )
{
@ -76,7 +99,8 @@ void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* aReporter )
m_progressReporter = aReporter;
}
bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
bool ZONE_FILLER::Fill( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck )
{
std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
auto connectivity = m_board->GetConnectivity();
@ -86,6 +110,12 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
if( !lock )
return false;
if( m_progressReporter )
{
m_progressReporter->Report( _( "Checking zone fills..." ) );
m_progressReporter->SetMaxProgress( toFill.size() );
}
for( auto zone : aZones )
{
// Keepout zones are not filled
@ -107,15 +137,6 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
zone->UnFill();
}
if( m_progressReporter )
{
m_progressReporter->Report( _( "Checking zone fills..." ) );
m_progressReporter->SetMaxProgress( toFill.size() );
}
// Remove deprecaded segment zones (only found in very old boards)
m_board->m_SegZoneDeprecated.DeleteAll();
std::atomic<size_t> nextItem( 0 );
size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(), toFill.size() );
std::vector<std::future<size_t>> returns( parallelThreadCount );
@ -132,14 +153,6 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
zone->SetRawPolysList( rawPolys );
zone->SetFilledPolysList( finalPolys );
if( zone->GetFillMode() == ZFM_SEGMENTS )
{
ZONE_SEGMENT_FILL segFill;
fillZoneWithSegments( zone, zone->GetFilledPolysList(), segFill );
zone->SetFillSegments( segFill );
}
zone->SetIsFilled( true );
if( m_progressReporter )
@ -204,10 +217,9 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
poly.DeletePolygon( idx );
}
}
// zones with no net can have areas outside the board cutouts.
// Please, use only this clipping for no nets zones: this is a very time consumming
// calculation (x 5 in a test case if made for all zones),
// mainly due to poly.Fracture
// Zones with no net can have areas outside the board cutouts.
// Please, use only this clipping for no-net zones: this is a very time consumming
// calculation (x 5 in a test case if made for all zones), mainly due to poly.Fracture
else if( clip_to_brd_outlines )
{
poly.BooleanIntersection( boardOutline, SHAPE_POLY_SET::PM_FAST );
@ -220,27 +232,16 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
outOfDate = true;
}
if( aCheck )
if( aCheck && outOfDate )
{
bool refill = false;
wxCHECK( m_progressReporter, false );
PROGRESS_REPORTER_HIDER raii( m_progressReporter );
KIDIALOG dlg( m_progressReporter->GetParent(),
_( "Zone fills are out-of-date. Refill?" ),
_( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( outOfDate )
{
m_progressReporter->Hide();
KIDIALOG dlg( m_progressReporter->GetParent(),
_( "Zone fills are out-of-date. Refill?" ),
_( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
refill = ( dlg.ShowModal() == wxID_OK );
m_progressReporter->Show();
}
if( !refill )
if( dlg.ShowModal() == wxID_CANCEL )
{
if( m_commit )
m_commit->Revert();
@ -312,10 +313,8 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
}
else
{
for( unsigned i = 0; i < toFill.size(); i++ )
{
connectivity->Update( toFill[i].m_zone );
}
for( auto& i : toFill )
connectivity->Update( i.m_zone );
connectivity->RecalculateRatsnest();
}
@ -867,169 +866,6 @@ bool ZONE_FILLER::fillSingleZone( ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aRawPol
return true;
}
bool ZONE_FILLER::fillZoneWithSegments( ZONE_CONTAINER* aZone,
const SHAPE_POLY_SET& aFilledPolys,
ZONE_SEGMENT_FILL& aFillSegs ) const
{
bool success = true;
// segments are on something like a grid. Give it a minimal size
// to avoid too many segments, and use the m_ZoneMinThickness when (this is usually the case)
// the size is > mingrid_size.
// This is not perfect, but the actual purpose of this code
// is to allow filling zones on a grid, with grid size > m_ZoneMinThickness,
// in order to have really a grid.
//
// Using a user selectable grid size is for future Kicad versions.
// For now the area is fully filled.
int mingrid_size = Millimeter2iu( 0.05 );
int grid_size = std::max( mingrid_size, aZone->GetMinThickness() );
// Make segments slightly overlapping to ensure a good full filling
grid_size -= grid_size/20;
// Creates the horizontal segments
for ( int index = 0; index < aFilledPolys.OutlineCount(); index++ )
{
const SHAPE_LINE_CHAIN& outline0 = aFilledPolys.COutline( index );
success = fillPolygonWithHorizontalSegments( outline0, aFillSegs, grid_size );
if( !success )
break;
// Creates the vertical segments. Because the filling algo creates horizontal segments,
// to reuse the fillPolygonWithHorizontalSegments function, we rotate the polygons to fill
// then fill them, then inverse rotate the result
SHAPE_LINE_CHAIN outline90;
outline90.Append( outline0 );
// Rotate 90 degrees the outline:
for( int ii = 0; ii < outline90.PointCount(); ii++ )
{
VECTOR2I& point = outline90.Point( ii );
std::swap( point.x, point.y );
point.y = -point.y;
}
int first_point = aFillSegs.size();
success = fillPolygonWithHorizontalSegments( outline90, aFillSegs, grid_size );
if( !success )
break;
// Rotate -90 degrees the segments:
for( unsigned ii = first_point; ii < aFillSegs.size(); ii++ )
{
SEG& segm = aFillSegs[ii];
std::swap( segm.A.x, segm.A.y );
std::swap( segm.B.x, segm.B.y );
segm.A.x = - segm.A.x;
segm.B.x = - segm.B.x;
}
}
aZone->SetNeedRefill( false );
return success;
}
/** Helper function fillPolygonWithHorizontalSegments
* fills a polygon with horizontal segments.
* It can be used for any angle, if the zone outline to fill is rotated by this angle
* and the result is rotated by -angle
* @param aPolygon = a SHAPE_LINE_CHAIN polygon to fill
* @param aFillSegmList = a std::vector\<SEGMENT\> which will be populated by filling segments
* @param aStep = the horizontal grid size
*/
bool ZONE_FILLER::fillPolygonWithHorizontalSegments( const SHAPE_LINE_CHAIN& aPolygon,
ZONE_SEGMENT_FILL& aFillSegmList, int aStep ) const
{
std::vector <int> x_coordinates;
bool success = true;
// Creates the horizontal segments
const SHAPE_LINE_CHAIN& outline = aPolygon;
const BOX2I& rect = outline.BBox();
// Calculate the y limits of the zone
for( int refy = rect.GetY(), endy = rect.GetBottom(); refy < endy; refy += aStep )
{
// find all intersection points of an infinite line with polyline sides
x_coordinates.clear();
for( int v = 0; v < outline.PointCount(); v++ )
{
int seg_startX = outline.CPoint( v ).x;
int seg_startY = outline.CPoint( v ).y;
int seg_endX = outline.CPoint( v + 1 ).x;
int seg_endY = outline.CPoint( v + 1 ).y;
/* Trivial cases: skip if ref above or below the segment to test */
if( ( seg_startY > refy ) && ( seg_endY > refy ) )
continue;
// segment below ref point, or its Y end pos on Y coordinate ref point: skip
if( ( seg_startY <= refy ) && (seg_endY <= refy ) )
continue;
/* at this point refy is between seg_startY and seg_endY
* see if an horizontal line at Y = refy is intersecting this segment
*/
// calculate the x position of the intersection of this segment and the
// infinite line this is more easier if we move the X,Y axis origin to
// the segment start point:
seg_endX -= seg_startX;
seg_endY -= seg_startY;
double newrefy = (double) ( refy - seg_startY );
double intersec_x;
if ( seg_endY == 0 ) // horizontal segment on the same line: skip
continue;
// Now calculate the x intersection coordinate of the horizontal line at
// y = newrefy and the segment from (0,0) to (seg_endX,seg_endY) with the
// horizontal line at the new refy position the line slope is:
// slope = seg_endY/seg_endX; and inv_slope = seg_endX/seg_endY
// and the x pos relative to the new origin is:
// intersec_x = refy/slope = refy * inv_slope
// Note: because horizontal segments are already tested and skipped, slope
// exists (seg_end_y not O)
double inv_slope = (double) seg_endX / seg_endY;
intersec_x = newrefy * inv_slope;
x_coordinates.push_back( (int) intersec_x + seg_startX );
}
// A line scan is finished: build list of segments
// Sort intersection points by increasing x value:
// So 2 consecutive points are the ends of a segment
std::sort( x_coordinates.begin(), x_coordinates.end() );
// An even number of coordinates is expected, because a segment has 2 ends.
// An if this algorithm always works, it must always find an even count.
if( ( x_coordinates.size() & 1 ) != 0 )
{
success = false;
break;
}
// Create segments having the same Y coordinate
int iimax = x_coordinates.size() - 1;
for( int ii = 0; ii < iimax; ii += 2 )
{
VECTOR2I seg_start, seg_end;
seg_start.x = x_coordinates[ii];
seg_start.y = refy;
seg_end.x = x_coordinates[ii + 1];
seg_end.y = refy;
SEG segment( seg_start, seg_end );
aFillSegmList.push_back( segment );
}
} // End examine segments in one area
return success;
}
/**
* Function buildUnconnectedThermalStubsPolygonList

View File

@ -42,7 +42,7 @@ public:
~ZONE_FILLER();
void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter );
bool Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck = false );
bool Fill( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck = false );
private:
@ -66,21 +66,6 @@ private:
SHAPE_POLY_SET& aRawPolys,
SHAPE_POLY_SET& aFinalPolys ) const;
bool fillPolygonWithHorizontalSegments( const SHAPE_LINE_CHAIN& aPolygon,
ZONE_SEGMENT_FILL& aFillSegmList, int aStep ) const;
/**
* Function fillZoneWithSegments
* Fill sub areas in a zone with segments with m_ZoneMinThickness width
* A scan is made line per line, on the whole filled areas, with a step of m_ZoneMinThickness.
* all intersecting points with the horizontal infinite line and polygons to fill are calculated
* a list of SEGZONE items is built, line per line
* @return true if success, false on error
*/
bool fillZoneWithSegments( ZONE_CONTAINER* aZone,
const SHAPE_POLY_SET& aFilledPolys,
ZONE_SEGMENT_FILL& aFillSegs ) const;
/**
* Function buildUnconnectedThermalStubsPolygonList
* Creates a set of polygons corresponding to stubs created by thermal shapes on pads

View File

@ -37,8 +37,7 @@
enum ZONE_FILL_MODE
{
ZFM_POLYGONS = 0, // fill zone with polygons
ZFM_SEGMENTS = 1, // fill zone with segments (legacy)
ZFM_HATCH_PATTERN = 2 // fill zone using a grid pattern
ZFM_HATCH_PATTERN = 1 // fill zone using a grid pattern
};
/**

View File

@ -996,9 +996,6 @@ void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* aZone )
EDA_RECT dirty = aZone->GetBoundingBox();
// For compatibility with old boards: remove old SEGZONE fill segments
Delete_OldZone_Fill( NULL, aZone->GetTimeStamp() );
// Remove current filling:
aZone->UnFill();

View File

@ -52,54 +52,10 @@
#include <zone_filler.h>
/**
* Function Delete_OldZone_Fill (obsolete)
* Used for compatibility with old boards
* Remove the zone filling which include the segment aZone, or the zone which have the
* given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param aZone = zone segment within the zone to delete. Can be NULL
* @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL
*/
void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, timestamp_t aTimestamp )
{
bool modify = false;
timestamp_t TimeStamp;
if( aZone == NULL )
TimeStamp = aTimestamp;
else
TimeStamp = aZone->GetTimeStamp(); // Save reference time stamp (aZone will be deleted)
// SEGZONE is a deprecated item, only used for compatibility with very old boards
SEGZONE* next;
for( SEGZONE* zone = GetBoard()->m_SegZoneDeprecated; zone != NULL; zone = next )
{
next = zone->Next();
if( zone->GetTimeStamp() == TimeStamp )
{
modify = true;
// remove item from linked list and free memory
zone->DeleteStructure();
}
}
if( modify )
{
OnModify();
m_canvas->Refresh();
}
}
int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow* aActiveWindow )
void PCB_EDIT_FRAME::Fill_All_Zones()
{
auto toolMgr = GetToolManager();
wxCHECK( toolMgr, 1 );
toolMgr->RunAction( PCB_ACTIONS::zoneFillAll, true );
return 0;
}