2022-09-14 02:59:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
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>
|
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
|
|
|
PCB_SEARCH_HANDLER::PCB_SEARCH_HANDLER( wxString aName, PCB_EDIT_FRAME* aFrame ) :
|
|
|
|
SEARCH_HANDLER( aName ), m_frame( aFrame )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
FOOTPRINT_SEARCH_HANDLER::FOOTPRINT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-01-25 16:12:13 +00:00
|
|
|
PCB_SEARCH_HANDLER( wxT( "Footprints" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
m_columns.emplace_back( wxT( "Reference" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Value" ), 2 );
|
|
|
|
m_columns.emplace_back( wxT( "Layer" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "X" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Y" ), 1 );
|
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();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
wxString FOOTPRINT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:44:17 +00:00
|
|
|
FOOTPRINT* fp = m_hitlist[aRow];
|
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 )
|
2022-09-19 09:25:20 +00:00
|
|
|
return m_frame->MessageTextFromValue( fp->GetX() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 4 )
|
2022-09-19 09:25:20 +00:00
|
|
|
return m_frame->MessageTextFromValue( fp->GetY() );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:58:49 +00:00
|
|
|
void FOOTPRINT_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:58:49 +00:00
|
|
|
std::vector<EDA_ITEM*> selectedItems;
|
2022-09-21 17:34:54 +00:00
|
|
|
|
2022-09-21 03:58:49 +00:00
|
|
|
for( long row : aItemRows )
|
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
2022-09-21 03:58:49 +00:00
|
|
|
{
|
|
|
|
FOOTPRINT* fp = m_hitlist[row];
|
|
|
|
selectedItems.push_back( fp );
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
2022-09-21 17:34:54 +00:00
|
|
|
|
|
|
|
if( selectedItems.size() )
|
2023-06-16 21:28:15 +00:00
|
|
|
{
|
|
|
|
EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, &selItems );
|
2023-06-16 21:28:15 +00:00
|
|
|
}
|
2022-09-21 17:34:54 +00:00
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
m_frame->GetCanvas()->Refresh( false );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ZONE_SEARCH_HANDLER::ZONE_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-01-25 16:12:13 +00:00
|
|
|
PCB_SEARCH_HANDLER( wxT( "Zones" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
m_columns.emplace_back( wxT( "Name" ), 2 );
|
|
|
|
m_columns.emplace_back( wxT( "Net" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Layer" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Priority" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "X" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Y" ), 1 );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
wxString ZONE_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:44:17 +00:00
|
|
|
ZONE* zone = m_hitlist[aRow];
|
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();
|
2022-09-21 03:44:17 +00:00
|
|
|
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 )
|
2022-09-21 02:15:41 +00:00
|
|
|
return m_frame->MessageTextFromValue( zone->GetX() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 5 )
|
2022-09-19 09:25:20 +00:00
|
|
|
return m_frame->MessageTextFromValue( zone->GetY() );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:58:49 +00:00
|
|
|
void ZONE_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:58:49 +00:00
|
|
|
std::vector<EDA_ITEM*> selectedItems;
|
2022-12-10 23:37:23 +00:00
|
|
|
|
2022-09-21 03:58:49 +00:00
|
|
|
for( long row : aItemRows )
|
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
2022-09-21 03:58:49 +00:00
|
|
|
{
|
|
|
|
ZONE* zone = m_hitlist[row];
|
|
|
|
selectedItems.push_back( zone );
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
2022-09-21 17:34:54 +00:00
|
|
|
|
|
|
|
if( selectedItems.size() )
|
2023-06-16 21:28:15 +00:00
|
|
|
{
|
|
|
|
EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, &selItems );
|
2023-06-16 21:28:15 +00:00
|
|
|
}
|
2022-09-21 17:34:54 +00:00
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
m_frame->GetCanvas()->Refresh( false );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEXT_SEARCH_HANDLER::TEXT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-01-25 16:12:13 +00:00
|
|
|
PCB_SEARCH_HANDLER( wxT( "Text" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
m_columns.emplace_back( wxT( "Type" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Text" ), 3 );
|
|
|
|
m_columns.emplace_back( wxT( "Layer" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "X" ), 1 );
|
|
|
|
m_columns.emplace_back( wxT( "Y" ), 1 );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
wxString TEXT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:44:17 +00:00
|
|
|
BOARD_ITEM* text = m_hitlist[aRow];
|
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
|
|
|
{
|
|
|
|
if( PCB_TEXT::ClassOf( text ) )
|
|
|
|
return _( "Text" );
|
|
|
|
else if( PCB_TEXTBOX::ClassOf( text ) )
|
|
|
|
return _( "Textbox" );
|
|
|
|
}
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 1 )
|
2022-09-20 22:22:17 +00:00
|
|
|
{
|
|
|
|
if( PCB_TEXT::ClassOf( text ) )
|
2022-11-22 13:50:36 +00:00
|
|
|
return UnescapeString( static_cast<PCB_TEXT*>( text )->GetText() );
|
2022-09-20 22:22:17 +00:00
|
|
|
else if( PCB_TEXTBOX::ClassOf( text ) )
|
2023-05-05 13:21:56 +00:00
|
|
|
return UnescapeString( static_cast<PCB_TEXTBOX*>( text )->GetText() );
|
2022-09-20 22:22:17 +00:00
|
|
|
}
|
2022-09-21 03:44:17 +00:00
|
|
|
if( aCol == 2 )
|
2022-09-14 02:59:57 +00:00
|
|
|
return text->GetLayerName();
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 3 )
|
2022-09-20 22:22:17 +00:00
|
|
|
return m_frame->MessageTextFromValue( text->GetX() );
|
2022-09-21 03:44:17 +00:00
|
|
|
else if( aCol == 4 )
|
2022-09-19 09:25:20 +00:00
|
|
|
return m_frame->MessageTextFromValue( text->GetY() );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:58:49 +00:00
|
|
|
void TEXT_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:58:49 +00:00
|
|
|
std::vector<EDA_ITEM*> selectedItems;
|
2022-12-10 23:37:23 +00:00
|
|
|
|
2022-09-21 03:58:49 +00:00
|
|
|
for( long row : aItemRows )
|
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
2022-09-21 03:58:49 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* text = m_hitlist[row];
|
|
|
|
selectedItems.push_back( text );
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
2022-09-21 17:34:54 +00:00
|
|
|
|
|
|
|
if( selectedItems.size() )
|
2023-06-16 21:28:15 +00:00
|
|
|
{
|
|
|
|
EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, &selItems );
|
2023-06-16 21:28:15 +00:00
|
|
|
}
|
2022-09-21 17:34:54 +00:00
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
m_frame->GetCanvas()->Refresh( false );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NETS_SEARCH_HANDLER::NETS_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
2023-01-25 16:12:13 +00:00
|
|
|
PCB_SEARCH_HANDLER( wxT( "Nets" ), aFrame )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-12-10 23:37:23 +00:00
|
|
|
m_columns.emplace_back( wxT( "Name" ), 2 );
|
|
|
|
m_columns.emplace_back( wxT( "Class" ), 2 );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-21 03:44:17 +00:00
|
|
|
wxString NETS_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
2022-09-21 03:44:17 +00:00
|
|
|
NETINFO_ITEM* net = m_hitlist[aRow];
|
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() )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* net = m_hitlist[row];
|
|
|
|
|
|
|
|
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" ) );
|
|
|
|
}
|