Actionize cvpcb
This commit is contained in:
parent
c0b80c67b9
commit
72120e0a96
|
@ -47,6 +47,7 @@ set( CVPCB_SRCS
|
|||
readwrite_dlgs.cpp
|
||||
toolbars_cvpcb.cpp
|
||||
tools/cvpcb_actions.cpp
|
||||
tools/cvpcb_control.cpp
|
||||
tools/cvpcb_fpviewer_control.cpp
|
||||
tools/cvpcb_fpviewer_selection_tool.cpp
|
||||
)
|
||||
|
|
|
@ -167,7 +167,7 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
||||
void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
{
|
||||
FOOTPRINT_EQUIVALENCE_LIST equiv_List;
|
||||
wxString msg, error_msg;
|
||||
|
|
|
@ -39,21 +39,8 @@
|
|||
// specific IDs
|
||||
enum id_cvpcb_frm
|
||||
{
|
||||
ID_CVPCB_CREATE_SCREENCMP = ID_END_LIST,
|
||||
ID_CVPCB_GOTO_FIRSTNA,
|
||||
ID_CVPCB_GOTO_PREVIOUSNA,
|
||||
ID_CVPCB_DEL_ASSOCIATIONS,
|
||||
ID_CVPCB_AUTO_ASSOCIE,
|
||||
ID_CVPCB_COMPONENT_LIST,
|
||||
ID_CVPCB_COMPONENT_LIST = ID_END_LIST,
|
||||
ID_CVPCB_FOOTPRINT_LIST,
|
||||
ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
|
||||
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
|
||||
ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
|
||||
ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
|
||||
ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME,
|
||||
ID_CVPCB_LIBRARY_LIST,
|
||||
ID_CVPCB_EQUFILES_LIST_EDIT,
|
||||
ID_CVPCB_LIB_TABLE_EDIT,
|
||||
ID_CVPCB_FILTER_TEXT_EDIT,
|
||||
ID_TB_MEASUREMENT_TOOL
|
||||
};
|
||||
|
|
|
@ -23,29 +23,33 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <bitmaps.h>
|
||||
#include <build_version.h>
|
||||
#include <kiway_express.h>
|
||||
#include <kiface_i.h>
|
||||
#include <kiface_ids.h>
|
||||
#include <macros.h>
|
||||
#include <confirm.h>
|
||||
#include <eda_dde.h>
|
||||
#include <html_messagebox.h>
|
||||
#include <fctsys.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <netlist_reader.h>
|
||||
#include <bitmaps.h>
|
||||
#include <widgets/progress_reporter.h>
|
||||
#include <cvpcb.h>
|
||||
#include <listboxes.h>
|
||||
#include <wx/statline.h>
|
||||
#include <html_messagebox.h>
|
||||
#include <invoke_pcb_dialog.h>
|
||||
#include <display_footprints_frame.h>
|
||||
#include <cvpcb_id.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <kiface_i.h>
|
||||
#include <kiface_ids.h>
|
||||
#include <kiway_express.h>
|
||||
#include <macros.h>
|
||||
#include <netlist_reader.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <tool/common_control.h>
|
||||
#include <tool/conditional_menu.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <widgets/progress_reporter.h>
|
||||
#include <wx/statline.h>
|
||||
|
||||
#include <cvpcb.h>
|
||||
#include <cvpcb_id.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <display_footprints_frame.h>
|
||||
#include <listboxes.h>
|
||||
#include <tools/cvpcb_actions.h>
|
||||
#include <tools/cvpcb_control.h>
|
||||
|
||||
wxSize const FRAME_MIN_SIZE_DU( 350, 250 );
|
||||
wxSize const FRAME_DEFAULT_SIZE_DU( 450, 300 );
|
||||
|
@ -58,44 +62,18 @@ static const wxString FilterFootprintEntry = "FilterFootprint";
|
|||
|
||||
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
|
||||
|
||||
// Menu events
|
||||
EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::OnSaveAndContinue )
|
||||
// Control events
|
||||
EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
|
||||
EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList )
|
||||
|
||||
// Toolbar events
|
||||
EVT_TOOL( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable )
|
||||
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
|
||||
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
|
||||
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
|
||||
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
|
||||
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AutomaticFootprintMatching )
|
||||
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
|
||||
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
||||
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
|
||||
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
||||
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
|
||||
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
||||
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME,
|
||||
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
||||
EVT_TEXT( ID_CVPCB_FILTER_TEXT_EDIT, CVPCB_MAINFRAME::OnEnterFilteringText )
|
||||
|
||||
// Button events
|
||||
EVT_BUTTON( wxID_OK, CVPCB_MAINFRAME::OnOK )
|
||||
EVT_BUTTON( wxID_CANCEL, CVPCB_MAINFRAME::OnCancel )
|
||||
|
||||
// Toolbar events
|
||||
EVT_TEXT( ID_CVPCB_FILTER_TEXT_EDIT, CVPCB_MAINFRAME::OnEnterFilteringText )
|
||||
|
||||
// Frame events
|
||||
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
|
||||
EVT_SIZE( CVPCB_MAINFRAME::OnSize )
|
||||
|
||||
// UI event handlers
|
||||
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyKeywords )
|
||||
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
|
||||
CVPCB_MAINFRAME::OnFilterFPbyPinCount )
|
||||
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
|
||||
CVPCB_MAINFRAME::OnFilterFPbyLibrary )
|
||||
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, CVPCB_MAINFRAME::OnFilterFPbyKeyName )
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -112,7 +90,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_mainToolBar = NULL;
|
||||
m_modified = false;
|
||||
m_skipComponentSelect = false;
|
||||
m_filteringOptions = 0;
|
||||
m_filteringOptions = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST;
|
||||
m_tcFilterString = NULL;
|
||||
m_FootprintsList = FOOTPRINT_LIST::GetInstance( Kiway() );
|
||||
m_initialized = false;
|
||||
|
@ -133,14 +111,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
// Frame size and position
|
||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
// Create the manager
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, this );
|
||||
|
||||
// Register tools
|
||||
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
||||
m_toolManager->InitTools();
|
||||
|
||||
setupTools();
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
|
||||
|
@ -216,24 +187,28 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_initialized = true;
|
||||
|
||||
// Connect Events
|
||||
m_saveAndContinue->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ),
|
||||
NULL, this );
|
||||
m_footprintListBox->Connect( wxEVT_RIGHT_DOWN,
|
||||
wxMouseEventHandler( CVPCB_MAINFRAME::OnFootprintRightClick ),
|
||||
NULL, this );
|
||||
m_compListBox->Connect( wxEVT_RIGHT_DOWN,
|
||||
wxMouseEventHandler( CVPCB_MAINFRAME::OnComponentRightClick ),
|
||||
NULL, this );
|
||||
|
||||
// Use Bind for this one to allow the lambda expression
|
||||
m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
[this]( wxCommandEvent& )
|
||||
{
|
||||
this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations );
|
||||
} );
|
||||
|
||||
// Ensure the toolbars are sync'd properly so the filtering options display correct
|
||||
SyncToolbars();
|
||||
}
|
||||
|
||||
|
||||
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_saveAndContinue->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ),
|
||||
NULL, this );
|
||||
m_footprintListBox->Disconnect( wxEVT_RIGHT_DOWN,
|
||||
wxMouseEventHandler( CVPCB_MAINFRAME::OnFootprintRightClick ),
|
||||
NULL, this );
|
||||
|
@ -242,6 +217,30 @@ CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::setupTools()
|
||||
{
|
||||
// Create the manager
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, this );
|
||||
|
||||
// Register tools
|
||||
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
||||
m_toolManager->RegisterTool( new CVPCB_CONTROL );
|
||||
m_toolManager->InitTools();
|
||||
|
||||
CVPCB_CONTROL* tool = m_toolManager->GetTool<CVPCB_CONTROL>();
|
||||
|
||||
// Create the context menu for the component list box
|
||||
m_componentContextMenu = new ACTION_MENU( true );
|
||||
m_componentContextMenu->SetTool( tool );
|
||||
m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
||||
|
||||
// Create the context menu for the footprint list box
|
||||
m_footprintContextMenu = new ACTION_MENU( true );
|
||||
m_footprintContextMenu->SetTool( tool );
|
||||
m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
||||
}
|
||||
|
||||
void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg )
|
||||
{
|
||||
EDA_BASE_FRAME::LoadSettings( aCfg );
|
||||
|
@ -321,7 +320,7 @@ void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight )
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
|
||||
void CVPCB_MAINFRAME::ToNextNA()
|
||||
{
|
||||
if( m_netlist.IsEmpty() )
|
||||
return;
|
||||
|
@ -351,7 +350,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
|
||||
void CVPCB_MAINFRAME::ToPreviousNA()
|
||||
{
|
||||
if( m_netlist.IsEmpty() )
|
||||
return;
|
||||
|
@ -384,19 +383,11 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
|
|||
void CVPCB_MAINFRAME::OnOK( wxCommandEvent& aEvent )
|
||||
{
|
||||
SaveFootprintAssociation( false );
|
||||
m_modified = false;
|
||||
|
||||
Close( true );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnSaveAndContinue( wxCommandEvent& aEvent )
|
||||
{
|
||||
SaveFootprintAssociation( true );
|
||||
m_modified = false;
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnCancel( wxCommandEvent& event )
|
||||
{
|
||||
// Throw away modifications on a Cancel
|
||||
|
@ -412,9 +403,9 @@ void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
|
||||
void CVPCB_MAINFRAME::DeleteAll()
|
||||
{
|
||||
if( IsOK( this, _( "Delete selections" ) ) )
|
||||
if( IsOK( this, _( "Delete all associations?" ) ) )
|
||||
{
|
||||
m_skipComponentSelect = true;
|
||||
|
||||
|
@ -446,42 +437,15 @@ bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, i
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
|
||||
{
|
||||
KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PCB );
|
||||
kiface->CreateWindow( this, DIALOG_PCB_LIBRARY_TABLE, &Kiway() );
|
||||
|
||||
wxBusyCursor dummy;
|
||||
BuildLIBRARY_LISTBOX();
|
||||
m_FootprintsList->ReadFootprintFiles( Prj().PcbFootprintLibs( Kiway() ) );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
|
||||
{
|
||||
CreateScreenCmp();
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnComponentRightClick( wxMouseEvent& event )
|
||||
{
|
||||
wxMenu menu;
|
||||
|
||||
menu.Append( ID_CVPCB_CREATE_SCREENCMP, _( "View Footprint" ),
|
||||
_( "Show the assigned footprint in the footprint viewer" ) );
|
||||
|
||||
PopupMenu( &menu );
|
||||
PopupMenu( m_componentContextMenu );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnFootprintRightClick( wxMouseEvent& event )
|
||||
{
|
||||
wxMenu menu;
|
||||
|
||||
menu.Append( ID_CVPCB_CREATE_SCREENCMP, _( "View Footprint" ),
|
||||
_( "Show the current footprint in the footprint viewer" ) );
|
||||
|
||||
PopupMenu( &menu );
|
||||
PopupMenu( m_footprintContextMenu );
|
||||
}
|
||||
|
||||
|
||||
|
@ -546,7 +510,7 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
|
|||
}
|
||||
|
||||
if( GetFootprintViewerFrame() )
|
||||
CreateScreenCmp();
|
||||
m_toolManager->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
||||
}
|
||||
|
||||
SendMessageToEESCHEMA();
|
||||
|
@ -554,64 +518,46 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event )
|
||||
void CVPCB_MAINFRAME::SetFootprintFilter(
|
||||
FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction )
|
||||
{
|
||||
int option = 0;
|
||||
int option = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST;
|
||||
|
||||
switch( event.GetId() )
|
||||
// Extract the needed information about the filter
|
||||
switch( aFilter )
|
||||
{
|
||||
case ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST:
|
||||
option = FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD;
|
||||
break;
|
||||
|
||||
case ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST:
|
||||
option = FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT;
|
||||
break;
|
||||
|
||||
case ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST:
|
||||
option = FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY;
|
||||
break;
|
||||
|
||||
case ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME:
|
||||
case FOOTPRINTS_LISTBOX::FILTERING_BY_NAME:
|
||||
// Extract the current search patten when needed
|
||||
m_currentSearchPattern = m_tcFilterString->GetValue();
|
||||
option = FOOTPRINTS_LISTBOX::FILTERING_BY_NAME;
|
||||
|
||||
case FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST:
|
||||
case FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT:
|
||||
case FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY:
|
||||
case FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD:
|
||||
option = aFilter;
|
||||
}
|
||||
|
||||
// Apply the filter accordingly
|
||||
switch( aAction )
|
||||
{
|
||||
case CVPCB_MAINFRAME::FILTER_DISABLE:
|
||||
m_filteringOptions &= ~option;
|
||||
break;
|
||||
|
||||
case CVPCB_MAINFRAME::FILTER_ENABLE:
|
||||
m_filteringOptions |= option;
|
||||
break;
|
||||
|
||||
case CVPCB_MAINFRAME::FILTER_TOGGLE:
|
||||
m_filteringOptions ^= option;
|
||||
break;
|
||||
}
|
||||
|
||||
if( event.IsChecked() )
|
||||
m_filteringOptions |= option;
|
||||
else
|
||||
m_filteringOptions &= ~option;
|
||||
|
||||
wxListEvent l_event;
|
||||
OnSelectComponent( l_event );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnFilterFPbyKeywords( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnFilterFPbyPinCount( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnFilterFPbyLibrary( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnFilterFPbyKeyName( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
|
||||
{
|
||||
// Called when changing the filter string in main toolbar.
|
||||
|
@ -623,7 +569,8 @@ void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
|
|||
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) == 0 )
|
||||
return;
|
||||
|
||||
OnSelectFilteringFootprint( aEvent );
|
||||
wxListEvent l_event;
|
||||
OnSelectComponent( l_event );
|
||||
}
|
||||
|
||||
|
||||
|
@ -806,39 +753,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::CreateScreenCmp()
|
||||
{
|
||||
DISPLAY_FOOTPRINTS_FRAME* fpframe = GetFootprintViewerFrame();
|
||||
|
||||
if( !fpframe )
|
||||
{
|
||||
fpframe = (DISPLAY_FOOTPRINTS_FRAME*) Kiway().Player( FRAME_CVPCB_DISPLAY, true, this );
|
||||
fpframe->Show( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fpframe->IsIconized() )
|
||||
fpframe->Iconize( false );
|
||||
|
||||
// The display footprint window might be buried under some other
|
||||
// windows, so CreateScreenCmp() on an existing window would not
|
||||
// show any difference, leaving the user confused.
|
||||
// So we want to put it to front, second after our CVPCB_MAINFRAME.
|
||||
// We do this by a little dance of bringing it to front then the main
|
||||
// frame back.
|
||||
wxWindow* focus = FindFocus();
|
||||
|
||||
fpframe->Raise(); // Make sure that is visible.
|
||||
Raise(); // .. but still we want the focus.
|
||||
|
||||
if( focus )
|
||||
focus->SetFocus();
|
||||
}
|
||||
|
||||
fpframe->InitDisplay();
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX()
|
||||
{
|
||||
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||
|
|
|
@ -25,22 +25,20 @@
|
|||
#ifndef _CVPCB_MAINFRAME_H_
|
||||
#define _CVPCB_MAINFRAME_H_
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/filename.h>
|
||||
#include <pcb_netlist.h>
|
||||
#include <footprint_info.h>
|
||||
|
||||
#include <pcb_base_frame.h>
|
||||
#include <config_params.h>
|
||||
#include <auto_associate.h>
|
||||
#include <footprint_info.h>
|
||||
#include <memory>
|
||||
#include <pcb_base_frame.h>
|
||||
#include <pcb_netlist.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
#include <auto_associate.h>
|
||||
#include <listboxes.h>
|
||||
#include <tool/action_menu.h>
|
||||
|
||||
/* Forward declarations of all top-level window classes. */
|
||||
class wxAuiToolBar;
|
||||
class FOOTPRINTS_LISTBOX;
|
||||
class COMPONENTS_LISTBOX;
|
||||
class LIBRARY_LISTBOX;
|
||||
class DISPLAY_FOOTPRINTS_FRAME;
|
||||
class COMPONENT;
|
||||
class FP_LIB_TABLE;
|
||||
|
@ -57,7 +55,7 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER
|
|||
wxString m_currentSearchPattern;
|
||||
NETLIST m_netlist;
|
||||
int m_filteringOptions;
|
||||
wxAuiToolBar* m_mainToolBar;
|
||||
ACTION_TOOLBAR* m_mainToolBar;
|
||||
FOOTPRINTS_LISTBOX* m_footprintListBox;
|
||||
LIBRARY_LISTBOX* m_libListBox;
|
||||
COMPONENTS_LISTBOX* m_compListBox;
|
||||
|
@ -89,6 +87,16 @@ public:
|
|||
|
||||
void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
|
||||
|
||||
/**
|
||||
* The action to apply to a footprint filter when it is modified.
|
||||
*/
|
||||
enum CVPCB_FILTER_ACTION
|
||||
{
|
||||
FILTER_DISABLE, ///< Turn off the filter
|
||||
FILTER_ENABLE, ///< Turn on the filter
|
||||
FILTER_TOGGLE ///< Toggle the filter state
|
||||
};
|
||||
|
||||
/**
|
||||
* @return a pointer on the Footprint Viewer frame, if exists, or NULL
|
||||
*/
|
||||
|
@ -103,16 +111,8 @@ public:
|
|||
*/
|
||||
void OnSelectComponent( wxListEvent& event );
|
||||
|
||||
/**
|
||||
* Function OnEditFootprintLibraryTable
|
||||
* displays the footprint library table editing dialog and updates the global and local
|
||||
* footprint tables accordingly.
|
||||
*/
|
||||
void OnEditFootprintLibraryTable( wxCommandEvent& event );
|
||||
|
||||
void OnCancel( wxCommandEvent& aEvent );
|
||||
void OnOK( wxCommandEvent& aEvent );
|
||||
void OnSaveAndContinue( wxCommandEvent& aEvent );
|
||||
void OnQuit( wxCommandEvent& event );
|
||||
void OnCloseWindow( wxCloseEvent& Event );
|
||||
void OnSize( wxSizeEvent& SizeEvent );
|
||||
|
@ -123,22 +123,21 @@ public:
|
|||
|
||||
void ChangeFocus( bool aMoveRight );
|
||||
|
||||
void ToFirstNA( wxCommandEvent& event );
|
||||
void ToPreviousNA( wxCommandEvent& event );
|
||||
/**
|
||||
* Move to the next not associated component.
|
||||
*/
|
||||
void ToNextNA();
|
||||
|
||||
/**
|
||||
* Function DelAssociations
|
||||
* Move to the previous not associated component.
|
||||
*/
|
||||
void ToPreviousNA();
|
||||
|
||||
/**
|
||||
* Function DeleteAll
|
||||
* removes all component footprint associations already made
|
||||
*/
|
||||
void DelAssociations( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function OnEditEquFilesList
|
||||
* envokes the equ files list edit dialog.
|
||||
*/
|
||||
void OnEditEquFilesList( wxCommandEvent& aEvent );
|
||||
|
||||
void DisplayModule( wxCommandEvent& event );
|
||||
void DeleteAll();
|
||||
|
||||
void OnComponentRightClick( wxMouseEvent& event );
|
||||
|
||||
|
@ -152,13 +151,17 @@ public:
|
|||
* format of a line:
|
||||
* 'cmp_ref' 'footprint_name'
|
||||
*/
|
||||
void AutomaticFootprintMatching( wxCommandEvent& event );
|
||||
void AutomaticFootprintMatching();
|
||||
|
||||
/**
|
||||
* Function OnSelectFilteringFootprint
|
||||
* is the command event handler for enabling and disabling footprint filtering.
|
||||
* Function SetFootprintFilter
|
||||
* Set a filter criteria to either on/off or toggle the criteria.
|
||||
*
|
||||
* @param aFilter The filter to modify
|
||||
* @param aAction What action (on, off or toggle) to take
|
||||
*/
|
||||
void OnSelectFilteringFootprint( wxCommandEvent& event );
|
||||
void SetFootprintFilter(
|
||||
FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction );
|
||||
|
||||
/**
|
||||
* Function OnEnterFilteringText
|
||||
|
@ -187,12 +190,6 @@ public:
|
|||
void BuildFOOTPRINTS_LISTBOX();
|
||||
void BuildLIBRARY_LISTBOX();
|
||||
|
||||
/**
|
||||
* Create or Update the frame showing the current highlighted footprint
|
||||
* and (if showed) the 3D display frame
|
||||
*/
|
||||
void CreateScreenCmp();
|
||||
|
||||
/**
|
||||
* Function SaveFootprintAssociation
|
||||
* saves the edits that the user has done by sending them back to eeschema
|
||||
|
@ -297,13 +294,16 @@ public:
|
|||
|
||||
void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
|
||||
|
||||
/**
|
||||
* Syncronize the toolbar state with the current tool state.
|
||||
*/
|
||||
void SyncToolbars() override;
|
||||
|
||||
private:
|
||||
// UI event handlers.
|
||||
// Keep consistent the display state of toggle menus or tools in toolbar
|
||||
void OnFilterFPbyKeywords( wxUpdateUIEvent& event );
|
||||
void OnFilterFPbyPinCount( wxUpdateUIEvent& event );
|
||||
void OnFilterFPbyLibrary( wxUpdateUIEvent& event );
|
||||
void OnFilterFPbyKeyName( wxUpdateUIEvent& event );
|
||||
/**
|
||||
* Setup the tool system for the CVPCB main frame.
|
||||
*/
|
||||
void setupTools();
|
||||
|
||||
/**
|
||||
* read the .equ files and populate the list of equvalents
|
||||
|
@ -316,6 +316,10 @@ private:
|
|||
|
||||
void refreshAfterComponentSearch (COMPONENT* component);
|
||||
|
||||
// Context menus for the list boxes
|
||||
ACTION_MENU* m_footprintContextMenu;
|
||||
ACTION_MENU* m_componentContextMenu;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
|
|
@ -59,14 +59,6 @@ DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
|
|||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnEditEquFilesList( wxCommandEvent& aEvent )
|
||||
{
|
||||
DIALOG_CONFIG_EQUFILES dlg( this );
|
||||
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CONFIG_EQUFILES::Init()
|
||||
{
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
|
|
@ -27,16 +27,17 @@
|
|||
* class to display the list of available footprints
|
||||
*/
|
||||
|
||||
#include <eda_pattern_match.h>
|
||||
#include <fctsys.h>
|
||||
#include <footprint_filter.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
#include <cvpcb.h>
|
||||
#include <cvpcb_id.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <listboxes.h>
|
||||
#include <cvpcb_id.h>
|
||||
#include <eda_pattern_match.h>
|
||||
#include <footprint_filter.h>
|
||||
|
||||
#include <tools/cvpcb_actions.h>
|
||||
|
||||
FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent,
|
||||
wxWindowID id, const wxPoint& loc,
|
||||
|
@ -215,7 +216,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
|
|||
|
||||
// If the footprint view window is displayed, update the footprint.
|
||||
if( GetParent()->GetFootprintViewerFrame() )
|
||||
GetParent()->CreateScreenCmp();
|
||||
GetParent()->GetToolManager()->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
||||
|
||||
GetParent()->DisplayStatus();
|
||||
|
||||
|
|
|
@ -211,10 +211,9 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event )
|
|||
|
||||
void LIBRARY_LISTBOX::OnSelectLibrary( wxListEvent& event )
|
||||
{
|
||||
wxCommandEvent setLibraryFilterEvent;
|
||||
setLibraryFilterEvent.SetId( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST );
|
||||
setLibraryFilterEvent.SetInt( 1 );
|
||||
GetParent()->OnSelectFilteringFootprint( setLibraryFilterEvent );
|
||||
// Apply the filter
|
||||
GetParent()->SetFootprintFilter(
|
||||
FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY, CVPCB_MAINFRAME::FILTER_ENABLE );
|
||||
|
||||
SetFocus();
|
||||
GetParent()->OnSelectComponent( event );
|
||||
|
|
|
@ -22,15 +22,17 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <bitmaps.h>
|
||||
#include <tool/conditional_menu.h>
|
||||
#include <tool/actions.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/common_control.h>
|
||||
#include "cvpcb_id.h"
|
||||
#include "cvpcb_mainframe.h"
|
||||
#include <menus_helpers.h>
|
||||
#include <pgm_base.h>
|
||||
#include <tool/actions.h>
|
||||
#include <tool/common_control.h>
|
||||
#include <tool/conditional_menu.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <cvpcb_id.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <tools/cvpcb_actions.h>
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::ReCreateMenuBar()
|
||||
|
@ -45,10 +47,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
|
|||
//
|
||||
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool );
|
||||
|
||||
fileMenu->AddItem( ID_SAVE_PROJECT,
|
||||
_( "&Save Schematic\tCtrl+S" ),
|
||||
_( "Save footprint associations in schematic symbol footprint fields" ),
|
||||
save_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
fileMenu->Resolve();
|
||||
|
||||
|
@ -56,19 +55,14 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
|
|||
//
|
||||
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
|
||||
|
||||
prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways );
|
||||
prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
|
||||
prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways );
|
||||
prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
|
||||
prefsMenu->AddItem( wxID_PREFERENCES,
|
||||
_( "Preferences...\tCTRL+," ),
|
||||
_( "Show preferences for all open tools" ),
|
||||
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
prefsMenu->AddSeparator();
|
||||
prefsMenu->AddItem( ID_CVPCB_EQUFILES_LIST_EDIT,
|
||||
_( "Footprint &Association Files..." ),
|
||||
_( "Configure footprint association file (.equ) list. These files are "
|
||||
"used to automatically assign footprint names from symbol values." ),
|
||||
library_table_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
prefsMenu->AddItem( CVPCB_ACTIONS::showEquFileTable, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
prefsMenu->AddSeparator();
|
||||
AddMenuLanguageList( prefsMenu, tool );
|
||||
|
|
|
@ -26,15 +26,15 @@
|
|||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#include <fctsys.h>
|
||||
#include <kiway.h>
|
||||
#include <build_version.h>
|
||||
#include <common.h>
|
||||
#include <confirm.h>
|
||||
#include <build_version.h>
|
||||
#include <macros.h>
|
||||
#include <lib_id.h>
|
||||
#include <fctsys.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <html_messagebox.h>
|
||||
#include <kiway.h>
|
||||
#include <lib_id.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <cvpcb.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
|
@ -390,5 +390,8 @@ bool CVPCB_MAINFRAME::SaveFootprintAssociation( bool doSaveSchematic )
|
|||
SetStatusText( _( "Schematic saved" ), 1 );
|
||||
}
|
||||
|
||||
// Changes are saved, so reset the flag
|
||||
m_modified = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,13 +23,16 @@
|
|||
* @file tool_cvpcb.cpp
|
||||
*/
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include <common.h>
|
||||
#include <fctsys.h>
|
||||
#include <kiface_i.h>
|
||||
#include <common.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <tool/actions.h>
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <cvpcb_id.h>
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <tools/cvpcb_actions.h>
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::ReCreateHToolbar()
|
||||
|
@ -37,35 +40,22 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
|
|||
if( m_mainToolBar )
|
||||
m_mainToolBar->Clear();
|
||||
else
|
||||
m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
||||
|
||||
m_mainToolBar->AddTool( ID_CVPCB_LIB_TABLE_EDIT, wxEmptyString,
|
||||
KiScaledBitmap( config_xpm, this ),
|
||||
_( "Edit footprint library table" ) );
|
||||
m_mainToolBar->Add( ACTIONS::showFootprintLibTable );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxEmptyString,
|
||||
KiScaledBitmap( show_footprint_xpm, this ),
|
||||
_( "View selected footprint" ) );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::showFootprintViewer );
|
||||
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
|
||||
KiScaledBitmap( left_xpm, this ),
|
||||
_( "Select previous unlinked symbol" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxEmptyString,
|
||||
KiScaledBitmap( right_xpm, this ),
|
||||
_( "Select next unlinked symbol" ) );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::gotoPreviousNA );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::gotoNextNA );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
|
||||
KiScaledBitmap( auto_associe_xpm, this ),
|
||||
_( "Perform automatic footprint association" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
|
||||
KiScaledBitmap( delete_association_xpm, this ),
|
||||
_( "Delete all footprint associations" ) );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::autoAssociate );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::deleteAll );
|
||||
|
||||
// Add tools for footprint names filtering:
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
|
@ -75,32 +65,12 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
|
|||
text->SetFont( m_mainToolBar->GetFont().Bold() );
|
||||
m_mainToolBar->AddControl( text );
|
||||
|
||||
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
|
||||
KiScaledBitmap( module_filtered_list_xpm, this ),
|
||||
wxNullBitmap,
|
||||
true, NULL,
|
||||
_( "Filter footprint list by schematic symbol keywords" ),
|
||||
wxEmptyString );
|
||||
|
||||
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
|
||||
KiScaledBitmap( module_pin_filtered_list_xpm, this ),
|
||||
wxNullBitmap,
|
||||
true, NULL,
|
||||
_( "Filter footprint list by pin count" ),
|
||||
wxEmptyString );
|
||||
|
||||
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
|
||||
KiScaledBitmap( module_library_list_xpm, this ),
|
||||
wxNullBitmap, true, NULL,
|
||||
_( "Filter footprint list by library" ),
|
||||
wxEmptyString );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::filterFPbyKeywords, true );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::filterFPbyPin, true );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::filterFPbyLibrary, true );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME,
|
||||
KiScaledBitmap( module_name_filtered_list_xpm, this ),
|
||||
wxNullBitmap, true, NULL,
|
||||
_( "Filter footprint list using a partial name or a pattern" ),
|
||||
wxEmptyString );
|
||||
m_mainToolBar->Add( CVPCB_ACTIONS::filterFPbyDisplayName, true );
|
||||
|
||||
m_tcFilterString = new wxTextCtrl( m_mainToolBar, ID_CVPCB_FILTER_TEXT_EDIT );
|
||||
|
||||
|
@ -110,3 +80,19 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
|
|||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||
m_mainToolBar->Realize();
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::SyncToolbars()
|
||||
{
|
||||
#define filterActive( filt ) ( m_filteringOptions & filt )
|
||||
|
||||
m_mainToolBar->Toggle( CVPCB_ACTIONS::filterFPbyKeywords,
|
||||
filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ) );
|
||||
m_mainToolBar->Toggle( CVPCB_ACTIONS::filterFPbyLibrary,
|
||||
filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) );
|
||||
m_mainToolBar->Toggle( CVPCB_ACTIONS::filterFPbyPin,
|
||||
filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) );
|
||||
m_mainToolBar->Toggle( CVPCB_ACTIONS::filterFPbyDisplayName,
|
||||
filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) );
|
||||
m_mainToolBar->Refresh();
|
||||
}
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <bitmaps.h>
|
||||
#include "cvpcb_actions.h"
|
||||
#include <frame_type.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <listboxes.h>
|
||||
#include <tools/cvpcb_actions.h>
|
||||
|
||||
// Actions, being statically-defined, require specialized I18N handling. We continue to
|
||||
// use the _() macro so that string harvesting by the I18N framework doesn't have to be
|
||||
|
@ -31,10 +33,89 @@
|
|||
#define _(s) s
|
||||
|
||||
|
||||
// CVPCB_SELECTION_TOOL
|
||||
//
|
||||
TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection",
|
||||
AS_GLOBAL, 0, "",
|
||||
"", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere
|
||||
// Selection tool action for the footprint viewer window
|
||||
TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection", AS_GLOBAL,
|
||||
0, "",
|
||||
"",
|
||||
"",
|
||||
NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
|
||||
// Action to show the footprint viewer window
|
||||
TOOL_ACTION CVPCB_ACTIONS::showFootprintViewer( "cvpcb.Control.ShowFootprintViewer", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "View selected footprint" ),
|
||||
_( "View the selected footprint in the footprint viewer" ),
|
||||
show_footprint_xpm );
|
||||
|
||||
|
||||
// Actions to handle management tasks
|
||||
TOOL_ACTION CVPCB_ACTIONS::showEquFileTable( "cvpcb.Control.ShowEquFileTable", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Manage Footprint Association Files" ),
|
||||
_( "Configure footprint association file (.equ) list. These files are "
|
||||
"used to automatically assign footprint names from symbol values." ),
|
||||
library_table_xpm );
|
||||
|
||||
TOOL_ACTION CVPCB_ACTIONS::saveAssociations( "cvpcb.Control.SaveAssocations", AS_GLOBAL,
|
||||
MD_CTRL + 'S', LEGACY_HK_NAME( "Save" ),
|
||||
_( "Save to Schematic" ),
|
||||
_( "Save footprint associations in schematic symbol footprint fields" ),
|
||||
save_xpm );
|
||||
|
||||
// Actions to navigate the component list
|
||||
TOOL_ACTION CVPCB_ACTIONS::gotoNextNA( "cvpcb.Control.GotoNextNA", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Select next unassociated symbol" ),
|
||||
_( "Select next unassociated symbol" ),
|
||||
right_xpm );
|
||||
|
||||
TOOL_ACTION CVPCB_ACTIONS::gotoPreviousNA( "cvpcb.Control.GotoPreviousNA", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Select previous unassociated symbol" ),
|
||||
_( "Select previous unassociated symbol" ),
|
||||
left_xpm );
|
||||
|
||||
|
||||
// Actions to modify component associations
|
||||
TOOL_ACTION CVPCB_ACTIONS::autoAssociate( "cvpcb.Control.AutoAssociate", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Automatically associate footprints" ),
|
||||
_( "Perform automatic footprint association" ),
|
||||
auto_associe_xpm );
|
||||
|
||||
TOOL_ACTION CVPCB_ACTIONS::deleteAll( "cvpcb.Control.DeleteAll", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Delete all footprint associations" ),
|
||||
_( "Delete all footprint associations" ),
|
||||
delete_association_xpm );
|
||||
|
||||
|
||||
// Actions to filter the footprint list
|
||||
TOOL_ACTION CVPCB_ACTIONS::filterFPbyKeywords( "cvpcb.Control.FilterFPByKeyword", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Filter by keyword" ),
|
||||
_( "Filter footprint list by schematic symbol keywords" ),
|
||||
module_filtered_list_xpm, AF_NONE,
|
||||
(void*) FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD );
|
||||
|
||||
TOOL_ACTION CVPCB_ACTIONS::filterFPbyPin( "cvpcb.Control.FilterFPByPin", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Filter by pin count" ),
|
||||
_( "Filter footprint list by pin count" ),
|
||||
module_pin_filtered_list_xpm, AF_NONE,
|
||||
(void*) FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT );
|
||||
|
||||
TOOL_ACTION CVPCB_ACTIONS::filterFPbyLibrary( "cvpcb.Control.FilterFPByLibrary", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Filter by library" ),
|
||||
_( "Filter footprint list by library" ),
|
||||
module_library_list_xpm, AF_NONE,
|
||||
(void*) FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY );
|
||||
|
||||
TOOL_ACTION CVPCB_ACTIONS::filterFPbyDisplayName( "cvpcb.Control.FilterFPByDisplayName", AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Filter by display name" ),
|
||||
_( "Filter footprint list using a partial name or a pattern" ),
|
||||
module_name_filtered_list_xpm, AF_NONE,
|
||||
(void*) FOOTPRINTS_LISTBOX::FILTERING_BY_NAME );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2016 CERN
|
||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -26,9 +26,9 @@
|
|||
#ifndef CVPCB_ACTIONS_H
|
||||
#define CVPCB_ACTIONS_H
|
||||
|
||||
#include <tool/tool_action.h>
|
||||
#include <tool/actions.h>
|
||||
#include <core/optional.h>
|
||||
#include <tool/actions.h>
|
||||
#include <tool/tool_action.h>
|
||||
|
||||
class TOOL_EVENT;
|
||||
class TOOL_MANAGER;
|
||||
|
@ -46,6 +46,28 @@ public:
|
|||
/// Activation of the selection tool
|
||||
static TOOL_ACTION selectionActivate;
|
||||
|
||||
/// Open the footprint viewer
|
||||
static TOOL_ACTION showFootprintViewer;
|
||||
|
||||
/// Navigate the component tree
|
||||
static TOOL_ACTION gotoPreviousNA;
|
||||
static TOOL_ACTION gotoNextNA;
|
||||
|
||||
/// Management actions
|
||||
static TOOL_ACTION saveAssociations;
|
||||
static TOOL_ACTION showEquFileTable;
|
||||
|
||||
/// Footprint Association actions
|
||||
static TOOL_ACTION autoAssociate;
|
||||
static TOOL_ACTION associate;
|
||||
static TOOL_ACTION deleteAll;
|
||||
|
||||
/// Footprint Filtering actions
|
||||
static TOOL_ACTION filterFPbyKeywords;
|
||||
static TOOL_ACTION filterFPbyPin;
|
||||
static TOOL_ACTION filterFPbyLibrary;
|
||||
static TOOL_ACTION filterFPbyDisplayName;
|
||||
|
||||
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
||||
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
|
||||
};
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Ian McInerney <Ian.S.McInerney@ieee.org>
|
||||
* Copyright (C) 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 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 <cstdint>
|
||||
#include <functional>
|
||||
#include <kiface_i.h>
|
||||
#include <kiway_express.h>
|
||||
#include <tool/actions.h>
|
||||
|
||||
#include <cvpcb_mainframe.h>
|
||||
#include <dialogs/dialog_config_equfiles.h>
|
||||
#include <display_footprints_frame.h>
|
||||
#include <listboxes.h>
|
||||
#include <tools/cvpcb_actions.h>
|
||||
#include <tools/cvpcb_control.h>
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
|
||||
CVPCB_CONTROL::CVPCB_CONTROL() :
|
||||
TOOL_INTERACTIVE( "cvpcb.Control" ),
|
||||
m_frame( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_CONTROL::Reset( RESET_REASON aReason )
|
||||
{
|
||||
m_frame = getEditFrame<CVPCB_MAINFRAME>();
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::ShowFootprintViewer( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
|
||||
DISPLAY_FOOTPRINTS_FRAME* fpframe = m_frame->GetFootprintViewerFrame();
|
||||
|
||||
if( !fpframe )
|
||||
{
|
||||
fpframe = (DISPLAY_FOOTPRINTS_FRAME*) m_frame->Kiway().Player(
|
||||
FRAME_CVPCB_DISPLAY, true, m_frame );
|
||||
fpframe->Show( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fpframe->IsIconized() )
|
||||
fpframe->Iconize( false );
|
||||
|
||||
// The display footprint window might be buried under some other
|
||||
// windows, so CreateScreenCmp() on an existing window would not
|
||||
// show any difference, leaving the user confused.
|
||||
// So we want to put it to front, second after our CVPCB_MAINFRAME.
|
||||
// We do this by a little dance of bringing it to front then the main
|
||||
// frame back.
|
||||
wxWindow* focus = m_frame->FindFocus();
|
||||
|
||||
fpframe->Raise(); // Make sure that is visible.
|
||||
m_frame->Raise(); // .. but still we want the focus.
|
||||
|
||||
if( focus )
|
||||
focus->SetFocus();
|
||||
}
|
||||
|
||||
fpframe->InitDisplay();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::ToggleFootprintFilter( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SetFootprintFilter(
|
||||
static_cast<FOOTPRINTS_LISTBOX::FP_FILTER_T>( aEvent.Parameter<intptr_t>() ),
|
||||
CVPCB_MAINFRAME::FILTER_TOGGLE );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::AutoAssociate( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->AutomaticFootprintMatching();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::DeleteAll( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->DeleteAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::ShowEquFileTable( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
DIALOG_CONFIG_EQUFILES dlg( m_frame );
|
||||
dlg.ShowModal();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::SaveAssociations( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SaveFootprintAssociation( true );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::ToNextNA( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->ToNextNA();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CVPCB_CONTROL::ToPreviousNA( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->ToPreviousNA();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_CONTROL::setTransitions()
|
||||
{
|
||||
// Run the footprint viewer
|
||||
Go( &CVPCB_CONTROL::ShowFootprintViewer, CVPCB_ACTIONS::showFootprintViewer.MakeEvent() );
|
||||
|
||||
// Management actions
|
||||
Go( &CVPCB_CONTROL::ShowEquFileTable, CVPCB_ACTIONS::showEquFileTable.MakeEvent() );
|
||||
Go( &CVPCB_CONTROL::SaveAssociations, CVPCB_ACTIONS::saveAssociations.MakeEvent() );
|
||||
Go( &CVPCB_CONTROL::DeleteAll, CVPCB_ACTIONS::deleteAll.MakeEvent() );
|
||||
|
||||
// Navigation actions
|
||||
Go( &CVPCB_CONTROL::ToNextNA, CVPCB_ACTIONS::gotoNextNA.MakeEvent() );
|
||||
Go( &CVPCB_CONTROL::ToPreviousNA, CVPCB_ACTIONS::gotoPreviousNA.MakeEvent() );
|
||||
|
||||
// Footprint association actions
|
||||
Go( &CVPCB_CONTROL::AutoAssociate, CVPCB_ACTIONS::autoAssociate.MakeEvent() );
|
||||
|
||||
// Filter the footprints
|
||||
Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::filterFPbyKeywords.MakeEvent() );
|
||||
Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::filterFPbyLibrary.MakeEvent() );
|
||||
Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::filterFPbyPin.MakeEvent() );
|
||||
Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::filterFPbyDisplayName.MakeEvent() );
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Ian McInerney <Ian.S.McInerney@ieee.org>
|
||||
* Copyright (C) 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 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 CVPCB_CONTROL_H_
|
||||
#define CVPCB_CONTROL_H_
|
||||
|
||||
#include <tool/tool_interactive.h>
|
||||
|
||||
#include <cvpcb_mainframe.h>
|
||||
|
||||
|
||||
/**
|
||||
* Class CVPCB_CONTROL
|
||||
*
|
||||
* Handles actions in main cvpcb window.
|
||||
*/
|
||||
|
||||
class CVPCB_CONTROL : public TOOL_INTERACTIVE
|
||||
{
|
||||
public:
|
||||
CVPCB_CONTROL();
|
||||
~CVPCB_CONTROL() {}
|
||||
|
||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
/**
|
||||
* Perform automatic footprint association.
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int AutoAssociate( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Delete all associations.
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int DeleteAll( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Move the selected component to the next not associated one.
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int ToNextNA( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Move the selected component to the previous not associated one.
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int ToPreviousNA( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Show the dialog to modify the included footprint association files (.equ)
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int ShowEquFileTable( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Save the associations to the schematic.
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int SaveAssociations( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Create or Update the frame showing the current highlighted footprint
|
||||
* and (if showed) the 3D display frame.
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int ShowFootprintViewer( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Filter the footprint list by toggling the given filter type.
|
||||
* The event parameter corresponds to the filter type (using the FP_FILTER_T from the
|
||||
* FOOTPRINTS_LISTBOX class)
|
||||
*
|
||||
* @param aEvent is the event generated by the tool framework
|
||||
*/
|
||||
int ToggleFootprintFilter( const TOOL_EVENT& aEvent );
|
||||
|
||||
/*
|
||||
* Sets up handlers for various events.
|
||||
*/
|
||||
void setTransitions() override;
|
||||
|
||||
private:
|
||||
CVPCB_MAINFRAME* m_frame;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue