47#include <wx/statline.h>
48#include <wx/stattext.h>
61#include <wx/settings.h>
64#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
70 m_viewerPendingUpdate( false )
87 icon.CopyFromBitmap(
KiBitmap( BITMAPS::icon_cvpcb ) );
90 SetAutoLayout(
true );
111 .Caption(
_(
"Footprint Libraries" ) )
115 .Caption(
_(
"Symbol : Footprint Assignments" ) ) );
118 .Caption(
_(
"Filtered Footprints" ) )
122 auto bottomPanel =
new wxPanel(
this );
123 auto panelSizer =
new wxBoxSizer( wxVERTICAL );
125 wxFlexGridSizer* fgSizerStatus =
new wxFlexGridSizer( 3, 1, 0, 0 );
126 fgSizerStatus->SetFlexibleDirection( wxBOTH );
127 fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
129 m_statusLine1 =
new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
132 m_statusLine2 =
new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
135 m_statusLine3 =
new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
138 panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
145 auto buttonsSizer =
new wxBoxSizer( wxHORIZONTAL );
146 auto sdbSizer =
new wxStdDialogButtonSizer();
149 _(
"Apply, Save Schematic && Continue" ) );
152 auto sdbSizerOK =
new wxButton( bottomPanel, wxID_OK );
153 sdbSizer->AddButton( sdbSizerOK );
154 auto sdbSizerCancel =
new wxButton( bottomPanel, wxID_CANCEL );
155 sdbSizer->AddButton( sdbSizerCancel );
158 buttonsSizer->Add( sdbSizer, 0, 0, 5 );
159 panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
161 bottomPanel->SetSizer( panelSizer );
164 sdbSizerOK->SetDefault();
167 m_auimgr.AddPane( bottomPanel,
EDA_PANE().HToolbar().Name(
"Buttons" ).Bottom().Layer(6) );
176 if( cfg->m_LibrariesWidth > 0 )
178 wxAuiPaneInfo& librariesPane =
m_auimgr.GetPane(
"Libraries" );
182 librariesPane.MinSize( cfg->m_LibrariesWidth, -1 );
183 librariesPane.BestSize( cfg->m_LibrariesWidth, -1 );
184 librariesPane.MaxSize( cfg->m_LibrariesWidth, -1 );
185 librariesPane.Fixed();
189 librariesPane.MinSize( 20, -1 );
190 librariesPane.Resizable();
194 if( cfg->m_FootprintsWidth > 0 )
196 wxAuiPaneInfo& footprintsPane =
m_auimgr.GetPane(
"Footprints" );
200 footprintsPane.MinSize( cfg->m_FootprintsWidth, -1 );
201 footprintsPane.BestSize( cfg->m_FootprintsWidth, -1 );
202 footprintsPane.MaxSize( cfg->m_FootprintsWidth, -1 );
203 footprintsPane.Fixed();
207 footprintsPane.MinSize( 20, -1 );
208 footprintsPane.Resizable();
288#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
289#define CHECK( x ) ACTION_CONDITIONS().Check( x )
327 [
this]( wxMouseEvent& )
333 [
this]( wxMouseEvent& )
340 [
this]( wxCommandEvent& )
348 [
this]( wxCommandEvent& )
355 [
this]( wxCommandEvent& )
362 [
this]( wxCommandEvent& )
367 [
this]( wxCommandEvent& )
377 []( wxSizeEvent& aEvent )
397 && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
522 if( footprintListHasFocus )
524 else if( symbolListHasFocus )
562 for(
const auto& assoc : curEntry )
565 redoEntries.emplace_back( assoc.Reverse() );
582 bool firstAssoc =
true;
584 for(
const auto& assoc : curEntry )
593 const wxString& aValue,
const wxString& aFootprint )
597 wxString desc = wxString::Format( wxT(
"%3d " ), idx );
599 for(
int ii = aReference.Length(); ii < 8; ++ii )
602 desc += aReference + wxT(
" - " );
604 for(
int ii = aValue.Length(); ii < 16; ++ii )
607 desc += aValue + wxT(
" : " ) + aFootprint;
614 bool aNewEntry,
bool aAddUndoItem )
621 if( symbol ==
nullptr )
630 wxString msg = wxString::Format(
_(
"'%s' is not a valid footprint." ),
642 const std::vector<KIID>& kiids = candidate->
GetKIIDs();
644 if( std::find( kiids.begin(), kiids.end(),
id ) != kiids.end() )
714 if( aSymbol ==
nullptr )
733 wxString candidateName;
737 candidateName = msg.AfterFirst( wxChar(
' ' ) );
739 if( footprintName.Cmp( candidateName ) == 0 )
755 int option = aFilter;
775 wxString filters, msg;
793 filters +=
_(
"Keywords" );
796 filters += wxString::Format( wxT(
" (%s)" ), msg );
804 msg = wxString::Format( wxT(
"%i" ), symbol->
GetPinCount() );
806 if( !filters.IsEmpty() )
807 filters += wxT(
", " );
809 filters +=
_(
"Pin Count" );
812 filters += wxString::Format( wxT(
" (%s)" ), msg );
819 if( !filters.IsEmpty() )
820 filters += wxT(
", " );
822 filters +=
_(
"Library" );
825 filters += wxString::Format( wxT(
" (%s)" ), msg );
830 if( !textFilter.IsEmpty() )
832 if( !filters.IsEmpty() )
833 filters += wxT(
", " );
835 filters +=
_(
"Search Text" ) + wxString::Format( wxT(
" (%s)" ), textFilter );
838 if( filters.IsEmpty() )
839 msg =
_(
"No Filtering" );
841 msg.Printf(
_(
"Filtered by %s" ), filters );
855 msg = wxString::Format(
_(
"Description: %s; Keywords: %s" ),
887 msg = wxString::Format(
_(
"Library location: %s" ), fptbl->
GetFullURI( lib ) );
889 msg = wxString::Format(
_(
"Library location: unknown" ) );
902 wxMessageBox(
_(
"No PCB footprint libraries are listed in the current footprint "
903 "library table." ),
_(
"Configuration Error" ), wxOK | wxICON_ERROR );
925 std::string command =
"$SELECT: ";
927 if( aClearSelectionOnly )
973 wxString msg = wxString::Format(
_(
"Error loading schematic.\n%s" ),
974 ioe.
What().GetData() );
975 wxMessageBox( msg,
_(
"Load Error" ), wxOK | wxICON_ERROR );
996 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
1014 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
1058 std::set<wxString> pinnedMatches;
1059 std::set<wxString> otherMatches;
1063 [&](
const wxString& aNickname )
1068 pinnedMatches.insert( aNickname );
1072 otherMatches.insert( aNickname );
1079 wxArrayString libNames;
1083 for(
const wxString& libNickName : libNickNames )
1087 for(
const wxString& nickname : pinnedMatches )
1090 for(
const wxString& nickname : otherMatches )
1116 else if( aIndex < m_symbolsListBox->GetCount() )
1130 std::vector<unsigned int> idx;
1141 std::iota( idx.begin(), idx.end(), 0 );
1151 idx.emplace_back( lastIdx );
1154 while( lastIdx > 0 )
1156 idx.emplace_back( lastIdx );
1165 idx.emplace_back( i );
1173 idx.emplace_back( i );
1178 wxASSERT_MSG(
false,
"Invalid symbol selection criteria" );
1239 default: wxFAIL_MSG(
"Invalid status row number" );
break;
1254 const std::string& payload = mail.
GetPayload();
constexpr EDA_IU_SCALE unityScale
static PGM_BASE * process
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Manage TOOL_ACTION objects.
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...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Handle actions that are shared between different applications.
Store all of the related footprint information found in a netlist.
const wxString & GetReference() const
const wxString & GetValue() const
void SetFPID(const LIB_ID &aFPID)
const wxArrayString & GetFootprintFilters() const
const std::vector< KIID > & GetKIIDs() const
const LIB_ID & GetFPID() const
Gather all the actions that are shared by tools.
static TOOL_ACTION saveAssociationsToFile
static TOOL_ACTION FilterFPbyLibrary
static TOOL_ACTION filterFPbyPin
static TOOL_ACTION deleteAssoc
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
A class to define a footprint association to be made in cvpcb.
unsigned int GetComponentIndex() const
Get the index of the component to modify the association of.
LIB_ID GetNewFootprint() const
Get the new footprint to associate to the component.
bool readNetListAndFpFiles(const std::string &aNetlist)
Load the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void ShowChangedLanguage() override
void SendComponentSelectionToSch(bool aClearSelectionOnly=false)
Send a remote command to Eeschema via a socket,.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
CVPCB_UNDO_REDO_LIST m_redoList
ACTION_MENU * m_symbolsContextMenu
wxStaticText * m_statusLine3
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const
Find out which control currently has focus.
CVPCB_FILTER_ACTION
The action to apply to a footprint filter when it is modified.
@ FILTER_DISABLE
Turn off the filter.
@ FILTER_ENABLE
Turn on the filter.
@ FILTER_TOGGLE
Toggle the filter state.
void onTextFilterChangedTimer(wxTimerEvent &aEvent)
void onTextFilterChanged(wxCommandEvent &event)
LIBRARY_LISTBOX * m_librariesListBox
void setupTools()
Setup the tool system for the CVPCB main frame.
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
wxButton * m_saveAndContinue
void RedoAssociation()
Redo the most recently undone association.
bool LoadFootprintFiles()
Read the list of footprint (*.mod files) and generate the list of footprints.
void BuildFootprintsListBox()
void SetStatusText(const wxString &aText, int aNumber=0) override
wxString GetSelectedFootprint()
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
CVPCB_MAINFRAME(KIWAY *aKiway, wxWindow *aParent)
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.
wxStaticText * m_statusLine1
void setupEventHandlers()
Setup event handlers.
void BuildLibrariesListBox()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetSelectedComponent(int aIndex, bool aSkipUpdate=false)
Set the currently selected component in the components listbox.
ACTION_MENU * m_footprintContextMenu
void BuildSymbolsListBox()
CONTROL_TYPE
The type of the controls present in the application.
@ CONTROL_NONE
No controls have focus.
@ CONTROL_LIBRARY
Library listbox.
@ CONTROL_FOOTPRINT
Footprint listbox.
@ CONTROL_COMPONENT
Component listbox.
bool m_skipComponentSelect
wxString formatSymbolDesc(int idx, const wxString &aReference, const wxString &aValue, const wxString &aFootprint)
void SetFocusedControl(CVPCB_MAINFRAME::CONTROL_TYPE aControl)
Set the focus to a specific control.
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
void UndoAssociation()
Undo the most recent associations that were performed.
void DisplayStatus()
Update the information displayed on the status bar at bottom of the main frame.
ACTION_TOOLBAR * m_mainToolBar
void RefreshFootprintViewer()
CVPCB_UNDO_REDO_LIST m_undoList
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
FOOTPRINT_LIST * m_FootprintsList
wxWindow * GetToolCanvas() const override
Canvas access.
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 AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
bool m_viewerPendingUpdate
void updateFootprintViewerOnIdle(wxIdleEvent &aEvent)
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxStaticText * m_statusLine2
FOOTPRINTS_LISTBOX * m_footprintListBox
CRITERIA
Criteria to use to identify sets of components.
@ ALL_COMPONENTS
All components.
@ NA_COMPONENTS
Not associated components.
@ SEL_COMPONENTS
Selected components.
@ ASSOC_COMPONENTS
Associated components.
SYMBOLS_LISTBOX * m_symbolsListBox
TOOL_DISPATCHER * m_toolDispatcher
int readSchematicNetlist(const std::string &aNetlist)
Read the netlist (.net) file built on the fly by Eeschema.
bool SaveFootprintAssociation(bool doSaveSchematic)
Save the edits that the user has done by sending them back to Eeschema via the kiway.
wxTextCtrl * m_tcFilterString
COMPONENT * GetSelectedComponent()
Get the selected component from the component listbox.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void ReCreateMenuBar()
Recreates the menu bar.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Class that groups generic conditions for editor states.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
void DeselectAll()
Remove all selection in lists which can have more than one item selected.
Read the new s-expression based KiCad netlist format.
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
void AppendLine(const wxString &text)
wxString GetSelectedLibrary()
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
static const wxString GetPinningSymbol()
unsigned GetCount() const
void Clear()
Remove all components from the netlist.
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
The backing store for a PROJECT, in JSON format.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
virtual PROJECT_FILE & GetProjectFile() const
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
wxArrayString m_SymbolList
void SetString(unsigned linecount, const wxString &text)
void SetSelection(int index, bool State=true)
void AppendWarning(int index)
void RemoveWarning(int index)
const char * c_str() const
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
@ ID_CVPCB_FOOTPRINT_LIST
@ ID_CVPCB_COMPONENT_LIST
#define CVPCB_MAINFRAME_NAME
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
#define KICAD_DEFAULT_DRAWFRAME_STYLE
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
This file contains miscellaneous commonly used macros and functions.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
wxFont GetMonospacedUIFont()
wxFont GetStatusFont(wxWindow *aWindow)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
std::vector< wxString > pinned_fp_libs