Coverity fixes.

This commit is contained in:
Wayne Stambaugh 2022-10-17 09:19:39 -04:00
parent bd145a4904
commit 598b09821a
12 changed files with 283 additions and 237 deletions

View File

@ -91,7 +91,7 @@ CLI::EXPORT_STEP_COMMAND::EXPORT_STEP_COMMAND() : COMMAND( "step" )
int CLI::EXPORT_STEP_COMMAND::Perform( KIWAY& aKiway ) const
{
JOB_EXPORT_STEP* step = new JOB_EXPORT_STEP( true );
std::unique_ptr<JOB_EXPORT_STEP> step( new JOB_EXPORT_STEP( true ) );
step->m_useDrillOrigin = m_argParser.get<bool>( ARG_DRILL_ORIGIN );
step->m_useGridOrigin = m_argParser.get<bool>( ARG_GRID_ORIGIN );
@ -168,7 +168,7 @@ int CLI::EXPORT_STEP_COMMAND::Perform( KIWAY& aKiway ) const
}
}
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, step );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, step.get() );
return exitCode;
}
}

View File

@ -42,6 +42,7 @@
#include <plotters/plotters_pslike.h>
std::string PDF_PLOTTER::encodeStringForPlotter( const wxString& aText )
{
// returns a string compatible with PDF string convention from a unicode string.
@ -250,11 +251,12 @@ void PDF_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T aFill, int w
double magic = radius * 0.551784; // You don't want to know where this come from
// This is the convex hull for the bezier approximated circle
fprintf( m_workFile, "%g %g m "
"%g %g %g %g %g %g c "
"%g %g %g %g %g %g c "
"%g %g %g %g %g %g c "
"%g %g %g %g %g %g c %c\n",
fprintf( m_workFile,
"%g %g m "
"%g %g %g %g %g %g c "
"%g %g %g %g %g %g c "
"%g %g %g %g %g %g c "
"%g %g %g %g %g %g c %c\n",
pos_dev.x - radius, pos_dev.y,
pos_dev.x - radius, pos_dev.y + magic,
@ -812,6 +814,7 @@ void PDF_PLOTTER::ClosePage()
m_pageStreamHandle = 0;
wxString pageOutlineName = wxEmptyString;
if( m_pageName.IsEmpty() )
{
pageOutlineName = wxString::Format( _( "Page %s" ), m_pageNumbers.back() );
@ -852,7 +855,6 @@ void PDF_PLOTTER::ClosePage()
} );
}
// Clean up
m_hyperlinksInPage.clear();
m_hyperlinkMenusInPage.clear();
@ -866,10 +868,9 @@ bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber )
}
bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber,
const wxString& aPageName )
bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber, const wxString& aPageName )
{
wxASSERT(m_outputFile);
wxASSERT( m_outputFile );
// First things first: the customary null object
m_xrefTable.clear();
@ -879,7 +880,6 @@ bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber,
m_hyperlinkHandles.clear();
m_hyperlinkMenuHandles.clear();
m_bookmarksInPage.clear();
m_outlineRoot.release();
m_totalOutlineNodes = 0;
m_outlineRoot = std::make_unique<OUTLINE_NODE>();
@ -899,7 +899,7 @@ bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber,
/* Now, the PDF is read from the end, (more or less)... so we start
with the page stream for page 1. Other more important stuff is written
at the end */
StartPage(aPageNumber, aPageName);
StartPage( aPageNumber, aPageName );
return true;
}
@ -941,9 +941,9 @@ void PDF_PLOTTER::emitOutlineNode( OUTLINE_NODE* node, int parentHandle, int nex
int prevNode )
{
int nodeHandle = node->entryHandle;
int prevHandle = -1;
int nextHandle = -1;
for( std::vector<OUTLINE_NODE*>::iterator it = node->children.begin();
it != node->children.end(); it++ )
{
@ -961,7 +961,8 @@ void PDF_PLOTTER::emitOutlineNode( OUTLINE_NODE* node, int parentHandle, int nex
prevHandle = ( *it )->entryHandle;
}
if( parentHandle != -1 ) // -1 for parentHandle is the outline root itself which is handed elsewhere
// -1 for parentHandle is the outline root itself which is handed elsewhere.
if( parentHandle != -1 )
{
startPdfObject( nodeHandle );
@ -1039,6 +1040,7 @@ int PDF_PLOTTER::emitOutline()
return -1;
}
bool PDF_PLOTTER::EndPlot()
{
wxASSERT( m_outputFile );
@ -1243,7 +1245,7 @@ bool PDF_PLOTTER::EndPlot()
fprintf( m_outputFile,
"]\n"
"/Count %ld\n"
">>\n", (long) m_pageHandles.size() );
">>\n", (long) m_pageHandles.size() );
closePdfObject();
@ -1256,8 +1258,8 @@ bool PDF_PLOTTER::EndPlot()
if( m_title.IsEmpty() )
{
// Windows uses '\' and other platforms use '/' as separator
m_title = m_filename.AfterLast( '\\');
m_title = m_title.AfterLast( '/');
m_title = m_filename.AfterLast( '\\' );
m_title = m_title.AfterLast( '/' );
}
fprintf( m_outputFile,
@ -1278,6 +1280,7 @@ bool PDF_PLOTTER::EndPlot()
// The catalog, at last
int catalogHandle = startPdfObject();
if( outlineHandle > 0 )
{
fprintf( m_outputFile,
@ -1304,6 +1307,7 @@ bool PDF_PLOTTER::EndPlot()
">>\n",
m_pageTreeHandle );
}
closePdfObject();
/* Emit the xref table (format is crucial to the byte, each entry must
@ -1405,7 +1409,8 @@ void PDF_PLOTTER::HyperlinkMenu( const BOX2I& aBox, const std::vector<wxString>&
}
void PDF_PLOTTER::Bookmark( const BOX2I& aLocation, const wxString& aSymbolReference, const wxString &aGroupName )
void PDF_PLOTTER::Bookmark( const BOX2I& aLocation, const wxString& aSymbolReference,
const wxString &aGroupName )
{
m_bookmarksInPage[aGroupName].push_back( std::make_pair( aLocation, aSymbolReference ) );

View File

@ -256,6 +256,8 @@ void DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable( REPORTER& aReporter )
{
symbol = dynamic_cast<SCH_SYMBOL*>( item );
wxCHECK2( symbol, continue );
if( !remapSymbolToLibTable( symbol ) )
{
msg.Printf( _( "No symbol %s found in symbol library table." ),

View File

@ -92,6 +92,7 @@ void SCH_LEGACY_PLUGIN::init( SCHEMATIC* aSchematic, const PROPERTIES* aProperti
{
m_version = 0;
m_rootSheet = nullptr;
m_currentSheet = nullptr;
m_schematic = aSchematic;
m_cache = nullptr;
m_out = nullptr;
@ -845,6 +846,7 @@ SCH_LINE* SCH_LEGACY_PLUGIN::loadWire( LINE_READER& aReader )
}
int prm_count = ( keyword == T_COLORA ) ? 4 : 3;
// fix opacity to 1.0 or 255, when not exists in file
color[3] = 255;
@ -925,6 +927,7 @@ SCH_BUS_ENTRY_BASE* SCH_LEGACY_PLUGIN::loadBusEntry( LINE_READER& aReader )
return busEntry.release();
}
// clang-format off
const std::map<LABEL_FLAG_SHAPE, const char*> sheetLabelNames
{
@ -1875,14 +1878,16 @@ void SCH_LEGACY_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry )
m_out->Print( 0, "Entry Wire Line\n\t%-4d %-4d %-4d %-4d\n",
schIUScale.IUToMils( aBusEntry->GetPosition().x ),
schIUScale.IUToMils( aBusEntry->GetPosition().y ),
schIUScale.IUToMils( aBusEntry->GetEnd().x ), schIUScale.IUToMils( aBusEntry->GetEnd().y ) );
schIUScale.IUToMils( aBusEntry->GetEnd().x ),
schIUScale.IUToMils( aBusEntry->GetEnd().y ) );
}
else
{
m_out->Print( 0, "Entry Bus Bus\n\t%-4d %-4d %-4d %-4d\n",
schIUScale.IUToMils( aBusEntry->GetPosition().x ),
schIUScale.IUToMils( aBusEntry->GetPosition().y ),
schIUScale.IUToMils( aBusEntry->GetEnd().x ), schIUScale.IUToMils( aBusEntry->GetEnd().y ) );
schIUScale.IUToMils( aBusEntry->GetEnd().x ),
schIUScale.IUToMils( aBusEntry->GetEnd().y ) );
}
}
@ -1920,8 +1925,10 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine )
m_out->Print( 0, "\n" );
m_out->Print( 0, "\t%-4d %-4d %-4d %-4d",
schIUScale.IUToMils( aLine->GetStartPoint().x ), schIUScale.IUToMils( aLine->GetStartPoint().y ),
schIUScale.IUToMils( aLine->GetEndPoint().x ), schIUScale.IUToMils( aLine->GetEndPoint().y ) );
schIUScale.IUToMils( aLine->GetStartPoint().x ),
schIUScale.IUToMils( aLine->GetStartPoint().y ),
schIUScale.IUToMils( aLine->GetEndPoint().x ),
schIUScale.IUToMils( aLine->GetEndPoint().y ) );
m_out->Print( 0, "\n");
}
@ -1977,7 +1984,8 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText )
spinStyle = 0;
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType,
schIUScale.IUToMils( aText->GetPosition().x ), schIUScale.IUToMils( aText->GetPosition().y ),
schIUScale.IUToMils( aText->GetPosition().x ),
schIUScale.IUToMils( aText->GetPosition().y ),
spinStyle,
schIUScale.IUToMils( aText->GetTextWidth() ),
italics, schIUScale.IUToMils( aText->GetTextThickness() ), TO_UTF8( text ) );
@ -1990,7 +1998,8 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText )
wxCHECK_RET( shapeLabelIt != sheetLabelNames.end(), "Shape not found in names list" );
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType,
schIUScale.IUToMils( aText->GetPosition().x ), schIUScale.IUToMils( aText->GetPosition().y ),
schIUScale.IUToMils( aText->GetPosition().x ),
schIUScale.IUToMils( aText->GetPosition().y ),
static_cast<int>( aText->GetTextSpinStyle() ),
schIUScale.IUToMils( aText->GetTextWidth() ),
shapeLabelIt->second,

View File

@ -5,7 +5,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 CERN
* Copyright (C) 2016-2021 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2016-2022 KiCad Developers, see change_log.txt for contributors.
*
* @author Wayne Stambaugh <stambaughw@gmail.com>
*

View File

@ -47,6 +47,7 @@ SCH_VIEW::SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame ) :
VIEW( aIsDynamic )
{
m_frame = aFrame;
// Set m_boundary to define the max working area size. The default value is acceptable for
// Pcbnew and Gerbview, but too large for Eeschema due to very different internal units.
// A full size = 3 * MAX_PAGE_SIZE_MILS size allows a wide margin around the drawing-sheet.
@ -109,6 +110,9 @@ void SCH_VIEW::DisplaySheet( const SCH_SCREEN *aScreen )
if( m_frame && m_frame->IsType( FRAME_SCH ) )
{
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
wxCHECK( editFrame, /* void */ );
wxString sheetName = editFrame->GetCurrentSheet().Last()->GetName();
wxString sheetPath = editFrame->GetCurrentSheet().PathHumanReadable();
m_drawingSheet->SetSheetName( TO_UTF8( sheetName ) );

View File

@ -292,6 +292,9 @@ void SYMBOL_LIBRARY_MANAGER::SetSymbolModified( const wxString& aAlias,
const LIB_BUFFER& buf = libIt->second;
std::shared_ptr<SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER> symbolBuf = buf.GetBuffer( aAlias );
wxCHECK( symbolBuf, /* void */ );
symbolBuf->GetScreen()->SetContentModified();
}

View File

@ -619,6 +619,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
if( line->HasFlag( STARTPOINT ) == line->HasFlag( ENDPOINT ) )
{
line->SetFlags( STARTPOINT | ENDPOINT );
// When we allow off grid items, the rotPoint should be set to the midpoint
// of the line to allow rotation around the center, and the next if
// should become an else-if
@ -1133,7 +1134,8 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
{
static_cast<SCH_SYMBOL*>( newItem )->ClearAnnotation( nullptr, false );
NULL_REPORTER reporter;
m_frame->AnnotateSymbols( ANNOTATE_SELECTION, (ANNOTATE_ORDER_T) annotate.sort_order,
m_frame->AnnotateSymbols( ANNOTATE_SELECTION,
(ANNOTATE_ORDER_T) annotate.sort_order,
(ANNOTATE_ALGO_T) annotate.method, annotate.recursive,
annotateStartNum, false, false, reporter, appendUndo );
}
@ -1368,7 +1370,8 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
if( parentType == SCH_SYMBOL_T && aField->GetId() < MANDATORY_FIELDS )
{
wxString translated_fieldname;
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), DO_TRANSLATE );
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(),
DO_TRANSLATE );
caption.Printf( _( "Edit %s Field" ), TitleCaps( translated_fieldname ) );
}
else if( parentType == SCH_SHEET_T && aField->GetId() < SHEET_MANDATORY_FIELDS )
@ -1929,10 +1932,12 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
bbox.Inflate( -textbox->GetTextMargin() );
if( convertTo == SCH_LABEL_T
|| convertTo == SCH_HIER_LABEL_T
|| convertTo == SCH_GLOBAL_LABEL_T )
|| convertTo == SCH_HIER_LABEL_T
|| convertTo == SCH_GLOBAL_LABEL_T )
{
int textSize = dynamic_cast<EDA_TEXT*>( item )->GetTextSize().y;
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
wxCHECK( text, 0 );
int textSize = text->GetTextSize().y;
bbox.Inflate( item->Schematic()->Settings().m_LabelSizeRatio * textSize );
}
@ -2129,6 +2134,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( item );
EDA_TEXT* new_eda_text = dynamic_cast<EDA_TEXT*>( newtext );
wxCHECK2( eda_text && new_eda_text, continue );
new_eda_text->SetFont( eda_text->GetFont() );
new_eda_text->SetTextSize( eda_text->GetTextSize() );
new_eda_text->SetTextThickness( eda_text->GetTextThickness() );

View File

@ -172,6 +172,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
bool solderMaskDirty = false;
bool autofillZones = false;
wxCHECK( frame && selTool, /* void */ );
std::vector<BOARD_ITEM*> bulkAddedItems;
std::vector<BOARD_ITEM*> bulkRemovedItems;
std::vector<BOARD_ITEM*> itemsChanged;
@ -239,243 +241,245 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
switch( changeType )
{
case CHT_ADD:
case CHT_ADD:
{
if( selTool->GetEnteredGroup() && !boardItem->GetParentGroup() )
selTool->GetEnteredGroup()->AddItem( boardItem );
if( m_isFootprintEditor )
{
if( selTool->GetEnteredGroup() && !boardItem->GetParentGroup() )
selTool->GetEnteredGroup()->AddItem( boardItem );
// footprints inside footprints are not supported yet
wxASSERT( boardItem->Type() != PCB_FOOTPRINT_T );
if( m_isFootprintEditor )
boardItem->SetParent( board->Footprints().front() );
if( !( changeFlags & CHT_DONE ) )
board->Footprints().front()->Add( boardItem );
}
else if( boardItem->Type() == PCB_PAD_T
|| boardItem->Type() == PCB_FP_TEXT_T
|| boardItem->Type() == PCB_FP_TEXTBOX_T
|| boardItem->Type() == PCB_FP_SHAPE_T
|| boardItem->Type() == PCB_FP_DIM_ALIGNED_T
|| boardItem->Type() == PCB_FP_DIM_LEADER_T
|| boardItem->Type() == PCB_FP_DIM_CENTER_T
|| boardItem->Type() == PCB_FP_DIM_RADIAL_T
|| boardItem->Type() == PCB_FP_DIM_ORTHOGONAL_T
|| boardItem->Type() == PCB_FP_ZONE_T )
{
wxASSERT( boardItem->GetParent() &&
boardItem->GetParent()->Type() == PCB_FOOTPRINT_T );
}
else
{
if( !( aCommitFlags & SKIP_UNDO ) )
undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
if( !( changeFlags & CHT_DONE ) )
{
// footprints inside footprints are not supported yet
wxASSERT( boardItem->Type() != PCB_FOOTPRINT_T );
boardItem->SetParent( board->Footprints().front() );
if( !( changeFlags & CHT_DONE ) )
board->Footprints().front()->Add( boardItem );
board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
bulkAddedItems.push_back( boardItem );
}
else if( boardItem->Type() == PCB_PAD_T
|| boardItem->Type() == PCB_FP_TEXT_T
|| boardItem->Type() == PCB_FP_TEXTBOX_T
|| boardItem->Type() == PCB_FP_SHAPE_T
|| boardItem->Type() == PCB_FP_DIM_ALIGNED_T
|| boardItem->Type() == PCB_FP_DIM_LEADER_T
|| boardItem->Type() == PCB_FP_DIM_CENTER_T
|| boardItem->Type() == PCB_FP_DIM_RADIAL_T
|| boardItem->Type() == PCB_FP_DIM_ORTHOGONAL_T
|| boardItem->Type() == PCB_FP_ZONE_T )
{
wxASSERT( boardItem->GetParent() &&
boardItem->GetParent()->Type() == PCB_FOOTPRINT_T );
}
else
{
if( !( aCommitFlags & SKIP_UNDO ) )
undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
if( !( changeFlags & CHT_DONE ) )
{
board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
bulkAddedItems.push_back( boardItem );
}
}
if( autofillZones && boardItem->Type() != PCB_MARKER_T )
dirtyIntersectingZones( boardItem );
if( view && boardItem->Type() != PCB_NETINFO_T )
view->Add( boardItem );
break;
}
case CHT_REMOVE:
if( autofillZones && boardItem->Type() != PCB_MARKER_T )
dirtyIntersectingZones( boardItem );
if( view && boardItem->Type() != PCB_NETINFO_T )
view->Add( boardItem );
break;
}
case CHT_REMOVE:
{
PCB_GROUP* parentGroup = boardItem->GetParentGroup();
if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
if( boardItem->IsSelected() )
{
PCB_GROUP* parentGroup = boardItem->GetParentGroup();
selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
itemsDeselected = true;
}
if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
if( autofillZones )
dirtyIntersectingZones( boardItem );
if( boardItem->IsSelected() )
switch( boardItem->Type() )
{
// Footprint items
case PCB_PAD_T:
case PCB_FP_SHAPE_T:
case PCB_FP_TEXT_T:
case PCB_FP_TEXTBOX_T:
case PCB_FP_DIM_ALIGNED_T:
case PCB_FP_DIM_LEADER_T:
case PCB_FP_DIM_CENTER_T:
case PCB_FP_DIM_RADIAL_T:
case PCB_FP_DIM_ORTHOGONAL_T:
case PCB_FP_ZONE_T:
// This level can only handle footprint children in the footprint editor as
// only in that case has the entire footprint (and all its children) already
// been saved for undo.
wxASSERT( m_isFootprintEditor );
if( boardItem->Type() == PCB_FP_TEXT_T )
{
selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
itemsDeselected = true;
FP_TEXT* text = static_cast<FP_TEXT*>( boardItem );
// don't allow deletion of Reference or Value
if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
break;
}
if( autofillZones )
dirtyIntersectingZones( boardItem );
if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
parentGroup->RemoveItem( boardItem );
switch( boardItem->Type() )
if( view )
view->Remove( boardItem );
if( !( changeFlags & CHT_DONE ) )
{
// Footprint items
case PCB_PAD_T:
case PCB_FP_SHAPE_T:
case PCB_FP_TEXT_T:
case PCB_FP_TEXTBOX_T:
case PCB_FP_DIM_ALIGNED_T:
case PCB_FP_DIM_LEADER_T:
case PCB_FP_DIM_CENTER_T:
case PCB_FP_DIM_RADIAL_T:
case PCB_FP_DIM_ORTHOGONAL_T:
case PCB_FP_ZONE_T:
// This level can only handle footprint children in the footprint editor as
// only in that case has the entire footprint (and all its children) already
// been saved for undo.
wxASSERT( m_isFootprintEditor );
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem->GetParent() );
wxASSERT( footprint && footprint->Type() == PCB_FOOTPRINT_T );
footprint->Delete( boardItem );
}
if( boardItem->Type() == PCB_FP_TEXT_T )
{
FP_TEXT* text = static_cast<FP_TEXT*>( boardItem );
break;
// don't allow deletion of Reference or Value
if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
break;
}
// Board items
case PCB_SHAPE_T: // a shape (normally not on copper layers)
case PCB_BITMAP_T: // a bitmap on a user layer
case PCB_TEXT_T: // a text on a layer
case PCB_TEXTBOX_T: // a wrapped text on a layer
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_ARC_T: // an arced track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like track segment on a copper layer)
case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T: // a leader dimension
case PCB_TARGET_T: // a target (graphic item)
case PCB_MARKER_T: // a marker used to show something
case PCB_ZONE_T:
if( view )
view->Remove( boardItem );
if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
parentGroup->RemoveItem( boardItem );
if( !( changeFlags & CHT_DONE ) )
{
board->Remove( boardItem, REMOVE_MODE::BULK );
bulkRemovedItems.push_back( boardItem );
}
if( view )
view->Remove( boardItem );
break;
if( !( changeFlags & CHT_DONE ) )
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem->GetParent() );
wxASSERT( footprint && footprint->Type() == PCB_FOOTPRINT_T );
footprint->Delete( boardItem );
}
case PCB_FOOTPRINT_T:
{
// No support for nested footprints (yet)
wxASSERT( !m_isFootprintEditor );
break;
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
// Board items
case PCB_SHAPE_T: // a shape (normally not on copper layers)
case PCB_BITMAP_T: // a bitmap on a user layer
case PCB_TEXT_T: // a text on a layer
case PCB_TEXTBOX_T: // a wrapped text on a layer
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_ARC_T: // an arced track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like track segment on a copper layer)
case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T: // a leader dimension
case PCB_TARGET_T: // a target (graphic item)
case PCB_MARKER_T: // a marker used to show something
case PCB_ZONE_T:
if( view )
view->Remove( boardItem );
if( view )
view->Remove( footprint );
if( !( changeFlags & CHT_DONE ) )
footprint->ClearFlags();
if( !( changeFlags & CHT_DONE ) )
{
board->Remove( footprint, REMOVE_MODE::BULK ); // handles connectivity
bulkRemovedItems.push_back( footprint );
}
}
break;
case PCB_GROUP_T:
if( view )
view->Remove( boardItem );
if( !( changeFlags & CHT_DONE ) )
{
if( m_isFootprintEditor )
board->GetFirstFootprint()->Remove( boardItem );
else
{
board->Remove( boardItem, REMOVE_MODE::BULK );
bulkRemovedItems.push_back( boardItem );
}
break;
case PCB_FOOTPRINT_T:
{
// No support for nested footprints (yet)
wxASSERT( !m_isFootprintEditor );
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
if( view )
view->Remove( footprint );
footprint->ClearFlags();
if( !( changeFlags & CHT_DONE ) )
{
board->Remove( footprint, REMOVE_MODE::BULK ); // handles connectivity
bulkRemovedItems.push_back( footprint );
}
}
break;
case PCB_GROUP_T:
if( view )
view->Remove( boardItem );
if( !( changeFlags & CHT_DONE ) )
{
if( m_isFootprintEditor )
board->GetFirstFootprint()->Remove( boardItem );
else
{
board->Remove( boardItem, REMOVE_MODE::BULK );
bulkRemovedItems.push_back( boardItem );
}
}
break;
// Metadata items
case PCB_NETINFO_T:
board->Remove( boardItem, REMOVE_MODE::BULK );
bulkRemovedItems.push_back( boardItem );
break;
default: // other types do not need to (or should not) be handled
wxASSERT( false );
break;
}
break;
}
case CHT_MODIFY:
{
if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
{
ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
wxASSERT( ent.m_copy );
itemWrapper.SetLink( ent.m_copy );
undoList.PushItem( itemWrapper );
}
if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
{
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
if( ent.m_copy )
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
connectivity->Update( boardItem );
}
if( autofillZones )
{
dirtyIntersectingZones( static_cast<BOARD_ITEM*>( ent.m_copy )); // before
dirtyIntersectingZones( boardItem ); // after
}
if( view )
{
view->Update( boardItem );
if( m_isFootprintEditor )
{
static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
view->Update( aChild );
});
}
}
itemsChanged.push_back( boardItem );
// if no undo entry is needed, the copy would create a memory leak
if( aCommitFlags & SKIP_UNDO )
delete ent.m_copy;
// Metadata items
case PCB_NETINFO_T:
board->Remove( boardItem, REMOVE_MODE::BULK );
bulkRemovedItems.push_back( boardItem );
break;
}
default:
default: // other types do not need to (or should not) be handled
wxASSERT( false );
break;
}
break;
}
case CHT_MODIFY:
{
if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
{
ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
wxASSERT( ent.m_copy );
itemWrapper.SetLink( ent.m_copy );
undoList.PushItem( itemWrapper );
}
if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
{
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
if( ent.m_copy )
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
connectivity->Update( boardItem );
}
if( autofillZones )
{
dirtyIntersectingZones( static_cast<BOARD_ITEM*>( ent.m_copy )); // before
dirtyIntersectingZones( boardItem ); // after
}
if( view )
{
view->Update( boardItem );
if( m_isFootprintEditor )
{
static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
view->Update( aChild );
});
}
}
itemsChanged.push_back( boardItem );
// if no undo entry is needed, the copy would create a memory leak
if( aCommitFlags & SKIP_UNDO )
delete ent.m_copy;
break;
}
default:
wxASSERT( false );
break;
}
}

View File

@ -415,6 +415,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
else
m_layerCheckListBox->Check( i, false );
}
break;
case ID_SELECT_COPPER_LAYERS:
@ -423,6 +424,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
if( IsCopperLayer( m_layerList[i] ) )
m_layerCheckListBox->Check( i, true );
}
break;
case ID_DESELECT_COPPER_LAYERS:
@ -431,16 +433,19 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
if( IsCopperLayer( m_layerList[i] ) )
m_layerCheckListBox->Check( i, false );
}
break;
case ID_SELECT_ALL_LAYERS:
for( unsigned i = 0; i < m_layerList.size(); i++ )
m_layerCheckListBox->Check( i, true );
break;
case ID_DESELECT_ALL_LAYERS:
for( unsigned i = 0; i < m_layerList.size(); i++ )
m_layerCheckListBox->Check( i, false );
break;
default:
@ -507,7 +512,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
if( dirDialog.ShowModal() == wxID_CANCEL )
return;
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
wxFileName fn( Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ) );
wxString defaultPath = fn.GetPathWithSep();
@ -885,6 +890,8 @@ void DIALOG_PLOT::applyPlotSettings()
wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
wxCHECK2( layerId, continue );
plotOnAllLayers.set( layerId->GetData() );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -139,6 +139,8 @@ class BASIC_FOOTPRINT_INFO : public FOOTPRINT_INFO
public:
BASIC_FOOTPRINT_INFO( FOOTPRINT* aFootprint )
{
wxASSERT( aFootprint );
m_nickname = aFootprint->GetFPID().GetLibNickname().wx_str();
m_fpname = aFootprint->GetFPID().GetLibItemName().wx_str();
m_pad_count = aFootprint->GetPadCount( DO_NOT_INCLUDE_NPTH );

View File

@ -3063,6 +3063,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
track->SetEnd( *joint1 );
PCB_TRACK* newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( *joint1 );
@ -3070,6 +3071,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
aCommit.Add( newTrack );
newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( viaPos );
@ -3077,6 +3079,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
aCommit.Add( newTrack );
newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( *joint2 );