PCB: add ratsnest to search pane
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/15338
This commit is contained in:
parent
1efd75ca79
commit
3cd25f0045
|
@ -2165,6 +2165,12 @@ void BOARD::OnItemsChanged( std::vector<BOARD_ITEM*>& aItems )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BOARD::OnRatsnestChanged()
|
||||||
|
{
|
||||||
|
InvokeListeners( &BOARD_LISTENER::OnBoardRatsnestChanged, *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BOARD::ResetNetHighLight()
|
void BOARD::ResetNetHighLight()
|
||||||
{
|
{
|
||||||
m_highLight.Clear();
|
m_highLight.Clear();
|
||||||
|
|
|
@ -250,6 +250,7 @@ public:
|
||||||
virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
|
virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
|
||||||
virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
|
virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
|
||||||
virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
|
virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
|
||||||
|
virtual void OnBoardRatsnestChanged( BOARD& aBoard ) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1137,6 +1138,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
|
void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the board and its listeners that the ratsnest has been recomputed.
|
||||||
|
*/
|
||||||
|
void OnRatsnestChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consistency check of internal m_groups structure.
|
* Consistency check of internal m_groups structure.
|
||||||
*
|
*
|
||||||
|
|
|
@ -454,6 +454,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
||||||
|
|
||||||
if( frame )
|
if( frame )
|
||||||
frame->GetCanvas()->RedrawRatsnest();
|
frame->GetCanvas()->RedrawRatsnest();
|
||||||
|
|
||||||
|
board->OnRatsnestChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( solderMaskDirty )
|
if( solderMaskDirty )
|
||||||
|
@ -665,6 +667,7 @@ void BOARD_COMMIT::Revert()
|
||||||
{
|
{
|
||||||
connectivity->RecalculateRatsnest();
|
connectivity->RecalculateRatsnest();
|
||||||
board->UpdateRatsnestExclusions();
|
board->UpdateRatsnestExclusions();
|
||||||
|
board->OnRatsnestChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
||||||
|
|
|
@ -36,6 +36,7 @@ void PCB_BASE_FRAME::Compile_Ratsnest( bool aDisplayStatus )
|
||||||
{
|
{
|
||||||
GetBoard()->GetConnectivity()->RecalculateRatsnest();
|
GetBoard()->GetConnectivity()->RecalculateRatsnest();
|
||||||
GetBoard()->UpdateRatsnestExclusions();
|
GetBoard()->UpdateRatsnestExclusions();
|
||||||
|
GetBoard()->OnRatsnestChanged();
|
||||||
|
|
||||||
if( aDisplayStatus )
|
if( aDisplayStatus )
|
||||||
SetMsgPanel( m_pcb );
|
SetMsgPanel( m_pcb );
|
||||||
|
|
|
@ -45,6 +45,7 @@ PCB_SEARCH_PANE::PCB_SEARCH_PANE( PCB_EDIT_FRAME* aFrame ) :
|
||||||
AddSearcher( new FOOTPRINT_SEARCH_HANDLER( aFrame ) );
|
AddSearcher( new FOOTPRINT_SEARCH_HANDLER( aFrame ) );
|
||||||
AddSearcher( new ZONE_SEARCH_HANDLER( aFrame ) );
|
AddSearcher( new ZONE_SEARCH_HANDLER( aFrame ) );
|
||||||
AddSearcher( new NETS_SEARCH_HANDLER( aFrame ) );
|
AddSearcher( new NETS_SEARCH_HANDLER( aFrame ) );
|
||||||
|
AddSearcher( new RATSNEST_SEARCH_HANDLER( aFrame ) );
|
||||||
AddSearcher( new TEXT_SEARCH_HANDLER( aFrame ) );
|
AddSearcher( new TEXT_SEARCH_HANDLER( aFrame ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,3 +143,12 @@ void PCB_SEARCH_PANE::OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM
|
||||||
void PCB_SEARCH_PANE::OnBoardHighlightNetChanged( BOARD& aBoard )
|
void PCB_SEARCH_PANE::OnBoardHighlightNetChanged( BOARD& aBoard )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardRatsnestChanged( BOARD& aBoard )
|
||||||
|
{
|
||||||
|
if( !IsShown() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
virtual void OnBoardItemsChanged( BOARD& aBoard,
|
virtual void OnBoardItemsChanged( BOARD& aBoard,
|
||||||
std::vector<BOARD_ITEM*>& aBoardItems ) override;
|
std::vector<BOARD_ITEM*>& aBoardItems ) override;
|
||||||
virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) override;
|
virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) override;
|
||||||
|
virtual void OnBoardRatsnestChanged( BOARD& aBoard ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onUnitsChanged( wxCommandEvent& event );
|
void onUnitsChanged( wxCommandEvent& event );
|
||||||
|
@ -50,4 +51,4 @@ private:
|
||||||
BOARD* m_brd;
|
BOARD* m_brd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include <pcb_painter.h>
|
#include <pcb_painter.h>
|
||||||
#include <pcb_textbox.h>
|
#include <pcb_textbox.h>
|
||||||
#include <pcb_text.h>
|
#include <pcb_text.h>
|
||||||
|
#include <connectivity/connectivity_data.h>
|
||||||
|
#include <ratsnest/ratsnest_data.h>
|
||||||
#include <string_utils.h>
|
#include <string_utils.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
|
@ -333,3 +335,87 @@ void NETS_SEARCH_HANDLER::ActivateItem( long aItemRow )
|
||||||
{
|
{
|
||||||
m_frame->ShowBoardSetupDialog( _( "Net Classes" ) );
|
m_frame->ShowBoardSetupDialog( _( "Net Classes" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RATSNEST_SEARCH_HANDLER::RATSNEST_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
PCB_SEARCH_HANDLER( wxT( "Ratsnest" ), aFrame )
|
||||||
|
{
|
||||||
|
m_columns.emplace_back( wxT( "Name" ), 2 );
|
||||||
|
m_columns.emplace_back( wxT( "Class" ), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RATSNEST_SEARCH_HANDLER::Search( const wxString& aQuery )
|
||||||
|
{
|
||||||
|
m_hitlist.clear();
|
||||||
|
|
||||||
|
EDA_SEARCH_DATA frp;
|
||||||
|
frp.findString = aQuery;
|
||||||
|
|
||||||
|
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
|
||||||
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
|
||||||
|
|
||||||
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
for( NETINFO_ITEM* net : board->GetNetInfo() )
|
||||||
|
{
|
||||||
|
if( net == nullptr || !net->Matches( frp, nullptr ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RN_NET* rn = board->GetConnectivity()->GetRatsnestForNet( net->GetNetCode() );
|
||||||
|
|
||||||
|
if( rn && !rn->GetEdges().empty() )
|
||||||
|
m_hitlist.push_back( net );
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) m_hitlist.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString RATSNEST_SEARCH_HANDLER::getResultCell( BOARD_ITEM* aItem, int aCol )
|
||||||
|
{
|
||||||
|
NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( aItem );
|
||||||
|
|
||||||
|
if( net->GetNetCode() == 0 )
|
||||||
|
{
|
||||||
|
if( aCol == 0 )
|
||||||
|
return _( "No Net" );
|
||||||
|
else if( aCol == 1 )
|
||||||
|
return wxT( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aCol == 0 )
|
||||||
|
return UnescapeString( net->GetNetname() );
|
||||||
|
else if( aCol == 1 )
|
||||||
|
return net->GetNetClass()->GetName();
|
||||||
|
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RATSNEST_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
||||||
|
{
|
||||||
|
RENDER_SETTINGS* ps = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();
|
||||||
|
ps->SetHighlight( false );
|
||||||
|
|
||||||
|
std::vector<NETINFO_ITEM*> selectedItems;
|
||||||
|
|
||||||
|
for( long row : aItemRows )
|
||||||
|
{
|
||||||
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
||||||
|
{
|
||||||
|
NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( m_hitlist[row] );
|
||||||
|
|
||||||
|
ps->SetHighlight( true, net->GetNetCode(), true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||||
|
m_frame->GetCanvas()->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RATSNEST_SEARCH_HANDLER::ActivateItem( long aItemRow )
|
||||||
|
{
|
||||||
|
m_frame->ShowBoardSetupDialog( _( "Net Classes" ) );
|
||||||
|
}
|
||||||
|
|
|
@ -105,4 +105,18 @@ private:
|
||||||
wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
|
wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class RATSNEST_SEARCH_HANDLER : public PCB_SEARCH_HANDLER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RATSNEST_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame );
|
||||||
|
|
||||||
|
int Search( const wxString& aQuery ) override;
|
||||||
|
void SelectItems( std::vector<long>& aItemRows ) override;
|
||||||
|
void ActivateItem( long aItemRow ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue