2022-09-14 02:59:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-11-11 15:29:34 +00:00
|
|
|
* Copyright (C) 2023 CERN
|
2023-06-10 13:49:37 +00:00
|
|
|
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-09-14 02:59:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <footprint.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcb_marker.h>
|
2022-11-21 23:47:08 +00:00
|
|
|
#include <pcb_painter.h>
|
2022-09-20 22:22:17 +00:00
|
|
|
#include <pcb_textbox.h>
|
2022-09-14 02:59:57 +00:00
|
|
|
#include <pcb_text.h>
|
2023-12-28 21:09:43 +00:00
|
|
|
#include <pcb_dimension.h>
|
2023-08-17 14:24:59 +00:00
|
|
|
#include <ratsnest/ratsnest_data.h>
|
2022-11-21 23:47:08 +00:00
|
|
|
#include <string_utils.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2022-09-14 02:59:57 +00:00
|
|
|
#include <zone.h>
|
|
|
|
#include "search_handlers.h"
|
|
|
|
|
|
|
|
|
2023-01-25 16:12:13 +00:00
|
|
|
void PCB_SEARCH_HANDLER::ActivateItem( long aItemRow )
|
|
|
|
{
|
|
|
|
std::vector<long> item = { aItemRow };
|
|
|
|
SelectItems( item );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::properties );
|
2023-01-25 16:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-09 17:30:58 +00:00
|
|
|
void PCB_SEARCH_HANDLER::Sort( int aCol, bool aAscending )
|
|
|
|
{
|
|
|
|
std::sort( m_hitlist.begin(), m_hitlist.end(),
|
|
|
|
[&]( BOARD_ITEM* a, BOARD_ITEM* b ) -> bool
|
|
|
|
{
|
|
|
|
// N.B. To meet the iterator sort conditions, we cannot simply invert the truth
|
|
|
|
// to get the opposite sort. i.e. ~(a<b) != (a>b)
|
|
|
|
if( aAscending )
|
|
|
|
return StrNumCmp( getResultCell( a, aCol ), getResultCell( b, aCol ), true ) < 0;
|
|
|
|
else
|
|
|
|
return StrNumCmp( getResultCell( b, aCol ), getResultCell( a, aCol ), true ) < 0;
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
|
|
|
{
|
|
|
|
std::vector<EDA_ITEM*> selectedItems;
|
|
|
|
|
|
|
|
for( long row : aItemRows )
|
|
|
|
{
|
|
|
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
|
|
|
selectedItems.push_back( m_hitlist[row] );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
|
|
|
|
|
|
|
if( selectedItems.size() )
|
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, &selectedItems );
|
|
|
|
|
|
|
|
m_frame->GetCanvas()->Refresh( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
FOOTPRINT_SEARCH_HANDLER::FOOTPRINT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-12-30 11:24:21 +00:00
|
|
|
PCB_SEARCH_HANDLER( _HKI( "Footprints" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-12-30 11:24:21 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Reference" ), 2, wxLIST_FORMAT_LEFT );
|
|
|
|
m_columns.emplace_back( _HKI( "Value" ), 8, wxLIST_FORMAT_LEFT );
|
|
|
|
m_columns.emplace_back( _HKI( "Layer" ), 3, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( wxT( "X" ), 3, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( wxT( "Y" ), 3, wxLIST_FORMAT_CENTER );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
int FOOTPRINT_SEARCH_HANDLER::Search( const wxString& aQuery )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
|
|
|
m_hitlist.clear();
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
2023-09-29 11:08:56 +00:00
|
|
|
if( board == nullptr )
|
|
|
|
return 0;
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
EDA_SEARCH_DATA frp;
|
2022-09-21 03:44:17 +00:00
|
|
|
frp.findString = aQuery;
|
2023-06-10 13:49:37 +00:00
|
|
|
|
|
|
|
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
|
|
|
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
for( FOOTPRINT* fp : board->Footprints() )
|
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
if( aQuery.IsEmpty()
|
|
|
|
|| fp->Reference().Matches( frp, nullptr )
|
|
|
|
|| fp->Value().Matches( frp, nullptr ) )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
|
|
|
m_hitlist.push_back( fp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
return (int) m_hitlist.size();
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-09 17:30:58 +00:00
|
|
|
wxString FOOTPRINT_SEARCH_HANDLER::getResultCell( BOARD_ITEM* aItem, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-08-09 17:30:58 +00:00
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( aItem );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
if( aCol == 0 )
|
2022-09-14 02:59:57 +00:00
|
|
|
return fp->GetReference();
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 1 )
|
2022-11-22 13:50:36 +00:00
|
|
|
return UnescapeString( fp->GetValue() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 2 )
|
2022-09-14 02:59:57 +00:00
|
|
|
return fp->GetLayerName();
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 3 )
|
2023-11-09 18:40:47 +00:00
|
|
|
return m_frame->MessageTextFromCoord( fp->GetX(), ORIGIN_TRANSFORMS::ABS_X_COORD );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 4 )
|
2023-11-09 18:40:47 +00:00
|
|
|
return m_frame->MessageTextFromCoord( fp->GetY(), ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ZONE_SEARCH_HANDLER::ZONE_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-12-30 11:24:21 +00:00
|
|
|
PCB_SEARCH_HANDLER( _HKI( "Zones" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-12-30 11:24:21 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Name" ), 6, wxLIST_FORMAT_LEFT );
|
|
|
|
m_columns.emplace_back( _HKI( "Net" ), 6, wxLIST_FORMAT_LEFT);
|
|
|
|
m_columns.emplace_back( _HKI( "Layer" ), 3, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( _HKI( "Priority" ), 2, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( wxT( "X" ), 3, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( wxT( "Y" ), 3, wxLIST_FORMAT_CENTER );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
int ZONE_SEARCH_HANDLER::Search( const wxString& aQuery )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
|
|
|
m_hitlist.clear();
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
|
|
|
EDA_SEARCH_DATA frp;
|
2022-09-21 03:44:17 +00:00
|
|
|
frp.findString = aQuery;
|
2023-06-10 13:49:37 +00:00
|
|
|
|
|
|
|
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
|
|
|
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* item : board->Zones() )
|
|
|
|
{
|
|
|
|
ZONE* zoneItem = dynamic_cast<ZONE*>( item );
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
if( zoneItem && ( aQuery.IsEmpty() || zoneItem->Matches( frp, nullptr ) ) )
|
2022-09-14 02:59:57 +00:00
|
|
|
m_hitlist.push_back( zoneItem );
|
|
|
|
}
|
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
return (int) m_hitlist.size();
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-09 17:30:58 +00:00
|
|
|
wxString ZONE_SEARCH_HANDLER::getResultCell( BOARD_ITEM* aItem, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-08-09 17:30:58 +00:00
|
|
|
ZONE* zone = static_cast<ZONE*>( aItem );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
if( aCol == 0 )
|
2022-09-21 02:15:41 +00:00
|
|
|
return zone->GetZoneName();
|
2023-11-07 13:40:24 +00:00
|
|
|
else if( aCol == 1 )
|
2022-11-21 23:47:08 +00:00
|
|
|
return UnescapeString( zone->GetNetname() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 2 )
|
2022-09-21 02:15:41 +00:00
|
|
|
{
|
|
|
|
wxArrayString layers;
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
|
|
|
layers.Add( board->GetLayerName( layer ) );
|
|
|
|
|
|
|
|
return wxJoin( layers, ',' );
|
|
|
|
}
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 3 )
|
2022-09-21 02:15:41 +00:00
|
|
|
return wxString::Format( "%d", zone->GetAssignedPriority() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 4 )
|
2023-11-09 18:40:47 +00:00
|
|
|
return m_frame->MessageTextFromCoord( zone->GetX(), ORIGIN_TRANSFORMS::ABS_X_COORD );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 5 )
|
2023-11-09 18:40:47 +00:00
|
|
|
return m_frame->MessageTextFromCoord( zone->GetY(), ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEXT_SEARCH_HANDLER::TEXT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-12-30 11:24:21 +00:00
|
|
|
PCB_SEARCH_HANDLER( _HKI( "Text" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-12-30 11:24:21 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Type" ), 2, wxLIST_FORMAT_LEFT );
|
|
|
|
m_columns.emplace_back( _HKI( "Text" ), 12, wxLIST_FORMAT_LEFT );
|
|
|
|
m_columns.emplace_back( _HKI( "Layer" ), 3, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( wxT( "X" ), 3, wxLIST_FORMAT_CENTER );
|
|
|
|
m_columns.emplace_back( wxT( "Y" ), 3, wxLIST_FORMAT_CENTER );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
int TEXT_SEARCH_HANDLER::Search( const wxString& aQuery )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
|
|
|
m_hitlist.clear();
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
|
|
|
EDA_SEARCH_DATA frp;
|
2022-09-21 03:44:17 +00:00
|
|
|
frp.findString = aQuery;
|
2023-06-10 13:49:37 +00:00
|
|
|
|
|
|
|
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
|
|
|
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* item : board->Drawings() )
|
|
|
|
{
|
|
|
|
PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item );
|
2022-09-20 22:22:17 +00:00
|
|
|
PCB_TEXTBOX* textBoxItem = dynamic_cast<PCB_TEXTBOX*>( item );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
if( textItem && ( aQuery.IsEmpty() || textItem->Matches( frp, nullptr ) ) )
|
2022-09-14 02:59:57 +00:00
|
|
|
m_hitlist.push_back( textItem );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( textBoxItem && ( aQuery.IsEmpty() || textBoxItem->Matches( frp, nullptr ) ) )
|
2022-09-20 22:22:17 +00:00
|
|
|
m_hitlist.push_back( textBoxItem );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
return (int) m_hitlist.size();
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-09 17:30:58 +00:00
|
|
|
wxString TEXT_SEARCH_HANDLER::getResultCell( BOARD_ITEM* aItem, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:44:17 +00:00
|
|
|
if( aCol == 0 )
|
2022-09-20 22:22:17 +00:00
|
|
|
{
|
2023-08-09 17:30:58 +00:00
|
|
|
if( PCB_TEXT::ClassOf( aItem ) )
|
2022-09-20 22:22:17 +00:00
|
|
|
return _( "Text" );
|
2023-08-09 17:30:58 +00:00
|
|
|
else if( PCB_TEXTBOX::ClassOf( aItem ) )
|
2022-09-20 22:22:17 +00:00
|
|
|
return _( "Textbox" );
|
2023-12-28 21:09:43 +00:00
|
|
|
else if( dynamic_cast<PCB_DIMENSION_BASE*>( aItem ) )
|
|
|
|
return _( "Dimension" );
|
2022-09-20 22:22:17 +00:00
|
|
|
}
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 1 )
|
2022-09-20 22:22:17 +00:00
|
|
|
{
|
2023-08-09 17:30:58 +00:00
|
|
|
if( PCB_TEXT::ClassOf( aItem ) )
|
|
|
|
return UnescapeString( static_cast<PCB_TEXT*>( aItem )->GetText() );
|
|
|
|
else if( PCB_TEXTBOX::ClassOf( aItem ) )
|
|
|
|
return UnescapeString( static_cast<PCB_TEXTBOX*>( aItem )->GetText() );
|
2023-12-28 21:09:43 +00:00
|
|
|
else if( PCB_DIMENSION_BASE* dimension = dynamic_cast<PCB_DIMENSION_BASE*>( aItem ) )
|
|
|
|
return UnescapeString( dimension->GetText() );
|
2022-09-20 22:22:17 +00:00
|
|
|
}
|
2023-11-07 13:40:24 +00:00
|
|
|
else if( aCol == 2 )
|
2023-08-09 17:30:58 +00:00
|
|
|
return aItem->GetLayerName();
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 3 )
|
2023-11-09 18:40:47 +00:00
|
|
|
return m_frame->MessageTextFromCoord( aItem->GetX(), ORIGIN_TRANSFORMS::ABS_X_COORD );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 4 )
|
2023-11-09 18:40:47 +00:00
|
|
|
return m_frame->MessageTextFromCoord( aItem->GetY(), ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NETS_SEARCH_HANDLER::NETS_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-12-30 11:24:21 +00:00
|
|
|
PCB_SEARCH_HANDLER( _HKI( "Nets" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-12-30 11:24:21 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Name" ), 6, wxLIST_FORMAT_LEFT );
|
2024-02-05 11:05:31 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Class" ), 6, wxLIST_FORMAT_LEFT );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
int NETS_SEARCH_HANDLER::Search( const wxString& aQuery )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
|
|
|
m_hitlist.clear();
|
|
|
|
|
|
|
|
EDA_SEARCH_DATA frp;
|
2022-09-21 03:44:17 +00:00
|
|
|
frp.findString = aQuery;
|
2023-06-10 13:49:37 +00:00
|
|
|
|
|
|
|
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
|
|
|
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
2022-12-10 23:37:23 +00:00
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
for( NETINFO_ITEM* net : board->GetNetInfo() )
|
|
|
|
{
|
2022-09-21 03:44:17 +00:00
|
|
|
if( net && ( aQuery.IsEmpty() || net->Matches( frp, nullptr ) ) )
|
2022-09-14 02:59:57 +00:00
|
|
|
m_hitlist.push_back( net );
|
|
|
|
}
|
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
return (int) m_hitlist.size();
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-09 17:30:58 +00:00
|
|
|
wxString NETS_SEARCH_HANDLER::getResultCell( BOARD_ITEM* aItem, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2023-08-09 17:30:58 +00:00
|
|
|
NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( aItem );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2022-12-13 20:50:59 +00:00
|
|
|
if( net->GetNetCode() == 0 )
|
|
|
|
{
|
|
|
|
if( aCol == 0 )
|
2022-12-13 21:33:08 +00:00
|
|
|
return _( "No Net" );
|
2022-12-13 20:50:59 +00:00
|
|
|
else if( aCol == 1 )
|
|
|
|
return wxT( "" );
|
|
|
|
}
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
if( aCol == 0 )
|
2022-11-21 23:47:08 +00:00
|
|
|
return UnescapeString( net->GetNetname() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 1 )
|
2022-09-14 02:59:57 +00:00
|
|
|
return net->GetNetClass()->GetName();
|
|
|
|
|
|
|
|
return wxEmptyString;
|
2022-10-23 23:53:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NETS_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
|
|
|
{
|
|
|
|
RENDER_SETTINGS* ps = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();
|
|
|
|
ps->SetHighlight( false );
|
|
|
|
|
|
|
|
std::vector<NETINFO_ITEM*> selectedItems;
|
2022-12-10 23:37:23 +00:00
|
|
|
|
2022-10-23 23:53:47 +00:00
|
|
|
for( long row : aItemRows )
|
|
|
|
{
|
|
|
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
|
|
|
{
|
2023-08-09 17:30:58 +00:00
|
|
|
NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( m_hitlist[row] );
|
2022-10-23 23:53:47 +00:00
|
|
|
|
|
|
|
ps->SetHighlight( true, net->GetNetCode(), true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
2022-11-21 23:47:08 +00:00
|
|
|
}
|
2023-02-18 20:40:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
void NETS_SEARCH_HANDLER::ActivateItem( long aItemRow )
|
|
|
|
{
|
|
|
|
m_frame->ShowBoardSetupDialog( _( "Net Classes" ) );
|
|
|
|
}
|
2023-08-17 14:24:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
RATSNEST_SEARCH_HANDLER::RATSNEST_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-12-30 11:24:21 +00:00
|
|
|
PCB_SEARCH_HANDLER( _HKI( "Ratsnest" ), aFrame )
|
2023-08-17 14:24:59 +00:00
|
|
|
{
|
2023-12-30 11:24:21 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Name" ), 6, wxLIST_FORMAT_LEFT );
|
2024-02-05 11:05:31 +00:00
|
|
|
m_columns.emplace_back( _HKI( "Class" ), 6, wxLIST_FORMAT_LEFT );
|
2023-08-17 14:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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" ) );
|
|
|
|
}
|