2023-05-15 01:35:39 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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-15 01:35:39 +00:00
|
|
|
{
|
|
|
|
m_sch = &(m_schFrame->Schematic());
|
|
|
|
|
|
|
|
if( m_sch != nullptr )
|
|
|
|
m_sch->AddListener( this );
|
|
|
|
|
|
|
|
m_schFrame->Connect( EDA_EVT_UNITS_CHANGED,
|
|
|
|
wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ), nullptr, this );
|
|
|
|
|
|
|
|
m_schFrame->Connect( EDA_EVT_SCHEMATIC_CHANGED,
|
|
|
|
wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ), nullptr, this );
|
|
|
|
|
2024-01-18 22:50:50 +00:00
|
|
|
m_schFrame->Bind( EDA_EVT_SCHEMATIC_CHANGING, [&]( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
ClearAllResults();
|
|
|
|
} );
|
|
|
|
|
2023-05-15 01:35:39 +00:00
|
|
|
wxFont infoFont = KIUI::GetDockedPaneFont( this );
|
|
|
|
SetFont( infoFont );
|
|
|
|
m_notebook->SetFont( infoFont );
|
|
|
|
|
|
|
|
AddSearcher( new SYMBOL_SEARCH_HANDLER( aFrame ) );
|
|
|
|
AddSearcher( new TEXT_SEARCH_HANDLER( aFrame ) );
|
|
|
|
AddSearcher( new LABEL_SEARCH_HANDLER( aFrame ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_SEARCH_PANE::~SCH_SEARCH_PANE()
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 21:28:54 +00:00
|
|
|
if( !IsShownOnScreen() )
|
2023-05-15 01:35:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
RefreshSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::OnSchItemsRemoved( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
|
|
|
|
{
|
2021-08-19 21:28:54 +00:00
|
|
|
if( !IsShownOnScreen() )
|
2023-05-15 01:35:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
RefreshSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SEARCH_PANE::OnSchItemsChanged( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
|
|
|
|
{
|
2021-08-19 21:28:54 +00:00
|
|
|
if( !IsShownOnScreen() )
|
2023-05-15 01:35:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
RefreshSearch();
|
2024-01-18 22:50:50 +00:00
|
|
|
}
|