43 #include <wx/statline.h> 44 #include <wx/stattext.h> 56 #include <wx/button.h> 57 #include <wx/settings.h> 60 #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" ) 84 SetAutoLayout(
true );
103 .Caption(
_(
"Footprint Libraries" ) )
107 .Caption(
_(
"Symbol : Footprint Assignments" ) ) );
110 .Caption(
_(
"Filtered Footprints" ) )
114 auto bottomPanel =
new wxPanel(
this );
115 auto panelSizer =
new wxBoxSizer( wxVERTICAL );
117 wxFlexGridSizer* fgSizerStatus =
new wxFlexGridSizer( 3, 1, 0, 0 );
118 fgSizerStatus->SetFlexibleDirection( wxBOTH );
119 fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
121 m_statusLine1 =
new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
124 m_statusLine2 =
new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
127 m_statusLine3 =
new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
130 panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
132 wxStaticLine* staticline1 =
new wxStaticLine( bottomPanel );
133 panelSizer->Add( staticline1, 0, wxEXPAND, 5 );
140 auto buttonsSizer =
new wxBoxSizer( wxHORIZONTAL );
141 auto sdbSizer =
new wxStdDialogButtonSizer();
144 _(
"Apply, Save Schematic && Continue" ) );
147 auto sdbSizerOK =
new wxButton( bottomPanel, wxID_OK );
148 sdbSizer->AddButton( sdbSizerOK );
149 auto sdbSizerCancel =
new wxButton( bottomPanel, wxID_CANCEL );
150 sdbSizer->AddButton( sdbSizerCancel );
153 buttonsSizer->Add( sdbSizer, 0, 0, 5 );
154 panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
156 bottomPanel->SetSizer( panelSizer );
159 sdbSizerOK->SetDefault();
162 m_auimgr.AddPane( bottomPanel,
EDA_PANE().HToolbar().Name( wxT(
"Buttons" ) ).Bottom().Layer(6) );
169 if( cfg->m_LibrariesWidth > 0 )
171 wxAuiPaneInfo& librariesPane =
m_auimgr.GetPane( wxT(
"Libraries" ) );
175 librariesPane.MinSize( cfg->m_LibrariesWidth, -1 );
176 librariesPane.BestSize( cfg->m_LibrariesWidth, -1 );
177 librariesPane.MaxSize( cfg->m_LibrariesWidth, -1 );
178 librariesPane.Fixed();
182 librariesPane.MinSize( 20, -1 );
183 librariesPane.Resizable();
187 if( cfg->m_FootprintsWidth > 0 )
189 wxAuiPaneInfo& footprintsPane =
m_auimgr.GetPane( wxT(
"Footprints" ) );
193 footprintsPane.MinSize( cfg->m_FootprintsWidth, -1 );
194 footprintsPane.BestSize( cfg->m_FootprintsWidth, -1 );
195 footprintsPane.MaxSize( cfg->m_FootprintsWidth, -1 );
196 footprintsPane.Fixed();
200 footprintsPane.MinSize( 20, -1 );
201 footprintsPane.Resizable();
276 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 277 #define CHECK( x ) ACTION_CONDITIONS().Check( x ) 315 [
this]( wxMouseEvent& )
321 [
this]( wxMouseEvent& )
328 [
this]( wxCommandEvent& )
336 [
this]( wxCommandEvent& )
343 [
this]( wxCommandEvent& )
350 [
this]( wxCommandEvent& )
355 [
this]( wxCommandEvent& )
365 []( wxSizeEvent& aEvent )
382 && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
436 wxString libraryName;
484 for(
const auto& assoc : curEntry )
487 redoEntries.emplace_back( assoc.Reverse() );
504 bool firstAssoc =
true;
506 for(
const auto& assoc : curEntry )
515 const wxString& aValue,
const wxString& aFootprint )
521 for(
int ii = aReference.Length(); ii < 8; ++ii )
524 desc += aReference + wxT(
" - " );
526 for(
int ii = aValue.Length(); ii < 16; ++ii )
529 desc += aValue + wxT(
" : " ) + aFootprint;
536 bool aNewEntry,
bool aAddUndoItem )
543 if( symbol ==
nullptr )
564 const std::vector<KIID>& kiids = candidate->
GetKIIDs();
566 if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
624 if( aSymbol ==
nullptr )
643 wxString candidateName;
647 candidateName = msg.AfterFirst( wxChar(
' ' ) );
649 if( footprintName.Cmp( candidateName ) == 0 )
668 int option = aFilter;
688 wxString filters, msg;
706 filters +=
_(
"Keywords" );
719 if( !filters.IsEmpty() )
720 filters += wxT(
", " );
722 filters +=
_(
"Pin Count" );
732 if( !filters.IsEmpty() )
733 filters += wxT(
", " );
735 filters +=
_(
"Library" );
743 if( !textFilter.IsEmpty() )
745 if( !filters.IsEmpty() )
746 filters += wxT(
", " );
751 if( filters.IsEmpty() )
752 msg =
_(
"No Filtering" );
754 msg.Printf(
_(
"Filtered by %s" ), filters );
815 wxMessageBox(
_(
"No PCB footprint libraries are listed in the current footprint " 816 "library table." ),
_(
"Configuration Error" ), wxOK | wxICON_ERROR );
840 std::string packet =
"$CLEAR: \"HIGHLIGHTED\"";
847 if( aClearHighligntOnly )
884 ioe.
What().GetData() );
885 wxMessageBox( msg,
_(
"Load Error" ), wxOK | wxICON_ERROR );
906 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
924 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
957 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
969 wxArrayString libNames;
973 for(
const wxString& libNickName : libNickNames )
974 libNames.Add( libNickName );
1000 else if( aIndex < m_symbolsListBox->GetCount() )
1014 std::vector<unsigned int> idx;
1025 std::iota( idx.begin(), idx.end(), 0 );
1035 idx.emplace_back( lastIdx );
1038 while( lastIdx > 0 )
1040 idx.emplace_back( lastIdx );
1049 idx.emplace_back( i );
1057 idx.emplace_back( i );
1062 wxASSERT_MSG(
false, wxT(
"Invalid symbol selection criteria" ) );
1073 return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
1136 default: wxFAIL_MSG( wxT(
"Invalid status row number" ) );
break;
1151 const std::string& payload = mail.
GetPayload();
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
void SetLibraryList(const wxArrayString &aList)
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
const UTF8 & GetLibItemName() const
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
CONTROL_TYPE
The type of the controls present in the application.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
FOOTPRINT_LIST * m_FootprintsList
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Read the new s-expression based KiCad netlist format.
CVPCB_FILTER_ACTION
The action to apply to a footprint filter when it is modified.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
ACTION_MENU * m_footprintContextMenu
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void SetFPID(const LIB_ID &aFPID)
This file is part of the common library.
static TOOL_ACTION saveAssociationsToFile
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetSelection(int index, bool State=true)
void SendMessageToEESCHEMA(bool aClearHighligntOnly=false)
Send a remote command to Eeschema via a socket,.
#define CVPCB_MAINFRAME_NAME
void UndoAssociation()
Undo the most recent associations that were performed.
void DeselectAll()
Remove all selection in lists which can have more than one item selected.
wxFont GetMonospacedUIFont()
void SetString(unsigned linecount, const wxString &text)
void AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
void setupEventHandlers()
Setup event handlers.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
LIB_ID GetNewFootprint() const
Get the new footprint to associate to the component.
void RedoAssociation()
Redo the most recently undone association.
int ReadSchematicNetlist(const std::string &aNetlist)
Read the netlist (.net) file built on the fly by Eeschema.
unsigned GetCount() const
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
bool m_skipComponentSelect
void SetFocusedControl(CVPCB_MAINFRAME::CONTROL_TYPE aControl)
Set the focus to a specific control.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
Manage TOOL_ACTION objects.
wxStaticText * m_statusLine3
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
bool LoadFootprintFiles()
Read the list of footprint (*.mod files) and generate the list of footprints.
Class that groups generic conditions for editor states.
This file contains miscellaneous commonly used macros and functions.
const char * c_str() const
ACTION_MENU * m_symbolsContextMenu
const LIB_ID & GetFPID() const
static TOOL_ACTION FilterFPbyLibrary
void BuildFootprintsListBox()
unsigned int GetComponentIndex() const
Get the index of the component to modify the association of.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void ShowChangedLanguage() override
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const
Find out which control currently has focus.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
virtual const wxString What() const
A composite of Problem() and Where()
void SetSelectedComponent(int aIndex, bool aSkipUpdate=false)
Set the currently selected component in the components listbox.
ACTION_TOOLBAR * m_mainToolBar
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
wxArrayString m_SymbolList
const wxString & GetReference() const
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
wxString GetSelectedLibrary()
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SYMBOLS_LISTBOX * m_symbolsListBox
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
void SetStatusText(const wxString &aText, int aNumber=0) override
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
CRITERIA
Criteria to use to identify sets of components.
static TOOL_ACTION deleteAssoc
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void ReCreateMenuBar() override
Recreates the menu bar.
CVPCB_UNDO_REDO_LIST m_undoList
Gather all the actions that are shared by tools.
wxControl * GetFocusedControlObject() const
Get a pointer to the currently focused control.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Handle actions that are shared between different applications.
TOOL_DISPATCHER * m_toolDispatcher
Specialization of the wxAuiPaneInfo class for KiCad panels.
void BuildSymbolsListBox()
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
wxFont GetStatusFont(wxWindow *aWindow)
Store all of the related footprint information found in a netlist.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
wxStaticText * m_statusLine2
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
wxString GetSelectedFootprint()
void Clear()
Remove all components from the netlist.
void doCloseWindow() override
bool ReadNetListAndFpFiles(const std::string &aNetlist)
Load the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.
CVPCB_MAINFRAME(KIWAY *aKiway, wxWindow *aParent)
static TOOL_ACTION filterFPbyPin
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
CVPCB_UNDO_REDO_LIST m_redoList
COMPONENT * GetSelectedComponent()
Get the selected component from the component listbox.
FOOTPRINTS_LISTBOX * m_footprintListBox
void BuildLibrariesListBox()
A class to define a footprint association to be made in cvpcb.
wxString formatSymbolDesc(int idx, const wxString &aReference, const wxString &aValue, const wxString &aFootprint)
const wxString & GetValue() const
const wxArrayString & GetFootprintFilters() const
wxWindow * GetToolCanvas() const override
Canvas access.
void SetFootprintFilter(FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction)
Set a filter criteria to either on/off or toggle the criteria.
std::vector< unsigned int > GetComponentIndices(CVPCB_MAINFRAME::CRITERIA aCriteria=CVPCB_MAINFRAME::ALL_COMPONENTS)
Get the indices for all the components meeting the specified criteria in the components listbox.
void OnEnterFilteringText(wxCommandEvent &event)
Called each time the text of m_tcFilterString is changed.
Not associated components.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
LIBRARY_LISTBOX * m_librariesListBox
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
void DisplayStatus()
Update the information displayed on the status bar at bottom of the main frame.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
wxButton * m_saveAndContinue
bool IsSingle() const
Is this KIFACE running under single_top?
void setupTools()
Setup the tool system for the CVPCB main frame.
wxStaticText * m_statusLine1
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
bool SaveFootprintAssociation(bool doSaveSchematic)
Save the edits that the user has done by sending them back to Eeschema via the kiway.
const std::vector< KIID > & GetKIIDs() const