ADDED: Search/inspect pane
This commit is contained in:
parent
ba723d36c9
commit
f304e2d4f6
|
@ -190,6 +190,9 @@ set( COMMON_WIDGET_SRCS
|
||||||
widgets/paged_dialog.cpp
|
widgets/paged_dialog.cpp
|
||||||
widgets/progress_reporter_base.cpp
|
widgets/progress_reporter_base.cpp
|
||||||
widgets/properties_panel.cpp
|
widgets/properties_panel.cpp
|
||||||
|
widgets/search_pane.cpp
|
||||||
|
widgets/search_pane_base.cpp
|
||||||
|
widgets/search_pane_tab.cpp
|
||||||
widgets/split_button.cpp
|
widgets/split_button.cpp
|
||||||
widgets/stepped_slider.cpp
|
widgets/stepped_slider.cpp
|
||||||
widgets/text_ctrl_eval.cpp
|
widgets/text_ctrl_eval.cpp
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include <wx/snglinst.h>
|
#include <wx/snglinst.h>
|
||||||
#include <dialogs/dialog_grid_settings.h>
|
#include <dialogs/dialog_grid_settings.h>
|
||||||
#include <widgets/ui_common.h>
|
#include <widgets/ui_common.h>
|
||||||
|
#include <widgets/search_pane.h>
|
||||||
#include <wx/dirdlg.h>
|
#include <wx/dirdlg.h>
|
||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
@ -1092,6 +1093,17 @@ void EDA_DRAW_FRAME::RecreateToolbars()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_FRAME::ShowChangedLanguage()
|
||||||
|
{
|
||||||
|
EDA_BASE_FRAME::ShowChangedLanguage();
|
||||||
|
|
||||||
|
if( m_searchPane )
|
||||||
|
{
|
||||||
|
m_searchPane->OnLanguageChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
COLOR_SETTINGS* EDA_DRAW_FRAME::GetColorSettings( bool aForceRefresh ) const
|
COLOR_SETTINGS* EDA_DRAW_FRAME::GetColorSettings( bool aForceRefresh ) const
|
||||||
{
|
{
|
||||||
if( !m_colorSettings || aForceRefresh )
|
if( !m_colorSettings || aForceRefresh )
|
||||||
|
|
|
@ -203,6 +203,12 @@ TOOL_ACTION ACTIONS::activatePointEditor( "common.Control.activatePointEditor",
|
||||||
TOOL_ACTION ACTIONS::changeEditMethod( "common.Interactive.changeEditMethod", AS_GLOBAL,
|
TOOL_ACTION ACTIONS::changeEditMethod( "common.Interactive.changeEditMethod", AS_GLOBAL,
|
||||||
MD_CTRL + ' ', "", _( "Change Edit Method" ), _( "Change edit method constraints" ) );
|
MD_CTRL + ' ', "", _( "Change Edit Method" ), _( "Change edit method constraints" ) );
|
||||||
|
|
||||||
|
TOOL_ACTION ACTIONS::search( "common.Interactive.search",
|
||||||
|
AS_GLOBAL,
|
||||||
|
MD_CTRL + 'G', LEGACY_HK_NAME( "Search" ),
|
||||||
|
_( "Find" ), _( "Search for items" ),
|
||||||
|
BITMAPS::find );
|
||||||
|
|
||||||
TOOL_ACTION ACTIONS::find( "common.Interactive.find",
|
TOOL_ACTION ACTIONS::find( "common.Interactive.find",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
MD_CTRL + 'F', LEGACY_HK_NAME( "Find" ),
|
MD_CTRL + 'F', LEGACY_HK_NAME( "Find" ),
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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 <widgets/search_pane.h>
|
||||||
|
#include <widgets/search_pane_tab.h>
|
||||||
|
#include <eda_draw_frame.h>
|
||||||
|
#include <kiway.h>
|
||||||
|
|
||||||
|
|
||||||
|
SEARCH_PANE::SEARCH_PANE( EDA_DRAW_FRAME* aFrame ) :
|
||||||
|
SEARCH_PANE_BASE( aFrame ),
|
||||||
|
m_frame( aFrame )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SEARCH_PANE::~SEARCH_PANE()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE::OnLanguageChange()
|
||||||
|
{
|
||||||
|
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
|
||||||
|
{
|
||||||
|
wxWindow* page = m_notebook->GetPage( i );
|
||||||
|
SEARCH_PANE_TAB* tab = dynamic_cast<SEARCH_PANE_TAB*>( page );
|
||||||
|
|
||||||
|
tab->RefreshColumnNames();
|
||||||
|
m_notebook->SetPageText( i, _( tab->GetSearchHandler()->GetName() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE::AddSearcher( SEARCH_HANDLER* aHandler )
|
||||||
|
{
|
||||||
|
SEARCH_PANE_TAB* tab = new SEARCH_PANE_TAB( aHandler, m_notebook );
|
||||||
|
|
||||||
|
m_notebook->AddPage( tab, _( aHandler->GetName() ) );
|
||||||
|
m_handlers.push_back( aHandler );
|
||||||
|
m_tabs.push_back( tab );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE::RefreshSearch()
|
||||||
|
{
|
||||||
|
for( SEARCH_PANE_TAB* tab : m_tabs )
|
||||||
|
{
|
||||||
|
tab->Search( m_lastQuery );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE::OnSearchTextEntry( wxCommandEvent& aEvent )
|
||||||
|
{
|
||||||
|
wxString query = m_searchCtrl1->GetValue();
|
||||||
|
m_lastQuery = query;
|
||||||
|
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE::FocusSearch()
|
||||||
|
{
|
||||||
|
m_searchCtrl1->SetFocus();
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "search_pane_base.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SEARCH_PANE_BASE::SEARCH_PANE_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
|
||||||
|
{
|
||||||
|
this->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
|
||||||
|
this->SetMinSize( wxSize( 360,100 ) );
|
||||||
|
|
||||||
|
m_sizerOuter = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
m_searchCtrl1 = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
#ifndef __WXMAC__
|
||||||
|
m_searchCtrl1->ShowSearchButton( true );
|
||||||
|
#endif
|
||||||
|
m_searchCtrl1->ShowCancelButton( false );
|
||||||
|
m_sizerOuter->Add( m_searchCtrl1, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
|
||||||
|
m_sizerOuter->Add( m_notebook, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
this->SetSizer( m_sizerOuter );
|
||||||
|
this->Layout();
|
||||||
|
|
||||||
|
// Connect Events
|
||||||
|
this->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( SEARCH_PANE_BASE::OnSetFocus ) );
|
||||||
|
this->Connect( wxEVT_SIZE, wxSizeEventHandler( SEARCH_PANE_BASE::OnSize ) );
|
||||||
|
m_searchCtrl1->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( SEARCH_PANE_BASE::OnSearchTextEntry ), NULL, this );
|
||||||
|
m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( SEARCH_PANE_BASE::OnNotebookPageChanged ), NULL, this );
|
||||||
|
m_notebook->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( SEARCH_PANE_BASE::OnSetFocus ), NULL, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
SEARCH_PANE_BASE::~SEARCH_PANE_BASE()
|
||||||
|
{
|
||||||
|
// Disconnect Events
|
||||||
|
this->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( SEARCH_PANE_BASE::OnSetFocus ) );
|
||||||
|
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( SEARCH_PANE_BASE::OnSize ) );
|
||||||
|
m_searchCtrl1->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( SEARCH_PANE_BASE::OnSearchTextEntry ), NULL, this );
|
||||||
|
m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( SEARCH_PANE_BASE::OnNotebookPageChanged ), NULL, this );
|
||||||
|
m_notebook->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( SEARCH_PANE_BASE::OnSetFocus ), NULL, this );
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,192 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<wxFormBuilder_Project>
|
||||||
|
<FileVersion major="1" minor="16" />
|
||||||
|
<object class="Project" expanded="1">
|
||||||
|
<property name="class_decoration">; </property>
|
||||||
|
<property name="code_generation">C++</property>
|
||||||
|
<property name="disconnect_events">1</property>
|
||||||
|
<property name="disconnect_mode">source_name</property>
|
||||||
|
<property name="disconnect_php_events">0</property>
|
||||||
|
<property name="disconnect_python_events">0</property>
|
||||||
|
<property name="embedded_files_path">res</property>
|
||||||
|
<property name="encoding">UTF-8</property>
|
||||||
|
<property name="event_generation">connect</property>
|
||||||
|
<property name="file">search_pane_base</property>
|
||||||
|
<property name="first_id">1000</property>
|
||||||
|
<property name="help_provider">none</property>
|
||||||
|
<property name="image_path_wrapper_function_name"></property>
|
||||||
|
<property name="indent_with_spaces"></property>
|
||||||
|
<property name="internationalize">1</property>
|
||||||
|
<property name="name">SEARCH PANE</property>
|
||||||
|
<property name="namespace"></property>
|
||||||
|
<property name="path">.</property>
|
||||||
|
<property name="precompiled_header"></property>
|
||||||
|
<property name="relative_path">1</property>
|
||||||
|
<property name="skip_lua_events">1</property>
|
||||||
|
<property name="skip_php_events">1</property>
|
||||||
|
<property name="skip_python_events">1</property>
|
||||||
|
<property name="ui_table">UI</property>
|
||||||
|
<property name="use_array_enum">0</property>
|
||||||
|
<property name="use_enum">0</property>
|
||||||
|
<property name="use_microsoft_bom">0</property>
|
||||||
|
<object class="Panel" expanded="1">
|
||||||
|
<property name="aui_managed">0</property>
|
||||||
|
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||||
|
<property name="bg"></property>
|
||||||
|
<property name="context_help"></property>
|
||||||
|
<property name="context_menu">1</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="event_handler">impl_virtual</property>
|
||||||
|
<property name="fg"></property>
|
||||||
|
<property name="font">,90,90,10,70,0</property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="maximum_size"></property>
|
||||||
|
<property name="minimum_size">360,100</property>
|
||||||
|
<property name="name">SEARCH_PANE_BASE</property>
|
||||||
|
<property name="pos"></property>
|
||||||
|
<property name="size">360,250</property>
|
||||||
|
<property name="subclass">; ; forward_declare</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="two_step_creation">0</property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||||
|
<event name="OnSetFocus">OnSetFocus</event>
|
||||||
|
<event name="OnSize">OnSize</event>
|
||||||
|
<object class="wxBoxSizer" expanded="1">
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="name">m_sizerOuter</property>
|
||||||
|
<property name="orient">wxVERTICAL</property>
|
||||||
|
<property name="permission">protected</property>
|
||||||
|
<object class="sizeritem" expanded="1">
|
||||||
|
<property name="border">5</property>
|
||||||
|
<property name="flag">wxALL|wxEXPAND</property>
|
||||||
|
<property name="proportion">0</property>
|
||||||
|
<object class="wxSearchCtrl" expanded="1">
|
||||||
|
<property name="BottomDockable">1</property>
|
||||||
|
<property name="LeftDockable">1</property>
|
||||||
|
<property name="RightDockable">1</property>
|
||||||
|
<property name="TopDockable">1</property>
|
||||||
|
<property name="aui_layer"></property>
|
||||||
|
<property name="aui_name"></property>
|
||||||
|
<property name="aui_position"></property>
|
||||||
|
<property name="aui_row"></property>
|
||||||
|
<property name="best_size"></property>
|
||||||
|
<property name="bg"></property>
|
||||||
|
<property name="cancel_button">0</property>
|
||||||
|
<property name="caption"></property>
|
||||||
|
<property name="caption_visible">1</property>
|
||||||
|
<property name="center_pane">0</property>
|
||||||
|
<property name="close_button">1</property>
|
||||||
|
<property name="context_help"></property>
|
||||||
|
<property name="context_menu">1</property>
|
||||||
|
<property name="default_pane">0</property>
|
||||||
|
<property name="dock">Dock</property>
|
||||||
|
<property name="dock_fixed">0</property>
|
||||||
|
<property name="docking">Left</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="fg"></property>
|
||||||
|
<property name="floatable">1</property>
|
||||||
|
<property name="font"></property>
|
||||||
|
<property name="gripper">0</property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="max_size"></property>
|
||||||
|
<property name="maximize_button">0</property>
|
||||||
|
<property name="maximum_size"></property>
|
||||||
|
<property name="min_size"></property>
|
||||||
|
<property name="minimize_button">0</property>
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="moveable">1</property>
|
||||||
|
<property name="name">m_searchCtrl1</property>
|
||||||
|
<property name="pane_border">1</property>
|
||||||
|
<property name="pane_position"></property>
|
||||||
|
<property name="pane_size"></property>
|
||||||
|
<property name="permission">protected</property>
|
||||||
|
<property name="pin_button">1</property>
|
||||||
|
<property name="pos"></property>
|
||||||
|
<property name="resize">Resizable</property>
|
||||||
|
<property name="search_button">1</property>
|
||||||
|
<property name="show">1</property>
|
||||||
|
<property name="size"></property>
|
||||||
|
<property name="style"></property>
|
||||||
|
<property name="subclass">; ; forward_declare</property>
|
||||||
|
<property name="toolbar_pane">0</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="validator_data_type"></property>
|
||||||
|
<property name="validator_style">wxFILTER_NONE</property>
|
||||||
|
<property name="validator_type">wxDefaultValidator</property>
|
||||||
|
<property name="validator_variable"></property>
|
||||||
|
<property name="value"></property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style"></property>
|
||||||
|
<event name="OnText">OnSearchTextEntry</event>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="sizeritem" expanded="1">
|
||||||
|
<property name="border">5</property>
|
||||||
|
<property name="flag">wxEXPAND</property>
|
||||||
|
<property name="proportion">1</property>
|
||||||
|
<object class="wxNotebook" expanded="1">
|
||||||
|
<property name="BottomDockable">1</property>
|
||||||
|
<property name="LeftDockable">1</property>
|
||||||
|
<property name="RightDockable">1</property>
|
||||||
|
<property name="TopDockable">1</property>
|
||||||
|
<property name="aui_layer"></property>
|
||||||
|
<property name="aui_name"></property>
|
||||||
|
<property name="aui_position"></property>
|
||||||
|
<property name="aui_row"></property>
|
||||||
|
<property name="best_size"></property>
|
||||||
|
<property name="bg"></property>
|
||||||
|
<property name="bitmapsize"></property>
|
||||||
|
<property name="caption"></property>
|
||||||
|
<property name="caption_visible">1</property>
|
||||||
|
<property name="center_pane">0</property>
|
||||||
|
<property name="close_button">1</property>
|
||||||
|
<property name="context_help"></property>
|
||||||
|
<property name="context_menu">1</property>
|
||||||
|
<property name="default_pane">0</property>
|
||||||
|
<property name="dock">Dock</property>
|
||||||
|
<property name="dock_fixed">0</property>
|
||||||
|
<property name="docking">Left</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="fg"></property>
|
||||||
|
<property name="floatable">1</property>
|
||||||
|
<property name="font"></property>
|
||||||
|
<property name="gripper">0</property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="max_size"></property>
|
||||||
|
<property name="maximize_button">0</property>
|
||||||
|
<property name="maximum_size"></property>
|
||||||
|
<property name="min_size"></property>
|
||||||
|
<property name="minimize_button">0</property>
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="moveable">1</property>
|
||||||
|
<property name="name">m_notebook</property>
|
||||||
|
<property name="pane_border">1</property>
|
||||||
|
<property name="pane_position"></property>
|
||||||
|
<property name="pane_size"></property>
|
||||||
|
<property name="permission">protected</property>
|
||||||
|
<property name="pin_button">1</property>
|
||||||
|
<property name="pos"></property>
|
||||||
|
<property name="resize">Resizable</property>
|
||||||
|
<property name="show">1</property>
|
||||||
|
<property name="size"></property>
|
||||||
|
<property name="style"></property>
|
||||||
|
<property name="subclass">; ; forward_declare</property>
|
||||||
|
<property name="toolbar_pane">0</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style"></property>
|
||||||
|
<event name="OnNotebookPageChanged">OnNotebookPageChanged</event>
|
||||||
|
<event name="OnSetFocus">OnSetFocus</event>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</wxFormBuilder_Project>
|
|
@ -0,0 +1,52 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/artprov.h>
|
||||||
|
#include <wx/xrc/xmlres.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/srchctrl.h>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Class SEARCH_PANE_BASE
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
class SEARCH_PANE_BASE : public wxPanel
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxBoxSizer* m_sizerOuter;
|
||||||
|
wxSearchCtrl* m_searchCtrl1;
|
||||||
|
wxNotebook* m_notebook;
|
||||||
|
|
||||||
|
// Virtual event handlers, override them in your derived class
|
||||||
|
virtual void OnSetFocus( wxFocusEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnSearchTextEntry( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnNotebookPageChanged( wxNotebookEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SEARCH_PANE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 360,250 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||||
|
|
||||||
|
~SEARCH_PANE_BASE();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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 <widgets/search_pane_tab.h>
|
||||||
|
#include <widgets/search_pane.h>
|
||||||
|
#include <kiway.h>
|
||||||
|
|
||||||
|
SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* parent,
|
||||||
|
wxWindowID winid, const wxPoint& pos,
|
||||||
|
const wxSize& size ) :
|
||||||
|
wxListView( parent, winid, pos, size, wxLC_REPORT | wxLC_VIRTUAL ),
|
||||||
|
m_handler( handler )
|
||||||
|
{
|
||||||
|
SetItemCount( 0 );
|
||||||
|
|
||||||
|
RefreshColumnNames();
|
||||||
|
|
||||||
|
Bind( wxEVT_LIST_ITEM_SELECTED, &SEARCH_PANE_LISTVIEW::onItemSelected, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE_LISTVIEW::onItemSelected( wxListEvent& aEvent )
|
||||||
|
{
|
||||||
|
long idx = aEvent.GetIndex();
|
||||||
|
|
||||||
|
m_handler->SelectItem( idx );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE_LISTVIEW::RefreshColumnNames()
|
||||||
|
{
|
||||||
|
Freeze();
|
||||||
|
DeleteAllColumns();
|
||||||
|
|
||||||
|
std::vector<wxString> columns = m_handler->GetColumnNames();
|
||||||
|
for( wxString& columnName : columns )
|
||||||
|
{
|
||||||
|
AppendColumn( _( columnName ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SEARCH_PANE_LISTVIEW::OnGetItemText( long item, long column ) const
|
||||||
|
{
|
||||||
|
return m_handler->GetResultCell( item, column );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SEARCH_PANE_TAB::SEARCH_PANE_TAB( SEARCH_HANDLER* handler, wxWindow* parent, wxWindowID aId,
|
||||||
|
const wxPoint& aLocation, const wxSize& aSize ) :
|
||||||
|
wxPanel( parent, aId, aLocation, aSize ),
|
||||||
|
m_handler( handler )
|
||||||
|
{
|
||||||
|
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
m_listView = new SEARCH_PANE_LISTVIEW( handler, this );
|
||||||
|
sizer->Add( m_listView, 5, wxRIGHT | wxBOTTOM | wxEXPAND, 1 );
|
||||||
|
|
||||||
|
SetSizer( sizer );
|
||||||
|
|
||||||
|
Layout();
|
||||||
|
sizer->Fit( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE_TAB::Search( wxString& query )
|
||||||
|
{
|
||||||
|
int results = m_handler->Search( query );
|
||||||
|
m_listView->SetItemCount( results );
|
||||||
|
m_listView->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SEARCH_PANE_TAB::RefreshColumnNames()
|
||||||
|
{
|
||||||
|
m_listView->RefreshColumnNames();
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ class COLOR_SETTINGS;
|
||||||
class TOOL_MENU;
|
class TOOL_MENU;
|
||||||
class APP_SETTINGS_BASE;
|
class APP_SETTINGS_BASE;
|
||||||
class wxFindReplaceData;
|
class wxFindReplaceData;
|
||||||
|
class SEARCH_PANE;
|
||||||
|
|
||||||
namespace KIGFX
|
namespace KIGFX
|
||||||
{
|
{
|
||||||
|
@ -444,6 +445,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void RecreateToolbars();
|
void RecreateToolbars();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redraw the menus and what not in current language.
|
||||||
|
*/
|
||||||
|
void ShowChangedLanguage() override;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -509,6 +515,7 @@ protected:
|
||||||
int m_msgFrameHeight;
|
int m_msgFrameHeight;
|
||||||
|
|
||||||
COLOR_SETTINGS* m_colorSettings;
|
COLOR_SETTINGS* m_colorSettings;
|
||||||
|
SEARCH_PANE* m_searchPane;
|
||||||
|
|
||||||
///< The current canvas type.
|
///< The current canvas type.
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType;
|
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType;
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
static TOOL_ACTION deleteTool;
|
static TOOL_ACTION deleteTool;
|
||||||
|
|
||||||
// Find and Replace
|
// Find and Replace
|
||||||
|
static TOOL_ACTION search;
|
||||||
static TOOL_ACTION find;
|
static TOOL_ACTION find;
|
||||||
static TOOL_ACTION findAndReplace;
|
static TOOL_ACTION findAndReplace;
|
||||||
static TOOL_ACTION findNext;
|
static TOOL_ACTION findNext;
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SEARCH_PANE_H
|
||||||
|
#define SEARCH_PANE_H
|
||||||
|
|
||||||
|
#include <widgets/search_pane_base.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class EDA_DRAW_FRAME;
|
||||||
|
class SEARCH_PANE_TAB;
|
||||||
|
|
||||||
|
class SEARCH_HANDLER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SEARCH_HANDLER( wxString aName ) :
|
||||||
|
m_name( aName ) {}
|
||||||
|
|
||||||
|
wxString GetName() const { return m_name; }
|
||||||
|
|
||||||
|
std::vector<wxString> GetColumnNames() const { return m_columnNames; }
|
||||||
|
|
||||||
|
virtual int Search( const wxString& string ) = 0;
|
||||||
|
virtual wxString GetResultCell( int row, int col ) = 0;
|
||||||
|
|
||||||
|
virtual void SelectItem(int row) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString m_name;
|
||||||
|
std::vector<wxString> m_columnNames;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SEARCH_PANE : public SEARCH_PANE_BASE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SEARCH_PANE( EDA_DRAW_FRAME* aFrame );
|
||||||
|
virtual ~SEARCH_PANE();
|
||||||
|
|
||||||
|
void AddSearcher( SEARCH_HANDLER* aHandler );
|
||||||
|
void OnSearchTextEntry( wxCommandEvent& aEvent ) override;
|
||||||
|
|
||||||
|
void RefreshSearch();
|
||||||
|
void OnLanguageChange();
|
||||||
|
void FocusSearch();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
EDA_DRAW_FRAME* m_frame;
|
||||||
|
std::vector<SEARCH_HANDLER*> m_handlers;
|
||||||
|
std::vector<SEARCH_PANE_TAB*> m_tabs;
|
||||||
|
wxString m_lastQuery;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SEARCH_PANE_TAB_H
|
||||||
|
#define SEARCH_PANE_TAB_H
|
||||||
|
|
||||||
|
#include <wx/listctrl.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
|
||||||
|
class SEARCH_HANDLER;
|
||||||
|
|
||||||
|
|
||||||
|
class SEARCH_PANE_LISTVIEW : public wxListView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler,
|
||||||
|
wxWindow* parent, wxWindowID winid = wxID_ANY,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize );
|
||||||
|
|
||||||
|
void RefreshColumnNames();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString OnGetItemText( long item, long column ) const override;
|
||||||
|
void onItemSelected( wxListEvent& aEvent );
|
||||||
|
|
||||||
|
private:
|
||||||
|
SEARCH_HANDLER* m_handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SEARCH_PANE_TAB : public wxPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SEARCH_PANE_TAB( SEARCH_HANDLER* handler, wxWindow* parent, wxWindowID aId = wxID_ANY,
|
||||||
|
const wxPoint& aLocation = wxDefaultPosition,
|
||||||
|
const wxSize& aSize = wxDefaultSize );
|
||||||
|
|
||||||
|
void Search( wxString& query );
|
||||||
|
void RefreshColumnNames();
|
||||||
|
|
||||||
|
SEARCH_HANDLER* GetSearchHandler() const { return m_handler; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SEARCH_PANE_LISTVIEW* m_listView;
|
||||||
|
SEARCH_HANDLER* m_handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -370,6 +370,8 @@ set( PCBNEW_CLASS_SRCS
|
||||||
widgets/appearance_controls_base.cpp
|
widgets/appearance_controls_base.cpp
|
||||||
widgets/panel_selection_filter.cpp
|
widgets/panel_selection_filter.cpp
|
||||||
widgets/panel_selection_filter_base.cpp
|
widgets/panel_selection_filter_base.cpp
|
||||||
|
widgets/pcb_search_pane.cpp
|
||||||
|
widgets/search_handlers.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
|
|
||||||
viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
|
viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
|
||||||
viewMenu->Add( PCB_ACTIONS::showProperties, ACTION_MENU::CHECK );
|
viewMenu->Add( PCB_ACTIONS::showProperties, ACTION_MENU::CHECK );
|
||||||
|
viewMenu->Add( PCB_ACTIONS::showSearch, ACTION_MENU::CHECK );
|
||||||
viewMenu->Add( ACTIONS::showFootprintBrowser );
|
viewMenu->Add( ACTIONS::showFootprintBrowser );
|
||||||
viewMenu->Add( ACTIONS::show3DViewer );
|
viewMenu->Add( ACTIONS::show3DViewer );
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,8 @@
|
||||||
#include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
|
#include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
|
||||||
#include <ratsnest/ratsnest_view_item.h>
|
#include <ratsnest/ratsnest_view_item.h>
|
||||||
#include <widgets/appearance_controls.h>
|
#include <widgets/appearance_controls.h>
|
||||||
|
#include <widgets/pcb_search_pane.h>
|
||||||
|
#include <wx/fdrepdlg.h>
|
||||||
#include <widgets/infobar.h>
|
#include <widgets/infobar.h>
|
||||||
#include <widgets/panel_selection_filter.h>
|
#include <widgets/panel_selection_filter.h>
|
||||||
#include <widgets/wx_aui_utils.h>
|
#include <widgets/wx_aui_utils.h>
|
||||||
|
@ -191,6 +193,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_supportsAutoSave = true;
|
m_supportsAutoSave = true;
|
||||||
m_probingSchToPcb = false;
|
m_probingSchToPcb = false;
|
||||||
m_show_properties = true;
|
m_show_properties = true;
|
||||||
|
m_show_search = false;
|
||||||
|
|
||||||
// We don't know what state board was in when it was last saved, so we have to
|
// We don't know what state board was in when it was last saved, so we have to
|
||||||
// assume dirty
|
// assume dirty
|
||||||
|
@ -248,6 +251,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
|
m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
|
||||||
|
|
||||||
m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
|
m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
|
||||||
|
m_searchPane = new PCB_SEARCH_PANE( this );
|
||||||
|
|
||||||
m_auimgr.SetManagedWindow( this );
|
m_auimgr.SetManagedWindow( this );
|
||||||
|
|
||||||
|
@ -297,12 +301,26 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
|
||||||
.Center() );
|
.Center() );
|
||||||
|
|
||||||
|
|
||||||
|
m_auimgr.AddPane( m_searchPane, EDA_PANE()
|
||||||
|
.Name( SearchPaneName() )
|
||||||
|
.Bottom()
|
||||||
|
.Caption( _( "Search" ) )
|
||||||
|
.PaneBorder( false )
|
||||||
|
.MinSize( 180, -1 )
|
||||||
|
.BestSize( 180, -1 )
|
||||||
|
.CloseButton( true )
|
||||||
|
.DestroyOnClose( false ) );
|
||||||
|
|
||||||
|
|
||||||
m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
|
m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
|
||||||
m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
|
m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
|
||||||
|
|
||||||
bool showProperties = ADVANCED_CFG::GetCfg().m_ShowPropertiesPanel && m_show_properties;
|
bool showProperties = ADVANCED_CFG::GetCfg().m_ShowPropertiesPanel && m_show_properties;
|
||||||
m_auimgr.GetPane( "PropertiesManager" ).Show( showProperties );
|
m_auimgr.GetPane( "PropertiesManager" ).Show( showProperties );
|
||||||
|
|
||||||
|
m_auimgr.GetPane( SearchPaneName() ).Show( m_show_search );
|
||||||
|
|
||||||
// The selection filter doesn't need to grow in the vertical direction when docked
|
// The selection filter doesn't need to grow in the vertical direction when docked
|
||||||
m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
|
m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,11 @@ public:
|
||||||
*/
|
*/
|
||||||
std::vector<BOARD_ITEM*> FindItemsFromSyncSelection( std::string syncStr );
|
std::vector<BOARD_ITEM*> FindItemsFromSyncSelection( std::string syncStr );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the wxAuiPaneInfo managing the Search panel
|
||||||
|
*/
|
||||||
|
static const wxString SearchPaneName() { return wxT( "Search" ); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the Find dialog.
|
* Show the Find dialog.
|
||||||
*/
|
*/
|
||||||
|
@ -296,6 +301,7 @@ public:
|
||||||
|
|
||||||
void ToggleLayersManager();
|
void ToggleLayersManager();
|
||||||
void ToggleProperties();
|
void ToggleProperties();
|
||||||
|
void ToggleSearch();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an ASCII footprint position file.
|
* Create an ASCII footprint position file.
|
||||||
|
@ -808,6 +814,7 @@ public:
|
||||||
|
|
||||||
bool m_show_layer_manager_tools;
|
bool m_show_layer_manager_tools;
|
||||||
bool m_show_properties;
|
bool m_show_properties;
|
||||||
|
bool m_show_search;
|
||||||
|
|
||||||
bool m_ZoneFillsDirty; // Board has been modified since last zone fill.
|
bool m_ZoneFillsDirty; // Board has been modified since last zone fill.
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <tools/pcb_selection_tool.h>
|
#include <tools/pcb_selection_tool.h>
|
||||||
#include <widgets/appearance_controls.h>
|
#include <widgets/appearance_controls.h>
|
||||||
|
#include <widgets/pcb_search_pane.h>
|
||||||
#include <widgets/wx_aui_utils.h>
|
#include <widgets/wx_aui_utils.h>
|
||||||
#include <wx/wupdlock.h>
|
#include <wx/wupdlock.h>
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
|
@ -793,6 +794,20 @@ void PCB_EDIT_FRAME::ToggleProperties()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_EDIT_FRAME::ToggleSearch()
|
||||||
|
{
|
||||||
|
m_show_search = !m_show_search;
|
||||||
|
|
||||||
|
m_auimgr.GetPane( SearchPaneName() ).Show( m_show_search );
|
||||||
|
m_auimgr.Update();
|
||||||
|
|
||||||
|
if( m_show_search )
|
||||||
|
{
|
||||||
|
m_searchPane->FocusSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
|
void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
|
||||||
{
|
{
|
||||||
if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
|
if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
|
||||||
|
|
|
@ -337,6 +337,13 @@ int BOARD_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int BOARD_EDITOR_CONTROL::Search( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
m_frame->ToggleSearch();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int BOARD_EDITOR_CONTROL::Find( const TOOL_EVENT& aEvent )
|
int BOARD_EDITOR_CONTROL::Find( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->ShowFindDialog();
|
m_frame->ShowFindDialog();
|
||||||
|
@ -678,6 +685,13 @@ int BOARD_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int BOARD_EDITOR_CONTROL::ToggleSearch( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int BOARD_EDITOR_CONTROL::TogglePythonConsole( const TOOL_EVENT& aEvent )
|
int BOARD_EDITOR_CONTROL::TogglePythonConsole( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->ScriptingConsoleEnableDisable();
|
m_frame->ScriptingConsoleEnableDisable();
|
||||||
|
@ -1587,6 +1601,7 @@ void BOARD_EDITOR_CONTROL::setTransitions()
|
||||||
Go( &BOARD_EDITOR_CONTROL::PageSettings, ACTIONS::pageSettings.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::PageSettings, ACTIONS::pageSettings.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
||||||
|
|
||||||
|
Go( &BOARD_EDITOR_CONTROL::Search, ACTIONS::search.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::Find, ACTIONS::find.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::Find, ACTIONS::find.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::FindNext, ACTIONS::findNext.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::FindNext, ACTIONS::findNext.MakeEvent() );
|
||||||
|
|
||||||
|
@ -1647,6 +1662,7 @@ void BOARD_EDITOR_CONTROL::setTransitions()
|
||||||
Go( &BOARD_EDITOR_CONTROL::ShowEeschema, PCB_ACTIONS::showEeschema.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::ShowEeschema, PCB_ACTIONS::showEeschema.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::ToggleProperties, PCB_ACTIONS::showProperties.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::ToggleProperties, PCB_ACTIONS::showProperties.MakeEvent() );
|
||||||
|
Go( &BOARD_EDITOR_CONTROL::ToggleSearch, PCB_ACTIONS::showSearch.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() );
|
||||||
Go( &BOARD_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
|
Go( &BOARD_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
int PageSettings( const TOOL_EVENT& aEvent );
|
int PageSettings( const TOOL_EVENT& aEvent );
|
||||||
int Plot( const TOOL_EVENT& aEvent );
|
int Plot( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
int Search( const TOOL_EVENT& aEvent );
|
||||||
int Find( const TOOL_EVENT& aEvent );
|
int Find( const TOOL_EVENT& aEvent );
|
||||||
int FindNext( const TOOL_EVENT& aEvent );
|
int FindNext( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ public:
|
||||||
int ShowEeschema( const TOOL_EVENT& aEvent );
|
int ShowEeschema( const TOOL_EVENT& aEvent );
|
||||||
int ToggleLayersManager( const TOOL_EVENT& aEvent );
|
int ToggleLayersManager( const TOOL_EVENT& aEvent );
|
||||||
int ToggleProperties( const TOOL_EVENT& aEvent );
|
int ToggleProperties( const TOOL_EVENT& aEvent );
|
||||||
|
int ToggleSearch( const TOOL_EVENT& aEvent );
|
||||||
int TogglePythonConsole( const TOOL_EVENT& aEvent );
|
int TogglePythonConsole( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
// Track & via size control
|
// Track & via size control
|
||||||
|
|
|
@ -837,6 +837,11 @@ TOOL_ACTION PCB_ACTIONS::showProperties( "pcbnew.Control.showProperties",
|
||||||
_( "Show Properties Panel" ), _( "Show/hide the properties panel" ),
|
_( "Show Properties Panel" ), _( "Show/hide the properties panel" ),
|
||||||
BITMAPS::tools );
|
BITMAPS::tools );
|
||||||
|
|
||||||
|
TOOL_ACTION PCB_ACTIONS::showSearch( "pcbnew.Control.showSearch",
|
||||||
|
AS_GLOBAL, 0, "",
|
||||||
|
_( "Show Search Panel" ), _( "Show/hide the search panel" ),
|
||||||
|
BITMAPS::tools );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::flipBoard( "pcbnew.Control.flipBoard",
|
TOOL_ACTION PCB_ACTIONS::flipBoard( "pcbnew.Control.flipBoard",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Flip Board View" ), _( "View board from the opposite side" ),
|
_( "Flip Board View" ), _( "View board from the opposite side" ),
|
||||||
|
|
|
@ -364,6 +364,7 @@ public:
|
||||||
|
|
||||||
static TOOL_ACTION showLayersManager;
|
static TOOL_ACTION showLayersManager;
|
||||||
static TOOL_ACTION showProperties;
|
static TOOL_ACTION showProperties;
|
||||||
|
static TOOL_ACTION showSearch;
|
||||||
static TOOL_ACTION showPythonConsole;
|
static TOOL_ACTION showPythonConsole;
|
||||||
|
|
||||||
// Module editor tools
|
// Module editor tools
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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 <pcb_edit_frame.h>
|
||||||
|
#include "pcb_search_pane.h"
|
||||||
|
#include "search_handlers.h"
|
||||||
|
|
||||||
|
|
||||||
|
PCB_SEARCH_PANE::PCB_SEARCH_PANE( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
m_pcbFrame( aFrame ), SEARCH_PANE( aFrame )
|
||||||
|
{
|
||||||
|
m_brd = m_pcbFrame->GetBoard();
|
||||||
|
|
||||||
|
if( m_brd != nullptr )
|
||||||
|
{
|
||||||
|
m_brd->AddListener( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pcbFrame->Connect( UNITS_CHANGED, wxCommandEventHandler( PCB_SEARCH_PANE::onUnitsChanged ),
|
||||||
|
nullptr, this );
|
||||||
|
|
||||||
|
m_pcbFrame->Connect( BOARD_CHANGED, wxCommandEventHandler( PCB_SEARCH_PANE::onBoardChanged ),
|
||||||
|
nullptr, this );
|
||||||
|
|
||||||
|
AddSearcher( new FOOTPRINT_SEARCH_HANDLER( aFrame ) );
|
||||||
|
AddSearcher( new ZONE_SEARCH_HANDLER( aFrame ) );
|
||||||
|
AddSearcher( new NETS_SEARCH_HANDLER( aFrame ) );
|
||||||
|
AddSearcher( new TEXT_SEARCH_HANDLER( aFrame ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_SEARCH_PANE::~PCB_SEARCH_PANE()
|
||||||
|
{
|
||||||
|
m_pcbFrame->Disconnect( UNITS_CHANGED, wxCommandEventHandler( PCB_SEARCH_PANE::onUnitsChanged ),
|
||||||
|
nullptr, this );
|
||||||
|
m_pcbFrame->Disconnect( BOARD_CHANGED, wxCommandEventHandler( PCB_SEARCH_PANE::onBoardChanged ),
|
||||||
|
nullptr, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::onUnitsChanged( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::onBoardChanged( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
m_brd = m_pcbFrame->GetBoard();
|
||||||
|
|
||||||
|
if( m_brd != nullptr )
|
||||||
|
m_brd->AddListener( this );
|
||||||
|
|
||||||
|
RefreshSearch();
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem )
|
||||||
|
{
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems )
|
||||||
|
{
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem )
|
||||||
|
{
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems )
|
||||||
|
{
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardNetSettingsChanged( BOARD& aBoard )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem )
|
||||||
|
{
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems )
|
||||||
|
{
|
||||||
|
RefreshSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_SEARCH_PANE::OnBoardHighlightNetChanged( BOARD& aBoard )
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_SEARCH_PANE_H
|
||||||
|
#define PCB_SEARCH_PANE_H
|
||||||
|
|
||||||
|
#include <board.h>
|
||||||
|
#include <widgets/search_pane.h>
|
||||||
|
|
||||||
|
class PCB_EDIT_FRAME;
|
||||||
|
|
||||||
|
class PCB_SEARCH_PANE : public SEARCH_PANE, public BOARD_LISTENER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PCB_SEARCH_PANE( PCB_EDIT_FRAME* aFrame );
|
||||||
|
virtual ~PCB_SEARCH_PANE();
|
||||||
|
|
||||||
|
virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
|
||||||
|
virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) override;
|
||||||
|
virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
|
||||||
|
virtual void OnBoardItemsRemoved( BOARD& aBoard,
|
||||||
|
std::vector<BOARD_ITEM*>& aBoardItems ) override;
|
||||||
|
virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) override;
|
||||||
|
virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
|
||||||
|
virtual void OnBoardItemsChanged( BOARD& aBoard,
|
||||||
|
std::vector<BOARD_ITEM*>& aBoardItems ) override;
|
||||||
|
virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onUnitsChanged( wxCommandEvent& event );
|
||||||
|
void onBoardChanged( wxCommandEvent& event );
|
||||||
|
|
||||||
|
PCB_EDIT_FRAME* m_pcbFrame;
|
||||||
|
BOARD* m_brd;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,248 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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 <base_units.h>
|
||||||
|
#include <footprint.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tools/pcb_actions.h>
|
||||||
|
#include <pcb_edit_frame.h>
|
||||||
|
#include <pcb_marker.h>
|
||||||
|
#include <pcb_text.h>
|
||||||
|
#include <zone.h>
|
||||||
|
#include "search_handlers.h"
|
||||||
|
|
||||||
|
|
||||||
|
FOOTPRINT_SEARCH_HANDLER::FOOTPRINT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
SEARCH_HANDLER( wxT( "Footprint" ) ), m_frame( aFrame )
|
||||||
|
{
|
||||||
|
m_columnNames.emplace_back( wxT( "Reference" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Value" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Layer" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "X" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Y" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int FOOTPRINT_SEARCH_HANDLER::Search( const wxString& query )
|
||||||
|
{
|
||||||
|
m_hitlist.clear();
|
||||||
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
EDA_SEARCH_DATA frp;
|
||||||
|
frp.findString = query;
|
||||||
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
||||||
|
|
||||||
|
for( FOOTPRINT* fp : board->Footprints() )
|
||||||
|
{
|
||||||
|
if( fp->Reference().Matches( frp, nullptr ) || fp->Value().Matches( frp, nullptr ) )
|
||||||
|
{
|
||||||
|
m_hitlist.push_back( fp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_hitlist.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString FOOTPRINT_SEARCH_HANDLER::GetResultCell( int row, int col )
|
||||||
|
{
|
||||||
|
FOOTPRINT* fp = m_hitlist[row];
|
||||||
|
|
||||||
|
if( col == 0 )
|
||||||
|
return fp->GetReference();
|
||||||
|
else if( col == 1 )
|
||||||
|
return fp->GetValue();
|
||||||
|
else if( col == 2 )
|
||||||
|
return fp->GetLayerName();
|
||||||
|
else if( col == 3 )
|
||||||
|
return MessageTextFromValue( m_frame->GetUserUnits(), fp->GetX() );
|
||||||
|
else if( col == 4 )
|
||||||
|
return MessageTextFromValue( m_frame->GetUserUnits(), fp->GetY() );
|
||||||
|
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_SEARCH_HANDLER::SelectItem( int row )
|
||||||
|
{
|
||||||
|
FOOTPRINT* fp = m_hitlist[row];
|
||||||
|
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItem, true, fp );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ZONE_SEARCH_HANDLER::ZONE_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
SEARCH_HANDLER( wxT( "Zones" ) ), m_frame( aFrame )
|
||||||
|
{
|
||||||
|
m_columnNames.emplace_back( wxT( "Name" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Layer" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "X" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Y" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ZONE_SEARCH_HANDLER::Search( const wxString& query )
|
||||||
|
{
|
||||||
|
m_hitlist.clear();
|
||||||
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
EDA_SEARCH_DATA frp;
|
||||||
|
frp.findString = query;
|
||||||
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
||||||
|
|
||||||
|
for( BOARD_ITEM* item : board->Zones() )
|
||||||
|
{
|
||||||
|
ZONE* zoneItem = dynamic_cast<ZONE*>( item );
|
||||||
|
|
||||||
|
if( zoneItem && zoneItem->Matches( frp, nullptr ) )
|
||||||
|
{
|
||||||
|
m_hitlist.push_back( zoneItem );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_hitlist.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString ZONE_SEARCH_HANDLER::GetResultCell( int row, int col )
|
||||||
|
{
|
||||||
|
ZONE* zone = m_hitlist[row];
|
||||||
|
|
||||||
|
if( col == 0 )
|
||||||
|
return zone->GetNetname();
|
||||||
|
else if( col == 1 )
|
||||||
|
return zone->GetLayerName();
|
||||||
|
else if( col == 2 )
|
||||||
|
return MessageTextFromValue( m_frame->GetUserUnits(), zone->GetX() );
|
||||||
|
else if( col == 3 )
|
||||||
|
return MessageTextFromValue( m_frame->GetUserUnits(), zone->GetY() );
|
||||||
|
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ZONE_SEARCH_HANDLER::SelectItem( int row )
|
||||||
|
{
|
||||||
|
ZONE* zone = m_hitlist[row];
|
||||||
|
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItem, true, zone );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEXT_SEARCH_HANDLER::TEXT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
SEARCH_HANDLER( wxT( "Text" ) ), m_frame( aFrame )
|
||||||
|
{
|
||||||
|
m_columnNames.emplace_back( wxT( "Text" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Layer" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "X" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Y" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int TEXT_SEARCH_HANDLER::Search( const wxString& query )
|
||||||
|
{
|
||||||
|
m_hitlist.clear();
|
||||||
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
EDA_SEARCH_DATA frp;
|
||||||
|
frp.findString = query;
|
||||||
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
||||||
|
|
||||||
|
for( BOARD_ITEM* item : board->Drawings() )
|
||||||
|
{
|
||||||
|
PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item );
|
||||||
|
|
||||||
|
if( textItem && textItem->Matches( frp, nullptr ) )
|
||||||
|
{
|
||||||
|
m_hitlist.push_back( textItem );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_hitlist.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString TEXT_SEARCH_HANDLER::GetResultCell( int row, int col )
|
||||||
|
{
|
||||||
|
PCB_TEXT* text = m_hitlist[row];
|
||||||
|
|
||||||
|
if( col == 0 )
|
||||||
|
return text->GetText();
|
||||||
|
if( col == 1 )
|
||||||
|
return text->GetLayerName();
|
||||||
|
else if( col == 2 )
|
||||||
|
return MessageTextFromValue( m_frame->GetUserUnits(), text->GetX() );
|
||||||
|
else if( col == 3 )
|
||||||
|
return MessageTextFromValue( m_frame->GetUserUnits(), text->GetY() );
|
||||||
|
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TEXT_SEARCH_HANDLER::SelectItem( int row )
|
||||||
|
{
|
||||||
|
PCB_TEXT* text = m_hitlist[row];
|
||||||
|
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItem, true, text );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NETS_SEARCH_HANDLER::NETS_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
SEARCH_HANDLER( wxT( "Nets" ) ), m_frame( aFrame )
|
||||||
|
{
|
||||||
|
m_columnNames.emplace_back( wxT( "Name" ) );
|
||||||
|
m_columnNames.emplace_back( wxT( "Class" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int NETS_SEARCH_HANDLER::Search( const wxString& query )
|
||||||
|
{
|
||||||
|
m_hitlist.clear();
|
||||||
|
|
||||||
|
EDA_SEARCH_DATA frp;
|
||||||
|
frp.findString = query;
|
||||||
|
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
||||||
|
|
||||||
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
for( NETINFO_ITEM* net : board->GetNetInfo() )
|
||||||
|
{
|
||||||
|
if( net && net->Matches( frp, nullptr ) )
|
||||||
|
{
|
||||||
|
m_hitlist.push_back( net );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_hitlist.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString NETS_SEARCH_HANDLER::GetResultCell( int row, int col )
|
||||||
|
{
|
||||||
|
NETINFO_ITEM* net = m_hitlist[row];
|
||||||
|
|
||||||
|
if( col == 0 )
|
||||||
|
return net->GetNetname();
|
||||||
|
else if( col == 1 )
|
||||||
|
return net->GetNetClass()->GetName();
|
||||||
|
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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 2
|
||||||
|
* 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, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SEARCH_HANDLERS_H
|
||||||
|
#define SEARCH_HANDLERS_H
|
||||||
|
|
||||||
|
#include <widgets/search_pane.h>
|
||||||
|
|
||||||
|
class ZONE;
|
||||||
|
class FOOTPRINT;
|
||||||
|
class PCB_TEXT;
|
||||||
|
|
||||||
|
class FOOTPRINT_SEARCH_HANDLER : public SEARCH_HANDLER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FOOTPRINT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame );
|
||||||
|
|
||||||
|
int Search( const wxString& query ) override;
|
||||||
|
wxString GetResultCell( int row, int col ) override;
|
||||||
|
void SelectItem( int row ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PCB_EDIT_FRAME* m_frame;
|
||||||
|
std::vector<FOOTPRINT*> m_hitlist;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ZONE_SEARCH_HANDLER : public SEARCH_HANDLER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ZONE_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame );
|
||||||
|
|
||||||
|
int Search( const wxString& query ) override;
|
||||||
|
wxString GetResultCell( int row, int col ) override;
|
||||||
|
void SelectItem( int row ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PCB_EDIT_FRAME* m_frame;
|
||||||
|
std::vector<ZONE*> m_hitlist;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TEXT_SEARCH_HANDLER : public SEARCH_HANDLER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TEXT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame );
|
||||||
|
|
||||||
|
int Search( const wxString& query ) override;
|
||||||
|
wxString GetResultCell( int row, int col ) override;
|
||||||
|
void SelectItem( int row ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PCB_EDIT_FRAME* m_frame;
|
||||||
|
std::vector<PCB_TEXT*> m_hitlist;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class NETS_SEARCH_HANDLER : public SEARCH_HANDLER
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NETS_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame );
|
||||||
|
|
||||||
|
int Search( const wxString& query ) override;
|
||||||
|
wxString GetResultCell( int row, int col ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PCB_EDIT_FRAME* m_frame;
|
||||||
|
std::vector<NETINFO_ITEM*> m_hitlist;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue