This commit is contained in:
Jeff Young 2022-07-25 09:12:42 +01:00
parent d4ed387eb1
commit e9478191e0
5 changed files with 38 additions and 78 deletions

View File

@ -22,26 +22,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file cvpcb_id.h
*/
/*
* Command IDs for CvPcb.
*
* Please add IDs that are unique to the component library viewer here and
* not in the global id.h file. This will prevent the entire project from
* being rebuilt when adding new commands to the component library viewer.
*/
// Generic IDs:
#include <id.h>
// specific IDs
// CvPCB-specific IDs
enum id_cvpcb_frm
{
ID_CVPCB_COMPONENT_LIST = ID_END_LIST,
ID_CVPCB_FOOTPRINT_LIST,
ID_CVPCB_LIBRARY_LIST,
ID_CVPCB_FILTER_TEXT_EDIT,
ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL
};

View File

@ -63,8 +63,8 @@
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
{
m_symbolsListBox = nullptr;
m_footprintListBox = nullptr;
@ -365,7 +365,7 @@ void CVPCB_MAINFRAME::setupEventHandlers()
}, wxID_EXIT );
// Toolbar events
Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::OnEnterFilteringText, this, ID_CVPCB_FILTER_TEXT_EDIT );
Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::onTextFilterChanged, this );
// Just skip the resize events
Bind( wxEVT_SIZE,
@ -421,7 +421,7 @@ void CVPCB_MAINFRAME::doCloseWindow()
}
void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event )
{
// Called when changing the filter string in main toolbar.
// If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
@ -875,7 +875,7 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
}
int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
int CVPCB_MAINFRAME::readSchematicNetlist( const std::string& aNetlist )
{
STRING_LINE_READER* stringReader = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
KICAD_NETLIST_READER netlistReader( stringReader, &m_netlist );
@ -1118,19 +1118,6 @@ CVPCB_MAINFRAME::CONTROL_TYPE CVPCB_MAINFRAME::GetFocusedControl() const
}
wxControl* CVPCB_MAINFRAME::GetFocusedControlObject() const
{
if( m_librariesListBox->HasFocus() )
return m_librariesListBox;
else if( m_symbolsListBox->HasFocus() )
return m_symbolsListBox;
else if( m_footprintListBox->HasFocus() )
return m_footprintListBox;
return nullptr;
}
void CVPCB_MAINFRAME::SetFocusedControl( CVPCB_MAINFRAME::CONTROL_TYPE aLB )
{
switch( aLB )
@ -1178,10 +1165,10 @@ void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
switch( mail.Command() )
{
case MAIL_EESCHEMA_NETLIST:
// Disable Close events during ReadNetListAndFpFiles() to avoid crash when updating
// Disable Close events during readNetListAndFpFiles() to avoid crash when updating
// widgets:
m_cannotClose = true;
ReadNetListAndFpFiles( payload );
readNetListAndFpFiles( payload );
m_cannotClose = false;
/* @todo
Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.

View File

@ -125,13 +125,6 @@ public:
*/
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const;
/**
* Get a pointer to the currently focused control
*
* @return the control that currently has focus
*/
wxControl* GetFocusedControlObject() const;
/**
* Set the focus to a specific control.
*
@ -147,9 +140,6 @@ public:
*/
void OnSelectComponent( wxListEvent& event );
bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
void doCloseWindow() override;
/*
* Functions to rebuild the toolbars and menubars
*/
@ -177,11 +167,6 @@ public:
void SetFootprintFilter( FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter,
CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction );
/**
* Called each time the text of m_tcFilterString is changed.
*/
void OnEnterFilteringText( wxCommandEvent& event );
/**
* Undo the most recent associations that were performed.
*/
@ -230,24 +215,6 @@ public:
*/
bool SaveFootprintAssociation( bool doSaveSchematic );
/**
* Load the netlist file built on the fly by Eeschema and loads footprint libraries from
* fp lib tables.
*
* @param aNetlist is the netlist from Eeschema in KiCad s-expr format.
* (see CVPCB_MAINFRAME::KiwayMailIn() to know how to get this netlist)
*/
bool ReadNetListAndFpFiles( const std::string& aNetlist );
/**
* Read the netlist (.net) file built on the fly by Eeschema.
*
* @param aNetlist is the netlist buffer filled by Eeschema, in KiCad s-expr format.
* It is the same netlist as the .net file created by Eeschema.
* (This method is called by ReadNetListAndFpFiles)
*/
int ReadSchematicNetlist( const std::string& aNetlist );
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
@ -337,6 +304,27 @@ protected:
void setupUIConditions() override;
bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
void doCloseWindow() override;
/**
* Load the netlist file built on the fly by Eeschema and loads footprint libraries from
* fp lib tables.
*
* @param aNetlist is the netlist from Eeschema in KiCad s-expr format.
* (see CVPCB_MAINFRAME::KiwayMailIn() to know how to get this netlist)
*/
bool readNetListAndFpFiles( const std::string& aNetlist );
/**
* Read the netlist (.net) file built on the fly by Eeschema.
*
* @param aNetlist is the netlist buffer filled by Eeschema, in KiCad s-expr format.
* It is the same netlist as the .net file created by Eeschema.
* (This method is called by readNetListAndFpFiles)
*/
int readSchematicNetlist( const std::string& aNetlist );
private:
wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
const wxString& aFootprint );
@ -351,6 +339,8 @@ private:
*/
void setupEventHandlers();
void onTextFilterChanged( wxCommandEvent& event );
/**
* Read the .equ files and populate the list of equivalents.
*

View File

@ -80,12 +80,12 @@ static int guessNickname( FP_LIB_TABLE* aTbl, LIB_ID* aFootprintId )
}
bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
bool CVPCB_MAINFRAME::readNetListAndFpFiles( const std::string& aNetlist )
{
wxString msg;
bool hasMissingNicks = false;
ReadSchematicNetlist( aNetlist );
readSchematicNetlist( aNetlist );
if( m_symbolsListBox == nullptr )
return false;

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2007-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2007-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
@ -19,11 +19,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file tool_cvpcb.cpp
*/
#include <bitmaps.h>
#include <tool/action_toolbar.h>
#include <tool/actions.h>
@ -42,7 +37,7 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
else
{
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
m_mainToolBar->SetAuiManager( &m_auimgr );
}
@ -86,10 +81,10 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
m_mainToolBar->AddScaledSeparator( this );
m_tcFilterString = new wxTextCtrl( m_mainToolBar, ID_CVPCB_FILTER_TEXT_EDIT, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_tcFilterString = new wxTextCtrl( m_mainToolBar, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxDefaultSize, wxTE_PROCESS_ENTER );
m_tcFilterString->Bind( wxEVT_TEXT_ENTER, &CVPCB_MAINFRAME::OnEnterFilteringText, this );
m_tcFilterString->Bind( wxEVT_TEXT_ENTER, &CVPCB_MAINFRAME::onTextFilterChanged, this );
m_mainToolBar->AddControl( m_tcFilterString );