KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_search_pane.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <sch_edit_frame.h>
21#include "sch_search_pane.h"
22#include "search_handlers.h"
23
24
26 SEARCH_PANE( aFrame ),
27 m_schFrame( aFrame )
28{
29 m_sch = &m_schFrame->Schematic();
30
31 if( m_sch != nullptr )
32 m_sch->AddListener( this );
33
34 m_schFrame->Bind( EDA_EVT_UNITS_CHANGED, &SCH_SEARCH_PANE::onUnitsChanged, this );
35 m_schFrame->Bind( EDA_EVT_SCHEMATIC_CHANGING, &SCH_SEARCH_PANE::onSchChanging, this );
36 m_schFrame->Bind( EDA_EVT_SCHEMATIC_CHANGED, &SCH_SEARCH_PANE::onSchChanged, this );
37
38 wxFont infoFont = KIUI::GetDockedPaneFont( this );
39 SetFont( infoFont );
40 m_notebook->SetFont( infoFont );
41
42 m_searchHandlers = { std::make_shared<SYMBOL_SEARCH_HANDLER>( aFrame ),
43 std::make_shared<POWER_SEARCH_HANDLER>( aFrame ),
44 std::make_shared<TEXT_SEARCH_HANDLER>( aFrame ),
45 std::make_shared<LABEL_SEARCH_HANDLER>( aFrame ),
46 std::make_shared<GROUP_SEARCH_HANDLER>( aFrame ) };
47
48 for( const auto& handler : m_searchHandlers )
49 AddSearcher( handler );
50}
51
52
54{
55 m_schFrame->Unbind( EDA_EVT_UNITS_CHANGED, &SCH_SEARCH_PANE::onUnitsChanged, this );
56 m_schFrame->Unbind( EDA_EVT_SCHEMATIC_CHANGING, &SCH_SEARCH_PANE::onSchChanging, this );
57 m_schFrame->Unbind( EDA_EVT_SCHEMATIC_CHANGED, &SCH_SEARCH_PANE::onSchChanged, this );
58}
59
60
61void SCH_SEARCH_PANE::onUnitsChanged( wxCommandEvent& event )
62{
65 event.Skip();
66}
67
68
69void SCH_SEARCH_PANE::onSchChanging( wxCommandEvent& event )
70{
71 if( m_sch )
72 m_sch->RemoveListener( this );
73
74 m_sch = nullptr;
77 event.Skip();
78}
79
80
81void SCH_SEARCH_PANE::onSchChanged( wxCommandEvent& event )
82{
83 m_sch = &m_schFrame->Schematic();
84
85 if( m_sch != nullptr )
86 m_sch->AddListener( this );
87
90 event.Skip();
91}
92
93
94void SCH_SEARCH_PANE::OnSchItemsAdded( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
95{
97}
98
99
100void SCH_SEARCH_PANE::OnSchItemsRemoved( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
101{
103}
104
105
106void SCH_SEARCH_PANE::OnSchItemsChanged( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
107{
109}
110
111
113{
114 for( const auto& handler : m_searchHandlers )
115 handler->InvalidateResults();
116}
117
118
120{
122
123 if( m_refreshPending || !m_sch || !IsShownOnScreen() )
124 return;
125
126 m_refreshPending = true;
127
128 // Item notifications precede cleanup and connectivity publication; search their final state once.
129 CallAfter( [this]()
130 {
131 m_refreshPending = false;
132
133 if( !m_sch || m_schFrame->IsClosing() || !IsShownOnScreen() )
134 return;
135
137 } );
138}
Holds all the data relating to one schematic.
Definition schematic.h:148
Schematic editor (Eeschema) main window.
void onUnitsChanged(wxCommandEvent &event)
virtual ~SCH_SEARCH_PANE()
void onSchChanged(wxCommandEvent &event)
virtual void OnSchItemsRemoved(SCHEMATIC &aBoard, std::vector< SCH_ITEM * > &aBoardItems) override
virtual void OnSchItemsChanged(SCHEMATIC &aBoard, std::vector< SCH_ITEM * > &aBoardItems) override
void onSchChanging(wxCommandEvent &event)
SCH_EDIT_FRAME * m_schFrame
SCHEMATIC * m_sch
virtual void OnSchItemsAdded(SCHEMATIC &aBoard, std::vector< SCH_ITEM * > &aBoardItems) override
SCH_SEARCH_PANE(SCH_EDIT_FRAME *aFrame)
std::vector< std::shared_ptr< SCH_SEARCH_HANDLER > > m_searchHandlers
wxNotebook * m_notebook
void RefreshSearch()
void AddSearcher(const std::shared_ptr< SEARCH_HANDLER > &aHandler)
SEARCH_PANE(EDA_DRAW_FRAME *aFrame)
void ClearAllResults()
KICOMMON_API wxFont GetDockedPaneFont(wxWindow *aWindow)