diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index b31b421e61..701c526e34 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -160,6 +160,7 @@ set( EESCHEMA_SRCS lib_polyline.cpp lib_rectangle.cpp lib_text.cpp + lib_view_frame.cpp libarch.cpp menubar.cpp netlist_generator.cpp @@ -206,11 +207,9 @@ set( EESCHEMA_SRCS symbol_tree_model_adapter.cpp symbol_tree_synchronizing_adapter.cpp template_fieldnames.cpp + toolbars_lib_view.cpp toolbars_sch_editor.cpp - toolbars_viewlib.cpp transform.cpp - viewlib_frame.cpp - viewlibs.cpp netlist_exporters/netlist_exporter.cpp netlist_exporters/netlist_exporter_cadstar.cpp diff --git a/eeschema/dialogs/dialog_symbol_remap.cpp b/eeschema/dialogs/dialog_symbol_remap.cpp index bb5473668a..d47b1ea827 100644 --- a/eeschema/dialogs/dialog_symbol_remap.cpp +++ b/eeschema/dialogs/dialog_symbol_remap.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -39,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 13fd5db5b9..f89de38ba6 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -35,8 +35,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 43c7104d69..6a978eb02a 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 23c2c97047..b879442156 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/eeschema/viewlib_frame.cpp b/eeschema/lib_view_frame.cpp similarity index 88% rename from eeschema/viewlib_frame.cpp rename to eeschema/lib_view_frame.cpp index 89f4f13b67..97806913e3 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -23,21 +23,25 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include #include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -47,6 +51,7 @@ #include #include #include +#include // Save previous component library viewer state. wxString LIB_VIEW_FRAME::m_libraryName; @@ -726,3 +731,103 @@ void LIB_VIEW_FRAME::FinishModal() Close( true ); } + + +void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) +{ + std::unique_lock dialogLock( DIALOG_CHOOSE_COMPONENT::g_Mutex, std::defer_lock ); + + // One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway. + if( !dialogLock.try_lock() ) + return; + + // Container doing search-as-you-type. + SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable(); + auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( libs ) ); + auto adapter = static_cast( adapterPtr.get() ); + + const auto libNicknames = libs->GetLogicalLibs(); + adapter->AddLibraries( libNicknames, this ); + + LIB_PART* current = GetSelectedSymbol(); + LIB_ID id; + int unit = 0; + + if( current ) + { + id = current->GetLibId(); + adapter->SetPreselectNode( id, unit ); + } + + wxString dialogTitle; + dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() ); + + DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, m_convert, false, false, false ); + + if( dlg.ShowQuasiModal() == wxID_CANCEL ) + return; + + id = dlg.GetSelectedLibId( &unit ); + + if( !id.IsValid() ) + return; + + SetSelectedLibrary( id.GetLibNickname() ); + SetSelectedComponent( id.GetLibItemName() ); + SetUnitAndConvert( unit, 1 ); +} + + +void LIB_VIEW_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent ) +{ + wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST ); + int ii = m_cmpList->GetSelection(); + + // Select the next symbol or stop at the end of the list. + if( ii != wxNOT_FOUND || ii != (int)m_cmpList->GetCount() - 1 ) + ii += 1; + + m_cmpList->SetSelection( ii ); + ProcessEvent( evt ); +} + + +void LIB_VIEW_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent ) +{ + wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST ); + int ii = m_cmpList->GetSelection(); + + // Select the previous symbol or stop at the beginning of list. + if( ii != wxNOT_FOUND && ii != 0 ) + ii -= 1; + + m_cmpList->SetSelection( ii ); + ProcessEvent( evt ); +} + + +void LIB_VIEW_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent ) +{ + int ii = m_unitChoice->GetSelection(); + + if( ii < 0 ) + return; + + m_unit = ii + 1; + + updatePreviewSymbol(); +} + + +void LIB_VIEW_FRAME::DisplayLibInfos() +{ + if( m_libList && !m_libList->IsEmpty() && !m_libraryName.IsEmpty() ) + { + const SYMBOL_LIB_TABLE_ROW* row = Prj().SchSymbolLibTable()->FindRow( m_libraryName ); + + wxString title = wxString::Format( _( "Symbol Library Browser -- %s" ), + row ? row->GetFullURI() : _( "no library selected" ) ); + SetTitle( title ); + } +} + diff --git a/eeschema/viewlib_frame.h b/eeschema/lib_view_frame.h similarity index 100% rename from eeschema/viewlib_frame.h rename to eeschema/lib_view_frame.h diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 5a6205ba73..9b3e8b2cb4 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -28,12 +28,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index c9207837c5..619d94e95a 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 9dac3acf53..53e0af391a 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_lib_view.cpp similarity index 99% rename from eeschema/toolbars_viewlib.cpp rename to eeschema/toolbars_lib_view.cpp index d45f105965..60c9e020e6 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_lib_view.cpp @@ -25,7 +25,7 @@ #include "class_library.h" #include "eeschema_id.h" #include "general.h" -#include "viewlib_frame.h" +#include "lib_view_frame.h" #include #include #include diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index a13c61197d..fb25a1c776 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index ce70654346..dc78361c99 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index f69a93d63d..69a9c864a4 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp deleted file mode 100644 index 64e0f0bdad..0000000000 --- a/eeschema/viewlibs.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2015-2019 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 - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) -{ - std::unique_lock dialogLock( DIALOG_CHOOSE_COMPONENT::g_Mutex, std::defer_lock ); - - // One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway. - if( !dialogLock.try_lock() ) - return; - - // Container doing search-as-you-type. - SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable(); - auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( libs ) ); - auto adapter = static_cast( adapterPtr.get() ); - - const auto libNicknames = libs->GetLogicalLibs(); - adapter->AddLibraries( libNicknames, this ); - - LIB_PART* current = GetSelectedSymbol(); - LIB_ID id; - int unit = 0; - - if( current ) - { - id = current->GetLibId(); - adapter->SetPreselectNode( id, unit ); - } - - wxString dialogTitle; - dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() ); - - DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, m_convert, false, false, false ); - - if( dlg.ShowQuasiModal() == wxID_CANCEL ) - return; - - id = dlg.GetSelectedLibId( &unit ); - - if( !id.IsValid() ) - return; - - SetSelectedLibrary( id.GetLibNickname() ); - SetSelectedComponent( id.GetLibItemName() ); - SetUnitAndConvert( unit, 1 ); -} - - -void LIB_VIEW_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent ) -{ - wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST ); - int ii = m_cmpList->GetSelection(); - - // Select the next symbol or stop at the end of the list. - if( ii != wxNOT_FOUND || ii != (int)m_cmpList->GetCount() - 1 ) - ii += 1; - - m_cmpList->SetSelection( ii ); - ProcessEvent( evt ); -} - - -void LIB_VIEW_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent ) -{ - wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST ); - int ii = m_cmpList->GetSelection(); - - // Select the previous symbol or stop at the beginning of list. - if( ii != wxNOT_FOUND && ii != 0 ) - ii -= 1; - - m_cmpList->SetSelection( ii ); - ProcessEvent( evt ); -} - - -void LIB_VIEW_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent ) -{ - int ii = m_unitChoice->GetSelection(); - - if( ii < 0 ) - return; - - m_unit = ii + 1; - - updatePreviewSymbol(); -} - - -void LIB_VIEW_FRAME::DisplayLibInfos() -{ - if( m_libList && !m_libList->IsEmpty() && !m_libraryName.IsEmpty() ) - { - const SYMBOL_LIB_TABLE_ROW* row = Prj().SchSymbolLibTable()->FindRow( m_libraryName ); - - wxString title = wxString::Format( _( "Symbol Library Browser -- %s" ), - row ? row->GetFullURI() : _( "no library selected" ) ); - SetTitle( title ); - } -} -