diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 4609a60dab..0c1561c90a 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -84,6 +84,7 @@ const std::initializer_list GENERAL_COLLECTOR::BoardLevelItems = { const std::initializer_list GENERAL_COLLECTOR::FootprintItems = { + PCB_MARKER_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_SHAPE_T, diff --git a/pcbnew/dialogs/dialog_footprint_checker.cpp b/pcbnew/dialogs/dialog_footprint_checker.cpp index a4aca38a8d..3c2c424235 100644 --- a/pcbnew/dialogs/dialog_footprint_checker.cpp +++ b/pcbnew/dialogs/dialog_footprint_checker.cpp @@ -39,6 +39,7 @@ DIALOG_FOOTPRINT_CHECKER::DIALOG_FOOTPRINT_CHECKER( FOOTPRINT_EDIT_FRAME* aParen m_frame( aParent ), m_checksRun( false ), m_markersProvider( nullptr ), + m_centerMarkerOnIdle( nullptr ), m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ) { m_markersTreeModel = new RC_TREE_MODEL( m_frame, m_markersDataView ); @@ -179,6 +180,25 @@ void DIALOG_FOOTPRINT_CHECKER::SetMarkersProvider( RC_ITEMS_PROVIDER* aProvider } +void DIALOG_FOOTPRINT_CHECKER::SelectMarker( const PCB_MARKER* aMarker ) +{ + m_markersTreeModel->SelectMarker( aMarker ); + + // wxWidgets on some platforms fails to correctly ensure that a selected item is + // visible, so we have to do it in a separate idle event. + m_centerMarkerOnIdle = aMarker; + Bind( wxEVT_IDLE, &DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler, this ); +} + + +void DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler( wxIdleEvent& aEvent ) +{ + m_markersTreeModel->CenterMarker( m_centerMarkerOnIdle ); + m_centerMarkerOnIdle = nullptr; + Unbind( wxEVT_IDLE, &DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler, this ); +} + + void DIALOG_FOOTPRINT_CHECKER::OnRunChecksClick( wxCommandEvent& aEvent ) { m_checksRun = false; @@ -194,6 +214,15 @@ void DIALOG_FOOTPRINT_CHECKER::OnSelectItem( wxDataViewEvent& aEvent ) const KIID& itemID = node ? RC_TREE_MODEL::ToUUID( aEvent.GetItem() ) : niluuid; BOARD_ITEM* item = board->GetItem( itemID ); + if( m_centerMarkerOnIdle ) + { + // we already came from a cross-probe of the marker in the document; don't go + // around in circles + + aEvent.Skip(); + return; + } + if( node && item ) { PCB_LAYER_ID principalLayer = UNDEFINED_LAYER; diff --git a/pcbnew/dialogs/dialog_footprint_checker.h b/pcbnew/dialogs/dialog_footprint_checker.h index e9743fdd56..02a5a7563c 100644 --- a/pcbnew/dialogs/dialog_footprint_checker.h +++ b/pcbnew/dialogs/dialog_footprint_checker.h @@ -29,6 +29,7 @@ #include class FOOTPRINT_EDIT_FRAME; +class PCB_MARKER; class DIALOG_FOOTPRINT_CHECKER: public DIALOG_FOOTPRINT_CHECKER_BASE @@ -39,12 +40,16 @@ public: void SetMarkersProvider( RC_ITEMS_PROVIDER* aProvider ); + void SelectMarker( const PCB_MARKER* aMarker ); + private: void syncCheckboxes(); void updateDisplayedCounts(); void runChecks(); + void centerMarkerIdleHandler( wxIdleEvent& aEvent ); + void deleteAllMarkers(); void refreshEditor(); @@ -69,6 +74,8 @@ private: RC_TREE_MODEL* m_markersTreeModel; RC_ITEMS_PROVIDER* m_markersProvider; + const PCB_MARKER* m_centerMarkerOnIdle; + int m_severities; }; diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index e2100a3cc1..7c403b2478 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -254,6 +255,10 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) m_toolManager->RunAction( PCB_ACTIONS::groupProperties, true, aItem ); break; + case PCB_MARKER_T: + m_toolManager->GetTool()->CrossProbe( static_cast( aItem ) ); + break; + default: wxFAIL_MSG( wxT( "FOOTPRINT_EDIT_FRAME::OnEditItemRequest: unsupported item type " ) + aItem->GetClass() ); diff --git a/pcbnew/tools/footprint_editor_control.cpp b/pcbnew/tools/footprint_editor_control.cpp index 2fa605ffcb..6cbea1989f 100644 --- a/pcbnew/tools/footprint_editor_control.cpp +++ b/pcbnew/tools/footprint_editor_control.cpp @@ -653,10 +653,23 @@ int FOOTPRINT_EDITOR_CONTROL::CheckFootprint( const TOOL_EVENT& aEvent ) m_checkerDialog->Show( true ); } + return 0; } +void FOOTPRINT_EDITOR_CONTROL::CrossProbe( const PCB_MARKER* aMarker ) +{ + if( !m_checkerDialog ) + m_checkerDialog = new DIALOG_FOOTPRINT_CHECKER( m_frame ); + + if( !m_checkerDialog->IsShown() ) + m_checkerDialog->Show( true ); + + m_checkerDialog->SelectMarker( aMarker ); +} + + void FOOTPRINT_EDITOR_CONTROL::DestroyCheckerDialog() { if( m_checkerDialog ) diff --git a/pcbnew/tools/footprint_editor_control.h b/pcbnew/tools/footprint_editor_control.h index 87b0022057..05fb7a919b 100644 --- a/pcbnew/tools/footprint_editor_control.h +++ b/pcbnew/tools/footprint_editor_control.h @@ -73,6 +73,7 @@ public: int EditTextAndGraphics( const TOOL_EVENT& aEvent ); int CheckFootprint( const TOOL_EVENT& aEvent ); + void CrossProbe( const PCB_MARKER* aMarker ); void DestroyCheckerDialog(); int CleanupGraphics( const TOOL_EVENT& aEvent );