2023-05-14 21:35:39 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2023-05-14 21:35:39 -04: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 <sch_edit_frame.h>
|
|
|
|
#include "sch_search_pane.h"
|
|
|
|
#include "search_handlers.h"
|
|
|
|
|
|
|
|
|
|
|
|
SCH_SEARCH_PANE::SCH_SEARCH_PANE( SCH_EDIT_FRAME* aFrame ) :
|
2023-11-07 13:40:24 +00:00
|
|
|
SEARCH_PANE( aFrame ),
|
|
|
|
m_schFrame( aFrame )
|
2023-05-14 21:35:39 -04:00
|
|
|
{
|
|
|
|
m_sch = &(m_schFrame->Schematic());
|
|
|
|
|
|
|
|
if( m_sch != nullptr )
|
|
|
|
m_sch->AddListener( this );
|
|
|
|
|
2025-03-20 12:25:58 +00:00
|
|
|
m_schFrame->Connect( EDA_EVT_UNITS_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ),
|
|
|
|
nullptr, this );
|
2023-05-14 21:35:39 -04:00
|
|
|
|
2025-03-20 12:25:58 +00:00
|
|
|
m_schFrame->Connect( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ),
|
|
|
|
nullptr, this );
|
2023-05-14 21:35:39 -04:00
|
|
|
|
2024-01-18 17:50:50 -05:00
|
|
|
m_schFrame->Bind( EDA_EVT_SCHEMATIC_CHANGING, [&]( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
ClearAllResults();
|
|
|
|
} );
|
|
|
|
|
2023-05-14 21:35:39 -04:00
|
|
|
wxFont infoFont = KIUI::GetDockedPaneFont( this );
|
|
|
|
SetFont( infoFont );
|
|
|
|
m_notebook->SetFont( infoFont );
|
|
|
|
|
|
|
|
AddSearcher( new SYMBOL_SEARCH_HANDLER( aFrame ) );
|
2024-05-20 13:59:06 -04:00
|
|
|
AddSearcher( new POWER_SEARCH_HANDLER( aFrame ) );
|
2023-05-14 21:35:39 -04:00
|
|
|
AddSearcher( new TEXT_SEARCH_HANDLER( aFrame ) );
|
|
|
|
AddSearcher( new LABEL_SEARCH_HANDLER( aFrame ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_SEARCH_PANE::~SCH_SEARCH_PANE()
|
|
|
|
{
|
2025-03-20 12:25:58 +00:00
|
|
|
m_schFrame->Disconnect( EDA_EVT_UNITS_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ),
|
|
|
|
nullptr, this );
|
|
|
|
m_schFrame->Disconnect( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ),
|
|
|
|
nullptr, this );
|
2023-05-14 21:35:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::onUnitsChanged( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
ClearAllResults();
|
|
|
|
RefreshSearch();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::onSchChanged( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
ClearAllResults();
|
|
|
|
RefreshSearch();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::OnSchItemsAdded( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
|
|
|
|
{
|
2021-08-19 22:28:54 +01:00
|
|
|
if( !IsShownOnScreen() )
|
2023-05-14 21:35:39 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
RefreshSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::OnSchItemsRemoved( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
|
|
|
|
{
|
2021-08-19 22:28:54 +01:00
|
|
|
if( !IsShownOnScreen() )
|
2023-05-14 21:35:39 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
RefreshSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::OnSchItemsChanged( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
|
|
|
|
{
|
2021-08-19 22:28:54 +01:00
|
|
|
if( !IsShownOnScreen() )
|
2023-05-14 21:35:39 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
RefreshSearch();
|
2024-01-18 17:50:50 -05:00
|
|
|
}
|