KiCad PCB EDA Suite
CVPCB_MAINFRAME Class Reference

The CvPcb application main window. More...

#include <cvpcb_mainframe.h>

Inheritance diagram for CVPCB_MAINFRAME:
KIWAY_PLAYER EDA_BASE_FRAME KIWAY_HOLDER

Public Member Functions

 ~CVPCB_MAINFRAME ()
 
bool OpenProjectFiles (const std::vector< wxString > &aFileSet, int aCtl=0) override
 
void KiwayMailIn (KIWAY_EXPRESS &aEvent) override
 Function KiwayMailIn receives KIWAY_EXPRESS messages from other players. More...
 
DISPLAY_FOOTPRINTS_FRAMEGetFootprintViewerFrame ()
 
void OnSelectComponent (wxListEvent &event)
 Function OnSelectComponent Called when clicking on a component in component list window. More...
 
void OnEditFootprintLibraryTable (wxCommandEvent &event)
 Function OnEditFootprintLibraryTable displays the footprint library table editing dialog and updates the global and local footprint tables accordingly. More...
 
void OnQuit (wxCommandEvent &event)
 
void OnCloseWindow (wxCloseEvent &Event)
 
void OnSize (wxSizeEvent &SizeEvent)
 
void ReCreateHToolbar ()
 
virtual void ReCreateMenuBar () override
 (Re)Create the menubar for the CvPcb mainframe More...
 
void ChangeFocus (bool aMoveRight)
 
void ToFirstNA (wxCommandEvent &event)
 
void ToPreviousNA (wxCommandEvent &event)
 
void DelAssociations (wxCommandEvent &event)
 Function DelAssociations removes all component footprint associations already made. More...
 
void SaveQuitCvpcb (wxCommandEvent &event)
 
void OnConfigurePaths (wxCommandEvent &aEvent)
 
void OnEditEquFilesList (wxCommandEvent &aEvent)
 Function OnEditEquFilesList envokes the equ files list edit dialog. More...
 
void OnKeepOpenOnSave (wxCommandEvent &event)
 
void DisplayModule (wxCommandEvent &event)
 
void AutomaticFootprintMatching (wxCommandEvent &event)
 Called by the automatic association button Read *.equ files to try to find corresponding footprint for each component that is not already linked to a footprint ( a "free" component ) format of a line: 'cmp_ref' 'footprint_name'. More...
 
void DisplayDocFile (wxCommandEvent &event)
 
void OnSelectFilteringFootprint (wxCommandEvent &event)
 Function OnSelectFilteringFootprint is the command event handler for enabling and disabling footprint filtering. More...
 
void OnEnterFilteringText (wxCommandEvent &event)
 Function OnEnterFilteringText Is called each time the text of m_tcFilterString is changed. More...
 
void SetNewPkg (const wxString &aFootprintName)
 Function SetNewPkg links the footprint to the current selected component and selects the next component. More...
 
void BuildCmpListBox ()
 
void BuildFOOTPRINTS_LISTBOX ()
 
void BuildLIBRARY_LISTBOX ()
 
void CreateScreenCmp ()
 Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display frame. More...
 
void SaveFootprintAssociation ()
 Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eeschema via the kiway. More...
 
bool ReadNetListAndLinkFiles (const std::string &aNetlist)
 Function ReadNetList reads the netlist (.net) file defined by #m_NetlistFileName. More...
 
int ReadSchematicNetlist (const std::string &aNetlist)
 
void LoadProjectFile ()
 Function LoadProjectFile reads the CvPcb configuration parameter from the project (.pro) file aFileName. More...
 
void SaveProjectFile ()
 Function SaveProjectFile Saves the CvPcb configuration parameter from the project (.pro) file aFileName. More...
 
void LoadSettings (wxConfigBase *aCfg) override
 Function LoadSettings loads common frame parameters from a configuration file. More...
 
void SaveSettings (wxConfigBase *aCfg) override
 Function SaveSettings saves common frame parameters to a configuration data file. More...
 
void DisplayStatus ()
 Function DisplayStatus updates the information displayed on the status bar at bottom of the main frame. More...
 
bool LoadFootprintFiles ()
 Function LoadFootprintFiles reads the list of footprint (*.mod files) and generate the list of footprints. More...
 
PARAM_CFG_ARRAYGetProjectFileParameters (void)
 Function GetProjectFileParameters return project file parameter list for CvPcb. More...
 
void UpdateTitle ()
 Function UpdateTitle sets the main window title bar text. More...
 
void SendMessageToEESCHEMA ()
 Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "reference" put cursor on component anchor. More...
 
COMPONENTGetSelectedComponent ()
 
const wxString GetSelectedFootprint ()
 
VTBL_ENTRY bool ShowModal (wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
 Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until this KIWAY_PLAYER derivative calls DismissModal(). More...
 
bool Destroy () override
 Our version of Destroy() which is virtual from wxWidgets. More...
 
bool ProcessEvent (wxEvent &aEvent) override
 Function ProcessEvent overrides the default process event handler to implement the auto save feature. More...
 
bool Enable (bool enable) override
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
void GetKicadHelp (wxCommandEvent &event)
 
void GetKicadContribute (wxCommandEvent &event)
 
void GetKicadAbout (wxCommandEvent &event)
 
void PrintMsg (const wxString &text)
 
wxString ConfigBaseName ()
 Function ConfigBaseName. More...
 
virtual void SaveProjectSettings (bool aAskForSave)
 Function SaveProjectSettings saves changes to the project settings to the project (.pro) file. More...
 
virtual void OnSelectPreferredEditor (wxCommandEvent &event)
 Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit or display files (reports ... More...
 
int ReadHotkeyConfig (struct EDA_HOTKEY_CONFIG *aDescList)
 Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys. More...
 
virtual int WriteHotkeyConfig (struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
 Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mechanism or a file. More...
 
int ReadHotkeyConfigFile (const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
 Function ReadHotkeyConfigFile Read an old configuration file (&ltfile&gt.key) and fill the current hotkey list with hotkeys. More...
 
void ImportHotkeyConfigFromFile (EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
 Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it. More...
 
void ExportHotkeyConfigToFile (EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
 Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
 Function GetFileFromHistory fetches the file name from the file history list. More...
 
void UpdateFileHistory (const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
 Function UpdateFileHistory Updates the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
bool IsWritable (const wxFileName &aFileName)
 Function IsWritable checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName, const wxString &aBackupFileExtension)
 Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
virtual void ShowChangedLanguage ()
 Function ShowChangedLanguage redraws the menus and what not in current language. More...
 
virtual void ShowChangedIcons ()
 Function ShowChangedIcons redraws items menus after a icon was changed option. More...
 
void AddMenuIconsOptions (wxMenu *MasterMenu)
 Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice, and add it as submenu to MasterMenu. More...
 
bool PostCommandMenuEvent (int evt_type)
 Function PostCommandMenuEvent. More...
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Public Attributes

wxArrayString m_ModuleLibNames
 
wxArrayString m_EquFilesNames
 
wxString m_DocModulesFileName
 
std::unique_ptr< FOOTPRINT_LISTm_FootprintsList
 

Protected Member Functions

 CVPCB_MAINFRAME (KIWAY *aKiway, wxWindow *aParent)
 
bool IsModal ()
 
void SetModal (bool aIsModal)
 
bool IsDismissed ()
 Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been dismissed yet with DismissModal(). More...
 
void DismissModal (bool aRetVal, const wxString &aResult=wxEmptyString)
 
void kiway_express (KIWAY_EXPRESS &aEvent)
 event handler, routes to derivative specific virtual KiwayMailIn() More...
 
void language_change (wxCommandEvent &event)
 Function language_change is an event handler called on a language menu selection. More...
 
void OnChangeIconsOptions (wxCommandEvent &event) override
 Function OnChangeIconsOptions is an event handler called on a icons options in menus or toolbars menu selection. More...
 
void onAutoSaveTimer (wxTimerEvent &aEvent)
 Function onAutoSaveTimer handles the auto save timer event. More...
 
virtual bool isAutoSaveRequired () const
 Function autoSaveRequired returns the auto save status of the application. More...
 
virtual bool doAutoSave ()
 Function doAutoSave should be overridden by the derived class to handle the auto save feature. More...
 
virtual wxConfigBase * config ()
 Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
virtual const SEARCH_STACKsys_search ()
 Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_MANAGER_FRAME. More...
 
virtual wxString help_name ()
 

Protected Attributes

int m_undefinedComponentCnt
 
bool m_modified
 
bool m_skipComponentSelect
 
PARAM_CFG_ARRAY m_projectFileParams
 
bool m_modal
 
WX_EVENT_LOOPm_modal_loop
 
wxWindow * m_modal_resultant_parent
 
wxString m_modal_string
 
bool m_modal_ret_val
 
FRAME_T m_Ident
 Id Type (pcb, schematic, library..) More...
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_configFrameName
 prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTOR is used More...
 
wxString m_AboutTitle
 Name of program displayed in About. More...
 
wxAuiManager m_auimgr
 
bool m_hasAutoSave
 Flag to indicate if this frame supports auto save. More...
 
bool m_autoSaveState
 Flag to indicate the last auto save state. More...
 
int m_autoSaveInterval
 The auto save interval time in seconds. More...
 
wxTimer * m_autoSaveTimer
 The timer used to implement the auto save feature;. More...
 
wxString m_perspective
 wxAuiManager perspective. More...
 
wxString m_mruPath
 Most recently used path. More...
 

Private Member Functions

void OnUpdateKeepOpenOnSave (wxUpdateUIEvent &event)
 
void OnFilterFPbyKeywords (wxUpdateUIEvent &event)
 
void OnFilterFPbyPinCount (wxUpdateUIEvent &event)
 
void OnFilterFPbyLibrary (wxUpdateUIEvent &event)
 
void OnFilterFPbyKeyName (wxUpdateUIEvent &event)
 
int buildEquivalenceList (FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=NULL)
 read the .equ files and populate the list of equvalents More...
 
void refreshAfterComponentSearch (COMPONENT *component)
 

Private Attributes

wxArrayString m_footprintListEntries
 
wxString m_currentSearchPattern
 
bool m_keepCvpcbOpen
 
NETLIST m_netlist
 
int m_filteringOptions
 
wxAuiToolBar * m_mainToolBar
 
FOOTPRINTS_LISTBOXm_footprintListBox
 
LIBRARY_LISTBOXm_libListBox
 
COMPONENTS_LISTBOXm_compListBox
 
wxTextCtrl * m_tcFilterString
 

Friends

struct CV::IFACE
 

Detailed Description

The CvPcb application main window.

Definition at line 57 of file cvpcb_mainframe.h.

Constructor & Destructor Documentation

CVPCB_MAINFRAME::CVPCB_MAINFRAME ( KIWAY aKiway,
wxWindow *  aParent 
)
protected

Definition at line 116 of file cvpcb_mainframe.cpp.

References BuildCmpListBox(), BuildFOOTPRINTS_LISTBOX(), BuildLIBRARY_LISTBOX(), EDA_BASE_FRAME::config(), DEFAULT_FOOTPRINTS_LIST_FILENAME, FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, FOOTPRINT_LIST::GetInstance(), EDA_PANEINFO::HorizontalToolbarPane(), EDA_PANEINFO::InfoToolbarPane(), KiBitmap(), KIWAY_HOLDER::Kiway(), PCAD2KICAD::Left, LoadSettings(), EDA_BASE_FRAME::m_auimgr, m_compListBox, m_DocModulesFileName, m_filteringOptions, m_footprintListBox, m_FootprintsList, EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, m_keepCvpcbOpen, m_libListBox, m_mainToolBar, m_modified, m_skipComponentSelect, m_tcFilterString, m_undefinedComponentCnt, ReCreateHToolbar(), ReCreateMenuBar(), PCAD2KICAD::Right, UpdateTitle(), wxPoint::x, and wxPoint::y.

116  :
117  KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, wxT( "CvPCB" ), wxDefaultPosition,
119 {
120  m_compListBox = NULL;
121  m_footprintListBox = NULL;
122  m_libListBox = NULL;
123  m_mainToolBar = NULL;
124  m_modified = false;
125  m_keepCvpcbOpen = false;
127  m_skipComponentSelect = false;
128  m_filteringOptions = 0;
129  m_tcFilterString = NULL;
131 
132  /* Name of the document footprint list
133  * usually located in share/modules/footprints_doc
134  * this is of the responsibility to users to create this file
135  * if they want to have a list of footprints
136  */
138 
139  // Give an icon
140  wxIcon icon;
141  icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
142  SetIcon( icon );
143 
144  SetAutoLayout( true );
145 
146  LoadSettings( config() );
147 
148  if( m_FrameSize.x < FRAME_MIN_SIZE_X )
150 
151  if( m_FrameSize.y < FRAME_MIN_SIZE_Y )
153 
154  // Set minimal frame width and height
155  SetSizeHints( FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, -1, -1, -1, -1 );
156 
157  // Frame size and position
158  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
159 
160  // create the status bar
161  static const int dims[3] = { -1, -1, 250 };
162 
163  CreateStatusBar( 3 );
164  SetStatusWidths( 3, dims );
165 
166  ReCreateMenuBar();
168 
169  // Create list of available modules and components of the schematic
170  BuildCmpListBox();
173 
174  m_auimgr.SetManagedWindow( this );
175 
176  UpdateTitle();
177 
178  EDA_PANEINFO horiz;
179  horiz.HorizontalToolbarPane();
180 
181  EDA_PANEINFO info;
182  info.InfoToolbarPane();
183 
184 
185  if( m_mainToolBar )
186  m_auimgr.AddPane( m_mainToolBar,
187  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top() );
188 
189  if( m_compListBox )
190  m_auimgr.AddPane( m_compListBox,
191  wxAuiPaneInfo( horiz ).Name( wxT( "m_compListBox" ) ).CentrePane() );
192 
193  if( m_libListBox)
194  m_auimgr.AddPane( m_libListBox,
195  wxAuiPaneInfo( info ).Name( wxT( "m_libListBox" ) ).
196  Left().BestSize( (int) ( m_FrameSize.x * 0.20 ), m_FrameSize.y ) );
197 
198  if( m_footprintListBox )
199  m_auimgr.AddPane( m_footprintListBox,
200  wxAuiPaneInfo( info ).Name( wxT( "m_footprintListBox" ) ).
201  Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) );
202 
203  m_auimgr.Update();
204 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:474
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
wxString m_DocModulesFileName
#define FRAME_MIN_SIZE_Y
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
COMPONENTS_LISTBOX * m_compListBox
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aWdoName=wxFrameNameStr)
#define CVPCB_MAINFRAME_NAME
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
void ReCreateHToolbar()
Definition: tool_cvpcb.cpp:42
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:361
wxAuiManager m_auimgr
Definition: wxstruct.h:139
static std::unique_ptr< FOOTPRINT_LIST > GetInstance(KIWAY &aKiway)
Factory function to return a new FOOTPRINT_LIST via Kiway.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:465
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
wxTextCtrl * m_tcFilterString
#define DEFAULT_FOOTPRINTS_LIST_FILENAME
Definition: cvpcb.h:29
wxAuiToolBar * m_mainToolBar
wxPoint m_FramePos
Definition: wxstruct.h:129
virtual void ReCreateMenuBar() override
(Re)Create the menubar for the CvPcb mainframe
void BuildFOOTPRINTS_LISTBOX()
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
Definition: wxstruct.h:539
LIBRARY_LISTBOX * m_libListBox
#define FRAME_MIN_SIZE_X
FOOTPRINTS_LISTBOX * m_footprintListBox
wxSize m_FrameSize
Definition: wxstruct.h:130
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
CVPCB_MAINFRAME::~CVPCB_MAINFRAME ( )

Definition at line 207 of file cvpcb_mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

208 {
209  m_auimgr.UnInit();
210 }
wxAuiManager m_auimgr
Definition: wxstruct.h:139

Member Function Documentation

void EDA_BASE_FRAME::AddMenuIconsOptions ( wxMenu *  MasterMenu)
inherited

Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice, and add it as submenu to MasterMenu.

Parameters
MasterMenuThe main menu. The sub menu list will be accessible from the menu item with id ID_KICAD_SELECT_ICONS_OPTIONS

Definition at line 671 of file basicframe.cpp.

References AddMenuItem(), ID_KICAD_SELECT_ICONS_IN_MENUS, ID_KICAD_SELECT_ICONS_OPTIONS, KiBitmap(), and Pgm().

Referenced by preparePreferencesMenu(), PL_EDITOR_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), and GERBVIEW_FRAME::ReCreateMenuBar().

672 {
673  wxMenu* menu = NULL;
674  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
675 
676  if( item ) // This menu exists, do nothing
677  return;
678 
679  menu = new wxMenu;
680 
681  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
682  _( "Icons in Menus" ), wxEmptyString,
683  wxITEM_CHECK ) );
684  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
685 
686  AddMenuItem( MasterMenu, menu,
688  _( "Icons Options" ),
689  _( "Select show icons in menus and icons sizes" ),
690  KiBitmap( hammer_xpm ) );
691 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
void CVPCB_MAINFRAME::AutomaticFootprintMatching ( wxCommandEvent &  event)

Called by the automatic association button Read *.equ files to try to find corresponding footprint for each component that is not already linked to a footprint ( a "free" component ) format of a line: 'cmp_ref' 'footprint_name'.

Definition at line 169 of file autosel.cpp.

References buildEquivalenceList(), LIB_ID::empty(), GetChars(), NETLIST::GetComponent(), NETLIST::GetCount(), COMPONENT::GetFootprintFilters(), FOOTPRINT_INFO::GetFootprintName(), COMPONENT::GetFPID(), COMPONENT::GetReference(), COMPONENT::GetValue(), NETLIST::IsEmpty(), m_compListBox, FOOTPRINT_EQUIVALENCE::m_ComponentValue, FOOTPRINT_EQUIVALENCE::m_FootprintFPID, m_FootprintsList, m_netlist, m_skipComponentSelect, next(), SetNewPkg(), COMPONENTS_LISTBOX::SetSelection(), and sortListbyCmpValue().

170 {
171  FOOTPRINT_EQUIVALENCE_LIST equiv_List;
172  COMPONENT* component;
173  wxString msg, error_msg;
174  size_t ii;
175 
176  if( m_netlist.IsEmpty() )
177  return;
178 
179  if( buildEquivalenceList( equiv_List, &error_msg ) )
180  wxMessageBox( error_msg, _( "Equivalence File Load Error" ), wxOK | wxICON_WARNING, this );
181 
182  // Sort the association list by component value.
183  // When sorted, find duplicate definitions (i.e. 2 or more items
184  // having the same component value) is more easy.
185  std::sort( equiv_List.begin(), equiv_List.end(), sortListbyCmpValue );
186 
187  // Display the number of footprint/component equivalences.
188  msg.Printf( _( "%lu footprint/cmp equivalences found." ), (unsigned long)equiv_List.size() );
189  SetStatusText( msg, 0 );
190 
191  // Now, associate each free component with a footprint, when the association
192  // is found in list
193  m_skipComponentSelect = true;
194  ii = 0;
195  error_msg.Empty();
196 
197  for( unsigned kk = 0; kk < m_netlist.GetCount(); kk++ )
198  {
199  component = m_netlist.GetComponent( kk );
200 
201  bool found = false;
202  m_compListBox->SetSelection( ii++, true );
203 
204  if( !component->GetFPID().empty() ) // the component has already a footprint
205  continue;
206 
207  // Here a first attempt is made. We can have multiple equivItem of the same value.
208  // When happens, using the footprint filter of components can remove the ambiguity by
209  // filtering equivItem so one can use multiple equiv_List (for polar and
210  // non-polar caps for example)
211  for( unsigned idx = 0; idx < equiv_List.size(); idx++ )
212  {
213  FOOTPRINT_EQUIVALENCE& equivItem = equiv_List[idx];
214 
215  if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 )
216  continue;
217 
218  const FOOTPRINT_INFO *module = m_FootprintsList->GetModuleInfo( equivItem.m_FootprintFPID );
219 
220  bool equ_is_unique = true;
221  unsigned next = idx+1;
222  int previous = idx-1;
223 
224  if( next < equiv_List.size() &&
225  equivItem.m_ComponentValue == equiv_List[next].m_ComponentValue )
226  equ_is_unique = false;
227 
228  if( previous >= 0 &&
229  equivItem.m_ComponentValue == equiv_List[previous].m_ComponentValue )
230  equ_is_unique = false;
231 
232  // If the equivalence is unique, no ambiguity: use the association
233  if( module && equ_is_unique )
234  {
235  SetNewPkg( equivItem.m_FootprintFPID );
236  found = true;
237  break;
238  }
239 
240  // The equivalence is not unique: use the footprint filter to try to remove
241  // ambiguity
242  if( module )
243  {
244  size_t filtercount = component->GetFootprintFilters().GetCount();
245  found = ( 0 == filtercount ); // if no entries, do not filter
246 
247  for( size_t jj = 0; jj < filtercount && !found; jj++ )
248  {
249  found = module->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
250  }
251  }
252  else
253  {
254  msg.Printf( _( "Component %s: footprint %s not found in any of the project "
255  "footprint libraries." ),
256  GetChars( component->GetReference() ),
257  GetChars( equivItem.m_FootprintFPID ) );
258 
259  if( ! error_msg.IsEmpty() )
260  error_msg << wxT("\n\n");
261 
262  error_msg += msg;
263  }
264 
265  if( found )
266  {
267  SetNewPkg( equivItem.m_FootprintFPID );
268  break;
269  }
270  }
271 
272  if( found )
273  continue;
274 
275  // obviously the last chance: there's only one filter matching one footprint
276  if( 1 == component->GetFootprintFilters().GetCount() )
277  {
278  // we do not need to analyze wildcards: single footprint do not
279  // contain them and if there are wildcards it just will not match any
280  const FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( component->GetFootprintFilters()[0] );
281 
282  if( module )
283  SetNewPkg( component->GetFootprintFilters()[0] );
284  }
285  }
286 
287  if( !error_msg.IsEmpty() )
288  wxMessageBox( error_msg, _( "CvPcb Warning" ), wxOK | wxICON_WARNING, this );
289 
290  m_skipComponentSelect = false;
291 }
CITER next(CITER it)
Definition: ptree.cpp:130
bool empty() const
Function empty.
Definition: lib_id.h:199
const wxString & GetFootprintName() const
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
COMPONENTS_LISTBOX * m_compListBox
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:175
void SetSelection(int index, bool State=true)
void SetNewPkg(const wxString &aFootprintName)
Function SetNewPkg links the footprint to the current selected component and selects the next compone...
wxString m_ComponentValue
Definition: autosel.h:37
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:235
const wxString & GetReference() const
Definition: pcb_netlist.h:149
const wxString & GetValue() const
Definition: pcb_netlist.h:151
boost::ptr_vector< FOOTPRINT_EQUIVALENCE > FOOTPRINT_EQUIVALENCE_LIST
Definition: autosel.h:43
bool sortListbyCmpValue(const FOOTPRINT_EQUIVALENCE &ref, const FOOTPRINT_EQUIVALENCE &test)
Definition: autosel.cpp:76
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
int buildEquivalenceList(FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=NULL)
read the .equ files and populate the list of equvalents
Definition: autosel.cpp:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
wxString m_FootprintFPID
Definition: autosel.h:38
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
void CVPCB_MAINFRAME::BuildCmpListBox ( )

Definition at line 872 of file cvpcb_mainframe.cpp.

References CMP_FORMAT, LIB_ID::Format(), FROM_UTF8(), GetChars(), NETLIST::GetComponent(), COMPONENTS_LISTBOX::GetCount(), NETLIST::GetCount(), COMPONENT::GetFPID(), COMPONENT::GetReference(), COMPONENT::GetValue(), ID_CVPCB_COMPONENT_LIST, m_compListBox, COMPONENTS_LISTBOX::m_ComponentList, m_netlist, COMPONENTS_LISTBOX::SetSelection(), and ITEMS_LISTBOX_BASE::UpdateWidth().

Referenced by CVPCB_MAINFRAME().

873 {
874  wxString msg;
875  COMPONENT* component;
876  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
877 
878  if( m_compListBox == NULL )
879  {
881  wxDefaultPosition, wxDefaultSize );
882  m_compListBox->SetFont( wxFont( guiFont.GetPointSize(),
883  wxFONTFAMILY_MODERN,
884  wxFONTSTYLE_NORMAL,
885  wxFONTWEIGHT_NORMAL ) );
886  }
887 
889 
890  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
891  {
892  component = m_netlist.GetComponent( i );
893 
894  msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
895  GetChars( component->GetReference() ),
896  GetChars( component->GetValue() ),
897  GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
898  m_compListBox->m_ComponentList.Add( msg );
899  }
900 
901  if( m_compListBox->m_ComponentList.Count() )
902  {
903  m_compListBox->SetItemCount( m_compListBox->m_ComponentList.Count() );
904  m_compListBox->SetSelection( 0, true );
905  m_compListBox->RefreshItems( 0L, m_compListBox->m_ComponentList.Count()-1 );
907  }
908 }
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
COMPONENTS_LISTBOX * m_compListBox
void SetSelection(int index, bool State=true)
const wxString & GetReference() const
Definition: pcb_netlist.h:149
const wxString & GetValue() const
Definition: pcb_netlist.h:151
void UpdateWidth(int aLine=-1)
Definition: listboxes.cpp:58
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
#define CMP_FORMAT
Definition: cvpcb.h:32
wxArrayString m_ComponentList
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
int CVPCB_MAINFRAME::buildEquivalenceList ( FOOTPRINT_EQUIVALENCE_LIST aList,
wxString *  aErrorMessages = NULL 
)
private

read the .equ files and populate the list of equvalents

Parameters
aListthe list to populate
aErrorMessagesis a pointer to a wxString to store error messages (can be NULL)
Returns
the error count ( 0 = no error)

Definition at line 83 of file autosel.cpp.

References SEARCH_STACK::FindValidPath(), FROM_UTF8(), GetChars(), GetLine(), GetQuotedText(), Kiface(), KIFACE_I::KifaceSearch(), FOOTPRINT_EQUIVALENCE::m_ComponentValue, m_EquFilesNames, and FOOTPRINT_EQUIVALENCE::m_FootprintFPID.

Referenced by AutomaticFootprintMatching().

84 {
85  char Line[1024];
86  int error_count = 0;
87  FILE* file;
88  wxFileName fn;
89  wxString tmp, error_msg;
90 
91  SEARCH_STACK& search = Kiface().KifaceSearch();
92 
93  // Find equivalences in all available files, and populates the
94  // equiv_List with all equivalences found in .equ files
95  for( unsigned ii = 0; ii < m_EquFilesNames.GetCount(); ii++ )
96  {
97  fn = wxExpandEnvVars( m_EquFilesNames[ii] );
98 
99  tmp = search.FindValidPath( fn.GetFullPath() );
100 
101  if( !tmp )
102  {
103  error_count++;
104 
105  if( aErrorMessages )
106  {
107  error_msg.Printf( _( "Equivalence file '%s' could not be found in the "
108  "default search paths." ),
109  GetChars( fn.GetFullName() ) );
110 
111  if( ! aErrorMessages->IsEmpty() )
112  *aErrorMessages << wxT("\n\n");
113 
114  *aErrorMessages += error_msg;
115  }
116 
117  continue;
118  }
119 
120  file = wxFopen( tmp, wxT( "rt" ) );
121 
122  if( file == NULL )
123  {
124  error_count++;
125 
126  if( aErrorMessages )
127  {
128  error_msg.Printf( _( "Error opening equivalence file '%s'." ), GetChars( tmp ) );
129 
130  if( ! aErrorMessages->IsEmpty() )
131  *aErrorMessages << wxT("\n\n");
132 
133  *aErrorMessages += error_msg;
134  }
135 
136  continue;
137  }
138 
139  while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
140  {
141  char* text = Line;
142  wxString value, footprint, wtext = FROM_UTF8( Line );
143 
144  value = GetQuotedText( wtext );
145 
146  if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
147  continue;
148 
149  footprint = GetQuotedText( wtext );
150 
151  if( footprint.IsEmpty() )
152  continue;
153 
154  value.Replace( wxT( " " ), wxT( "_" ) );
155 
156  FOOTPRINT_EQUIVALENCE* equivItem = new FOOTPRINT_EQUIVALENCE();
157  equivItem->m_ComponentValue = value;
158  equivItem->m_FootprintFPID = footprint;
159  aList.push_back( equivItem );
160  }
161 
162  fclose( file );
163  }
164 
165  return error_count;
166 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
wxArrayString m_EquFilesNames
wxString m_ComponentValue
Definition: autosel.h:37
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:125
wxString GetQuotedText(wxString &text)
Definition: autosel.cpp:56
char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine)
Function GetLine reads one line line from aFile.
Definition: string.cpp:213
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
wxString m_FootprintFPID
Definition: autosel.h:38
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:71
void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX ( )

Definition at line 852 of file cvpcb_mainframe.cpp.

References DisplayStatus(), ID_CVPCB_FOOTPRINT_LIST, m_footprintListBox, m_FootprintsList, FOOTPRINTS_LISTBOX::SetFootprints(), and FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST.

Referenced by CVPCB_MAINFRAME(), and ReadNetListAndLinkFiles().

853 {
854  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
855 
856  if( m_footprintListBox == NULL )
857  {
859  wxDefaultPosition, wxDefaultSize );
860  m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(),
861  wxFONTFAMILY_MODERN,
862  wxFONTSTYLE_NORMAL,
863  wxFONTWEIGHT_NORMAL ) );
864  }
865 
866  m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL,
868  DisplayStatus();
869 }
FOOTPRINTS_LISTBOX * m_footprintListBox
void SetFootprints(FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
Function SetFootprints populates the wxListCtrl with the footprints from aList that meet the filter c...
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX ( )

Definition at line 911 of file cvpcb_mainframe.cpp.

References LIB_TABLE::GetLogicalLibs(), ID_CVPCB_LIBRARY_LIST, KIWAY_HOLDER::Kiway(), m_libListBox, PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), and LIBRARY_LISTBOX::SetLibraryList().

Referenced by CVPCB_MAINFRAME(), OnEditFootprintLibraryTable(), and ReadNetListAndLinkFiles().

912 {
913  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
914 
915  if( m_libListBox == NULL )
916  {
918  wxDefaultPosition, wxDefaultSize );
919  m_libListBox->SetFont( wxFont( guiFont.GetPointSize(),
920  wxFONTFAMILY_MODERN,
921  wxFONTSTYLE_NORMAL,
922  wxFONTWEIGHT_NORMAL ) );
923  }
924 
925  FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
926 
927  if( tbl )
928  {
929  wxArrayString libNames;
930 
931  std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
932 
933  for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
934  libNames.Add( libNickNames[ii] );
935 
936  m_libListBox->SetLibraryList( libNames );
937  }
938 }
void SetLibraryList(const wxArrayString &aList)
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
LIBRARY_LISTBOX * m_libListBox
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
std::vector< wxString > GetLogicalLibs()
Function GetLogicalLibs.
void CVPCB_MAINFRAME::ChangeFocus ( bool  aMoveRight)

Definition at line 279 of file cvpcb_mainframe.cpp.

References m_compListBox, m_footprintListBox, and m_libListBox.

Referenced by FOOTPRINTS_LISTBOX::OnChar(), and COMPONENTS_LISTBOX::OnChar().

280 {
281  wxWindow* hasFocus = wxWindow::FindFocus();
282 
283  if( aMoveRight )
284  {
285  if( hasFocus == m_libListBox )
286  m_compListBox->SetFocus();
287  else if( hasFocus == m_compListBox )
288  m_footprintListBox->SetFocus();
289  else if( hasFocus == m_footprintListBox )
290  m_libListBox->SetFocus();
291  }
292  else
293  {
294  if( hasFocus == m_libListBox )
295  m_footprintListBox->SetFocus();
296  else if( hasFocus == m_compListBox )
297  m_libListBox->SetFocus();
298  else if( hasFocus == m_footprintListBox )
299  m_compListBox->SetFocus();
300  }
301 }
COMPONENTS_LISTBOX * m_compListBox
LIBRARY_LISTBOX * m_libListBox
FOOTPRINTS_LISTBOX * m_footprintListBox
void EDA_BASE_FRAME::CheckForAutoSaveFile ( const wxFileName &  aFileName,
const wxString &  aBackupFileExtension 
)
inherited

Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropriate action depending on the user input.

If an auto save file exists for aFileName, the user is prompted if they wish to replace file aFileName with the auto saved file. If the user chooses to replace the file, the backup file of aFileName is removed, aFileName is renamed to the backup file name, and the auto save file is renamed to aFileName. If user chooses to keep the existing version of aFileName, the auto save file is removed.

Parameters
aFileNameA wxFileName object containing the file name to check.
aBackupFileExtensionA wxString object containing the backup file extension used to create the backup file name.

Definition at line 576 of file basicframe.cpp.

References AUTOSAVE_PREFIX_FILENAME, Format(), GetChars(), Pgm(), and traceAutoSave.

Referenced by SCH_EDIT_FRAME::LoadOneEEFile(), and PCB_EDIT_FRAME::OpenProjectFiles().

578 {
579  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
580  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
581 
582  wxFileName autoSaveFileName = aFileName;
583 
584  // Check for auto save file.
585  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
586 
587  wxLogTrace( traceAutoSave,
588  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
589 
590  if( !autoSaveFileName.FileExists() )
591  return;
592 
593  wxString msg = wxString::Format( _(
594  "Well this is potentially embarrassing!\n"
595  "It appears that the last time you were editing the file\n"
596  "'%s'\n"
597  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
598  GetChars( aFileName.GetFullName() )
599  );
600 
601  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
602 
603  // Make a backup of the current file, delete the file, and rename the auto save file to
604  // the file name.
605  if( response == wxYES )
606  {
607  // Get the backup file name.
608  wxFileName backupFileName = aFileName;
609  backupFileName.SetExt( aBackupFileExtension );
610 
611  // If an old backup file exists, delete it. If an old copy of the file exists, rename
612  // it to the backup file name
613  if( aFileName.FileExists() )
614  {
615  // Remove the old file backup file.
616  if( backupFileName.FileExists() )
617  wxRemoveFile( backupFileName.GetFullPath() );
618 
619  // Rename the old file to the backup file name.
620  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
621  {
622  msg.Printf( _( "Could not create backup file <%s>" ),
623  GetChars( backupFileName.GetFullPath() ) );
624  wxMessageBox( msg );
625  }
626  }
627 
628  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
629  {
630  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
631  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
632  }
633  }
634  else
635  {
636  wxLogTrace( traceAutoSave,
637  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
638 
639  // Remove the auto save file when using the previous file as is.
640  wxRemoveFile( autoSaveFileName.GetFullPath() );
641  }
642 }
const wxChar traceAutoSave[]
Custom trace mask to enable and disable auto save tracing.
Definition: basicframe.cpp:53
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define AUTOSAVE_PREFIX_FILENAME
a prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash ...
Definition: wxstruct.h:70
wxConfigBase * EDA_BASE_FRAME::config ( )
protectedvirtualinherited
wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited

Function ConfigBaseName.

Returns
a base name prefix used in Load/Save settings to build the full name of keys used in config. This is usually the name of the frame set by CTOR, unless m_configFrameName contains a base name. this is the case of frames which can be shown in normal or modal mode. This is needed because we want only one base name prefix, regardless the mode used.

Definition at line 255 of file wxstruct.h.

References EDA_BASE_FRAME::m_configFrameName.

Referenced by EDA_BASE_FRAME::LoadSettings(), EDA_DRAW_FRAME::LoadSettings(), EDA_BASE_FRAME::SaveSettings(), and EDA_DRAW_FRAME::SaveSettings().

256  {
257  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
258  return baseCfgName;
259  }
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:132
void CVPCB_MAINFRAME::CreateScreenCmp ( )

Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display frame.

Definition at line 824 of file cvpcb_mainframe.cpp.

References GetFootprintViewerFrame(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), and KIWAY_HOLDER::Kiway().

Referenced by DisplayModule(), and refreshAfterComponentSearch().

825 {
827 
828  if( !fpframe )
829  {
830  fpframe = new DISPLAY_FOOTPRINTS_FRAME( &Kiway(), this );
831  fpframe->Show( true );
832  }
833  else
834  {
835  if( fpframe->IsIconized() )
836  fpframe->Iconize( false );
837 
838  // The display footprint window might be buried under some other
839  // windows, so CreateScreenCmp() on an existing window would not
840  // show any difference, leaving the user confused.
841  // So we want to put it to front, second after our CVPCB_MAINFRAME.
842  // We do this by a little dance of bringing it to front then the main
843  // frame back.
844  fpframe->Raise(); // Make sure that is visible.
845  Raise(); // .. but still we want the focus.
846  }
847 
848  fpframe->InitDisplay();
849 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
Class DISPLAY_FOOTPRINTS_FRAME is used to display footprints.
void InitDisplay()
Function InitDisplay Refresh the full display for this frame: Set the title, the status line and redr...
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame()
void CVPCB_MAINFRAME::DelAssociations ( wxCommandEvent &  event)

Function DelAssociations removes all component footprint associations already made.

Definition at line 375 of file cvpcb_mainframe.cpp.

References ITEMS_LISTBOX_BASE::DeselectAll(), DisplayStatus(), NETLIST::GetComponent(), NETLIST::GetCount(), IsOK(), m_compListBox, m_netlist, m_skipComponentSelect, m_undefinedComponentCnt, COMPONENT::SetFPID(), SetNewPkg(), and COMPONENTS_LISTBOX::SetSelection().

376 {
377  if( IsOK( this, _( "Delete selections" ) ) )
378  {
379  m_skipComponentSelect = true;
380 
381  // Remove all selections to avoid issues when setting the fpids
383 
384  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
385  {
386  LIB_ID fpid;
387 
388  m_netlist.GetComponent( i )->SetFPID( fpid );
389  SetNewPkg( wxEmptyString );
390  }
391 
392  // Remove all selections after setting the fpids
394 
395  m_skipComponentSelect = false;
398  }
399 
400  DisplayStatus();
401 }
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:153
COMPONENTS_LISTBOX * m_compListBox
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
Definition: listboxes.cpp:112
void SetSelection(int index, bool State=true)
void SetNewPkg(const wxString &aFootprintName)
Function SetNewPkg links the footprint to the current selected component and selects the next compone...
Class LIB_ID.
Definition: lib_id.h:56
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:111
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void KIWAY_PLAYER::DismissModal ( bool  aRetVal,
const wxString &  aResult = wxEmptyString 
)
protectedinherited
void CVPCB_MAINFRAME::DisplayDocFile ( wxCommandEvent &  event)
void CVPCB_MAINFRAME::DisplayModule ( wxCommandEvent &  event)

Definition at line 470 of file cvpcb_mainframe.cpp.

References CreateScreenCmp(), GetFootprintViewerFrame(), and EDA_DRAW_FRAME::RedrawScreen().

471 {
472  CreateScreenCmp();
473  GetFootprintViewerFrame()->RedrawScreen( wxPoint( 0, 0 ), false );
474 }
void CreateScreenCmp()
Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display f...
void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Function RedrawScreen redraws the entire screen area by updating the scroll bars and mouse pointer in...
Definition: zoom.cpp:46
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame()
void CVPCB_MAINFRAME::DisplayStatus ( )

Function DisplayStatus updates the information displayed on the status bar at bottom of the main frame.

When the library or component list controls have the focus, the footprint assignment status of the components is displayed in the first status bar pane and the list of filters for the selected component is displayed in the second status bar pane. When the footprint list control has the focus, the description of the selected footprint is displayed in the first status bar pane and the key words for the selected footprint are displayed in the second status bar pane. The third status bar pane always displays the current footprint list filtering.

Definition at line 627 of file cvpcb_mainframe.cpp.

References FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD, FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY, FOOTPRINTS_LISTBOX::FILTERING_BY_NAME, FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT, GetChars(), FOOTPRINTS_LISTBOX::GetCount(), NETLIST::GetCount(), FOOTPRINT_INFO::GetDoc(), COMPONENT::GetFootprintFilters(), FOOTPRINT_INFO::GetKeywords(), GetSelectedComponent(), GetSelectedFootprint(), m_compListBox, m_filteringOptions, m_footprintListBox, m_FootprintsList, m_libListBox, m_netlist, and m_undefinedComponentCnt.

Referenced by BuildFOOTPRINTS_LISTBOX(), DelAssociations(), ReadNetListAndLinkFiles(), refreshAfterComponentSearch(), and SetNewPkg().

628 {
629  wxString msg;
630  COMPONENT* component;
631 
632  if( wxWindow::FindFocus() == m_compListBox || wxWindow::FindFocus() == m_libListBox )
633  {
634  msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(),
636  SetStatusText( msg, 0 );
637 
638  msg.Empty();
639 
640  component = GetSelectedComponent();
641 
642  if( component )
643  {
644  for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ )
645  {
646  if( msg.IsEmpty() )
647  msg += component->GetFootprintFilters()[ii];
648  else
649  msg += wxT( ", " ) + component->GetFootprintFilters()[ii];
650  }
651 
652  msg = _( "Filter list: " ) + msg;
653  }
654 
655  SetStatusText( msg, 1 );
656  }
657  else
658  {
659  wxString footprintName = GetSelectedFootprint();
660 
661  FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName );
662 
663  if( module ) // can be NULL if no netlist loaded
664  {
665  msg = _( "Description: " ) + module->GetDoc();
666  SetStatusText( msg, 0 );
667 
668  msg = _( "Key words: " ) + module->GetKeywords();
669  SetStatusText( msg, 1 );
670  }
671  }
672 
673  msg.Empty();
674  wxString filters;
675 
676  if( m_footprintListBox )
677  {
679  filters = _( "key words" );
680 
682  {
683  if( !filters.IsEmpty() )
684  filters += wxT( "+" );
685 
686  filters += _( "pin count" );
687  }
688 
690  {
691  if( !filters.IsEmpty() )
692  filters += wxT( "+" );
693 
694  filters += _( "library" );
695  }
696 
698  {
699  if( !filters.IsEmpty() )
700  filters += wxT( "+" );
701 
702  filters += _( "name" );
703  }
704 
705  if( filters.IsEmpty() )
706  msg = _( "No filtering" );
707  else
708  msg.Printf( _( "Filtered by %s" ), GetChars( filters ) );
709 
710  msg << wxT( ": " ) << m_footprintListBox->GetCount();
711 
712  SetStatusText( msg, 2 );
713  }
714 }
COMPONENTS_LISTBOX * m_compListBox
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:175
const wxString & GetDoc()
const wxString & GetKeywords()
const wxString GetSelectedFootprint()
LIBRARY_LISTBOX * m_libListBox
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
COMPONENT * GetSelectedComponent()
FOOTPRINTS_LISTBOX * m_footprintListBox
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
bool EDA_BASE_FRAME::doAutoSave ( )
protectedvirtualinherited

Function doAutoSave should be overridden by the derived class to handle the auto save feature.

Returns
true if the auto save was successful otherwise false.

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 231 of file basicframe.cpp.

Referenced by EDA_BASE_FRAME::onAutoSaveTimer().

232 {
233  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
234 }
bool EDA_BASE_FRAME::Enable ( bool  enable)
overrideinherited

Definition at line 192 of file basicframe.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), and KIWAY_PLAYER::ShowModal().

193 {
194  // so we can do logging of this state change:
195 
196 #if defined(DEBUG)
197  const char* type_id = typeid( *this ).name();
198  printf( "wxFrame %-28s: %s\n", type_id, enable ? "enabled" : "disabled" );
199 #endif
200 
201  return wxFrame::Enable( enable );
202 }
void EDA_BASE_FRAME::ExportHotkeyConfigToFile ( EDA_HOTKEY_CONFIG aDescList,
const wxString &  aDefaultShortname 
)
inherited

Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it.

Parameters
aDescList= current hotkey list descr. to initialize.
aDefaultShortname= a default short name (extention not needed) like eechema, kicad...

Definition at line 768 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), EDA_BASE_FRAME::GetMruPath(), Prj(), EDA_BASE_FRAME::SetMruPath(), and EDA_BASE_FRAME::WriteHotkeyConfig().

Referenced by KICAD_MANAGER_FRAME::Process_Config(), LIB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Config(), PL_EDITOR_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), GERBVIEW_FRAME::Process_Config(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

770 {
771  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
772  wxString mask = wxT( "*." ) + ext;
773 
774 #if 0
775  wxString path = wxPathOnly( Prj().GetProjectFullName() );
776 #else
777  wxString path = GetMruPath();
778 #endif
779  wxFileName fn( aDefaultShortname );
780  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
781 
782  wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ),
783  path,
784  fn.GetFullPath(),
785  ext,
786  mask,
787  this,
788  wxFD_SAVE,
789  true );
790 
791  if( filename.IsEmpty() )
792  return;
793 
794  WriteHotkeyConfig( aDescList, &filename );
795  SetMruPath( wxFileName( filename ).GetPath() );
796 }
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:356
PROJECT & Prj()
Definition: kicad.cpp:293
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
wxString GetMruPath() const
Definition: wxstruct.h:358
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 214 of file wxstruct.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

Referenced by DIALOG_GENERALOPTIONS::init(), and SCH_EDIT_FRAME::OnPreferencesOptions().

214 { return m_autoSaveInterval; }
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
wxString EDA_BASE_FRAME::GetFileFromHistory ( int  cmdId,
const wxString &  type,
wxFileHistory *  aFileHistory = NULL 
)
inherited

Function GetFileFromHistory fetches the file name from the file history list.

and removes the selected file, if this file does not exists Note also the menu is updated, if wxFileHistory::UseMenu was called at init time

Parameters
cmdIdThe command ID associated with the aFileHistory object.
typePlease document me!
aFileHistoryThe wxFileHistory in use. If null, the main application file history is used
Returns
a wxString containing the selected filename

Definition at line 400 of file basicframe.cpp.

References Format(), GetChars(), KIFACE_I::GetFileHistory(), and Kiface().

Referenced by GERBVIEW_FRAME::OnDrlFileHistory(), KICAD_MANAGER_FRAME::OnFileHistory(), PL_EDITOR_FRAME::OnFileHistory(), PCB_EDIT_FRAME::OnFileHistory(), GERBVIEW_FRAME::OnGbrFileHistory(), and GERBVIEW_FRAME::OnZipFileHistory().

402 {
403  wxFileHistory* fileHistory = aFileHistory;
404 
405  if( !fileHistory )
406  fileHistory = &Kiface().GetFileHistory();
407 
408  int baseId = fileHistory->GetBaseId();
409 
410  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
411 
412  unsigned i = cmdId - baseId;
413 
414  if( i < fileHistory->GetCount() )
415  {
416  wxString fn = fileHistory->GetHistoryFile( i );
417 
418  if( wxFileName::FileExists( fn ) )
419  return fn;
420  else
421  {
422  wxString msg = wxString::Format(
423  wxT( "file '%s' was not found." ),
424  GetChars( fn ) );
425 
426  wxMessageBox( msg );
427 
428  fileHistory->RemoveFileFromHistory( i );
429  }
430  }
431 
432  return wxEmptyString;
433 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:121
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
DISPLAY_FOOTPRINTS_FRAME * CVPCB_MAINFRAME::GetFootprintViewerFrame ( )
Returns
a pointer on the Footprint Viewer frame, if exists, or NULL

Definition at line 952 of file cvpcb_mainframe.cpp.

References FOOTPRINTVIEWER_FRAME_NAME.

Referenced by CreateScreenCmp(), DisplayModule(), OnCloseWindow(), and refreshAfterComponentSearch().

953 {
954  // returns the Footprint Viewer frame, if exists, or NULL
955  return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>
956  ( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) );
957 }
#define FOOTPRINTVIEWER_FRAME_NAME
Class DISPLAY_FOOTPRINTS_FRAME is used to display footprints.
void EDA_BASE_FRAME::GetKicadAbout ( wxCommandEvent &  event)
inherited

Definition at line 525 of file basicframe.cpp.

References ShowAboutDialog().

526 {
527  bool ShowAboutDialog(wxWindow * parent);
528  ShowAboutDialog( this );
529 }
bool ShowAboutDialog(wxWindow *parent)
void EDA_BASE_FRAME::GetKicadContribute ( wxCommandEvent &  event)
inherited

Definition at line 514 of file basicframe.cpp.

References URL_GET_INVOLVED.

515 {
516  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
517  {
518  wxString msg = _( "Could not launch the default browser. For information on how to help the KiCad project, visit " );
519  msg.Append( URL_GET_INVOLVED );
520  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
521  }
522 }
#define URL_GET_INVOLVED
Definition: basicframe.cpp:51
void EDA_BASE_FRAME::GetKicadHelp ( wxCommandEvent &  event)
inherited

Definition at line 436 of file basicframe.cpp.

References DIM, Format(), GetAssociatedDocument(), GetChars(), EDA_BASE_FRAME::help_name(), SearchHelpFileFullPath(), and EDA_BASE_FRAME::sys_search().

437 {
438  const SEARCH_STACK& search = sys_search();
439 
440  /* We have to get document for beginners,
441  * or the full specific doc
442  * if event id is wxID_INDEX, we want the document for beginners.
443  * else the specific doc file (its name is in Kiface().GetHelpFileName())
444  * The document for beginners is the same for all KiCad utilities
445  */
446  if( event.GetId() == wxID_INDEX )
447  {
448  // List of possible names for Getting Started in KiCad
449  const wxChar* names[2] = {
450  wxT( "getting_started_in_kicad" ),
451  wxT( "Getting_Started_in_KiCad" )
452  };
453 
454  wxString helpFile;
455  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
456  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
457  for( unsigned ii = 0; ii < DIM( names ); ii++ )
458  {
459  helpFile = SearchHelpFileFullPath( search, names[ii] );
460 
461  if( !helpFile.IsEmpty() )
462  break;
463  }
464 
465  if( !helpFile )
466  {
467  wxString msg = wxString::Format( _(
468  "Html or pdf help file \n'%s'\n or\n'%s' could not be found." ), names[0], names[1] );
469  wxMessageBox( msg );
470  }
471  else
472  {
473  GetAssociatedDocument( this, helpFile );
474  }
475 
476  return;
477  }
478 
479  wxString base_name = help_name();
480  wxString helpFile = SearchHelpFileFullPath( search, base_name );
481 
482  if( !helpFile )
483  {
484  wxString msg = wxString::Format( _(
485  "Help file '%s' could not be found." ),
486  GetChars( base_name )
487  );
488  wxMessageBox( msg );
489  }
490  else
491  {
492  GetAssociatedDocument( this, helpFile );
493  }
494 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:86
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
virtual const SEARCH_STACK & sys_search()
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
Definition: basicframe.cpp:370
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSStack, const wxString &aBaseName)
Function SearchHelpFileFullPath returns the help file's full path.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
virtual wxString help_name()
Definition: basicframe.cpp:376
wxString EDA_BASE_FRAME::GetMruPath ( ) const
inlineinherited

Definition at line 358 of file wxstruct.h.

References EDA_BASE_FRAME::m_mruPath.

Referenced by EDA_BASE_FRAME::ExportHotkeyConfigToFile(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), and KICAD_MANAGER_FRAME::OnLoadProject().

358 { return m_mruPath; }
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:155
PARAM_CFG_ARRAY & CVPCB_MAINFRAME::GetProjectFileParameters ( void  )

Function GetProjectFileParameters return project file parameter list for CvPcb.

Populate the project file parameter array specific to CvPcb if it hasn't already been populated and return a reference to the array to the caller. Creating the parameter list at run time has the advantage of being able to define local variables. The old method of statically building the array at compile time requiring global variable definitions.

Returns
A reference to a PARAM_CFG_ARRAY contain the project settings for CvPcb.

Definition at line 45 of file cfg.cpp.

References GROUP_CVP_EQU, GROUP_PCB_LIBS, m_EquFilesNames, m_projectFileParams, and PARAM_COMMAND_ERASE.

Referenced by LoadProjectFile(), and SaveProjectFile().

46 {
47  if( !m_projectFileParams.empty() )
48  return m_projectFileParams;
49 
51 
53  wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) );
54 
55  return m_projectFileParams;
56 }
wxArrayString m_EquFilesNames
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
PARAM_CFG_ARRAY m_projectFileParams
#define GROUP_CVP_EQU
Definition: config_params.h:53
#define GROUP_PCB_LIBS
(and few for component editor).
Definition: config_params.h:48
COMPONENT * CVPCB_MAINFRAME::GetSelectedComponent ( )

Definition at line 941 of file cvpcb_mainframe.cpp.

References NETLIST::GetComponent(), NETLIST::GetCount(), ITEMS_LISTBOX_BASE::GetSelection(), m_compListBox, and m_netlist.

Referenced by DisplayStatus(), and OnSelectComponent().

942 {
943  int selection = m_compListBox->GetSelection();
944 
945  if( selection >= 0 && selection < (int) m_netlist.GetCount() )
946  return m_netlist.GetComponent( selection );
947 
948  return NULL;
949 }
COMPONENTS_LISTBOX * m_compListBox
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
const wxString CVPCB_MAINFRAME::GetSelectedFootprint ( )
Returns
the LIB_ID of the selected footprint in footprint listview or a empty string if no selection

Definition at line 959 of file cvpcb_mainframe.cpp.

References FOOTPRINTS_LISTBOX::GetSelectedFootprint(), and m_footprintListBox.

Referenced by DisplayStatus(), and DISPLAY_FOOTPRINTS_FRAME::InitDisplay().

960 {
961  // returns the LIB_ID of the selected footprint in footprint listview
962  // or a empty string
964 }
FOOTPRINTS_LISTBOX * m_footprintListBox
wxString EDA_BASE_FRAME::help_name ( )
protectedvirtualinherited

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 376 of file basicframe.cpp.

References KIFACE_I::GetHelpFileName(), and Kiface().

Referenced by EDA_BASE_FRAME::GetKicadHelp().

377 {
378  return Kiface().GetHelpFileName();
379 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
const wxString & GetHelpFileName() const
Function GetHelpFileName returns just the basename portion of the current help file.
Definition: kiface_i.h:119
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile ( EDA_HOTKEY_CONFIG aDescList,
const wxString &  aDefaultShortname 
)
inherited

Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.

Parameters
aDescList= current hotkey list descr. to initialize.
aDefaultShortname= a default short name (extention not needed) like eechema, kicad...

Definition at line 737 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), EDA_BASE_FRAME::GetMruPath(), Prj(), EDA_BASE_FRAME::ReadHotkeyConfigFile(), and EDA_BASE_FRAME::SetMruPath().

Referenced by KICAD_MANAGER_FRAME::Process_Config(), LIB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Config(), PL_EDITOR_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), GERBVIEW_FRAME::Process_Config(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

739 {
740  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
741  wxString mask = wxT( "*." ) + ext;
742 
743 #if 0 // pass in the project dir as an argument
744  wxString path = wxPathOnly( Prj().GetProjectFullName() );
745 #else
746  wxString path = GetMruPath();
747 #endif
748  wxFileName fn( aDefaultShortname );
749  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
750 
751  wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ),
752  path,
753  fn.GetFullPath(),
754  ext,
755  mask,
756  this,
757  wxFD_OPEN,
758  true );
759 
760  if( filename.IsEmpty() )
761  return;
762 
763  ReadHotkeyConfigFile( filename, aDescList );
764  SetMruPath( wxFileName( filename ).GetPath() );
765 }
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:356
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfigFile Read an old configuration file (<file>.key) and fill the current ho...
PROJECT & Prj()
Definition: kicad.cpp:293
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
wxString GetMruPath() const
Definition: wxstruct.h:358
virtual bool EDA_BASE_FRAME::isAutoSaveRequired ( ) const
inlineprotectedvirtualinherited

Function autoSaveRequired returns the auto save status of the application.

Override this function if your derived frame supports automatic file saving.

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 168 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ProcessEvent().

168 { return false; }
bool KIWAY_PLAYER::IsDismissed ( )
protectedinherited

Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been dismissed yet with DismissModal().

IOW, it will return true if the dialog is not modal or if it is modal and has been dismissed.

Definition at line 163 of file kiway_player.cpp.

References DBG, and KIWAY_PLAYER::m_modal_loop.

Referenced by LIB_VIEW_FRAME::OnCloseWindow(), FOOTPRINT_VIEWER_FRAME::OnCloseWindow(), and FOOTPRINT_WIZARD_FRAME::OnCloseWindow().

164 {
165  bool ret = !m_modal_loop;
166 
167  DBG(printf( "%s: ret:%d\n", __func__, ret );)
168 
169  return ret;
170 }
WX_EVENT_LOOP * m_modal_loop
Definition: kiway_player.h:247
#define DBG(x)
Definition: fctsys.h:33
bool EDA_BASE_FRAME::IsType ( FRAME_T  aType) const
inlineinherited
bool EDA_BASE_FRAME::IsWritable ( const wxFileName &  aFileName)
inherited

Function IsWritable checks if aFileName can be written.

The function performs a number of tests on aFileName to verify that it can be saved. If aFileName defines a path with no file name, them the path is tested for user write permission. If aFileName defines a file name that does not exist in the path, the path is tested for user write permission. If aFileName defines a file that already exits, the file name is tested for user write permissions.

Note
The file name path must be set or an assertion will be raised on debug builds and return false on release builds.
Parameters
aFileNameThe full path and/or file name of the file to test.
Returns
False if aFileName cannot be written.

Definition at line 532 of file basicframe.cpp.

References GetChars().

Referenced by SCH_EDIT_FRAME::doAutoSave(), LIB_EDIT_FRAME::SaveActiveLibrary(), SCH_EDIT_FRAME::SaveEEFile(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SaveProjectFile(), and SCH_EDIT_FRAME::SaveProjectSettings().

533 {
534  wxString msg;
535  wxFileName fn = aFileName;
536 
537  // Check for absence of a file path with a file name. Unfortunately KiCad
538  // uses paths relative to the current project path without the ./ part which
539  // confuses wxFileName. Making the file name path absolute may be less than
540  // elegant but it solves the problem.
541  if( fn.GetPath().IsEmpty() && fn.HasName() )
542  fn.MakeAbsolute();
543 
544  wxCHECK_MSG( fn.IsOk(), false,
545  wxT( "File name object is invalid. Bad programmer!" ) );
546  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
547  wxT( "File name object path <" ) + fn.GetFullPath() +
548  wxT( "> is not set. Bad programmer!" ) );
549 
550  if( fn.IsDir() && !fn.IsDirWritable() )
551  {
552  msg.Printf( _( "You do not have write permissions to folder <%s>." ),
553  GetChars( fn.GetPath() ) );
554  }
555  else if( !fn.FileExists() && !fn.IsDirWritable() )
556  {
557  msg.Printf( _( "You do not have write permissions to save file <%s> to folder <%s>." ),
558  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
559  }
560  else if( fn.FileExists() && !fn.IsFileWritable() )
561  {
562  msg.Printf( _( "You do not have write permissions to save file <%s>." ),
563  GetChars( fn.GetFullPath() ) );
564  }
565 
566  if( !msg.IsEmpty() )
567  {
568  wxMessageBox( msg );
569  return false;
570  }
571 
572  return true;
573 }
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 60 of file kiway_player.h.

References KIWAY_HOLDER::m_kiway.

Referenced by SCH_EDIT_FRAME::AppendOneEEProject(), BuildLIBRARY_LISTBOX(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), CreateScreenCmp(), CVPCB_MAINFRAME(), DIALOG_SHIM::DIALOG_SHIM(), EDIT_TOOL::editFootprintInFpEditor(), SCH_EDIT_FRAME::EditSheet(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers(), LIB_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallModuleOptionsFrame(), KIWAY_PLAYER::language_change(), SCH_SHEET::Load(), LoadFootprintFiles(), KIWAY_PLAYER::OnChangeIconsOptions(), OnEditFootprintLibraryTable(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnLeftClick(), SCH_BASE_FRAME::OnOpenLibraryViewer(), SCH_EDIT_FRAME::OnSimulate(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard(), SCH_EDIT_FRAME::OpenProjectFiles(), KIWAY_HOLDER::Prj(), PCB_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), ReadNetListAndLinkFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_EDIT_FRAME::refreshSchematic(), SCH_EDIT_FRAME::SaveEEFile(), SaveFootprintAssociation(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame(), FOOTPRINT_VIEWER_FRAME::Show3D_Frame(), FOOTPRINT_EDIT_FRAME::Show3D_Frame(), FOOTPRINT_WIZARD_FRAME::Show3D_Frame(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint().

61  {
62  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
63  return *m_kiway;
64  }
KIWAY * m_kiway
Definition: kiway_player.h:85
void KIWAY_PLAYER::kiway_express ( KIWAY_EXPRESS aEvent)
protectedinherited

event handler, routes to derivative specific virtual KiwayMailIn()

Definition at line 188 of file kiway_player.cpp.

References KIWAY_EXPRESS::Command(), KIWAY_EXPRESS::GetPayload(), KIWAY_PLAYER::KiwayMailIn(), and name.

189 {
190  // logging support
191 #if defined(DEBUG)
192  const char* class_name = typeid( this ).name();
193 
194  printf( "%s: received cmd:%d pay:'%s'\n", class_name,
195  aEvent.Command(), aEvent.GetPayload().c_str() );
196 #endif
197 
198  KiwayMailIn( aEvent ); // call the virtual, override in derived.
199 }
virtual void KiwayMailIn(KIWAY_EXPRESS &aEvent)
Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.
const std::string & GetPayload()
Function Payload returns the payload, which can be any text but it typicall self identifying s-expres...
Definition: kiway_express.h:62
const char * name
MAIL_T Command()
Function Command returns the MAIL_T associated with this mail.
Definition: kiway_express.h:52
void CVPCB_MAINFRAME::KiwayMailIn ( KIWAY_EXPRESS aEvent)
overridevirtual

Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.

Merely override it in derived classes.

Reimplemented from KIWAY_PLAYER.

Definition at line 973 of file cvpcb_mainframe.cpp.

References KIWAY_EXPRESS::Command(), DBG, KIWAY_EXPRESS::GetPayload(), MAIL_EESCHEMA_NETLIST, and ReadNetListAndLinkFiles().

974 {
975  const std::string& payload = mail.GetPayload();
976 
977  DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
978 
979  switch( mail.Command() )
980  {
982  ReadNetListAndLinkFiles( payload );
983  /* @todo
984  Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
985  */
986  break;
987 
988  default:
989  ; // ignore most
990  }
991 }
bool ReadNetListAndLinkFiles(const std::string &aNetlist)
Function ReadNetList reads the netlist (.net) file defined by #m_NetlistFileName. ...
#define DBG(x)
Definition: fctsys.h:33
EESCHEMA->CVPCB netlist immediately after launching CVPCB.
Definition: mail_type.h:41
void KIWAY_PLAYER::language_change ( wxCommandEvent &  event)
protectedinherited

Function language_change is an event handler called on a language menu selection.

Definition at line 202 of file kiway_player.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::SetLanguage().

203 {
204  int id = event.GetId();
205 
206  // tell all the KIWAY_PLAYERs about the language change.
207  Kiway().SetLanguage( id );
208 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs...
Definition: kiway.cpp:396
bool CVPCB_MAINFRAME::LoadFootprintFiles ( )

Function LoadFootprintFiles reads the list of footprint (*.mod files) and generate the list of footprints.

for each module are stored the module name documentation string associated keywords m_ModuleLibNames is the list of library that must be read (loaded) fills m_footprints

Returns
true if libraries are found, false otherwise.

Definition at line 717 of file cvpcb_mainframe.cpp.

References dummy(), LIB_TABLE::GetLogicalLibs(), KIWAY_HOLDER::Kiway(), m_FootprintsList, PROJECT::PcbFootprintLibs(), and KIWAY_HOLDER::Prj().

Referenced by ReadNetListAndLinkFiles().

718 {
719  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs( Kiway() );
720 
721  // Check if there are footprint libraries in the footprint library table.
722  if( !fptbl || !fptbl->GetLogicalLibs().size() )
723  {
724  wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
725  "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
726  return false;
727  }
728 
729  {
730  wxBusyCursor dummy; // Let the user know something is happening.
731 
732  m_FootprintsList->ReadFootprintFiles( fptbl );
733  }
734 
735  if( m_FootprintsList->GetErrorCount() )
736  {
737  m_FootprintsList->DisplayErrors( this );
738  }
739 
740  return true;
741 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
std::vector< wxString > GetLogicalLibs()
Function GetLogicalLibs.
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
void CVPCB_MAINFRAME::LoadProjectFile ( )

Function LoadProjectFile reads the CvPcb configuration parameter from the project (.pro) file aFileName.

Definition at line 59 of file cfg.cpp.

References PROJECT::ConfigLoad(), GetProjectFileParameters(), GROUP_CVP, Kiface(), m_EquFilesNames, m_ModuleLibNames, and KIWAY_HOLDER::Prj().

Referenced by ReadNetListAndLinkFiles().

60 {
61  PROJECT& prj = Prj();
62 
63  m_ModuleLibNames.Clear();
64  m_EquFilesNames.Clear();
65 
66  prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() );
67 }
Class PROJECT holds project specific data.
Definition: project.h:52
wxArrayString m_EquFilesNames
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxArrayString m_ModuleLibNames
#define GROUP_CVP
Definition: config_params.h:52
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:342
PARAM_CFG_ARRAY & GetProjectFileParameters(void)
Function GetProjectFileParameters return project file parameter list for CvPcb.
Definition: cfg.cpp:45
void CVPCB_MAINFRAME::LoadSettings ( wxConfigBase *  aCfg)
overridevirtual

Function LoadSettings loads common frame parameters from a configuration file.

Don't forget to call the base method or your frames won't remember their positions and sizes.

Reimplemented from EDA_BASE_FRAME.

Definition at line 213 of file cvpcb_mainframe.cpp.

References DEFAULT_FOOTPRINTS_LIST_FILENAME, FilterFootprintEntry, FootprintDocFileEntry, KeepCvpcbOpenEntry, EDA_BASE_FRAME::LoadSettings(), m_DocModulesFileName, m_filteringOptions, m_keepCvpcbOpen, and FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST.

Referenced by CVPCB_MAINFRAME().

214 {
216 
217  aCfg->Read( KeepCvpcbOpenEntry, &m_keepCvpcbOpen, true );
221 }
wxString m_DocModulesFileName
static const wxString FootprintDocFileEntry
static const wxString FilterFootprintEntry
#define DEFAULT_FOOTPRINTS_LIST_FILENAME
Definition: cvpcb.h:29
static const wxString KeepCvpcbOpenEntry
Nonzero iff cvpcb should be kept open after saving files.
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
Definition: basicframe.cpp:256
void EDA_BASE_FRAME::onAutoSaveTimer ( wxTimerEvent &  aEvent)
protectedinherited

Function onAutoSaveTimer handles the auto save timer event.

Definition at line 224 of file basicframe.cpp.

References EDA_BASE_FRAME::doAutoSave(), EDA_BASE_FRAME::m_autoSaveInterval, and EDA_BASE_FRAME::m_autoSaveTimer.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

225 {
226  if( !doAutoSave() )
227  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
228 }
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
Definition: basicframe.cpp:231
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:151
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
void KIWAY_PLAYER::OnChangeIconsOptions ( wxCommandEvent &  event)
overrideprotectedvirtualinherited

Function OnChangeIconsOptions is an event handler called on a icons options in menus or toolbars menu selection.

Reimplemented from EDA_BASE_FRAME.

Definition at line 211 of file kiway_player.cpp.

References KIWAY_HOLDER::Kiway(), EDA_BASE_FRAME::OnChangeIconsOptions(), and KIWAY::ShowChangedIcons().

212 {
215 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: basicframe.cpp:660
VTBL_ENTRY void ShowChangedIcons()
Function ShowChangedIcons Calls ShowChangedIcons() on all KIWAY_PLAYERs.
Definition: kiway.cpp:432
void CVPCB_MAINFRAME::OnCloseWindow ( wxCloseEvent &  Event)

Definition at line 246 of file cvpcb_mainframe.cpp.

References KIWAY_PLAYER::Destroy(), DisplayExitDialog(), GetFootprintViewerFrame(), m_modified, and SaveFootprintAssociation().

247 {
248  if( m_modified )
249  {
250  wxString msg = _( "Component to Footprint links modified.\nSave before exit ?" );
251  int ii = DisplayExitDialog( this, msg );
252 
253  switch( ii )
254  {
255  case wxID_CANCEL:
256  Event.Veto();
257  return;
258 
259  case wxID_NO:
260  break;
261 
262  case wxID_YES:
264  break;
265  }
266  }
267 
268  // Close module display frame
270  GetFootprintViewerFrame()->Close( true );
271 
272  m_modified = false;
273 
274  Destroy();
275  return;
276 }
int DisplayExitDialog(wxWindow *parent, const wxString &aMessage)
Function DisplayExitDialog displays a dialog with 3 buttons: Save and Exit Cancel Exit without save...
Definition: confirm.cpp:58
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame()
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void SaveFootprintAssociation()
Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eesc...
void CVPCB_MAINFRAME::OnConfigurePaths ( wxCommandEvent &  aEvent)

Definition at line 967 of file cvpcb_mainframe.cpp.

References PGM_BASE::ConfigurePaths(), and Pgm().

968 {
969  Pgm().ConfigurePaths( this );
970 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
VTBL_ENTRY void ConfigurePaths(wxWindow *aParent=NULL)
Function ConfigurePaths.
Definition: pgm_base.cpp:897
void CVPCB_MAINFRAME::OnEditEquFilesList ( wxCommandEvent &  aEvent)

Function OnEditEquFilesList envokes the equ files list edit dialog.

Definition at line 60 of file dialog_config_equfiles.cpp.

61 {
62  DIALOG_CONFIG_EQUFILES dlg( this );
63 
64  dlg.ShowModal();
65 }
void CVPCB_MAINFRAME::OnEditFootprintLibraryTable ( wxCommandEvent &  event)

Function OnEditFootprintLibraryTable displays the footprint library table editing dialog and updates the global and local footprint tables accordingly.

Definition at line 410 of file cvpcb_mainframe.cpp.

References BuildLIBRARY_LISTBOX(), dummy(), PROJECT::FootprintLibTblName(), Format(), GetChars(), FP_LIB_TABLE::GetGlobalTableFileName(), GFootprintTable, InvokePcbLibTableEditor(), KIWAY_HOLDER::Kiway(), m_FootprintsList, PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), LIB_TABLE::Save(), and IO_ERROR::What().

411 {
412  bool tableChanged = false;
413  int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs( Kiway() ) );
414 
415  if( r & 1 )
416  {
417  wxString fileName = FP_LIB_TABLE::GetGlobalTableFileName();
418 
419  try
420  {
421  GFootprintTable.Save( fileName );
422  tableChanged = true;
423  }
424  catch( const IO_ERROR& ioe )
425  {
426  wxString msg = wxString::Format(
427  _( "Error occurred saving the global footprint library table:\n'%s'\n%s" ),
428  GetChars( fileName ),
429  GetChars( ioe.What() )
430  );
431  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
432  }
433  }
434 
435  if( r & 2 )
436  {
437  wxString fileName = Prj().FootprintLibTblName();
438 
439  try
440  {
441  Prj().PcbFootprintLibs( Kiway() )->Save( fileName );
442  tableChanged = true;
443  }
444  catch( const IO_ERROR& ioe )
445  {
446  wxString msg = wxString::Format(
447  _( "Error occurred saving the project footprint library table:\n'%s'\n%s" ),
448  GetChars( fileName ),
449  GetChars( ioe.What() )
450  );
451  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
452  }
453  }
454 
455  if( tableChanged )
456  {
457  wxBusyCursor dummy;
459  m_FootprintsList->ReadFootprintFiles( Prj().PcbFootprintLibs( Kiway() ) );
460  }
461 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:321
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
int InvokePcbLibTableEditor(wxTopLevelWindow *aParent, FP_LIB_TABLE *aGlobal, FP_LIB_TABLE *aProject)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib ...
void Save(const wxString &aFileName) const
Function Save.
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table, i.e.
Definition: project.cpp:114
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
void CVPCB_MAINFRAME::OnEnterFilteringText ( wxCommandEvent &  event)

Function OnEnterFilteringText Is called each time the text of m_tcFilterString is changed.

Definition at line 612 of file cvpcb_mainframe.cpp.

References FOOTPRINTS_LISTBOX::FILTERING_BY_NAME, m_currentSearchPattern, m_filteringOptions, m_tcFilterString, and OnSelectFilteringFootprint().

613 {
614  // Called when changing the filter string in main toolbar.
615  // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_NAME is set, update the list of
616  // available footprints which match the filter
617 
619 
621  return;
622 
623  OnSelectFilteringFootprint( aEvent );
624 }
void OnSelectFilteringFootprint(wxCommandEvent &event)
Function OnSelectFilteringFootprint is the command event handler for enabling and disabling footprint...
wxString m_currentSearchPattern
wxTextCtrl * m_tcFilterString
void CVPCB_MAINFRAME::OnFilterFPbyKeyName ( wxUpdateUIEvent &  event)
private
void CVPCB_MAINFRAME::OnFilterFPbyKeywords ( wxUpdateUIEvent &  event)
private
void CVPCB_MAINFRAME::OnFilterFPbyLibrary ( wxUpdateUIEvent &  event)
private
void CVPCB_MAINFRAME::OnFilterFPbyPinCount ( wxUpdateUIEvent &  event)
private
void CVPCB_MAINFRAME::OnKeepOpenOnSave ( wxCommandEvent &  event)

Definition at line 464 of file cvpcb_mainframe.cpp.

References m_keepCvpcbOpen.

465 {
466  m_keepCvpcbOpen = event.IsChecked();
467 }
void CVPCB_MAINFRAME::OnQuit ( wxCommandEvent &  event)

Definition at line 240 of file cvpcb_mainframe.cpp.

241 {
242  Close( false );
243 }
void CVPCB_MAINFRAME::OnSelectComponent ( wxListEvent &  event)

Function OnSelectComponent Called when clicking on a component in component list window.

  • Updates the filtered footprint list, if the filtered list option is selected
  • Updates the current selected footprint in footprint list
  • Updates the footprint shown in footprint display window (if opened)

Definition at line 477 of file cvpcb_mainframe.cpp.

References GetSelectedComponent(), LIBRARY_LISTBOX::GetSelectedLibrary(), m_currentSearchPattern, m_filteringOptions, m_footprintListBox, m_FootprintsList, m_libListBox, m_skipComponentSelect, refreshAfterComponentSearch(), and FOOTPRINTS_LISTBOX::SetFootprints().

Referenced by COMPONENTS_LISTBOX::OnSelectComponent(), OnSelectFilteringFootprint(), and LIBRARY_LISTBOX::OnSelectLibrary().

478 {
480  return;
481 
482  wxString libraryName;
483  COMPONENT* component = GetSelectedComponent();
484  libraryName = m_libListBox->GetSelectedLibrary();
485 
486  m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component,
488 
489  refreshAfterComponentSearch (component);
490 }
wxString m_currentSearchPattern
void refreshAfterComponentSearch(COMPONENT *component)
LIBRARY_LISTBOX * m_libListBox
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetSelectedComponent()
FOOTPRINTS_LISTBOX * m_footprintListBox
void SetFootprints(FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
Function SetFootprints populates the wxListCtrl with the footprints from aList that meet the filter c...
std::unique_ptr< FOOTPRINT_LIST > m_FootprintsList
void CVPCB_MAINFRAME::OnSelectFilteringFootprint ( wxCommandEvent &  event)

Function OnSelectFilteringFootprint is the command event handler for enabling and disabling footprint filtering.

Definition at line 548 of file cvpcb_mainframe.cpp.

References FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD, FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY, FOOTPRINTS_LISTBOX::FILTERING_BY_NAME, FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT, m_currentSearchPattern, m_filteringOptions, m_tcFilterString, and OnSelectComponent().

Referenced by OnEnterFilteringText().

549 {
550  int option = 0;
551 
552  switch( event.GetId() )
553  {
556  break;
557 
560  break;
561 
564  break;
565 
569  break;
570  }
571 
572  if( event.IsChecked() )
573  m_filteringOptions |= option;
574  else
575  m_filteringOptions &= ~option;
576 
577  wxListEvent l_event;
578  OnSelectComponent( l_event );
579 }
wxString m_currentSearchPattern
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Function OnSelectComponent Called when clicking on a component in component list window.
void EDA_BASE_FRAME::OnSelectPreferredEditor ( wxCommandEvent &  event)
virtualinherited

Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit or display files (reports ...

) The full filename editor is saved in configuration (global params)

Definition at line 497 of file basicframe.cpp.

References PGM_BASE::AskUserForPreferredEditor(), PGM_BASE::GetEditorName(), Pgm(), and PGM_BASE::SetEditorName().

498 {
499  // Ask for the current editor and instruct GetEditorName() to not show
500  // unless we pass false as argument.
501  wxString editorname = Pgm().GetEditorName( false );
502 
503  // Ask the user to select a new editor, but suggest the current one as the default.
504  editorname = Pgm().AskUserForPreferredEditor( editorname );
505 
506  // If we have a new editor name request it to be copied to m_editor_name and saved
507  // to the preferences file. If the user cancelled the dialog then the previous
508  // value will be retained.
509  if( !editorname.IsEmpty() )
510  Pgm().SetEditorName( editorname );
511 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:328
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
VTBL_ENTRY const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Shows a dialog that instructs the user to select a new preferred editor.
Definition: pgm_base.cpp:373
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:336
void CVPCB_MAINFRAME::OnSize ( wxSizeEvent &  SizeEvent)

Definition at line 234 of file cvpcb_mainframe.cpp.

235 {
236  event.Skip();
237 }
void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave ( wxUpdateUIEvent &  event)
private

Definition at line 582 of file cvpcb_mainframe.cpp.

References m_keepCvpcbOpen.

583 {
584  event.Check( m_keepCvpcbOpen );
585 }
bool CVPCB_MAINFRAME::OpenProjectFiles ( const std::vector< wxString > &  aFileSet,
int  aCtl = 0 
)
override

Definition at line 404 of file cvpcb_mainframe.cpp.

405 {
406  return true;
407 }
bool EDA_BASE_FRAME::PostCommandMenuEvent ( int  evt_type)
inherited

Function PostCommandMenuEvent.

Post a menu event to the frame, which can be used to trigger actions bound to menu items.

Definition at line 645 of file basicframe.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::OnHotKey(), FOOTPRINT_EDIT_FRAME::OnHotkeyDeleteItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyDuplicateItem(), PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyEditItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyMoveItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyMoveItemExact(), and FOOTPRINT_EDIT_FRAME::OnHotkeyRotateItem().

646 {
647  if( evt_type != 0 )
648  {
649  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
650  evt.SetEventObject( this );
651  evt.SetId( evt_type );
652  wxPostEvent( this, evt );
653  return true;
654  }
655 
656  return false;
657 }
void EDA_BASE_FRAME::PrintMsg ( const wxString &  text)
inherited

Definition at line 382 of file basicframe.cpp.

Referenced by SCH_EDIT_FRAME::LoadOneEEFile(), and EDA_DRAW_PANEL::OnMouseEvent().

383 {
384  SetStatusText( text );
385 }
PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Function Prj returns a reference to the PROJECT "associated with" this KIWAY.

Definition at line 34 of file kiway_holder.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::AppendOneEEProject(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), LIB_VIEW_FRAME::BestZoom(), DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile(), DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint(), BuildLIBRARY_LISTBOX(), DIALOG_MODULE_MODULE_EDITOR::Cfg3DPath(), DIALOG_MODULE_BOARD_EDITOR::Cfg3DPath(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_SCREEN::CheckComponentsToPartsLinks(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), SCH_EDIT_FRAME::CreateArchiveLibrary(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), LIB_EDIT_FRAME::DeleteOnePart(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_FP_LIB_TABLE::DIALOG_FP_LIB_TABLE(), DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR(), DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), PCB_EDIT_FRAME::doAutoSave(), DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName(), DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::ExportToGenCAD(), PCB_EDIT_FRAME::ExportVRML_File(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::GenD356File(), NETLIST_DIALOG::GenNetlist(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), LIB_EDIT_FRAME::GetCurPart(), FOOTPRINT_EDIT_FRAME::GetCurrentLib(), FOOTPRINT_EDIT_FRAME::getLibPath(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), DIALOG_BOM::getPluginFileName(), LIB_VIEW_FRAME::getSelectedAlias(), FP_THREAD_IFACE::GetTable(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), DIALOG_MODULE_MODULE_EDITOR::initModeditProperties(), DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties(), LIB_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallNetlistFrame(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), SCH_EDIT_FRAME::Load_Component(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), DIALOG_BOM_EDITOR::LoadComponents(), LoadFootprintFiles(), SCH_EDIT_FRAME::LoadOneEEFile(), LIB_EDIT_FRAME::LoadOneLibraryPart(), LIB_EDIT_FRAME::LoadOneSymbol(), LoadProjectFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_DRC_CONTROL::makeValidFileNameReport(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath(), DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick(), LIB_EDIT_FRAME::OnCloseWindow(), OnEditFootprintLibraryTable(), DIALOG_GENDRILL::OnGenReportFile(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), PCB_EDIT_FRAME::OnLeftClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OnRightClick(), DIALOG_BOM::OnRunPlugin(), DIALOG_NETLIST::OnSaveMessagesToFile(), SCH_EDIT_FRAME::OnSaveProject(), DIALOG_SPICE_MODEL::onSelectIcLib(), LIB_VIEW_FRAME::OnSelectSymbol(), SCH_EDIT_FRAME::OnSelectUnit(), DIALOG_SPICE_MODEL::onSemiSelectLib(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName(), FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib(), LIB_EDIT_FRAME::OnViewEntryDoc(), LIB_VIEW_FRAME::onViewSymbolDocument(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_EDITOR_CONTROL::PlaceModule(), SCH_EDIT_FRAME::prepareForNetlist(), SCH_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), ReadNetListAndLinkFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_VIEW_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), LIB_VIEW_FRAME::RedrawActiveWindow(), EDA_3D_VIEWER::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), SCH_EDIT_FRAME::RescueProject(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_SCREEN::Save(), LIB_EDIT_FRAME::SaveActiveLibrary(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectComponentFromLibrary(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_ERC::TestErc(), DIALOG_SPICE_MODEL::updateFromFile(), SIM_PLOT_FRAME::updateNetlistExporter(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR(), and DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR().

35 {
36  return Kiway().Prj();
37 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:144
bool EDA_BASE_FRAME::ProcessEvent ( wxEvent &  aEvent)
overrideinherited

Function ProcessEvent overrides the default process event handler to implement the auto save feature.

Warning
If you override this function in a derived class, make sure you call down to this or the auto save feature will be disabled.

Definition at line 166 of file basicframe.cpp.

References EDA_BASE_FRAME::isAutoSaveRequired(), EDA_BASE_FRAME::m_autoSaveInterval, EDA_BASE_FRAME::m_autoSaveState, EDA_BASE_FRAME::m_autoSaveTimer, EDA_BASE_FRAME::m_hasAutoSave, and traceAutoSave.

Referenced by LIB_VIEW_FRAME::onSelectNextSymbol(), LIB_VIEW_FRAME::onSelectPreviousSymbol(), KIWAY::ProcessEvent(), LIB_VIEW_FRAME::ReCreateListCmp(), and PCBNEW_CONTROL::SwitchUnits().

167 {
168  if( !wxFrame::ProcessEvent( aEvent ) )
169  return false;
170 
171  if( IsShown() && m_hasAutoSave &&
173  {
174  if( !m_autoSaveState )
175  {
176  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
177  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
178  m_autoSaveState = true;
179  }
180  else if( m_autoSaveTimer->IsRunning() )
181  {
182  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
183  m_autoSaveTimer->Stop();
184  m_autoSaveState = false;
185  }
186  }
187 
188  return true;
189 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:145
const wxChar traceAutoSave[]
Custom trace mask to enable and disable auto save tracing.
Definition: basicframe.cpp:53
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:151
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:168
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:142
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
int EDA_BASE_FRAME::ReadHotkeyConfig ( struct EDA_HOTKEY_CONFIG aDescList)
inherited

Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys.

Parameters
aDescList= current hotkey list descr. to initialize.

Definition at line 658 of file hotkeys_basic.cpp.

659 {
660  ::ReadHotkeyConfig( GetName(), aDescList );
661  return 1;
662 }
int ReadHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
int EDA_BASE_FRAME::ReadHotkeyConfigFile ( const wxString &  aFilename,
struct EDA_HOTKEY_CONFIG aDescList 
)
inherited

Function ReadHotkeyConfigFile Read an old configuration file (&ltfile&gt.key) and fill the current hotkey list with hotkeys.

Parameters
aFilename= file name to read.
aDescList= current hotkey list descr. to initialize.

Definition at line 601 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, and ParseHotkeyConfig().

Referenced by EDA_BASE_FRAME::ImportHotkeyConfigFromFile().

603 {
604  wxFileName fn( aFilename );
605  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
606 
607  wxFile cfgfile( fn.GetFullPath() );
608 
609  if( !cfgfile.IsOpened() ) // There is a problem to open file
610  return 0;
611 
612  // get length
613  cfgfile.SeekEnd();
614  wxFileOffset size = cfgfile.Tell();
615  cfgfile.Seek( 0 );
616 
617  // read data
618  char* buffer = new char[size];
619  cfgfile.Read( buffer, size );
620 
621  wxString data( buffer, wxConvUTF8 );
622 
623  // parse
624  ParseHotkeyConfig( data, aDescList );
625 
626  // cleanup
627  delete[] buffer;
628  cfgfile.Close();
629  return 1;
630 }
void ParseHotkeyConfig(const wxString &data, struct EDA_HOTKEY_CONFIG *aDescList)
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles ( const std::string &  aNetlist)

Function ReadNetList reads the netlist (.net) file defined by #m_NetlistFileName.

and the corresponding cmp to footprint (.cmp) link file

Parameters
aNetlistis the netlist from eeschema in kicad s-expr format.

Definition at line 158 of file readwrite_dlgs.cpp.

References DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::Add(), NETLIST::AnyFootprintsLinked(), COMPONENTS_LISTBOX::AppendLine(), BuildFOOTPRINTS_LISTBOX(), BuildLIBRARY_LISTBOX(), COMPONENTS_LISTBOX::Clear(), CMP_FORMAT, DBG, DisplayStatus(), LIB_ID::empty(), LIB_ID::Format(), Format(), FROM_UTF8(), COMPONENT::GetAltFPID(), GetChars(), NETLIST::GetComponent(), COMPONENTS_LISTBOX::GetCount(), NETLIST::GetCount(), COMPONENT::GetFPID(), LIB_ID::GetLibItemName(), COMPONENT::GetReference(), DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::GetSelection(), COMPONENT::GetValue(), guessNickname(), NETLIST::IsEmpty(), LIB_ID::IsLegacy(), IsOK(), KIWAY_HOLDER::Kiway(), HTML_MESSAGE_BOX::ListSet(), LoadFootprintFiles(), LoadProjectFile(), m_compListBox, m_modified, m_netlist, m_undefinedComponentCnt, HTML_MESSAGE_BOX::MessageSet(), PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), ReadSchematicNetlist(), COMPONENT::SetFPID(), COMPONENTS_LISTBOX::SetSelection(), DIALOG_SHIM::Show(), TO_UTF8, UpdateTitle(), and IO_ERROR::What().

Referenced by KiwayMailIn().

159 {
160  wxString msg;
161  bool hasMissingNicks = false;
162 
163  ReadSchematicNetlist( aNetlist );
164 
165  if( m_compListBox == NULL )
166  return false;
167 
168  LoadProjectFile();
170 
173 
174  m_compListBox->Clear();
176 
178  {
179  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
180  {
181  COMPONENT* component = m_netlist.GetComponent( i );
182 
183  if( component->GetFPID().empty() )
184  continue;
185 
186  if( component->GetFPID().IsLegacy() )
187  hasMissingNicks = true;
188  }
189  }
190 
191  // Check if footprint links were generated before the footprint library table was implemented.
192  if( hasMissingNicks )
193  {
194  msg = _(
195  "Some of the assigned footprints are legacy entries (are missing lib nicknames). "
196  "Would you like CvPcb to attempt to convert them to the new required LIB_ID format? "
197  "(If you answer no, then these assignments will be cleared out and you will "
198  "have to re-assign these footprints yourself.)"
199  );
200 
201  if( IsOK( this, msg ) )
202  {
203  msg.Clear();
204 
205  try
206  {
207  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
208  {
209  COMPONENT* component = m_netlist.GetComponent( i );
210 
211  if( component->GetFPID().IsLegacy() )
212  {
213  // get this first here, it's possibly obsoleted if we get it too soon.
214  FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
215 
216  int guess = guessNickname( tbl, (LIB_ID*) &component->GetFPID() );
217 
218  switch( guess )
219  {
220  case 0:
221  DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__,
222  TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );)
223  m_modified = true;
224  break;
225 
226  case 1:
227  msg += wxString::Format( _(
228  "Component '%s' footprint '%s' was <b>not found</b> in any library.\n" ),
229  GetChars( component->GetReference() ),
230  GetChars( FROM_UTF8( component->GetFPID().GetLibItemName() ) )
231  );
232  break;
233 
234  case 2:
235  msg += wxString::Format( _(
236  "Component '%s' footprint '%s' was found in <b>multiple</b> libraries.\n" ),
237  GetChars( component->GetReference() ),
238  GetChars( FROM_UTF8( component->GetFPID().GetLibItemName() ) )
239  );
240  break;
241  }
242  }
243  }
244  }
245  catch( const IO_ERROR& ioe )
246  {
247  msg = ioe.What();
248  msg += wxT( "\n\n" );
249  msg += _( "First check your footprint library table entries." );
250 
251  wxMessageBox( msg, _( "Problematic Footprint Library Tables" ) );
252  return false;
253  }
254 
255  if( msg.size() )
256  {
257  HTML_MESSAGE_BOX dlg( this, wxEmptyString );
258 
259  dlg.MessageSet( _( "The following errors occurred attempting to convert the "
260  "footprint assignments:\n\n" ) );
261  dlg.ListSet( msg );
262  dlg.MessageSet( _( "\nYou will need to reassign them manually if you want them "
263  "to be updated correctly the next time you import the "
264  "netlist in Pcbnew." ) );
265 
266 #if 1
267  dlg.ShowModal();
268 #else
269  dlg.Fit();
270  dlg.Show( true ); // modeless lets user watch while fixing the problems, but its not working.
271 #endif
272  }
273  }
274  else
275  {
276  // Clear the legacy footprint assignments.
277  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
278  {
279  COMPONENT* component = m_netlist.GetComponent( i );
280 
281  if( component->GetFPID().IsLegacy() )
282  {
283  component->SetFPID( LIB_ID() /* empty */ );
284  m_modified = true;
285  }
286  }
287  }
288  }
289 
290 
291  // Display a dialog to select footprint selection, if the netlist
292  // and the .cmp file give 2 different valid footprints
293  std::vector <int > m_indexes; // indexes of footprints in netlist
294 
295  for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
296  {
297  COMPONENT* component = m_netlist.GetComponent( ii );
298 
299  if( component->GetAltFPID().empty() )
300  continue;
301 
302  if( component->GetFPID().IsLegacy() || component->GetAltFPID().IsLegacy())
303  continue;
304 
305  m_indexes.push_back( ii );
306  }
307 
308  // If a n assignment conflict is found,
309  // open a dialog to chose between schematic assignment
310  // and .cmp file assignment:
311  if( m_indexes.size() > 0 )
312  {
314 
315  for( unsigned ii = 0; ii < m_indexes.size(); ii++ )
316  {
317  COMPONENT* component = m_netlist.GetComponent( m_indexes[ii] );
318 
319  wxString cmpfpid = FROM_UTF8( component->GetFPID().Format() );
320  wxString schfpid = FROM_UTF8( component->GetAltFPID().Format() );
321 
322  dlg.Add( component->GetReference(), schfpid, cmpfpid );
323  }
324 
325  if( dlg.ShowModal() == wxID_OK )
326  {
327 
328  // Update the fp selection:
329  for( unsigned ii = 0; ii < m_indexes.size(); ii++ )
330  {
331  COMPONENT* component = m_netlist.GetComponent( m_indexes[ii] );
332 
333  int choice = dlg.GetSelection( component->GetReference() );
334 
335  if( choice == 0 ) // the schematic (alt fpid) is chosen:
336  component->SetFPID( component->GetAltFPID() );
337  }
338  }
339  }
340 
341  // Populates the component list box:
342  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
343  {
344  COMPONENT* component = m_netlist.GetComponent( i );
345 
346  msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
347  GetChars( component->GetReference() ),
348  GetChars( component->GetValue() ),
349  GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
350 
351  m_compListBox->AppendLine( msg );
352 
353  if( component->GetFPID().empty() )
354  {
356  continue;
357  }
358  }
359 
360  if( !m_netlist.IsEmpty() )
361  m_compListBox->SetSelection( 0, true );
362 
363  DisplayStatus();
364 
365  UpdateTitle();
366  return true;
367 }
bool empty() const
Function empty.
Definition: lib_id.h:199
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
bool AnyFootprintsLinked() const
Function AnyFootprintsLinked.
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:153
COMPONENTS_LISTBOX * m_compListBox
bool IsLegacy() const
Function IsLegacy.
Definition: lib_id.h:185
void SetSelection(int index, bool State=true)
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
int ReadSchematicNetlist(const std::string &aNetlist)
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:235
Class LIB_ID.
Definition: lib_id.h:56
bool LoadFootprintFiles()
Function LoadFootprintFiles reads the list of footprint (*.mod files) and generate the list of footpr...
static int guessNickname(FP_LIB_TABLE *aTbl, LIB_ID *aFootprintId)
Return true if the resultant LIB_ID has a certain nickname.
void AppendLine(const wxString &text)
const wxString & GetReference() const
Definition: pcb_netlist.h:149
const wxString & GetValue() const
Definition: pcb_netlist.h:151
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
void BuildFOOTPRINTS_LISTBOX()
Class HTML_MESSAGE_BOX.
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
#define CMP_FORMAT
Definition: cvpcb.h:32
const LIB_ID & GetAltFPID() const
Definition: pcb_netlist.h:166
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
#define DBG(x)
Definition: fctsys.h:33
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:111
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void LoadProjectFile()
Function LoadProjectFile reads the CvPcb configuration parameter from the project (...
Definition: cfg.cpp:59
int CVPCB_MAINFRAME::ReadSchematicNetlist ( const std::string &  aNetlist)

Definition at line 791 of file cvpcb_mainframe.cpp.

References NETLIST::Clear(), Format(), NETLIST::GetComponent(), NETLIST::GetCount(), COMPONENT::GetFPID(), LIB_ID::GetLibItemName(), KICAD_NETLIST_READER::LoadNetlist(), m_netlist, COMPONENT::SetFPID(), NETLIST::SortByReference(), and IO_ERROR::What().

Referenced by ReadNetListAndLinkFiles().

792 {
793  STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
794  KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
795 
796  m_netlist.Clear();
797 
798  try
799  {
800  netrdr.LoadNetlist();
801  }
802  catch( const IO_ERROR& ioe )
803  {
804  wxString msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.What().GetData() );
805  wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
806  return 1;
807  }
808 
809  // We also remove footprint name if it is "$noname" because this is a dummy name,
810  // not the actual name of the footprint.
811  for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
812  {
813  if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
814  m_netlist.GetComponent( ii )->SetFPID( LIB_ID( wxEmptyString ) );
815  }
816 
817  // Sort components by reference:
819 
820  return 0;
821 }
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
Class KICAD_NETLIST_READER read the new s-expression based KiCad netlist format.
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:153
Class LIB_ID.
Definition: lib_id.h:56
void SortByReference()
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void Clear()
Function Clear removes all components from the netlist.
Definition: pcb_netlist.h:241
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
void CVPCB_MAINFRAME::ReCreateHToolbar ( void  )

Definition at line 42 of file tool_cvpcb.cpp.

References ID_CVPCB_AUTO_ASSOCIE, ID_CVPCB_CREATE_SCREENCMP, ID_CVPCB_DEL_ASSOCIATIONS, ID_CVPCB_FILTER_TEXT_EDIT, ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, ID_CVPCB_GOTO_FIRSTNA, ID_CVPCB_GOTO_PREVIOUSNA, ID_CVPCB_LIB_TABLE_EDIT, ID_H_TOOLBAR, KiBitmap(), m_mainToolBar, m_tcFilterString, and SAVE_HLP_MSG.

Referenced by CVPCB_MAINFRAME().

43 {
44  if( m_mainToolBar != NULL )
45  return;
46 
47  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
48  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
49 
50  m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiBitmap( save_xpm ), SAVE_HLP_MSG );
51 
52  m_mainToolBar->AddSeparator();
53  m_mainToolBar->AddTool( ID_CVPCB_LIB_TABLE_EDIT, wxEmptyString,
54  KiBitmap( config_xpm ),
55  _( "Edit footprint library table" ) );
56 
57  m_mainToolBar->AddSeparator();
58  m_mainToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxEmptyString,
59  KiBitmap( show_footprint_xpm ),
60  _( "View selected footprint" ) );
61 
62  m_mainToolBar->AddSeparator();
63  m_mainToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
64  KiBitmap( left_xpm ),
65  _( "Select previous unlinked component" ) );
66 
67  m_mainToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxEmptyString,
68  KiBitmap( right_xpm ),
69  _( "Select next unlinked component" ) );
70 
71  m_mainToolBar->AddSeparator();
72  m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
73  KiBitmap( auto_associe_xpm ),
74  _( "Perform automatic footprint association" ) );
75 
76  m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
77  KiBitmap( delete_association_xpm ),
78  _( "Delete all footprint associations" ) );
79 
80  m_mainToolBar->AddSeparator();
82  KiBitmap( module_filtered_list_xpm ),
83  wxNullBitmap,
84  true, NULL,
85  _( "Filter footprint list by schematic components keywords" ),
86  wxEmptyString );
87 
89  KiBitmap( module_pin_filtered_list_xpm ),
90  wxNullBitmap,
91  true, NULL,
92  _( "Filter footprint list by pin count" ),
93  wxEmptyString );
94 
96  KiBitmap( module_library_list_xpm ),
97  wxNullBitmap, true, NULL,
98  _( "Filter footprint list by library" ),
99  wxEmptyString );
100 
101  m_mainToolBar->AddSeparator();
103  KiBitmap( module_name_filtered_list_xpm ),
104  wxNullBitmap, true, NULL,
105  _( "Filter footprint list using a partial name or a pattern" ),
106  wxEmptyString );
107 
109 
110  m_mainToolBar->AddControl( m_tcFilterString );
111 
112 
113  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
114  m_mainToolBar->Realize();
115 }
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
wxTextCtrl * m_tcFilterString
#define SAVE_HLP_MSG
wxAuiToolBar * m_mainToolBar
void CVPCB_MAINFRAME::ReCreateMenuBar ( void  )
overridevirtual

(Re)Create the menubar for the CvPcb mainframe

Reimplemented from EDA_BASE_FRAME.

Definition at line 43 of file cvpcb/menubar.cpp.

References AddMenuItem(), PGM_BASE::AddMenuLanguageList(), ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, ID_CVPCB_EQUFILES_LIST_EDIT, ID_CVPCB_LIB_TABLE_EDIT, ID_PREFERENCES_CONFIGURE_PATHS, KiBitmap(), and Pgm().

Referenced by CVPCB_MAINFRAME().

44 {
45  // Create the current menubar if it does not yet exist
46  wxMenuBar* menuBar = GetMenuBar();
47 
48  if( ! menuBar ) // Delete all menus
49  menuBar = new wxMenuBar();
50 
51  // Delete all existing menus so they can be rebuilt.
52  // This allows language changes of the menu text on the fly.
53  menuBar->Freeze();
54 
55  while( menuBar->GetMenuCount() )
56  delete menuBar->Remove( 0 );
57 
58  // Recreate all menus:
59 
60  // Menu File:
61  wxMenu* filesMenu = new wxMenu;
62 
63  // Save the footprints back into eeschema
64  AddMenuItem( filesMenu, wxID_SAVE,
65  _( "&Save Footprint Associations\tCtrl+S" ),
66  _( "Save footprint association in schematic component footprint fields" ),
67  KiBitmap( save_xpm ) );
68 
69  // Separator
70  filesMenu->AppendSeparator();
71 
72  // Quit
73  AddMenuItem( filesMenu, wxID_EXIT,
74  _( "&Close" ), _( "Close CvPcb" ),
75  KiBitmap( exit_xpm ) );
76 
77  // Preferences Menu :
78  wxMenu* preferencesMenu = new wxMenu;
79 
80  AddMenuItem( preferencesMenu, ID_CVPCB_LIB_TABLE_EDIT,
81  _( "Footprint Li&braries" ), _( "Configure footprint libraries" ),
82  KiBitmap( library_table_xpm ) );
83 
84  // Path configuration edit dialog.
85  AddMenuItem( preferencesMenu,
87  _( "Configure Pa&ths" ),
88  _( "Edit path configuration environment variables" ),
89  KiBitmap( editor_xpm ) );
90 
91  preferencesMenu->AppendSeparator();
92  AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
93  _( "&Edit Footprint Association File" ),
94  _( "Modify footprint association file (.equ). This is the file which "
95  "assigns the footprint name by the component value" ),
96  KiBitmap( library_table_xpm ) );
97  preferencesMenu->AppendSeparator();
98 
99  // Language submenu
100  Pgm().AddMenuLanguageList( preferencesMenu );
101 
102  // Keep open on save data
103  preferencesMenu->AppendSeparator();
105  _( "&Keep Open On Save" ),
106  _( "Prevent CvPcb from exiting after saving netlist file" ),
107  KiBitmap( exit_xpm ),
108  wxITEM_CHECK );
109 
110  // Menu Help:
111  wxMenu* helpMenu = new wxMenu;
112 
113  // Manual Contents
114  AddMenuItem( helpMenu, wxID_HELP, _( "CvPcb &Manual" ),
115  _( "Open CvPcb Manual" ),
116  KiBitmap( online_help_xpm ) );
117 
118  AddMenuItem( helpMenu,
119  wxID_INDEX,
120  _( "&Getting Started in KiCad" ),
121  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
122  KiBitmap( help_xpm ) );
123 
124  // About CvPcb
125  AddMenuItem( helpMenu, wxID_ABOUT,
126  _( "&About Kicad" ),
127  _( "About KiCad" ),
128  KiBitmap( info_xpm ) );
129 
130  // Create the menubar and append all submenus
131  menuBar->Append( filesMenu, _( "&Save" ) );
132  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
133  menuBar->Append( helpMenu, _( "&Help" ) );
134 
135  menuBar->Thaw();
136 
137  // Associate the menu bar with the frame, if no previous menubar
138  if( GetMenuBar() == NULL )
139  SetMenuBar( menuBar );
140  else
141  menuBar->Refresh();
142 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
VTBL_ENTRY void AddMenuLanguageList(wxMenu *MasterMenu)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
Definition: pgm_base.cpp:816
void CVPCB_MAINFRAME::refreshAfterComponentSearch ( COMPONENT component)
private

Definition at line 493 of file cvpcb_mainframe.cpp.

References CreateScreenCmp(), DisplayStatus(), LIB_ID::Format(), FROM_UTF8(), FOOTPRINTS_LISTBOX::GetCount(), GetFootprintViewerFrame(), COMPONENT::GetFPID(), ITEMS_LISTBOX_BASE::GetSelection(), EDA_BASE_FRAME::m_auimgr, m_compListBox, m_footprintListBox, m_libListBox, FOOTPRINTS_LISTBOX::OnGetItemText(), SendMessageToEESCHEMA(), and FOOTPRINTS_LISTBOX::SetSelection().

Referenced by OnSelectComponent().

494 {
495  // Tell AuiMgr that objects are changed !
496  if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
497  // (could be not the case when starting CvPcb
498  m_auimgr.Update();
499 
500  if( component == NULL )
501  return;
502 
503  // Preview of the already assigned footprint.
504  // Find the footprint that was already chosen for this component and select it,
505  // but only if the selection is made from the component list or the library list.
506  // If the selection is made from the footprint list, do not change the current
507  // selected footprint.
508  if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
509  {
510  wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );
511 
512  bool found = false;
513 
514  for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
515  {
516  wxString footprintName;
517  wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
518  msg.Trim( true );
519  msg.Trim( false );
520  footprintName = msg.AfterFirst( wxChar( ' ' ) );
521 
522  if( module.Cmp( footprintName ) == 0 )
523  {
524  m_footprintListBox->SetSelection( ii, true );
525  found = true;
526  break;
527  }
528  }
529 
530  if( !found )
531  {
532  int ii = m_footprintListBox->GetSelection();
533 
534  if ( ii >= 0 )
535  m_footprintListBox->SetSelection( ii, false );
536 
538  {
539  CreateScreenCmp();
540  }
541  }
542  }
543 
545  DisplayStatus();
546 }
void SendMessageToEESCHEMA()
Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "r...
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
COMPONENTS_LISTBOX * m_compListBox
wxAuiManager m_auimgr
Definition: wxstruct.h:139
void CreateScreenCmp()
Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display f...
wxString OnGetItemText(long item, long column) const override
Function OnGetItemText this overloaded function MUST be provided for the wxLC_VIRTUAL mode because re...
LIBRARY_LISTBOX * m_libListBox
void SetSelection(int index, bool State=true)
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame()
FOOTPRINTS_LISTBOX * m_footprintListBox
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void CVPCB_MAINFRAME::SaveFootprintAssociation ( )

Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eeschema via the kiway.

Definition at line 370 of file readwrite_dlgs.cpp.

References KIWAY::ExpressMail(), NETLIST::FormatBackAnnotation(), FRAME_SCH, STRING_FORMATTER::GetString(), KIWAY_HOLDER::Kiway(), m_netlist, and MAIL_BACKANNOTATE_FOOTPRINTS.

Referenced by OnCloseWindow(), and SaveQuitCvpcb().

371 {
372  STRING_FORMATTER sf;
373 
375 
377 
378  SetStatusText( _("Footprint association sent to Eeschema") );
379 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
CVPCB->SCH footprint stuffing at cvpcb termination.
Definition: mail_type.h:40
const std::string & GetString()
Definition: richio.h:475
void FormatBackAnnotation(OUTPUTFORMATTER *aOut)
Definition: pcb_netlist.h:346
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, const std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:387
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
void CVPCB_MAINFRAME::SaveProjectFile ( )

Function SaveProjectFile Saves the CvPcb configuration parameter from the project (.pro) file aFileName.

Definition at line 70 of file cfg.cpp.

References PROJECT::ConfigSave(), GetProjectFileParameters(), PROJECT::GetProjectFullName(), GROUP_CVP, EDA_BASE_FRAME::IsWritable(), Kiface(), and KIWAY_HOLDER::Prj().

Referenced by DIALOG_CONFIG_EQUFILES::OnOkClick().

71 {
72  PROJECT& prj = Prj();
73  wxFileName fn = prj.GetProjectFullName();
74 
75  if( !IsWritable( fn ) )
76  {
77  wxMessageBox( _( "Project file '%s' is not writable" ), fn.GetFullPath() );
78  return;
79  }
80 
81  wxString pro_name = fn.GetFullPath();
82 
83  prj.ConfigSave( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters(), pro_name );
84 }
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:307
Class PROJECT holds project specific data.
Definition: project.h:52
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:532
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
#define GROUP_CVP
Definition: config_params.h:52
PARAM_CFG_ARRAY & GetProjectFileParameters(void)
Function GetProjectFileParameters return project file parameter list for CvPcb.
Definition: cfg.cpp:45
virtual void EDA_BASE_FRAME::SaveProjectSettings ( bool  aAskForSave)
inlinevirtualinherited

Function SaveProjectSettings saves changes to the project settings to the project (.pro) file.

The method is virtual so you can override it to call the suitable save method. The base method do nothing

Parameters
aAskForSave= true to open a dialog before saving the settings

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 269 of file wxstruct.h.

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick().

269 {};
void CVPCB_MAINFRAME::SaveQuitCvpcb ( wxCommandEvent &  event)

Definition at line 364 of file cvpcb_mainframe.cpp.

References m_keepCvpcbOpen, m_modified, and SaveFootprintAssociation().

365 {
367 
368  m_modified = false;
369 
370  if( !m_keepCvpcbOpen )
371  Close( true );
372 }
void SaveFootprintAssociation()
Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eesc...
void CVPCB_MAINFRAME::SaveSettings ( wxConfigBase *  aCfg)
overridevirtual

Function SaveSettings saves common frame parameters to a configuration data file.

Don't forget to call the base class's SaveSettings() from your derived SaveSettings() otherwise the frames won't remember their positions and sizes.

Reimplemented from EDA_BASE_FRAME.

Definition at line 224 of file cvpcb_mainframe.cpp.

References FilterFootprintEntry, FootprintDocFileEntry, KeepCvpcbOpenEntry, m_DocModulesFileName, m_filteringOptions, m_keepCvpcbOpen, and EDA_BASE_FRAME::SaveSettings().

225 {
227 
228  aCfg->Write( KeepCvpcbOpenEntry, m_keepCvpcbOpen );
231 }
wxString m_DocModulesFileName
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: basicframe.cpp:316
static const wxString FootprintDocFileEntry
static const wxString FilterFootprintEntry
static const wxString KeepCvpcbOpenEntry
Nonzero iff cvpcb should be kept open after saving files.
void CVPCB_MAINFRAME::SendMessageToEESCHEMA ( )

Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "reference" put cursor on component anchor.

Definition at line 767 of file cvpcb_mainframe.cpp.

References KIWAY::ExpressMail(), FRAME_SCH, NETLIST::GetComponent(), COMPONENT::GetReference(), ITEMS_LISTBOX_BASE::GetSelection(), NETLIST::IsEmpty(), Kiface(), KIWAY_HOLDER::Kiway(), m_compListBox, m_netlist, MAIL_CROSS_PROBE, MSG_TO_SCH, SendCommand(), StrPrintf(), and TO_UTF8.

Referenced by refreshAfterComponentSearch(), ToFirstNA(), and ToPreviousNA().

768 {
769  if( m_netlist.IsEmpty() )
770  return;
771 
772  int selection = m_compListBox->GetSelection();
773 
774  if ( selection < 0 )
775  selection = 0;
776 
777  if( m_netlist.GetComponent( selection ) == NULL )
778  return;
779 
780  COMPONENT* component = m_netlist.GetComponent( selection );
781 
782  std::string packet = StrPrintf( "$PART: \"%s\"", TO_UTF8( component->GetReference() ) );
783 
784  if( Kiface().IsSingle() )
785  SendCommand( MSG_TO_SCH, packet.c_str() );
786  else
787  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
788 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
COMPONENTS_LISTBOX * m_compListBox
#define MSG_TO_SCH
Definition: eda_dde.h:46
bool SendCommand(int service, const char *cmdline)
Definition: eda_dde.cpp:134
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:235
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
int StrPrintf(std::string *result, const char *format,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:75
const wxString & GetReference() const
Definition: pcb_netlist.h:149
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, const std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:387
PCB<->SCH, CVPCB->SCH cross-probing.
Definition: mail_type.h:39
void EDA_BASE_FRAME::SetAutoSaveInterval ( int  aInterval)
inherited

Definition at line 205 of file basicframe.cpp.

References EDA_BASE_FRAME::m_autoSaveInterval, EDA_BASE_FRAME::m_autoSaveState, and EDA_BASE_FRAME::m_autoSaveTimer.

Referenced by DIALOG_GENERALOPTIONS::OnOkClick(), and SCH_EDIT_FRAME::OnPreferencesOptions().

206 {
207  m_autoSaveInterval = aInterval;
208 
209  if( m_autoSaveTimer->IsRunning() )
210  {
211  if( m_autoSaveInterval > 0 )
212  {
213  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
214  }
215  else
216  {
217  m_autoSaveTimer->Stop();
218  m_autoSaveState = false;
219  }
220  }
221 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:145
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:151
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

Function SetKiway.

Parameters
aDestis the recipient of aKiway pointer. It is only used for debugging, since "this" is not a wxWindow*. "this" is a KIWAY_HOLDER mix-in.
aKiwayis often from a parent window, or from KIFACE::CreateWindow().

Definition at line 41 of file kiway_holder.cpp.

References KIWAY_HOLDER::m_kiway, and name.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

42 {
43 #if defined(DEBUG)
44  // offer a trap point for debugging most any window
45  wxASSERT( aDest );
46  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
47  {
48  int breakhere=1;
49  (void) breakhere;
50  }
51 #endif
52 
53  (void) aDest;
54 
55  m_kiway = aKiway;
56 }
KIWAY * m_kiway
Definition: kiway_player.h:85
const char * name
void KIWAY_PLAYER::SetModal ( bool  aIsModal)
inlineprotectedinherited

Definition at line 217 of file kiway_player.h.

References KIWAY_PLAYER::m_modal.

217 { m_modal = aIsModal; }
void EDA_BASE_FRAME::SetMruPath ( const wxString &  aPath)
inlineinherited

Definition at line 356 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ExportHotkeyConfigToFile(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), and KICAD_MANAGER_FRAME::OnLoadProject().

356 { m_mruPath = aPath; }
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:155
void CVPCB_MAINFRAME::SetNewPkg ( const wxString &  aFootprintName)

Function SetNewPkg links the footprint to the current selected component and selects the next component.

Parameters
aFootprintName= the selected footprint

Definition at line 47 of file readwrite_dlgs.cpp.

References CMP_FORMAT, DisplayStatus(), LIB_ID::empty(), LIB_ID::Format(), Format(), FROM_UTF8(), GetChars(), NETLIST::GetComponent(), COMPONENTS_LISTBOX::GetCount(), COMPONENT::GetFPID(), COMPONENT::GetReference(), COMPONENT::GetValue(), NETLIST::IsEmpty(), m_compListBox, m_modified, m_netlist, m_undefinedComponentCnt, LIB_ID::Parse(), COMPONENT::SetFPID(), COMPONENTS_LISTBOX::SetSelection(), COMPONENTS_LISTBOX::SetString(), and TO_UTF8.

Referenced by AutomaticFootprintMatching(), DelAssociations(), and FOOTPRINTS_LISTBOX::OnLeftDClick().

48 {
49  COMPONENT* component;
50  bool hasFootprint = false;
51  int componentIndex;
52 
53  if( m_netlist.IsEmpty() )
54  return;
55 
56  // If no component is selected, select the first one
57  if( m_compListBox->GetFirstSelected() < 0 )
58  {
59  componentIndex = 0;
60  m_compListBox->SetSelection( componentIndex, true );
61  }
62 
63  // iterate over the selection
64  while( m_compListBox->GetFirstSelected() != -1 )
65  {
66  // Get the component for the current iteration
67  componentIndex = m_compListBox->GetFirstSelected();
68  component = m_netlist.GetComponent( componentIndex );
69 
70  if( component == NULL )
71  return;
72 
73  // Check to see if the component has already a footprint set.
74  hasFootprint = !component->GetFPID().empty();
75 
76  LIB_ID fpid;
77 
78  if( !aFootprintName.IsEmpty() )
79  {
80  wxCHECK_RET( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0,
81  wxString::Format( wxT( "<%s> is not a valid LIB_ID." ),
82  GetChars( aFootprintName ) ) );
83  }
84 
85  component->SetFPID( fpid );
86 
87  // create the new component description
88  wxString description = wxString::Format( CMP_FORMAT, componentIndex + 1,
89  GetChars( component->GetReference() ),
90  GetChars( component->GetValue() ),
91  GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
92 
93  // If the component hasn't had a footprint associated with it
94  // it now has, so we decrement the count of components without
95  // a footprint assigned.
96  if( !hasFootprint )
98 
99  // Set the new description and deselect the processed component
100  m_compListBox->SetString( componentIndex, description );
101  m_compListBox->SetSelection( componentIndex, false );
102  }
103 
104  // Mark this "session" as modified
105  m_modified = true;
106 
107  // select the next component, if there is one
108  if( componentIndex < (m_compListBox->GetCount() - 1) )
109  componentIndex++;
110 
111  m_compListBox->SetSelection( componentIndex, true );
112 
113  // update the statusbar
114  DisplayStatus();
115 }
bool empty() const
Function empty.
Definition: lib_id.h:199
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:153
COMPONENTS_LISTBOX * m_compListBox
void SetSelection(int index, bool State=true)
int Parse(const UTF8 &aId)
Function Parse.
Definition: lib_id.cpp:122
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:235
Class LIB_ID.
Definition: lib_id.h:56
const wxString & GetReference() const
Definition: pcb_netlist.h:149
const wxString & GetValue() const
Definition: pcb_netlist.h:151
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
#define CMP_FORMAT
Definition: cvpcb.h:32
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetString(unsigned linecount, const wxString &text)
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void EDA_BASE_FRAME::ShowChangedIcons ( )
virtualinherited

Function ShowChangedIcons redraws items menus after a icon was changed option.

Definition at line 249 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by KIWAY::ShowChangedIcons().

250 {
251  ReCreateMenuBar();
252  GetMenuBar()->Refresh();
253 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
void EDA_BASE_FRAME::ShowChangedLanguage ( )
virtualinherited

Function ShowChangedLanguage redraws the menus and what not in current language.

Reimplemented in PCB_EDIT_FRAME, and GERBVIEW_FRAME.

Definition at line 242 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by KIWAY::SetLanguage(), GERBVIEW_FRAME::ShowChangedLanguage(), and PCB_EDIT_FRAME::ShowChangedLanguage().

243 {
244  ReCreateMenuBar();
245  GetMenuBar()->Refresh();
246 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
bool KIWAY_PLAYER::ShowModal ( wxString *  aResult = NULL,
wxWindow *  aResultantFocusWindow = NULL 
)
inherited

Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until this KIWAY_PLAYER derivative calls DismissModal().

That is, behavior is similar to a modal dialog window. Not all KIWAY_PLAYERs use this interface, so don't call this unless the implementation knows how to call DismissModal() on a button click or double click or some special event which ends the modal behavior.

Parameters
aResultif not NULL, indicates a place to put a resultant string.
aResultantFocusWindowif not NULL, indicates what window to pass focus to on return.
Returns
bool - true if frame implementation called KIWAY_PLAYER::DismissModal() with aRetVal of true.

Definition at line 81 of file kiway_player.cpp.

References DBG, EDA_BASE_FRAME::Enable(), KIWAY_PLAYER::IsModal(), KIWAY_PLAYER::m_modal_loop, KIWAY_PLAYER::m_modal_resultant_parent, KIWAY_PLAYER::m_modal_ret_val, KIWAY_PLAYER::m_modal_string, TO_UTF8, and WX_EVENT_LOOP.

Referenced by DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), PCB_BASE_FRAME::SelectFootprintFromLibBrowser(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler(), and DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint().

82 {
83  wxASSERT_MSG( IsModal(), wxT( "ShowModal() shouldn't be called on non-modal frame" ) );
84 
85  /*
86  This function has a nice interface but a necessarily unsightly implementation.
87  Now the implementation is encapsulated, localizing future changes.
88 
89  It works in tandem with DismissModal(). But only ShowModal() is in the
90  vtable and therefore cross-module capable.
91  */
92 
93  // This is an exception safe way to zero a pointer before returning.
94  // Yes, even though DismissModal() clears this first normally, this is
95  // here in case there's an exception before the dialog is dismissed.
96  struct NULLER
97  {
98  void*& m_what;
99  NULLER( void*& aPtr ) : m_what( aPtr ) {}
100  ~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
101  } clear_this( (void*&) m_modal_loop );
102 
103 
104  m_modal_resultant_parent = aResultantFocusWindow;
105 
106  Show( true );
107  Raise(); // Needed on some Window managers to always display the frame
108 
109  SetFocus();
110 
111  {
112  // We have to disable all frames but the the modal one.
113  // wxWindowDisabler does that, but it also disables all top level windows
114  // We do not want to disable top level windows which are child of the modal one,
115  // if they are enabled.
116  // An example is an aui toolbar which was moved
117  // or a dialog or an other frame or miniframe opened by the modal one.
118  wxWindowList wlist = GetChildren();
119  std::vector<wxWindow*> enabledTopLevelWindows;
120 
121  for( unsigned ii = 0; ii < wlist.size(); ii++ )
122  if( wlist[ii]->IsTopLevel() && wlist[ii]->IsEnabled() )
123  enabledTopLevelWindows.push_back( wlist[ii] );
124 
125  // exception safe way to disable all top level windows except the modal one,
126  // re-enables only those that were disabled on exit
127  wxWindowDisabler toggle( this );
128 
129  for( unsigned ii = 0; ii < enabledTopLevelWindows.size(); ii++ )
130  enabledTopLevelWindows[ii]->Enable( true );
131 
132  WX_EVENT_LOOP event_loop;
133  m_modal_loop = &event_loop;
134  event_loop.Run();
135 
136  } // End of scope for some variables.
137  // End nesting before setting focus below.
138 
139  if( aResult )
140  *aResult = m_modal_string;
141 
142  DBG(printf( "~%s: aResult:'%s' ret:%d\n",
143  __func__, TO_UTF8( m_modal_string ), m_modal_ret_val );)
144 
145  if( aResultantFocusWindow )
146  {
147  aResultantFocusWindow->Raise();
148 
149  // have the final say, after wxWindowDisabler reenables my parent and
150  // the events settle down, set the focus
151  wxSafeYield();
152  aResultantFocusWindow->SetFocus();
153  }
154 
155  return m_modal_ret_val;
156 }
bool m_modal_ret_val
Definition: kiway_player.h:250
#define WX_EVENT_LOOP
Definition: kiway_player.h:91
wxWindow * m_modal_resultant_parent
Definition: kiway_player.h:248
wxString m_modal_string
Definition: kiway_player.h:249
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
bool Enable(bool enable) override
Definition: basicframe.cpp:192
bool IsModal()
Definition: kiway_player.h:216
WX_EVENT_LOOP * m_modal_loop
Definition: kiway_player.h:247
#define DBG(x)
Definition: fctsys.h:33
const SEARCH_STACK & EDA_BASE_FRAME::sys_search ( )
protectedvirtualinherited

Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 370 of file basicframe.cpp.

References Kiface(), and KIFACE_I::KifaceSearch().

Referenced by EDA_BASE_FRAME::GetKicadHelp().

371 {
372  return Kiface().KifaceSearch();
373 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:125
void CVPCB_MAINFRAME::ToFirstNA ( wxCommandEvent &  event)

Definition at line 304 of file cvpcb_mainframe.cpp.

References ITEMS_LISTBOX_BASE::DeselectAll(), LIB_ID::empty(), NETLIST::GetComponent(), NETLIST::GetCount(), COMPONENT::GetFPID(), NETLIST::IsEmpty(), m_compListBox, m_netlist, SendMessageToEESCHEMA(), and COMPONENTS_LISTBOX::SetSelection().

305 {
306  if( m_netlist.IsEmpty() )
307  return;
308 
309  long first_selected = m_compListBox->GetFirstSelected();
310 
311  if( first_selected < 0 )
312  first_selected = -1; // We will start to 0 for the first search , if no item selected
313 
314  int candidate = -1;
315 
316  for( unsigned jj = first_selected+1; jj < m_netlist.GetCount(); jj++ )
317  {
318  if( m_netlist.GetComponent( jj )->GetFPID().empty() )
319  {
320  candidate = jj;
321  break;
322  }
323  }
324 
325  if( candidate >= 0 )
326  {
328  m_compListBox->SetSelection( candidate );
330  }
331 }
void SendMessageToEESCHEMA()
Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "r...
bool empty() const
Function empty.
Definition: lib_id.h:199
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
COMPONENTS_LISTBOX * m_compListBox
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
Definition: listboxes.cpp:112
void SetSelection(int index, bool State=true)
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:235
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:247
void CVPCB_MAINFRAME::ToPreviousNA ( wxCommandEvent &  event)

Definition at line 334 of file cvpcb_mainframe.cpp.

References ITEMS_LISTBOX_BASE::DeselectAll(), LIB_ID::empty(), NETLIST::GetComponent(), COMPONENTS_LISTBOX::GetCount(), COMPONENT::GetFPID(), NETLIST::IsEmpty(), m_compListBox, m_netlist, SendMessageToEESCHEMA(), and COMPONENTS_LISTBOX::SetSelection().

335 {
336  if( m_netlist.IsEmpty() )
337  return;
338 
339  int first_selected = m_compListBox->GetFirstSelected();
340 
341  if( first_selected < 0 )
342  first_selected = m_compListBox->GetCount();
343 
344  int candidate = -1;
345 
346  for( int jj = first_selected-1; jj >= 0; jj-- )
347  {
348  if( m_netlist.GetComponent( jj )->GetFPID().empty() )
349  {
350  candidate = jj;
351  break;
352  }
353  }
354 
355  if( candidate >= 0 )
356  {
358  m_compListBox->SetSelection( candidate );
360  }
361 }
void SendMessageToEESCHEMA()
Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "r...
bool empty() const
Function empty.
Definition: lib_id.h:199
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:164
COMPONENTS_LISTBOX * m_compListBox
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
Definition: listboxes.cpp:112
void SetSelection(int index, bool State=true)
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:235
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:256
void EDA_BASE_FRAME::UpdateFileHistory ( const wxString &  FullFileName,
wxFileHistory *  aFileHistory = NULL 
)
inherited

Function UpdateFileHistory Updates the list of recently opened files.

Note also the menu is updated, if wxFileHistory::UseMenu was called at init time

Parameters
FullFileNameThe full file name including the path.
aFileHistoryThe wxFileHistory in use. If NULL, the main application file history is used.

Definition at line 388 of file basicframe.cpp.

References KIFACE_I::GetFileHistory(), and Kiface().

Referenced by GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::LoadGerberFiles(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), KICAD_MANAGER_FRAME::OnCloseWindow(), KICAD_MANAGER_FRAME::OnLoadProject(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::SavePcbFile(), and GERBVIEW_FRAME::unarchiveFiles().

390 {
391  wxFileHistory* fileHistory = aFileHistory;
392 
393  if( !fileHistory )
394  fileHistory = &Kiface().GetFileHistory();
395 
396  fileHistory->AddFileToHistory( FullFileName );
397 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:121
void CVPCB_MAINFRAME::UpdateTitle ( )

Function UpdateTitle sets the main window title bar text.

If no current project open( eeschema run outside kicad manager with no schematic loaded), the title is set to the application name appended with "no project". Otherwise, the title shows the project name.

Definition at line 744 of file cvpcb_mainframe.cpp.

References PROJECT::GetProjectFullName(), and KIWAY_HOLDER::Prj().

Referenced by CVPCB_MAINFRAME(), and ReadNetListAndLinkFiles().

745 {
746  wxString title;
747  PROJECT& prj = Prj();
748  wxFileName fn = prj.GetProjectFullName();
749 
750  if( fn.IsOk() && !prj.GetProjectFullName().IsEmpty() && fn.FileExists() )
751  {
752  title.Printf( L"Cvpcb \u2014 %s%s",
753  fn.GetFullPath(),
754  fn.IsFileWritable()
755  ? wxString( wxEmptyString )
756  : _( " [Read Only]" ) );
757  }
758  else
759  {
760  title = "Cvpcb";
761  }
762 
763  SetTitle( title );
764 }
Class PROJECT holds project specific data.
Definition: project.h:52
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
int EDA_BASE_FRAME::WriteHotkeyConfig ( struct EDA_HOTKEY_CONFIG aDescList,
wxString *  aFullFileName = NULL 
)
virtualinherited

Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mechanism or a file.

Parameters
aDescList= pointer to the current hotkey list.
aFullFileName= a wxString pointer to a full file name. if NULL, use the standard wxConfig mechanism (default) the output format is: shortcut "key" "function" lines starting with # are comments

Reimplemented in EDA_DRAW_FRAME.

Definition at line 534 of file hotkeys_basic.cpp.

References AddDelimiterString(), EDA_BASE_FRAME::config(), DEFAULT_HOTKEY_FILENAME_EXT, GetChars(), GetNewConfig(), HOTKEYS_CONFIG_KEY, KeyNameFromKeyCode(), EDA_HOTKEY_CONFIG::m_HK_InfoList, EDA_HOTKEY::m_InfoMsg, EDA_HOTKEY::m_KeyCode, EDA_HOTKEY_CONFIG::m_SectionTag, EDA_HOTKEY_CONFIG::m_Title, and TO_UTF8.

Referenced by EDA_BASE_FRAME::ExportHotkeyConfigToFile(), HOTKEYS_EDITOR_DIALOG::TransferDataFromWindow(), and EDA_DRAW_FRAME::WriteHotkeyConfig().

536 {
537  wxString msg;
538  wxString keyname, infokey;
539 
540  msg = wxT( "$hotkey list\n" );
541 
542  // Print the current hotkey list
543  EDA_HOTKEY** list;
544 
545  for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
546  {
547  if( aDescList->m_Title )
548  {
549  msg += wxT( "# " );
550  msg += *aDescList->m_Title;
551  msg += wxT( "\n" );
552  }
553 
554  msg += *aDescList->m_SectionTag;
555  msg += wxT( "\n" );
556 
557  list = aDescList->m_HK_InfoList;
558 
559  for( ; *list != NULL; list++ )
560  {
561  EDA_HOTKEY* hk_decr = *list;
562  msg += wxT( "shortcut " );
563  keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
564  AddDelimiterString( keyname );
565  infokey = hk_decr->m_InfoMsg;
566  AddDelimiterString( infokey );
567  msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
568  }
569  }
570 
571  msg += wxT( "$Endlist\n" );
572 
573  if( aFullFileName )
574  {
575  FILE* file = wxFopen( *aFullFileName, wxT( "wt" ) );
576 
577  if( file )
578  {
579  fputs( TO_UTF8( msg ), file );
580  fclose( file );
581  }
582  else
583  {
584  msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
585  return 0;
586  }
587  }
588  else
589  {
590  wxFileName fn( GetName() );
591  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
592  wxConfigBase* config = GetNewConfig( fn.GetFullPath() );
593  config->Write( HOTKEYS_CONFIG_KEY, msg );
594  delete config;
595  }
596 
597  return 1;
598 }
EDA_HOTKEY ** m_HK_InfoList
Definition: hotkeys_basic.h:91
wxConfigBase * GetNewConfig(const wxString &aProgName)
Function GetNewConfig.
Definition: common.cpp:205
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:361
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
#define HOTKEYS_CONFIG_KEY
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
wxString * m_SectionTag
Definition: hotkeys_basic.h:90
wxString m_InfoMsg
Definition: hotkeys_basic.h:64
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:57
wxString * m_Title
Definition: hotkeys_basic.h:92
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Function KeyNameFromKeyCode return the key name from the key code Only some wxWidgets key values are ...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34

Friends And Related Function Documentation

friend struct CV::IFACE
friend

Definition at line 59 of file cvpcb_mainframe.h.

Member Data Documentation

wxString EDA_BASE_FRAME::m_AboutTitle
protectedinherited

Name of program displayed in About.

Definition at line 137 of file wxstruct.h.

bool EDA_BASE_FRAME::m_autoSaveState
protectedinherited
wxTimer* EDA_BASE_FRAME::m_autoSaveTimer
protectedinherited
wxString EDA_BASE_FRAME::m_configFrameName
protectedinherited

prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTOR is used

Definition at line 132 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ConfigBaseName().

wxString CVPCB_MAINFRAME::m_currentSearchPattern
private
wxString CVPCB_MAINFRAME::m_DocModulesFileName

Definition at line 75 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), LoadSettings(), and SaveSettings().

wxArrayString CVPCB_MAINFRAME::m_EquFilesNames
wxArrayString CVPCB_MAINFRAME::m_footprintListEntries
private

Definition at line 61 of file cvpcb_mainframe.h.

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

Definition at line 142 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME(), EDA_BASE_FRAME::LoadSettings(), EDA_BASE_FRAME::ProcessEvent(), and EDA_BASE_FRAME::SaveSettings().

FRAME_T EDA_BASE_FRAME::m_Ident
protectedinherited

Id Type (pcb, schematic, library..)

Definition at line 128 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

bool CVPCB_MAINFRAME::m_keepCvpcbOpen
private
LIBRARY_LISTBOX* CVPCB_MAINFRAME::m_libListBox
private
wxAuiToolBar* CVPCB_MAINFRAME::m_mainToolBar
private

Definition at line 66 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), and ReCreateHToolbar().

bool KIWAY_PLAYER::m_modal
protectedinherited

Definition at line 246 of file kiway_player.h.

Referenced by KIWAY_PLAYER::IsModal(), and KIWAY_PLAYER::SetModal().

WX_EVENT_LOOP* KIWAY_PLAYER::m_modal_loop
protectedinherited
wxWindow* KIWAY_PLAYER::m_modal_resultant_parent
protectedinherited

Definition at line 248 of file kiway_player.h.

Referenced by KIWAY_PLAYER::ShowModal().

bool KIWAY_PLAYER::m_modal_ret_val
protectedinherited
wxString KIWAY_PLAYER::m_modal_string
protectedinherited

Definition at line 249 of file kiway_player.h.

Referenced by KIWAY_PLAYER::DismissModal(), and KIWAY_PLAYER::ShowModal().

bool CVPCB_MAINFRAME::m_modified
protected
wxArrayString CVPCB_MAINFRAME::m_ModuleLibNames

Definition at line 73 of file cvpcb_mainframe.h.

Referenced by LoadProjectFile().

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 153 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::LoadSettings().

PARAM_CFG_ARRAY CVPCB_MAINFRAME::m_projectFileParams
protected

Definition at line 83 of file cvpcb_mainframe.h.

Referenced by GetProjectFileParameters().

bool CVPCB_MAINFRAME::m_skipComponentSelect
protected
wxTextCtrl* CVPCB_MAINFRAME::m_tcFilterString
private
int CVPCB_MAINFRAME::m_undefinedComponentCnt
protected

The documentation for this class was generated from the following files: