Browse Source

ADDED: DRC item context menu "fix" actions.

Active for the following errors:
DRCE_LIB_FOOTPRINT_ISSUES
DRCE_LIB_FOOTPRINT_MISMATCH
DRCE_FOOTPRINT_FILTERS
DRCE_SCHEMATIC_PARITY
DRCE_MISSING_FOOTPRINT
DRCE_DUPLICATE_FOOTPRINT
DRCE_EXTRA_FOOTPRINT
DRCE_FOOTPRINT_TYPE_MISMATCH
DRCE_FOOTPRINT
DRCE_PADSTACK
DRCE_PADSTACK_INVALID
DRCE_TEXT_HEIGHT
DRCE_TEXT_THICKNESS
DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
DRCE_NONMIRRORED_TEXT_ON_BACK_LAYER
DRCE_DANGLING_TRACK
DRCE_DANGLING_VIA

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21646
master
Jeff Young 2 weeks ago
parent
commit
de1491256f
  1. 28
      common/eda_base_frame.cpp
  2. 2
      include/eda_base_frame.h
  3. 21
      pcbnew/dialogs/dialog_drc.cpp
  4. 44
      pcbnew/tools/board_inspection_tool.cpp
  5. 103
      pcbnew/tools/drc_tool.cpp
  6. 3
      pcbnew/tools/drc_tool.h

28
common/eda_base_frame.cpp

@ -661,6 +661,34 @@ void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
}
wxString EDA_BASE_FRAME::GetRunMenuCommandDescription( const TOOL_ACTION& aAction )
{
wxString menuItemLabel = aAction.GetMenuLabel();
wxMenuBar* menuBar = GetMenuBar();
for( size_t ii = 0; ii < menuBar->GetMenuCount(); ++ii )
{
for( wxMenuItem* menuItem : menuBar->GetMenu( ii )->GetMenuItems() )
{
if( menuItem->GetItemLabelText() == menuItemLabel )
{
wxString menuTitleLabel = menuBar->GetMenuLabelText( ii );
menuTitleLabel.Replace( wxS( "&" ), wxS( "&&" ) );
menuItemLabel.Replace( wxS( "&" ), wxS( "&&" ) );
return wxString::Format( _( "Run: %s > %s" ),
menuTitleLabel,
menuItemLabel );
}
}
}
return wxString::Format( _( "Run %s" ), aAction.GetFriendlyName() );
};
void EDA_BASE_FRAME::ShowChangedLanguage()
{
TOOLS_HOLDER::ShowChangedLanguage();

2
include/eda_base_frame.h

@ -484,6 +484,8 @@ public:
*/
void AddStandardHelpMenu( wxMenuBar* aMenuBar );
wxString GetRunMenuCommandDescription( const TOOL_ACTION& aAction );
/**
* Check if \a aFileName can be written.
*

21
pcbnew/dialogs/dialog_drc.cpp

@ -709,6 +709,7 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
{
TOOL_MANAGER* toolMgr = m_frame->GetToolManager();
BOARD_INSPECTION_TOOL* inspectionTool = toolMgr->GetTool<BOARD_INSPECTION_TOOL>();
DRC_TOOL* drcTool = toolMgr->GetTool<DRC_TOOL>();
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
if( !node )
@ -736,6 +737,7 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
ID_ADD_EXCLUSION_WITH_COMMENT,
ID_ADD_EXCLUSION_ALL,
ID_INSPECT_VIOLATION,
ID_FIX_VIOLATION,
ID_SET_SEVERITY_TO_ERROR,
ID_SET_SEVERITY_TO_WARNING,
ID_SET_SEVERITY_TO_IGNORE,
@ -778,12 +780,21 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
}
}
menu.AppendSeparator();
wxString inspectDRCErrorMenuText = inspectionTool->InspectDRCErrorMenuText( rcItem );
wxString fixDRCErrorMenuText = drcTool->FixDRCErrorMenuText( rcItem );
if( !inspectDRCErrorMenuText.IsEmpty() )
menu.Append( ID_INSPECT_VIOLATION, inspectDRCErrorMenuText );
if( !inspectDRCErrorMenuText.IsEmpty() || !fixDRCErrorMenuText.IsEmpty() )
{
if( !inspectDRCErrorMenuText.IsEmpty() )
menu.Append( ID_INSPECT_VIOLATION, inspectDRCErrorMenuText );
menu.AppendSeparator();
if( !fixDRCErrorMenuText.IsEmpty() )
menu.Append( ID_FIX_VIOLATION, fixDRCErrorMenuText );
menu.AppendSeparator();
}
if( bds().m_DRCSeverities[ rcItem->GetErrorCode() ] == RPT_SEVERITY_WARNING )
{
@ -948,6 +959,10 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
inspectionTool->InspectDRCError( node->m_RcItem );
break;
case ID_FIX_VIOLATION:
drcTool->FixDRCError( node->m_RcItem );
break;
case ID_SET_SEVERITY_TO_ERROR:
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR;

44
pcbnew/tools/board_inspection_tool.cpp

@ -274,40 +274,13 @@ wxString reportMax( PCB_BASE_FRAME* aFrame, DRC_CONSTRAINT& aConstraint )
wxString BOARD_INSPECTION_TOOL::InspectDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem )
{
auto menuDescription =
[&]( const TOOL_ACTION& aAction )
{
wxString menuItemLabel = aAction.GetMenuLabel();
wxMenuBar* menuBar = m_frame->GetMenuBar();
for( size_t ii = 0; ii < menuBar->GetMenuCount(); ++ii )
{
for( wxMenuItem* menuItem : menuBar->GetMenu( ii )->GetMenuItems() )
{
if( menuItem->GetItemLabelText() == menuItemLabel )
{
wxString menuTitleLabel = menuBar->GetMenuLabelText( ii );
menuTitleLabel.Replace( wxS( "&" ), wxS( "&&" ) );
menuItemLabel.Replace( wxS( "&" ), wxS( "&&" ) );
return wxString::Format( _( "Run %s > %s" ),
menuTitleLabel,
menuItemLabel );
}
}
}
return wxString::Format( _( "Run %s" ), aAction.GetFriendlyName() );
};
if( aDRCItem->GetErrorCode() == DRCE_CLEARANCE
|| aDRCItem->GetErrorCode() == DRCE_EDGE_CLEARANCE
|| aDRCItem->GetErrorCode() == DRCE_HOLE_CLEARANCE
|| aDRCItem->GetErrorCode() == DRCE_DRILLED_HOLES_TOO_CLOSE
|| aDRCItem->GetErrorCode() == DRCE_STARVED_THERMAL )
{
return menuDescription( PCB_ACTIONS::inspectClearance );
return m_frame->GetRunMenuCommandDescription( PCB_ACTIONS::inspectClearance );
}
else if( aDRCItem->GetErrorCode() == DRCE_TEXT_HEIGHT
|| aDRCItem->GetErrorCode() == DRCE_TEXT_THICKNESS
@ -322,16 +295,11 @@ wxString BOARD_INSPECTION_TOOL::InspectDRCErrorMenuText( const std::shared_ptr<R
|| aDRCItem->GetErrorCode() == DRCE_CONNECTION_WIDTH
|| aDRCItem->GetErrorCode() == DRCE_ASSERTION_FAILURE )
{
return menuDescription( PCB_ACTIONS::inspectConstraints );
return m_frame->GetRunMenuCommandDescription( PCB_ACTIONS::inspectConstraints );
}
else if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH )
{
return menuDescription( PCB_ACTIONS::diffFootprint );
}
else if( aDRCItem->GetErrorCode() == DRCE_DANGLING_TRACK
|| aDRCItem->GetErrorCode() == DRCE_DANGLING_VIA )
{
return menuDescription( PCB_ACTIONS::cleanupTracksAndVias );
return m_frame->GetRunMenuCommandDescription( PCB_ACTIONS::diffFootprint );
}
return wxEmptyString;
@ -357,12 +325,6 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
return;
}
else if( aDRCItem->GetErrorCode() == DRCE_DANGLING_TRACK
|| aDRCItem->GetErrorCode() == DRCE_DANGLING_VIA )
{
m_toolMgr->RunAction( PCB_ACTIONS::cleanupTracksAndVias );
return;
}
DIALOG_BOOK_REPORTER* dialog = m_frame->GetInspectDrcErrorDialog();
wxCHECK( dialog, /* void */ );

103
pcbnew/tools/drc_tool.cpp

@ -37,6 +37,7 @@
#include <drc/drc_item.h>
#include <netlist_reader/pcb_netlist.h>
#include <macros.h>
#include <dialog_exchange_footprints.h>
DRC_TOOL::DRC_TOOL() :
PCB_TOOL_BASE( "pcbnew.DRCTool" ),
@ -284,6 +285,108 @@ int DRC_TOOL::ExcludeMarker( const TOOL_EVENT& aEvent )
}
wxString DRC_TOOL::FixDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem )
{
if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_ISSUES )
{
return frame()->GetRunMenuCommandDescription( PCB_ACTIONS::showFootprintLibTable );
}
else if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH )
{
return frame()->GetRunMenuCommandDescription( PCB_ACTIONS::updateFootprint );
}
else if( aDRCItem->GetErrorCode() == DRCE_FOOTPRINT_FILTERS )
{
return frame()->GetRunMenuCommandDescription( PCB_ACTIONS::changeFootprint );
}
else if( aDRCItem->GetErrorCode() == DRCE_SCHEMATIC_PARITY
|| aDRCItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT
|| aDRCItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT
|| aDRCItem->GetErrorCode() == DRCE_EXTRA_FOOTPRINT )
{
return frame()->GetRunMenuCommandDescription( PCB_ACTIONS::updatePcbFromSchematic );
}
else if( aDRCItem->GetErrorCode() == DRCE_FOOTPRINT_TYPE_MISMATCH
|| aDRCItem->GetErrorCode() == DRCE_FOOTPRINT )
{
return _( "Edit Footprint Properties..." );
}
else if( aDRCItem->GetErrorCode() == DRCE_PADSTACK
|| aDRCItem->GetErrorCode() == DRCE_PADSTACK_INVALID )
{
return _( "Edit Pad Properties..." );
}
else if( aDRCItem->GetErrorCode() == DRCE_TEXT_HEIGHT
|| aDRCItem->GetErrorCode() == DRCE_TEXT_THICKNESS
|| aDRCItem->GetErrorCode() == DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
|| aDRCItem->GetErrorCode() == DRCE_NONMIRRORED_TEXT_ON_BACK_LAYER )
{
BOARD_ITEM* item = m_pcb->ResolveItem( aDRCItem->GetMainItemID() );
if( item && BaseType( item->Type() ) == PCB_DIMENSION_T )
return _( "Edit Dimension Properties..." );
else if( item && item->Type() == PCB_FIELD_T )
return _( "Edit Field Properties..." );
else
return _( "Edit Text Properties..." );
}
else if( aDRCItem->GetErrorCode() == DRCE_DANGLING_TRACK
|| aDRCItem->GetErrorCode() == DRCE_DANGLING_VIA )
{
return frame()->GetRunMenuCommandDescription( PCB_ACTIONS::cleanupTracksAndVias );
}
return wxEmptyString;
}
void DRC_TOOL::FixDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem )
{
if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_ISSUES )
{
m_toolMgr->RunAction( PCB_ACTIONS::showFootprintLibTable );
}
else if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH
|| aDRCItem->GetErrorCode() == DRCE_FOOTPRINT_FILTERS )
{
bool updateMode = aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH;
BOARD_ITEM* item = m_pcb->ResolveItem( aDRCItem->GetMainItemID() );
if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item ) )
{
DIALOG_EXCHANGE_FOOTPRINTS dialog( m_editFrame, footprint, updateMode, true );
dialog.ShowQuasiModal();
}
}
else if( aDRCItem->GetErrorCode() == DRCE_SCHEMATIC_PARITY
|| aDRCItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT
|| aDRCItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT
|| aDRCItem->GetErrorCode() == DRCE_EXTRA_FOOTPRINT )
{
m_toolMgr->RunAction( PCB_ACTIONS::updatePcbFromSchematic );
}
else if( aDRCItem->GetErrorCode() == DRCE_FOOTPRINT_TYPE_MISMATCH
|| aDRCItem->GetErrorCode() == DRCE_FOOTPRINT
|| aDRCItem->GetErrorCode() == DRCE_PADSTACK
|| aDRCItem->GetErrorCode() == DRCE_PADSTACK_INVALID
|| aDRCItem->GetErrorCode() == DRCE_TEXT_HEIGHT
|| aDRCItem->GetErrorCode() == DRCE_TEXT_THICKNESS
|| aDRCItem->GetErrorCode() == DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
|| aDRCItem->GetErrorCode() == DRCE_NONMIRRORED_TEXT_ON_BACK_LAYER)
{
BOARD_ITEM* item = m_pcb->ResolveItem( aDRCItem->GetMainItemID() );
m_editFrame->OnEditItemRequest( item );
}
else if( aDRCItem->GetErrorCode() == DRCE_DANGLING_TRACK
|| aDRCItem->GetErrorCode() == DRCE_DANGLING_VIA )
{
m_toolMgr->RunAction( PCB_ACTIONS::cleanupTracksAndVias );
}
}
void DRC_TOOL::setTransitions()
{
Go( &DRC_TOOL::ShowDRCDialog, PCB_ACTIONS::runDRC.MakeEvent() );

3
pcbnew/tools/drc_tool.h

@ -97,6 +97,9 @@ public:
int ExcludeMarker( const TOOL_EVENT& aEvent );
wxString FixDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem );
void FixDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem );
private:
///< Set up handlers for various events.
void setTransitions() override;

Loading…
Cancel
Save