diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 328e6c4186..4d53f4e061 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -675,15 +675,22 @@ void DIALOG_ERC::NextMarker() } -void DIALOG_ERC::ExcludeMarker() +void DIALOG_ERC::ExcludeMarker( SCH_MARKER* aMarker ) { + SCH_MARKER* marker = aMarker; + + if( marker != nullptr ) + m_markerTreeModel->SelectMarker( marker ); + if( m_notebook->GetSelection() != 1 ) return; RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( m_markerDataView->GetCurrentItem() ); - SCH_MARKER* marker = dynamic_cast( node->m_RcItem->GetParent() ); - if( marker && !marker->IsExcluded() ) + if( node && node->m_RcItem ) + marker = dynamic_cast( node->m_RcItem->GetParent() ); + + if( node && marker && !marker->IsExcluded() ) { marker->SetExcluded( true ); m_parent->GetCanvas()->GetView()->Update( marker ); diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h index f3735c7c34..83711a9431 100644 --- a/eeschema/dialogs/dialog_erc.h +++ b/eeschema/dialogs/dialog_erc.h @@ -37,6 +37,9 @@ #define DIALOG_ERC_WINDOW_NAME "DialogErcWindowName" +class SCH_MARKER; + + class DIALOG_ERC : public DIALOG_ERC_BASE, PROGRESS_REPORTER_BASE { public: @@ -50,7 +53,14 @@ public: void PrevMarker(); void NextMarker(); - void ExcludeMarker(); + + /** + * Exclude aMarker from the ERC list. If aMarker is nullptr, exclude the selected marker + * in this dialog. + * + * @param aMarker aMarker to exclude + */ + void ExcludeMarker( SCH_MARKER* aMarker = nullptr ); void UpdateAnnotationWarning(); diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 3a84457c3b..2e64addd3a 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -70,14 +70,11 @@ bool EE_INSPECTION_TOOL::Init() { EE_TOOL_BASE::Init(); - auto singleMarkerCondition = SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T ) - && SELECTION_CONDITIONS::Count( 1 ); - // Add inspection actions to the selection tool menu // CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu(); - selToolMenu.AddItem( EE_ACTIONS::excludeMarker, singleMarkerCondition, 100 ); + selToolMenu.AddItem( EE_ACTIONS::excludeMarker, EE_CONDITIONS::SingleNonExcludedMarker, 100 ); selToolMenu.AddItem( EE_ACTIONS::showDatasheet, EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 220 ); @@ -171,25 +168,26 @@ int EE_INSPECTION_TOOL::NextMarker( const TOOL_EVENT& aEvent ) int EE_INSPECTION_TOOL::ExcludeMarker( const TOOL_EVENT& aEvent ) { + EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + EE_SELECTION& selection = selTool->GetSelection(); + SCH_MARKER* marker = nullptr; + + if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_MARKER_T ) + marker = static_cast( selection.Front() ); + if( m_ercDialog ) { // Let the ERC dialog handle it since it has more update hassles to worry about - m_ercDialog->ExcludeMarker(); + // Note that if marker is nullptr the dialog will exclude whichever marker is selected + // in the dialog itself + m_ercDialog->ExcludeMarker( marker ); } - else + else if( marker != nullptr ) { - EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); - EE_SELECTION& selection = selTool->GetSelection(); - - if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_MARKER_T ) - { - SCH_MARKER* marker = static_cast( selection.Front() ); - - marker->SetExcluded( true ); - m_frame->GetCanvas()->GetView()->Update( marker ); - m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); - } + marker->SetExcluded( true ); + m_frame->GetCanvas()->GetView()->Update( marker ); + m_frame->GetCanvas()->Refresh(); + m_frame->OnModify(); } return 0; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 8138252c7d..c74adac4e5 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +108,15 @@ SELECTION_CONDITION EE_CONDITIONS::SingleMultiUnitSymbol = []( const SELECTION& }; +SELECTION_CONDITION EE_CONDITIONS::SingleNonExcludedMarker = []( const SELECTION& aSel ) +{ + if( aSel.CountType( SCH_MARKER_T ) != 1 ) + return false; + + return !static_cast( aSel.Front() )->IsExcluded(); +}; + + #define HITTEST_THRESHOLD_PIXELS 5 diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index 03e8d50e47..357da82b52 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -49,6 +49,7 @@ public: static SELECTION_CONDITION SingleSymbolOrPower; static SELECTION_CONDITION SingleDeMorganSymbol; static SELECTION_CONDITION SingleMultiUnitSymbol; + static SELECTION_CONDITION SingleNonExcludedMarker; };